[Freeswitch-svn] [commit] r11320 - in freeswitch/trunk/src/mod: applications/mod_dptools endpoints/mod_sofia
FreeSWITCH SVN
brian at freeswitch.org
Tue Jan 20 13:24:38 PST 2009
Author: brian
Date: Tue Jan 20 15:24:37 2009
New Revision: 11320
Log:
fix MODENDP-173
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Tue Jan 20 15:24:37 2009
@@ -1064,13 +1064,14 @@
SWITCH_STANDARD_API(chat_api_function)
{
- char *lbuf, *argv[4];
+ char *lbuf, *argv[5];
int argc = 0;
if (!switch_strlen_zero(cmd) && (lbuf = strdup(cmd))
- && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
-
- if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3], NULL, "") == SWITCH_STATUS_SUCCESS) {
+ && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) {
+
+ if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3],
+ !switch_strlen_zero(argv[4]) ? argv[4] : NULL , "") == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "Sent");
} else {
stream->write_function(stream, "Error! Message Not Sent");
@@ -2487,7 +2488,8 @@
switch_api_execute(cmd, arg, NULL, &stream);
if (proto) {
- switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from, "text/plain", (char *) stream.data, NULL, NULL);
+ switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from,
+ !switch_strlen_zero(type) ? type : NULL, (char *) stream.data, NULL, NULL);
}
switch_safe_free(stream.data);
@@ -2540,7 +2542,7 @@
SWITCH_ADD_CHAT(chat_interface, "api", api_chat_send);
SWITCH_ADD_API(api_interface, "strepoch", "Convert a date string into epoch time", strepoch_api_function, "<string>");
- SWITCH_ADD_API(api_interface, "chat", "chat", chat_api_function, "<proto>|<from>|<to>|<message>");
+ SWITCH_ADD_API(api_interface, "chat", "chat", chat_api_function, "<proto>|<from>|<to>|<message>|[<content-type>]");
SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, "<format_string>");
SWITCH_ADD_API(api_interface, "presence", "presence", presence_api_function, "<user> <rpid> <message>");
SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number",
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Tue Jan 20 15:24:37 2009
@@ -62,15 +62,15 @@
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 @@
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 @@
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);
}
More information about the Freeswitch-svn
mailing list