add some more warning msgs

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8859 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-06-27 17:46:04 +00:00
parent 17b96b492c
commit 587bbe6557
2 changed files with 24 additions and 12 deletions

View File

@ -1080,8 +1080,11 @@ SWITCH_STANDARD_API(chat_api_function)
switch_chat_interface_t *ci; switch_chat_interface_t *ci;
if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) { if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) {
ci->chat_send("dp", argv[1], argv[2], "", argv[3], ""); if (ci->chat_send("dp", argv[1], argv[2], "", argv[3], "") == SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "Sent"); stream->write_function(stream, "Sent");
} else {
stream->write_function(stream, "Error! Message Not Sent");
}
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", argv[0]); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", argv[0]);
} }

View File

@ -52,14 +52,16 @@ 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, *host; char *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;
switch_status_t status = SWITCH_STATUS_FALSE;
if (!to) { if (!to) {
return SWITCH_STATUS_SUCCESS; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To: header.\n");
goto end;
} }
user = strdup(to); user = strdup(to);
@ -73,21 +75,22 @@ switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char
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]", host ? host : "NULL");
return SWITCH_STATUS_FALSE; goto end;
} }
if (!sofia_reg_find_reg_url(profile, user, host, buf, sizeof(buf))) { if (!sofia_reg_find_reg_url(profile, user, host, buf, sizeof(buf))) {
return SWITCH_STATUS_FALSE; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find user. [%s][%s]\n", user, host);
goto end;
} }
if (!strcmp(proto, SOFIA_CHAT_PROTO)) { if (!strcasecmp(proto, SOFIA_CHAT_PROTO)) {
from = hint; from = hint;
} else { } else {
char *fp, *p, *fu = NULL; char *fp, *p, *fu = NULL;
fp = strdup(from); fp = strdup(from);
if (!fp) { if (!fp) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
return SWITCH_STATUS_FALSE; goto end;
} }
if ((p = strchr(fp, '@'))) { if ((p = strchr(fp, '@'))) {
@ -96,27 +99,33 @@ switch_status_t sofia_presence_chat_send(char *proto, char *from, char *to, char
*p = '+'; *p = '+';
} }
ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fu, proto, fp, profile->name); ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fu, proto, fp, profile->domain_name);
from = ffrom; from = ffrom;
switch_safe_free(fu); switch_safe_free(fu);
switch_safe_free(fp); switch_safe_free(fp);
} }
status = SWITCH_STATUS_SUCCESS;
contact = sofia_glue_get_url_from_contact(buf, 1); contact = sofia_glue_get_url_from_contact(buf, 1);
msg_nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(buf), // if this cries, add contact here too, change the 1 to 0 and omit the safe_free // if this cries, add contact here too, change the 1 to 0 and omit the safe_free
msg_nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(buf),
SIPTAG_CONTACT_STR(profile->url), TAG_END()); SIPTAG_CONTACT_STR(profile->url), TAG_END());
switch_safe_free(contact); switch_safe_free(contact);
nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END()); nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
end:
switch_safe_free(ffrom); switch_safe_free(ffrom);
free(user); switch_safe_free(user);
if (profile) { if (profile) {
switch_thread_rwlock_unlock(profile->rwlock); switch_thread_rwlock_unlock(profile->rwlock);
} }
return SWITCH_STATUS_SUCCESS; return status;
} }
void sofia_presence_cancel(void) void sofia_presence_cancel(void)