break some more stuff

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1319 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-05-02 17:42:24 +00:00
parent 397bf1bffc
commit ccab39a2e7
5 changed files with 41 additions and 30 deletions

View File

@ -46,7 +46,7 @@ load => mod_commands
;load => mod_commands ;load => mod_commands
; Dialplan Interfaces ; Dialplan Interfaces
load => mod_dialplan_demo load => mod_dialplan_flatfile
;load => mod_dialplan_directory ;load => mod_dialplan_directory
load => mod_pcre load => mod_pcre
@ -96,7 +96,7 @@ level => debug,info,warning-alert
debug => 0 debug => 0
;ip => 1.2.3.4 ;ip => 1.2.3.4
port => 4569 port => 4569
dialplan => demo dialplan => flatfile
codec_prefs => PCMU,PCMA,speex,L16 codec_prefs => PCMU,PCMA,speex,L16
codec_master => us codec_master => us
codec_rates=8 codec_rates=8
@ -176,7 +176,7 @@ debug=0
[+portaudio.conf] [+portaudio.conf]
[settings] [settings]
debug => 2 debug => 2
dialplan => demo dialplan => flatfile
; partial string match on something in the name or the device # ; partial string match on something in the name or the device #
indev => USB indev => USB
@ -238,7 +238,7 @@ base => dc=freeswitch,dc=org
;---- BASIC EXTENSIONS ;---- BASIC EXTENSIONS
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
[+extensions.conf] [+extensions.conf]
[extensions] [default]
1000 => playback /var/sounds/beep.raw 1000 => playback /var/sounds/beep.raw
@ -260,7 +260,7 @@ codec_prefs => PCMU
name => google name => google
login => myjabberid@myjabberserver.com/talk login => myjabberid@myjabberserver.com/talk
password => mypass password => mypass
dialplan => demo dialplan => flatfile
message => Jingle all the way message => Jingle all the way
rtp-ip => 0.0.0.0 rtp-ip => 0.0.0.0
auto-login => true auto-login => true

View File

@ -14,7 +14,7 @@ codecs/mod_gsm
#codecs/mod_ilbc #codecs/mod_ilbc
codecs/mod_l16 codecs/mod_l16
#codecs/mod_speex #codecs/mod_speex
dialplans/mod_dialplan_demo dialplans/mod_dialplan_flatfile
#dialplans/mod_dialplan_directory #dialplans/mod_dialplan_directory
dialplans/mod_pcre dialplans/mod_pcre
#directories/mod_ldap #directories/mod_ldap

View File

@ -116,7 +116,11 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
return NULL; return NULL;
} }
sprintf(filter, "exten=%s", caller_profile->destination_number); snprintf(filter, sizeof(filter), "exten=%s", caller_profile->destination_number);
if (caller_profile->context) {
snprintf(filter + strlen(filter), sizeof(filter) - strlen(filter), "context=%s", caller_profile->context);
}
switch_core_directory_query(&dh, globals.base, filter); switch_core_directory_query(&dh, globals.base, filter);
while (switch_core_directory_next(&dh) == SWITCH_STATUS_SUCCESS) { while (switch_core_directory_next(&dh) == SWITCH_STATUS_SUCCESS) {

View File

@ -26,7 +26,7 @@
* Anthony Minessale II <anthmct@yahoo.com> * Anthony Minessale II <anthmct@yahoo.com>
* *
* *
* mod_dialplan_demo.c -- Example Dialplan Module * mod_dialplan_flatfile.c -- Example Dialplan Module
* *
*/ */
#include <switch.h> #include <switch.h>
@ -35,22 +35,28 @@
#include <fcntl.h> #include <fcntl.h>
static const char modname[] = "mod_dialplan_demo"; static const char modname[] = "mod_dialplan_flatfile";
static switch_caller_extension_t *demo_dialplan_hunt(switch_core_session_t *session) static switch_caller_extension_t *flatfile_dialplan_hunt(switch_core_session_t *session)
{ {
switch_caller_profile_t *caller_profile; switch_caller_profile_t *caller_profile = NULL;
switch_caller_extension_t *extension = NULL; switch_caller_extension_t *extension = NULL;
switch_channel_t *channel; switch_channel_t *channel;
char *cf = "extensions.conf"; char *cf = "extensions.conf";
switch_config_t cfg; switch_config_t cfg;
char *var, *val; char *var, *val;
char app[1024]; char app[1024];
char *context = NULL;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
caller_profile = switch_channel_get_caller_profile(channel);
//switch_channel_set_variable(channel, "pleasework", "yay"); if ((caller_profile = switch_channel_get_caller_profile(channel))) {
context = caller_profile->context ? caller_profile->context : "default";
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
return NULL;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Hello %s You Dialed %s!\n", caller_profile->caller_id_name,
caller_profile->destination_number); caller_profile->destination_number);
@ -62,7 +68,7 @@ static switch_caller_extension_t *demo_dialplan_hunt(switch_core_session_t *sess
} }
while (switch_config_next_pair(&cfg, &var, &val)) { while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "extensions")) { if (!strcasecmp(cfg.category, context)) {
if (!strcmp(var, caller_profile->destination_number) && val) { if (!strcmp(var, caller_profile->destination_number) && val) {
char *data; char *data;
@ -95,6 +101,7 @@ static switch_caller_extension_t *demo_dialplan_hunt(switch_core_session_t *sess
if (extension) { if (extension) {
switch_channel_set_state(channel, CS_EXECUTE); switch_channel_set_state(channel, CS_EXECUTE);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Cannot locate extension %s in context %s\n", caller_profile->destination_number, context);
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST); switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
} }
@ -102,17 +109,17 @@ static switch_caller_extension_t *demo_dialplan_hunt(switch_core_session_t *sess
} }
static const switch_dialplan_interface_t demo_dialplan_interface = { static const switch_dialplan_interface_t flatfile_dialplan_interface = {
/*.interface_name = */ "demo", /*.interface_name = */ "flatfile",
/*.hunt_function = */ demo_dialplan_hunt /*.hunt_function = */ flatfile_dialplan_hunt
/*.next = NULL */ /*.next = NULL */
}; };
static const switch_loadable_module_interface_t demo_dialplan_module_interface = { static const switch_loadable_module_interface_t flatfile_dialplan_module_interface = {
/*.module_name = */ modname, /*.module_name = */ modname,
/*.endpoint_interface = */ NULL, /*.endpoint_interface = */ NULL,
/*.timer_interface = */ NULL, /*.timer_interface = */ NULL,
/*.dialplan_interface = */ &demo_dialplan_interface, /*.dialplan_interface = */ &flatfile_dialplan_interface,
/*.codec_interface = */ NULL, /*.codec_interface = */ NULL,
/*.application_interface = */ NULL /*.application_interface = */ NULL
}; };
@ -121,7 +128,7 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
{ {
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = &demo_dialplan_module_interface; *module_interface = &flatfile_dialplan_module_interface;
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;

View File

@ -2,9 +2,9 @@
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="mod_dialplan_demo" Name="mod_dialplan_flatfile"
ProjectGUID="{2988EB83-785F-45D4-8731-8E1E4345177E}" ProjectGUID="{2988EB83-785F-45D4-8731-8E1E4345177E}"
RootNamespace="mod_dialplan_demo" RootNamespace="mod_dialplan_flatfile"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
<Platforms> <Platforms>
@ -63,13 +63,13 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_demo.dll" OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)" AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/mod_dialplan_demo.pdb" ProgramDatabaseFile="$(OutDir)/mod_dialplan_flatfile.pdb"
SubSystem="2" SubSystem="2"
ImportLibrary="$(OutDir)/mod_dialplan_demo.lib" ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@ -141,14 +141,14 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_demo.dll" OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)" AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/mod_dialplan_demo.lib" ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@ -186,7 +186,7 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
> >
<File <File
RelativePath=".\mod_dialplan_demo.c" RelativePath=".\mod_dialplan_flatfile.c"
> >
</File> </File>
</Filter> </Filter>