struct Upnp_Event becomes UpnpEvent. One less externally visible data structure.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@359 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
2e4a96f034
commit
98a45e17b5
@ -22,6 +22,7 @@ upnpinclude_HEADERS = \
|
|||||||
inc/ActionComplete.h \
|
inc/ActionComplete.h \
|
||||||
inc/ActionRequest.h \
|
inc/ActionRequest.h \
|
||||||
inc/Discovery.h \
|
inc/Discovery.h \
|
||||||
|
inc/Event.h \
|
||||||
inc/EventSubscribe.h \
|
inc/EventSubscribe.h \
|
||||||
inc/FileInfo.h \
|
inc/FileInfo.h \
|
||||||
inc/StateVarComplete.h \
|
inc/StateVarComplete.h \
|
||||||
@ -123,6 +124,7 @@ libupnp_la_SOURCES += \
|
|||||||
libupnp_la_SOURCES += src/api/ActionComplete.c
|
libupnp_la_SOURCES += src/api/ActionComplete.c
|
||||||
libupnp_la_SOURCES += src/api/ActionRequest.c
|
libupnp_la_SOURCES += src/api/ActionRequest.c
|
||||||
libupnp_la_SOURCES += src/api/Discovery.c
|
libupnp_la_SOURCES += src/api/Discovery.c
|
||||||
|
libupnp_la_SOURCES += src/api/Event.c
|
||||||
libupnp_la_SOURCES += src/api/EventSubscribe.c
|
libupnp_la_SOURCES += src/api/EventSubscribe.c
|
||||||
libupnp_la_SOURCES += src/api/FileInfo.c
|
libupnp_la_SOURCES += src/api/FileInfo.c
|
||||||
libupnp_la_SOURCES += src/api/StateVarComplete.c
|
libupnp_la_SOURCES += src/api/StateVarComplete.c
|
||||||
|
@ -13,10 +13,8 @@ extern "C" {
|
|||||||
typedef struct {} UpnpActionRequest;
|
typedef struct {} UpnpActionRequest;
|
||||||
|
|
||||||
|
|
||||||
#include "String.h" // for UpnpString
|
|
||||||
|
|
||||||
|
|
||||||
#include "ixml.h" // for IXML_Document
|
#include "ixml.h" // for IXML_Document
|
||||||
|
#include "String.h" // for UpnpString
|
||||||
|
|
||||||
|
|
||||||
#include <netinet/in.h> // for in_addr
|
#include <netinet/in.h> // for in_addr
|
||||||
|
51
upnp/inc/Event.h
Normal file
51
upnp/inc/Event.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef EVENT_H
|
||||||
|
#define EVENT_H
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/** Returned along with a {\bf UPNP_EVENT_RECEIVED} callback. */
|
||||||
|
typedef struct {} UpnpEvent;
|
||||||
|
|
||||||
|
|
||||||
|
#include "ixml.h" // for IXML_Document
|
||||||
|
#include "String.h" // for UpnpString
|
||||||
|
|
||||||
|
|
||||||
|
/** Constructor */
|
||||||
|
UpnpEvent *UpnpEvent_new();
|
||||||
|
|
||||||
|
/** Destructor */
|
||||||
|
void UpnpEvent_delete(UpnpEvent *p);
|
||||||
|
|
||||||
|
/** Copy Constructor */
|
||||||
|
UpnpEvent *UpnpEvent_dup(const UpnpEvent *p);
|
||||||
|
|
||||||
|
/** Assignment operator */
|
||||||
|
void UpnpEvent_assign(UpnpEvent *q, const UpnpEvent *p);
|
||||||
|
|
||||||
|
/** The event sequence number. */
|
||||||
|
int UpnpEvent_get_EventKey(const UpnpEvent *p);
|
||||||
|
void UpnpEvent_set_EventKey(UpnpEvent *p, int n);
|
||||||
|
|
||||||
|
/** The DOM tree representing the changes generating the event. */
|
||||||
|
IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p);
|
||||||
|
void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d);
|
||||||
|
|
||||||
|
/** The subscription ID for this subscription. */
|
||||||
|
UpnpString *UpnpEvent_get_SID(const UpnpEvent *p);
|
||||||
|
void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EVENT_H */
|
||||||
|
|
@ -519,6 +519,7 @@
|
|||||||
#include "ActionComplete.h"
|
#include "ActionComplete.h"
|
||||||
#include "ActionRequest.h"
|
#include "ActionRequest.h"
|
||||||
#include "Discovery.h"
|
#include "Discovery.h"
|
||||||
|
#include "Event.h"
|
||||||
#include "EventSubscribe.h"
|
#include "EventSubscribe.h"
|
||||||
#include "FileInfo.h"
|
#include "FileInfo.h"
|
||||||
#include "StateVarComplete.h"
|
#include "StateVarComplete.h"
|
||||||
@ -634,7 +635,7 @@ enum Upnp_EventType_e {
|
|||||||
UPNP_EVENT_SUBSCRIPTION_REQUEST,
|
UPNP_EVENT_SUBSCRIPTION_REQUEST,
|
||||||
|
|
||||||
/** Received by a control point when an event arrives. The {\bf
|
/** Received by a control point when an event arrives. The {\bf
|
||||||
* Event} parameter contains a {\bf Upnp_Event} structure
|
* Event} parameter contains a {\bf UpnpEvent} structure
|
||||||
* with the information about the event. */
|
* with the information about the event. */
|
||||||
|
|
||||||
UPNP_EVENT_RECEIVED,
|
UPNP_EVENT_RECEIVED,
|
||||||
@ -735,20 +736,6 @@ enum Upnp_DescType_e {
|
|||||||
typedef enum Upnp_DescType_e Upnp_DescType;
|
typedef enum Upnp_DescType_e Upnp_DescType;
|
||||||
|
|
||||||
|
|
||||||
/** Returned along with a {\bf UPNP_EVENT_RECEIVED} callback. */
|
|
||||||
struct Upnp_Event
|
|
||||||
{
|
|
||||||
/** The subscription ID for this subscription. */
|
|
||||||
Upnp_SID Sid;
|
|
||||||
|
|
||||||
/** The event sequence number. */
|
|
||||||
int EventKey;
|
|
||||||
|
|
||||||
/** The DOM tree representing the changes generating the event. */
|
|
||||||
IXML_Document *ChangedVariables;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIPTION_REQUEST}
|
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIPTION_REQUEST}
|
||||||
* callback. */
|
* callback. */
|
||||||
|
|
||||||
|
@ -548,15 +548,16 @@ SampleUtil_PrintEvent( IN Upnp_EventType EventType,
|
|||||||
|
|
||||||
case UPNP_EVENT_RECEIVED:
|
case UPNP_EVENT_RECEIVED:
|
||||||
{
|
{
|
||||||
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
|
UpnpEvent *e_event = (UpnpEvent *)Event;
|
||||||
char *xmlbuff = NULL;
|
char *xmlbuff = NULL;
|
||||||
xmlbuff = ixmlPrintNode( (IXML_Node *) e_event->ChangedVariables );
|
xmlbuff = ixmlPrintNode(
|
||||||
|
(IXML_Node *) UpnpEvent_get_ChangedVariables(e_event));
|
||||||
SampleUtil_Print(
|
SampleUtil_Print(
|
||||||
"SID = %s\n"
|
"SID = %s\n"
|
||||||
"EventKey = %d\n"
|
"EventKey = %d\n"
|
||||||
"ChangedVars = %s\n",
|
"ChangedVars = %s\n",
|
||||||
e_event->Sid,
|
UpnpString_get_String(UpnpEvent_get_SID(e_event)),
|
||||||
e_event->EventKey,
|
UpnpEvent_get_EventKey(e_event),
|
||||||
xmlbuff);
|
xmlbuff);
|
||||||
ixmlFreeDOMString(xmlbuff);
|
ixmlFreeDOMString(xmlbuff);
|
||||||
}
|
}
|
||||||
|
@ -937,27 +937,31 @@ TvStateUpdate( char *UDN,
|
|||||||
* changes -- The DOM document representing the changes
|
* changes -- The DOM document representing the changes
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void TvCtrlPointHandleEvent(
|
||||||
TvCtrlPointHandleEvent( Upnp_SID sid,
|
const UpnpString *sid,
|
||||||
int evntkey,
|
int evntkey,
|
||||||
IXML_Document *changes)
|
IXML_Document *changes)
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int service;
|
int service;
|
||||||
|
const char *aux_sid = NULL;
|
||||||
|
|
||||||
ithread_mutex_lock(&DeviceListMutex);
|
ithread_mutex_lock(&DeviceListMutex);
|
||||||
|
|
||||||
tmpdevnode = GlobalDeviceList;
|
tmpdevnode = GlobalDeviceList;
|
||||||
while (tmpdevnode) {
|
while (tmpdevnode) {
|
||||||
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
|
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
|
||||||
if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) ==
|
aux_sid = UpnpString_get_String(sid);
|
||||||
0 ) {
|
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
|
||||||
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
|
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
|
||||||
TvServiceName[service], evntkey, sid );
|
TvServiceName[service],
|
||||||
|
evntkey,
|
||||||
TvStateUpdate( tmpdevnode->device.UDN, service, changes,
|
aux_sid);
|
||||||
( char ** )&tmpdevnode->device.
|
TvStateUpdate(
|
||||||
TvService[service].VariableStrVal );
|
tmpdevnode->device.UDN,
|
||||||
|
service,
|
||||||
|
changes,
|
||||||
|
(char **)&tmpdevnode->device.TvService[service].VariableStrVal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1148,9 +1152,11 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
|||||||
|
|
||||||
/* GENA Stuff */
|
/* GENA Stuff */
|
||||||
case UPNP_EVENT_RECEIVED: {
|
case UPNP_EVENT_RECEIVED: {
|
||||||
struct Upnp_Event *e_event = ( struct Upnp_Event * )Event;
|
UpnpEvent *e_event = (UpnpEvent *)Event;
|
||||||
TvCtrlPointHandleEvent( e_event->Sid, e_event->EventKey,
|
TvCtrlPointHandleEvent(
|
||||||
e_event->ChangedVariables );
|
UpnpEvent_get_SID(e_event),
|
||||||
|
UpnpEvent_get_EventKey(e_event),
|
||||||
|
UpnpEvent_get_ChangedVariables(e_event));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ int TvCtrlPointPrintDevice(int);
|
|||||||
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
|
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
|
||||||
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
|
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
|
||||||
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
||||||
void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
|
void TvCtrlPointHandleEvent(const UpnpString *, int, IXML_Document *);
|
||||||
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
|
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
|
||||||
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
||||||
void TvCtrlPointVerifyTimeouts(int);
|
void TvCtrlPointVerifyTimeouts(int);
|
||||||
|
@ -1745,8 +1745,7 @@ TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT c
|
|||||||
* Cookie -- Optional data specified during callback registration
|
* Cookie -- Optional data specified during callback registration
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||||
TvDeviceCallbackEventHandler( Upnp_EventType EventType, void *Event, void *Cookie )
|
|
||||||
{
|
{
|
||||||
switch ( EventType ) {
|
switch ( EventType ) {
|
||||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||||
|
@ -937,27 +937,31 @@ TvStateUpdate( char *UDN,
|
|||||||
* changes -- The DOM document representing the changes
|
* changes -- The DOM document representing the changes
|
||||||
*
|
*
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
void
|
void TvCtrlPointHandleEvent(
|
||||||
TvCtrlPointHandleEvent( Upnp_SID sid,
|
const UpnpString *sid,
|
||||||
int evntkey,
|
int evntkey,
|
||||||
IXML_Document *changes)
|
IXML_Document *changes)
|
||||||
{
|
{
|
||||||
struct TvDeviceNode *tmpdevnode;
|
struct TvDeviceNode *tmpdevnode;
|
||||||
int service;
|
int service;
|
||||||
|
const char *aux_sid = NULL;
|
||||||
|
|
||||||
ithread_mutex_lock(&DeviceListMutex);
|
ithread_mutex_lock(&DeviceListMutex);
|
||||||
|
|
||||||
tmpdevnode = GlobalDeviceList;
|
tmpdevnode = GlobalDeviceList;
|
||||||
while (tmpdevnode) {
|
while (tmpdevnode) {
|
||||||
for( service = 0; service < TV_SERVICE_SERVCOUNT; service++ ) {
|
for (service = 0; service < TV_SERVICE_SERVCOUNT; ++service) {
|
||||||
if( strcmp( tmpdevnode->device.TvService[service].SID, sid ) ==
|
aux_sid = UpnpString_get_String(sid);
|
||||||
0 ) {
|
if (strcmp(tmpdevnode->device.TvService[service].SID, aux_sid) == 0) {
|
||||||
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
|
SampleUtil_Print("Received Tv %s Event: %d for SID %s",
|
||||||
TvServiceName[service], evntkey, sid );
|
TvServiceName[service],
|
||||||
|
evntkey,
|
||||||
TvStateUpdate( tmpdevnode->device.UDN, service, changes,
|
aux_sid);
|
||||||
( char ** )&tmpdevnode->device.
|
TvStateUpdate(
|
||||||
TvService[service].VariableStrVal );
|
tmpdevnode->device.UDN,
|
||||||
|
service,
|
||||||
|
changes,
|
||||||
|
(char **)&tmpdevnode->device.TvService[service].VariableStrVal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1148,9 +1152,11 @@ int TvCtrlPointCallbackEventHandler(Upnp_EventType EventType, void *Event, void
|
|||||||
|
|
||||||
/* GENA Stuff */
|
/* GENA Stuff */
|
||||||
case UPNP_EVENT_RECEIVED: {
|
case UPNP_EVENT_RECEIVED: {
|
||||||
struct Upnp_Event *e_event = ( struct Upnp_Event * )Event;
|
UpnpEvent *e_event = (UpnpEvent *)Event;
|
||||||
TvCtrlPointHandleEvent( e_event->Sid, e_event->EventKey,
|
TvCtrlPointHandleEvent(
|
||||||
e_event->ChangedVariables );
|
UpnpEvent_get_SID(e_event),
|
||||||
|
UpnpEvent_get_EventKey(e_event),
|
||||||
|
UpnpEvent_get_ChangedVariables(e_event));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ int TvCtrlPointPrintDevice(int);
|
|||||||
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
|
void TvCtrlPointAddDevice(IXML_Document *, const char *, int);
|
||||||
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
|
void TvCtrlPointHandleGetVar(const char *, const char *, const DOMString);
|
||||||
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
void TvStateUpdate(char*,int, IXML_Document * , char **);
|
||||||
void TvCtrlPointHandleEvent(Upnp_SID, int, IXML_Document *);
|
void TvCtrlPointHandleEvent(const UpnpString *, int, IXML_Document *);
|
||||||
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
|
void TvCtrlPointHandleSubscribeUpdate(const char *, const Upnp_SID, int);
|
||||||
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
int TvCtrlPointCallbackEventHandler(Upnp_EventType, void *, void *);
|
||||||
void TvCtrlPointVerifyTimeouts(int);
|
void TvCtrlPointVerifyTimeouts(int);
|
||||||
|
@ -1747,8 +1747,7 @@ TvDeviceDecreaseBrightness( IN IXML_Document *in, OUT IXML_Document **out, OUT c
|
|||||||
* Cookie -- Optional data specified during callback registration
|
* Cookie -- Optional data specified during callback registration
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Cookie)
|
||||||
TvDeviceCallbackEventHandler( Upnp_EventType EventType, void *Event, void *Cookie )
|
|
||||||
{
|
{
|
||||||
switch ( EventType ) {
|
switch ( EventType ) {
|
||||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||||
|
105
upnp/src/api/Event.c
Normal file
105
upnp/src/api/Event.c
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h> // for calloc(), free()
|
||||||
|
|
||||||
|
|
||||||
|
struct SUpnpEvent
|
||||||
|
{
|
||||||
|
int m_eventKey;
|
||||||
|
IXML_Document *m_changedVariables;
|
||||||
|
UpnpString *m_SID;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UpnpEvent *UpnpEvent_new()
|
||||||
|
{
|
||||||
|
struct SUpnpEvent *p = calloc(1, sizeof (struct SUpnpEvent));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
p->m_eventKey = 0;
|
||||||
|
p->m_changedVariables = NULL;
|
||||||
|
#endif
|
||||||
|
p->m_SID = UpnpString_new();
|
||||||
|
|
||||||
|
return (UpnpEvent *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_delete(UpnpEvent *p)
|
||||||
|
{
|
||||||
|
struct SUpnpEvent *q = (struct SUpnpEvent *)p;
|
||||||
|
|
||||||
|
q->m_eventKey = 0;
|
||||||
|
|
||||||
|
q->m_changedVariables = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_SID);
|
||||||
|
q->m_SID = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpEvent *UpnpEvent_dup(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
UpnpEvent *q = UpnpEvent_new();
|
||||||
|
|
||||||
|
UpnpEvent_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_assign(UpnpEvent *q, const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
if (q != p) {
|
||||||
|
UpnpEvent_set_EventKey(q, UpnpEvent_get_EventKey(p));
|
||||||
|
UpnpEvent_set_ChangedVariables(q, UpnpEvent_get_ChangedVariables(p));
|
||||||
|
UpnpEvent_set_SID(q, UpnpEvent_get_SID(p));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpEvent_get_EventKey(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpEvent *)p)->m_eventKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_set_EventKey(UpnpEvent *p, int n)
|
||||||
|
{
|
||||||
|
((struct SUpnpEvent *)p)->m_eventKey = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpEvent *)p)->m_changedVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d)
|
||||||
|
{
|
||||||
|
ixmlDocument_free(((struct SUpnpEvent *)p)->m_changedVariables);
|
||||||
|
((struct SUpnpEvent *)p)->m_changedVariables = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UpnpString *UpnpEvent_get_SID(const UpnpEvent *p)
|
||||||
|
{
|
||||||
|
return ((struct SUpnpEvent *)p)->m_SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SUpnpEvent *)p)->m_SID);
|
||||||
|
((struct SUpnpEvent *)p)->m_SID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
@ -770,11 +770,11 @@ exit_function:
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event)
|
void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event)
|
||||||
{
|
{
|
||||||
struct Upnp_Event event_struct;
|
UpnpEvent *event_struct = UpnpEvent_new();
|
||||||
|
IXML_Document *ChangedVars = NULL;
|
||||||
int eventKey;
|
int eventKey;
|
||||||
token sid;
|
token sid;
|
||||||
ClientSubscription *subscription = NULL;
|
ClientSubscription *subscription = NULL;
|
||||||
IXML_Document *ChangedVars;
|
|
||||||
struct Handle_Info *handle_info;
|
struct Handle_Info *handle_info;
|
||||||
void *cookie;
|
void *cookie;
|
||||||
Upnp_FunPtr callback;
|
Upnp_FunPtr callback;
|
||||||
@ -788,8 +788,7 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
// get SID
|
// get SID
|
||||||
if (httpmsg_find_hdr(event, HDR_SID, &sid_hdr) == NULL) {
|
if (httpmsg_find_hdr(event, HDR_SID, &sid_hdr) == NULL) {
|
||||||
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
||||||
|
goto exit_function;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
sid.buff = sid_hdr.buf;
|
sid.buff = sid_hdr.buf;
|
||||||
sid.size = sid_hdr.length;
|
sid.size = sid_hdr.length;
|
||||||
@ -798,24 +797,21 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
if (httpmsg_find_hdr(event, HDR_SEQ, &seq_hdr) == NULL ||
|
if (httpmsg_find_hdr(event, HDR_SEQ, &seq_hdr) == NULL ||
|
||||||
matchstr(seq_hdr.buf, seq_hdr.length, "%d%0", &eventKey) != PARSE_OK) {
|
matchstr(seq_hdr.buf, seq_hdr.length, "%d%0", &eventKey) != PARSE_OK) {
|
||||||
error_respond( info, HTTP_BAD_REQUEST, event );
|
error_respond( info, HTTP_BAD_REQUEST, event );
|
||||||
|
goto exit_function;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get NT and NTS headers
|
// get NT and NTS headers
|
||||||
if (httpmsg_find_hdr(event, HDR_NT, &nt_hdr) == NULL ||
|
if (httpmsg_find_hdr(event, HDR_NT, &nt_hdr) == NULL ||
|
||||||
httpmsg_find_hdr(event, HDR_NTS, &nts_hdr) == NULL) {
|
httpmsg_find_hdr(event, HDR_NTS, &nts_hdr) == NULL) {
|
||||||
error_respond( info, HTTP_BAD_REQUEST, event );
|
error_respond( info, HTTP_BAD_REQUEST, event );
|
||||||
|
goto exit_function;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify NT and NTS headers
|
// verify NT and NTS headers
|
||||||
if (memptr_cmp(&nt_hdr, "upnp:event") != 0 ||
|
if (memptr_cmp(&nt_hdr, "upnp:event") != 0 ||
|
||||||
memptr_cmp(&nts_hdr, "upnp:propchange") != 0) {
|
memptr_cmp(&nts_hdr, "upnp:propchange") != 0) {
|
||||||
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
||||||
|
goto exit_function;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the content (should be XML)
|
// parse the content (should be XML)
|
||||||
@ -823,8 +819,7 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
event->msg.length == 0 ||
|
event->msg.length == 0 ||
|
||||||
ixmlParseBufferEx(event->entity.buf, &ChangedVars) != IXML_SUCCESS) {
|
ixmlParseBufferEx(event->entity.buf, &ChangedVars) != IXML_SUCCESS) {
|
||||||
error_respond(info, HTTP_BAD_REQUEST, event);
|
error_respond(info, HTTP_BAD_REQUEST, event);
|
||||||
|
goto exit_function;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleLock();
|
HandleLock();
|
||||||
@ -833,9 +828,7 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
if (GetClientHandleInfo(&client_handle, &handle_info) != HND_CLIENT) {
|
if (GetClientHandleInfo(&client_handle, &handle_info) != HND_CLIENT) {
|
||||||
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
ixmlDocument_free(ChangedVars);
|
goto exit_function;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get subscription based on SID
|
// get subscription based on SID
|
||||||
@ -859,9 +852,7 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
error_respond(info, HTTP_PRECONDITION_FAILED, event);
|
||||||
SubscribeUnlock();
|
SubscribeUnlock();
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
ixmlDocument_free(ChangedVars);
|
goto exit_function;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subscription = GetClientSubActualSID(handle_info->ClientSubList, &sid);
|
subscription = GetClientSubActualSID(handle_info->ClientSubList, &sid);
|
||||||
@ -869,18 +860,14 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||||
SubscribeUnlock();
|
SubscribeUnlock();
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
ixmlDocument_free( ChangedVars );
|
goto exit_function;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscribeUnlock();
|
SubscribeUnlock();
|
||||||
} else {
|
} else {
|
||||||
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
error_respond( info, HTTP_PRECONDITION_FAILED, event );
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
ixmlDocument_free( ChangedVars );
|
goto exit_function;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -888,9 +875,9 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
error_respond(info, HTTP_OK, event);
|
error_respond(info, HTTP_OK, event);
|
||||||
|
|
||||||
// fill event struct
|
// fill event struct
|
||||||
strcpy(event_struct.Sid, UpnpString_get_String(UpnpClientSubscription_get_SID(subscription)));
|
UpnpEvent_set_EventKey(event_struct, eventKey);
|
||||||
event_struct.EventKey = eventKey;
|
UpnpEvent_set_ChangedVariables(event_struct, ChangedVars);
|
||||||
event_struct.ChangedVariables = ChangedVars;
|
UpnpEvent_set_SID(event_struct, UpnpClientSubscription_get_SID(subscription));
|
||||||
|
|
||||||
// copy callback
|
// copy callback
|
||||||
callback = handle_info->Callback;
|
callback = handle_info->Callback;
|
||||||
@ -902,9 +889,11 @@ void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event
|
|||||||
// In future, should find a way of mainting
|
// In future, should find a way of mainting
|
||||||
// that the handle is not unregistered in the middle of a
|
// that the handle is not unregistered in the middle of a
|
||||||
// callback
|
// callback
|
||||||
callback(UPNP_EVENT_RECEIVED, &event_struct, cookie);
|
callback(UPNP_EVENT_RECEIVED, event_struct, cookie);
|
||||||
|
|
||||||
|
exit_function:
|
||||||
ixmlDocument_free(ChangedVars);
|
ixmlDocument_free(ChangedVars);
|
||||||
|
UpnpEvent_delete(event_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INCLUDE_CLIENT_APIS
|
#endif // INCLUDE_CLIENT_APIS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user