]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add some stuff
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 Nov 2007 02:48:44 +0000 (02:48 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 29 Nov 2007 02:48:44 +0000 (02:48 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6430 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/js/.update
libs/js/configure.ac
src/include/switch_xml.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/applications/mod_voicemail/mod_voicemail.c
src/mod/endpoints/mod_sofia/sofia_reg.c
src/mod/languages/mod_spidermonkey/sm.mak
src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
src/switch_xml.cpp

index c9ce1e76d919c035d35740f03cf842fcef74d3a7..af163dc36da66f5c5efc2bf1177a8b7c51697449 100644 (file)
@@ -1 +1 @@
-Mon Apr 23 14:11:42 EDT 2007
+Wed Nov 28 21:37:06 EST 2007
index 381a0711d0e4f4e52b77544a1693ed7ea486ea6b..5c5a729bc15c60cf1adc6b24f007431d385a1c80 100644 (file)
@@ -141,6 +141,15 @@ if test ".$ac_cv_with_file" = ".yes"; then
     CPPFLAGS="$CPPFLAGS -DJS_HAS_FILE_OBJECT=1"
 fi
 
+dnl #   configure option --without-xml
+AC_ARG_WITH([xml],
+       AS_HELP_STRING([--without-xml], [build without XML object]),
+       [ac_cv_with_xml=$withval], [ac_cv_with_xml=yes])
+AC_CACHE_CHECK([whether to build with the XML object], [ac_cv_with_xml], [ac_cv_with_xml=yes])
+if test ".$ac_cv_with_xml" = ".yes"; then
+    CPPFLAGS="$CPPFLAGS -DJS_HAS_XML_SUPPORT=1"
+fi
+
 dnl #   configure option --with-dso
 AC_ARG_WITH([dso],
        AS_HELP_STRING([--with-dso], [build without DSO object (allows run-time process extending)]),
index 842006cb42c8be0bee2421fbefe17c5fb4399128..2f6e27a0ee3e744be0aa63d215b192114bf6f5e2 100644 (file)
@@ -319,7 +319,9 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
                                                                                                  const char *params);
 
 SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name, char *params, switch_xml_t *root, switch_xml_t *domain);
-SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *user_name, const char *domain_name, 
+SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
+                                                                                                          const char *user_name, 
+                                                                                                          const char *domain_name, 
                                                                                                           const char *ip, 
                                                                                                           switch_xml_t *root,
                                                                                                           switch_xml_t *domain,
index 075026850f27d5c03033a5a2a2a77f6f25551fc3..822af3ebaec39bca8489cc9db952e4894dfe133d 100644 (file)
@@ -41,6 +41,66 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load);
 SWITCH_MODULE_DEFINITION(mod_commands, mod_commands_load, NULL, NULL);
 
 
+SWITCH_STANDARD_API(find_user_function)
+{
+       switch_xml_t x_domain, x_user, xml = NULL;
+       int argc;
+    char *mydata = NULL, *argv[3];
+       char *key, *user, *domain;
+       char *xmlstr, *xs;
+
+    if (!cmd) {
+               stream->write_function(stream,  "bad args\n");
+        goto end;
+    }
+
+    mydata = strdup(cmd);
+    assert(mydata);
+       
+    argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+    if (argc < 3) {
+               stream->write_function(stream,  "bad args\n");
+        goto end;
+    }
+
+       key = argv[0];
+       user = argv[1];
+       domain = argv[2];
+
+    if (!(key && user && domain)) {
+               stream->write_function(stream,  "bad args\n");
+        goto end;
+    }
+
+       if (switch_xml_locate_user(key, user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
+               stream->write_function(stream,  "can't find user [%s@%s]\n", user, domain);
+               goto end;
+       }
+
+
+ end:
+
+       if (xml) {
+               xmlstr = switch_xml_toxml(x_user);
+               assert(xmlstr);
+               if ((xs = strstr(xmlstr, "?>"))) {
+                       xs += 2;
+               } else {
+                       xs = xmlstr;
+               }
+               stream->write_function(stream,  "%s", xs);
+               free(xmlstr);
+               switch_xml_free(xml);
+               
+       }
+
+       free(mydata);
+       return SWITCH_STATUS_SUCCESS;
+
+}
+
+
 SWITCH_STANDARD_API(regex_function)
 {
        switch_regex_t *re = NULL;
@@ -1782,6 +1842,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "qq", "Eval a conditional", cond_function, "<expr> ? <true val> : <false val>");
        SWITCH_ADD_API(commands_api_interface, "regex", "Eval a regex", regex_function, "<data>|<pattern>[|<subst string>]");
        SWITCH_ADD_API(commands_api_interface, "uuid_chat", "Send a chat message", uuid_chat, UUID_CHAT_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "find_user_xml", "find a usere", find_user_function, "<key> <user>@<domain>");
 
        /* indicate that the module should continue to be loaded */
        return SWITCH_STATUS_NOUNLOAD;
index cce49404f38a8671258b3ada5fdff65086f7410f..4001d8972843b2564ec98851502b26212accb3b4 100644 (file)
@@ -109,7 +109,7 @@ SWITCH_STANDARD_APP(set_user_function)
 
        *domain++ = '\0';
        
-       if (switch_xml_locate_user(user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
+       if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, NULL) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain);
                goto done;
        }
index 10ed475a03cb3b741ba46d7b94ffc88e7f9fa3a0..29aec0b305cd39f1bb55aad522e61d5db12ba1ba 100644 (file)
@@ -1570,7 +1570,7 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro
                     
                     assert(xtra);
 
-                    if (switch_xml_locate_user(myid, domain_name, switch_channel_get_variable(channel, "network_addr"), 
+                    if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"), 
                                                &x_domain_root, &x_domain, &x_user, xtra) != SWITCH_STATUS_SUCCESS) {
                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", myid, domain_name);
                         ok = 0;
@@ -1753,7 +1753,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
         
         assert(xtra);
         x_user = x_domain = x_domain_root = NULL;
-        if (switch_xml_locate_user(id, domain_name, switch_channel_get_variable(channel, "network_addr"), 
+        if (switch_xml_locate_user("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"), 
                                    &x_domain_root, &x_domain, &x_user, xtra) == SWITCH_STATUS_SUCCESS) {
             if ((x_params = switch_xml_child(x_user, "params"))) {
                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
index e7f742591784665ba1fe5e05f4560a876e31b6bb..1dae459cbccab761463f17157a63c0574e2578a7 100644 (file)
@@ -893,7 +893,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
                domain_name = realm;
        }
        
-       if (switch_xml_locate_user(username, domain_name, ip, &xml, &domain, &user, pbuf) != SWITCH_STATUS_SUCCESS) {
+       if (switch_xml_locate_user("id", username, domain_name, ip, &xml, &domain, &user, pbuf) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", username, domain_name);
                ret = AUTH_FORBIDDEN;
                goto end;
index 86617568e4dfb7e99f38d414d0546d0984206f53..450f24a2be9fcb920c0f86be9369ecfe26f22a1f 100644 (file)
@@ -2,7 +2,7 @@ switch_srcdir=../../../..
 JS_DIR=$(switch_srcdir)/libs/js
 JSLA=$(JS_DIR)/libjs.la
 
-LOCAL_CFLAGS+=-I$(JS_DIR)/src -I$(JS_DIR)/nsprpub/dist/include/nspr  -DXP_UNIX -I../mod_spidermonkey  -DJS_THREADSAFE -DJS_HAS_FILE_OBJECT=1
+LOCAL_CFLAGS+=-I$(JS_DIR)/src -I$(JS_DIR)/nsprpub/dist/include/nspr  -DXP_UNIX -I../mod_spidermonkey  -DJS_THREADSAFE -DJS_HAS_FILE_OBJECT=1 -DJS_HAS_XML_SUPPORT=1
 LOCAL_LDFLAGS+=-L$(JS_DIR)/nsprpub/pr/src -L$(JS_DIR)/nsprpub/dist/lib -lnspr4
 LOCAL_LIBADD+=$(JSLA)
 
index 5c54bcc3b6c67966cdb2bb214785e85cd77d8ad0..c4be9bb89d54023ef3d5c211a87a65a957e1aa66 100644 (file)
@@ -172,7 +172,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
                                        *pass++ = '\0';
                                }
                                
-                               if (switch_xml_locate_user(user, domain_name, NULL, &x_domain_root, &x_domain, &x_user, "mailbox=check") != SWITCH_STATUS_SUCCESS) {
+                               if (switch_xml_locate_user("id", user, domain_name, NULL, &x_domain_root, &x_domain, &x_user, "mailbox=check") != SWITCH_STATUS_SUCCESS) {
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain_name);
                                        goto fail;
                                }
index 47da443bfcfe0f5156d955aa2d7fbad4deb4656d..419450e51f7482581c4818c4ab0a24284503b63c 100644 (file)
@@ -1296,7 +1296,8 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name
 }
 
 
-SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *user_name, 
+SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
+                                                                                                          const char *user_name,
                                                                                                           const char *domain_name, 
                                                                                                           const char *ip, 
                                                                                                           switch_xml_t *root,
@@ -1311,10 +1312,10 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *user_name,
        *domain = NULL;
        
        if (!switch_strlen_zero(xtra_params)) {
-               snprintf(params, sizeof(params), "user=%s&domain=%s&ip=%s&%s", 
+               snprintf(params, sizeof(params), "key=%s&user=%s&domain=%s&ip=%s&%s", key,
                                 switch_str_nil(user_name), switch_str_nil(domain_name), switch_str_nil(ip), xtra_params);
        } else {
-               snprintf(params, sizeof(params), "user=%s&domain=%s&ip=%s", 
+               snprintf(params, sizeof(params), "key=%s&user=%s&domain=%s&ip=%s", key,
                                 switch_str_nil(user_name), switch_str_nil(domain_name), switch_str_nil(ip));
                xtra_params = "";
        }
@@ -1336,7 +1337,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *user_name,
                        }
                }
 
-               if ((*user = switch_xml_find_child(*domain, "user", "id", user_name))) {
+               if ((*user = switch_xml_find_child(*domain, "user", key, user_name))) {
                        return SWITCH_STATUS_SUCCESS;
                }