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