Ring Daemon
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, pjsip_transaction* tsx, pjsip_event* event);
118 static void pres_client_evsub_on_rx_notify(pjsip_evsub* sub,
120 int* p_st_code,
124 static void pres_client_timer_cb(pj_timer_heap_t* th, pj_timer_entry* entry);
125
131 void rescheduleTimer(bool reschedule, unsigned msec);
136 void reportPresence();
140 pj_status_t updateSubscription();
141 /*
142 * Compare the reason of a transaction end with the given string.
143 */
144 bool isTermReason(const std::string&);
148 unsigned getTermCode();
149
150 SIPPresence* pres_;
151 pj_str_t uri_;
152 pj_str_t contact_;
153 pj_str_t display_;
154 pjsip_dialog* dlg_;
155 pj_bool_t monitored_;
156 pj_str_t name_;
157 pj_caching_pool cp_;
158 pj_pool_t* pool_;
159 pjsip_pres_status status_;
160 pjsip_evsub* sub_;
161 unsigned term_code_;
162 pj_str_t term_reason_;
163 pj_timer_entry timer_;
164 void* user_data_;
165 int lock_count_;
166 int lock_flag_;
167 static int modId_; // used to extract data structure from event_subscription
168};
169
170} // namespace jami
171
172#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 jami_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30