[asterisk-commits] kharwell: trunk r408883 - in /trunk: ./ include/asterisk/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 25 11:51:53 CST 2014
Author: kharwell
Date: Tue Feb 25 11:51:51 2014
New Revision: 408883
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408883
Log:
res_pjsip_exten_state: Presence for digium phones
Added presence support for digium phones.
Review: https://reviewboard.asterisk.org/r/3239/
........
Merged revisions 408882 from http://svn.asterisk.org/svn/asterisk/branches/12
Added:
trunk/res/res_pjsip_pidf_digium_body_supplement.c
- copied unchanged from r408882, branches/12/res/res_pjsip_pidf_digium_body_supplement.c
Modified:
trunk/ (props changed)
trunk/include/asterisk/res_pjsip_body_generator_types.h
trunk/res/res_pjsip_exten_state.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/include/asterisk/res_pjsip_body_generator_types.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/res_pjsip_body_generator_types.h?view=diff&rev=408883&r1=408882&r2=408883
==============================================================================
--- trunk/include/asterisk/res_pjsip_body_generator_types.h (original)
+++ trunk/include/asterisk/res_pjsip_body_generator_types.h Tue Feb 25 11:51:51 2014
@@ -36,6 +36,12 @@
enum ast_extension_states exten_state;
/*! The presence state of the change */
enum ast_presence_state presence_state;
+ /*! The presence subtype of the change */
+ char *presence_subtype;
+ /*! The presence message of the change */
+ char *presence_message;
+ /*! Subscriber user agent */
+ char *user_agent;
/*! Current device state information */
struct ao2_container *device_state_info;
/*! Local dialog URI */
Modified: trunk/res/res_pjsip_exten_state.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_exten_state.c?view=diff&rev=408883&r1=408882&r2=408883
==============================================================================
--- trunk/res/res_pjsip_exten_state.c (original)
+++ trunk/res/res_pjsip_exten_state.c Tue Feb 25 11:51:51 2014
@@ -57,8 +57,12 @@
char context[AST_MAX_CONTEXT];
/*! Extension within the context to receive updates from */
char exten[AST_MAX_EXTENSION];
+ /*! The subscription's user agent */
+ char *user_agent;
/*! The last known extension state */
enum ast_extension_states last_exten_state;
+ /*! The last known presence state */
+ enum ast_presence_state last_presence_state;
};
#define DEFAULT_PRESENCE_BODY "application/pidf+xml"
@@ -90,7 +94,27 @@
{
struct exten_state_subscription *sub = obj;
+ ast_free(sub->user_agent);
ao2_cleanup(sub->sip_sub);
+}
+
+static char *get_user_agent(pjsip_rx_data *rdata)
+{
+ static const pj_str_t USER_AGENT = { "User-Agent", 10 };
+
+ size_t size;
+ char *user_agent = NULL;
+ pjsip_user_agent_hdr *user_agent_hdr = pjsip_msg_find_hdr_by_name(
+ rdata->msg_info.msg, &USER_AGENT, NULL);
+
+ if (!user_agent_hdr) {
+ return NULL;
+ }
+
+ size = pj_strlen(&user_agent_hdr->hvalue) + 1;
+ user_agent = ast_malloc(size);
+ ast_copy_pj_str(user_agent, &user_agent_hdr->hvalue, size);
+ return ast_str_to_lower(user_agent);
}
/*!
@@ -125,7 +149,8 @@
}
exten_state_sub->last_exten_state = INITIAL_LAST_EXTEN_STATE;
-
+ exten_state_sub->last_presence_state = AST_PRESENCE_NOT_SET;
+ exten_state_sub->user_agent = get_user_agent(rdata);
ao2_ref(exten_state_sub, +1);
return exten_state_sub;
}
@@ -190,6 +215,9 @@
.exten = exten_state_sub->exten,
.presence_state = ast_hint_presence_state(NULL, exten_state_sub->context,
exten_state_sub->exten, &subtype, &message),
+ .presence_subtype = subtype,
+ .presence_message = message,
+ .user_agent = exten_state_sub->user_agent
};
dlg = ast_sip_subscription_get_dlg(exten_state_sub->sip_sub);
@@ -226,6 +254,9 @@
ao2_ref(task_data->exten_state_sub, -1);
ao2_cleanup(task_data->exten_state_data.device_state_info);
+ ast_free(task_data->exten_state_data.presence_subtype);
+ ast_free(task_data->exten_state_data.presence_message);
+ ast_free(task_data->exten_state_data.user_agent);
}
static struct notify_task_data *alloc_notify_task_data(char *exten, struct exten_state_subscription *exten_state_sub,
@@ -243,11 +274,15 @@
task_data->evsub_state = PJSIP_EVSUB_STATE_ACTIVE;
task_data->exten_state_sub = exten_state_sub;
task_data->exten_state_sub->last_exten_state = info->exten_state;
+ task_data->exten_state_sub->last_presence_state = info->presence_state;
ao2_ref(task_data->exten_state_sub, +1);
task_data->exten_state_data.exten = exten_state_sub->exten;
task_data->exten_state_data.exten_state = info->exten_state;
task_data->exten_state_data.presence_state = info->presence_state;
+ task_data->exten_state_data.presence_subtype = ast_strdup(info->presence_subtype);
+ task_data->exten_state_data.presence_message = ast_strdup(info->presence_message);
+ task_data->exten_state_data.user_agent = ast_strdup(exten_state_sub->user_agent);
task_data->exten_state_data.device_state_info = info->device_state_info;
if (task_data->exten_state_data.device_state_info) {
@@ -299,7 +334,8 @@
struct notify_task_data *task_data;
struct exten_state_subscription *exten_state_sub = data;
- if (exten_state_sub->last_exten_state == info->exten_state) {
+ if (exten_state_sub->last_exten_state == info->exten_state &&
+ exten_state_sub->last_presence_state == info->presence_state) {
return 0;
}
More information about the asterisk-commits
mailing list