Skip to content

Instantly share code, notes, and snippets.

@seven1240
Created July 2, 2013 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seven1240/5907525 to your computer and use it in GitHub Desktop.
Save seven1240/5907525 to your computer and use it in GitHub Desktop.
Makefile: include ../../../../build/modmake.rules
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2012, Anthony Minessale II <anthm@freeswitch.org>
*
* 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
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
* Neal Horman <neal at wanlink dot com>
*
*
* mod_my_dialplan.c -- Framework Demo Module
*
*/
#include <switch.h>
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_my_dialplan_shutdown);
/*
SWITCH_MODULE_RUNTIME_FUNCTION(mod_my_dialplan_runtime);
*/
SWITCH_MODULE_LOAD_FUNCTION(mod_my_dialplan_load);
SWITCH_MODULE_DEFINITION(mod_my_dialplan, mod_my_dialplan_load, mod_my_dialplan_shutdown, NULL);
SWITCH_STANDARD_DIALPLAN(dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
// char *alt_path = (char *) arg;
// const char *hunt = NULL;
if (!caller_profile) {
if (!(caller_profile = switch_channel_get_caller_profile(channel))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
goto done;
}
}
if (!caller_profile->context) {
caller_profile->context = "default";
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "MyProcessing %s <%s>->%s in context %s\n",
caller_profile->caller_id_name, caller_profile->caller_id_number, caller_profile->destination_number, caller_profile->context);
if ((extension = switch_caller_extension_new(session, "exten_name", caller_profile->destination_number)) == 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Memory Error!\n");
goto done;
}
switch_caller_extension_add_application(session, extension, "info", NULL);
switch_caller_extension_add_application(session, extension, "log", "ERR extension from my dialplan");
switch_caller_extension_add_application(session, extension, "answer", NULL);
switch_caller_extension_add_application(session, extension, "my_app", "-------------------------------blah");
switch_caller_extension_add_application(session, extension, "echo", NULL);
done:
return extension;
}
SWITCH_STANDARD_APP(my_function)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", data);
// switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
}
SWITCH_MODULE_LOAD_FUNCTION(mod_my_dialplan_load)
{
switch_dialplan_interface_t *dp_interface;
switch_application_interface_t *app_interface;
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_DIALPLAN(dp_interface, "MYDP", dialplan_hunt);
SWITCH_ADD_APP(app_interface, "my_app", "myapp", "", my_function, "", SAF_NONE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
// Called when the system shuts down
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_my_dialplan_shutdown)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Bye World!\n");
return SWITCH_STATUS_SUCCESS;
}
/*
If it exists, this is called in it's own thread when the module-load completes
If it returns anything but SWITCH_STATUS_TERM it will be called again automaticly
SWITCH_MODULE_RUNTIME_FUNCTION(mod_my_dialplan_runtime);
{
while(looping)
{
switch_yield(1000);
}
return SWITCH_STATUS_TERM;
}
*/
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:nil
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet expandtab:
*/
@seven1240
Copy link
Author

internal.xml:

<param name="dialplan" value="MYDP"/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment