rearrange some things please see conf/freeswitch.xml as there is a significant change to the conf that will break your stuff
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1446 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
d314140374
commit
d53d9d3997
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<document type="freeswitch/xml">
|
||||
<section name="configuration">
|
||||
<section name="configuration" description="Various Configuration">
|
||||
<configuration name="modules.conf" description="Modules">
|
||||
<modules>
|
||||
<!-- Loggers (I'd load these first) -->
|
||||
|
@ -205,14 +205,51 @@
|
|||
</settings>
|
||||
</configuration>
|
||||
|
||||
<configuration name="extensions.conf" description="Regex/XML Dialplan">
|
||||
<!-- any extension starting with a '4' -->
|
||||
<!-- strip the '4' and consider the rest a numeric filename -->
|
||||
<configuration name="dingaling.conf" description="XMPP Jingle Endpoint">
|
||||
<settings>
|
||||
<param name="debug" value="0"/>
|
||||
<param name="codec_prefs" value="PCMU"/>
|
||||
</settings>
|
||||
<!-- *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok) -->
|
||||
<!-- *NOTE* as of May 2 2006 you must set"auto-login" to"true" if you want to be able to auto-login on startup"/> -->
|
||||
<interface>
|
||||
<param name="name" value="jingle"/>
|
||||
<param name="login" value="myjid@myserver.com/talk"/>
|
||||
<param name="password" value="mypass"/>
|
||||
<param name="dialplan" value="XML"/>
|
||||
<param name="message" value="Jingle all the way"/>
|
||||
<param name="rtp-ip" value="10.0.0.1"/>
|
||||
<param name="auto-login" value="true"/>
|
||||
<!-- or -->
|
||||
<!-- <param name="rtp-ip" value="my_lan_ip"/> -->
|
||||
<!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
|
||||
<!-- default extension (if one cannot be determined) -->
|
||||
<param name="exten" value="888"/>
|
||||
<!-- VAD choose one -->
|
||||
<!-- <param name="vad" value="in"/> -->
|
||||
<!-- <param name="vad" value="out"/> -->
|
||||
<param name="vad" value="both"/>
|
||||
</interface>
|
||||
</configuration>
|
||||
<configuration name="xml_rpc.conf" description="XML RPC">
|
||||
<settings>
|
||||
<!-- The port where you want to run the http service (default 8080) -->
|
||||
<param name="http_port" value="8080"/>
|
||||
<!-- The url to a gateway cgi that can generate xml similar to
|
||||
what's in this file only on-the-fly (leave it commented if you dont
|
||||
need it) -->
|
||||
<!-- <param name="gateway_url" value="http://www.server.com/gateway.cgi"/> -->
|
||||
</settings>
|
||||
</configuration>
|
||||
</section>
|
||||
|
||||
<section name="dialplan" description="Regex/XML Dialplan">
|
||||
<!-- Valid fields in conditions:
|
||||
"dialplan, caller_id_name, ani, ani2, caller_id_number,
|
||||
network_addr, rdnis, destination_number, uuid, source,
|
||||
context, chan_name" -->
|
||||
|
||||
<!-- *NOTE* The special context name 'any' will match any context -->
|
||||
<context name="default">
|
||||
<extension name="devconf">
|
||||
<condition field="destination_number" expression="^888$">
|
||||
|
@ -268,46 +305,9 @@
|
|||
</condition>
|
||||
</extension>
|
||||
</context>
|
||||
</configuration>
|
||||
|
||||
<configuration name="dingaling.conf" description="XMPP Jingle Endpoint">
|
||||
<settings>
|
||||
<param name="debug" value="0"/>
|
||||
<param name="codec_prefs" value="PCMU"/>
|
||||
</settings>
|
||||
<!-- *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok) -->
|
||||
<!-- *NOTE* as of May 2 2006 you must set"auto-login" to"true" if you want to be able to auto-login on startup"/> -->
|
||||
<interface>
|
||||
<param name="name" value="jingle"/>
|
||||
<param name="login" value="myjid@myserver.com/talk"/>
|
||||
<param name="password" value="mypass"/>
|
||||
<param name="dialplan" value="XML"/>
|
||||
<param name="message" value="Jingle all the way"/>
|
||||
<param name="rtp-ip" value="10.0.0.1"/>
|
||||
<param name="auto-login" value="true"/>
|
||||
<!-- or -->
|
||||
<!-- <param name="rtp-ip" value="my_lan_ip"/> -->
|
||||
<!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
|
||||
<!-- default extension (if one cannot be determined) -->
|
||||
<param name="exten" value="888"/>
|
||||
<!-- VAD choose one -->
|
||||
<!-- <param name="vad" value="in"/> -->
|
||||
<!-- <param name="vad" value="out"/> -->
|
||||
<param name="vad" value="both"/>
|
||||
</interface>
|
||||
</configuration>
|
||||
<configuration name="xml_rpc.conf" description="XML RPC">
|
||||
<settings>
|
||||
<!-- The port where you want to run the http service (default 8080) -->
|
||||
<param name="http_port" value="8080"/>
|
||||
<!-- The url to a gateway cgi that can generate xml similar to
|
||||
what's in this file only on-the-fly (leave it commented if you dont
|
||||
need it) -->
|
||||
<!-- <param name="gateway_url" value="http://www.server.com/gateway.cgi"/> -->
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
</section>
|
||||
</section>
|
||||
<section name="directory" description="User Directory">
|
||||
</section>
|
||||
</document>
|
||||
|
||||
|
||||
|
|
|
@ -93,6 +93,14 @@ SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
|
|||
#define SWITCH_TRUE 1
|
||||
#define SWITCH_FALSE 0
|
||||
|
||||
|
||||
typedef enum {
|
||||
SWITCH_XML_SECTION_RESULT = 0,
|
||||
SWITCH_XML_SECTION_CONFIG = (1 << 0),
|
||||
SWITCH_XML_SECTION_DIRECTORY = (1 << 1),
|
||||
SWITCH_XML_SECTION_DIALPLAN = (1 << 2)
|
||||
} switch_xml_section_t;
|
||||
|
||||
/*!
|
||||
\enum switch_vad_flag_t
|
||||
\brief RTP Related Flags
|
||||
|
|
|
@ -151,7 +151,8 @@ SWITCH_DECLARE(unsigned char) switch_char_to_rfc2833(char key);
|
|||
\param fname the function name to declare
|
||||
\param vname the name of the global pointer to modify with the new function
|
||||
*/
|
||||
#define SWITCH_DECLARE_GLOBAL_STRING_FUNC(fname, vname) static void fname(char *string) { if (vname) {free(vname); vname = NULL;}vname = strdup(string);}
|
||||
#define SWITCH_DECLARE_GLOBAL_STRING_FUNC(fname, vname) static void fname(char *string) { if (!string) return;\
|
||||
if (vname) {free(vname); vname = NULL;}vname = strdup(string);}
|
||||
|
||||
/*!
|
||||
\brief Separate a string into an array based on a character delimeter
|
||||
|
|
|
@ -313,9 +313,15 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(char *file_path, switch_xml_t *
|
|||
|
||||
///\brief bind a search function to an external gateway
|
||||
///\param function the search function to bind
|
||||
///\param sections a bitmask of sections you wil service
|
||||
///\return SWITCH_STATUS_SUCCESS if successful
|
||||
///\note gateway functions will be executed in the order they were binded until a success is found else the root registry will be used
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function);
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function, switch_xml_section_t sections);
|
||||
|
||||
///\brief parse a string for a list of sections
|
||||
///\param string a | delimited list of section names
|
||||
///\return the section mask
|
||||
SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(char *str);
|
||||
|
||||
END_EXTERN_C
|
||||
|
||||
|
|
|
@ -127,7 +127,6 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
|
|||
switch_caller_profile_t *caller_profile;
|
||||
switch_caller_extension_t *extension = NULL;
|
||||
switch_channel_t *channel;
|
||||
char *cf = "extensions.conf";
|
||||
char *exten_name = NULL;
|
||||
switch_xml_t cfg, xml, xcontext, xexten, xaction, xcond;
|
||||
char *context = NULL;
|
||||
|
@ -145,10 +144,11 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
|
|||
caller_profile->destination_number);
|
||||
|
||||
snprintf(params, sizeof(params), "dest=%s", caller_profile->destination_number);
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
|
||||
if (switch_xml_locate("dialplan", NULL, NULL, NULL, &xml, &cfg, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", context))) {
|
||||
|
|
|
@ -49,9 +49,11 @@ static struct {
|
|||
uint16_t port;
|
||||
uint8_t running;
|
||||
char *url;
|
||||
char *bindings;
|
||||
} globals;
|
||||
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_url, globals.url)
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_url, globals.url);
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_bindings, globals.bindings);
|
||||
|
||||
struct config_data {
|
||||
char *name;
|
||||
|
@ -79,8 +81,14 @@ static switch_xml_t xml_url_fetch(char *section,
|
|||
struct config_data config_data;
|
||||
switch_xml_t xml = NULL;
|
||||
|
||||
snprintf(url, sizeof(url), "%s?section=%s&tag_name=%s&key_name=%s&key_value=%s%s%s\n",
|
||||
globals.url, section, tag_name, key_name, key_value, params ? "&" : "", params ? params : "");
|
||||
snprintf(url, sizeof(url), "%s?section=%s&tag_name=%s&key_name=%s&&key_value=%s%s%s\n",
|
||||
globals.url,
|
||||
section,
|
||||
tag_name ? tag_name : "",
|
||||
key_name ? key_name : "",
|
||||
key_value ? key_value : "",
|
||||
params ? "&" : "", params ? params : "");
|
||||
|
||||
srand((unsigned int)(time(NULL) + strlen(url)));
|
||||
snprintf(filename, sizeof(filename), "%s%04x.tmp", SWITCH_GLOBAL_dirs.temp_dir, (rand() & 0xffff));
|
||||
curl_handle = curl_easy_init();
|
||||
|
@ -142,6 +150,8 @@ static switch_status_t do_config(void)
|
|||
char *val = (char *) switch_xml_attr(param, "value");
|
||||
|
||||
if (!strcasecmp(var, "gateway_url")) {
|
||||
char *bindings = (char *) switch_xml_attr(param, "bindings");
|
||||
set_global_bindings(bindings);
|
||||
set_global_url(val);
|
||||
} else if (!strcasecmp(var, "http_port")) {
|
||||
globals.port = (uint16_t)atoi(val);
|
||||
|
@ -167,8 +177,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
|||
memset(&globals, 0, sizeof(globals));
|
||||
|
||||
if (do_config() == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding XML Fetch Function [%s]\n", globals.url);
|
||||
switch_xml_bind_search_function(xml_url_fetch);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding XML Fetch Function [%s] [%s]\n", globals.url, globals.bindings ? globals.bindings : "all");
|
||||
switch_xml_bind_search_function(xml_url_fetch, switch_xml_parse_section_string(globals.bindings));
|
||||
}
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
|
|
@ -84,6 +84,7 @@ char *SWITCH_XML_NIL[] = { NULL }; // empty, null terminated array of strings
|
|||
|
||||
struct switch_xml_binding {
|
||||
switch_xml_search_function_t function;
|
||||
switch_xml_section_t sections;
|
||||
struct switch_xml_binding *next;
|
||||
};
|
||||
|
||||
|
@ -94,7 +95,43 @@ static switch_memory_pool_t *XML_MEMORY_POOL;
|
|||
static switch_mutex_t *XML_LOCK;
|
||||
static switch_thread_rwlock_t *RWLOCK;
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function)
|
||||
struct xml_section_t {
|
||||
const char *name;
|
||||
switch_xml_section_t section;
|
||||
};
|
||||
|
||||
|
||||
static struct xml_section_t SECTIONS[] = {
|
||||
{ "result", SWITCH_XML_SECTION_RESULT},
|
||||
{ "config", SWITCH_XML_SECTION_CONFIG},
|
||||
{ "directory", SWITCH_XML_SECTION_DIRECTORY},
|
||||
{ "dialplan", SWITCH_XML_SECTION_DIALPLAN},
|
||||
{ NULL, 0}
|
||||
};
|
||||
|
||||
SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(char *str)
|
||||
{
|
||||
int x;
|
||||
char buf[1024] = "";
|
||||
switch_xml_section_t sections = SWITCH_XML_SECTION_RESULT;
|
||||
|
||||
if (str) {
|
||||
for(x = 0; x < strlen(str); x++) {
|
||||
buf[x] = tolower(str[x]);
|
||||
}
|
||||
for(x = 0;;x++) {
|
||||
if (!SECTIONS[x].name) {
|
||||
break;
|
||||
}
|
||||
if (strstr(buf, SECTIONS[x].name)) {
|
||||
sections |= SECTIONS[x].section;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_search_function_t function, switch_xml_section_t sections)
|
||||
{
|
||||
switch_xml_binding_t *binding = NULL, *ptr = NULL;
|
||||
assert(function != NULL);
|
||||
|
@ -104,6 +141,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function(switch_xml_searc
|
|||
}
|
||||
|
||||
binding->function = function;
|
||||
binding->sections = sections;
|
||||
|
||||
switch_mutex_lock(XML_LOCK);
|
||||
for (ptr = BINDINGS; ptr && ptr->next; ptr = ptr->next);
|
||||
|
@ -123,8 +161,13 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(switch_xml_t node, char *chil
|
|||
{
|
||||
switch_xml_t p = NULL;
|
||||
|
||||
if (!(childname && attrname && value)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
for (p = switch_xml_child(node, childname); p; p = p->next) {
|
||||
const char *aname = switch_xml_attr(p, attrname);
|
||||
|
||||
if (!strcasecmp(aname, value)) {
|
||||
break;
|
||||
}
|
||||
|
@ -757,6 +800,12 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(char *section,
|
|||
switch_mutex_lock(XML_LOCK);
|
||||
|
||||
for(binding = BINDINGS; binding; binding = binding->next) {
|
||||
switch_xml_section_t sections = switch_xml_parse_section_string(section);
|
||||
|
||||
if (binding->sections && !(sections & binding->sections)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((xml = binding->function(section, tag_name, key_name, key_value, params))) {
|
||||
const char *err = NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue