kodi
PltEvent.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Platinum - Event
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
13 |
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
21 |
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
26 |
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
32 |
33 ****************************************************************/
34 
39 #ifndef _PLT_EVENT_H_
40 #define _PLT_EVENT_H_
41 
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 #include "PltHttpClientTask.h"
47 
48 /*----------------------------------------------------------------------
49 | forward declarations
50 +---------------------------------------------------------------------*/
51 class PLT_StateVariable;
52 class PLT_DeviceData;
53 class PLT_Service;
54 class PLT_TaskManager;
55 class PLT_CtrlPoint;
56 
57 /*----------------------------------------------------------------------
58 | PLT_EventNotification class
59 +---------------------------------------------------------------------*/
65 {
66 public:
68 
69  static PLT_EventNotification* Parse(const NPT_HttpRequest& request,
70  const NPT_HttpRequestContext& context,
71  NPT_HttpResponse& response);
72 
73 
74  NPT_TimeStamp m_ReceptionTime;
75  NPT_HttpUrl m_RequestUrl;
76  NPT_String m_SID;
77  NPT_Ordinal m_EventKey;
78  NPT_String m_XmlBody;
79 
80 protected:
81  PLT_EventNotification() : m_EventKey(0) {}
82 };
83 
84 /*----------------------------------------------------------------------
85 | PLT_EventSubscriber class
86 +---------------------------------------------------------------------*/
92 {
93 public:
95  PLT_Service* service,
96  const char* sid,
97  NPT_Timeout timeout_secs = -1);
99 
100  PLT_Service* GetService();
101  NPT_Ordinal GetEventKey();
102  NPT_Result SetEventKey(NPT_Ordinal value);
103  NPT_SocketAddress GetLocalIf();
104  NPT_Result SetLocalIf(NPT_SocketAddress value);
105  NPT_TimeStamp GetExpirationTime();
106  NPT_Result SetTimeout(NPT_Timeout seconds = -1);
107  const NPT_String& GetSID() const { return m_SID; }
108  NPT_Result FindCallbackURL(const char* callback_url);
109  NPT_Result AddCallbackURL(const char* callback_url);
110  NPT_Result Notify(NPT_List<PLT_StateVariable*>& vars);
111 
112 protected:
113  //members
114  PLT_TaskManagerReference m_TaskManager;
115  PLT_Service* m_Service;
116  NPT_Ordinal m_EventKey;
117  PLT_HttpClientSocketTask* m_SubscriberTask;
118  NPT_String m_SID;
119  NPT_SocketAddress m_LocalIf;
120  NPT_Array<NPT_String> m_CallbackURLs;
121  NPT_TimeStamp m_ExpirationTime;
122 };
123 
125 
126 /*----------------------------------------------------------------------
127 | PLT_EventSubscriberFinderBySID
128 +---------------------------------------------------------------------*/
134 {
135 public:
136  // methods
137  PLT_EventSubscriberFinderBySID(const char* sid) : m_SID(sid) {}
138 
139  bool operator()(PLT_EventSubscriberReference const & sub) const {
140  return m_SID.Compare(sub->GetSID(), true) ? false : true;
141  }
142 
143 private:
144  // members
145  NPT_String m_SID;
146 };
147 
148 /*----------------------------------------------------------------------
149 | PLT_EventSubscriberFinderByCallbackURL
150 +---------------------------------------------------------------------*/
156 {
157 public:
158  // methods
159  PLT_EventSubscriberFinderByCallbackURL(const char* callback_url) :
160  m_CallbackURL(callback_url) {}
161 
162  bool operator()(PLT_EventSubscriberReference const & sub) const {
163  return NPT_SUCCEEDED(sub->FindCallbackURL(m_CallbackURL));
164  }
165 
166 private:
167  // members
168  NPT_String m_CallbackURL;
169 };
170 
171 /*----------------------------------------------------------------------
172 | PLT_EventSubscriberFinderByService
173 +---------------------------------------------------------------------*/
179 {
180 public:
181  // methods
182  PLT_EventSubscriberFinderByService(PLT_Service* service) : m_Service(service) {}
184  bool operator()(PLT_EventSubscriberReference const & eventSub) const;
185 
186 private:
187  // members
188  PLT_Service* m_Service;
189 };
190 
191 #endif /* _PLT_EVENT_H_ */
Definition: NptHttp.h:566
The PLT_HttpClientSocketTask class is the base class used to send a HTTP request asynchronously using...
Definition: PltHttpClientTask.h:58
Definition: NptHttp.h:315
Definition: NptHttp.h:126
The PLT_EventSubscriberFinderByCallbackURL class returns an instance of a PLT_EventSubscriber given i...
Definition: PltEvent.h:155
Definition: NptHttp.h:282
UPnP Service.
Definition: PltService.h:67
The PLT_TaskManager class maintains a list of runnable tasks.
Definition: PltTaskManager.h:60
Definition: NptTime.h:50
The PLT_EventSubscriberFinderBySID class returns an instance of a PLT_EventSubscriber given its subsc...
Definition: PltEvent.h:133
The PLT_StateVariable class maintains the state of a UPnP Service state variable. ...
Definition: PltStateVariable.h:75
Definition: NptSockets.h:77
The PLT_EventNotification class represents an event notification for a given service to a given subsc...
Definition: PltEvent.h:64
HTTP Client tasks.
The PLT_DeviceData class holds information about a device being advertised or found by a control poin...
Definition: PltDeviceData.h:93
The PLT_EventSubscriberFinderByService class returns an instance of a PLT_EventSubscriber given a UPn...
Definition: PltEvent.h:178
The PLT_EventSubscriber class represents an event subscription for a given service from a UPnP Contro...
Definition: PltEvent.h:91
Definition: NptStrings.h:57
The PLT_CtrlPoint class implements the base functionality of a UPnP ControlPoint. ...
Definition: PltCtrlPoint.h:89
Definition: NptList.h:54