xmas presence
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3719 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
0c38d21951
commit
fc85d8aa21
|
@ -297,7 +297,7 @@ ldl_status ldl_session_create(ldl_session_t **session_p, ldl_handle_t *handle, c
|
||||||
static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, char *to, iks *xml, char *xtype)
|
static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from, char *to, iks *xml, char *xtype)
|
||||||
{
|
{
|
||||||
ldl_session_t *session = NULL;
|
ldl_session_t *session = NULL;
|
||||||
ldl_signal_t signal = LDL_SIGNAL_NONE;
|
ldl_signal_t dl_signal = LDL_SIGNAL_NONE;
|
||||||
char *initiator = iks_find_attrib(xml, "initiator");
|
char *initiator = iks_find_attrib(xml, "initiator");
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
|
||||||
|
|
||||||
if (!strcasecmp(type, "initiate") || !strcasecmp(type, "accept")) {
|
if (!strcasecmp(type, "initiate") || !strcasecmp(type, "accept")) {
|
||||||
|
|
||||||
signal = LDL_SIGNAL_INITIATE;
|
dl_signal = LDL_SIGNAL_INITIATE;
|
||||||
if (!strcasecmp(type, "accept")) {
|
if (!strcasecmp(type, "accept")) {
|
||||||
msg = "accept";
|
msg = "accept";
|
||||||
}
|
}
|
||||||
|
@ -363,10 +363,10 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
|
||||||
tag = iks_next_tag(tag);
|
tag = iks_next_tag(tag);
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(type, "transport-accept")) {
|
} else if (!strcasecmp(type, "transport-accept")) {
|
||||||
signal = LDL_SIGNAL_TRANSPORT_ACCEPT;
|
dl_signal = LDL_SIGNAL_TRANSPORT_ACCEPT;
|
||||||
} else if (!strcasecmp(type, "transport-info")) {
|
} else if (!strcasecmp(type, "transport-info")) {
|
||||||
char *tid = iks_find_attrib(xml, "id");
|
char *tid = iks_find_attrib(xml, "id");
|
||||||
signal = LDL_SIGNAL_CANDIDATES;
|
dl_signal = LDL_SIGNAL_CANDIDATES;
|
||||||
tag = iks_child (xml);
|
tag = iks_child (xml);
|
||||||
|
|
||||||
if (tag && !strcasecmp(iks_name(tag), "transport")) {
|
if (tag && !strcasecmp(iks_name(tag), "transport")) {
|
||||||
|
@ -458,17 +458,17 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
|
||||||
tag = iks_next_tag(tag);
|
tag = iks_next_tag(tag);
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(type, "terminate")) {
|
} else if (!strcasecmp(type, "terminate")) {
|
||||||
signal = LDL_SIGNAL_TERMINATE;
|
dl_signal = LDL_SIGNAL_TERMINATE;
|
||||||
} else if (!strcasecmp(type, "error")) {
|
} else if (!strcasecmp(type, "error")) {
|
||||||
signal = LDL_SIGNAL_ERROR;
|
dl_signal = LDL_SIGNAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = iks_child(xml);
|
xml = iks_child(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle->session_callback && signal) {
|
if (handle->session_callback && dl_signal) {
|
||||||
handle->session_callback(handle, session, signal, to, from, id, msg);
|
handle->session_callback(handle, session, dl_signal, to, from, id, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LDL_STATUS_SUCCESS;
|
return LDL_STATUS_SUCCESS;
|
||||||
|
@ -700,20 +700,22 @@ static int on_presence(void *user_data, ikspak *pak)
|
||||||
char id[1024];
|
char id[1024];
|
||||||
char *resource;
|
char *resource;
|
||||||
struct ldl_buffer *buffer;
|
struct ldl_buffer *buffer;
|
||||||
ldl_signal_t signal;
|
ldl_signal_t dl_signal = LDL_SIGNAL_PRESENCE_IN;
|
||||||
|
|
||||||
|
if (type && *type) {
|
||||||
if (type && !strcasecmp(type, "unavailable")) {
|
if (!strcasecmp(type, "unavailable")) {
|
||||||
signal = LDL_SIGNAL_PRESENCE_OUT;
|
dl_signal = LDL_SIGNAL_PRESENCE_OUT;
|
||||||
} else if (type && !strcasecmp(type, "probe")) {
|
} else if (!strcasecmp(type, "probe")) {
|
||||||
signal = LDL_SIGNAL_PRESENCE_PROBE;
|
dl_signal = LDL_SIGNAL_PRESENCE_PROBE;
|
||||||
} else {
|
}
|
||||||
signal = LDL_SIGNAL_PRESENCE_IN;
|
if (!status) {
|
||||||
}
|
status = type;
|
||||||
|
}
|
||||||
if (!status) {
|
} else {
|
||||||
status = type;
|
if (!status) {
|
||||||
}
|
status = "Available";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
apr_cpystrn(id, from, sizeof(id));
|
apr_cpystrn(id, from, sizeof(id));
|
||||||
|
@ -738,7 +740,7 @@ static int on_presence(void *user_data, ikspak *pak)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle->session_callback) {
|
if (handle->session_callback) {
|
||||||
handle->session_callback(handle, NULL, signal, to, id, status ? status : "n/a", show ? show : "n/a");
|
handle->session_callback(handle, NULL, dl_signal, to, id, status ? status : "n/a", show ? show : "n/a");
|
||||||
}
|
}
|
||||||
|
|
||||||
return IKS_FILTER_EAT;
|
return IKS_FILTER_EAT;
|
||||||
|
|
|
@ -187,7 +187,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||||
switch_io_flag_t flags, int stream_id);
|
switch_io_flag_t flags, int stream_id);
|
||||||
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
||||||
|
|
||||||
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t signal, char *to, char *from, char *subject, char *msg);
|
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg);
|
||||||
static ldl_status handle_response(ldl_handle_t *handle, char *id);
|
static ldl_status handle_response(ldl_handle_t *handle, char *id);
|
||||||
static switch_status_t load_config(void);
|
static switch_status_t load_config(void);
|
||||||
|
|
||||||
|
@ -2065,7 +2065,7 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
|
||||||
switch_safe_free(xmlstr);
|
switch_safe_free(xmlstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t signal, char *to, char *from, char *subject, char *msg)
|
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg)
|
||||||
{
|
{
|
||||||
struct mdl_profile *profile = NULL;
|
struct mdl_profile *profile = NULL;
|
||||||
switch_core_session_t *session = NULL;
|
switch_core_session_t *session = NULL;
|
||||||
|
@ -2085,7 +2085,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
|
|
||||||
if (!dlsession) {
|
if (!dlsession) {
|
||||||
if (profile->user_flags & LDL_FLAG_COMPONENT) {
|
if (profile->user_flags & LDL_FLAG_COMPONENT) {
|
||||||
switch(signal) {
|
switch(dl_signal) {
|
||||||
case LDL_SIGNAL_VCARD:
|
case LDL_SIGNAL_VCARD:
|
||||||
do_vcard(handle, to, from, subject);
|
do_vcard(handle, to, from, subject);
|
||||||
break;
|
break;
|
||||||
|
@ -2174,8 +2174,8 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
case LDL_SIGNAL_PRESENCE_OUT:
|
case LDL_SIGNAL_PRESENCE_OUT:
|
||||||
|
|
||||||
|
@ -2183,7 +2183,8 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
execute_sql(profile->dbname, sql, profile->mutex);
|
execute_sql(profile->dbname, sql, profile->mutex);
|
||||||
switch_core_db_free(sql);
|
switch_core_db_free(sql);
|
||||||
}
|
}
|
||||||
|
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXNO FUCKING WAY!!! %d %d\n", dl_signal, LDL_SIGNAL_PRESENCE_OUT);
|
||||||
|
abort();
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", profile->login);
|
||||||
|
@ -2196,7 +2197,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(signal) {
|
switch(dl_signal) {
|
||||||
case LDL_SIGNAL_MSG: {
|
case LDL_SIGNAL_MSG: {
|
||||||
switch_chat_interface_t *ci;
|
switch_chat_interface_t *ci;
|
||||||
char *proto = MDL_CHAT_PROTO;
|
char *proto = MDL_CHAT_PROTO;
|
||||||
|
@ -2284,7 +2285,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (signal != LDL_SIGNAL_INITIATE) {
|
if (dl_signal != LDL_SIGNAL_INITIATE) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session is already dead\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session is already dead\n");
|
||||||
status = LDL_STATUS_FALSE;
|
status = LDL_STATUS_FALSE;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -2325,7 +2326,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(signal) {
|
switch(dl_signal) {
|
||||||
case LDL_SIGNAL_MSG:
|
case LDL_SIGNAL_MSG:
|
||||||
if (msg) {
|
if (msg) {
|
||||||
if (*msg == '+') {
|
if (*msg == '+') {
|
||||||
|
@ -2370,7 +2371,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
|
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
|
||||||
break;
|
break;
|
||||||
case LDL_SIGNAL_INITIATE:
|
case LDL_SIGNAL_INITIATE:
|
||||||
if (signal) {
|
if (dl_signal) {
|
||||||
ldl_payload_t *payloads;
|
ldl_payload_t *payloads;
|
||||||
unsigned int len = 0;
|
unsigned int len = 0;
|
||||||
int match = 0;
|
int match = 0;
|
||||||
|
@ -2448,7 +2449,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LDL_SIGNAL_CANDIDATES:
|
case LDL_SIGNAL_CANDIDATES:
|
||||||
if (signal) {
|
if (dl_signal) {
|
||||||
ldl_candidate_t *candidates;
|
ldl_candidate_t *candidates;
|
||||||
unsigned int len = 0;
|
unsigned int len = 0;
|
||||||
unsigned int x;
|
unsigned int x;
|
||||||
|
|
|
@ -3234,7 +3234,10 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||||
open = "closed";
|
open = "closed";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp(proto, SOFIA_CHAT_PROTO)) {
|
if (!strcasecmp(sub_to_host, host)) {
|
||||||
|
/* same host */
|
||||||
|
id = switch_mprintf("sip:%s+%s@%s", proto, sub_to_user, sub_to_host);
|
||||||
|
} else if (strcasecmp(proto, SOFIA_CHAT_PROTO)) {
|
||||||
/*encapsulate*/
|
/*encapsulate*/
|
||||||
id = switch_mprintf("sip:%s+%s+%s@%s", proto, sub_to_user, sub_to_host, host);
|
id = switch_mprintf("sip:%s+%s+%s@%s", proto, sub_to_user, sub_to_host, host);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3268,7 +3271,7 @@ static int sub_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||||
nua_notify(nh,
|
nua_notify(nh,
|
||||||
NUTAG_URL(contact),
|
NUTAG_URL(contact),
|
||||||
SIPTAG_TO_STR(full_from),
|
SIPTAG_TO_STR(full_from),
|
||||||
SIPTAG_FROM_STR(to),
|
SIPTAG_FROM_STR(id),
|
||||||
SIPTAG_CONTACT_STR(profile->url),
|
SIPTAG_CONTACT_STR(profile->url),
|
||||||
SIPTAG_CALL_ID_STR(callid),
|
SIPTAG_CALL_ID_STR(callid),
|
||||||
SIPTAG_VIA_STR(full_via),
|
SIPTAG_VIA_STR(full_via),
|
||||||
|
@ -3406,6 +3409,13 @@ static void sip_i_subscribe(int status,
|
||||||
exp_raw = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
|
exp_raw = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
|
||||||
exp = (long) time(NULL) + exp_raw;
|
exp = (long) time(NULL) + exp_raw;
|
||||||
|
|
||||||
|
if (sip && sip->sip_from) {
|
||||||
|
from_user = (char *) sip->sip_from->a_url->url_user;
|
||||||
|
from_host = (char *) sip->sip_from->a_url->url_host;
|
||||||
|
} else {
|
||||||
|
from_user = "n/a";
|
||||||
|
from_host = "n/a";
|
||||||
|
}
|
||||||
|
|
||||||
if ((sql = switch_mprintf("delete from sip_subscriptions where "
|
if ((sql = switch_mprintf("delete from sip_subscriptions where "
|
||||||
"proto='%q' and user='%q' and host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q';\n"
|
"proto='%q' and user='%q' and host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q';\n"
|
||||||
|
|
Loading…
Reference in New Issue