This commit is contained in:
Anthony Minessale 2012-02-17 09:51:04 -06:00
parent 5e66db63f1
commit f869fb305a
1 changed files with 68 additions and 62 deletions

View File

@ -899,7 +899,13 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
} }
if (event->event_id == SWITCH_EVENT_ROSTER) { if (event->event_id == SWITCH_EVENT_ROSTER) {
struct presence_helper helper = { 0 }; if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
switch_console_callback_match_node_t *m;
for (m = matches->head; m; m = m->next) {
if ((profile = sofia_glue_find_profile(m->val))) {
if (profile->pres_type != PRES_TYPE_FULL) {
if (!mod_sofia_globals.profile_hash) { if (!mod_sofia_globals.profile_hash) {
return; return;
@ -926,8 +932,10 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
",1,'%q','%q',sip_presence.status,sip_presence.rpid,sip_presence.open_closed,'','','','','sip'," ",1,'%q','%q',sip_presence.status,sip_presence.rpid,sip_presence.open_closed,'','','','','sip',"
" sip_subscriptions.full_to,sip_subscriptions.network_ip,sip_subscriptions.network_port " " sip_subscriptions.full_to,sip_subscriptions.network_ip,sip_subscriptions.network_port "
"from sip_subscriptions left join sip_presence on " "from sip_subscriptions left join sip_presence on "
"(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and " "(sip_subscriptions.sub_to_user=sip_presence.sip_user and "
"sip_subscriptions.profile_name=sip_presence.profile_name and sip_presence.profile_name=sip_subscriptions.profile_name) " "sip_subscriptions.sub_to_host=sip_presence.sip_host and "
"sip_subscriptions.profile_name=sip_presence.profile_name and "
"sip_presence.profile_name=sip_subscriptions.profile_name) "
"where sip_subscriptions.hostname='%q' and sip_subscriptions.profile_name='%q' and " "where sip_subscriptions.hostname='%q' and sip_subscriptions.profile_name='%q' and "
"sip_subscriptions.event='presence' and sip_subscriptions.full_from like '%%%q%%'", "sip_subscriptions.event='presence' and sip_subscriptions.full_from like '%%%q%%'",
switch_str_nil(status), switch_str_nil(rpid), mod_sofia_globals.hostname, profile->name, from); switch_str_nil(status), switch_str_nil(rpid), mod_sofia_globals.hostname, profile->name, from);
@ -950,8 +958,10 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
",1,'%q','%q',sip_presence.status,sip_presence.rpid,sip_presence.open_closed,'','','','','sip'," ",1,'%q','%q',sip_presence.status,sip_presence.rpid,sip_presence.open_closed,'','','','','sip',"
"sip_subscriptions.full_to,sip_subscriptions.network_ip,sip_subscriptions.network_port " "sip_subscriptions.full_to,sip_subscriptions.network_ip,sip_subscriptions.network_port "
"from sip_subscriptions left join sip_presence on " "from sip_subscriptions left join sip_presence on "
"(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and " "(sip_subscriptions.sub_to_user=sip_presence.sip_user and "
"sip_subscriptions.profile_name=sip_presence.profile_name and sip_subscriptions.hostname = sip_presence.hostname) " "sip_subscriptions.sub_to_host=sip_presence.sip_host and "
"sip_subscriptions.profile_name=sip_presence.profile_name and "
"sip_subscriptions.hostname = sip_presence.hostname) "
"where sip_subscriptions.hostname='%q' and sip_subscriptions.profile_name='%q' and " "where sip_subscriptions.hostname='%q' and sip_subscriptions.profile_name='%q' and "
"sip_subscriptions.event='presence'", switch_str_nil(status), "sip_subscriptions.event='presence'", switch_str_nil(status),
switch_str_nil(rpid), mod_sofia_globals.hostname, profile->name); switch_str_nil(rpid), mod_sofia_globals.hostname, profile->name);
@ -959,29 +969,25 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
switch_assert(sql != NULL); switch_assert(sql != NULL);
if (list_profiles_full(NULL, NULL, &matches, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
switch_console_callback_match_node_t *m;
for (m = matches->head; m; m = m->next) {
if ((profile = sofia_glue_find_profile(m->val))) {
if (profile->pres_type != PRES_TYPE_FULL) {
if (mod_sofia_globals.debug_presence > 0) { if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s is passive, skipping\n", (char *) profile->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s is passive, skipping\n", (char *) profile->name);
} }
sofia_glue_release_profile(profile); sofia_glue_release_profile(profile);
continue; continue;
} }
memset(&helper, 0, sizeof(helper));
helper.profile = profile; helper.profile = profile;
helper.event = NULL; helper.event = NULL;
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_callback, &helper); sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_callback, &helper);
switch_safe_free(sql);
sofia_glue_release_profile(profile); sofia_glue_release_profile(profile);
} }
} }
switch_console_free_matches(&matches); switch_console_free_matches(&matches);
} }
free(sql); switch_safe_free(sql);
return; return;
} }