fix MODENDP-173

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11320 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West
2009-01-20 21:24:37 +00:00
parent ec3f6f4ec6
commit 7c2bd04232
2 changed files with 32 additions and 17 deletions
+24 -11
View File
@@ -62,15 +62,15 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
switch_status_t status = SWITCH_STATUS_FALSE;
const char *ct = "text/html";
if (subject && strchr(subject, '/')) {
ct = subject;
}
if (!to) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To: header.\n");
goto end;
}
if (!switch_strlen_zero(type)) {
ct = type;
}
dup = strdup(to);
switch_assert(dup);
prof = dup;
@@ -88,13 +88,19 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
if (!prof) prof = host;
}
if (!host || !(profile = sofia_glue_find_profile(prof))) {
if (!prof || !(profile = sofia_glue_find_profile(prof))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", proto, from, to,
body ? body : "[no body]", prof ? prof : "NULL");
goto end;
}
if (switch_strlen_zero(host)) {
host = profile->domain_name;
if (switch_strlen_zero(host)) {
host=prof;
}
}
if (!sofia_reg_find_reg_url(profile, user, host, buf, sizeof(buf))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find user. [%s][%s]\n", user, host);
goto end;
@@ -103,22 +109,29 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co
if (!strcasecmp(proto, SOFIA_CHAT_PROTO)) {
from = hint;
} else {
char *fp, *p, *fu = NULL;
char *fp, *p = NULL;
fp = strdup(from);
if (!fp) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
goto end;
}
if ((p = strchr(fp, '@'))) {
*p = '\0';
fu = strdup(fp);
*p = '+';
*p++ = '\0';
}
ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fu, proto, fp, profile->domain_name);
if (switch_strlen_zero(p)) {
p=profile->domain_name;
if (switch_strlen_zero(p)) {
p=host;
}
}
ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fp, proto, fp, p);
from = ffrom;
switch_safe_free(fu);
switch_safe_free(fp);
}