Tempplat object for ClientSubscription.
This commit is contained in:
parent
9e77129b87
commit
549ac300f7
@ -131,7 +131,7 @@ static int ScheduleGenaAutoRenew(
|
||||
/*! [in] The time out value of the subscription. */
|
||||
IN int TimeOut,
|
||||
/*! [in] Subscription being renewed. */
|
||||
IN ClientSubscription *sub)
|
||||
IN GenlibClientSubscription *sub)
|
||||
{
|
||||
UpnpEventSubscribe *RenewEventStruct = NULL;
|
||||
upnp_timeout *RenewEvent = NULL;
|
||||
@ -398,7 +398,7 @@ static int gena_subscribe(
|
||||
|
||||
int genaUnregisterClient(UpnpClient_Handle client_handle)
|
||||
{
|
||||
ClientSubscription *sub_copy = GenlibClientSubscription_new();
|
||||
GenlibClientSubscription *sub_copy = GenlibClientSubscription_new();
|
||||
int return_code = UPNP_E_SUCCESS;
|
||||
struct Handle_Info *handle_info = NULL;
|
||||
http_parser_t response;
|
||||
@ -446,10 +446,10 @@ int genaUnSubscribe(
|
||||
UpnpClient_Handle client_handle,
|
||||
const UpnpString *in_sid)
|
||||
{
|
||||
ClientSubscription *sub = NULL;
|
||||
GenlibClientSubscription *sub = NULL;
|
||||
int return_code = GENA_SUCCESS;
|
||||
struct Handle_Info *handle_info;
|
||||
ClientSubscription *sub_copy = GenlibClientSubscription_new();
|
||||
GenlibClientSubscription *sub_copy = GenlibClientSubscription_new();
|
||||
http_parser_t response;
|
||||
|
||||
// validate handle and sid
|
||||
@ -501,7 +501,7 @@ int genaSubscribe(
|
||||
UpnpString *out_sid)
|
||||
{
|
||||
int return_code = GENA_SUCCESS;
|
||||
ClientSubscription *newSubscription = GenlibClientSubscription_new();
|
||||
GenlibClientSubscription *newSubscription = GenlibClientSubscription_new();
|
||||
uuid_upnp uid;
|
||||
Upnp_SID temp_sid;
|
||||
Upnp_SID temp_sid2;
|
||||
@ -582,8 +582,8 @@ int genaRenewSubscription(
|
||||
int *TimeOut)
|
||||
{
|
||||
int return_code = GENA_SUCCESS;
|
||||
ClientSubscription *sub = NULL;
|
||||
ClientSubscription *sub_copy = GenlibClientSubscription_new();
|
||||
GenlibClientSubscription *sub = NULL;
|
||||
GenlibClientSubscription *sub_copy = GenlibClientSubscription_new();
|
||||
struct Handle_Info *handle_info;
|
||||
UpnpString *ActualSID = UpnpString_new();
|
||||
ThreadPoolJob tempJob;
|
||||
@ -682,7 +682,7 @@ void gena_process_notification_event(
|
||||
IXML_Document *ChangedVars = NULL;
|
||||
int eventKey;
|
||||
token sid;
|
||||
ClientSubscription *subscription = NULL;
|
||||
GenlibClientSubscription *subscription = NULL;
|
||||
struct Handle_Info *handle_info;
|
||||
void *cookie;
|
||||
Upnp_FunPtr callback;
|
||||
|
@ -1,200 +1,18 @@
|
||||
|
||||
/************************************************************************
|
||||
* Purpose: This file defines the functions for clients. It defines
|
||||
* functions for adding and removing clients to and from the client table,
|
||||
* adding and accessing subscription and other attributes pertaining to the
|
||||
* client
|
||||
************************************************************************/
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*
|
||||
* \brief GenlibClientSubscription object implementation.
|
||||
*
|
||||
* \author Marcelo Roberto Jimenez
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "ClientSubscription.h"
|
||||
|
||||
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
|
||||
#define TEMPLATE_GENERATE_SOURCE
|
||||
#include "ClientSubscription.h"
|
||||
|
||||
#include <stdlib.h> // for calloc(), free()
|
||||
|
||||
|
||||
struct SClientSubscription {
|
||||
int m_renewEventId;
|
||||
UpnpString *m_SID;
|
||||
UpnpString *m_actualSID;
|
||||
UpnpString *m_eventURL;
|
||||
struct SClientSubscription *m_next;
|
||||
};
|
||||
|
||||
|
||||
ClientSubscription *GenlibClientSubscription_new()
|
||||
{
|
||||
struct SClientSubscription *p = calloc(1, sizeof (struct SClientSubscription));
|
||||
#if 0
|
||||
p->renewEventId = 0;
|
||||
#endif
|
||||
p->m_SID = UpnpString_new();
|
||||
p->m_actualSID = UpnpString_new();
|
||||
p->m_eventURL = UpnpString_new();
|
||||
p->m_next = NULL;
|
||||
|
||||
return (ClientSubscription *)p;
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_delete(ClientSubscription *p)
|
||||
{
|
||||
struct SClientSubscription *q = (struct SClientSubscription *)p;
|
||||
|
||||
if (!q) return;
|
||||
|
||||
q->m_renewEventId = 0;
|
||||
|
||||
UpnpString_delete(q->m_SID);
|
||||
q->m_SID = NULL;
|
||||
|
||||
UpnpString_delete(q->m_actualSID);
|
||||
q->m_actualSID = NULL;
|
||||
|
||||
UpnpString_delete(q->m_eventURL);
|
||||
q->m_eventURL = NULL;
|
||||
|
||||
q->m_next = NULL;
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
ClientSubscription *GenlibClientSubscription_dup(const ClientSubscription *p)
|
||||
{
|
||||
ClientSubscription *q = GenlibClientSubscription_new();
|
||||
|
||||
GenlibClientSubscription_assign(q, p);
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_assign(ClientSubscription *q, const ClientSubscription *p)
|
||||
{
|
||||
if (q != p) {
|
||||
/*struct SClientSubscription *_p = (struct SClientSubscription *)p;*/
|
||||
struct SClientSubscription *_q = (struct SClientSubscription *)q;
|
||||
// Do not copy RenewEventId
|
||||
_q->m_renewEventId = -1;
|
||||
GenlibClientSubscription_set_SID(q, GenlibClientSubscription_get_SID(p));
|
||||
GenlibClientSubscription_set_ActualSID(q, GenlibClientSubscription_get_ActualSID(p));
|
||||
GenlibClientSubscription_set_EventURL(q, GenlibClientSubscription_get_EventURL(p));
|
||||
// Do not copy m_next
|
||||
_q->m_next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GenlibClientSubscription_get_RenewEventId(const ClientSubscription *p)
|
||||
{
|
||||
return ((struct SClientSubscription *)p)->m_renewEventId;
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_set_RenewEventId(ClientSubscription *p, int n)
|
||||
{
|
||||
((struct SClientSubscription *)p)->m_renewEventId = n;
|
||||
}
|
||||
|
||||
|
||||
const UpnpString *GenlibClientSubscription_get_SID(const ClientSubscription *p)
|
||||
{
|
||||
return ((struct SClientSubscription *)p)->m_SID;
|
||||
}
|
||||
|
||||
const char *GenlibClientSubscription_get_SID_cstr(const ClientSubscription *p)
|
||||
{
|
||||
return UpnpString_get_String(GenlibClientSubscription_get_SID(p));
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_set_SID(ClientSubscription *p, const UpnpString *s)
|
||||
{
|
||||
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
|
||||
((struct SClientSubscription *)p)->m_SID = UpnpString_dup(s);
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_strcpy_SID(ClientSubscription *p, const char *s)
|
||||
{
|
||||
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
|
||||
((struct SClientSubscription *)p)->m_SID = UpnpString_new();
|
||||
UpnpString_set_String(((struct SClientSubscription *)p)->m_SID, s);
|
||||
}
|
||||
|
||||
|
||||
const UpnpString *GenlibClientSubscription_get_ActualSID(const ClientSubscription *p)
|
||||
{
|
||||
return ((struct SClientSubscription *)p)->m_actualSID;
|
||||
}
|
||||
|
||||
|
||||
const char *GenlibClientSubscription_get_ActualSID_cstr(const ClientSubscription *p)
|
||||
{
|
||||
return UpnpString_get_String(GenlibClientSubscription_get_ActualSID(p));
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_set_ActualSID(ClientSubscription *p, const UpnpString *s)
|
||||
{
|
||||
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
|
||||
((struct SClientSubscription *)p)->m_actualSID = UpnpString_dup(s);
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_strcpy_ActualSID(ClientSubscription *p, const char *s)
|
||||
{
|
||||
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
|
||||
((struct SClientSubscription *)p)->m_actualSID = UpnpString_new();
|
||||
UpnpString_set_String(((struct SClientSubscription *)p)->m_actualSID, s);
|
||||
}
|
||||
|
||||
|
||||
const UpnpString *GenlibClientSubscription_get_EventURL(const ClientSubscription *p)
|
||||
{
|
||||
return ((struct SClientSubscription *)p)->m_eventURL;
|
||||
}
|
||||
|
||||
|
||||
const char *GenlibClientSubscription_get_EventURL_cstr(const ClientSubscription *p)
|
||||
{
|
||||
return UpnpString_get_String(GenlibClientSubscription_get_EventURL(p));
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_set_EventURL(ClientSubscription *p, const UpnpString *s)
|
||||
{
|
||||
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
|
||||
((struct SClientSubscription *)p)->m_eventURL = UpnpString_dup(s);
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_strcpy_EventURL(ClientSubscription *p, const char *s)
|
||||
{
|
||||
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
|
||||
((struct SClientSubscription *)p)->m_eventURL = UpnpString_new();
|
||||
UpnpString_set_String(((struct SClientSubscription *)p)->m_eventURL, s);
|
||||
}
|
||||
|
||||
|
||||
ClientSubscription *GenlibClientSubscription_get_Next(const ClientSubscription *p)
|
||||
{
|
||||
return (ClientSubscription *)(((struct SClientSubscription *)p)->m_next);
|
||||
}
|
||||
|
||||
|
||||
void GenlibClientSubscription_set_Next(ClientSubscription *p, ClientSubscription *q)
|
||||
{
|
||||
((struct SClientSubscription *)p)->m_next = (struct SClientSubscription *)q;
|
||||
}
|
||||
|
||||
|
||||
#endif /* INCLUDE_CLIENT_APIS */
|
||||
#endif /* INCLUDE_CLIENT_APIS */
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <stdlib.h> // for calloc(), free()
|
||||
|
||||
|
||||
void free_client_subscription(ClientSubscription *sub)
|
||||
void free_client_subscription(GenlibClientSubscription *sub)
|
||||
{
|
||||
upnp_timeout *event;
|
||||
ThreadPoolJob tempJob;
|
||||
@ -40,9 +40,9 @@ void free_client_subscription(ClientSubscription *sub)
|
||||
}
|
||||
|
||||
|
||||
void freeClientSubList(ClientSubscription *list)
|
||||
void freeClientSubList(GenlibClientSubscription *list)
|
||||
{
|
||||
ClientSubscription *next;
|
||||
GenlibClientSubscription *next;
|
||||
while (list) {
|
||||
free_client_subscription(list);
|
||||
next = GenlibClientSubscription_get_Next(list);
|
||||
@ -52,10 +52,10 @@ void freeClientSubList(ClientSubscription *list)
|
||||
}
|
||||
|
||||
|
||||
void RemoveClientSubClientSID(ClientSubscription **head, const UpnpString *sid)
|
||||
void RemoveClientSubClientSID(GenlibClientSubscription **head, const UpnpString *sid)
|
||||
{
|
||||
ClientSubscription *finger = *head;
|
||||
ClientSubscription *previous = NULL;
|
||||
GenlibClientSubscription *finger = *head;
|
||||
GenlibClientSubscription *previous = NULL;
|
||||
int found = 0;
|
||||
while (finger) {
|
||||
found = !strcmp(
|
||||
@ -79,9 +79,9 @@ void RemoveClientSubClientSID(ClientSubscription **head, const UpnpString *sid)
|
||||
}
|
||||
|
||||
|
||||
ClientSubscription *GetClientSubClientSID(ClientSubscription *head, const UpnpString *sid)
|
||||
GenlibClientSubscription *GetClientSubClientSID(GenlibClientSubscription *head, const UpnpString *sid)
|
||||
{
|
||||
ClientSubscription *next = head;
|
||||
GenlibClientSubscription *next = head;
|
||||
int found = 0;
|
||||
while (next) {
|
||||
found = !strcmp(
|
||||
@ -98,9 +98,9 @@ ClientSubscription *GetClientSubClientSID(ClientSubscription *head, const UpnpSt
|
||||
}
|
||||
|
||||
|
||||
ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
|
||||
GenlibClientSubscription *GetClientSubActualSID(GenlibClientSubscription *head, token *sid)
|
||||
{
|
||||
ClientSubscription *next = head;
|
||||
GenlibClientSubscription *next = head;
|
||||
while (next) {
|
||||
if (!memcmp(
|
||||
GenlibClientSubscription_get_ActualSID_cstr(next),
|
||||
|
@ -1,198 +1,27 @@
|
||||
|
||||
|
||||
#ifndef CLIENTSUBSCRIPTION_H
|
||||
#define CLIENTSUBSCRIPTION_H
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*
|
||||
* \brief GenlibClientSubscription object declararion.
|
||||
*
|
||||
* \author Marcelo Roberto Jimenez
|
||||
*/
|
||||
|
||||
#define CLASS GenlibClientSubscription
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#define EXPAND_CLASS_MEMBERS(CLASS) \
|
||||
EXPAND_CLASS_MEMBER_INT(CLASS, RenewEventId, int) \
|
||||
EXPAND_CLASS_MEMBER_STRING(CLASS, SID) \
|
||||
EXPAND_CLASS_MEMBER_STRING(CLASS, ActualSID) \
|
||||
EXPAND_CLASS_MEMBER_STRING(CLASS, EventURL) \
|
||||
EXPAND_CLASS_MEMBER_INT(CLASS, Next, GenlibClientSubscription *) \
|
||||
|
||||
|
||||
#include "UpnpString.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
|
||||
|
||||
typedef struct s_ClientSubscription ClientSubscription;
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Constructor.
|
||||
*/
|
||||
ClientSubscription *GenlibClientSubscription_new();
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Destructor.
|
||||
*/
|
||||
void GenlibClientSubscription_delete(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Copy Constructor.
|
||||
*/
|
||||
ClientSubscription *GenlibClientSubscription_dup(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Assignment operator.
|
||||
*/
|
||||
void GenlibClientSubscription_assign(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *q,
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
int GenlibClientSubscription_get_RenewEventId(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_set_RenewEventId(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
/*! [in] . */
|
||||
int n);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
const UpnpString *GenlibClientSubscription_get_SID(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
const char *GenlibClientSubscription_get_SID_cstr(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_set_SID(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
const UpnpString *s);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_strcpy_SID(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
const char *s);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
const UpnpString *GenlibClientSubscription_get_ActualSID(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
const char *GenlibClientSubscription_get_ActualSID_cstr(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_set_ActualSID(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
const UpnpString *s);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_strcpy_ActualSID(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
const char *s);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
const UpnpString *GenlibClientSubscription_get_EventURL(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_set_EventURL(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
const UpnpString *s);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_strcpy_EventURL(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
const char *s);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
ClientSubscription *GenlibClientSubscription_get_Next(
|
||||
/*! [in] The \b this pointer. */
|
||||
const ClientSubscription *p);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*/
|
||||
void GenlibClientSubscription_set_Next(
|
||||
/*! [in] The \b this pointer. */
|
||||
ClientSubscription *p,
|
||||
ClientSubscription *q);
|
||||
|
||||
|
||||
#endif /* INCLUDE_CLIENT_APIS */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#include "TemplateInclude.h"
|
||||
|
||||
|
||||
#endif /* CLIENTSUBSCRIPTION_H */
|
||||
|
@ -40,7 +40,7 @@ extern TimerThread gTimerThread;
|
||||
*/
|
||||
void free_client_subscription(
|
||||
/*! [in] Client subscription to be freed. */
|
||||
ClientSubscription *sub);
|
||||
GenlibClientSubscription *sub);
|
||||
|
||||
|
||||
/*!
|
||||
@ -48,7 +48,7 @@ void free_client_subscription(
|
||||
*/
|
||||
void freeClientSubList(
|
||||
/*! [in] Client subscription list to be freed. */
|
||||
ClientSubscription *list);
|
||||
GenlibClientSubscription *list);
|
||||
|
||||
|
||||
/*!
|
||||
@ -58,7 +58,7 @@ void freeClientSubList(
|
||||
*/
|
||||
void RemoveClientSubClientSID(
|
||||
/*! [in] Head of the subscription list. */
|
||||
ClientSubscription **head,
|
||||
GenlibClientSubscription **head,
|
||||
/*! [in] Subscription ID to be mactched. */
|
||||
const UpnpString *sid);
|
||||
|
||||
@ -69,9 +69,9 @@ void RemoveClientSubClientSID(
|
||||
*
|
||||
* \return The matching subscription.
|
||||
*/
|
||||
ClientSubscription *GetClientSubClientSID(
|
||||
GenlibClientSubscription *GetClientSubClientSID(
|
||||
/*! [in] Head of the subscription list. */
|
||||
ClientSubscription *head,
|
||||
GenlibClientSubscription *head,
|
||||
/*! [in] Subscription ID to be mactched. */
|
||||
const UpnpString *sid);
|
||||
|
||||
@ -82,9 +82,9 @@ ClientSubscription *GetClientSubClientSID(
|
||||
*
|
||||
* \return The matching subscription.
|
||||
*/
|
||||
ClientSubscription *GetClientSubActualSID(
|
||||
GenlibClientSubscription *GetClientSubActualSID(
|
||||
/*! [in] Head of the subscription list. */
|
||||
ClientSubscription *head,
|
||||
GenlibClientSubscription *head,
|
||||
/*! [in] Subscription ID to be mactched. */
|
||||
token *sid);
|
||||
|
||||
|
@ -103,7 +103,7 @@ struct Handle_Info
|
||||
/* Client only */
|
||||
#ifdef INCLUDE_CLIENT_APIS
|
||||
/*! Client subscription list. */
|
||||
ClientSubscription *ClientSubList;
|
||||
GenlibClientSubscription *ClientSubList;
|
||||
/*! Active SSDP searches. */
|
||||
LinkedList SsdpSearchList;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user