Upnp_Subscription_Request becomes UpnpSubscriptionRequest. One less externally visible data structure.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@360 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
98a45e17b5
commit
d2c34a15de
@ -27,6 +27,7 @@ upnpinclude_HEADERS = \
|
||||
inc/FileInfo.h \
|
||||
inc/StateVarComplete.h \
|
||||
inc/StateVarRequest.h \
|
||||
inc/SubscriptionRequest.h \
|
||||
inc/String.h \
|
||||
inc/upnp.h \
|
||||
inc/upnpdebug.h
|
||||
@ -129,6 +130,7 @@ libupnp_la_SOURCES += src/api/EventSubscribe.c
|
||||
libupnp_la_SOURCES += src/api/FileInfo.c
|
||||
libupnp_la_SOURCES += src/api/StateVarComplete.c
|
||||
libupnp_la_SOURCES += src/api/StateVarRequest.c
|
||||
libupnp_la_SOURCES += src/api/SubscriptionRequest.c
|
||||
libupnp_la_SOURCES += src/api/String.c
|
||||
libupnp_la_SOURCES += src/api/upnpapi.c
|
||||
if ENABLE_TOOLS
|
||||
|
53
upnp/inc/SubscriptionRequest.h
Normal file
53
upnp/inc/SubscriptionRequest.h
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
|
||||
#ifndef SUBSCRIPTIONREQUEST_H
|
||||
#define SUBSCRIPTIONREQUEST_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIPTION_REQUEST} callback. */
|
||||
typedef struct {} UpnpSubscriptionRequest;
|
||||
|
||||
|
||||
#include "String.h" // for UpnpString
|
||||
|
||||
|
||||
/** Constructor */
|
||||
UpnpSubscriptionRequest *UpnpSubscriptionRequest_new();
|
||||
|
||||
/** Destructor */
|
||||
void UpnpSubscriptionRequest_delete(UpnpSubscriptionRequest *p);
|
||||
|
||||
/** Copy Constructor */
|
||||
UpnpSubscriptionRequest *UpnpSubscriptionRequest_dup(const UpnpSubscriptionRequest *p);
|
||||
|
||||
/** Assignment operator */
|
||||
void UpnpSubscriptionRequest_assign(UpnpSubscriptionRequest *q, const UpnpSubscriptionRequest *p);
|
||||
|
||||
/** The identifier for the service being subscribed to. */
|
||||
const UpnpString *UpnpSubscriptionRequest_get_ServiceId(const UpnpSubscriptionRequest *p);
|
||||
void UpnpSubscriptionRequest_set_ServiceId(UpnpSubscriptionRequest *p, const UpnpString *s);
|
||||
void UpnpSubscriptionRequest_strcpy_ServiceId(UpnpSubscriptionRequest *p, const char *s);
|
||||
|
||||
/** Universal device name. */
|
||||
const UpnpString *UpnpSubscriptionRequest_get_UDN(const UpnpSubscriptionRequest *p);
|
||||
void UpnpSubscriptionRequest_set_UDN(UpnpSubscriptionRequest *p, const UpnpString *s);
|
||||
void UpnpSubscriptionRequest_strcpy_UDN(UpnpSubscriptionRequest *p, const char *s);
|
||||
|
||||
/** The assigned subscription ID for this subscription. */
|
||||
const UpnpString *UpnpSubscriptionRequest_get_SID(const UpnpSubscriptionRequest *p);
|
||||
void UpnpSubscriptionRequest_set_SID(UpnpSubscriptionRequest *p, const UpnpString *s);
|
||||
void UpnpSubscriptionRequest_strcpy_SID(UpnpSubscriptionRequest *p, const char *s);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* SUBSCRIPTIONREQUEST_H */
|
||||
|
@ -524,6 +524,7 @@
|
||||
#include "FileInfo.h"
|
||||
#include "StateVarComplete.h"
|
||||
#include "StateVarRequest.h"
|
||||
#include "SubscriptionRequest.h"
|
||||
|
||||
|
||||
enum UpnpOpenFileMode
|
||||
@ -624,7 +625,7 @@ enum Upnp_EventType_e {
|
||||
|
||||
/** Received by a device when a subscription arrives.
|
||||
* The {\bf Event} parameter contains a pointer to a {\bf
|
||||
* Upnp_Subscription_Request} structure. At this point, the
|
||||
* UpnpSubscriptionRequest} structure. At this point, the
|
||||
* subscription has already been accepted. {\bf UpnpAcceptSubscription}
|
||||
* needs to be called to confirm the subscription and transmit the
|
||||
* initial state table. This can be done during this callback. The SDK
|
||||
@ -690,10 +691,9 @@ typedef char Upnp_SID[44];
|
||||
{\bf UpnpSearchAsync}, the control point application
|
||||
can control the scope of the search from all devices
|
||||
to specific devices or services.
|
||||
*/
|
||||
*/
|
||||
|
||||
enum Upnp_SType_e {
|
||||
|
||||
/** Search for all devices and services on the network. */
|
||||
UPNP_S_ALL,
|
||||
|
||||
@ -707,7 +707,6 @@ enum Upnp_SType_e {
|
||||
/** Search for a particular service type, possibly on a particular
|
||||
* device type or device instance. */
|
||||
UPNP_S_SERVICE
|
||||
|
||||
};
|
||||
|
||||
typedef enum Upnp_SType_e Upnp_SType;
|
||||
@ -717,9 +716,8 @@ typedef enum Upnp_SType_e Upnp_SType;
|
||||
{\bf UpnpRegisterRootDevice2}.
|
||||
@doc These values control how {\bf UpnpRegisterRootDevice2}
|
||||
interprets the {\bf description} parameter.
|
||||
*/
|
||||
*/
|
||||
enum Upnp_DescType_e {
|
||||
|
||||
/** The description is the URL to the description document. */
|
||||
UPNPREG_URL_DESC,
|
||||
|
||||
@ -730,28 +728,11 @@ enum Upnp_DescType_e {
|
||||
/** The description is a pointer to a character array containing
|
||||
the XML description document. */
|
||||
UPNPREG_BUF_DESC
|
||||
|
||||
};
|
||||
|
||||
typedef enum Upnp_DescType_e Upnp_DescType;
|
||||
|
||||
|
||||
/** Returned along with a {\bf UPNP_EVENT_SUBSCRIPTION_REQUEST}
|
||||
* callback. */
|
||||
|
||||
struct Upnp_Subscription_Request
|
||||
{
|
||||
/** The identifier for the service being subscribed to. */
|
||||
char *ServiceId;
|
||||
|
||||
/** Universal device name. */
|
||||
char *UDN;
|
||||
|
||||
/** The assigned subscription ID for this subscription. */
|
||||
Upnp_SID Sid;
|
||||
};
|
||||
|
||||
|
||||
/* The type of handle returned by the web server for open requests. */
|
||||
|
||||
typedef void *UpnpWebFileHandle;
|
||||
@ -1660,19 +1641,20 @@ EXPORT_SPEC int UpnpSendActionExAsync(
|
||||
*/
|
||||
|
||||
EXPORT_SPEC int UpnpAcceptSubscription(
|
||||
IN UpnpDevice_Handle Hnd, /** The handle of the device. */
|
||||
IN const char *DevID, /** The device ID of the subdevice of the
|
||||
service generating the event. */
|
||||
IN const char *ServID, /** The unique service identifier of the service
|
||||
generating the event. */
|
||||
IN const char **VarName, /** Pointer to an array of event variables. */
|
||||
IN const char **NewVal, /** Pointer to an array of values for
|
||||
the event variables. */
|
||||
IN int cVariables, /** The number of event variables in
|
||||
{\bf VarName}. */
|
||||
IN Upnp_SID SubsId /** The subscription ID of the newly
|
||||
registered control point. */
|
||||
);
|
||||
/** The handle of the device. */
|
||||
IN UpnpDevice_Handle Hnd,
|
||||
/** The device ID of the subdevice of the service generating the event. */
|
||||
IN const char *DevID,
|
||||
/** The unique service identifier of the service generating the event. */
|
||||
IN const char *ServID,
|
||||
/** Pointer to an array of event variables. */
|
||||
IN const char **VarName,
|
||||
/** Pointer to an array of values for the event variables. */
|
||||
IN const char **NewVal,
|
||||
/** The number of event variables in {\bf VarName}. */
|
||||
IN int cVariables,
|
||||
/** The subscription ID of the newly registered control point. */
|
||||
IN const Upnp_SID SubsId);
|
||||
|
||||
/** {\bf UpnpAcceptSubscriptionExt} is similar to {\bf UpnpAcceptSubscription}
|
||||
* except that it takes a DOM document for the variables to event rather
|
||||
|
@ -534,15 +534,14 @@ SampleUtil_PrintEvent( IN Upnp_EventType EventType,
|
||||
*/
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
{
|
||||
struct Upnp_Subscription_Request *sr_event =
|
||||
(struct Upnp_Subscription_Request *)Event;
|
||||
UpnpSubscriptionRequest *sr_event = (UpnpSubscriptionRequest *)Event;
|
||||
SampleUtil_Print(
|
||||
"ServiceID = %s\n"
|
||||
"UDN = %s\n"
|
||||
"SID = %s\n",
|
||||
sr_event->ServiceId,
|
||||
sr_event->UDN,
|
||||
sr_event->Sid );
|
||||
UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event)),
|
||||
UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event)),
|
||||
UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -364,61 +364,68 @@ TvDeviceStateTableInit( IN char *DescDocURL )
|
||||
* sr_event -- The subscription request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
|
||||
*sr_event )
|
||||
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
|
||||
{
|
||||
unsigned int i = 0; //,j=0;
|
||||
unsigned int i = 0;
|
||||
//unsigned int j = 0;
|
||||
int cmp1 = 0;
|
||||
int cmp2 = 0;
|
||||
const char *l_serviceId = NULL;
|
||||
const char *l_udn = NULL;
|
||||
const char *l_sid = NULL;
|
||||
// IXML_Document *PropSet = NULL;
|
||||
|
||||
// IXML_Document *PropSet=NULL;
|
||||
// lock state mutex
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
|
||||
//lock state mutex
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
|
||||
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
|
||||
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
|
||||
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
|
||||
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
|
||||
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
|
||||
if (cmp1 == 0 && cmp2 == 0) {
|
||||
#if 0
|
||||
PropSet = NULL;
|
||||
|
||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
||||
if( ( strcmp( sr_event->UDN, tv_service_table[i].UDN ) == 0 ) &&
|
||||
( strcmp( sr_event->ServiceId, tv_service_table[i].ServiceId )
|
||||
== 0 ) ) {
|
||||
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
|
||||
// add each variable to the property set
|
||||
// for initial state dump
|
||||
UpnpAddToPropertySet(
|
||||
&PropSet,
|
||||
tv_service_table[i].VariableName[j],
|
||||
tv_service_table[i].VariableStrVal[j]);
|
||||
}
|
||||
|
||||
/*
|
||||
PropSet = NULL;
|
||||
// dump initial state
|
||||
UpnpAcceptSubscriptionExt(
|
||||
device_handle,
|
||||
l_udn,
|
||||
l_serviceId,
|
||||
PropSet,
|
||||
l_sid);
|
||||
// free document
|
||||
Document_free(PropSet);
|
||||
#endif
|
||||
UpnpAcceptSubscription(
|
||||
device_handle,
|
||||
l_udn,
|
||||
l_serviceId,
|
||||
(const char **)tv_service_table[i].
|
||||
VariableName,
|
||||
(const char **)tv_service_table[i].
|
||||
VariableStrVal,
|
||||
tv_service_table[i].VariableCount,
|
||||
l_sid);
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0; j< tv_service_table[i].VariableCount; j++)
|
||||
{
|
||||
//add each variable to the property set
|
||||
//for initial state dump
|
||||
UpnpAddToPropertySet(&PropSet,
|
||||
tv_service_table[i].VariableName[j],
|
||||
tv_service_table[i].VariableStrVal[j]);
|
||||
}
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
|
||||
//dump initial state
|
||||
UpnpAcceptSubscriptionExt(device_handle, sr_event->UDN,
|
||||
sr_event->ServiceId,
|
||||
PropSet,sr_event->Sid);
|
||||
//free document
|
||||
Document_free(PropSet);
|
||||
|
||||
*/
|
||||
|
||||
UpnpAcceptSubscription( device_handle,
|
||||
sr_event->UDN,
|
||||
sr_event->ServiceId,
|
||||
( const char ** )tv_service_table[i].
|
||||
VariableName,
|
||||
( const char ** )tv_service_table[i].
|
||||
VariableStrVal,
|
||||
tv_service_table[i].VariableCount,
|
||||
sr_event->Sid );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
|
||||
return ( 1 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceHandleGetVarRequest
|
||||
*
|
||||
@ -1749,7 +1756,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
|
||||
{
|
||||
switch ( EventType ) {
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
TvDeviceHandleSubscriptionRequest( (struct Upnp_Subscription_Request *)Event );
|
||||
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||
break;
|
||||
|
||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||
|
@ -226,7 +226,7 @@ int TvDeviceStateTableInit(char*);
|
||||
* sr_event -- The subscription request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
|
||||
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceHandleGetVarRequest
|
||||
|
@ -366,61 +366,68 @@ TvDeviceStateTableInit( IN char *DescDocURL )
|
||||
* sr_event -- The subscription request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int
|
||||
TvDeviceHandleSubscriptionRequest( IN struct Upnp_Subscription_Request
|
||||
*sr_event )
|
||||
int TvDeviceHandleSubscriptionRequest(IN const UpnpSubscriptionRequest *sr_event)
|
||||
{
|
||||
unsigned int i = 0; //,j=0;
|
||||
unsigned int i = 0;
|
||||
//unsigned int j = 0;
|
||||
int cmp1 = 0;
|
||||
int cmp2 = 0;
|
||||
const char *l_serviceId = NULL;
|
||||
const char *l_udn = NULL;
|
||||
const char *l_sid = NULL;
|
||||
// IXML_Document *PropSet = NULL;
|
||||
|
||||
// IXML_Document *PropSet=NULL;
|
||||
// lock state mutex
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
|
||||
//lock state mutex
|
||||
ithread_mutex_lock( &TVDevMutex );
|
||||
l_serviceId = UpnpString_get_String(UpnpSubscriptionRequest_get_ServiceId(sr_event));
|
||||
l_udn = UpnpString_get_String(UpnpSubscriptionRequest_get_UDN(sr_event));
|
||||
l_sid = UpnpString_get_String(UpnpSubscriptionRequest_get_SID(sr_event));
|
||||
for (i = 0; i < TV_SERVICE_SERVCOUNT; ++i) {
|
||||
cmp1 = strcmp(l_udn, tv_service_table[i].UDN);
|
||||
cmp2 = strcmp(l_serviceId, tv_service_table[i].ServiceId);
|
||||
if (cmp1 == 0 && cmp2 == 0) {
|
||||
#if 0
|
||||
PropSet = NULL;
|
||||
|
||||
for( i = 0; i < TV_SERVICE_SERVCOUNT; i++ ) {
|
||||
if( ( strcmp( sr_event->UDN, tv_service_table[i].UDN ) == 0 ) &&
|
||||
( strcmp( sr_event->ServiceId, tv_service_table[i].ServiceId )
|
||||
== 0 ) ) {
|
||||
for (j = 0; j< tv_service_table[i].VariableCount; ++j) {
|
||||
// add each variable to the property set
|
||||
// for initial state dump
|
||||
UpnpAddToPropertySet(
|
||||
&PropSet,
|
||||
tv_service_table[i].VariableName[j],
|
||||
tv_service_table[i].VariableStrVal[j]);
|
||||
}
|
||||
|
||||
/*
|
||||
PropSet = NULL;
|
||||
// dump initial state
|
||||
UpnpAcceptSubscriptionExt(
|
||||
device_handle,
|
||||
l_udn,
|
||||
l_serviceId,
|
||||
PropSet,
|
||||
l_sid);
|
||||
// free document
|
||||
Document_free(PropSet);
|
||||
#endif
|
||||
UpnpAcceptSubscription(
|
||||
device_handle,
|
||||
l_udn,
|
||||
l_serviceId,
|
||||
(const char **)tv_service_table[i].
|
||||
VariableName,
|
||||
(const char **)tv_service_table[i].
|
||||
VariableStrVal,
|
||||
tv_service_table[i].VariableCount,
|
||||
l_sid);
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0; j< tv_service_table[i].VariableCount; j++)
|
||||
{
|
||||
//add each variable to the property set
|
||||
//for initial state dump
|
||||
UpnpAddToPropertySet(&PropSet,
|
||||
tv_service_table[i].VariableName[j],
|
||||
tv_service_table[i].VariableStrVal[j]);
|
||||
}
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
|
||||
//dump initial state
|
||||
UpnpAcceptSubscriptionExt(device_handle, sr_event->UDN,
|
||||
sr_event->ServiceId,
|
||||
PropSet,sr_event->Sid);
|
||||
//free document
|
||||
Document_free(PropSet);
|
||||
|
||||
*/
|
||||
|
||||
UpnpAcceptSubscription( device_handle,
|
||||
sr_event->UDN,
|
||||
sr_event->ServiceId,
|
||||
( const char ** )tv_service_table[i].
|
||||
VariableName,
|
||||
( const char ** )tv_service_table[i].
|
||||
VariableStrVal,
|
||||
tv_service_table[i].VariableCount,
|
||||
sr_event->Sid );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ithread_mutex_unlock( &TVDevMutex );
|
||||
|
||||
return ( 1 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceHandleGetVarRequest
|
||||
*
|
||||
@ -1751,7 +1758,7 @@ int TvDeviceCallbackEventHandler(Upnp_EventType EventType, void *Event, void *Co
|
||||
{
|
||||
switch ( EventType ) {
|
||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||
TvDeviceHandleSubscriptionRequest( (struct Upnp_Subscription_Request *)Event );
|
||||
TvDeviceHandleSubscriptionRequest((UpnpSubscriptionRequest *)Event);
|
||||
break;
|
||||
|
||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||
|
@ -226,7 +226,7 @@ int TvDeviceStateTableInit(char*);
|
||||
* sr_event -- The subscription request event structure
|
||||
*
|
||||
*****************************************************************************/
|
||||
int TvDeviceHandleSubscriptionRequest(struct Upnp_Subscription_Request *);
|
||||
int TvDeviceHandleSubscriptionRequest(const UpnpSubscriptionRequest *);
|
||||
|
||||
/******************************************************************************
|
||||
* TvDeviceHandleGetVarRequest
|
||||
|
131
upnp/src/api/SubscriptionRequest.c
Normal file
131
upnp/src/api/SubscriptionRequest.c
Normal file
@ -0,0 +1,131 @@
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "SubscriptionRequest.h"
|
||||
|
||||
|
||||
#include <stdlib.h> // for calloc(), free()
|
||||
#include <string.h> // for memset(), strlen(), strdup()
|
||||
|
||||
|
||||
struct SUpnpSubscriptionRequest
|
||||
{
|
||||
UpnpString *m_serviceId;
|
||||
UpnpString *m_UDN;
|
||||
UpnpString *m_SID;
|
||||
};
|
||||
|
||||
|
||||
UpnpSubscriptionRequest *UpnpSubscriptionRequest_new()
|
||||
{
|
||||
struct SUpnpSubscriptionRequest *p = calloc(1, sizeof (struct SUpnpSubscriptionRequest));
|
||||
|
||||
p->m_serviceId = UpnpString_new();
|
||||
p->m_UDN = UpnpString_new();
|
||||
p->m_SID = UpnpString_new();
|
||||
|
||||
return (UpnpSubscriptionRequest *)p;
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_delete(UpnpSubscriptionRequest *p)
|
||||
{
|
||||
struct SUpnpSubscriptionRequest *q = (struct SUpnpSubscriptionRequest *)p;
|
||||
|
||||
UpnpString_delete(q->m_serviceId);
|
||||
q->m_serviceId = NULL;
|
||||
|
||||
UpnpString_delete(q->m_UDN);
|
||||
q->m_UDN = NULL;
|
||||
|
||||
UpnpString_delete(q->m_SID);
|
||||
q->m_SID = NULL;
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
UpnpSubscriptionRequest *UpnpSubscriptionRequest_dup(const UpnpSubscriptionRequest *p)
|
||||
{
|
||||
UpnpSubscriptionRequest *q = UpnpSubscriptionRequest_new();
|
||||
|
||||
UpnpSubscriptionRequest_assign(q, p);
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_assign(UpnpSubscriptionRequest *q, const UpnpSubscriptionRequest *p)
|
||||
{
|
||||
if (q != p) {
|
||||
UpnpSubscriptionRequest_set_ServiceId(q, UpnpSubscriptionRequest_get_ServiceId(p));
|
||||
UpnpSubscriptionRequest_set_UDN(q, UpnpSubscriptionRequest_get_UDN(p));
|
||||
UpnpSubscriptionRequest_set_SID(q, UpnpSubscriptionRequest_get_SID(p));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const UpnpString *UpnpSubscriptionRequest_get_ServiceId(const UpnpSubscriptionRequest *p)
|
||||
{
|
||||
return ((struct SUpnpSubscriptionRequest *)p)->m_serviceId;
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_set_ServiceId(UpnpSubscriptionRequest *p, const UpnpString *s)
|
||||
{
|
||||
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_serviceId);
|
||||
((struct SUpnpSubscriptionRequest *)p)->m_serviceId = UpnpString_dup(s);
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_strcpy_ServiceId(UpnpSubscriptionRequest *p, const char *s)
|
||||
{
|
||||
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_serviceId);
|
||||
((struct SUpnpSubscriptionRequest *)p)->m_serviceId = UpnpString_new();
|
||||
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_serviceId, s);
|
||||
}
|
||||
|
||||
|
||||
const UpnpString *UpnpSubscriptionRequest_get_UDN(const UpnpSubscriptionRequest *p)
|
||||
{
|
||||
return ((struct SUpnpSubscriptionRequest *)p)->m_UDN;
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_set_UDN(UpnpSubscriptionRequest *p, const UpnpString *s)
|
||||
{
|
||||
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_UDN);
|
||||
((struct SUpnpSubscriptionRequest *)p)->m_UDN = UpnpString_dup(s);
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_strcpy_UDN(UpnpSubscriptionRequest *p, const char *s)
|
||||
{
|
||||
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_UDN);
|
||||
((struct SUpnpSubscriptionRequest *)p)->m_UDN = UpnpString_new();
|
||||
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_UDN, s);
|
||||
}
|
||||
|
||||
|
||||
const UpnpString *UpnpSubscriptionRequest_get_SID(const UpnpSubscriptionRequest *p)
|
||||
{
|
||||
return ((struct SUpnpSubscriptionRequest *)p)->m_SID;
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_set_SID(UpnpSubscriptionRequest *p, const UpnpString *s)
|
||||
{
|
||||
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_SID);
|
||||
((struct SUpnpSubscriptionRequest *)p)->m_SID = UpnpString_dup(s);
|
||||
}
|
||||
|
||||
|
||||
void UpnpSubscriptionRequest_strcpy_SID(UpnpSubscriptionRequest *p, const char *s)
|
||||
{
|
||||
UpnpString_delete(((struct SUpnpSubscriptionRequest *)p)->m_SID);
|
||||
((struct SUpnpSubscriptionRequest *)p)->m_SID = UpnpString_new();
|
||||
UpnpString_set_String(((struct SUpnpSubscriptionRequest *)p)->m_SID, s);
|
||||
}
|
||||
|
@ -2572,14 +2572,14 @@ UpnpNotifyExt( IN UpnpDevice_Handle Hnd,
|
||||
* Return Values: int
|
||||
* UPNP_E_SUCCESS if successful else sends appropriate error.
|
||||
***************************************************************************/
|
||||
int
|
||||
UpnpAcceptSubscription( IN UpnpDevice_Handle Hnd,
|
||||
IN const char *DevID_const,
|
||||
IN const char *ServName_const,
|
||||
IN const char **VarName_const,
|
||||
IN const char **NewVal_const,
|
||||
int cVariables,
|
||||
IN Upnp_SID SubsId )
|
||||
int UpnpAcceptSubscription(
|
||||
IN UpnpDevice_Handle Hnd,
|
||||
IN const char *DevID_const,
|
||||
IN const char *ServName_const,
|
||||
IN const char **VarName_const,
|
||||
IN const char **NewVal_const,
|
||||
int cVariables,
|
||||
IN const Upnp_SID SubsId)
|
||||
{
|
||||
struct Handle_Info *SInfo = NULL;
|
||||
int retVal;
|
||||
|
@ -433,35 +433,15 @@ genaNotifyThread( IN void *input )
|
||||
HandleUnlock();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function : genaInitNotify
|
||||
*
|
||||
* Parameters :
|
||||
* IN UpnpDevice_Handle device_handle : Device handle
|
||||
* IN char *UDN : Device udn
|
||||
* IN char *servId : Service ID
|
||||
* IN char **VarNames : Array of variable names
|
||||
* IN char **VarValues : Array of variable values
|
||||
* IN int var_count : array size
|
||||
* IN Upnp_SID sid : subscription ID
|
||||
*
|
||||
* Description : This function sends the intial state table dump to
|
||||
* newly subscribed control point.
|
||||
*
|
||||
* Return : int
|
||||
* returns GENA_E_SUCCESS if successful else returns appropriate error
|
||||
*
|
||||
* Note : No other event will be sent to this control point before the
|
||||
* intial state table dump.
|
||||
****************************************************************************/
|
||||
int
|
||||
genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN char **VarNames,
|
||||
IN char **VarValues,
|
||||
IN int var_count,
|
||||
IN Upnp_SID sid )
|
||||
|
||||
int genaInitNotify(
|
||||
IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN char **VarNames,
|
||||
IN char **VarValues,
|
||||
IN int var_count,
|
||||
IN const Upnp_SID sid)
|
||||
{
|
||||
char *UDN_copy = NULL;
|
||||
char *servId_copy = NULL;
|
||||
@ -523,12 +503,12 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
return GENA_E_BAD_SERVICE;
|
||||
}
|
||||
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ",
|
||||
UDN, servId );
|
||||
UDN, servId);
|
||||
|
||||
if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) ||
|
||||
( sub->active ) ) {
|
||||
sub = GetSubscriptionSID(sid, service);
|
||||
if (sub == NULL || sub->active) {
|
||||
free( UDN_copy );
|
||||
free( reference_count );
|
||||
free( servId_copy );
|
||||
@ -625,32 +605,13 @@ genaInitNotify( IN UpnpDevice_Handle device_handle,
|
||||
return return_code;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function : genaInitNotifyExt
|
||||
*
|
||||
* Parameters :
|
||||
* IN UpnpDevice_Handle device_handle : Device handle
|
||||
* IN char *UDN : Device udn
|
||||
* IN char *servId : Service ID
|
||||
* IN IXML_Document *PropSet : Document of the state table
|
||||
* IN Upnp_SID sid : subscription ID
|
||||
*
|
||||
* Description : This function is similar to the genaInitNofity. The only
|
||||
* difference is that it takes the xml document for the state table and
|
||||
* sends the intial state table dump to newly subscribed control point.
|
||||
*
|
||||
* Return : int
|
||||
* returns GENA_E_SUCCESS if successful else returns appropriate error
|
||||
*
|
||||
* Note : No other event will be sent to this control point before the
|
||||
* intial state table dump.
|
||||
****************************************************************************/
|
||||
int
|
||||
genaInitNotifyExt( IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN IXML_Document * PropSet,
|
||||
IN Upnp_SID sid )
|
||||
|
||||
int genaInitNotifyExt(
|
||||
IN UpnpDevice_Handle device_handle,
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN IXML_Document *PropSet,
|
||||
IN const Upnp_SID sid)
|
||||
{
|
||||
char *UDN_copy = NULL;
|
||||
char *servId_copy = NULL;
|
||||
@ -1281,196 +1242,198 @@ create_url_list( IN memptr * url_list,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function : gena_process_subscription_request
|
||||
*
|
||||
* Parameters :
|
||||
* IN SOCKINFO *info : socket info of the device
|
||||
* IN http_message_t* request : SUBSCRIPTION request from the control
|
||||
* point
|
||||
*
|
||||
* Description : This function handles a subscription request from a
|
||||
* ctrl point. The socket is not closed on return.
|
||||
*
|
||||
* Return : void
|
||||
*
|
||||
* Note :
|
||||
****************************************************************************/
|
||||
void
|
||||
gena_process_subscription_request( IN SOCKINFO * info,
|
||||
IN http_message_t * request )
|
||||
* Function: gena_process_subscription_request
|
||||
*
|
||||
* Parameters:
|
||||
* IN SOCKINFO *info: socket info of the device
|
||||
* IN http_message_t* request:
|
||||
* SUBSCRIPTION request from the control point
|
||||
*
|
||||
* Description: This function handles a subscription request from a
|
||||
* ctrl point. The socket is not closed on return.
|
||||
*
|
||||
* Return: void
|
||||
****************************************************************************/
|
||||
void gena_process_subscription_request(
|
||||
IN SOCKINFO *info,
|
||||
IN http_message_t *request)
|
||||
{
|
||||
Upnp_SID temp_sid;
|
||||
int return_code = 1;
|
||||
int time_out = 1801;
|
||||
service_info *service;
|
||||
struct Upnp_Subscription_Request request_struct;
|
||||
subscription *sub;
|
||||
uuid_upnp uid;
|
||||
struct Handle_Info *handle_info;
|
||||
void *cookie;
|
||||
Upnp_FunPtr callback_fun;
|
||||
UpnpDevice_Handle device_handle;
|
||||
memptr nt_hdr;
|
||||
char *event_url_path = NULL;
|
||||
memptr callback_hdr;
|
||||
memptr timeout_hdr;
|
||||
UpnpSubscriptionRequest *request_struct = UpnpSubscriptionRequest_new();
|
||||
Upnp_SID temp_sid;
|
||||
int return_code = 1;
|
||||
int time_out = 1801;
|
||||
service_info *service;
|
||||
subscription *sub;
|
||||
uuid_upnp uid;
|
||||
struct Handle_Info *handle_info;
|
||||
void *cookie;
|
||||
Upnp_FunPtr callback_fun;
|
||||
UpnpDevice_Handle device_handle;
|
||||
memptr nt_hdr;
|
||||
char *event_url_path = NULL;
|
||||
memptr callback_hdr;
|
||||
memptr timeout_hdr;
|
||||
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request Received:\n" );
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request Received:\n");
|
||||
|
||||
if( httpmsg_find_hdr( request, HDR_NT, &nt_hdr ) == NULL ) {
|
||||
error_respond( info, HTTP_BAD_REQUEST, request );
|
||||
return;
|
||||
}
|
||||
if (httpmsg_find_hdr(request, HDR_NT, &nt_hdr) == NULL) {
|
||||
error_respond(info, HTTP_BAD_REQUEST, request);
|
||||
goto exit_function;
|
||||
}
|
||||
|
||||
// check NT header
|
||||
//Windows Millenium Interoperability:
|
||||
//we accept either upnp:event, or upnp:propchange for the NT header
|
||||
if( memptr_cmp_nocase( &nt_hdr, "upnp:event" ) != 0 ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||
return;
|
||||
}
|
||||
// check NT header
|
||||
// Windows Millenium Interoperability:
|
||||
// we accept either upnp:event, or upnp:propchange for the NT header
|
||||
if (memptr_cmp_nocase(&nt_hdr, "upnp:event") != 0) {
|
||||
error_respond(info, HTTP_PRECONDITION_FAILED, request);
|
||||
goto exit_function;
|
||||
}
|
||||
|
||||
// if a SID is present then the we have a bad request
|
||||
// "incompatible headers"
|
||||
if( httpmsg_find_hdr( request, HDR_SID, NULL ) != NULL ) {
|
||||
error_respond( info, HTTP_BAD_REQUEST, request );
|
||||
return;
|
||||
}
|
||||
//look up service by eventURL
|
||||
if( ( event_url_path = str_alloc( request->uri.pathquery.buff,
|
||||
request->uri.pathquery.size ) ) ==
|
||||
NULL ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
return;
|
||||
}
|
||||
// if a SID is present then the we have a bad request "incompatible headers"
|
||||
if (httpmsg_find_hdr(request, HDR_SID, NULL) != NULL) {
|
||||
error_respond(info, HTTP_BAD_REQUEST, request);
|
||||
goto exit_function;
|
||||
}
|
||||
// look up service by eventURL
|
||||
event_url_path = str_alloc(request->uri.pathquery.buff, request->uri.pathquery.size);
|
||||
if (event_url_path == NULL) {
|
||||
error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request);
|
||||
goto exit_function;
|
||||
}
|
||||
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"SubscriptionRequest for event URL path: %s\n",
|
||||
event_url_path );
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"SubscriptionRequest for event URL path: %s\n",
|
||||
event_url_path);
|
||||
|
||||
HandleLock();
|
||||
HandleLock();
|
||||
|
||||
// CURRENTLY, ONLY ONE DEVICE
|
||||
if( GetDeviceHandleInfo( info->foreign_sockaddr.ss_family ,
|
||||
&device_handle, &handle_info ) != HND_DEVICE ) {
|
||||
free( event_url_path );
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
service = FindServiceEventURLPath( &handle_info->ServiceTable,
|
||||
event_url_path );
|
||||
free( event_url_path );
|
||||
// CURRENTLY, ONLY ONE DEVICE
|
||||
if (GetDeviceHandleInfo(info->foreign_sockaddr.ss_family ,
|
||||
&device_handle, &handle_info) != HND_DEVICE) {
|
||||
free(event_url_path);
|
||||
error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
service = FindServiceEventURLPath(&handle_info->ServiceTable, event_url_path);
|
||||
free(event_url_path);
|
||||
|
||||
if( service == NULL || !service->active ) {
|
||||
error_respond( info, HTTP_NOT_FOUND, request );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
if (service == NULL || !service->active) {
|
||||
error_respond(info, HTTP_NOT_FOUND, request);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
|
||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request: Number of Subscriptions already %d\n "
|
||||
"Max Subscriptions allowed: %d\n",
|
||||
service->TotalSubscriptions,
|
||||
handle_info->MaxSubscriptions );
|
||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__,
|
||||
"Subscription Request: Number of Subscriptions already %d\n "
|
||||
"Max Subscriptions allowed: %d\n",
|
||||
service->TotalSubscriptions,
|
||||
handle_info->MaxSubscriptions);
|
||||
|
||||
// too many subscriptions
|
||||
if( handle_info->MaxSubscriptions != -1 &&
|
||||
service->TotalSubscriptions >= handle_info->MaxSubscriptions ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
// generate new subscription
|
||||
sub = ( subscription * ) malloc( sizeof( subscription ) );
|
||||
if( sub == NULL ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
sub->eventKey = 0;
|
||||
sub->ToSendEventKey = 0;
|
||||
sub->active = 0;
|
||||
sub->next = NULL;
|
||||
sub->DeliveryURLs.size = 0;
|
||||
sub->DeliveryURLs.URLs = NULL;
|
||||
sub->DeliveryURLs.parsedURLs = NULL;
|
||||
// too many subscriptions
|
||||
if (handle_info->MaxSubscriptions != -1 &&
|
||||
service->TotalSubscriptions >= handle_info->MaxSubscriptions) {
|
||||
error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
// generate new subscription
|
||||
sub = (subscription *)malloc(sizeof (subscription));
|
||||
if (sub == NULL) {
|
||||
error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
sub->eventKey = 0;
|
||||
sub->ToSendEventKey = 0;
|
||||
sub->active = 0;
|
||||
sub->next = NULL;
|
||||
sub->DeliveryURLs.size = 0;
|
||||
sub->DeliveryURLs.URLs = NULL;
|
||||
sub->DeliveryURLs.parsedURLs = NULL;
|
||||
|
||||
// check for valid callbacks
|
||||
if( httpmsg_find_hdr( request, HDR_CALLBACK, &callback_hdr ) == NULL ||
|
||||
( return_code = create_url_list( &callback_hdr,
|
||||
&sub->DeliveryURLs ) ) == 0 ) {
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||
freeSubscriptionList( sub );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
if( return_code == UPNP_E_OUTOF_MEMORY ) {
|
||||
error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
|
||||
freeSubscriptionList( sub );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
// set the timeout
|
||||
if( httpmsg_find_hdr( request, HDR_TIMEOUT, &timeout_hdr ) != NULL ) {
|
||||
if( matchstr( timeout_hdr.buf, timeout_hdr.length,
|
||||
"%iSecond-%d%0", &time_out ) == PARSE_OK ) {
|
||||
// nothing
|
||||
} else if( memptr_cmp_nocase( &timeout_hdr, "Second-infinite" ) ==
|
||||
0 ) {
|
||||
time_out = -1; // infinite timeout
|
||||
} else {
|
||||
time_out = DEFAULT_TIMEOUT; // default is > 1800 seconds
|
||||
}
|
||||
}
|
||||
// replace infinite timeout with max timeout, if possible
|
||||
if( handle_info->MaxSubscriptionTimeOut != -1 ) {
|
||||
if( time_out == -1 ||
|
||||
time_out > handle_info->MaxSubscriptionTimeOut ) {
|
||||
time_out = handle_info->MaxSubscriptionTimeOut;
|
||||
}
|
||||
}
|
||||
if( time_out >= 0 ) {
|
||||
sub->expireTime = time( NULL ) + time_out;
|
||||
} else {
|
||||
sub->expireTime = 0; // infinite time
|
||||
}
|
||||
// check for valid callbacks
|
||||
if (httpmsg_find_hdr( request, HDR_CALLBACK, &callback_hdr) == NULL) {
|
||||
error_respond(info, HTTP_PRECONDITION_FAILED, request);
|
||||
freeSubscriptionList(sub);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
return_code = create_url_list(&callback_hdr, &sub->DeliveryURLs);
|
||||
if (return_code == 0) {
|
||||
error_respond(info, HTTP_PRECONDITION_FAILED, request);
|
||||
freeSubscriptionList(sub);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
if (return_code == UPNP_E_OUTOF_MEMORY) {
|
||||
error_respond(info, HTTP_INTERNAL_SERVER_ERROR, request);
|
||||
freeSubscriptionList(sub);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
// set the timeout
|
||||
if (httpmsg_find_hdr(request, HDR_TIMEOUT, &timeout_hdr) != NULL) {
|
||||
if (matchstr(timeout_hdr.buf, timeout_hdr.length,
|
||||
"%iSecond-%d%0", &time_out) == PARSE_OK) {
|
||||
// nothing
|
||||
} else if(memptr_cmp_nocase(&timeout_hdr, "Second-infinite") == 0) {
|
||||
// infinite timeout
|
||||
time_out = -1;
|
||||
} else {
|
||||
// default is > 1800 seconds
|
||||
time_out = DEFAULT_TIMEOUT;
|
||||
}
|
||||
}
|
||||
// replace infinite timeout with max timeout, if possible
|
||||
if (handle_info->MaxSubscriptionTimeOut != -1) {
|
||||
if (time_out == -1 ||
|
||||
time_out > handle_info->MaxSubscriptionTimeOut) {
|
||||
time_out = handle_info->MaxSubscriptionTimeOut;
|
||||
}
|
||||
}
|
||||
if (time_out >= 0) {
|
||||
sub->expireTime = time(NULL) + time_out;
|
||||
} else {
|
||||
// infinite time
|
||||
sub->expireTime = 0;
|
||||
}
|
||||
|
||||
//generate SID
|
||||
uuid_create( &uid );
|
||||
uuid_unpack( &uid, temp_sid );
|
||||
sprintf( sub->sid, "uuid:%s", temp_sid );
|
||||
// generate SID
|
||||
uuid_create(&uid);
|
||||
uuid_unpack(&uid, temp_sid);
|
||||
sprintf(sub->sid, "uuid:%s", temp_sid);
|
||||
|
||||
// respond OK
|
||||
if( respond_ok( info, time_out, sub, request ) != UPNP_E_SUCCESS ) {
|
||||
freeSubscriptionList( sub );
|
||||
HandleUnlock();
|
||||
return;
|
||||
}
|
||||
//add to subscription list
|
||||
sub->next = service->subscriptionList;
|
||||
service->subscriptionList = sub;
|
||||
service->TotalSubscriptions++;
|
||||
// respond OK
|
||||
if (respond_ok(info, time_out, sub, request) != UPNP_E_SUCCESS) {
|
||||
freeSubscriptionList(sub);
|
||||
HandleUnlock();
|
||||
goto exit_function;
|
||||
}
|
||||
// add to subscription list
|
||||
sub->next = service->subscriptionList;
|
||||
service->subscriptionList = sub;
|
||||
service->TotalSubscriptions++;
|
||||
|
||||
//finally generate callback for init table dump
|
||||
request_struct.ServiceId = service->serviceId;
|
||||
request_struct.UDN = service->UDN;
|
||||
strcpy( ( char * )request_struct.Sid, sub->sid );
|
||||
// finally generate callback for init table dump
|
||||
UpnpSubscriptionRequest_strcpy_ServiceId(request_struct, service->serviceId);
|
||||
UpnpSubscriptionRequest_strcpy_UDN(request_struct, service->UDN);
|
||||
UpnpSubscriptionRequest_strcpy_SID(request_struct, sub->sid);
|
||||
|
||||
//copy callback
|
||||
callback_fun = handle_info->Callback;
|
||||
cookie = handle_info->Cookie;
|
||||
// copy callback
|
||||
callback_fun = handle_info->Callback;
|
||||
cookie = handle_info->Cookie;
|
||||
|
||||
HandleUnlock();
|
||||
HandleUnlock();
|
||||
|
||||
//make call back with request struct
|
||||
//in the future should find a way of mainting
|
||||
//that the handle is not unregistered in the middle of a
|
||||
//callback
|
||||
// make call back with request struct
|
||||
// in the future should find a way of mainting that the handle
|
||||
// is not unregistered in the middle of a callback
|
||||
callback_fun(UPNP_EVENT_SUBSCRIPTION_REQUEST, request_struct, cookie);
|
||||
|
||||
callback_fun( UPNP_EVENT_SUBSCRIPTION_REQUEST,
|
||||
&request_struct, cookie );
|
||||
exit_function:
|
||||
UpnpSubscriptionRequest_delete(request_struct);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -1666,7 +1629,6 @@ gena_process_unsubscribe_request( IN SOCKINFO * info,
|
||||
// validate service
|
||||
if( service == NULL ||
|
||||
!service->active || GetSubscriptionSID( sid, service ) == NULL )
|
||||
//CheckSubscriptionSID(sid, service) == NULL )
|
||||
{
|
||||
error_respond( info, HTTP_PRECONDITION_FAILED, request );
|
||||
HandleUnlock();
|
||||
|
@ -116,25 +116,8 @@ RemoveSubscriptionSID( Upnp_SID sid,
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : GetSubscriptionSID
|
||||
*
|
||||
* Parameters :
|
||||
* Upnp_SID sid ; subscription ID
|
||||
* service_info * service ; service object providing the list of
|
||||
* subscriptions
|
||||
*
|
||||
* Description : Return the subscription from the service table
|
||||
* that matches const Upnp_SID sid value.
|
||||
*
|
||||
* Return : subscription * - Pointer to the matching subscription
|
||||
* node;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
subscription *
|
||||
GetSubscriptionSID( Upnp_SID sid,
|
||||
service_info * service )
|
||||
|
||||
subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service)
|
||||
{
|
||||
subscription *next = service->subscriptionList;
|
||||
subscription *previous = NULL;
|
||||
@ -169,31 +152,15 @@ GetSubscriptionSID( Upnp_SID sid,
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : GetNextSubscription
|
||||
*
|
||||
* Parameters :
|
||||
* service_info * service ; service object providing the list of
|
||||
* subscriptions
|
||||
* subscription *current ; current subscription object
|
||||
*
|
||||
* Description : Get current and valid subscription from the service
|
||||
* table.
|
||||
*
|
||||
* Return : subscription * - Pointer to the next subscription node;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
subscription *
|
||||
GetNextSubscription( service_info * service,
|
||||
subscription * current )
|
||||
|
||||
subscription *GetNextSubscription(service_info *service, subscription *current)
|
||||
{
|
||||
time_t current_time;
|
||||
subscription *next = NULL;
|
||||
subscription *previous = NULL;
|
||||
int notDone = 1;
|
||||
|
||||
//get the current_time
|
||||
// get the current_time
|
||||
time( ¤t_time );
|
||||
while( ( notDone ) && ( current ) ) {
|
||||
previous = current;
|
||||
@ -218,52 +185,26 @@ GetNextSubscription( service_info * service,
|
||||
return next;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : GetFirstSubscription
|
||||
*
|
||||
* Parameters :
|
||||
* service_info *service ; service object providing the list of
|
||||
* subscriptions
|
||||
*
|
||||
* Description : Gets pointer to the first subscription node in the
|
||||
* service table.
|
||||
*
|
||||
* Return : subscription * - pointer to the first subscription node ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
subscription *
|
||||
GetFirstSubscription( service_info * service )
|
||||
{
|
||||
subscription temp;
|
||||
subscription *next = NULL;
|
||||
|
||||
temp.next = service->subscriptionList;
|
||||
next = GetNextSubscription( service, &temp );
|
||||
service->subscriptionList = temp.next;
|
||||
// service->subscriptionList=next;
|
||||
return next;
|
||||
subscription *GetFirstSubscription(service_info *service)
|
||||
{
|
||||
subscription temp;
|
||||
subscription *next = NULL;
|
||||
|
||||
temp.next = service->subscriptionList;
|
||||
next = GetNextSubscription(service, &temp);
|
||||
service->subscriptionList = temp.next;
|
||||
// service->subscriptionList = next;
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function : freeSubscription
|
||||
*
|
||||
* Parameters :
|
||||
* subscription * sub ; subscription to be freed
|
||||
*
|
||||
* Description : Free's the memory allocated for storing the URL of
|
||||
* the subscription.
|
||||
*
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void
|
||||
freeSubscription( subscription * sub )
|
||||
|
||||
void freeSubscription(subscription *sub)
|
||||
{
|
||||
if( sub ) {
|
||||
free_URL_list( &sub->DeliveryURLs );
|
||||
}
|
||||
if (sub) {
|
||||
free_URL_list(&sub->DeliveryURLs);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
@ -302,10 +302,10 @@ EXTERN_C int genaNotifyAll(
|
||||
* Function: genaNotifyAllExt
|
||||
*
|
||||
* Parameters:
|
||||
* IN UpnpDevice_Handle device_handle: Device handle
|
||||
* IN char *UDN: Device udn
|
||||
* IN char *servId: Service ID
|
||||
* IN IXML_Document *PropSet: XML document Event varible property set
|
||||
* IN UpnpDevice_Handle device_handle: Device handle
|
||||
* IN char *UDN: Device udn
|
||||
* IN char *servId: Service ID
|
||||
* IN IXML_Document *PropSet: XML document Event varible property set
|
||||
*
|
||||
* Description : This function sends a notification to all the subscribed
|
||||
* control points
|
||||
@ -328,13 +328,13 @@ EXTERN_C int genaNotifyAllExt(
|
||||
* Function: genaInitNotify
|
||||
*
|
||||
* Parameters:
|
||||
* IN UpnpDevice_Handle device_handle: Device handle
|
||||
* IN char *UDN: Device udn
|
||||
* IN char *servId: Service ID
|
||||
* IN char **VarNames: Array of variable names
|
||||
* IN char **VarValues: Array of variable values
|
||||
* IN int var_count: array size
|
||||
* IN Upnp_SID sid: subscription ID
|
||||
* IN UpnpDevice_Handle device_handle: Device handle
|
||||
* IN char *UDN: Device udn
|
||||
* IN char *servId: Service ID
|
||||
* IN char **VarNames: Array of variable names
|
||||
* IN char **VarValues: Array of variable values
|
||||
* IN int var_count: array size
|
||||
* IN Upnp_SID sid: subscription ID
|
||||
*
|
||||
* Description: This function sends the intial state table dump to
|
||||
* newly subscribed control point.
|
||||
@ -352,29 +352,30 @@ EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
|
||||
IN char **VarNames,
|
||||
IN char **VarValues,
|
||||
IN int var_count,
|
||||
IN Upnp_SID sid);
|
||||
IN const Upnp_SID sid);
|
||||
#endif /* INCLUDE_DEVICE_APIS */
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function : genaInitNotifyExt
|
||||
* Function: genaInitNotifyExt
|
||||
*
|
||||
* Parameters :
|
||||
* IN UpnpDevice_Handle device_handle : Device handle
|
||||
* IN char *UDN : Device udn
|
||||
* IN char *servId : Service ID
|
||||
* IN IXML_Document *PropSet : Document of the state table
|
||||
* IN Upnp_SID sid : subscription ID
|
||||
* Parameters :
|
||||
* IN UpnpDevice_Handle device_handle: Device handle
|
||||
* IN char *UDN: Device udn
|
||||
* IN char *servId: Service ID
|
||||
* IN IXML_Document *PropSet: Document of the state table
|
||||
* IN Upnp_SID sid: subscription ID
|
||||
*
|
||||
* Description : This function is similar to the genaInitNofity. The only
|
||||
* Description:
|
||||
* This function is similar to the genaInitNofity. The only
|
||||
* difference is that it takes the xml document for the state table and
|
||||
* sends the intial state table dump to newly subscribed control point.
|
||||
*
|
||||
* Return : int
|
||||
* returns GENA_E_SUCCESS if successful else returns appropriate error
|
||||
* Return: int
|
||||
* returns GENA_E_SUCCESS if successful else returns appropriate error
|
||||
*
|
||||
* Note : No other event will be sent to this control point before the
|
||||
* intial state table dump.
|
||||
* Note: No other event will be sent to this control point before the
|
||||
* intial state table dump.
|
||||
****************************************************************************/
|
||||
#ifdef INCLUDE_DEVICE_APIS
|
||||
EXTERN_C int genaInitNotifyExt(
|
||||
@ -382,7 +383,7 @@ EXTERN_C int genaInitNotifyExt(
|
||||
IN char *UDN,
|
||||
IN char *servId,
|
||||
IN IXML_Document *PropSet,
|
||||
IN Upnp_SID sid);
|
||||
IN const Upnp_SID sid);
|
||||
#endif /* INCLUDE_DEVICE_APIS */
|
||||
|
||||
|
||||
|
@ -118,46 +118,48 @@ int copy_subscription(subscription *in, subscription *out);
|
||||
void RemoveSubscriptionSID(Upnp_SID sid, service_info * service);
|
||||
|
||||
/************************************************************************
|
||||
* Function : GetSubscriptionSID
|
||||
*
|
||||
* Parameters :
|
||||
* Upnp_SID sid ; subscription ID
|
||||
* service_info * service ; service object providing the list of
|
||||
* subscriptions
|
||||
*
|
||||
* Description : Return the subscription from the service table
|
||||
* that matches const Upnp_SID sid value.
|
||||
*
|
||||
* Return : subscription * - Pointer to the matching subscription
|
||||
* node;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
subscription * GetSubscriptionSID(Upnp_SID sid,service_info * service);
|
||||
* Function: GetSubscriptionSID
|
||||
*
|
||||
* Parameters:
|
||||
* const Upnp_SID sid: subscription ID
|
||||
* const service_info *service: service object providing the list of
|
||||
* subscriptions
|
||||
*
|
||||
* Description : Return the subscription from the service table
|
||||
* that matches const Upnp_SID sid value.
|
||||
*
|
||||
* Return: subscription *: Pointer to the matching subscription node;
|
||||
************************************************************************/
|
||||
subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service);
|
||||
|
||||
//returns a pointer to the subscription with the SID, NULL if not found
|
||||
|
||||
subscription * CheckSubscriptionSID(Upnp_SID sid,service_info * service);
|
||||
|
||||
//returns a pointer to the first subscription
|
||||
subscription * GetFirstSubscription(service_info *service);
|
||||
/************************************************************************
|
||||
* Function: GetFirstSubscription
|
||||
*
|
||||
* Parameters:
|
||||
* service_info *service: service object providing the list of
|
||||
* subscriptions
|
||||
*
|
||||
* Description: Gets pointer to the first subscription node in the
|
||||
* service table.
|
||||
*
|
||||
* Return: subscription *: pointer to the first subscription node
|
||||
************************************************************************/
|
||||
subscription *GetFirstSubscription(service_info *service);
|
||||
|
||||
/************************************************************************
|
||||
* Function : GetNextSubscription
|
||||
*
|
||||
* Parameters :
|
||||
* service_info * service ; service object providing the list of
|
||||
* subscriptions
|
||||
* subscription *current ; current subscription object
|
||||
*
|
||||
* Description : Get current and valid subscription from the service
|
||||
* table.
|
||||
*
|
||||
* Return : subscription * - Pointer to the next subscription node;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
subscription * GetNextSubscription(service_info * service, subscription *current);
|
||||
* Function: GetNextSubscription
|
||||
*
|
||||
* Parameters:
|
||||
* service_info *service: service object providing the list of
|
||||
* subscriptions
|
||||
* subscription *current: current subscription object
|
||||
*
|
||||
* Description: Get current and valid subscription from the service
|
||||
* table.
|
||||
*
|
||||
* Return: subscription *: pointer to the next subscription node
|
||||
************************************************************************/
|
||||
subscription *GetNextSubscription(service_info *service, subscription *current);
|
||||
|
||||
/************************************************************************
|
||||
* Function : freeSubscription
|
||||
@ -172,7 +174,7 @@ subscription * GetNextSubscription(service_info * service, subscription *current
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void freeSubscription(subscription * sub);
|
||||
void freeSubscription(subscription *sub);
|
||||
|
||||
/************************************************************************
|
||||
* Function : freeSubscriptionList
|
||||
|
Loading…
x
Reference in New Issue
Block a user