SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t);
SWITCH_DECLARE(void) switch_cond_next(void);
+SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to,
+ const char *subject, const char *body, const char *type, const char *hint);
///\}
/*!
/*! the name of the interface */
const char *interface_name;
/*! function to open the directory interface */
- switch_status_t (*chat_send) (char *proto, char *from, char *to, char *subject, char *body, char *hint);
+ switch_status_t (*chat_send) (const char *proto, const char *from, const char *to,
+ const char *subject, const char *body, const char *type, const char *hint);
switch_thread_rwlock_t *rwlock;
int refs;
switch_mutex_t *reflock;
static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin);
static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop);
static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool);
-static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint);
+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
+ const char *body, const char *type, const char *hint);
+
static void launch_conference_record_thread(conference_obj_t *conference, char *path);
typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_stream_handle_t *, int, char **);
freeme = switch_mprintf("%s+%s@%s", CONF_CHAT_PROTO, member->conference->name, member->conference->domain);
to = freeme;
}
- chat_send(proto, from, to, subject, body, hint);
+ chat_send(proto, from, to, subject, body, NULL, hint);
switch_safe_free(freeme);
}
}
switch_thread_create(&thread, thd_attr, conference_record_thread_run, rec, rec->pool);
}
-static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
+ const char *body, const char *type, const char *hint)
{
char name[512] = "", *p, *lbuf = NULL;
- switch_chat_interface_t *ci;
conference_obj_t *conference = NULL;
switch_stream_handle_t stream = { 0 };
return SWITCH_STATUS_SUCCESS;
}
- if (!(ci = switch_loadable_module_get_chat_interface(proto))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
- return SWITCH_STATUS_FALSE;
- }
-
-
if ((p = strchr(to, '@'))) {
switch_copy_string(name, to, ++p - to);
} else {
if (!(conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, name))) {
- ci->chat_send(CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL);
+ switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", "Conference not active.", NULL, NULL);
return SWITCH_STATUS_FALSE;
}
switch_safe_free(lbuf);
- ci->chat_send(CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL);
+ switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL);
switch_safe_free(stream.data);
return SWITCH_STATUS_SUCCESS;
if (!switch_strlen_zero(cmd) && (lbuf = strdup(cmd))
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
- switch_chat_interface_t *ci;
-
- if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) {
- if (ci->chat_send("dp", argv[1], argv[2], "", argv[3], "") == SWITCH_STATUS_SUCCESS) {
- stream->write_function(stream, "Sent");
- } else {
- stream->write_function(stream, "Error! Message Not Sent");
- }
+
+ if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3], NULL, "") == SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "Sent");
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", argv[0]);
+ stream->write_function(stream, "Error! Message Not Sent");
}
} else {
stream->write_function(stream, "Invalid");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", WAIT_FOR_SILENCE_SYNTAX);
}
-static switch_status_t event_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
+static switch_status_t event_chat_send(const char *proto, const char *from, const char *to, const char *subject,
+ const char *body, const char *type, const char *hint)
{
switch_event_t *event;
return SWITCH_STATUS_MEMERR;
}
-static switch_status_t api_chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
+static switch_status_t api_chat_send(const char *proto, const char *from, const char *to, const char *subject,
+ const char *body, const char *type, const char *hint)
{
if (to) {
const char *v;
switch_stream_handle_t stream = { 0 };
char *cmd, *arg;
- switch_chat_interface_t *ci;
-
+
if (!(v = switch_core_get_variable(to))) {
v = to;
}
SWITCH_STANDARD_STREAM(stream);
switch_api_execute(cmd, arg, NULL, &stream);
- if (proto && (ci = switch_loadable_module_get_chat_interface(proto))) {
- ci->chat_send("api", to, hint && strchr(hint, '/') ? hint : from, "text/plain", (char *) stream.data, NULL);
+ if (proto) {
+ switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from, "text/plain", (char *) stream.data, NULL, NULL);
}
switch_safe_free(stream.data);
switch_safe_free(sql);
}
-static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
+ const char *body, const char *type, const char *hint);
{
char *user, *host, *f_user = NULL, *ffrom = NULL, *f_host = NULL, *f_resource = NULL;
mdl_profile_t *profile = NULL;
switch (dl_signal) {
case LDL_SIGNAL_MSG:{
- switch_chat_interface_t *ci;
- char *proto = MDL_CHAT_PROTO;
- char *pproto = NULL, *ffrom = NULL;
- char *hint;
+ char *proto = MDL_CHAT_PROTO;
+ char *pproto = NULL, *ffrom = NULL;
+ char *hint;
#ifdef AUTO_REPLY
if (profile->auto_reply) {
ldl_handle_send_msg(handle,
from = ffrom;
}
- if ((ci = switch_loadable_module_get_chat_interface(proto))) {
- ci->chat_send(MDL_CHAT_PROTO, from, to, subject, switch_str_nil(msg), hint);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
- }
+
+ switch_core_chat_send(proto, MDL_CHAT_PROTO, from, to, subject, switch_str_nil(msg), NULL, hint);
switch_safe_free(pproto);
switch_safe_free(ffrom);
void launch_sofia_profile_thread(sofia_profile_t *profile);
-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(const char *proto, const char *from, const char *to, const char *subject,
+ const char *body, const char *type, const char *hint);
void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt);
switch_status_t sofia_glue_tech_media(private_object_t *tech_pvt, const char *r_sdp);
char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const char *host, char *val, switch_size_t len);
char last_uuid[512];
};
-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(const char *proto, const char *from, const char *to, const char *subject,
+ const char *body, const char *type, const char *hint)
{
char buf[256];
char *prof = NULL, *user = NULL, *host = NULL;
}
}
} else {
- switch_chat_interface_t *ci;
- if ((ci = switch_loadable_module_get_chat_interface(proto))) {
- ci->chat_send(SOFIA_CHAT_PROTO, from_addr, to_addr, "", msg, full_from);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
- }
+ switch_core_chat_send(proto, SOFIA_CHAT_PROTO, from_addr, to_addr, "", msg, NULL, full_from);
}
switch_safe_free(to_addr);
switch_safe_free(from_addr);
return switch_test_flag((&runtime), SCF_RESTART) ? SWITCH_STATUS_RESTART : SWITCH_STATUS_SUCCESS;
}
+SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to,
+ const char *subject, const char *body, const char *type, const char *hint)
+{
+ switch_chat_interface_t *ci;
+ switch_status_t status;
+
+ if (!name || !(ci = switch_loadable_module_get_chat_interface(name)) || !ci->chat_send) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", name);
+ return SWITCH_STATUS_FALSE;
+ }
+
+ status = ci->chat_send(proto, from, to, subject, body, type, hint);
+
+ UNPROTECT_INTERFACE(ci);
+
+ return status;
+}
+
SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
{
const switch_management_interface_t *ptr;
return ret;
}
+
+
/* For Emacs:
* Local Variables:
* mode:c
HASH_FUNC(speech)
HASH_FUNC(asr)
HASH_FUNC(directory)
+HASH_FUNC(chat)
-SWITCH_DECLARE(switch_chat_interface_t *) switch_loadable_module_get_chat_interface(const char *name)
-{
- return switch_core_hash_find_locked(loadable_modules.chat_hash, name, loadable_modules.mutex);
-}
-
SWITCH_DECLARE(switch_say_interface_t *) switch_loadable_module_get_say_interface(const char *name)
{
return switch_core_hash_find_locked(loadable_modules.say_hash, name, loadable_modules.mutex);