summaryrefslogtreecommitdiff
path: root/pjsip/include
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-10-26 11:21:37 +0000
committerBenny Prijono <bennylp@teluu.com>2009-10-26 11:21:37 +0000
commit058d9c4c6d15338e1d3b2e05ffea340eec565d9a (patch)
treef2e22ada6b8929a60cf842f83a870c1a3d2bd921 /pjsip/include
parent295cdeb355d07347f2ba1f4a66ae144fee5efbf7 (diff)
Implement ticket #982: Support for SIP Message Summary/Message Waiting Indication (MWI, RFC 3842)
- PJSIP-SIMPLE: - implement MWI - PJSUA-LIB: - added "mwi_enabled" flag in account config - added "on_mwi_info" callback - pjsua app: - added "--mwi" option to enable MWI on account - added simple callback to log the NOTIFY message - other: - added SIPp scenario files to simulate UAS side - build: - added MWI support on VS6, VS2005, MMP, and Makefile git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2968 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include')
-rw-r--r--pjsip/include/pjsip-simple/mwi.h208
-rw-r--r--pjsip/include/pjsip/sip_msg.h12
-rw-r--r--pjsip/include/pjsip_simple.h1
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h30
-rw-r--r--pjsip/include/pjsua-lib/pjsua_internal.h7
5 files changed, 258 insertions, 0 deletions
diff --git a/pjsip/include/pjsip-simple/mwi.h b/pjsip/include/pjsip-simple/mwi.h
new file mode 100644
index 00000000..c1128372
--- /dev/null
+++ b/pjsip/include/pjsip-simple/mwi.h
@@ -0,0 +1,208 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef __PJSIP_SIMPLE_MWI_H__
+#define __PJSIP_SIMPLE_MWI_H__
+
+/**
+ * @file mwi.h
+ * @brief SIP Extension for MWI (RFC 3842)
+ */
+#include <pjsip-simple/evsub.h>
+#include <pjsip/sip_msg.h>
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @defgroup mwi SIP Message Summary and Message Waiting Indication (RFC 3842)
+ * @ingroup PJSIP_SIMPLE
+ * @brief Support for SIP MWI Extension (RFC 3842)
+ * @{
+ *
+ * This module implements RFC 3842: A Message Summary and Message Waiting
+ * Indication Event Package for the Session Initiation Protocol (SIP).
+ * It uses the SIP Event Notification framework (evsub.h) and extends the
+ * framework by implementing "message-summary" event package.
+ */
+
+
+/**
+ * Initialize the MWI module and register it as endpoint module and
+ * package to the event subscription module.
+ *
+ * @param endpt The endpoint instance.
+ * @param mod_evsub The event subscription module instance.
+ *
+ * @return PJ_SUCCESS if the module is successfully
+ * initialized and registered to both endpoint
+ * and the event subscription module.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_init_module(pjsip_endpoint *endpt,
+ pjsip_module *mod_evsub);
+
+/**
+ * Get the MWI module instance.
+ *
+ * @return The MWI module instance.
+ */
+PJ_DECL(pjsip_module*) pjsip_mwi_instance(void);
+
+/**
+ * Create MWI client subscription session.
+ *
+ * @param dlg The underlying dialog to use.
+ * @param user_cb Pointer to callbacks to receive MWI subscription
+ * events.
+ * @param options Option flags. Currently only PJSIP_EVSUB_NO_EVENT_ID
+ * is recognized.
+ * @param p_evsub Pointer to receive the MWI subscription
+ * session.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_create_uac( pjsip_dialog *dlg,
+ const pjsip_evsub_user *user_cb,
+ unsigned options,
+ pjsip_evsub **p_evsub );
+
+/**
+ * Create MWI server subscription session.
+ *
+ * @param dlg The underlying dialog to use.
+ * @param user_cb Pointer to callbacks to receive MWI subscription
+ * events.
+ * @param rdata The incoming SUBSCRIBE request that creates the event
+ * subscription.
+ * @param p_evsub Pointer to receive the MWI subscription
+ * session.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_create_uas( pjsip_dialog *dlg,
+ const pjsip_evsub_user *user_cb,
+ pjsip_rx_data *rdata,
+ pjsip_evsub **p_evsub );
+
+/**
+ * Forcefully destroy the MWI subscription. This function should only
+ * be called on special condition, such as when the subscription
+ * initialization has failed. For other conditions, application MUST terminate
+ * the subscription by sending the appropriate un(SUBSCRIBE) or NOTIFY.
+ *
+ * @param sub The MWI subscription.
+ * @param notify Specify whether the state notification callback
+ * should be called.
+ *
+ * @return PJ_SUCCESS if subscription session has been destroyed.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_terminate( pjsip_evsub *sub,
+ pj_bool_t notify );
+
+/**
+ * Call this function to create request to initiate MWI subscription, to
+ * refresh subcription, or to request subscription termination.
+ *
+ * @param sub Client subscription instance.
+ * @param expires Subscription expiration. If the value is set to zero,
+ * this will request unsubscription.
+ * @param p_tdata Pointer to receive the request.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_initiate( pjsip_evsub *sub,
+ pj_int32_t expires,
+ pjsip_tx_data **p_tdata);
+
+/**
+ * Accept the incoming subscription request by sending 2xx response to
+ * incoming SUBSCRIBE request.
+ *
+ * @param sub Server subscription instance.
+ * @param rdata The incoming subscription request message.
+ * @param st_code Status code, which MUST be final response.
+ * @param hdr_list Optional list of headers to be added in the response.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_accept( pjsip_evsub *sub,
+ pjsip_rx_data *rdata,
+ int st_code,
+ const pjsip_hdr *hdr_list );
+
+/**
+ * For notifier, create NOTIFY request to subscriber, and set the state
+ * of the subscription.
+ *
+ * @param sub The server subscription (notifier) instance.
+ * @param state New state to set.
+ * @param state_str The state string name, if state contains value other
+ * than active, pending, or terminated. Otherwise this
+ * argument is ignored.
+ * @param reason Specify reason if new state is terminated, otherwise
+ * put NULL.
+ * @param mime_type MIME type/content type of the message body.
+ * @param body Message body to be included in the NOTIFY request.
+ * @param p_tdata Pointer to receive the request.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_notify( pjsip_evsub *sub,
+ pjsip_evsub_state state,
+ const pj_str_t *state_str,
+ const pj_str_t *reason,
+ const pjsip_media_type *mime_type,
+ const pj_str_t *body,
+ pjsip_tx_data **p_tdata);
+
+/**
+ * Create NOTIFY request containing message body from the last NOITFY
+ * message created.
+ *
+ * @param sub Server subscription object.
+ * @param p_tdata Pointer to receive request.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_current_notify( pjsip_evsub *sub,
+ pjsip_tx_data **p_tdata );
+
+
+/**
+ * Send request message that was previously created with initiate(), notify(),
+ * or current_notify(). Application may also send request created with other
+ * functions, e.g. authentication. But the request MUST be either request
+ * that creates/refresh subscription or NOTIFY request.
+ *
+ * @param sub The subscription object.
+ * @param tdata Request message to be sent.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_mwi_send_request( pjsip_evsub *sub,
+ pjsip_tx_data *tdata );
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+
+#endif /* __PJSIP_SIMPLE_MWI_H__ */
diff --git a/pjsip/include/pjsip/sip_msg.h b/pjsip/include/pjsip/sip_msg.h
index 437f9b2a..1ca065fe 100644
--- a/pjsip/include/pjsip/sip_msg.h
+++ b/pjsip/include/pjsip/sip_msg.h
@@ -511,6 +511,18 @@ typedef struct pjsip_media_type
pj_str_t param; /**< Media type parameters (concatenated). */
} pjsip_media_type;
+
+/**
+ * Copy SIP media type to another.
+ *
+ * @param pool Pool to duplicate strings.
+ * @param dst Destination structure.
+ * @param src Source structure.
+ */
+PJ_DECL(void) pjsip_media_type_cp(pj_pool_t *pool,
+ pjsip_media_type *dst,
+ const pjsip_media_type *src);
+
/**
* @}
*/
diff --git a/pjsip/include/pjsip_simple.h b/pjsip/include/pjsip_simple.h
index 8fda8152..87ad120e 100644
--- a/pjsip/include/pjsip_simple.h
+++ b/pjsip/include/pjsip_simple.h
@@ -37,6 +37,7 @@
#include <pjsip-simple/evsub.h>
#include <pjsip-simple/evsub_msg.h>
#include <pjsip-simple/iscomposing.h>
+#include <pjsip-simple/mwi.h>
#include <pjsip-simple/presence.h>
#include <pjsip-simple/pidf.h>
#include <pjsip-simple/publish.h>
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 356cab76..a8bb2f39 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -379,6 +379,17 @@ PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
/**
+ * Structure to be passed on MWI callback.
+ */
+typedef struct pjsua_mwi_info
+{
+ pjsip_evsub *evsub; /**< Event subscription session, for
+ reference. */
+ pjsip_rx_data *rdata; /**< The received NOTIFY request. */
+} pjsua_mwi_info;
+
+
+/**
* This structure describes application callback to receive various event
* notification from PJSUA-API. All of these callbacks are OPTIONAL,
* although definitely application would want to implement some of
@@ -821,6 +832,17 @@ typedef struct pjsua_callback
const pjsip_uri *target,
const pjsip_event *e);
+ /**
+ * This callback is called when a NOTIFY request for message summary /
+ * message waiting indication is received.
+ *
+ * @param acc_id The account ID.
+ * @param mwi_info Structure containing details of the event,
+ * including the received NOTIFY request in the
+ * \a rdata field.
+ */
+ void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
+
} pjsua_callback;
@@ -1860,6 +1882,14 @@ typedef struct pjsua_acc_config
pj_str_t reg_uri;
/**
+ * Enable message summary and message waiting indication subscription
+ * (RFC 3842) for this account.
+ *
+ * Default: no
+ */
+ pj_bool_t mwi_enabled;
+
+ /**
* If this flag is set, the presence information of this account will
* be PUBLISH-ed to the server where the account belongs.
*
diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h
index 0f777967..c90da124 100644
--- a/pjsip/include/pjsua-lib/pjsua_internal.h
+++ b/pjsip/include/pjsua-lib/pjsua_internal.h
@@ -144,6 +144,8 @@ typedef struct pjsua_acc
pjsip_publishc *publish_sess; /**< Client publication session. */
pj_bool_t publish_state; /**< Last published online status */
+ pjsip_evsub *mwi_sub; /**< MWI client subscription */
+ pjsip_dialog *mwi_dlg; /**< Dialog for MWI sub. */
} pjsua_acc;
@@ -452,6 +454,11 @@ void pjsua_pres_delete_acc(int acc_id);
pj_status_t pjsua_im_init(void);
/**
+ * Start MWI subscription
+ */
+void pjsua_start_mwi(pjsua_acc *acc);
+
+/**
* Init call subsystem.
*/
pj_status_t pjsua_call_subsys_init(const pjsua_config *cfg);