Ring Daemon 16.0.0
Loading...
Searching...
No Matches
pres_sub_client.h
Go to the documentation of this file.
1/*
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
6 *
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.
11 *
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.
16 *
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/>.
19 */
20
21#ifndef PRES_SUB_CLIENT_H
22#define PRES_SUB_CLIENT_H
23
24#include <pjsip-simple/presence.h>
25#include <pj/timer.h>
26#include <pj/pool.h>
27#include <string>
28
29#include <pjsip-simple/evsub.h>
30#include <pjsip-simple/evsub_msg.h>
31#include <pjsip/sip_endpoint.h>
32#include <pjsip/sip_transport.h>
33#include "noncopyable.h"
34
35namespace jami {
36
37class SIPPresence;
38
40{
41public:
46 PresSubClient(const std::string& uri, SIPPresence* pres);
56 bool match(PresSubClient* b);
63 void enable(bool flag);
71 bool lock();
75 void unlock();
79 bool subscribe();
84 bool unsubscribe();
88 bool isSubscribed();
92 std::string_view getURI();
93
97 bool isPresent();
98
102 std::string_view getLineStatus();
103
107 void incLock() { lock_count_++; }
108 void decLock() { lock_count_--; }
109
110private:
112
116 static void pres_client_evsub_on_state(pjsip_evsub* sub, pjsip_event* event);
117 static void pres_client_evsub_on_tsx_state(pjsip_evsub* sub,
120 static void pres_client_evsub_on_rx_notify(pjsip_evsub* sub,
122 int* p_st_code,
126 static void pres_client_timer_cb(pj_timer_heap_t* th, pj_timer_entry* entry);
127
133 void rescheduleTimer(bool reschedule, unsigned msec);
138 void reportPresence();
142 pj_status_t updateSubscription();
143 /*
144 * Compare the reason of a transaction end with the given string.
145 */
146 bool isTermReason(const std::string&);
150 unsigned getTermCode();
151
152 SIPPresence* pres_;
153 pj_str_t uri_;
154 pj_str_t contact_;
155 pj_str_t display_;
156 pjsip_dialog* dlg_;
157 pj_bool_t monitored_;
158 pj_str_t name_;
159 pj_caching_pool cp_;
160 pj_pool_t* pool_;
161 pjsip_pres_status status_;
162 pjsip_evsub* sub_;
163 unsigned term_code_;
164 pj_str_t term_reason_;
165 pj_timer_entry timer_;
166 void* user_data_;
167 int lock_count_;
168 int lock_flag_;
169 static int modId_; // used to extract data structure from event_subscription
170};
171
172} // namespace jami
173
174#endif /* PRES_SUB_CLIENT_H */
void enable(bool flag)
Enable the monitoring and report signal to the client.
bool isPresent()
Is the buddy present.
bool unsubscribe()
Send a SUBCRIBE to the PXB or directly to a pres_client in the IP2IP context but the 0s timeout make ...
bool match(PresSubClient *b)
Compare with another pres_client's uris.
void incLock()
TODO: explain this:
bool isSubscribed()
Return the monitor variable.
bool lock()
Data lock function.
bool subscribe()
Send a SUBCRIBE to the PXB or directly to a pres_client in the IP2IP context.
std::string_view getURI()
Return the pres_client URI.
void unlock()
Data unlock function.
std::string_view getLineStatus()
A message from the URIs.
SIPPresence * getPresence()
Get associated parent presence_module.
void emitSignal(Args... args)
Definition ring_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30