提交 a56e221e authored 作者: Anthony Minessale's avatar Anthony Minessale

xmas presence

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3722 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 375f1b38
...@@ -312,17 +312,25 @@ static void pres_event_handler(switch_event_t *event) ...@@ -312,17 +312,25 @@ static void pres_event_handler(switch_event_t *event)
switch_core_db_t *db; switch_core_db_t *db;
char *errmsg; char *errmsg;
char *to = switch_event_get_header(event, "to"); char *to = switch_event_get_header(event, "to");
char *f_host = NULL;
if (to) {
if ((f_host = strchr(to, '@'))) {
f_host++;
}
}
if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) { if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
if (!(db = switch_core_db_open_file(profile->dbname))) { if (to && (sql = switch_mprintf("select * from subscriptions where sub_to='%q'", to))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname); if (!(db = switch_core_db_open_file(profile->dbname))) {
return; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
return;
}
switch_mutex_lock(profile->mutex);
switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
switch_mutex_unlock(profile->mutex);
switch_core_db_close(db);
switch_safe_free(sql);
} }
switch_mutex_lock(profile->mutex);
switch_core_db_exec(db, sql, sin_callback, profile, &errmsg);
switch_mutex_unlock(profile->mutex);
switch_core_db_close(db);
switch_safe_free(sql);
} }
} }
return; return;
......
...@@ -5346,7 +5346,7 @@ static void pres_event_handler(switch_event_t *event) ...@@ -5346,7 +5346,7 @@ static void pres_event_handler(switch_event_t *event)
*host++ = '\0'; *host++ = '\0';
} }
if (user && host && if (user && host &&
(sql = switch_mprintf("select user,host,'Registered','unknown','' from sip_registrations where user='%q' and host='%q'", user, host))) { (sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where user='%q' and host='%q'", user, host))) {
switch_mutex_lock(profile->ireg_mutex); switch_mutex_lock(profile->ireg_mutex);
switch_core_db_exec(db, sql, resub_callback, profile, &errmsg); switch_core_db_exec(db, sql, resub_callback, profile, &errmsg);
switch_mutex_unlock(profile->ireg_mutex); switch_mutex_unlock(profile->ireg_mutex);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论