| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * Asterisk -- An open source telephony toolkit. | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * Copyright (C) 1999 - 2005, Digium, Inc. | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-02-17 18:07:33 +00:00
										 |  |  |  * Mark Spencer <markster@digium.com> | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * See http://www.asterisk.org for more information about
 | 
					
						
							|  |  |  |  * the Asterisk project. Please do not directly contact | 
					
						
							|  |  |  |  * any of the maintainers of this project for assistance; | 
					
						
							|  |  |  |  * the project provides a web site, mailing lists and IRC | 
					
						
							|  |  |  |  * channels for your use. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  |  * This program is free software, distributed under the terms of | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * the GNU General Public License Version 2. See the LICENSE file | 
					
						
							|  |  |  |  * at the top of the source tree. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-24 20:12:06 +00:00
										 |  |  | /*! \file
 | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-10-24 20:12:06 +00:00
										 |  |  |  * \brief IVR Demo application | 
					
						
							| 
									
										
										
										
											2005-12-30 21:18:06 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * \author Mark Spencer <markster@digium.com> | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  *  | 
					
						
							| 
									
										
										
										
											2005-11-06 15:09:47 +00:00
										 |  |  |  * \ingroup applications | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-24 17:11:45 +00:00
										 |  |  | /*** MODULEINFO
 | 
					
						
							|  |  |  | 	<defaultenabled>no</defaultenabled> | 
					
						
							|  |  |  |  ***/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-07 18:54:56 +00:00
										 |  |  | #include "asterisk.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ASTERISK_FILE_VERSION(__FILE__, "$Revision$") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 19:47:56 +00:00
										 |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2005-06-06 22:39:32 +00:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <unistd.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-21 06:02:45 +00:00
										 |  |  | #include "asterisk/file.h"
 | 
					
						
							|  |  |  | #include "asterisk/logger.h"
 | 
					
						
							|  |  |  | #include "asterisk/channel.h"
 | 
					
						
							|  |  |  | #include "asterisk/pbx.h"
 | 
					
						
							|  |  |  | #include "asterisk/module.h"
 | 
					
						
							|  |  |  | #include "asterisk/lock.h"
 | 
					
						
							|  |  |  | #include "asterisk/app.h"
 | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static char *tdesc = "IVR Demo Application"; | 
					
						
							|  |  |  | static char *app = "IVRDemo"; | 
					
						
							|  |  |  | static char *synopsis =  | 
					
						
							|  |  |  | "  This is a skeleton application that shows you the basic structure to create your\n" | 
					
						
							|  |  |  | "own asterisk applications and demonstrates the IVR demo.\n"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int ivr_demo_func(struct ast_channel *chan, void *data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ast_verbose("IVR Demo, data is %s!\n", (char *)data); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-26 19:06:09 +00:00
										 |  |  | AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0,  | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-03-05 21:06:26 +00:00
										 |  |  | 	{ "s", AST_ACTION_BACKGROUND, "demo-abouttotry" }, | 
					
						
							|  |  |  | 	{ "s", AST_ACTION_WAITOPTION }, | 
					
						
							|  |  |  | 	{ "1", AST_ACTION_PLAYBACK, "digits/1" }, | 
					
						
							|  |  |  | 	{ "1", AST_ACTION_PLAYBACK, "digits/1" }, | 
					
						
							|  |  |  | 	{ "1", AST_ACTION_RESTART }, | 
					
						
							|  |  |  | 	{ "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" }, | 
					
						
							|  |  |  | 	{ "3", AST_ACTION_CALLBACK, ivr_demo_func }, | 
					
						
							|  |  |  | 	{ "4", AST_ACTION_TRANSFER, "demo|s|1" }, | 
					
						
							|  |  |  | 	{ "*", AST_ACTION_REPEAT }, | 
					
						
							|  |  |  | 	{ "#", AST_ACTION_UPONE  }, | 
					
						
							|  |  |  | 	{ NULL } | 
					
						
							| 
									
										
										
										
											2005-02-26 19:06:09 +00:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-26 19:06:09 +00:00
										 |  |  | AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0,  | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 	{ "s", AST_ACTION_BACKGROUND, "demo-congrats" }, | 
					
						
							|  |  |  | 	{ "g", AST_ACTION_BACKGROUND, "demo-instruct" }, | 
					
						
							|  |  |  | 	{ "g", AST_ACTION_WAITOPTION }, | 
					
						
							|  |  |  | 	{ "1", AST_ACTION_PLAYBACK, "digits/1" }, | 
					
						
							|  |  |  | 	{ "1", AST_ACTION_RESTART }, | 
					
						
							|  |  |  | 	{ "2", AST_ACTION_MENU, &ivr_submenu }, | 
					
						
							|  |  |  | 	{ "2", AST_ACTION_RESTART }, | 
					
						
							|  |  |  | 	{ "i", AST_ACTION_PLAYBACK, "invalid" }, | 
					
						
							| 
									
										
										
										
											2005-03-05 21:06:26 +00:00
										 |  |  | 	{ "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 }, | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 	{ "#", AST_ACTION_EXIT }, | 
					
						
							|  |  |  | 	{ NULL }, | 
					
						
							| 
									
										
										
										
											2005-02-26 19:06:09 +00:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int skel_exec(struct ast_channel *chan, void *data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int res=0; | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	struct ast_module_user *u; | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2005-10-26 19:48:14 +00:00
										 |  |  | 	if (ast_strlen_zero(data)) { | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 		ast_log(LOG_WARNING, "skel requires an argument (filename)\n"); | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	u = ast_module_user_add(chan); | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 	/* Do our thing here */ | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 	if (chan->_state != AST_STATE_UP) | 
					
						
							|  |  |  | 		res = ast_answer(chan); | 
					
						
							|  |  |  | 	if (!res) | 
					
						
							|  |  |  | 		res = ast_ivr_menu_run(chan, &ivr_demo, data); | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	ast_module_user_remove(u); | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | 	return res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int unload_module(void) | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2005-10-18 22:52:21 +00:00
										 |  |  | 	int res; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	res = ast_unregister_application(app); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 	ast_module_user_hangup_all(); | 
					
						
							| 
									
										
										
										
											2005-10-18 22:52:21 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	return res; | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int load_module(void) | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2005-03-12 05:37:32 +00:00
										 |  |  | 	return ast_register_application(app, skel_exec, tdesc, synopsis); | 
					
						
							| 
									
										
										
										
											2005-02-17 14:57:36 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "IVR Demo Application"); |