]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
break some more stuff
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 May 2006 17:42:24 +0000 (17:42 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 May 2006 17:42:24 +0000 (17:42 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1319 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/freeswitch.conf
modules.conf.in
src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.c [moved from src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c with 73% similarity]
src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.vcproj [moved from src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.vcproj with 89% similarity]

index 037943d158d9c3acdbf1a36ca2dc18756baea74a..d34551a0f3fb04a7ae10d37ec1b11df95a0a85d1 100644 (file)
@@ -46,7 +46,7 @@ load => mod_commands
 ;load => mod_commands
 
 ; Dialplan Interfaces
-load => mod_dialplan_demo
+load => mod_dialplan_flatfile
 ;load => mod_dialplan_directory
 load => mod_pcre
 
@@ -96,7 +96,7 @@ level    => debug,info,warning-alert
 debug => 0
 ;ip => 1.2.3.4
 port => 4569
-dialplan => demo
+dialplan => flatfile
 codec_prefs => PCMU,PCMA,speex,L16
 codec_master => us
 codec_rates=8
@@ -176,7 +176,7 @@ debug=0
 [+portaudio.conf]
 [settings]
 debug => 2
-dialplan => demo
+dialplan => flatfile
 
 ; partial string match on something in the name or the device #
 indev => USB
@@ -238,7 +238,7 @@ base => dc=freeswitch,dc=org
 ;---- BASIC EXTENSIONS
 ;--------------------------------------------------------------------------------
 [+extensions.conf]
-[extensions]
+[default]
 
 1000 => playback /var/sounds/beep.raw
 
@@ -260,7 +260,7 @@ codec_prefs => PCMU
  name => google
  login => myjabberid@myjabberserver.com/talk
  password => mypass
- dialplan => demo
+ dialplan => flatfile
  message => Jingle all the way
  rtp-ip => 0.0.0.0
  auto-login => true
index aa4db904db86f417a328be35c796f1e9c5ef404e..ea23d936c9d39261bd4e75f31e2af49275215c99 100644 (file)
@@ -14,7 +14,7 @@ codecs/mod_gsm
 #codecs/mod_ilbc
 codecs/mod_l16
 #codecs/mod_speex
-dialplans/mod_dialplan_demo
+dialplans/mod_dialplan_flatfile
 #dialplans/mod_dialplan_directory
 dialplans/mod_pcre
 #directories/mod_ldap
index c5453d63efe6add16826e3c169b75175429be097..798dadcff9a09ffcc27add0d740882ed5ba54dda 100644 (file)
@@ -116,7 +116,11 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
                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);
        while (switch_core_directory_next(&dh) == SWITCH_STATUS_SUCCESS) {
similarity index 73%
rename from src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.c
rename to src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.c
index 0a5f4ebce7ffa584634e1d0dcde7798b9b87a15e..c4fd6171b1b5124a2911f83b2c7424f347e823a3 100644 (file)
@@ -26,7 +26,7 @@
  * Anthony Minessale II <anthmct@yahoo.com>
  *
  *
- * mod_dialplan_demo.c -- Example Dialplan Module
+ * mod_dialplan_flatfile.c -- Example Dialplan Module
  *
  */
 #include <switch.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_channel_t *channel;
        char *cf = "extensions.conf";
        switch_config_t cfg;
        char *var, *val;
        char app[1024];
+       char *context = NULL;
 
        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,
-                                                 caller_profile->destination_number);
+                                         caller_profile->destination_number);
 
        if (!switch_config_open_file(&cfg, cf)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -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)) {
-               if (!strcasecmp(cfg.category, "extensions")) {
+               if (!strcasecmp(cfg.category, context)) {
                        if (!strcmp(var, caller_profile->destination_number) && val) {
                                char *data;
 
@@ -95,6 +101,7 @@ static switch_caller_extension_t *demo_dialplan_hunt(switch_core_session_t *sess
        if (extension) {
                switch_channel_set_state(channel, CS_EXECUTE);
        } 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);
        }
 
@@ -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 = {
-       /*.interface_name = */ "demo",
-       /*.hunt_function = */ demo_dialplan_hunt
-               /*.next = NULL */
+static const switch_dialplan_interface_t flatfile_dialplan_interface = {
+       /*.interface_name = */ "flatfile",
+       /*.hunt_function = */ flatfile_dialplan_hunt
+       /*.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,
        /*.endpoint_interface = */ NULL,
        /*.timer_interface = */ NULL,
-       /*.dialplan_interface = */ &demo_dialplan_interface,
+       /*.dialplan_interface = */ &flatfile_dialplan_interface,
        /*.codec_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 */
-       *module_interface = &demo_dialplan_module_interface;
+       *module_interface = &flatfile_dialplan_module_interface;
 
        /* indicate that the module should continue to be loaded */
        return SWITCH_STATUS_SUCCESS;
similarity index 89%
rename from src/mod/dialplans/mod_dialplan_demo/mod_dialplan_demo.vcproj
rename to src/mod/dialplans/mod_dialplan_flatfile/mod_dialplan_flatfile.vcproj
index 2a51473a3e1d5576751e13a78b67bcbf14d21e0b..f4d932b71c4188d034d0c21c4d31bb96242f8a19 100644 (file)
@@ -2,9 +2,9 @@
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
        Version="8.00"\r
-       Name="mod_dialplan_demo"\r
+       Name="mod_dialplan_flatfile"\r
        ProjectGUID="{2988EB83-785F-45D4-8731-8E1E4345177E}"\r
-       RootNamespace="mod_dialplan_demo"\r
+       RootNamespace="mod_dialplan_flatfile"\r
        Keyword="Win32Proj"\r
        >\r
        <Platforms>\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_demo.dll"\r
+                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"\r
                                LinkIncremental="2"\r
                                AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"\r
                                GenerateDebugInformation="true"\r
-                               ProgramDatabaseFile="$(OutDir)/mod_dialplan_demo.pdb"\r
+                               ProgramDatabaseFile="$(OutDir)/mod_dialplan_flatfile.pdb"\r
                                SubSystem="2"\r
-                               ImportLibrary="$(OutDir)/mod_dialplan_demo.lib"\r
+                               ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"\r
                                TargetMachine="1"\r
                        />\r
                        <Tool\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_demo.dll"\r
+                               OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_dialplan_flatfile.dll"\r
                                LinkIncremental="1"\r
                                AdditionalLibraryDirectories="..\..\..\..\w32\vsnet\$(OutDir)"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OptimizeReferences="2"\r
                                EnableCOMDATFolding="2"\r
-                               ImportLibrary="$(OutDir)/mod_dialplan_demo.lib"\r
+                               ImportLibrary="$(OutDir)/mod_dialplan_flatfile.lib"\r
                                TargetMachine="1"\r
                        />\r
                        <Tool\r
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
                        >\r
                        <File\r
-                               RelativePath=".\mod_dialplan_demo.c"\r
+                               RelativePath=".\mod_dialplan_flatfile.c"\r
                                >\r
                        </File>\r
                </Filter>\r