提交 0715b44f authored 作者: Anthony Minessale's avatar Anthony Minessale

(SFSIP-83) chat (send an IM) assumes that the user's profile is the same as…

(SFSIP-83) chat (send an IM) assumes that the user's profile is the same as their domain, which isn't necessarily so

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9686 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 75df7a47
...@@ -52,11 +52,12 @@ struct presence_helper { ...@@ -52,11 +52,12 @@ struct presence_helper {
switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint) switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
{ {
char buf[256]; char buf[256];
char *user = NULL, *host = NULL; char *prof = NULL, *user = NULL, *host = NULL;
sofia_profile_t *profile = NULL; sofia_profile_t *profile = NULL;
char *ffrom = NULL; char *ffrom = NULL;
nua_handle_t *msg_nh; nua_handle_t *msg_nh;
char *contact; char *contact;
char *dup = NULL;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
const char *ct = "text/html"; const char *ct = "text/html";
...@@ -69,17 +70,27 @@ switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char ...@@ -69,17 +70,27 @@ switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char
goto end; goto end;
} }
user = strdup(to); dup = strdup(to);
switch_assert(user); switch_assert(dup);
prof = dup;
// Do we have a user of the form profile/user[@host]?
if ((user = strchr(prof, '/'))) {
*user++ = '\0';
} else {
user = prof;
prof = NULL;
}
if ((host = strchr(user, '@'))) { if ((host = strchr(user, '@'))) {
*host++ = '\0'; *host++ = '\0';
if (!prof) prof = host;
} }
if (!host || !(profile = sofia_glue_find_profile(host))) { if (!host || !(profile = sofia_glue_find_profile(prof))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 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, "Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", proto, from, to,
body ? body : "[no body]", host ? host : "NULL"); body ? body : "[no body]", prof ? prof : "NULL");
goto end; goto end;
} }
...@@ -123,7 +134,7 @@ switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char ...@@ -123,7 +134,7 @@ switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char
end: end:
switch_safe_free(ffrom); switch_safe_free(ffrom);
switch_safe_free(user); switch_safe_free(dup);
if (profile) { if (profile) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论