31 #ifndef OPAL_SIP_SIPPRES_H
32 #define OPAL_SIP_SIPPRES_H
41 #include <ptclib/pxml.h>
43 #include <ptlib/notifier_ext.h>
46 class XCAPClient :
public PHTTPClient
49 struct ElementSelector {
51 const PString & name = PString::Empty(),
52 const PString & position = PString::Empty()
54 , m_position(position)
55 { PAssert(!m_name.IsEmpty(), PInvalidParameter); }
59 const PString & attribute,
62 , m_attribute(attribute)
64 { PAssert(!m_name.IsEmpty(), PInvalidParameter); }
68 const PString & position,
69 const PString & attribute,
72 , m_position(position)
73 , m_attribute(attribute)
75 { PAssert(!m_name.IsEmpty(), PInvalidParameter); }
77 PString AsString()
const;
85 class NodeSelector :
public std::list<ElementSelector>
91 const ElementSelector & selector
92 ) { push_back(selector); }
94 const ElementSelector & selector1,
95 const ElementSelector & selector2
96 ) { push_back(selector1); push_back(selector2); }
98 const ElementSelector & selector1,
99 const ElementSelector & selector2,
100 const ElementSelector & selector3
101 ) { push_back(selector1); push_back(selector2); push_back(selector3); }
104 const PString & name,
105 const PString & position = PString::Empty()
106 ) { push_back(ElementSelector(name, position)); }
109 const PString & name,
110 const PString & attribute,
111 const PString & value
112 ) { push_back(ElementSelector(name, attribute, value)); }
115 const PString & name,
116 const PString & position,
117 const PString & attribute,
118 const PString & value
119 ) { push_back(ElementSelector(name, position, attribute, value)); }
122 const PString & space,
123 const PString & alias = PString::Empty()
124 ) { PAssert(!space.IsEmpty(), PInvalidParameter); m_namespaces[alias] = space; }
131 std::map<PString, PString> m_namespaces;
139 ) {
return GetXml(BuildURL(), xml); }
148 ) {
return PutXml(BuildURL(), xml); }
155 bool DeleteXml() {
return DeleteDocument(BuildURL()); }
163 ) { m_root = server; }
164 const PURL & GetRoot()
const {
return m_root; }
166 void SetApplicationUniqueID(
169 const PString & GetApplicationUniqueID()
const {
return m_auid; }
171 void SetGlobal() { m_global =
true; }
172 bool IsGlobal()
const {
return m_global; }
174 void SetUserIdentifier(
176 ) { m_global =
false; m_xui = id; }
177 const PString & GetUserIdentifier()
const {
return m_xui; }
181 ) { m_filename = fn; }
182 const PString & GetFilename()
const {
return m_filename; }
185 const NodeSelector & node
187 const NodeSelector & GetNode()
const {
return m_node; }
188 void ClearNode() { m_node.clear(); }
192 ) { m_contentType = type; }
193 const PString & GetContentType()
const {
return m_contentType; }
202 PString m_contentType;
206 class SIPWatcherInfoCommand :
public OpalPresentityCommand {
208 SIPWatcherInfoCommand(
bool unsubscribe =
false) : m_unsubscribe(unsubscribe) { }
216 class SIP_Presentity :
public OpalPresentityWithCommandThread,
public PValidatedNotifierTarget
218 PCLASSINFO(SIP_Presentity, OpalPresentityWithCommandThread);
222 SIP_Presentity(
const SIP_Presentity & other);
225 virtual PObject * Clone()
const {
return new SIP_Presentity(*
this); }
235 static const PCaselessString & PIDFEntityKey();
236 static const PCaselessString & SubProtocolKey();
237 static const PCaselessString & PresenceAgentKey();
238 static const PCaselessString & TransportKey();
239 static const PCaselessString & XcapRootKey();
240 static const PCaselessString & XcapAuthIdKey();
241 static const PCaselessString & XcapPasswordKey();
242 static const PCaselessString & XcapAuthAuidKey();
243 static const PCaselessString & XcapAuthFileKey();
244 static const PCaselessString & XcapBuddyListKey();
246 virtual PStringArray GetAttributeNames()
const;
247 virtual PStringArray GetAttributeTypes()
const;
250 virtual bool Close();
251 virtual BuddyStatus GetBuddyListEx(BuddyList & buddies);
252 virtual BuddyStatus SetBuddyListEx(
const BuddyList & buddies);
253 virtual BuddyStatus DeleteBuddyListEx();
254 virtual BuddyStatus GetBuddyEx(BuddyInfo & buddy);
255 virtual BuddyStatus SetBuddyEx(
const BuddyInfo & buddy);
256 virtual BuddyStatus DeleteBuddyEx(
const PURL & presentity);
257 virtual BuddyStatus SubscribeBuddyListEx(PINDEX & successful,
bool subscribe =
true);
259 SIPEndPoint & GetEndpoint() {
return *m_endpoint; }
261 void Internal_SendLocalPresence(
const OpalSetLocalPresenceCommand & cmd);
262 void Internal_SubscribeToPresence(
const OpalSubscribeToPresenceCommand & cmd);
263 void Internal_SubscribeToWatcherInfo(
const SIPWatcherInfoCommand & cmd);
264 void Internal_AuthorisationRequest(
const OpalAuthorisationRequestCommand & cmd);
266 unsigned GetExpiryTime()
const;
273 void OnReceivedWatcherStatus(PXMLElement * watcher);
274 void SetPIDFEntity(PURL & entity);
275 bool ChangeAuthNode(XCAPClient & xcap,
const OpalAuthorisationRequestCommand & cmd);
276 void InitRootXcap(XCAPClient & xcap);
279 const PString & entryName = PString::Empty(),
280 const PString & listName = PString::Empty()
284 SubProtocol m_subProtocol;
285 SIPURL m_presenceAgentURL;
286 PURL m_defaultRootURL;
287 PString m_watcherSubscriptionAOR;
288 int m_watcherInfoVersion;
289 PString m_publishedTupleId;
291 typedef std::map<PString, PString> StringMap;
292 StringMap m_watcherAorById;
293 StringMap m_presenceIdByAor;
294 StringMap m_presenceAorById;
295 StringMap m_authorisationIdByAor;
298 void operator=(
const SIP_Presentity &) { }
302 #endif // OPAL_SIP_PRESENCE
304 #endif // OPAL_SIP_SIPPRES_H