From 65bbe544386b216dbbe073dece394a467c79e978 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 6 Jun 2008 14:52:41 +0000 Subject: [PATCH] add CtRiX's patch, beat him up if it causes a regression git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8778 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 34693529e7..379146df75 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1453,8 +1453,8 @@ static int contact_callback(void *pArg, int argc, char **argv, char **columnName struct cb_helper *cb = (struct cb_helper *) pArg; char *contact; - if (!switch_strlen_zero(argv[0]) && (contact = sofia_glue_get_url_from_contact(argv[0], 1))) { - cb->stream->write_function(cb->stream, "sofia/%s/%s,", cb->profile->name, contact + 4); + if (!switch_strlen_zero(argv[0]) && (contact = sofia_glue_get_url_from_contact(argv[0], 1)) ) { + cb->stream->write_function(cb->stream, "%ssofia/%s/%s,", argv[1], cb->profile->name, contact + 4); free(contact); } @@ -1466,6 +1466,7 @@ SWITCH_STANDARD_API(sofia_contact_function) char *data; char *user = NULL; char *domain = NULL; + char *concat = NULL; char *profile_name = NULL; char *p; sofia_profile_t *profile = NULL; @@ -1496,6 +1497,14 @@ SWITCH_STANDARD_API(sofia_contact_function) if ((domain = strchr(user, '@'))) { *domain++ = '\0'; + if ( (concat = strchr( domain, '/')) ) { + *concat++ = '\0'; + } + } + else { + if ( (concat = strchr( user, '/')) ) { + *concat++ = '\0'; + } } if (!profile_name && domain) { @@ -1528,10 +1537,11 @@ SWITCH_STANDARD_API(sofia_contact_function) cb.stream = &mystream; if (exclude_contact) { - sql = switch_mprintf("select contact from sip_registrations where sip_user='%q' and sip_host='%q' and contact not like '%%%s%%'", - user, domain, exclude_contact); + sql = switch_mprintf("select contact, '%q' from sip_registrations where sip_user='%q' and sip_host='%q' and contact not like '%%%s%%'", + ( concat != NULL ) ? concat : "", user, domain, exclude_contact); } else { - sql = switch_mprintf("select contact from sip_registrations where sip_user='%q' and sip_host='%q'", user, domain); + sql = switch_mprintf("select contact, '%q' from sip_registrations where sip_user='%q' and sip_host='%q'", + ( concat != NULL ) ? concat : "", user, domain); } switch_assert(sql);