2
* Copyright (C) 2012, 2013 LOTES TM LLC
3
* Author : Andrey Loukhnov <aol.nnov@gmail.com>
4
* Author : Patrick Keroulas <patrick.keroulas@savoirfairelinux.com>
5
* This file is a part of pult5-voip
7
* pult5-voip is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3 of the License, or
10
* (at your option) any later version.
12
* pult5-voip is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this programm. If not, see <http://www.gnu.org/licenses/>.
20
* Additional permission under GNU GPL version 3 section 7:
22
* If you modify pult5-voip, or any covered work, by linking or
23
* combining it with the OpenSSL project's OpenSSL library (or a
24
* modified version of that library), containing parts covered by the
25
* terms of the OpenSSL or SSLeay licenses, LOTES-TM LLC
26
* Corresponding Source for a non-source form of such a combination
27
* shall include the source code for the parts of OpenSSL used as well
28
* as that of the covered work.
31
#ifndef PRES_SUB_CLIENT_H
32
#define PRES_SUB_CLIENT_H
34
#include <pjsip-simple/presence.h>
39
#include <pjsip-simple/evsub.h>
40
#include <pjsip-simple/evsub_msg.h>
41
#include <pjsip/sip_endpoint.h>
42
#include <pjsip/sip_transport.h>
43
#include "noncopyable.h"
52
* @param uri SIP uri of remote user that we want to subscribe,
54
PresSubClient(const std::string &uri, SIPPresence *pres);
57
* Process the the unsubscription before the destruction.
61
* Compare with another pres_client's uris.
62
* @param b Other pres_client pointer
64
bool match(PresSubClient *b);
66
* Enable the monitoring and report signal to the client.
67
* The PBX server must approve and maintain the subrciption before the pres_client is added in the pres_client list.
68
* @param flag State of subscription. True if active.
70
void enable(bool flag);
72
* Get associated parent presence_module
74
SIPPresence * getPresence();
80
* Data unlock function
84
* Send a SUBCRIBE to the PXB or directly to a pres_client in the IP2IP context.
88
* Send a SUBCRIBE to the PXB or directly to a pres_client in the IP2IP context but
89
* the 0s timeout make the dialog expire immediatly.
93
* Return the monitor variable.
97
* Return the pres_client URI
102
* Is the buddy present
107
* A message from the URIs
109
std::string getLineStatus();
113
* TODO: explain this:
124
NON_COPYABLE(PresSubClient);
127
* Transaction functions of event subscription client side.
129
static void pres_client_evsub_on_state(pjsip_evsub *sub, pjsip_event *event);
130
static void pres_client_evsub_on_tsx_state(pjsip_evsub *sub,
131
pjsip_transaction *tsx,
133
static void pres_client_evsub_on_rx_notify(pjsip_evsub *sub,
134
pjsip_rx_data *rdata,
136
pj_str_t **p_st_text,
138
pjsip_msg_body **p_body);
139
static void pres_client_timer_cb(pj_timer_heap_t *th, pj_timer_entry *entry);
142
* Plan a retry or a renew a subscription.
143
* @param reschedule Allow for reschedule.
144
* @param msec Delay value in milliseconds.
146
void rescheduleTimer(bool reschedule, unsigned msec);
148
* Callback after a presence notification was received.
149
* Tranfert info to the SIP account.
151
void reportPresence();
153
* Process the un/subscribe request transmission.
155
pj_status_t updateSubscription();
157
* Compare the reason of a transaction end with the given string.
159
bool isTermReason(const std::string &);
161
* return the code after a transaction is terminated.
163
unsigned getTermCode();
165
SIPPresence *pres_; /**< Associated SIPPresence pointer */
166
pj_str_t uri_; /**< pres_client URI. */
167
pj_str_t contact_; /**< Contact learned from subscrp. */
168
pj_str_t display_; /**< pres_client display name. */
169
pjsip_dialog *dlg_; /**< The underlying dialog. */
170
pj_bool_t monitored_; /**< Should we monitor? */
171
pj_str_t name_; /**< pres_client name. */
173
pj_pool_t *pool_; /**< Pool for this pres_client. */
174
pjsip_pres_status status_; /**< pres_client presence status. */
175
pjsip_evsub *sub_; /**< pres_client presence subscription */
176
unsigned term_code_; /**< Subscription termination code */
177
pj_str_t term_reason_; /**< Subscription termination reason */
178
pj_timer_entry timer_; /**< Resubscription timer */
179
void *user_data_; /**< Application data. */
182
static int modId_; // used to extract data structure from event_subscription
185
#endif /* PRES_SUB_CLIENT_H */