[Freeswitch-branches] [commit] r3339 - freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr

Freeswitch SVN knhor at freeswitch.org
Mon Nov 13 00:21:32 EST 2006


Author: knhor
Date: Mon Nov 13 00:21:31 2006
New Revision: 3339

Added:
   freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/
   freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/mod_ivr.c

Log:
initial commit of mod_ivr that uses switch_ivr_xml_menu_stack function


Added: freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/mod_ivr.c
==============================================================================
--- (empty file)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/mod_ivr.c	Mon Nov 13 00:21:31 2006
@@ -0,0 +1,105 @@
+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct at yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Neal Horman <neal at wanlink dot com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Neal Horman <neal at wanlink dot com>
+ *
+ *
+ * mod_ivr.c -- IVR application using core ivr functions
+ *
+ */
+#include <switch.h>
+
+static const char modname[] = "mod_ivr";
+static const char global_app_name[] = "ivr";
+static char *global_cf_name = "ivr.conf";
+
+static void ivr_application_function(switch_core_session_t *session, char *data);
+
+static const switch_application_interface_t ivr_application_interface = {
+	/*.interface_name */		global_app_name,
+	/*.application_function */	&ivr_application_function,
+					NULL,
+					NULL,
+					NULL,
+	/*.next */			NULL
+};
+
+static switch_loadable_module_interface_t skel_module_interface = {
+	/*.module_name */		modname,
+	/*.endpoint_interface */	NULL,
+	/*.timer_interface */		NULL,
+	/*.dialplan_interface */	NULL,
+	/*.codec_interface */		NULL,
+	/*.application_interface */	&ivr_application_interface,
+	/*.api_interface */		NULL,
+	/*.file_interface */		NULL,
+	/*.speech_interface */		NULL,
+	/*.directory_interface */	NULL,
+	/*.chat_interface */		NULL
+};
+
+static void ivr_application_function(switch_core_session_t *session, char *data)
+{
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	char *params = switch_core_session_strdup(session,data);
+
+	if (channel != NULL && params != NULL) {
+		switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
+
+		// Open the config from the xml registry
+		if ((cxml = switch_xml_open_cfg(global_cf_name, &cfg, NULL)) != NULL) {
+			switch_xml_free(cxml);
+			if ((xml_menus = switch_xml_child(cfg, "menus"))) {
+				xml_menu = switch_xml_find_child(xml_menus, "menu", "name", params);
+
+				// if the menu was found
+				if (xml_menu != NULL) {
+					switch_ivr_menu_t *menu_stack = NULL;
+
+					// build a menu tree and execute it
+					if (switch_ivr_build_xml_menu_stack(&menu_stack,xml_menus,xml_menu,NULL) == SWITCH_STATUS_SUCCESS) {
+						switch_channel_answer(channel);
+						switch_ivr_menu_execute(session,menu_stack,params,NULL);
+					} else {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu '%s'\n", params);
+					}
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find menu '%s'\n", params);
+				}
+			}
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
+		}
+	}
+}
+
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
+{
+	/* connect my internal structure to the blank pointer passed to me */
+	*module_interface = &skel_module_interface;
+
+	/* indicate that the module should continue to be loaded */
+	return SWITCH_STATUS_SUCCESS;
+}



More information about the Freeswitch-branches mailing list