]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
xmas presence
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 19 Dec 2006 18:45:14 +0000 (18:45 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 19 Dec 2006 18:45:14 +0000 (18:45 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3725 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_sofia/mod_sofia.c

index 188b733264495dba0b15449521b4532bfe8d846d..90823f0fc8ad831895e71489b89f3aa30edf1fde 100644 (file)
@@ -307,7 +307,7 @@ static void pres_event_handler(switch_event_t *event)
 
        switch(event->event_id) {
        case SWITCH_EVENT_PRESENCE_PROBE: 
-        if (proto && !strcasecmp(proto, MDL_CHAT_PROTO)) {
+        if (proto) {
                char *sql;
             switch_core_db_t *db;
             char *errmsg;
index c176a96db8e1aa798c3a4e81bc61d50cdda9802d..d5c7f74a1d63216dca13b7c7b5f78dfaa7e7210c 100644 (file)
@@ -5327,26 +5327,33 @@ static void pres_event_handler(switch_event_t *event)
 
        switch(event->event_id) {
     case SWITCH_EVENT_PRESENCE_PROBE: 
-        if (proto && !strcasecmp(proto, SOFIA_CHAT_PROTO)) {
+        if (proto) {
             switch_core_db_t *db;
             char *to = switch_event_get_header(event, "to");
-            char *user, *host;
+            char *user, *euser, *host, *p;
 
             if (!to || !(user = strdup(to))) {
                 return;
             }
 
-            if (!(db = switch_core_db_open_file(profile->dbname))) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
-                switch_safe_free(user);
-                return;
-            }
-
             if ((host = strchr(user, '@'))) {
                 *host++ = '\0';
             }
-            if (user && host && 
-                (sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where user='%q' and host='%q'", user, host))) {
+            euser = user;
+            if ((p = strchr(euser, '+'))) {
+                euser = (p+1);
+            }
+
+            if (euser && host && 
+                (sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where user='%q' and host='%q'", euser, host)) &&
+                (profile = (sofia_profile_t *) switch_core_hash_find(globals.profile_hash, host))) {
+                if (!(db = switch_core_db_open_file(profile->dbname))) {
+                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+                    switch_safe_free(user);
+                    switch_safe_free(sql);
+                    return;
+                }
+
                 switch_mutex_lock(profile->ireg_mutex);
                 switch_core_db_exec(db, sql, resub_callback, profile, &errmsg);
                 switch_mutex_unlock(profile->ireg_mutex);