diff --git a/.travis.yml b/.travis.yml index 924c8ead..0746f610 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -osx_image: xcode7.1 +osx_image: xcode7.3 language: objective-c before_install: - brew update diff --git a/Cartfile.resolved b/Cartfile.resolved index 95b9df66..f7ed5794 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "plutinosoft/Neptune" "1.1.9" +github "plutinosoft/Neptune" "1.1.10" diff --git a/Docs/Doxygen/html/PltDeviceHost_8h_source.html b/Docs/Doxygen/html/PltDeviceHost_8h_source.html index 780377a3..93d74a6a 100644 --- a/Docs/Doxygen/html/PltDeviceHost_8h_source.html +++ b/Docs/Doxygen/html/PltDeviceHost_8h_source.html @@ -256,7 +256,7 @@
PLT_DeviceHost::SetByeByeFirst
virtual void SetByeByeFirst(bool bye_bye_first)
When a UPnP device comes up, the specifications require that a SSDP bye-bye sequence is sent to force...
Definition: PltDeviceHost.h:104
PLT_DeviceHost::Announce
NPT_Result Announce(NPT_HttpRequest &request, NPT_UdpSocket &socket, PLT_SsdpAnnounceType type)
Called during SSDP announce.
Definition: PltDeviceHost.h:148
PLT_DeviceHost::ProcessHttpPostRequest
virtual NPT_Result ProcessHttpPostRequest(NPT_HttpRequest &request, const NPT_HttpRequestContext &context, NPT_HttpResponse &response)
This method is called when a "POST" request has been received.
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
PltTaskManager.h
Runnable Tasks Manager.
PLT_DeviceHost::ProcessHttpGetRequest
virtual NPT_Result ProcessHttpGetRequest(NPT_HttpRequest &request, const NPT_HttpRequestContext &context, NPT_HttpResponse &response)
This method is called when a "GET" request for a resource other than the device description, SCPD, or icons has been received.
PLT_DeviceHost::ProcessGetDescription
virtual NPT_Result ProcessGetDescription(NPT_HttpRequest &request, const NPT_HttpRequestContext &context, NPT_HttpResponse &response)
This method is called when a control point is requesting the device description.
diff --git a/Docs/Doxygen/html/PltEvent_8h_source.html b/Docs/Doxygen/html/PltEvent_8h_source.html index 89550630..fe80c5e1 100644 --- a/Docs/Doxygen/html/PltEvent_8h_source.html +++ b/Docs/Doxygen/html/PltEvent_8h_source.html @@ -147,85 +147,91 @@
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 
-
124 typedef NPT_Reference<PLT_EventSubscriber> PLT_EventSubscriberReference;
-
125 
-
126 /*----------------------------------------------------------------------
-
127 | PLT_EventSubscriberFinderBySID
-
128 +---------------------------------------------------------------------*/
-
133 class PLT_EventSubscriberFinderBySID
-
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 +---------------------------------------------------------------------*/
-
155 class PLT_EventSubscriberFinderByCallbackURL
-
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 +---------------------------------------------------------------------*/
-
178 class PLT_EventSubscriberFinderByService
-
179 {
-
180 public:
-
181  // methods
-
182  PLT_EventSubscriberFinderByService(PLT_Service* service) : m_Service(service) {}
-
183  virtual ~PLT_EventSubscriberFinderByService() {}
-
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_ */
+
111 
+
112  // PLT_HttpClientTask methods
+
113  NPT_Result ProcessResponse(NPT_Result res,
+
114  const NPT_HttpRequest& request,
+
115  const NPT_HttpRequestContext& context,
+
116  NPT_HttpResponse* response);
+
117 
+
118 protected:
+
119  //members
+
120  PLT_TaskManagerReference m_TaskManager;
+
121  PLT_Service* m_Service;
+
122  NPT_Ordinal m_EventKey;
+
123  PLT_HttpClientSocketTask* m_SubscriberTask;
+
124  NPT_String m_SID;
+
125  NPT_SocketAddress m_LocalIf;
+
126  NPT_Array<NPT_String> m_CallbackURLs;
+
127  NPT_TimeStamp m_ExpirationTime;
+
128 };
+
129 
+
130 typedef NPT_Reference<PLT_EventSubscriber> PLT_EventSubscriberReference;
+
131 
+
132 /*----------------------------------------------------------------------
+
133 | PLT_EventSubscriberFinderBySID
+
134 +---------------------------------------------------------------------*/
+
139 class PLT_EventSubscriberFinderBySID
+
140 {
+
141 public:
+
142  // methods
+
143  PLT_EventSubscriberFinderBySID(const char* sid) : m_SID(sid) {}
+
144 
+
145  bool operator()(PLT_EventSubscriberReference const & sub) const {
+
146  return m_SID.Compare(sub->GetSID(), true) ? false : true;
+
147  }
+
148 
+
149 private:
+
150  // members
+
151  NPT_String m_SID;
+
152 };
+
153 
+
154 /*----------------------------------------------------------------------
+
155 | PLT_EventSubscriberFinderByCallbackURL
+
156 +---------------------------------------------------------------------*/
+
161 class PLT_EventSubscriberFinderByCallbackURL
+
162 {
+
163 public:
+
164  // methods
+
165  PLT_EventSubscriberFinderByCallbackURL(const char* callback_url) :
+
166  m_CallbackURL(callback_url) {}
+
167 
+
168  bool operator()(PLT_EventSubscriberReference const & sub) const {
+
169  return NPT_SUCCEEDED(sub->FindCallbackURL(m_CallbackURL));
+
170  }
+
171 
+
172 private:
+
173  // members
+
174  NPT_String m_CallbackURL;
+
175 };
+
176 
+
177 /*----------------------------------------------------------------------
+
178 | PLT_EventSubscriberFinderByService
+
179 +---------------------------------------------------------------------*/
+
184 class PLT_EventSubscriberFinderByService
+
185 {
+
186 public:
+
187  // methods
+
188  PLT_EventSubscriberFinderByService(PLT_Service* service) : m_Service(service) {}
+
189  virtual ~PLT_EventSubscriberFinderByService() {}
+
190  bool operator()(PLT_EventSubscriberReference const & eventSub) const;
+
191 
+
192 private:
+
193  // members
+
194  PLT_Service* m_Service;
+
195 };
+
196 
+
197 #endif /* _PLT_EVENT_H_ */
PLT_HttpClientSocketTask
The PLT_HttpClientSocketTask class is the base class used to send a HTTP request asynchronously using...
Definition: PltHttpClientTask.h:58
-
PLT_EventSubscriberFinderByCallbackURL
The PLT_EventSubscriberFinderByCallbackURL class returns an instance of a PLT_EventSubscriber given i...
Definition: PltEvent.h:155
+
PLT_EventSubscriberFinderByCallbackURL
The PLT_EventSubscriberFinderByCallbackURL class returns an instance of a PLT_EventSubscriber given i...
Definition: PltEvent.h:161
PLT_Service
UPnP Service.
Definition: PltService.h:67
PLT_TaskManager
The PLT_TaskManager class maintains a list of runnable tasks.
Definition: PltTaskManager.h:60
-
PLT_EventSubscriberFinderBySID
The PLT_EventSubscriberFinderBySID class returns an instance of a PLT_EventSubscriber given its subsc...
Definition: PltEvent.h:133
+
PLT_EventSubscriberFinderBySID
The PLT_EventSubscriberFinderBySID class returns an instance of a PLT_EventSubscriber given its subsc...
Definition: PltEvent.h:139
PLT_StateVariable
The PLT_StateVariable class maintains the state of a UPnP Service state variable. ...
Definition: PltStateVariable.h:75
PLT_EventNotification
The PLT_EventNotification class represents an event notification for a given service to a given subsc...
Definition: PltEvent.h:64
PltHttpClientTask.h
HTTP Client tasks.
PLT_DeviceData
The PLT_DeviceData class holds information about a device being advertised or found by a control poin...
Definition: PltDeviceData.h:93
-
PLT_EventSubscriberFinderByService
The PLT_EventSubscriberFinderByService class returns an instance of a PLT_EventSubscriber given a UPn...
Definition: PltEvent.h:178
+
PLT_EventSubscriberFinderByService
The PLT_EventSubscriberFinderByService class returns an instance of a PLT_EventSubscriber given a UPn...
Definition: PltEvent.h:184
PLT_EventSubscriber
The PLT_EventSubscriber class represents an event subscription for a given service from a UPnP Contro...
Definition: PltEvent.h:91
PLT_CtrlPoint
The PLT_CtrlPoint class implements the base functionality of a UPnP ControlPoint. ...
Definition: PltCtrlPoint.h:89
diff --git a/Docs/Doxygen/html/PltFileMediaServer_8h_source.html b/Docs/Doxygen/html/PltFileMediaServer_8h_source.html index e9907567..22a90daf 100644 --- a/Docs/Doxygen/html/PltFileMediaServer_8h_source.html +++ b/Docs/Doxygen/html/PltFileMediaServer_8h_source.html @@ -194,7 +194,7 @@
PLT_MediaServer
The PLT_MediaServer class implements the base class for a UPnP AV Media Server device.
Definition: PltMediaServer.h:102
PltMediaCache.h
Simple Object Caching utility.
PLT_FileMediaServer
File Media Server.
Definition: PltFileMediaServer.h:130
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
PLT_MediaObject
The PLT_MediaObject class is any data entity that can be returned by a ContentDirectory Service from ...
Definition: PltMediaItem.h:179
diff --git a/Docs/Doxygen/html/PltHttpClientTask_8h_source.html b/Docs/Doxygen/html/PltHttpClientTask_8h_source.html index a2e31136..0e949255 100644 --- a/Docs/Doxygen/html/PltHttpClientTask_8h_source.html +++ b/Docs/Doxygen/html/PltHttpClientTask_8h_source.html @@ -134,28 +134,30 @@
97 class PLT_HttpClientTask : public PLT_HttpClientSocketTask
98 {
99 public:
-
100  PLT_HttpClientTask<T>(const NPT_HttpUrl& url, T* data) :
-
101  PLT_HttpClientSocketTask(new NPT_HttpRequest(url,
-
102  "GET",
-
103  NPT_HTTP_PROTOCOL_1_1)),
-
104  m_Data(data) {}
-
105  protected:
-
106  virtual ~PLT_HttpClientTask<T>() {}
-
107 
-
108 protected:
-
109  // PLT_HttpClientSocketTask method
-
110  NPT_Result ProcessResponse(NPT_Result res,
-
111  const NPT_HttpRequest& request,
-
112  const NPT_HttpRequestContext& context,
-
113  NPT_HttpResponse* response) {
-
114  return m_Data->ProcessResponse(res, request, context, response);
-
115  }
-
116 
-
117 protected:
-
118  T* m_Data;
-
119 };
-
120 
-
121 #endif /* _PLT_HTTP_CLIENT_TASK_H_ */
+
100  PLT_HttpClientTask<T>(T* data, bool wait_forever = false) :
+
101  PLT_HttpClientSocketTask(NULL, wait_forever), m_Data(data) {}
+
102  PLT_HttpClientTask<T>(const NPT_HttpUrl& url, T* data) :
+
103  PLT_HttpClientSocketTask(new NPT_HttpRequest(url,
+
104  "GET",
+
105  NPT_HTTP_PROTOCOL_1_1)),
+
106  m_Data(data) {}
+
107  protected:
+
108  virtual ~PLT_HttpClientTask<T>() {}
+
109 
+
110 protected:
+
111  // PLT_HttpClientSocketTask method
+
112  NPT_Result ProcessResponse(NPT_Result res,
+
113  const NPT_HttpRequest& request,
+
114  const NPT_HttpRequestContext& context,
+
115  NPT_HttpResponse* response) {
+
116  return m_Data->ProcessResponse(res, request, context, response);
+
117  }
+
118 
+
119 protected:
+
120  T* m_Data;
+
121 };
+
122 
+
123 #endif /* _PLT_HTTP_CLIENT_TASK_H_ */
PltThreadTask.h
Runnable Task.
PLT_HttpClientSocketTask
The PLT_HttpClientSocketTask class is the base class used to send a HTTP request asynchronously using...
Definition: PltHttpClientTask.h:58
PLT_HttpClientSocketTask::DoAbort
virtual void DoAbort()
This method to override in derived classes is called when the task is about to stop.
diff --git a/Docs/Doxygen/html/PltHttp_8h_source.html b/Docs/Doxygen/html/PltHttp_8h_source.html index b95b3278..16a93283 100644 --- a/Docs/Doxygen/html/PltHttp_8h_source.html +++ b/Docs/Doxygen/html/PltHttp_8h_source.html @@ -138,115 +138,116 @@
95  static NPT_Result SetBody(NPT_HttpMessage& message, const void* body, NPT_LargeSize len, NPT_HttpEntity** entity = NULL);
96  static NPT_Result SetBody(NPT_HttpMessage& message, NPT_InputStreamReference stream, NPT_HttpEntity** entity = NULL);
97  static NPT_Result GetBody(const NPT_HttpMessage& message, NPT_String& body);
-
98  static NPT_Result ParseBody(const NPT_HttpMessage& message, NPT_XmlElementNode*& xml);
-
99 
-
100  static void SetBasicAuthorization(NPT_HttpRequest& request, const char* username, const char* password);
-
101 };
-
102 
-
103 /*----------------------------------------------------------------------
-
104 | PLT_HttpRequestContext
-
105 +---------------------------------------------------------------------*/
-
111 class PLT_HttpRequestContext : public NPT_HttpRequestContext {
-
112 public:
-
113  // constructors and destructor
-
114  PLT_HttpRequestContext(const NPT_HttpRequest& request) :
-
115  m_Request(request) {}
-
116  PLT_HttpRequestContext(const NPT_HttpRequest& request, const NPT_HttpRequestContext& context) :
-
117  NPT_HttpRequestContext(&context.GetLocalAddress(), &context.GetRemoteAddress()),
-
118  m_Request(request) {}
-
119  virtual ~PLT_HttpRequestContext() {}
-
120 
-
121  const NPT_HttpRequest& GetRequest() const { return m_Request; }
-
122  PLT_DeviceSignature GetDeviceSignature() { return PLT_HttpHelper::GetDeviceSignature(m_Request); }
-
123 
-
124 private:
-
125  const NPT_HttpRequest& m_Request;
-
126 };
-
127 
-
128 /*----------------------------------------------------------------------
-
129 | NPT_HttpHeaderPrinter
-
130 +---------------------------------------------------------------------*/
-
131 class NPT_HttpHeaderPrinter
-
132 {
-
133 public:
-
134  // methods
-
135  NPT_HttpHeaderPrinter(NPT_OutputStreamReference& stream) :
-
136  m_Stream(stream) {}
-
137  NPT_Result operator()(NPT_HttpHeader*& header) const {
-
138  m_Stream->WriteString(header->GetName());
-
139  m_Stream->Write(": ", 2);
-
140  m_Stream->WriteString(header->GetValue());
-
141  m_Stream->Write("\r\n", 2, NULL);
-
142  return NPT_SUCCESS;
-
143  }
-
144 
-
145 private:
-
146  // members
-
147  NPT_OutputStreamReference& m_Stream;
-
148 };
-
149 
-
150 /*----------------------------------------------------------------------
-
151 | macros
-
152 +---------------------------------------------------------------------*/
-
153 #if defined(NPT_CONFIG_ENABLE_LOGGING)
-
154 #define PLT_LOG_HTTP_REQUEST_L(_logger, _level, _prefix, _request) \
-
155 do { \
-
156  if (!_request) break; \
-
157  NPT_LOG_GET_LOGGER((_logger)) \
-
158  if ((_logger).logger && (_level) >= (_logger).logger->GetLevel()) { \
-
159  NPT_StringOutputStreamReference stream(new NPT_StringOutputStream); \
-
160  NPT_OutputStreamReference output = stream; \
-
161  _request->GetHeaders().GetHeaders().Apply(NPT_HttpHeaderPrinter(output)); \
-
162  NPT_LOG_X((_logger),(_level),((_level),__FILE__,__LINE__,(NPT_LocalFunctionName),"%s\n%s %s %s\n%s", (const char*)_prefix, (const char*)_request->GetMethod(), (const char*)_request->GetUrl().ToRequestString(true), (const char*)_request->GetProtocol(), (const char*)stream->GetString())); \
-
163  } \
-
164 } while (0)
-
165 
-
166 #define PLT_LOG_HTTP_RESPONSE_L(_logger, _level, _prefix, _response) \
-
167 do { \
-
168  if (!_response) break; \
-
169  NPT_LOG_GET_LOGGER((_logger)) \
-
170  if ((_logger).logger && (_level) >= (_logger).logger->GetLevel()) { \
-
171  NPT_StringOutputStreamReference stream(new NPT_StringOutputStream); \
-
172  NPT_OutputStreamReference output = stream; \
-
173  _response->GetHeaders().GetHeaders().Apply(NPT_HttpHeaderPrinter(output)); \
-
174  NPT_LOG_X((_logger),(_level),((_level),__FILE__,__LINE__,(NPT_LocalFunctionName),"%s\n%s %d %s\n%s", (const char*)_prefix, (const char*)_response->GetProtocol(), _response->GetStatusCode(), (const char*)_response->GetReasonPhrase(), (const char*)stream->GetString())); \
-
175  } \
-
176 } while (0)
-
177 
-
178 #define PLT_LOG_HTTP_REQUEST(_level,_prefix,_request) PLT_LOG_HTTP_REQUEST_L(_NPT_LocalLogger,(_level),(_prefix),(_request))
-
179 
-
180 #define PLT_LOG_HTTP_RESPONSE(_level,_prefix,_response) PLT_LOG_HTTP_RESPONSE_L(_NPT_LocalLogger,(_level),(_prefix),(_response))
-
181 
-
182 #else /* NPT_CONFIG_ENABLE_LOGGING */
-
183 #define PLT_LOG_HTTP_MESSAGE_L(_logger, _level, _prefix, _msg)
-
184 #define PLT_LOG_HTTP_MESSAGE(_level, _prefix, _msg)
-
185 #endif /* NPT_CONFIG_ENABLE_LOGGING */
-
186 
-
187 /*----------------------------------------------------------------------
-
188 | PLT_HttpRequestHandler
-
189 +---------------------------------------------------------------------*/
-
194 class PLT_HttpRequestHandler : public NPT_HttpRequestHandler
-
195 {
-
196 public:
-
197  PLT_HttpRequestHandler(NPT_HttpRequestHandler* delegate) :
-
198  m_Delegate(delegate) {}
-
199  virtual ~PLT_HttpRequestHandler() {}
-
200 
-
201  // NPT_HttpRequestHandler methods
-
202  NPT_Result SetupResponse(NPT_HttpRequest& request,
-
203  const NPT_HttpRequestContext& context,
-
204  NPT_HttpResponse& response) {
-
205  return m_Delegate->SetupResponse(request, context, response);
-
206  }
-
207 
-
208 private:
-
209  NPT_HttpRequestHandler* m_Delegate;
-
210 };
-
211 
-
212 #endif /* _PLT_HTTP_H_ */
+
98  static NPT_Result GetBody(const NPT_HttpMessage& message, NPT_OutputStreamReference output_stream);
+
99  static NPT_Result ParseBody(const NPT_HttpMessage& message, NPT_XmlElementNode*& xml);
+
100 
+
101  static void SetBasicAuthorization(NPT_HttpRequest& request, const char* username, const char* password);
+
102 };
+
103 
+
104 /*----------------------------------------------------------------------
+
105 | PLT_HttpRequestContext
+
106 +---------------------------------------------------------------------*/
+
112 class PLT_HttpRequestContext : public NPT_HttpRequestContext {
+
113 public:
+
114  // constructors and destructor
+
115  PLT_HttpRequestContext(const NPT_HttpRequest& request) :
+
116  m_Request(request) {}
+
117  PLT_HttpRequestContext(const NPT_HttpRequest& request, const NPT_HttpRequestContext& context) :
+
118  NPT_HttpRequestContext(&context.GetLocalAddress(), &context.GetRemoteAddress()),
+
119  m_Request(request) {}
+
120  virtual ~PLT_HttpRequestContext() {}
+
121 
+
122  const NPT_HttpRequest& GetRequest() const { return m_Request; }
+
123  PLT_DeviceSignature GetDeviceSignature() { return PLT_HttpHelper::GetDeviceSignature(m_Request); }
+
124 
+
125 private:
+
126  const NPT_HttpRequest& m_Request;
+
127 };
+
128 
+
129 /*----------------------------------------------------------------------
+
130 | NPT_HttpHeaderPrinter
+
131 +---------------------------------------------------------------------*/
+
132 class NPT_HttpHeaderPrinter
+
133 {
+
134 public:
+
135  // methods
+
136  NPT_HttpHeaderPrinter(NPT_OutputStreamReference& stream) :
+
137  m_Stream(stream) {}
+
138  NPT_Result operator()(NPT_HttpHeader*& header) const {
+
139  m_Stream->WriteString(header->GetName());
+
140  m_Stream->Write(": ", 2);
+
141  m_Stream->WriteString(header->GetValue());
+
142  m_Stream->Write("\r\n", 2, NULL);
+
143  return NPT_SUCCESS;
+
144  }
+
145 
+
146 private:
+
147  // members
+
148  NPT_OutputStreamReference& m_Stream;
+
149 };
+
150 
+
151 /*----------------------------------------------------------------------
+
152 | macros
+
153 +---------------------------------------------------------------------*/
+
154 #if defined(NPT_CONFIG_ENABLE_LOGGING)
+
155 #define PLT_LOG_HTTP_REQUEST_L(_logger, _level, _prefix, _request) \
+
156 do { \
+
157  if (!_request) break; \
+
158  NPT_LOG_GET_LOGGER((_logger)) \
+
159  if ((_logger).logger && (_level) >= (_logger).logger->GetLevel()) { \
+
160  NPT_StringOutputStreamReference stream(new NPT_StringOutputStream); \
+
161  NPT_OutputStreamReference output = stream; \
+
162  _request->GetHeaders().GetHeaders().Apply(NPT_HttpHeaderPrinter(output)); \
+
163  NPT_LOG_X((_logger),(_level),((_level),__FILE__,__LINE__,(NPT_LocalFunctionName),"%s\n%s %s %s\n%s", (const char*)_prefix, (const char*)_request->GetMethod(), (const char*)_request->GetUrl().ToRequestString(true), (const char*)_request->GetProtocol(), (const char*)stream->GetString())); \
+
164  } \
+
165 } while (0)
+
166 
+
167 #define PLT_LOG_HTTP_RESPONSE_L(_logger, _level, _prefix, _response) \
+
168 do { \
+
169  if (!_response) break; \
+
170  NPT_LOG_GET_LOGGER((_logger)) \
+
171  if ((_logger).logger && (_level) >= (_logger).logger->GetLevel()) { \
+
172  NPT_StringOutputStreamReference stream(new NPT_StringOutputStream); \
+
173  NPT_OutputStreamReference output = stream; \
+
174  _response->GetHeaders().GetHeaders().Apply(NPT_HttpHeaderPrinter(output)); \
+
175  NPT_LOG_X((_logger),(_level),((_level),__FILE__,__LINE__,(NPT_LocalFunctionName),"%s\n%s %d %s\n%s", (const char*)_prefix, (const char*)_response->GetProtocol(), _response->GetStatusCode(), (const char*)_response->GetReasonPhrase(), (const char*)stream->GetString())); \
+
176  } \
+
177 } while (0)
+
178 
+
179 #define PLT_LOG_HTTP_REQUEST(_level,_prefix,_request) PLT_LOG_HTTP_REQUEST_L(_NPT_LocalLogger,(_level),(_prefix),(_request))
+
180 
+
181 #define PLT_LOG_HTTP_RESPONSE(_level,_prefix,_response) PLT_LOG_HTTP_RESPONSE_L(_NPT_LocalLogger,(_level),(_prefix),(_response))
+
182 
+
183 #else /* NPT_CONFIG_ENABLE_LOGGING */
+
184 #define PLT_LOG_HTTP_MESSAGE_L(_logger, _level, _prefix, _msg)
+
185 #define PLT_LOG_HTTP_MESSAGE(_level, _prefix, _msg)
+
186 #endif /* NPT_CONFIG_ENABLE_LOGGING */
+
187 
+
188 /*----------------------------------------------------------------------
+
189 | PLT_HttpRequestHandler
+
190 +---------------------------------------------------------------------*/
+
195 class PLT_HttpRequestHandler : public NPT_HttpRequestHandler
+
196 {
+
197 public:
+
198  PLT_HttpRequestHandler(NPT_HttpRequestHandler* delegate) :
+
199  m_Delegate(delegate) {}
+
200  virtual ~PLT_HttpRequestHandler() {}
+
201 
+
202  // NPT_HttpRequestHandler methods
+
203  NPT_Result SetupResponse(NPT_HttpRequest& request,
+
204  const NPT_HttpRequestContext& context,
+
205  NPT_HttpResponse& response) {
+
206  return m_Delegate->SetupResponse(request, context, response);
+
207  }
+
208 
+
209 private:
+
210  NPT_HttpRequestHandler* m_Delegate;
+
211 };
+
212 
+
213 #endif /* _PLT_HTTP_H_ */
PLT_HttpHelper
The PLT_HttpHelper class is a set of utility functions for manipulating HTTP headers, entities and messages.
Definition: PltHttp.h:81
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
-
PLT_HttpRequestHandler
The PLT_HttpRequestHandler class delegates the handling of the response of a received HTTP request by...
Definition: PltHttp.h:194
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
+
PLT_HttpRequestHandler
The PLT_HttpRequestHandler class delegates the handling of the response of a received HTTP request by...
Definition: PltHttp.h:195
diff --git a/Docs/Doxygen/html/PltMediaConnect_8h_source.html b/Docs/Doxygen/html/PltMediaConnect_8h_source.html index 03ea6280..aa765549 100644 --- a/Docs/Doxygen/html/PltMediaConnect_8h_source.html +++ b/Docs/Doxygen/html/PltMediaConnect_8h_source.html @@ -166,7 +166,7 @@
PLT_Service
UPnP Service.
Definition: PltService.h:67
PLT_MediaServer::SetupServices
virtual NPT_Result SetupServices()
Required method for setting up UPnP services of device host (and any embedded).
PLT_MediaServer::OnAction
virtual NPT_Result OnAction(PLT_ActionReference &action, const PLT_HttpRequestContext &context)
This mehod is called when an action performed by a control point has been received and needs to be an...
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
PLT_DeviceHost::ProcessGetDescription
virtual NPT_Result ProcessGetDescription(NPT_HttpRequest &request, const NPT_HttpRequestContext &context, NPT_HttpResponse &response)
This method is called when a control point is requesting the device description.
diff --git a/Docs/Doxygen/html/PltMediaItem_8h_source.html b/Docs/Doxygen/html/PltMediaItem_8h_source.html index 74ff7a10..d7aa6ee1 100644 --- a/Docs/Doxygen/html/PltMediaItem_8h_source.html +++ b/Docs/Doxygen/html/PltMediaItem_8h_source.html @@ -333,7 +333,7 @@
PLT_MediaItem
The PLT_MediaItem class represents a first-level class derived directly from PLT_MediaObject.
Definition: PltMediaItem.h:238
PLT_MediaObjectList
The PLT_MediaObjectList class is a list of PLT_MediaObject instances.
Definition: PltMediaItem.h:291
PLT_MediaContainer
The PLT_MediaContainer class represents a first-level class derived directly from PLT_MediaObject...
Definition: PltMediaItem.h:260
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
PLT_ObjectClass
The PLT_ObjectClass struct is used to assign a type to a PLT_MediaObject.
Definition: PltMediaItem.h:55
PLT_MediaObject
The PLT_MediaObject class is any data entity that can be returned by a ContentDirectory Service from ...
Definition: PltMediaItem.h:179
PltProtocolInfo.h
UPnP AV Media Object Protocol Info.
diff --git a/Docs/Doxygen/html/PltMediaRenderer_8h_source.html b/Docs/Doxygen/html/PltMediaRenderer_8h_source.html index b1a02204..4a4e7298 100644 --- a/Docs/Doxygen/html/PltMediaRenderer_8h_source.html +++ b/Docs/Doxygen/html/PltMediaRenderer_8h_source.html @@ -170,7 +170,7 @@
PLT_DeviceHost::OnAction
virtual NPT_Result OnAction(PLT_ActionReference &action, const PLT_HttpRequestContext &context)
This mehod is called when an action performed by a control point has been received and needs to be an...
PLT_DeviceHost
UPnP Device Host.
Definition: PltDeviceHost.h:69
PltDeviceHost.h
UPnP Device.
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
diff --git a/Docs/Doxygen/html/PltMediaServer_8h_source.html b/Docs/Doxygen/html/PltMediaServer_8h_source.html index 747db758..b8777575 100644 --- a/Docs/Doxygen/html/PltMediaServer_8h_source.html +++ b/Docs/Doxygen/html/PltMediaServer_8h_source.html @@ -231,7 +231,7 @@
PLT_MediaServer::SetupServices
virtual NPT_Result SetupServices()
Required method for setting up UPnP services of device host (and any embedded).
PltDeviceHost.h
UPnP Device.
PLT_MediaServer::OnAction
virtual NPT_Result OnAction(PLT_ActionReference &action, const PLT_HttpRequestContext &context)
This mehod is called when an action performed by a control point has been received and needs to be an...
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
diff --git a/Docs/Doxygen/html/PltMimeType_8h_source.html b/Docs/Doxygen/html/PltMimeType_8h_source.html index 759354a3..a51f864e 100644 --- a/Docs/Doxygen/html/PltMimeType_8h_source.html +++ b/Docs/Doxygen/html/PltMimeType_8h_source.html @@ -120,7 +120,7 @@
73 };
74 
75 #endif /* _PLT_MIMETYPE_H_ */
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
PltHttp.h
HTTP utilities.
diff --git a/Docs/Doxygen/html/PltProtocolInfo_8h_source.html b/Docs/Doxygen/html/PltProtocolInfo_8h_source.html index fbf8d138..f4d10193 100644 --- a/Docs/Doxygen/html/PltProtocolInfo_8h_source.html +++ b/Docs/Doxygen/html/PltProtocolInfo_8h_source.html @@ -200,7 +200,7 @@
157 
158 #endif /* _PLT_PROTOCOL_INFO_H_ */
PLT_ProtocolInfo
The PLT_ProtocolInfo class holds information about the protocol info of a given UPnP Media Item resou...
Definition: PltProtocolInfo.h:68
-
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:111
+
PLT_HttpRequestContext
The PLT_HttpRequestContext class holds information about the request sent, the local & remote ip addr...
Definition: PltHttp.h:112
PltHttp.h
HTTP utilities.
diff --git a/Docs/Doxygen/html/PltService_8h_source.html b/Docs/Doxygen/html/PltService_8h_source.html index 81534db2..2d93f24f 100644 --- a/Docs/Doxygen/html/PltService_8h_source.html +++ b/Docs/Doxygen/html/PltService_8h_source.html @@ -199,179 +199,181 @@
302 
303  // methods
304  void Cleanup();
-
305 
-
311  NPT_Result AddChanged(PLT_StateVariable* var);
-
312 
-
319  NPT_Result UpdateLastChange(NPT_List<PLT_StateVariable*>& vars);
-
320 
-
324  NPT_Result NotifyChanged();
-
325 
-
326  // Events
-
330  NPT_Result ProcessNewSubscription(
-
331  PLT_TaskManagerReference task_manager,
-
332  const NPT_SocketAddress& addr,
-
333  const NPT_String& callback_urls,
-
334  int timeout,
-
335  NPT_HttpResponse& response);
-
336 
-
341  NPT_Result ProcessRenewSubscription(
-
342  const NPT_SocketAddress& addr,
-
343  const NPT_String& sid,
-
344  int timeout,
-
345  NPT_HttpResponse& response);
-
346 
-
351  NPT_Result ProcessCancelSubscription(
-
352  const NPT_SocketAddress& addr,
-
353  const NPT_String& sid,
-
354  NPT_HttpResponse& response);
-
355 
-
356 
-
357 protected:
-
358  // friends that need to call private functions
-
359  friend class PLT_StateVariable; // AddChanged
-
360  friend class PLT_DeviceHost; // ProcessXXSubscription
-
361 
-
362  //members
-
363  PLT_DeviceData* m_Device;
-
364  NPT_String m_ServiceType;
-
365  NPT_String m_ServiceID;
-
366  NPT_String m_ServiceName;
-
367  NPT_String m_SCPDURL;
-
368  NPT_String m_ControlURL;
-
369  NPT_String m_EventSubURL;
-
370  PLT_ServiceEventTask* m_EventTask;
-
371  NPT_Array<PLT_ActionDesc*> m_ActionDescs;
-
372  NPT_List<PLT_StateVariable*> m_StateVars;
-
373  NPT_Mutex m_Lock;
-
374  NPT_List<PLT_StateVariable*> m_StateVarsChanged;
-
375  NPT_List<PLT_StateVariable*> m_StateVarsToPublish;
-
376  NPT_List<PLT_EventSubscriberReference> m_Subscribers;
-
377  bool m_EventingPaused;
-
378  NPT_String m_LastChangeNamespace;
-
379 };
-
380 
-
381 /*----------------------------------------------------------------------
-
382 | PLT_ServiceSCPDURLFinder
-
383 +---------------------------------------------------------------------*/
-
388 class PLT_ServiceSCPDURLFinder
-
389 {
-
390 public:
-
391  // methods
-
392  PLT_ServiceSCPDURLFinder(const char* url) : m_URL(url) {}
-
393  virtual ~PLT_ServiceSCPDURLFinder() {}
-
394  bool operator()(PLT_Service* const & service) const;
-
395 
-
396 private:
-
397  // members
-
398  NPT_String m_URL;
-
399 };
+
305 
+
309  void PurgeSubscribers();
+
310 
+
316  NPT_Result AddChanged(PLT_StateVariable* var);
+
317 
+
324  NPT_Result UpdateLastChange(NPT_List<PLT_StateVariable*>& vars);
+
325 
+
329  NPT_Result NotifyChanged();
+
330 
+
331  // Events
+
335  NPT_Result ProcessNewSubscription(
+
336  PLT_TaskManagerReference task_manager,
+
337  const NPT_SocketAddress& addr,
+
338  const NPT_String& callback_urls,
+
339  int timeout,
+
340  NPT_HttpResponse& response);
+
341 
+
346  NPT_Result ProcessRenewSubscription(
+
347  const NPT_SocketAddress& addr,
+
348  const NPT_String& sid,
+
349  int timeout,
+
350  NPT_HttpResponse& response);
+
351 
+
356  NPT_Result ProcessCancelSubscription(
+
357  const NPT_SocketAddress& addr,
+
358  const NPT_String& sid,
+
359  NPT_HttpResponse& response);
+
360 
+
361 
+
362 protected:
+
363  // friends that need to call private functions
+
364  friend class PLT_StateVariable; // AddChanged
+
365  friend class PLT_DeviceHost; // ProcessXXSubscription
+
366 
+
367  //members
+
368  PLT_DeviceData* m_Device;
+
369  NPT_String m_ServiceType;
+
370  NPT_String m_ServiceID;
+
371  NPT_String m_ServiceName;
+
372  NPT_String m_SCPDURL;
+
373  NPT_String m_ControlURL;
+
374  NPT_String m_EventSubURL;
+
375  PLT_ServiceEventTask* m_EventTask;
+
376  NPT_Array<PLT_ActionDesc*> m_ActionDescs;
+
377  NPT_List<PLT_StateVariable*> m_StateVars;
+
378  NPT_Mutex m_Lock;
+
379  NPT_List<PLT_StateVariable*> m_StateVarsChanged;
+
380  NPT_List<PLT_StateVariable*> m_StateVarsToPublish;
+
381  NPT_List<PLT_EventSubscriberReference> m_Subscribers;
+
382  bool m_EventingPaused;
+
383  NPT_String m_LastChangeNamespace;
+
384 };
+
385 
+
386 /*----------------------------------------------------------------------
+
387 | PLT_ServiceSCPDURLFinder
+
388 +---------------------------------------------------------------------*/
+
393 class PLT_ServiceSCPDURLFinder
+
394 {
+
395 public:
+
396  // methods
+
397  PLT_ServiceSCPDURLFinder(const char* url) : m_URL(url) {}
+
398  virtual ~PLT_ServiceSCPDURLFinder() {}
+
399  bool operator()(PLT_Service* const & service) const;
400 
-
401 /*----------------------------------------------------------------------
-
402 | PLT_ServiceControlURLFinder
-
403 +---------------------------------------------------------------------*/
-
408 class PLT_ServiceControlURLFinder
-
409 {
-
410 public:
-
411  // methods
-
412  PLT_ServiceControlURLFinder(const char* url) : m_URL(url) {}
-
413  virtual ~PLT_ServiceControlURLFinder() {}
-
414  bool operator()(PLT_Service* const & service) const;
-
415 
-
416 private:
-
417  // members
-
418  NPT_String m_URL;
-
419 };
+
401 private:
+
402  // members
+
403  NPT_String m_URL;
+
404 };
+
405 
+
406 /*----------------------------------------------------------------------
+
407 | PLT_ServiceControlURLFinder
+
408 +---------------------------------------------------------------------*/
+
413 class PLT_ServiceControlURLFinder
+
414 {
+
415 public:
+
416  // methods
+
417  PLT_ServiceControlURLFinder(const char* url) : m_URL(url) {}
+
418  virtual ~PLT_ServiceControlURLFinder() {}
+
419  bool operator()(PLT_Service* const & service) const;
420 
-
421 /*----------------------------------------------------------------------
-
422 | PLT_ServiceEventSubURLFinder
-
423 +---------------------------------------------------------------------*/
-
428 class PLT_ServiceEventSubURLFinder
-
429 {
-
430 public:
-
431  // methods
-
432  PLT_ServiceEventSubURLFinder(const char* url) : m_URL(url) {}
-
433  virtual ~PLT_ServiceEventSubURLFinder() {}
-
434  bool operator()(PLT_Service* const & service) const;
-
435 
-
436 private:
-
437  // members
-
438  NPT_String m_URL;
-
439 };
+
421 private:
+
422  // members
+
423  NPT_String m_URL;
+
424 };
+
425 
+
426 /*----------------------------------------------------------------------
+
427 | PLT_ServiceEventSubURLFinder
+
428 +---------------------------------------------------------------------*/
+
433 class PLT_ServiceEventSubURLFinder
+
434 {
+
435 public:
+
436  // methods
+
437  PLT_ServiceEventSubURLFinder(const char* url) : m_URL(url) {}
+
438  virtual ~PLT_ServiceEventSubURLFinder() {}
+
439  bool operator()(PLT_Service* const & service) const;
440 
-
441 /*----------------------------------------------------------------------
-
442 | PLT_ServiceIDFinder
-
443 +---------------------------------------------------------------------*/
-
448 class PLT_ServiceIDFinder
-
449 {
-
450 public:
-
451  // methods
-
452  PLT_ServiceIDFinder(const char* id) : m_Id(id) {}
-
453  virtual ~PLT_ServiceIDFinder() {}
-
454  bool operator()(PLT_Service* const & service) const;
-
455 
-
456 private:
-
457  // members
-
458  NPT_String m_Id;
-
459 };
+
441 private:
+
442  // members
+
443  NPT_String m_URL;
+
444 };
+
445 
+
446 /*----------------------------------------------------------------------
+
447 | PLT_ServiceIDFinder
+
448 +---------------------------------------------------------------------*/
+
453 class PLT_ServiceIDFinder
+
454 {
+
455 public:
+
456  // methods
+
457  PLT_ServiceIDFinder(const char* id) : m_Id(id) {}
+
458  virtual ~PLT_ServiceIDFinder() {}
+
459  bool operator()(PLT_Service* const & service) const;
460 
-
461 /*----------------------------------------------------------------------
-
462 | PLT_ServiceTypeFinder
-
463 +---------------------------------------------------------------------*/
-
468 class PLT_ServiceTypeFinder
-
469 {
-
470 public:
-
471  // methods
-
472  PLT_ServiceTypeFinder(const char* type) : m_Type(type) {}
-
473  virtual ~PLT_ServiceTypeFinder() {}
-
474  bool operator()(PLT_Service* const & service) const;
-
475 
-
476 private:
-
477  // members
-
478  NPT_String m_Type;
-
479 };
+
461 private:
+
462  // members
+
463  NPT_String m_Id;
+
464 };
+
465 
+
466 /*----------------------------------------------------------------------
+
467 | PLT_ServiceTypeFinder
+
468 +---------------------------------------------------------------------*/
+
473 class PLT_ServiceTypeFinder
+
474 {
+
475 public:
+
476  // methods
+
477  PLT_ServiceTypeFinder(const char* type) : m_Type(type) {}
+
478  virtual ~PLT_ServiceTypeFinder() {}
+
479  bool operator()(PLT_Service* const & service) const;
480 
-
481 /*----------------------------------------------------------------------
-
482 | PLT_ServiceNameFinder
-
483 +---------------------------------------------------------------------*/
-
488 class PLT_ServiceNameFinder
-
489 {
-
490 public:
-
491  // methods
-
492  PLT_ServiceNameFinder(const char* name) : m_Name(name) {}
-
493  virtual ~PLT_ServiceNameFinder() {}
-
494  bool operator()(PLT_Service* const & service) const;
-
495 
-
496 private:
-
497  // members
-
498  NPT_String m_Name;
-
499 };
+
481 private:
+
482  // members
+
483  NPT_String m_Type;
+
484 };
+
485 
+
486 /*----------------------------------------------------------------------
+
487 | PLT_ServiceNameFinder
+
488 +---------------------------------------------------------------------*/
+
493 class PLT_ServiceNameFinder
+
494 {
+
495 public:
+
496  // methods
+
497  PLT_ServiceNameFinder(const char* name) : m_Name(name) {}
+
498  virtual ~PLT_ServiceNameFinder() {}
+
499  bool operator()(PLT_Service* const & service) const;
500 
-
501 /*----------------------------------------------------------------------
-
502 | PLT_LastChangeXMLIterator
-
503 +---------------------------------------------------------------------*/
-
508 class PLT_LastChangeXMLIterator
-
509 {
-
510 public:
-
511  // methods
-
512  PLT_LastChangeXMLIterator(NPT_XmlElementNode* node) : m_Node(node) {}
-
513  virtual ~PLT_LastChangeXMLIterator() {}
-
514 
-
515  NPT_Result operator()(PLT_StateVariable* const & var) const;
-
516 
-
517 private:
-
518  NPT_XmlElementNode* m_Node;
-
519 };
-
520 
-
521 #endif /* _PLT_SERVICE_H_ */
+
501 private:
+
502  // members
+
503  NPT_String m_Name;
+
504 };
+
505 
+
506 /*----------------------------------------------------------------------
+
507 | PLT_LastChangeXMLIterator
+
508 +---------------------------------------------------------------------*/
+
513 class PLT_LastChangeXMLIterator
+
514 {
+
515 public:
+
516  // methods
+
517  PLT_LastChangeXMLIterator(NPT_XmlElementNode* node) : m_Node(node) {}
+
518  virtual ~PLT_LastChangeXMLIterator() {}
+
519 
+
520  NPT_Result operator()(PLT_StateVariable* const & var) const;
+
521 
+
522 private:
+
523  NPT_XmlElementNode* m_Node;
+
524 };
+
525 
+
526 #endif /* _PLT_SERVICE_H_ */
PLT_Service::GetSCPDXML
NPT_Result GetSCPDXML(NPT_String &xml)
Return the service SCPD xml document.
PLT_Service::FindActionDesc
PLT_ActionDesc * FindActionDesc(const char *name)
Return the PLT_ActionDesc given an action name.
PLT_Service::InitURLs
NPT_Result InitURLs(const char *service_name)
When service is hosted by a PLT_DeviceHost, this setups the SCPD, control and event urls...
PltStateVariable.h
UPnP State Variable.
PLT_Service::GetServiceType
const NPT_String & GetServiceType() const
Return the service type.
Definition: PltService.h:171
-
PLT_LastChangeXMLIterator
The PLT_LastChangeXMLIterator class is used to serialize the LastChange variable changes into xml giv...
Definition: PltService.h:508
+
PLT_LastChangeXMLIterator
The PLT_LastChangeXMLIterator class is used to serialize the LastChange variable changes into xml giv...
Definition: PltService.h:513
PLT_ActionDesc
The PLT_ActionDesc class provides information about a UPnP Service given action.
Definition: PltAction.h:61
PltArgument.h
UPnP Service Action Argument.
-
PLT_ServiceIDFinder
The PLT_ServiceIDFinder class returns an instance of a PLT_Service given a service id...
Definition: PltService.h:448
+
PLT_ServiceIDFinder
The PLT_ServiceIDFinder class returns an instance of a PLT_Service given a service id...
Definition: PltService.h:453
PLT_Service::ForceVersion
NPT_Result ForceVersion(NPT_Cardinal version)
When a control point discover a new service with a higher version number than it can work with...
PLT_Service
UPnP Service.
Definition: PltService.h:67
PLT_Service::SetSCPDXML
NPT_Result SetSCPDXML(const char *xml)
Set the service SCPD xml document.
@@ -384,22 +386,22 @@
PltEvent.h
UPnP Eventing.
PLT_Service::SetStateVariable
NPT_Result SetStateVariable(const char *name, const char *value)
Set a new value for a given state variable.
PLT_Service::GetEventSubURL
NPT_String GetEventSubURL(bool absolute=false)
Return the Event subscription url associated with this service.
-
PLT_ServiceNameFinder
The PLT_ServiceNameFinder class returns an instance of a PLT_Service given a service name...
Definition: PltService.h:488
+
PLT_ServiceNameFinder
The PLT_ServiceNameFinder class returns an instance of a PLT_Service given a service name...
Definition: PltService.h:493
PLT_Service::IsSubscribable
bool IsSubscribable()
Return whether a service is capable of sending events.
PLT_Service::GetStateVariables
const NPT_List< PLT_StateVariable * > & GetStateVariables() const
Return the list of state variables.
Definition: PltService.h:269
PLT_Service::GetServiceName
const NPT_String & GetServiceName() const
Return the service friendly name.
Definition: PltService.h:177
PltAction.h
UPnP Service Action.
PLT_DeviceData
The PLT_DeviceData class holds information about a device being advertised or found by a control poin...
Definition: PltDeviceData.h:93
-
PLT_ServiceEventSubURLFinder
The PLT_ServiceEventSubURLFinder class returns an instance of a PLT_Service given a service event sub...
Definition: PltService.h:428
+
PLT_ServiceEventSubURLFinder
The PLT_ServiceEventSubURLFinder class returns an instance of a PLT_Service given a service event sub...
Definition: PltService.h:433
PLT_DeviceHost
UPnP Device Host.
Definition: PltDeviceHost.h:69
-
PLT_ServiceSCPDURLFinder
The PLT_ServiceSCPDURLFinder class returns an instance of a PLT_Service given a service SCPD url...
Definition: PltService.h:388
+
PLT_ServiceSCPDURLFinder
The PLT_ServiceSCPDURLFinder class returns an instance of a PLT_Service given a service SCPD url...
Definition: PltService.h:393
PLT_Service::GetActionDescs
const NPT_Array< PLT_ActionDesc * > & GetActionDescs() const
Return an array of actions descriptions PLT_ActionDesc.
Definition: PltService.h:282
PLT_Service::GetDescription
NPT_Result GetDescription(NPT_XmlElementNode *parent, NPT_XmlElementNode **service=NULL)
Populate the UPnP Device description document with service information.
PLT_Service::FindStateVariable
PLT_StateVariable * FindStateVariable(const char *name)
Return the PLT_StateVariable pointer given a state variable name.
-
PLT_ServiceTypeFinder
The PLT_ServiceTypeFinder class returns an instance of a PLT_Service given a service type...
Definition: PltService.h:468
+
PLT_ServiceTypeFinder
The PLT_ServiceTypeFinder class returns an instance of a PLT_Service given a service type...
Definition: PltService.h:473
PLT_Service::PLT_Service
PLT_Service(PLT_DeviceData *device, const char *type, const char *id, const char *name, const char *last_change_namespace=NULL)
Create an instance of a UPnP Service either hosted or discovered.
PLT_Service::GetSCPDURL
NPT_String GetSCPDURL(bool absolute=false)
Return the SCPD url associated with this service.
-
PLT_ServiceControlURLFinder
The PLT_ServiceControlURLFinder class returns an instance of a PLT_Service given a service control ur...
Definition: PltService.h:408
+
PLT_ServiceControlURLFinder
The PLT_ServiceControlURLFinder class returns an instance of a PLT_Service given a service control ur...
Definition: PltService.h:413
PLT_Service::GetServiceID
const NPT_String & GetServiceID() const
Return the service id.
Definition: PltService.h:165
PLT_ThreadTask
The PLT_ThreadTask class is a base class for executing a given task in a worker thread.
Definition: PltThreadTask.h:56
PLT_Service::GetControlURL
NPT_String GetControlURL(bool absolute=false)
Return the Control url associated with this service.
diff --git a/Docs/Doxygen/html/PltStateVariable_8h_source.html b/Docs/Doxygen/html/PltStateVariable_8h_source.html index c778624e..e595cdbb 100644 --- a/Docs/Doxygen/html/PltStateVariable_8h_source.html +++ b/Docs/Doxygen/html/PltStateVariable_8h_source.html @@ -190,7 +190,7 @@
PLT_StateVariable::GetAllowedValueRange
const NPT_AllowedValueRange * GetAllowedValueRange() const
Return the state variable allowed value range if any.
Definition: PltStateVariable.h:156
PLT_Argument
The PLT_Argument class provides a mechanism to set or verify the validity of a specific UPNP service ...
Definition: PltArgument.h:99
PLT_StateVariable::IsReadyToPublish
bool IsReadyToPublish()
Return whether the state variable value changed and subscribers need to be notified.
-
PLT_LastChangeXMLIterator
The PLT_LastChangeXMLIterator class is used to serialize the LastChange variable changes into xml giv...
Definition: PltService.h:508
+
PLT_LastChangeXMLIterator
The PLT_LastChangeXMLIterator class is used to serialize the LastChange variable changes into xml giv...
Definition: PltService.h:513
PLT_StateVariable::GetName
const NPT_String & GetName() const
Return the state variable name.
Definition: PltStateVariable.h:138
PLT_Service
UPnP Service.
Definition: PltService.h:67
PLT_StateVariableNameFinder
The PLT_StateVariableNameFinder class returns the PLT_StateVariable instance given a state variable n...
Definition: PltStateVariable.h:207
diff --git a/Source/Core/PltEvent.cpp b/Source/Core/PltEvent.cpp index 7bc699ba..5088ab75 100644 --- a/Source/Core/PltEvent.cpp +++ b/Source/Core/PltEvent.cpp @@ -42,6 +42,7 @@ #include "PltDeviceData.h" #include "PltUtilities.h" #include "PltCtrlPointTask.h" +#include "PltHttp.h" NPT_SET_LOCAL_LOGGER("platinum.core.event") @@ -177,7 +178,6 @@ PLT_EventSubscriber::SetLocalIf(NPT_SocketAddress value) /*---------------------------------------------------------------------- | PLT_EventSubscriber::GetExpirationTime +---------------------------------------------------------------------*/ -// a TimeStamp of 0 means no expiration NPT_TimeStamp PLT_EventSubscriber::GetExpirationTime() { @@ -292,10 +292,10 @@ PLT_EventSubscriber::Notify(NPT_List& vars) // start the task now if not started already if (!m_SubscriberTask) { - // TODO: the subscriber task should inform subscriber if + // The subscriber task should inform subscriber if // a notification failed to be received so it can be removed // from the list of subscribers inside the device host - NPT_Reference task(new PLT_HttpClientSocketTask(request, true)); + NPT_Reference task(new PLT_HttpClientTask(this, true)); // short connection time out in case subscriber is not alive NPT_HttpClient::Config config; @@ -311,11 +311,34 @@ PLT_EventSubscriber::Notify(NPT_List& vars) // Task successfully started, keep around for future notifications m_SubscriberTask = task.AsPointer(); task.Detach(); - } else { - m_SubscriberTask->AddRequest(request); } - - return NPT_SUCCESS; + + return m_SubscriberTask->AddRequest(request); +} + +/*---------------------------------------------------------------------- +| PLT_EventSubscriberFinderByService::operator() ++---------------------------------------------------------------------*/ +NPT_Result +PLT_EventSubscriber::ProcessResponse(NPT_Result res, + const NPT_HttpRequest& request, + const NPT_HttpRequestContext& context, + NPT_HttpResponse* response) +{ + NPT_COMPILER_UNUSED(request); + NPT_COMPILER_UNUSED(context); + + NPT_NullOutputStreamReference output; + if (NPT_FAILED(res) || NPT_FAILED(PLT_HttpHelper::GetBody(*response, output))) { + NPT_LOG_WARNING_1("Notification failed for subscriber: %s", GetSID().GetChars()); + + // Force expiration time to be far in the past so this subscriber + // gets purged next time a notification needs to be sent + m_ExpirationTime = 0.; + return NPT_FAILURE; + } + + return NPT_SUCCESS; } /*---------------------------------------------------------------------- diff --git a/Source/Core/PltEvent.h b/Source/Core/PltEvent.h index de754bbf..ad0ce191 100644 --- a/Source/Core/PltEvent.h +++ b/Source/Core/PltEvent.h @@ -108,7 +108,13 @@ class PLT_EventSubscriber NPT_Result FindCallbackURL(const char* callback_url); NPT_Result AddCallbackURL(const char* callback_url); NPT_Result Notify(NPT_List& vars); - + + // PLT_HttpClientTask methods + NPT_Result ProcessResponse(NPT_Result res, + const NPT_HttpRequest& request, + const NPT_HttpRequestContext& context, + NPT_HttpResponse* response); + protected: //members PLT_TaskManagerReference m_TaskManager; diff --git a/Source/Core/PltHttp.cpp b/Source/Core/PltHttp.cpp index 41159bed..6c084853 100644 --- a/Source/Core/PltHttp.cpp +++ b/Source/Core/PltHttp.cpp @@ -192,7 +192,17 @@ PLT_HttpHelper::SetBody(NPT_HttpMessage& message, NPT_Result PLT_HttpHelper::GetBody(const NPT_HttpMessage& message, NPT_String& body) { - NPT_Result res; + // extract body + NPT_StringOutputStreamReference output_stream(new NPT_StringOutputStream(&body)); + return PLT_HttpHelper::GetBody(message, output_stream); +} + +/*---------------------------------------------------------------------- +| PLT_HttpHelper::GetBody ++---------------------------------------------------------------------*/ +NPT_Result +PLT_HttpHelper::GetBody(const NPT_HttpMessage& message, NPT_OutputStreamReference output_stream) +{ NPT_InputStreamReference stream; // get stream @@ -204,13 +214,10 @@ PLT_HttpHelper::GetBody(const NPT_HttpMessage& message, NPT_String& body) } // extract body - NPT_StringOutputStream* output_stream = new NPT_StringOutputStream(&body); - res = NPT_StreamToStreamCopy(*stream, - *output_stream, - 0, - entity->GetContentLength()); - delete output_stream; - return res; + return NPT_StreamToStreamCopy(*stream, + *output_stream.AsPointer(), + 0, + entity->GetContentLength()); } /*---------------------------------------------------------------------- diff --git a/Source/Core/PltHttp.h b/Source/Core/PltHttp.h index 84a84d57..e754283d 100644 --- a/Source/Core/PltHttp.h +++ b/Source/Core/PltHttp.h @@ -95,6 +95,7 @@ class PLT_HttpHelper { static NPT_Result SetBody(NPT_HttpMessage& message, const void* body, NPT_LargeSize len, NPT_HttpEntity** entity = NULL); static NPT_Result SetBody(NPT_HttpMessage& message, NPT_InputStreamReference stream, NPT_HttpEntity** entity = NULL); static NPT_Result GetBody(const NPT_HttpMessage& message, NPT_String& body); + static NPT_Result GetBody(const NPT_HttpMessage& message, NPT_OutputStreamReference output_stream); static NPT_Result ParseBody(const NPT_HttpMessage& message, NPT_XmlElementNode*& xml); static void SetBasicAuthorization(NPT_HttpRequest& request, const char* username, const char* password); diff --git a/Source/Core/PltHttpClientTask.cpp b/Source/Core/PltHttpClientTask.cpp index 82c4acd3..2f007758 100644 --- a/Source/Core/PltHttpClientTask.cpp +++ b/Source/Core/PltHttpClientTask.cpp @@ -37,6 +37,7 @@ +---------------------------------------------------------------------*/ #include "PltHttpClientTask.h" #include "PltConstants.h" +#include "PltHttp.h" NPT_SET_LOCAL_LOGGER("platinum.core.http.clienttask") @@ -166,25 +167,10 @@ PLT_HttpClientSocketTask::ProcessResponse(NPT_Result res, NPT_LOG_FINE_1("PLT_HttpClientSocketTask::ProcessResponse (result=%d)", res); NPT_CHECK_WARNING(res); + NPT_CHECK_POINTER_WARNING(response); - NPT_CHECK_POINTER_WARNING(response); - - // check if there's a body to read - NPT_HttpEntity* entity; - NPT_InputStreamReference body; - if (!(entity = response->GetEntity()) || - NPT_FAILED(entity->GetInputStream(body)) || - body.IsNull()) { - return NPT_SUCCESS; - } - - // dump body into ether - // (if no content-length specified, read until disconnected) - NPT_NullOutputStream output; - NPT_CHECK_SEVERE(NPT_StreamToStreamCopy(*body, - output, - 0, - entity->GetContentLength())); + NPT_NullOutputStreamReference output; + NPT_CHECK_SEVERE(PLT_HttpHelper::GetBody(*response, output)); return NPT_SUCCESS; } diff --git a/Source/Core/PltHttpClientTask.h b/Source/Core/PltHttpClientTask.h index 293c5920..31085225 100644 --- a/Source/Core/PltHttpClientTask.h +++ b/Source/Core/PltHttpClientTask.h @@ -97,11 +97,13 @@ template class PLT_HttpClientTask : public PLT_HttpClientSocketTask { public: - PLT_HttpClientTask(const NPT_HttpUrl& url, T* data) : + PLT_HttpClientTask(T* data, bool wait_forever = false) : + PLT_HttpClientSocketTask(NULL, wait_forever), m_Data(data) {} + PLT_HttpClientTask(const NPT_HttpUrl& url, T* data) : PLT_HttpClientSocketTask(new NPT_HttpRequest(url, "GET", NPT_HTTP_PROTOCOL_1_1)), - m_Data(data) {} + m_Data(data) {} protected: virtual ~PLT_HttpClientTask() {} diff --git a/Source/Core/PltService.cpp b/Source/Core/PltService.cpp index b1fec513..3f541f15 100644 --- a/Source/Core/PltService.cpp +++ b/Source/Core/PltService.cpp @@ -84,6 +84,29 @@ PLT_Service::~PLT_Service() m_Subscribers.Clear(); } +/*---------------------------------------------------------------------- +| PLT_Service::PurgeSubscribers ++---------------------------------------------------------------------*/ +void +PLT_Service::PurgeSubscribers() +{ + NPT_List::Iterator sub_iter = m_Subscribers.GetFirstItem(); + while (sub_iter) { + NPT_TimeStamp now, expiration; + NPT_System::GetCurrentTimeStamp(now); + expiration = (*sub_iter)->GetExpirationTime(); + + // forget sub if it didn't renew subscription in time + if (now >= (expiration + NPT_TimeStamp(30.f))) { + NPT_LOG_FINE_1("Removing expired subscriber: %s", (*sub_iter)->GetSID().GetChars()); + m_Subscribers.Erase(sub_iter++); + continue; + } + + ++sub_iter; + } +} + /*---------------------------------------------------------------------- | PLT_Service::GetSCPDXML +---------------------------------------------------------------------*/ @@ -638,7 +661,7 @@ PLT_Service::ProcessRenewSubscription(const NPT_SocketAddress& addr, m_EventSubURL.GetChars(), sid.GetChars()); - // first look if we don't have a subscriber with same callbackURL + // first look that we have a subscriber with corresponding SID PLT_EventSubscriberReference subscriber; if (NPT_SUCCEEDED(NPT_ContainerFind(m_Subscribers, PLT_EventSubscriberFinderBySID(sid), @@ -800,7 +823,7 @@ PLT_Service::NotifyChanged() m_StateVarsToPublish.Erase(iter++); // clear last changed list if we're about to send LastChange var - if (!var->GetName().Compare("LastChange")) m_StateVarsChanged.Clear(); + if (var->GetName().Compare("LastChange") == 0) m_StateVarsChanged.Clear(); continue; } @@ -808,31 +831,26 @@ PLT_Service::NotifyChanged() ++iter; } - // if nothing to publish then bail out now - // we'll clean up expired subscribers when we have something to publish - if (vars_ready.GetItemCount() == 0) return NPT_SUCCESS; - - // send vars that are ready to go and remove old subscribers + // if nothing to publish then bail out now + // we'll clean up expired subscribers when we have something to publish + if (vars_ready.GetItemCount() == 0) return NPT_SUCCESS; + + // purge expired subscribers now + PurgeSubscribers(); + + // send vars that are ready to go NPT_List::Iterator sub_iter = m_Subscribers.GetFirstItem(); while (sub_iter) { - PLT_EventSubscriberReference sub = *sub_iter; - - NPT_TimeStamp now, expiration; - NPT_System::GetCurrentTimeStamp(now); - expiration = sub->GetExpirationTime(); - - // forget sub if it didn't renew subscription in time or if notification failed - if (expiration == NPT_TimeStamp() || now < expiration + NPT_TimeStamp(30.f)) { - // TODO: Notification is asynchronous, so we won't know if it failed until - // the subscriber m_SubscriberTask is done - NPT_Result res = vars_ready.GetItemCount()?sub->Notify(vars_ready):NPT_SUCCESS; - if (NPT_SUCCEEDED(res)) { - ++sub_iter; - continue; - } + // forget sub if notification failed immediately. However, since + // the request is asynchronous, the subscriber may be purged at + // a later time. + if (NPT_FAILED((*sub_iter)->Notify(vars_ready))) { + NPT_LOG_WARNING_1("Failed to notify subscriber: %s", (*sub_iter)->GetSID().GetChars()); + m_Subscribers.Erase(sub_iter++); + continue; } - - m_Subscribers.Erase(sub_iter++); + + ++sub_iter; } return NPT_SUCCESS; diff --git a/Source/Core/PltService.h b/Source/Core/PltService.h index 84959f23..2484db07 100644 --- a/Source/Core/PltService.h +++ b/Source/Core/PltService.h @@ -302,6 +302,11 @@ class PLT_Service // methods void Cleanup(); + + /** + Called regularly prior to notifying new or existing subscribers + */ + void PurgeSubscribers(); /** Called by a PLT_StateVariable to keep track of what events need to be diff --git a/Source/Core/PltTaskManager.cpp b/Source/Core/PltTaskManager.cpp index 3109995e..368a0573 100644 --- a/Source/Core/PltTaskManager.cpp +++ b/Source/Core/PltTaskManager.cpp @@ -190,7 +190,7 @@ PLT_TaskManager::AddTask(PLT_ThreadTask* task) return result; } - NPT_LOG_FINER_3("[TaskManager 0x%p] %d/%d running tasks", this, ++m_RunningTasks, m_MaxTasks); + NPT_LOG_FINER_3("[TaskManager 0x%p] %d/%d running tasks", (void*)this, ++m_RunningTasks, m_MaxTasks); // keep track of running task result = m_Tasks.Add(task); @@ -223,7 +223,7 @@ PLT_TaskManager::RemoveTask(PLT_ThreadTask* task) } } - NPT_LOG_FINER_3("[TaskManager 0x%p] %d/%d running tasks", this, --m_RunningTasks, m_MaxTasks); + NPT_LOG_FINER_3("[TaskManager 0x%p] %d/%d running tasks", (void*)this, --m_RunningTasks, m_MaxTasks); m_Tasks.Remove(task); } diff --git a/Source/Tests/LightSample/LightSampleTest.cpp b/Source/Tests/LightSample/LightSampleTest.cpp index 9a4ff18f..a4b8ce5b 100644 --- a/Source/Tests/LightSample/LightSampleTest.cpp +++ b/Source/Tests/LightSample/LightSampleTest.cpp @@ -38,7 +38,7 @@ #include "PltUPnP.h" #include "PltLightSample.h" -#define TEST_EMBEDDED_DEVICE 1 +//#define TEST_EMBEDDED_DEVICE 1 /*---------------------------------------------------------------------- | main @@ -46,6 +46,9 @@ int main(int /* argc */, char** /* argv */) { + // setup Neptune logging + NPT_LogManager::GetDefault().Configure("plist:.level=FINE;.handlers=ConsoleHandler;.ConsoleHandler.colors=off;.ConsoleHandler.filter=42"); + PLT_UPnP upnp; PLT_DeviceHostReference device(new PLT_LightSampleDevice("Platinum Light Bulb"));