mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 23:38:23 +00:00
Add support for ICE/STUN/TURN in res_rtp_asterisk and chan_sip.
Review: https://reviewboard.asterisk.org/r/1891/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369517 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
118
res/pjproject/pjsip/include/pjsip-simple/errno.h
Normal file
118
res/pjproject/pjsip/include/pjsip-simple/errno.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_ERRNO_H__
|
||||
#define __PJSIP_SIMPLE_ERRNO_H__
|
||||
|
||||
#include <pjsip/sip_errno.h>
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Start of error code relative to PJ_ERRNO_START_USER.
|
||||
*/
|
||||
#define PJSIP_SIMPLE_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*2)
|
||||
|
||||
|
||||
/************************************************************
|
||||
* EVENT PACKAGE ERRORS
|
||||
***********************************************************/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* No event package with the specified name.
|
||||
*/
|
||||
#define PJSIP_SIMPLE_ENOPKG (PJSIP_SIMPLE_ERRNO_START+1) /*270001*/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* Event package already exists.
|
||||
*/
|
||||
#define PJSIP_SIMPLE_EPKGEXISTS (PJSIP_SIMPLE_ERRNO_START+2) /*270002*/
|
||||
|
||||
|
||||
/************************************************************
|
||||
* PRESENCE ERROR
|
||||
***********************************************************/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* Expecting SUBSCRIBE request
|
||||
*/
|
||||
#define PJSIP_SIMPLE_ENOTSUBSCRIBE (PJSIP_SIMPLE_ERRNO_START+20) /*270020*/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* No presence associated with subscription
|
||||
*/
|
||||
#define PJSIP_SIMPLE_ENOPRESENCE (PJSIP_SIMPLE_ERRNO_START+21) /*270021*/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* No presence info in server subscription
|
||||
*/
|
||||
#define PJSIP_SIMPLE_ENOPRESENCEINFO (PJSIP_SIMPLE_ERRNO_START+22) /*270022*/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* Bad Content-Type
|
||||
*/
|
||||
#define PJSIP_SIMPLE_EBADCONTENT (PJSIP_SIMPLE_ERRNO_START+23) /*270023*/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* Bad PIDF Message
|
||||
*/
|
||||
#define PJSIP_SIMPLE_EBADPIDF (PJSIP_SIMPLE_ERRNO_START+24) /*270024*/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* Bad XPIDF Message
|
||||
*/
|
||||
#define PJSIP_SIMPLE_EBADXPIDF (PJSIP_SIMPLE_ERRNO_START+25) /*270025*/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* Bad RPID Message
|
||||
*/
|
||||
#define PJSIP_SIMPLE_EBADRPID (PJSIP_SIMPLE_ERRNO_START+26) /*270026*/
|
||||
|
||||
|
||||
/************************************************************
|
||||
* ISCOMPOSING ERRORS
|
||||
***********************************************************/
|
||||
/**
|
||||
* @hideinitializer
|
||||
* Bad isComposing XML message.
|
||||
*/
|
||||
#define PJSIP_SIMPLE_EBADISCOMPOSE (PJSIP_SIMPLE_ERRNO_START+40) /*270040*/
|
||||
|
||||
/**
|
||||
* Get error message for the specified error code. Note that this
|
||||
* function is only able to decode PJSIP-SIMPLE specific error code.
|
||||
* Application should use pj_strerror(), which should be able to
|
||||
* decode all error codes belonging to all subsystems (e.g. pjlib,
|
||||
* pjmedia, pjsip, etc).
|
||||
*
|
||||
* @param status The error code.
|
||||
* @param buffer The buffer where to put the error message.
|
||||
* @param bufsize Size of the buffer.
|
||||
*
|
||||
* @return The error message as NULL terminated string,
|
||||
* wrapped with pj_str_t.
|
||||
*/
|
||||
PJ_DECL(pj_str_t) pjsipsimple_strerror(pj_status_t status,
|
||||
char *buffer, pj_size_t bufsize);
|
||||
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_ERRNO_H__ */
|
||||
|
||||
505
res/pjproject/pjsip/include/pjsip-simple/evsub.h
Normal file
505
res/pjproject/pjsip/include/pjsip-simple/evsub.h
Normal file
@@ -0,0 +1,505 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_EVSUB_H__
|
||||
#define __PJSIP_SIMPLE_EVSUB_H__
|
||||
|
||||
/**
|
||||
* @file evsub.h
|
||||
* @brief SIP Specific Event Notification Extension (RFC 3265)
|
||||
*/
|
||||
|
||||
#include <pjsip-simple/types.h>
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup PJSIP_EVENT_NOT SIP Event Notification (RFC 3265) Module
|
||||
* @ingroup PJSIP_SIMPLE
|
||||
* @brief Core Event Subscription framework, used by presence, call transfer, etc.
|
||||
* @{
|
||||
*
|
||||
* This module provides the implementation of SIP Extension for SIP Specific
|
||||
* Event Notification (RFC 3265). It extends PJSIP by supporting SUBSCRIBE and
|
||||
* NOTIFY methods.
|
||||
*
|
||||
* This module itself is extensible; new event packages can be registered to
|
||||
* this module to handle specific extensions (such as presence).
|
||||
*/
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
|
||||
/**
|
||||
* Opaque type for event subscription session.
|
||||
*/
|
||||
typedef struct pjsip_evsub pjsip_evsub;
|
||||
|
||||
|
||||
/**
|
||||
* This enumeration describes basic subscription state as described in the
|
||||
* RFC 3265. The standard specifies that extensions may define additional
|
||||
* states. In the case where the state is not known, the subscription state
|
||||
* will be set to PJSIP_EVSUB_STATE_UNKNOWN, and the token will be kept
|
||||
* in state_str member of the susbcription structure.
|
||||
*/
|
||||
enum pjsip_evsub_state
|
||||
{
|
||||
PJSIP_EVSUB_STATE_NULL, /**< State is NULL. */
|
||||
PJSIP_EVSUB_STATE_SENT, /**< Client has sent SUBSCRIBE request. */
|
||||
PJSIP_EVSUB_STATE_ACCEPTED, /**< 2xx response to SUBSCRIBE has been
|
||||
sent/received. */
|
||||
PJSIP_EVSUB_STATE_PENDING, /**< Subscription is pending. */
|
||||
PJSIP_EVSUB_STATE_ACTIVE, /**< Subscription is active. */
|
||||
PJSIP_EVSUB_STATE_TERMINATED,/**< Subscription is terminated. */
|
||||
PJSIP_EVSUB_STATE_UNKNOWN, /**< Subscription state can not be determined.
|
||||
Application can query the state by
|
||||
calling #pjsip_evsub_get_state_name().*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @see pjsip_evsub_state
|
||||
*/
|
||||
typedef enum pjsip_evsub_state pjsip_evsub_state;
|
||||
|
||||
|
||||
/**
|
||||
* Some options for the event subscription.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
/**
|
||||
* If this flag is set, then outgoing request to create subscription
|
||||
* will not have id in the Event header (e.g. in REFER request). But if
|
||||
* there is an id in the incoming NOTIFY, that id will be used.
|
||||
*/
|
||||
PJSIP_EVSUB_NO_EVENT_ID = 1,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This structure describes callback that is registered by application or
|
||||
* package to receive notifications about subscription events.
|
||||
*/
|
||||
struct pjsip_evsub_user
|
||||
{
|
||||
/**
|
||||
* This callback is called when subscription state has changed.
|
||||
* Application MUST be prepared to receive NULL event and events with
|
||||
* type other than PJSIP_EVENT_TSX_STATE
|
||||
*
|
||||
* This callback is OPTIONAL.
|
||||
*
|
||||
* @param sub The subscription instance.
|
||||
* @param event The event that has caused the state to change,
|
||||
* which may be NULL or may have type other than
|
||||
* PJSIP_EVENT_TSX_STATE.
|
||||
*/
|
||||
void (*on_evsub_state)( pjsip_evsub *sub, pjsip_event *event);
|
||||
|
||||
/**
|
||||
* This callback is called when transaction state has changed.
|
||||
*
|
||||
* @param sub The subscription instance.
|
||||
* @param tsx Transaction.
|
||||
* @param event The event.
|
||||
*/
|
||||
void (*on_tsx_state)(pjsip_evsub *sub, pjsip_transaction *tsx,
|
||||
pjsip_event *event);
|
||||
|
||||
/**
|
||||
* This callback is called when incoming SUBSCRIBE (or any method that
|
||||
* establishes the subscription in the first place) is received. It
|
||||
* allows application to specify what response should be sent to
|
||||
* remote, along with additional headers and message body to be put
|
||||
* in the response.
|
||||
*
|
||||
* This callback is OPTIONAL.
|
||||
*
|
||||
* However, implementation MUST send NOTIFY request upon receiving this
|
||||
* callback. The suggested behavior is to call
|
||||
* #pjsip_evsub_current_notify(), since this function takes care
|
||||
* about unsubscription request and calculates the appropriate expiration
|
||||
* interval.
|
||||
*/
|
||||
void (*on_rx_refresh)( pjsip_evsub *sub,
|
||||
pjsip_rx_data *rdata,
|
||||
int *p_st_code,
|
||||
pj_str_t **p_st_text,
|
||||
pjsip_hdr *res_hdr,
|
||||
pjsip_msg_body **p_body);
|
||||
|
||||
/**
|
||||
* This callback is called when client/subscriber received incoming
|
||||
* NOTIFY request. It allows the application to specify what response
|
||||
* should be sent to remote, along with additional headers and message
|
||||
* body to be put in the response.
|
||||
*
|
||||
* This callback is OPTIONAL. When it is not implemented, the default
|
||||
* behavior is to respond incoming NOTIFY request with 200 (OK).
|
||||
*
|
||||
* @param sub The subscription instance.
|
||||
* @param rdata The received NOTIFY request.
|
||||
* @param p_st_code Application MUST set the value of this argument with
|
||||
* final status code (200-699) upon returning from the
|
||||
* callback.
|
||||
* @param p_st_text Custom status text, if any.
|
||||
* @param res_hdr Upon return, application can put additional headers
|
||||
* to be sent in the response in this list.
|
||||
* @param p_body Application MAY specify message body to be sent in
|
||||
* the response.
|
||||
*/
|
||||
void (*on_rx_notify)(pjsip_evsub *sub,
|
||||
pjsip_rx_data *rdata,
|
||||
int *p_st_code,
|
||||
pj_str_t **p_st_text,
|
||||
pjsip_hdr *res_hdr,
|
||||
pjsip_msg_body **p_body);
|
||||
|
||||
/**
|
||||
* This callback is called when it is time for the client to refresh
|
||||
* the subscription.
|
||||
*
|
||||
* This callback is OPTIONAL when PJSIP package such as presence or
|
||||
* refer is used; the event package will refresh subscription by sending
|
||||
* SUBSCRIBE with the interval set to current/last interval.
|
||||
*
|
||||
* @param sub The subscription instance.
|
||||
*/
|
||||
void (*on_client_refresh)(pjsip_evsub *sub);
|
||||
|
||||
/**
|
||||
* This callback is called when server doesn't receive subscription
|
||||
* refresh after the specified subscription interval.
|
||||
*
|
||||
* This callback is OPTIONAL when PJSIP package such as presence or
|
||||
* refer is used; the event package send NOTIFY to terminate the
|
||||
* subscription.
|
||||
*/
|
||||
void (*on_server_timeout)(pjsip_evsub *sub);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @see pjsip_evsub_user
|
||||
*/
|
||||
typedef struct pjsip_evsub_user pjsip_evsub_user;
|
||||
|
||||
|
||||
/**
|
||||
* SUBSCRIBE method constant. @see pjsip_get_subscribe_method()
|
||||
*/
|
||||
PJ_DECL_DATA(const pjsip_method) pjsip_subscribe_method;
|
||||
|
||||
/**
|
||||
* NOTIFY method constant. @see pjsip_get_notify_method()
|
||||
*/
|
||||
PJ_DECL_DATA(const pjsip_method) pjsip_notify_method;
|
||||
|
||||
/**
|
||||
* SUBSCRIBE method constant.
|
||||
*/
|
||||
PJ_DECL(const pjsip_method*) pjsip_get_subscribe_method(void);
|
||||
|
||||
/**
|
||||
* NOTIFY method constant.
|
||||
*/
|
||||
PJ_DECL(const pjsip_method*) pjsip_get_notify_method(void);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the event subscription module and register the module to the
|
||||
* specified endpoint.
|
||||
*
|
||||
* @param endpt The endpoint instance.
|
||||
*
|
||||
* @return PJ_SUCCESS if module can be created and registered
|
||||
* successfully.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_init_module(pjsip_endpoint *endpt);
|
||||
|
||||
|
||||
/**
|
||||
* Get the event subscription module instance that was previously created
|
||||
* and registered to endpoint.
|
||||
*
|
||||
* @return The event subscription module instance.
|
||||
*/
|
||||
PJ_DECL(pjsip_module*) pjsip_evsub_instance(void);
|
||||
|
||||
|
||||
/**
|
||||
* Register event package to the event subscription framework.
|
||||
*
|
||||
* @param pkg_mod The module that implements the event package being
|
||||
* registered.
|
||||
* @param event_name Event package identification.
|
||||
* @param expires Default subscription expiration time, in seconds.
|
||||
* @param accept_cnt Number of strings in Accept array.
|
||||
* @param accept Array of Accept value.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_register_pkg( pjsip_module *pkg_mod,
|
||||
const pj_str_t *event_name,
|
||||
unsigned expires,
|
||||
unsigned accept_cnt,
|
||||
const pj_str_t accept[]);
|
||||
|
||||
/**
|
||||
* Get the Allow-Events header. This header is built based on the packages
|
||||
* that are registered to the evsub module.
|
||||
*
|
||||
* @param m Pointer to event subscription module instance, or
|
||||
* NULL to use default instance (equal to
|
||||
* #pjsip_evsub_instance()).
|
||||
*
|
||||
* @return The Allow-Events header.
|
||||
*/
|
||||
PJ_DECL(const pjsip_hdr*) pjsip_evsub_get_allow_events_hdr(pjsip_module *m);
|
||||
|
||||
|
||||
/**
|
||||
* Create client subscription session.
|
||||
*
|
||||
* @param dlg The underlying dialog to use.
|
||||
* @param user_cb Callback to receive event subscription notifications.
|
||||
* @param event Event name.
|
||||
* @param option Bitmask of options.
|
||||
* @param p_evsub Pointer to receive event subscription instance.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_create_uac( pjsip_dialog *dlg,
|
||||
const pjsip_evsub_user *user_cb,
|
||||
const pj_str_t *event,
|
||||
unsigned option,
|
||||
pjsip_evsub **p_evsub);
|
||||
|
||||
/**
|
||||
* Create server subscription session.
|
||||
*
|
||||
* @param dlg The underlying dialog to use.
|
||||
* @param user_cb Callback to receive event subscription notifications.
|
||||
* @param rdata The incoming request that creates the event
|
||||
* subscription, such as SUBSCRIBE or REFER.
|
||||
* @param option Bitmask of options.
|
||||
* @param p_evsub Pointer to receive event subscription instance.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_create_uas( pjsip_dialog *dlg,
|
||||
const pjsip_evsub_user *user_cb,
|
||||
pjsip_rx_data *rdata,
|
||||
unsigned option,
|
||||
pjsip_evsub **p_evsub);
|
||||
|
||||
/**
|
||||
* Forcefully destroy the subscription session. 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 event 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_evsub_terminate( pjsip_evsub *sub,
|
||||
pj_bool_t notify );
|
||||
|
||||
|
||||
/**
|
||||
* Get subscription state.
|
||||
*
|
||||
* @param sub Event subscription instance.
|
||||
*
|
||||
* @return Subscription state.
|
||||
*/
|
||||
PJ_DECL(pjsip_evsub_state) pjsip_evsub_get_state(pjsip_evsub *sub);
|
||||
|
||||
|
||||
/**
|
||||
* Get the string representation of the subscription state.
|
||||
*
|
||||
* @param sub Event subscription instance.
|
||||
*
|
||||
* @return NULL terminated string.
|
||||
*/
|
||||
PJ_DECL(const char*) pjsip_evsub_get_state_name(pjsip_evsub *sub);
|
||||
|
||||
|
||||
/**
|
||||
* Get subscription termination reason, if any. If remote did not
|
||||
* send termination reason, this function will return empty string.
|
||||
*
|
||||
* @param sub Event subscription instance.
|
||||
*
|
||||
* @return NULL terminated string.
|
||||
*/
|
||||
PJ_DECL(const pj_str_t*) pjsip_evsub_get_termination_reason(pjsip_evsub *sub);
|
||||
|
||||
|
||||
/**
|
||||
* Call this function to create request to initiate subscription, to
|
||||
* refresh subcription, or to request subscription termination.
|
||||
*
|
||||
* @param sub Client subscription instance.
|
||||
* @param method The method that establishes the subscription, such as
|
||||
* SUBSCRIBE or REFER. If this argument is NULL, then
|
||||
* SUBSCRIBE will be used.
|
||||
* @param expires Subscription expiration. If the value is set to zero,
|
||||
* this will request unsubscription. If the value is
|
||||
* negative, default expiration as defined by the package
|
||||
* will be used.
|
||||
* @param p_tdata Pointer to receive the request.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_initiate( pjsip_evsub *sub,
|
||||
const pjsip_method *method,
|
||||
pj_int32_t expires,
|
||||
pjsip_tx_data **p_tdata);
|
||||
|
||||
|
||||
/**
|
||||
* Add a list of headers to the subscription instance. The list of headers
|
||||
* will be added to outgoing presence subscription requests.
|
||||
*
|
||||
* @param sub Subscription instance.
|
||||
* @param hdr_list List of headers to be added.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_add_header( pjsip_evsub *sub,
|
||||
const pjsip_hdr *hdr_list );
|
||||
|
||||
|
||||
/**
|
||||
* 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_evsub_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 p_tdata Pointer to receive request message.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_notify( pjsip_evsub *sub,
|
||||
pjsip_evsub_state state,
|
||||
const pj_str_t *state_str,
|
||||
const pj_str_t *reason,
|
||||
pjsip_tx_data **p_tdata);
|
||||
|
||||
|
||||
/**
|
||||
* For notifier, create a NOTIFY request that reflects current subscription
|
||||
* status.
|
||||
*
|
||||
* @param sub The server subscription instance.
|
||||
* @param p_tdata Pointer to receive the request messge.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_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 event subscription object.
|
||||
* @param tdata Request message to be send.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_evsub_send_request( pjsip_evsub *sub,
|
||||
pjsip_tx_data *tdata);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the event subscription instance associated with the specified
|
||||
* transaction.
|
||||
*
|
||||
* @param tsx The transaction.
|
||||
*
|
||||
* @return The event subscription instance registered in the
|
||||
* transaction, if any.
|
||||
*/
|
||||
PJ_DECL(pjsip_evsub*) pjsip_tsx_get_evsub(pjsip_transaction *tsx);
|
||||
|
||||
|
||||
/**
|
||||
* Set event subscription's module data.
|
||||
*
|
||||
* @param sub The event subscription.
|
||||
* @param mod_id The module id.
|
||||
* @param data Arbitrary data.
|
||||
*/
|
||||
PJ_DECL(void) pjsip_evsub_set_mod_data( pjsip_evsub *sub, unsigned mod_id,
|
||||
void *data );
|
||||
|
||||
|
||||
/**
|
||||
* Get event subscription's module data.
|
||||
*
|
||||
* @param sub The event subscription.
|
||||
* @param mod_id The module id.
|
||||
*
|
||||
* @return Data previously set at the specified id.
|
||||
*/
|
||||
PJ_DECL(void*) pjsip_evsub_get_mod_data( pjsip_evsub *sub, unsigned mod_id );
|
||||
|
||||
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_EVSUB_H__ */
|
||||
119
res/pjproject/pjsip/include/pjsip-simple/evsub_msg.h
Normal file
119
res/pjproject/pjsip/include/pjsip-simple/evsub_msg.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_EVENT_NOTIFY_MSG_H__
|
||||
#define __PJSIP_SIMPLE_EVENT_NOTIFY_MSG_H__
|
||||
|
||||
/**
|
||||
* @file evsub_msg.h
|
||||
* @brief SIP Event Notification Headers (RFC 3265)
|
||||
*/
|
||||
#include <pjsip/sip_msg.h>
|
||||
|
||||
/**
|
||||
* @defgroup PJSIP_EVENT_HDRS Additional Header Fields
|
||||
* @ingroup PJSIP_EVENT_NOT
|
||||
* @{
|
||||
*/
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
|
||||
/** Max events in Allow-Events header. */
|
||||
#define PJSIP_MAX_ALLOW_EVENTS 16
|
||||
|
||||
/**
|
||||
* This structure describes Event header.
|
||||
*/
|
||||
typedef struct pjsip_event_hdr
|
||||
{
|
||||
/** Standard header fields. */
|
||||
PJSIP_DECL_HDR_MEMBER(struct pjsip_event_hdr);
|
||||
|
||||
pj_str_t event_type; /**< Event name. */
|
||||
pj_str_t id_param; /**< Optional event ID parameter. */
|
||||
pjsip_param other_param; /**< Other parameter. */
|
||||
} pjsip_event_hdr;
|
||||
|
||||
/**
|
||||
* Create an Event header.
|
||||
*
|
||||
* @param pool The pool.
|
||||
*
|
||||
* @return New Event header instance.
|
||||
*/
|
||||
PJ_DECL(pjsip_event_hdr*) pjsip_event_hdr_create(pj_pool_t *pool);
|
||||
|
||||
|
||||
/**
|
||||
* This structure describes Allow-Events header.
|
||||
*/
|
||||
typedef pjsip_generic_array_hdr pjsip_allow_events_hdr;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Allow-Events header.
|
||||
*
|
||||
* @param pool The pool.
|
||||
*
|
||||
* @return Allow-Events header.
|
||||
*/
|
||||
PJ_DECL(pjsip_allow_events_hdr*)
|
||||
pjsip_allow_events_hdr_create(pj_pool_t *pool);
|
||||
|
||||
|
||||
/**
|
||||
* This structure describes Subscription-State header.
|
||||
*/
|
||||
typedef struct pjsip_sub_state_hdr
|
||||
{
|
||||
/** Standard header fields. */
|
||||
PJSIP_DECL_HDR_MEMBER(struct pjsip_sub_state_hdr);
|
||||
|
||||
pj_str_t sub_state; /**< Subscription state. */
|
||||
pj_str_t reason_param; /**< Optional termination reason. */
|
||||
int expires_param; /**< Expires param, or -1. */
|
||||
int retry_after; /**< Retry after param, or -1. */
|
||||
pjsip_param other_param; /**< Other parameters. */
|
||||
} pjsip_sub_state_hdr;
|
||||
|
||||
/**
|
||||
* Create new Subscription-State header.
|
||||
*
|
||||
* @param pool The pool.
|
||||
*
|
||||
* @return Subscription-State header.
|
||||
*/
|
||||
PJ_DECL(pjsip_sub_state_hdr*) pjsip_sub_state_hdr_create(pj_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Initialize parser for event notify module.
|
||||
*/
|
||||
PJ_DECL(void) pjsip_evsub_init_parser(void);
|
||||
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_EVENT_NOTIFY_MSG_H__ */
|
||||
|
||||
135
res/pjproject/pjsip/include/pjsip-simple/iscomposing.h
Normal file
135
res/pjproject/pjsip/include/pjsip-simple/iscomposing.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_ISCOMPOSING_H__
|
||||
#define __PJSIP_SIMPLE_ISCOMPOSING_H__
|
||||
|
||||
/**
|
||||
* @file iscomposing.h
|
||||
* @brief Support for Indication of Message Composition (RFC 3994)
|
||||
*/
|
||||
#include <pjsip-simple/types.h>
|
||||
#include <pjlib-util/xml.h>
|
||||
|
||||
/**
|
||||
* @defgroup PJSIP_ISCOMPOSING Message Composition Indication (RFC 3994)
|
||||
* @ingroup PJSIP_SIMPLE
|
||||
* @brief Support for Indication of Message Composition (RFC 3994)
|
||||
* @{
|
||||
*
|
||||
* This implements message composition indication, as described in
|
||||
* RFC 3994.
|
||||
*/
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
|
||||
/**
|
||||
* Create XML message with MIME type "application/im-iscomposing+xml"
|
||||
* to indicate the message composition status.
|
||||
*
|
||||
* @param pool Pool to allocate memory.
|
||||
* @param is_composing Message composition indication status. Set to
|
||||
* PJ_TRUE (or non-zero) to indicate that application
|
||||
* is currently composing an instant message.
|
||||
* @param lst_actv Optional attribute to indicate time of last
|
||||
* activity. If none is to be specified, the value
|
||||
* MUST be set to NULL.
|
||||
* @param content_tp Optional attribute to indicate the content type of
|
||||
* message being composed. If none is to be specified,
|
||||
* the value MUST be set to NULL.
|
||||
* @param refresh Optional attribute to indicate the interval when
|
||||
* next indication will be sent, only when
|
||||
* is_composing is non-zero. If none is to be
|
||||
* specified, the value MUST be set to -1.
|
||||
*
|
||||
* @return An XML message containing the message indication.
|
||||
* NULL will be returned when there's not enough
|
||||
* memory to allocate the message.
|
||||
*/
|
||||
PJ_DECL(pj_xml_node*) pjsip_iscomposing_create_xml(pj_pool_t *pool,
|
||||
pj_bool_t is_composing,
|
||||
const pj_time_val *lst_actv,
|
||||
const pj_str_t *content_tp,
|
||||
int refresh);
|
||||
|
||||
|
||||
/**
|
||||
* Create message body with Content-Type "application/im-iscomposing+xml"
|
||||
* to indicate the message composition status.
|
||||
*
|
||||
* @param pool Pool to allocate memory.
|
||||
* @param is_composing Message composition indication status. Set to
|
||||
* PJ_TRUE (or non-zero) to indicate that application
|
||||
* is currently composing an instant message.
|
||||
* @param lst_actv Optional attribute to indicate time of last
|
||||
* activity. If none is to be specified, the value
|
||||
* MUST be set to NULL.
|
||||
* @param content_tp Optional attribute to indicate the content type of
|
||||
* message being composed. If none is to be specified,
|
||||
* the value MUST be set to NULL.
|
||||
* @param refresh Optional attribute to indicate the interval when
|
||||
* next indication will be sent, only when
|
||||
* is_composing is non-zero. If none is to be
|
||||
* specified, the value MUST be set to -1.
|
||||
*
|
||||
* @return The SIP message body containing XML message
|
||||
* indication. NULL will be returned when there's not
|
||||
* enough memory to allocate the message.
|
||||
*/
|
||||
PJ_DECL(pjsip_msg_body*) pjsip_iscomposing_create_body( pj_pool_t *pool,
|
||||
pj_bool_t is_composing,
|
||||
const pj_time_val *lst_actv,
|
||||
const pj_str_t *content_tp,
|
||||
int refresh);
|
||||
|
||||
|
||||
/**
|
||||
* Parse the buffer and return message composition indication in the
|
||||
* message.
|
||||
*
|
||||
* @param pool Pool to allocate memory for the parsing process.
|
||||
* @param msg The message to be parsed.
|
||||
* @param len Length of the message.
|
||||
* @param p_is_composing Optional pointer to receive iscomposing status.
|
||||
* @param p_last_active Optional pointer to receive last active attribute.
|
||||
* @param p_content_type Optional pointer to receive content type attribute.
|
||||
* @param p_refresh Optional pointer to receive refresh time.
|
||||
*
|
||||
* @return PJ_SUCCESS if message can be successfully parsed.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_iscomposing_parse( pj_pool_t *pool,
|
||||
char *msg,
|
||||
pj_size_t len,
|
||||
pj_bool_t *p_is_composing,
|
||||
pj_str_t **p_last_active,
|
||||
pj_str_t **p_content_type,
|
||||
int *p_refresh );
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_ISCOMPOSING_H__ */
|
||||
|
||||
208
res/pjproject/pjsip/include/pjsip-simple/mwi.h
Normal file
208
res/pjproject/pjsip/include/pjsip-simple/mwi.h
Normal file
@@ -0,0 +1,208 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 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__ */
|
||||
178
res/pjproject/pjsip/include/pjsip-simple/pidf.h
Normal file
178
res/pjproject/pjsip/include/pjsip-simple/pidf.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_PIDF_H__
|
||||
#define __PJSIP_SIMPLE_PIDF_H__
|
||||
|
||||
/**
|
||||
* @file pidf.h
|
||||
* @brief PIDF/Presence Information Data Format (RFC 3863)
|
||||
*/
|
||||
#include <pjsip-simple/types.h>
|
||||
#include <pjlib-util/xml.h>
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup PJSIP_SIMPLE_PIDF PIDF/Presence Information Data Format (RFC 3863)
|
||||
* @ingroup PJSIP_SIMPLE
|
||||
* @brief Support for PIDF/Presence Information Data Format (RFC 3863)
|
||||
* @{
|
||||
*
|
||||
* This file provides tools for manipulating Presence Information Data
|
||||
* Format (PIDF) as described in RFC 3863.
|
||||
*/
|
||||
typedef struct pj_xml_node pjpidf_pres;
|
||||
typedef struct pj_xml_node pjpidf_tuple;
|
||||
typedef struct pj_xml_node pjpidf_status;
|
||||
typedef struct pj_xml_node pjpidf_note;
|
||||
|
||||
typedef struct pjpidf_status_op
|
||||
{
|
||||
void (*construct)(pj_pool_t*, pjpidf_status*);
|
||||
pj_bool_t (*is_basic_open)(const pjpidf_status*);
|
||||
void (*set_basic_open)(pjpidf_status*, pj_bool_t);
|
||||
} pjpidf_status_op;
|
||||
|
||||
typedef struct pjpidf_tuple_op
|
||||
{
|
||||
void (*construct)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
|
||||
|
||||
const pj_str_t* (*get_id)(const pjpidf_tuple* );
|
||||
void (*set_id)(pj_pool_t*, pjpidf_tuple *, const pj_str_t*);
|
||||
|
||||
pjpidf_status* (*get_status)(pjpidf_tuple* );
|
||||
|
||||
const pj_str_t* (*get_contact)(const pjpidf_tuple*);
|
||||
void (*set_contact)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
|
||||
void (*set_contact_prio)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
|
||||
const pj_str_t* (*get_contact_prio)(const pjpidf_tuple*);
|
||||
|
||||
pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
|
||||
pjpidf_note* (*get_first_note)(pjpidf_tuple*);
|
||||
pjpidf_note* (*get_next_note)(pjpidf_tuple*, pjpidf_note*);
|
||||
|
||||
const pj_str_t* (*get_timestamp)(const pjpidf_tuple*);
|
||||
void (*set_timestamp)(pj_pool_t*, pjpidf_tuple*, const pj_str_t*);
|
||||
void (*set_timestamp_np)(pj_pool_t*,pjpidf_tuple*, pj_str_t*);
|
||||
|
||||
} pjpidf_tuple_op;
|
||||
|
||||
typedef struct pjpidf_pres_op
|
||||
{
|
||||
void (*construct)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
|
||||
|
||||
pjpidf_tuple* (*add_tuple)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
|
||||
pjpidf_tuple* (*get_first_tuple)(pjpidf_pres*);
|
||||
pjpidf_tuple* (*get_next_tuple)(pjpidf_pres*, pjpidf_tuple*);
|
||||
pjpidf_tuple* (*find_tuple)(pjpidf_pres*, const pj_str_t*);
|
||||
void (*remove_tuple)(pjpidf_pres*, pjpidf_tuple*);
|
||||
|
||||
pjpidf_note* (*add_note)(pj_pool_t*, pjpidf_pres*, const pj_str_t*);
|
||||
pjpidf_note* (*get_first_note)(pjpidf_pres*);
|
||||
pjpidf_note* (*get_next_note)(pjpidf_pres*, pjpidf_note*);
|
||||
|
||||
} pjpidf_pres_op;
|
||||
|
||||
|
||||
extern struct pjpidf_op_desc
|
||||
{
|
||||
pjpidf_pres_op pres;
|
||||
pjpidf_tuple_op tuple;
|
||||
pjpidf_status_op status;
|
||||
} pjpidf_op;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Top level API for managing presence document.
|
||||
*****************************************************************************/
|
||||
PJ_DECL(pjpidf_pres*) pjpidf_create(pj_pool_t *pool, const pj_str_t *entity);
|
||||
PJ_DECL(pjpidf_pres*) pjpidf_parse(pj_pool_t *pool, char *text, int len);
|
||||
PJ_DECL(int) pjpidf_print(const pjpidf_pres* pres, char *buf, int len);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* API for managing Presence node.
|
||||
*****************************************************************************/
|
||||
PJ_DECL(void) pjpidf_pres_construct(pj_pool_t *pool, pjpidf_pres *pres,
|
||||
const pj_str_t *entity);
|
||||
PJ_DECL(pjpidf_tuple*) pjpidf_pres_add_tuple(pj_pool_t *pool, pjpidf_pres *pres,
|
||||
const pj_str_t *id);
|
||||
PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_first_tuple(pjpidf_pres *pres);
|
||||
PJ_DECL(pjpidf_tuple*) pjpidf_pres_get_next_tuple(pjpidf_pres *pres,
|
||||
pjpidf_tuple *t);
|
||||
PJ_DECL(pjpidf_tuple*) pjpidf_pres_find_tuple(pjpidf_pres *pres,
|
||||
const pj_str_t *id);
|
||||
PJ_DECL(void) pjpidf_pres_remove_tuple(pjpidf_pres *pres,
|
||||
pjpidf_tuple*);
|
||||
|
||||
PJ_DECL(pjpidf_note*) pjpidf_pres_add_note(pj_pool_t *pool, pjpidf_pres *pres,
|
||||
const pj_str_t *text);
|
||||
PJ_DECL(pjpidf_note*) pjpidf_pres_get_first_note(pjpidf_pres *pres);
|
||||
PJ_DECL(pjpidf_note*) pjpidf_pres_get_next_note(pjpidf_pres*, pjpidf_note*);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* API for managing Tuple node.
|
||||
*****************************************************************************/
|
||||
PJ_DECL(void) pjpidf_tuple_construct(pj_pool_t *pool, pjpidf_tuple *t,
|
||||
const pj_str_t *id);
|
||||
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_id(const pjpidf_tuple *t );
|
||||
PJ_DECL(void) pjpidf_tuple_set_id(pj_pool_t *pool, pjpidf_tuple *t,
|
||||
const pj_str_t *id);
|
||||
|
||||
PJ_DECL(pjpidf_status*) pjpidf_tuple_get_status(pjpidf_tuple *t);
|
||||
|
||||
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact(const pjpidf_tuple *t);
|
||||
PJ_DECL(void) pjpidf_tuple_set_contact(pj_pool_t *pool, pjpidf_tuple *t,
|
||||
const pj_str_t *contact);
|
||||
PJ_DECL(void) pjpidf_tuple_set_contact_prio(pj_pool_t *pool, pjpidf_tuple *t,
|
||||
const pj_str_t *prio);
|
||||
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_contact_prio(const pjpidf_tuple *t);
|
||||
|
||||
PJ_DECL(pjpidf_note*) pjpidf_tuple_add_note(pj_pool_t *pool, pjpidf_tuple *t,
|
||||
const pj_str_t *text);
|
||||
PJ_DECL(pjpidf_note*) pjpidf_tuple_get_first_note(pjpidf_tuple *t);
|
||||
PJ_DECL(pjpidf_note*) pjpidf_tuple_get_next_note(pjpidf_tuple *t, pjpidf_note *n);
|
||||
|
||||
PJ_DECL(const pj_str_t*) pjpidf_tuple_get_timestamp(const pjpidf_tuple *t);
|
||||
PJ_DECL(void) pjpidf_tuple_set_timestamp(pj_pool_t *pool, pjpidf_tuple *t,
|
||||
const pj_str_t *ts);
|
||||
PJ_DECL(void) pjpidf_tuple_set_timestamp_np( pj_pool_t*, pjpidf_tuple *t,
|
||||
pj_str_t *ts);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* API for managing Status node.
|
||||
*****************************************************************************/
|
||||
PJ_DECL(void) pjpidf_status_construct(pj_pool_t*, pjpidf_status*);
|
||||
PJ_DECL(pj_bool_t) pjpidf_status_is_basic_open(const pjpidf_status*);
|
||||
PJ_DECL(void) pjpidf_status_set_basic_open(pjpidf_status*, pj_bool_t);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_PIDF_H__ */
|
||||
415
res/pjproject/pjsip/include/pjsip-simple/presence.h
Normal file
415
res/pjproject/pjsip/include/pjsip-simple/presence.h
Normal file
@@ -0,0 +1,415 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_PRESENCE_H__
|
||||
#define __PJSIP_SIMPLE_PRESENCE_H__
|
||||
|
||||
/**
|
||||
* @file presence.h
|
||||
* @brief SIP Extension for Presence (RFC 3856)
|
||||
*/
|
||||
#include <pjsip-simple/evsub.h>
|
||||
#include <pjsip-simple/pidf.h>
|
||||
#include <pjsip-simple/xpidf.h>
|
||||
#include <pjsip-simple/rpid.h>
|
||||
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup PJSIP_SIMPLE_PRES SIP Extension for Presence (RFC 3856)
|
||||
* @ingroup PJSIP_SIMPLE
|
||||
* @brief Support for SIP Extension for Presence (RFC 3856)
|
||||
* @{
|
||||
*
|
||||
* This module contains the implementation of SIP Presence Extension as
|
||||
* described in RFC 3856. It uses the SIP Event Notification framework
|
||||
* (evsub.h) and extends the framework by implementing "presence"
|
||||
* event package.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the presence 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_pres_init_module(pjsip_endpoint *endpt,
|
||||
pjsip_module *mod_evsub);
|
||||
|
||||
|
||||
/**
|
||||
* Get the presence module instance.
|
||||
*
|
||||
* @return The presence module instance.
|
||||
*/
|
||||
PJ_DECL(pjsip_module*) pjsip_pres_instance(void);
|
||||
|
||||
|
||||
/**
|
||||
* Maximum presence status info.
|
||||
*/
|
||||
#define PJSIP_PRES_STATUS_MAX_INFO 8
|
||||
|
||||
|
||||
/**
|
||||
* This structure describes presence status of a presentity.
|
||||
*/
|
||||
struct pjsip_pres_status
|
||||
{
|
||||
unsigned info_cnt; /**< Number of info in the status. */
|
||||
struct {
|
||||
|
||||
pj_bool_t basic_open; /**< Basic status/availability. */
|
||||
pjrpid_element rpid; /**< Optional RPID info. */
|
||||
|
||||
pj_str_t id; /**< Tuple id. */
|
||||
pj_str_t contact; /**< Optional contact address. */
|
||||
|
||||
pj_xml_node *tuple_node; /**< Pointer to tuple XML node of
|
||||
parsed PIDF body received from
|
||||
remote agent. Only valid for
|
||||
client subscription. If the
|
||||
last received NOTIFY request
|
||||
does not contain any PIDF body,
|
||||
this valud will be set to NULL */
|
||||
|
||||
} info[PJSIP_PRES_STATUS_MAX_INFO]; /**< Array of info. */
|
||||
|
||||
pj_bool_t _is_valid; /**< Internal flag. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @see pjsip_pres_status
|
||||
*/
|
||||
typedef struct pjsip_pres_status pjsip_pres_status;
|
||||
|
||||
|
||||
/**
|
||||
* Create presence client subscription session.
|
||||
*
|
||||
* @param dlg The underlying dialog to use.
|
||||
* @param user_cb Pointer to callbacks to receive presence subscription
|
||||
* events.
|
||||
* @param options Option flags. Currently only PJSIP_EVSUB_NO_EVENT_ID
|
||||
* is recognized.
|
||||
* @param p_evsub Pointer to receive the presence subscription
|
||||
* session.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_create_uac( pjsip_dialog *dlg,
|
||||
const pjsip_evsub_user *user_cb,
|
||||
unsigned options,
|
||||
pjsip_evsub **p_evsub );
|
||||
|
||||
|
||||
/**
|
||||
* Create presence server subscription session.
|
||||
*
|
||||
* @param dlg The underlying dialog to use.
|
||||
* @param user_cb Pointer to callbacks to receive presence subscription
|
||||
* events.
|
||||
* @param rdata The incoming SUBSCRIBE request that creates the event
|
||||
* subscription.
|
||||
* @param p_evsub Pointer to receive the presence subscription
|
||||
* session.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_create_uas( pjsip_dialog *dlg,
|
||||
const pjsip_evsub_user *user_cb,
|
||||
pjsip_rx_data *rdata,
|
||||
pjsip_evsub **p_evsub );
|
||||
|
||||
|
||||
/**
|
||||
* Forcefully destroy the presence 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 presence 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_pres_terminate( pjsip_evsub *sub,
|
||||
pj_bool_t notify );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Call this function to create request to initiate presence 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_pres_initiate( pjsip_evsub *sub,
|
||||
pj_int32_t expires,
|
||||
pjsip_tx_data **p_tdata);
|
||||
|
||||
|
||||
/**
|
||||
* Add a list of headers to the subscription instance. The list of headers
|
||||
* will be added to outgoing presence subscription requests.
|
||||
*
|
||||
* @param sub Subscription instance.
|
||||
* @param hdr_list List of headers to be added.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_add_header( pjsip_evsub *sub,
|
||||
const pjsip_hdr *hdr_list );
|
||||
|
||||
|
||||
/**
|
||||
* 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_pres_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. Application MUST set the presence status to the
|
||||
* appropriate state (by calling #pjsip_pres_set_status()) before calling
|
||||
* this function.
|
||||
*
|
||||
* @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 p_tdata Pointer to receive the request.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_notify( pjsip_evsub *sub,
|
||||
pjsip_evsub_state state,
|
||||
const pj_str_t *state_str,
|
||||
const pj_str_t *reason,
|
||||
pjsip_tx_data **p_tdata);
|
||||
|
||||
|
||||
/**
|
||||
* Create NOTIFY request to reflect current subscription status.
|
||||
*
|
||||
* @param sub Server subscription object.
|
||||
* @param p_tdata Pointer to receive request.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_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_pres_send_request( pjsip_evsub *sub,
|
||||
pjsip_tx_data *tdata );
|
||||
|
||||
|
||||
/**
|
||||
* Get the presence status. Client normally would call this function
|
||||
* after receiving NOTIFY request from server.
|
||||
*
|
||||
* @param sub The client or server subscription.
|
||||
* @param status The structure to receive presence status.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_get_status( pjsip_evsub *sub,
|
||||
pjsip_pres_status *status );
|
||||
|
||||
|
||||
/**
|
||||
* Set the presence status. This operation is only valid for server
|
||||
* subscription. After calling this function, application would need to
|
||||
* send NOTIFY request to client.
|
||||
*
|
||||
* @param sub The server subscription.
|
||||
* @param status Status to be set.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_set_status( pjsip_evsub *sub,
|
||||
const pjsip_pres_status *status );
|
||||
|
||||
|
||||
/**
|
||||
* This is a utility function to create PIDF message body from PJSIP
|
||||
* presence status (pjsip_pres_status).
|
||||
*
|
||||
* @param pool The pool to allocate memory for the message body.
|
||||
* @param status Presence status to be converted into PIDF message
|
||||
* body.
|
||||
* @param entity The entity ID, which normally is equal to the
|
||||
* presentity ID publishing this presence info.
|
||||
* @param p_body Pointer to receive the SIP message body.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_create_pidf( pj_pool_t *pool,
|
||||
const pjsip_pres_status *status,
|
||||
const pj_str_t *entity,
|
||||
pjsip_msg_body **p_body );
|
||||
|
||||
|
||||
/**
|
||||
* This is a utility function to create X-PIDF message body from PJSIP
|
||||
* presence status (pjsip_pres_status).
|
||||
*
|
||||
* @param pool The pool to allocate memory for the message body.
|
||||
* @param status Presence status to be converted into X-PIDF message
|
||||
* body.
|
||||
* @param entity The entity ID, which normally is equal to the
|
||||
* presentity ID publishing this presence info.
|
||||
* @param p_body Pointer to receive the SIP message body.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_create_xpidf(pj_pool_t *pool,
|
||||
const pjsip_pres_status *status,
|
||||
const pj_str_t *entity,
|
||||
pjsip_msg_body **p_body );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is a utility function to parse PIDF body into PJSIP presence status.
|
||||
*
|
||||
* @param rdata The incoming SIP message containing the PIDF body.
|
||||
* @param pool Pool to allocate memory to copy the strings into
|
||||
* the presence status structure.
|
||||
* @param status The presence status to be initialized.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*
|
||||
* @see pjsip_pres_parse_pidf2()
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_parse_pidf(pjsip_rx_data *rdata,
|
||||
pj_pool_t *pool,
|
||||
pjsip_pres_status *status);
|
||||
|
||||
/**
|
||||
* This is a utility function to parse PIDF body into PJSIP presence status.
|
||||
*
|
||||
* @param body Text body, with one extra space at the end to place
|
||||
* NULL character temporarily during parsing.
|
||||
* @param body_len Length of the body, not including the NULL termination
|
||||
* character.
|
||||
* @param pool Pool to allocate memory to copy the strings into
|
||||
* the presence status structure.
|
||||
* @param status The presence status to be initialized.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*
|
||||
* @see pjsip_pres_parse_pidf()
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_parse_pidf2(char *body, unsigned body_len,
|
||||
pj_pool_t *pool,
|
||||
pjsip_pres_status *status);
|
||||
|
||||
|
||||
/**
|
||||
* This is a utility function to parse X-PIDF body into PJSIP presence status.
|
||||
*
|
||||
* @param rdata The incoming SIP message containing the X-PIDF body.
|
||||
* @param pool Pool to allocate memory to copy the strings into
|
||||
* the presence status structure.
|
||||
* @param status The presence status to be initialized.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*
|
||||
* @see pjsip_pres_parse_xpidf2()
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_parse_xpidf(pjsip_rx_data *rdata,
|
||||
pj_pool_t *pool,
|
||||
pjsip_pres_status *status);
|
||||
|
||||
|
||||
/**
|
||||
* This is a utility function to parse X-PIDF body into PJSIP presence status.
|
||||
*
|
||||
* @param body Text body, with one extra space at the end to place
|
||||
* NULL character temporarily during parsing.
|
||||
* @param body_len Length of the body, not including the NULL termination
|
||||
* character.
|
||||
* @param pool Pool to allocate memory to copy the strings into
|
||||
* the presence status structure.
|
||||
* @param status The presence status to be initialized.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*
|
||||
* @see pjsip_pres_parse_xpidf()
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_pres_parse_xpidf2(char *body, unsigned body_len,
|
||||
pj_pool_t *pool,
|
||||
pjsip_pres_status *status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_PRESENCE_H__ */
|
||||
333
res/pjproject/pjsip/include/pjsip-simple/publish.h
Normal file
333
res/pjproject/pjsip/include/pjsip-simple/publish.h
Normal file
@@ -0,0 +1,333 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_PUBLISH_H__
|
||||
#define __PJSIP_SIMPLE_PUBLISH_H__
|
||||
|
||||
/**
|
||||
* @file publish.h
|
||||
* @brief SIP Extension for Event State Publication (PUBLISH, RFC 3903)
|
||||
*/
|
||||
|
||||
#include <pjsip/sip_util.h>
|
||||
#include <pjsip/sip_auth.h>
|
||||
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
|
||||
/**
|
||||
@defgroup PJSIP_SIMPLE_PUBLISH SIP Event State Publication (PUBLISH, RFC 3903)
|
||||
@ingroup PJSIP_SIMPLE
|
||||
@brief Support for SIP Event State Publication (PUBLISH, RFC 3903)
|
||||
@{
|
||||
|
||||
This module contains the implementation of Session Initiation Protocol (SIP)
|
||||
Extension for Event State Publication (PUBLISH) as defined by RFC 3903.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The SIP PUBLISH method constant.
|
||||
*/
|
||||
extern const pjsip_method pjsip_publish_method;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* @defgroup PJSIP_SIMPLE_PUBLISH_CLIENT SIP Event State Publication Client
|
||||
* @ingroup PJSIP_SIMPLE
|
||||
* @brief Event State Publication Clien
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** Expiration not specified. */
|
||||
#define PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED ((pj_uint32_t)0xFFFFFFFFUL)
|
||||
|
||||
/**
|
||||
* Opaque declaration for client side event publication session.
|
||||
*/
|
||||
typedef struct pjsip_publishc pjsip_publishc;
|
||||
|
||||
|
||||
/**
|
||||
* Client publication options. Application should initialize this structure
|
||||
* with its default values by calling #pjsip_publishc_opt_default()
|
||||
*/
|
||||
typedef struct pjsip_publishc_opt
|
||||
{
|
||||
/**
|
||||
* Specify whether the client publication session should queue the
|
||||
* PUBLISH request should there be another PUBLISH transaction still
|
||||
* pending. If this is set to false, the client will return error
|
||||
* on the PUBLISH request if there is another PUBLISH transaction still
|
||||
* in progress.
|
||||
*
|
||||
* Default: PJSIP_PUBLISHC_QUEUE_REQUEST
|
||||
*/
|
||||
pj_bool_t queue_request;
|
||||
|
||||
} pjsip_publishc_opt;
|
||||
|
||||
|
||||
/** Structure to hold parameters when calling application's callback.
|
||||
* The application's callback is called when the client publication process
|
||||
* has finished.
|
||||
*/
|
||||
struct pjsip_publishc_cbparam
|
||||
{
|
||||
pjsip_publishc *pubc; /**< Client publication structure. */
|
||||
void *token; /**< Arbitrary token. */
|
||||
pj_status_t status; /**< Error status. */
|
||||
int code; /**< SIP status code received. */
|
||||
pj_str_t reason; /**< SIP reason phrase received. */
|
||||
pjsip_rx_data *rdata; /**< The complete received response. */
|
||||
int expiration;/**< Next expiration interval. If the
|
||||
value is -1, it means the session
|
||||
will not renew itself. */
|
||||
};
|
||||
|
||||
|
||||
/** Type declaration for callback to receive publication result. */
|
||||
typedef void pjsip_publishc_cb(struct pjsip_publishc_cbparam *param);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize client publication session option with default values.
|
||||
*
|
||||
* @param opt The option.
|
||||
*/
|
||||
PJ_DECL(void) pjsip_publishc_opt_default(pjsip_publishc_opt *opt);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize client publication module.
|
||||
*
|
||||
* @param endpt SIP endpoint.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_init_module(pjsip_endpoint *endpt);
|
||||
|
||||
|
||||
/**
|
||||
* Create client publication structure.
|
||||
*
|
||||
* @param endpt Endpoint, used to allocate pool from.
|
||||
* @param opt Options, or NULL to specify default options.
|
||||
* @param token Opaque data to be associated with the client publication.
|
||||
* @param cb Pointer to callback function to receive publication status.
|
||||
* @param p_pubc Pointer to receive client publication structure.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_create( pjsip_endpoint *endpt,
|
||||
const pjsip_publishc_opt *opt,
|
||||
void *token,
|
||||
pjsip_publishc_cb *cb,
|
||||
pjsip_publishc **p_pubc);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy client publication structure. If a publication transaction is
|
||||
* in progress, then the structure will be deleted only after a final response
|
||||
* has been received, and in this case, the callback won't be called.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_destroy(pjsip_publishc *pubc);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the memory pool associated with a publication client session.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
* @return pool handle.
|
||||
*/
|
||||
PJ_DECL(pj_pool_t*) pjsip_publishc_get_pool(pjsip_publishc *pubc);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize client publication structure with various information needed to
|
||||
* perform the publication.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
* @param event The Event identification (e.g. "presence").
|
||||
* @param target_uri The URI of the presentity which the which the status
|
||||
* is being published.
|
||||
* @param from_uri The URI of the endpoint who sends the event
|
||||
* publication. Normally the value would be the same as
|
||||
* target_uri.
|
||||
* @param to_uri The URI to be put in To header. Normally the value
|
||||
* would be the same as target_uri.
|
||||
* @param expires The default expiration of the event publication.
|
||||
* If the value PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED is
|
||||
* given, then no default expiration will be applied.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_init(pjsip_publishc *pubc,
|
||||
const pj_str_t *event,
|
||||
const pj_str_t *target_uri,
|
||||
const pj_str_t *from_uri,
|
||||
const pj_str_t *to_uri,
|
||||
pj_uint32_t expires);
|
||||
|
||||
|
||||
/**
|
||||
* Set authentication credentials to use by this publication.
|
||||
*
|
||||
* @param pubc The publication structure.
|
||||
* @param count Number of credentials in the array.
|
||||
* @param c Array of credentials.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_set_credentials(pjsip_publishc *pubc,
|
||||
int count,
|
||||
const pjsip_cred_info c[]);
|
||||
|
||||
/**
|
||||
* Set route set to be used for outgoing requests.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
* @param rs List containing Route headers.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_set_route_set(pjsip_publishc *pubc,
|
||||
const pjsip_route_hdr *rs);
|
||||
|
||||
|
||||
/**
|
||||
* Set list of headers to be added to each PUBLISH request generated by
|
||||
* the client publication session. Note that application can also add
|
||||
* the headers to the request after calling #pjsip_publishc_publish()
|
||||
* or #pjsip_publishc_unpublish(), but the benefit of this function is
|
||||
* the headers will also be added to requests generated internally by
|
||||
* the session, such as during session renewal/refresh.
|
||||
*
|
||||
* Note that calling this function will clear the previously added list
|
||||
* of headers.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
* @param hdr_list The list of headers.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_set_headers(pjsip_publishc *pubc,
|
||||
const pjsip_hdr *hdr_list);
|
||||
|
||||
/**
|
||||
* Create PUBLISH request for the specified client publication structure.
|
||||
* Application can use this function to both create initial publication
|
||||
* or to modify existing publication.
|
||||
*
|
||||
* After the PUBLISH request is created, application MUST fill in the
|
||||
* body part of the request with the appropriate content for the Event
|
||||
* being published.
|
||||
*
|
||||
* Note that publication refresh are handled automatically by the session
|
||||
* (as long as auto_refresh argument below is non-zero), and application
|
||||
* should not use this function to perform publication refresh.
|
||||
*
|
||||
* @param pubc The client publication session.
|
||||
* @param auto_refresh If non zero, the library will automatically
|
||||
* refresh the next publication until application
|
||||
* unpublish.
|
||||
* @param p_tdata Pointer to receive the PUBLISH request. Note that
|
||||
* the request DOES NOT have a message body.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_publish(pjsip_publishc *pubc,
|
||||
pj_bool_t auto_refresh,
|
||||
pjsip_tx_data **p_tdata);
|
||||
|
||||
|
||||
/**
|
||||
* Create PUBLISH request to unpublish the current client publication.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
* @param p_tdata Pointer to receive the PUBLISH request.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_unpublish(pjsip_publishc *pubc,
|
||||
pjsip_tx_data **p_tdata);
|
||||
|
||||
|
||||
/**
|
||||
* Update the client publication expiration value. Note that this DOES NOT
|
||||
* automatically send outgoing PUBLISH request to update the publication
|
||||
* session. If application wants to do this, then it must construct a
|
||||
* PUBLISH request and send it to the server.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
* @param expires The new expires value.
|
||||
*
|
||||
* @return PU_SUCCESS on successfull.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_update_expires(pjsip_publishc *pubc,
|
||||
pj_uint32_t expires );
|
||||
|
||||
|
||||
/**
|
||||
* Sends outgoing PUBLISH request. The process will complete asynchronously,
|
||||
* and application will be notified via the callback when the process
|
||||
* completes.
|
||||
*
|
||||
* If the session has another PUBLISH request outstanding, the behavior
|
||||
* depends on whether request queueing is enabled in the session (this was
|
||||
* set by setting \a queue_request field of #pjsip_publishc_opt to true
|
||||
* when calling #pjsip_publishc_create(). Default is true). If request
|
||||
* queueing is enabled, the request will be queued and the function will
|
||||
* return PJ_EPENDING. One the outstanding request is complete, the queued
|
||||
* request will be sent automatically. If request queueing is disabled, the
|
||||
* function will reject the request and return PJ_EBUSY.
|
||||
*
|
||||
* @param pubc The client publication structure.
|
||||
* @param tdata Transmit data.
|
||||
*
|
||||
* @return - PJ_SUCCESS on success, or
|
||||
* - PJ_EPENDING if request is queued, or
|
||||
* - PJ_EBUSY if request is rejected because another PUBLISH
|
||||
* request is in progress, or
|
||||
* - other status code to indicate the error.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjsip_publishc_send(pjsip_publishc *pubc,
|
||||
pjsip_tx_data *tdata);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_PUBLISH_H__ */
|
||||
|
||||
149
res/pjproject/pjsip/include/pjsip-simple/rpid.h
Normal file
149
res/pjproject/pjsip/include/pjsip-simple/rpid.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_RPID_H__
|
||||
#define __PJSIP_SIMPLE_RPID_H__
|
||||
|
||||
/**
|
||||
* @file rpid.h
|
||||
* @brief RPID: Rich Presence Extensions to the PIDF (RFC 4480)
|
||||
*/
|
||||
#include <pjsip-simple/types.h>
|
||||
#include <pjsip-simple/pidf.h>
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup PJSIP_SIMPLE_RPID RPID/Rich Presence Extensions to PIDF (RFC 4480)
|
||||
* @ingroup PJSIP_SIMPLE
|
||||
* @brief RPID/Rich Presence Extensions to PIDF (RFC 4480)
|
||||
* @{
|
||||
*
|
||||
* This file provides tools for managing subset of RPID elements into
|
||||
* PIDF document.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This enumeration describes subset of standard activities as
|
||||
* described by RFC 4880, RPID: Rich Presence Extensions to the
|
||||
* Presence Information Data Format (PIDF).
|
||||
*/
|
||||
typedef enum pjrpid_activity
|
||||
{
|
||||
/** Activity is unknown. The activity would then be conceived
|
||||
* in the "note" field.
|
||||
*/
|
||||
PJRPID_ACTIVITY_UNKNOWN,
|
||||
|
||||
/** The person is away */
|
||||
PJRPID_ACTIVITY_AWAY,
|
||||
|
||||
/** The person is busy */
|
||||
PJRPID_ACTIVITY_BUSY
|
||||
|
||||
} pjrpid_activity;
|
||||
|
||||
|
||||
/**
|
||||
* This enumeration describes types of RPID element.
|
||||
*/
|
||||
typedef enum pjrpid_element_type
|
||||
{
|
||||
/** RPID <person> element */
|
||||
PJRPID_ELEMENT_TYPE_PERSON
|
||||
|
||||
} pjrpid_element_type;
|
||||
|
||||
|
||||
/**
|
||||
* This structure describes person information in RPID document.
|
||||
*/
|
||||
typedef struct pjrpid_element
|
||||
{
|
||||
/** Element type. */
|
||||
pjrpid_element_type type;
|
||||
|
||||
/** Optional id to set on the element. */
|
||||
pj_str_t id;
|
||||
|
||||
/** Activity type. */
|
||||
pjrpid_activity activity;
|
||||
|
||||
/** Optional text describing the person/element. */
|
||||
pj_str_t note;
|
||||
|
||||
} pjrpid_element;
|
||||
|
||||
|
||||
/**
|
||||
* Duplicate RPID element.
|
||||
*
|
||||
* @param pool Pool.
|
||||
* @param dst Destination structure.
|
||||
* @param src Source structure.
|
||||
*/
|
||||
PJ_DECL(void) pjrpid_element_dup(pj_pool_t *pool, pjrpid_element *dst,
|
||||
const pjrpid_element *src);
|
||||
|
||||
|
||||
/**
|
||||
* Add RPID element information into existing PIDF document. This will also
|
||||
* add the appropriate XML namespace attributes into the presence's XML
|
||||
* node, if the attributes are not already present, and also a <note> element
|
||||
* to the first <tuple> element of the PIDF document.
|
||||
*
|
||||
* @param pres The PIDF presence document.
|
||||
* @param pool Pool.
|
||||
* @param options Currently unused, and must be zero.
|
||||
* @param elem RPID element information to be added into the PIDF
|
||||
* document.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjrpid_add_element(pjpidf_pres *pres,
|
||||
pj_pool_t *pool,
|
||||
unsigned options,
|
||||
const pjrpid_element *elem);
|
||||
|
||||
/**
|
||||
* Get RPID element information from PIDF document, if any.
|
||||
*
|
||||
* @param pres The PIDF document containing RPID elements.
|
||||
* @param pool Pool to duplicate the information.
|
||||
* @param elem Structure to receive the element information.
|
||||
*
|
||||
* @return PJ_SUCCESS if the document does contain RPID element
|
||||
* and the information has been parsed successfully.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjrpid_get_element(const pjpidf_pres *pres,
|
||||
pj_pool_t *pool,
|
||||
pjrpid_element *elem);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_RPID_H__ */
|
||||
|
||||
31
res/pjproject/pjsip/include/pjsip-simple/types.h
Normal file
31
res/pjproject/pjsip/include/pjsip-simple/types.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_TYPES_H__
|
||||
#define __PJSIP_SIMPLE_TYPES_H__
|
||||
|
||||
#include <pjsip/sip_types.h>
|
||||
|
||||
|
||||
#define PJSIP_EVSUB_POOL_LEN 4000
|
||||
#define PJSIP_EVSUB_POOL_INC 4000
|
||||
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_TYPES_H__ */
|
||||
|
||||
135
res/pjproject/pjsip/include/pjsip-simple/xpidf.h
Normal file
135
res/pjproject/pjsip/include/pjsip-simple/xpidf.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
|
||||
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
|
||||
*
|
||||
* 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_XPIDF_H__
|
||||
#define __PJSIP_SIMPLE_XPIDF_H__
|
||||
|
||||
/**
|
||||
* @file xpidf.h
|
||||
* @brief XPIDF/Presence Information Data Format
|
||||
*/
|
||||
#include <pjsip-simple/types.h>
|
||||
#include <pjlib-util/xml.h>
|
||||
|
||||
PJ_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* @defgroup PJSIP_SIMPLE_XPIDF XPIDF/Presence Information Data Format
|
||||
* @ingroup PJSIP_SIMPLE
|
||||
* @brief Support for XPIDF/Presence Information Data Format
|
||||
* @{
|
||||
*
|
||||
* This is an old presence data format as described in:
|
||||
* draft-rosenberg-impp-pidf-00.txt.
|
||||
*
|
||||
* We won't support this format extensively here, as it seems there's not
|
||||
* too many implementations support this anymore, as it shouldn't.
|
||||
*/
|
||||
|
||||
/** Type definitions for XPIDF root document. */
|
||||
typedef pj_xml_node pjxpidf_pres;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new XPIDF document.
|
||||
*
|
||||
* @param pool Pool.
|
||||
* @param uri URI to set in the XPIDF document.
|
||||
*
|
||||
* @return XPIDF document.
|
||||
*/
|
||||
PJ_DECL(pjxpidf_pres*) pjxpidf_create(pj_pool_t *pool, const pj_str_t *uri);
|
||||
|
||||
|
||||
/**
|
||||
* Parse XPIDF document.
|
||||
*
|
||||
* @param pool Pool.
|
||||
* @param text Input text.
|
||||
* @param len Length of input text.
|
||||
*
|
||||
* @return XPIDF document.
|
||||
*/
|
||||
PJ_DECL(pjxpidf_pres*) pjxpidf_parse(pj_pool_t *pool, char *text, pj_size_t len);
|
||||
|
||||
|
||||
/**
|
||||
* Print XPIDF document.
|
||||
*
|
||||
* @param pres The XPIDF document to print.
|
||||
* @param text Buffer to place the output.
|
||||
* @param len Length of the buffer.
|
||||
*
|
||||
* @return The length printed.
|
||||
*/
|
||||
PJ_DECL(int) pjxpidf_print( pjxpidf_pres *pres, char *text, pj_size_t len);
|
||||
|
||||
|
||||
/**
|
||||
* Get URI in the XPIDF document
|
||||
*
|
||||
* @param pres XPIDF document
|
||||
*
|
||||
* @return The URI, or an empty string.
|
||||
*/
|
||||
PJ_DECL(pj_str_t*) pjxpidf_get_uri(pjxpidf_pres *pres);
|
||||
|
||||
|
||||
/**
|
||||
* Set the URI of the XPIDF document.
|
||||
*
|
||||
* @param pool Pool.
|
||||
* @param pres The XPIDF document.
|
||||
* @param uri URI to set in the XPIDF document.
|
||||
*
|
||||
* @return Zero on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjxpidf_set_uri(pj_pool_t *pool, pjxpidf_pres *pres,
|
||||
const pj_str_t *uri);
|
||||
|
||||
|
||||
/**
|
||||
* Get presence status in the XPIDF document.
|
||||
*
|
||||
* @param pres XPIDF document.
|
||||
*
|
||||
* @return True to indicate the contact is online.
|
||||
*/
|
||||
PJ_DECL(pj_bool_t) pjxpidf_get_status(pjxpidf_pres *pres);
|
||||
|
||||
|
||||
/**
|
||||
* Set presence status in the XPIDF document.
|
||||
*
|
||||
* @param pres XPIDF document.
|
||||
* @param status Status to set, True for online, False for offline.
|
||||
*
|
||||
* @return Zero on success.
|
||||
*/
|
||||
PJ_DECL(pj_status_t) pjxpidf_set_status(pjxpidf_pres *pres, pj_bool_t status);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
PJ_END_DECL
|
||||
|
||||
|
||||
#endif /* __PJSIP_SIMPLE_XPIDF_H__ */
|
||||
Reference in New Issue
Block a user