/usr/include/pjsua2/presence.hpp is in libpjproject-dev 2.7.2~dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | /* $Id: presence.hpp 5672 2017-10-06 08:14:31Z riza $ */
/*
* Copyright (C) 2013 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 __PJSUA2_PRESENCE_HPP__
#define __PJSUA2_PRESENCE_HPP__
/**
* @file pjsua2/presence.hpp
* @brief PJSUA2 Presence Operations
*/
#include <pjsua2/persistent.hpp>
#include <pjsua2/siptypes.hpp>
/** PJSUA2 API is inside pj namespace */
namespace pj
{
/**
* @defgroup PJSUA2_PRES Presence
* @ingroup PJSUA2_Ref
* @{
*/
using std::string;
using std::vector;
/**
* This describes presence status.
*/
struct PresenceStatus
{
/**
* Buddy's online status.
*/
pjsua_buddy_status status;
/**
* Text to describe buddy's online status.
*/
string statusText;
/**
* Activity type.
*/
pjrpid_activity activity;
/**
* Optional text describing the person/element.
*/
string note;
/**
* Optional RPID ID string.
*/
string rpidId;
public:
/**
* Constructor.
*/
PresenceStatus();
};
/**
* This structure describes buddy configuration when adding a buddy to
* the buddy list with Buddy::create().
*/
struct BuddyConfig : public PersistentObject
{
/**
* Buddy URL or name address.
*/
string uri;
/**
* Specify whether presence subscription should start immediately.
*/
bool subscribe;
public:
/**
* Read this object from a container node.
*
* @param node Container to read values from.
*/
virtual void readObject(const ContainerNode &node) throw(Error);
/**
* Write this object to a container node.
*
* @param node Container to write values to.
*/
virtual void writeObject(ContainerNode &node) const throw(Error);
};
/**
* This structure describes buddy info, which can be retrieved by via
* Buddy::getInfo().
*/
struct BuddyInfo
{
/**
* The full URI of the buddy, as specified in the configuration.
*/
string uri;
/**
* Buddy's Contact, only available when presence subscription has
* been established to the buddy.
*/
string contact;
/**
* Flag to indicate that we should monitor the presence information for
* this buddy (normally yes, unless explicitly disabled).
*/
bool presMonitorEnabled;
/**
* If \a presMonitorEnabled is true, this specifies the last state of
* the presence subscription. If presence subscription session is currently
* active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
* subscription request has been rejected, the value will be
* PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
* specified in \a subTermReason.
*/
pjsip_evsub_state subState;
/**
* String representation of subscription state.
*/
string subStateName;
/**
* Specifies the last presence subscription termination code. This would
* return the last status of the SUBSCRIBE request. If the subscription
* is terminated with NOTIFY by the server, this value will be set to
* 200, and subscription termination reason will be given in the
* \a subTermReason field.
*/
pjsip_status_code subTermCode;
/**
* Specifies the last presence subscription termination reason. If
* presence subscription is currently active, the value will be empty.
*/
string subTermReason;
/**
* Presence status.
*/
PresenceStatus presStatus;
public:
/** Import from pjsip structure */
void fromPj(const pjsua_buddy_info &pbi);
};
/**
* This structure contains parameters for Buddy::onBuddyEvSubState() callback.
*/
struct OnBuddyEvSubStateParam
{
/**
* * The event which triggers state change event.
*/
SipEvent e;
};
/**
* Buddy.
*/
class Buddy
{
public:
/**
* Constructor.
*/
Buddy();
/**
* Destructor. Note that if the Buddy instance is deleted, it will also
* delete the corresponding buddy in the PJSUA-LIB.
*/
virtual ~Buddy();
/**
* Create buddy and register the buddy to PJSUA-LIB.
*
* @param acc The account for this buddy.
* @param cfg The buddy config.
*/
void create(Account &acc, const BuddyConfig &cfg) throw(Error);
/**
* Check if this buddy is valid.
*
* @return True if it is.
*/
bool isValid() const;
/**
* Get detailed buddy info.
*
* @return Buddy info.
*/
BuddyInfo getInfo() const throw(Error);
/**
* Enable/disable buddy's presence monitoring. Once buddy's presence is
* subscribed, application will be informed about buddy's presence status
* changed via \a onBuddyState() callback.
*
* @param subscribe Specify true to activate presence
* subscription.
*/
void subscribePresence(bool subscribe) throw(Error);
/**
* Update the presence information for the buddy. Although the library
* periodically refreshes the presence subscription for all buddies,
* some application may want to refresh the buddy's presence subscription
* immediately, and in this case it can use this function to accomplish
* this.
*
* Note that the buddy's presence subscription will only be initiated
* if presence monitoring is enabled for the buddy. See
* subscribePresence() for more info. Also if presence subscription for
* the buddy is already active, this function will not do anything.
*
* Once the presence subscription is activated successfully for the buddy,
* application will be notified about the buddy's presence status in the
* \a onBuddyState() callback.
*/
void updatePresence(void) throw(Error);
/**
* Send instant messaging outside dialog, using this buddy's specified
* account for route set and authentication.
*
* @param prm Sending instant message parameter.
*/
void sendInstantMessage(const SendInstantMessageParam &prm) throw(Error);
/**
* Send typing indication outside dialog.
*
* @param prm Sending instant message parameter.
*/
void sendTypingIndication(const SendTypingIndicationParam &prm)
throw(Error);
public:
/*
* Callbacks
*/
/**
* Notify application when the buddy state has changed.
* Application may then query the buddy info to get the details.
*/
virtual void onBuddyState()
{}
/**
* Notify application when the state of client subscription session
* associated with a buddy has changed. Application may use this
* callback to retrieve more detailed information about the state
* changed event.
*
* @param prm Callback parameter.
*/
virtual void onBuddyEvSubState(OnBuddyEvSubStateParam &prm)
{ PJ_UNUSED_ARG(prm); }
private:
/**
* Buddy ID.
*/
pjsua_buddy_id id;
/**
* Account.
*/
Account *acc;
};
/** Array of buddies */
typedef std::vector<Buddy*> BuddyVector;
/**
* @} // PJSUA2_PRES
*/
} // namespace pj
#endif /* __PJSUA2_PRESENCE_HPP__ */
|