CyberLink for C

cstatevariable.h File Reference

#include <cybergarage/typedef.h>
#include <cybergarage/xml/cxml.h>
#include <cybergarage/util/clist.h>
#include <cybergarage/util/cstring.h>
#include <cybergarage/upnp/cupnp_status.h>

Data Structures

struct  _CgUpnpAllowedValuesList
struct  _CgUpnpStateVariable

Defines

#define CG_UPNP_STATEVARIABLE_ELEM_NAME   "stateVariable"
#define CG_UPNP_SERVICESTATETALBE_ELEM_NAME   "serviceStateTable"
#define CG_UPNP_STATEVARIABLE_NAME   "name"
#define CG_UPNP_STATEVARIABLE_DATATYPE   "dataType"
#define CG_UPNP_STATEVARIABLE_SENDEVENTS   "sendEvents"
#define CG_UPNP_STATEVARIABLE_SENDEVENTS_YES   "yes"
#define CG_UPNP_STATEVARIABLE_SENDEVENTS_NO   "no"
#define CG_UPNP_STATEVARIABLE_ALLOWEDVALUELIST   "allowedValueList"
#define cg_upnp_statevariable_next(statVar)   (CgUpnpStateVariable *)cg_list_next((CgList *)statVar)
#define cg_upnp_statevariable_isstatevariablenode(node)   cg_xml_node_isname(node, CG_UPNP_STATEVARIABLE_ELEM_NAME)
#define cg_upnp_statevariable_getstatevariablenode(statVar)   (statVar->stateVarNode)
#define cg_upnp_statevariable_setservice(statVar, service)   (statVar->parentService = service)
#define cg_upnp_statevariable_getservice(statVar)   ((CgUpnpService *)statVar->parentService)
#define cg_upnp_statevariable_hasallowedvaluelist(statVar)   cg_upnp_allowedvaluelist_size(statVar->allowedValueList)
#define cg_upnp_statevariable_getallowedvaluerange(statVar)   (statVar->allowedValueRange)
#define cg_upnp_statevariable_hasallowedvaluerange(statVar)   ((statVar->allowedValueRange != NULL) ? TRUE : FALSE)
#define cg_upnp_statevariable_setname(statVar, value)   cg_xml_node_setchildnode(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_NAME, value)
#define cg_upnp_statevariable_getname(statVar)   cg_xml_node_getchildnodevalue(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_NAME)
#define cg_upnp_statevariable_isname(statVar, name)   cg_streq(cg_upnp_statevariable_getname(statVar), name)
#define cg_upnp_statevariable_setdatatype(statVar, value)   cg_xml_node_setchildnode(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_DATATYPE, value)
#define cg_upnp_statevariable_getdatatype(statVar)   cg_xml_node_getchildnodevalue(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_DATATYPE)
#define cg_upnp_statevariable_setsendevents(statVar, value)   cg_xml_node_setattribute(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_SENDEVENTS, value)
#define cg_upnp_statevariable_getsendevents(statVar)   cg_xml_node_getattributevalue(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_SENDEVENTS)
#define cg_upnp_statevariable_issendevents(statVar)   (cg_streq(cg_upnp_statevariable_getsendevents(statVar), CG_UPNP_STATEVARIABLE_SENDEVENTS_YES))
#define cg_upnp_statevariable_getvalue(statVar)   cg_string_getvalue(statVar->value)
#define cg_upnp_statevariable_setlistener(statVar, func)   (statVar->listener = func)
#define cg_upnp_statevariable_getlistener(statVar)   (statVar->listener)
#define cg_upnp_statevariable_setstatuscode(statVar, code)   cg_upnp_status_setcode(statVar->upnpStatus, code)
#define cg_upnp_statevariable_getstatuscode(statVar)   cg_upnp_status_getcode(statVar->upnpStatus)
#define cg_upnp_statevariable_setstatusdescription(statVar, value)   cg_upnp_status_setdescription(statVar->upnpStatus, value)
#define cg_upnp_statevariable_getstatusdescription(statVar)   cg_upnp_status_getdescription(statVar->upnpStatus)
#define cg_upnp_statevariable_setuserdata(statVar, value)   (statVar->userData = value)
#define cg_upnp_statevariable_getuserdata(statVar)   (statVar->userData)
#define cg_upnp_servicestatetable_clear(stateTable)   cg_list_clear((CgList *)stateTable, (CG_LIST_DESTRUCTORFUNC)cg_upnp_statevariable_delete)
#define cg_upnp_servicestatetable_size(stateTable)   cg_list_size((CgList *)stateTable)
#define cg_upnp_servicestatetable_gets(stateTable)   (CgUpnpStateVariable *)cg_list_next((CgList *)stateTable)
#define cg_upnp_servicestatetable_add(stateTable, statVar)   cg_list_add((CgList *)stateTable, (CgList *)statVar)

Typedefs

typedef struct
_CgUpnpAllowedValuesList 
CgUpnpAllowedValuesList
typedef struct
_CgUpnpAllowedValuesList 
CgUpnpAllowedValue
typedef struct _CgUpnpStateVariable CgUpnpStateVariable
typedef struct _CgUpnpStateVariable CgUpnpServiceStateTable
typedef BOOL(* CG_UPNP_STATEVARIABLE_LISTNER )(CgUpnpStateVariable *)

Functions

CgUpnpStateVariable * cg_upnp_statevariable_new ()
void cg_upnp_statevariable_delete (CgUpnpStateVariable *statVar)
void cg_upnp_statevariable_setstatevariablenode (CgUpnpStateVariable *statVar, CgXmlNode *node)
CgUpnpAllowedValuesList * cg_upnp_statevariable_getallowedvaluelist (CgUpnpStateVariable *statVar)
int cg_upnp_statevariable_is_allowed_value (CgUpnpStateVariable *statVar, const char *value)
CgUpnpAllowedValuesList * cg_upnp_allowedvaluelist_new ()
void cg_upnp_statevariable_setvalue (CgUpnpStateVariable *statVar, char *data)
void cg_upnp_statevariable_setvaluewithoutnotify (CgUpnpStateVariable *statVar, char *data)
CgUpnpServiceStateTable * cg_upnp_servicestatetable_new ()
void cg_upnp_servicestatetable_delete (CgUpnpServiceStateTable *servicestatetable)

Define Documentation

#define cg_upnp_servicestatetable_add (   stateTable,
  statVar 
)    cg_list_add((CgList *)stateTable, (CgList *)statVar)

Add new service state table into service state table list

Parameters:
stateTableService state table
statVarState variable
#define cg_upnp_servicestatetable_clear (   stateTable)    cg_list_clear((CgList *)stateTable, (CG_LIST_DESTRUCTORFUNC)cg_upnp_statevariable_delete)

Clear service state table

Parameters:
stateTableService state table
#define cg_upnp_servicestatetable_gets (   stateTable)    (CgUpnpStateVariable *)cg_list_next((CgList *)stateTable)

Get next service state table from service state table list

Parameters:
stateTableService state table
Returns:
Service state table (node)
#define cg_upnp_servicestatetable_size (   stateTable)    cg_list_size((CgList *)stateTable)

Get size of service state table

Parameters:
stateTableService state table
#define CG_UPNP_SERVICESTATETALBE_ELEM_NAME   "serviceStateTable"

Definition for service state table XML element name

#define CG_UPNP_STATEVARIABLE_ALLOWEDVALUELIST   "allowedValueList"

Definition for state variable allowed values list

#define CG_UPNP_STATEVARIABLE_DATATYPE   "dataType"

Definition for state variable data type element

#define CG_UPNP_STATEVARIABLE_ELEM_NAME   "stateVariable"

Definition for state variable XML element name

#define cg_upnp_statevariable_getallowedvaluerange (   statVar)    (statVar->allowedValueRange)

Get allowed value range for state variable

Parameters:
statVarState variable
Returns:
Allowed value range
#define cg_upnp_statevariable_getdatatype (   statVar)    cg_xml_node_getchildnodevalue(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_DATATYPE)

Get data type from state variable

Parameters:
statVarState variable
Returns:
Data type
#define cg_upnp_statevariable_getlistener (   statVar)    (statVar->listener)

Get lister function associated with state variable

Parameters:
statVarState variable
#define cg_upnp_statevariable_getname (   statVar)    cg_xml_node_getchildnodevalue(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_NAME)

Get state variable name

Parameters:
statVarState variable
Returns:
State variable name
#define cg_upnp_statevariable_getsendevents (   statVar)    cg_xml_node_getattributevalue(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_SENDEVENTS)

Get state variable event sending option value

Parameters:
statVarState variable
Returns:
Current value associated to state variable
#define cg_upnp_statevariable_getservice (   statVar)    ((CgUpnpService *)statVar->parentService)

Get service from state variable

Parameters:
statVarState variable
Returns:
UPnP service
#define cg_upnp_statevariable_getstatevariablenode (   statVar)    (statVar->stateVarNode)

Get XML node from this state variable

Parameters:
statVarState variable
#define cg_upnp_statevariable_getstatuscode (   statVar)    cg_upnp_status_getcode(statVar->upnpStatus)

Get status code of this state variable

Parameters:
statVarStatus variable
#define cg_upnp_statevariable_getstatusdescription (   statVar)    cg_upnp_status_getdescription(statVar->upnpStatus)

Get status description from this state variable

Parameters:
statVarState variable
#define cg_upnp_statevariable_getuserdata (   statVar)    (statVar->userData)

Get user data from this state variable

Parameters:
statVarState variable
Returns:
User data
#define cg_upnp_statevariable_getvalue (   statVar)    cg_string_getvalue(statVar->value)

Get value associated with this state variable

Parameters:
statVarState variable
Returns:
Value associated with this state variable
#define cg_upnp_statevariable_hasallowedvaluelist (   statVar)    cg_upnp_allowedvaluelist_size(statVar->allowedValueList)

Check if state variable has allowed value list

Parameters:
statVarState variable
Returns:
0 if it does not have allowed value list integer greater than zero otherwise
#define cg_upnp_statevariable_hasallowedvaluerange (   statVar)    ((statVar->allowedValueRange != NULL) ? TRUE : FALSE)

Checks if state variable has allowed variable range

Parameters:
statVarState variable
Returns:
True if allowed value range exists, false otherwise
#define cg_upnp_statevariable_isname (   statVar,
  name 
)    cg_streq(cg_upnp_statevariable_getname(statVar), name)

Checks if state variable has certain name

Parameters:
statVarState variable
nameName to be checked
Returns:
True if State variable name is same as provided, false otherwise
#define cg_upnp_statevariable_issendevents (   statVar)    (cg_streq(cg_upnp_statevariable_getsendevents(statVar), CG_UPNP_STATEVARIABLE_SENDEVENTS_YES))

Check if events are sent to subscribers when this state variable changes

Parameters:
statVarState variable
Returns:
True if events are sent, false otherwise
#define cg_upnp_statevariable_isstatevariablenode (   node)    cg_xml_node_isname(node, CG_UPNP_STATEVARIABLE_ELEM_NAME)

Check if XML node is state variable node

Parameters:
nodeXML node
#define CG_UPNP_STATEVARIABLE_NAME   "name"

Definition for state variable name element

#define cg_upnp_statevariable_next (   statVar)    (CgUpnpStateVariable *)cg_list_next((CgList *)statVar)

Get next element from state variable list

Parameters:
statVarstate variable list node
#define CG_UPNP_STATEVARIABLE_SENDEVENTS   "sendEvents"

Definition for state variable send events element name

#define CG_UPNP_STATEVARIABLE_SENDEVENTS_NO   "no"

Definition for state variable send events element value

#define CG_UPNP_STATEVARIABLE_SENDEVENTS_YES   "yes"

Definition for state variable send events element value

#define cg_upnp_statevariable_setdatatype (   statVar,
  value 
)    cg_xml_node_setchildnode(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_DATATYPE, value)

Set data type for state variable

Parameters:
statVarState variable
valueData type
#define cg_upnp_statevariable_setlistener (   statVar,
  func 
)    (statVar->listener = func)

Set listener callback for this state variable

Parameters:
statVarState variable
funcListener function
#define cg_upnp_statevariable_setname (   statVar,
  value 
)    cg_xml_node_setchildnode(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_NAME, value)

Set state variable name

Parameters:
statVarState variable
valueNew state variable name
#define cg_upnp_statevariable_setsendevents (   statVar,
  value 
)    cg_xml_node_setattribute(cg_upnp_statevariable_getstatevariablenode(statVar), CG_UPNP_STATEVARIABLE_SENDEVENTS, value)

Set send events option for state variable, can be used to disable eventing for certain variables.

Parameters:
statVarState variable
valueNew value
#define cg_upnp_statevariable_setservice (   statVar,
  service 
)    (statVar->parentService = service)

Set service for this state variable

Parameters:
statVarState variable
serviceService
#define cg_upnp_statevariable_setstatuscode (   statVar,
  code 
)    cg_upnp_status_setcode(statVar->upnpStatus, code)

Set status code for state variable

Parameters:
statVarState variable
codeStatus code
#define cg_upnp_statevariable_setstatusdescription (   statVar,
  value 
)    cg_upnp_status_setdescription(statVar->upnpStatus, value)

Set status description for state variable

Parameters:
statVarState variable
valueStatus description
#define cg_upnp_statevariable_setuserdata (   statVar,
  value 
)    (statVar->userData = value)

Set arbitrary user data associated with this state variable

Parameters:
statVarState variable
valueData

Typedef Documentation

Type definition for state variable listener function

Data type for allowed state variables allowed values table

Data type for state variable and state table


Function Documentation

CgUpnpAllowedValuesList* cg_upnp_allowedvaluelist_new ( )

Create new allowed state variable values list

void cg_upnp_servicestatetable_delete ( CgUpnpServiceStateTable *  servicestatetable)

Delete service state table object

Parameters:
servicestatetableService state table
CgUpnpServiceStateTable* cg_upnp_servicestatetable_new ( )

Create service state table object

void cg_upnp_statevariable_delete ( CgUpnpStateVariable *  statVar)

Delete state variable object

Parameters:
statVarstate variable
CgUpnpAllowedValuesList* cg_upnp_statevariable_getallowedvaluelist ( CgUpnpStateVariable *  statVar)

Get allowed value list

Parameters:
statVarState variable
Returns:
Allowed value list
int cg_upnp_statevariable_is_allowed_value ( CgUpnpStateVariable *  statVar,
const char *  value 
)

Check if state variable allowes to receive value

value value to be checked

Parameters:
statVarState variable
Returns:
0 if it does allowed to receive value
CgUpnpStateVariable* cg_upnp_statevariable_new ( )

Create new state variable object

void cg_upnp_statevariable_setstatevariablenode ( CgUpnpStateVariable *  statVar,
CgXmlNode *  node 
)

Set XML node for this state variable

Parameters:
statVarState variable
nodeXML node
void cg_upnp_statevariable_setvalue ( CgUpnpStateVariable *  statVar,
char *  data 
)

Set state variable value

Parameters:
statVarState variable
dataNew value associated with this state variable, and the value is send to other devices which subscribe the service.
void cg_upnp_statevariable_setvaluewithoutnotify ( CgUpnpStateVariable *  statVar,
char *  data 
)

Set state variable value

Parameters:
statVarState variable
dataNew value associated with this state variable