mUPnP for C
statevariable.h File Reference
#include <mupnp/typedef.h>
#include <mupnp/xml/xml.h>
#include <mupnp/util/list.h>
#include <mupnp/util/string.h>
#include <mupnp/upnp_status.h>

Data Structures

struct  _mUpnpAllowedValuesList
 
struct  _mUpnpStateVariable
 

Macros

#define MUPNP_STATEVARIABLE_ELEM_NAME   "stateVariable"
 
#define MUPNP_SERVICESTATETALBE_ELEM_NAME   "serviceStateTable"
 
#define MUPNP_STATEVARIABLE_NAME   "name"
 
#define MUPNP_STATEVARIABLE_DATATYPE   "dataType"
 
#define MUPNP_STATEVARIABLE_SENDEVENTS   "sendEvents"
 
#define MUPNP_STATEVARIABLE_SENDEVENTS_YES   "yes"
 
#define MUPNP_STATEVARIABLE_SENDEVENTS_NO   "no"
 
#define MUPNP_STATEVARIABLE_ALLOWEDVALUELIST   "allowedValueList"
 
#define mupnp_statevariable_next(statVar)
 
#define mupnp_statevariable_isstatevariablenode(node)
 
#define mupnp_statevariable_getstatevariablenode(statVar)
 
#define mupnp_statevariable_setservice(statVar, service)
 
#define mupnp_statevariable_getservice(statVar)
 
#define mupnp_statevariable_hasallowedvaluelist(statVar)
 
#define mupnp_statevariable_getallowedvaluerange(statVar)
 
#define mupnp_statevariable_hasallowedvaluerange(statVar)
 
#define mupnp_statevariable_setname(statVar, value)
 
#define mupnp_statevariable_getname(statVar)
 
#define mupnp_statevariable_isname(statVar, name)
 
#define mupnp_statevariable_setdatatype(statVar, value)
 
#define mupnp_statevariable_getdatatype(statVar)
 
#define mupnp_statevariable_setsendevents(statVar, value)
 
#define mupnp_statevariable_getsendevents(statVar)
 
#define mupnp_statevariable_issendevents(statVar)
 
#define mupnp_statevariable_getvalue(statVar)
 
#define mupnp_statevariable_setlistener(statVar, func)
 
#define mupnp_statevariable_getlistener(statVar)
 
#define mupnp_statevariable_setstatuscode(statVar, code)
 
#define mupnp_statevariable_getstatuscode(statVar)
 
#define mupnp_statevariable_setstatusdescription(statVar, value)
 
#define mupnp_statevariable_getstatusdescription(statVar)
 
#define mupnp_statevariable_setuserdata(statVar, value)
 
#define mupnp_statevariable_getuserdata(statVar)
 
#define mupnp_servicestatetable_clear(stateTable)
 
#define mupnp_servicestatetable_size(stateTable)
 
#define mupnp_servicestatetable_gets(stateTable)
 
#define mupnp_servicestatetable_add(stateTable, statVar)
 

Typedefs

typedef struct _mUpnpAllowedValuesList mUpnpAllowedValuesList
 
typedef struct _mUpnpAllowedValuesList mUpnpAllowedValue
 
typedef struct _mUpnpStateVariable mUpnpStateVariable
 
typedef struct _mUpnpStateVariable mUpnpServiceStateTable
 
typedef bool(* MUPNP_STATEVARIABLE_LISTNER) (mUpnpStateVariable *)
 

Functions

mUpnpStateVariablemupnp_statevariable_new (void)
 
void mupnp_statevariable_delete (mUpnpStateVariable *statVar)
 
void mupnp_statevariable_setstatevariablenode (mUpnpStateVariable *statVar, mUpnpXmlNode *node)
 
mUpnpAllowedValuesListmupnp_statevariable_getallowedvaluelist (mUpnpStateVariable *statVar)
 
int mupnp_statevariable_is_allowed_value (mUpnpStateVariable *statVar, const char *value)
 
mUpnpAllowedValuesListmupnp_allowedvaluelist_new (void)
 
void mupnp_statevariable_setvalue (mUpnpStateVariable *statVar, const char *data)
 
void mupnp_statevariable_setvaluewithoutnotify (mUpnpStateVariable *statVar, const char *data)
 
mUpnpServiceStateTablemupnp_servicestatetable_new (void)
 
void mupnp_servicestatetable_delete (mUpnpServiceStateTable *servicestatetable)
 

Macro Definition Documentation

◆ mupnp_servicestatetable_add

#define mupnp_servicestatetable_add ( stateTable,
statVar )
Value:
mupnp_list_add((mUpnpList*)stateTable, (mUpnpList*)statVar)
void mupnp_list_add(mUpnpList *headList, mUpnpList *list)
Definition list.c:123
The generic list interface in mUPnP.
Definition list.h:56

Add new service state table into service state table list

Parameters
stateTableService state table
statVarState variable

◆ mupnp_servicestatetable_clear

#define mupnp_servicestatetable_clear ( stateTable)
Value:
void mupnp_list_clear(mUpnpList *headList, MUPNP_LIST_DESTRUCTORFUNC destructorFunc)
Definition list.c:257
void(* MUPNP_LIST_DESTRUCTORFUNC)(void *)
Definition list.h:29
void mupnp_statevariable_delete(mUpnpStateVariable *statVar)
Definition statevariable.c:53

Clear service state table

Parameters
stateTableService state table

◆ mupnp_servicestatetable_gets

#define mupnp_servicestatetable_gets ( stateTable)
Value:
mUpnpList * mupnp_list_next(mUpnpList *list)
Definition list.c:234
Definition statevariable.h:86

Get next service state table from service state table list

Parameters
stateTableService state table
Returns
Service state table (node)

◆ mupnp_servicestatetable_size

#define mupnp_servicestatetable_size ( stateTable)
Value:
int mupnp_list_size(mUpnpList *headList)
Definition list.c:53

Get size of service state table

Parameters
stateTableService state table

◆ MUPNP_SERVICESTATETALBE_ELEM_NAME

#define MUPNP_SERVICESTATETALBE_ELEM_NAME   "serviceStateTable"

Definition for service state table XML element name

◆ MUPNP_STATEVARIABLE_ALLOWEDVALUELIST

#define MUPNP_STATEVARIABLE_ALLOWEDVALUELIST   "allowedValueList"

Definition for state variable allowed values list

◆ MUPNP_STATEVARIABLE_DATATYPE

#define MUPNP_STATEVARIABLE_DATATYPE   "dataType"

Definition for state variable data type element

◆ MUPNP_STATEVARIABLE_ELEM_NAME

#define MUPNP_STATEVARIABLE_ELEM_NAME   "stateVariable"

Definition for state variable XML element name

◆ mupnp_statevariable_getallowedvaluerange

#define mupnp_statevariable_getallowedvaluerange ( statVar)
Value:
(statVar->allowedValueRange)

Get allowed value range for state variable

Parameters
statVarState variable
Returns
Allowed value range

◆ mupnp_statevariable_getdatatype

#define mupnp_statevariable_getdatatype ( statVar)
Value:
#define mupnp_statevariable_getstatevariablenode(statVar)
Definition statevariable.h:155
#define MUPNP_STATEVARIABLE_DATATYPE
Definition statevariable.h:48
const char * mupnp_xml_node_getchildnodevalue(mUpnpXmlNode *node, const char *name)
Definition xml_node.c:216

Get data type from state variable

Parameters
statVarState variable
Returns
Data type

◆ mupnp_statevariable_getlistener

#define mupnp_statevariable_getlistener ( statVar)
Value:
(statVar->listener)

Get lister function associated with state variable

Parameters
statVarState variable

◆ mupnp_statevariable_getname

#define mupnp_statevariable_getname ( statVar)
Value:

Get state variable name

Parameters
statVarState variable
Returns
State variable name

◆ mupnp_statevariable_getsendevents

#define mupnp_statevariable_getsendevents ( statVar)
Value:
#define MUPNP_STATEVARIABLE_SENDEVENTS
Definition statevariable.h:53
#define mupnp_xml_node_getattributevalue(node, name)
Definition xml.h:166

Get state variable event sending option value

Parameters
statVarState variable
Returns
Current value associated to state variable

◆ mupnp_statevariable_getservice

#define mupnp_statevariable_getservice ( statVar)
Value:
((mUpnpService*)statVar->parentService)
Definition service.h:51

Get service from state variable

Parameters
statVarState variable
Returns
UPnP service

◆ mupnp_statevariable_getstatevariablenode

#define mupnp_statevariable_getstatevariablenode ( statVar)
Value:
(statVar->stateVarNode)

Get XML node from this state variable

Parameters
statVarState variable

◆ mupnp_statevariable_getstatuscode

#define mupnp_statevariable_getstatuscode ( statVar)
Value:
mupnp_status_getcode(statVar->upnpStatus)
#define mupnp_status_getcode(upnpStat)
Definition upnp_status.h:77

Get status code of this state variable

Parameters
statVarStatus variable

◆ mupnp_statevariable_getstatusdescription

#define mupnp_statevariable_getstatusdescription ( statVar)
Value:
mupnp_status_getdescription(statVar->upnpStatus)
#define mupnp_status_getdescription(upnpStat)
Definition upnp_status.h:92

Get status description from this state variable

Parameters
statVarState variable

◆ mupnp_statevariable_getuserdata

#define mupnp_statevariable_getuserdata ( statVar)
Value:
(statVar->userData)

Get user data from this state variable

Parameters
statVarState variable
Returns
User data

◆ mupnp_statevariable_getvalue

#define mupnp_statevariable_getvalue ( statVar)
Value:
mupnp_string_getvalue(statVar->value)
char * mupnp_string_getvalue(mUpnpString *str)
Definition string.c:177

Get value associated with this state variable

Parameters
statVarState variable
Returns
Value associated with this state variable

◆ mupnp_statevariable_hasallowedvaluelist

#define mupnp_statevariable_hasallowedvaluelist ( statVar)
Value:
mupnp_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

◆ mupnp_statevariable_hasallowedvaluerange

#define mupnp_statevariable_hasallowedvaluerange ( statVar)
Value:
((statVar->allowedValueRange != NULL) ? true : false)
#define true
Definition typedef.h:63

Checks if state variable has allowed variable range

Parameters
statVarState variable
Returns
True if allowed value range exists, false otherwise

◆ mupnp_statevariable_isname

#define mupnp_statevariable_isname ( statVar,
name )
Value:
#define mupnp_statevariable_getname(statVar)
Definition statevariable.h:248
bool mupnp_streq(const char *str1, const char *str2)
Definition string_function.c:158

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

◆ mupnp_statevariable_issendevents

#define mupnp_statevariable_issendevents ( statVar)
Value:
#define mupnp_statevariable_getsendevents(statVar)
Definition statevariable.h:297
#define MUPNP_STATEVARIABLE_SENDEVENTS_YES
Definition statevariable.h:58

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

Parameters
statVarState variable
Returns
True if events are sent, false otherwise

◆ mupnp_statevariable_isstatevariablenode

#define mupnp_statevariable_isstatevariablenode ( node)
Value:
#define MUPNP_STATEVARIABLE_ELEM_NAME
Definition statevariable.h:33
#define mupnp_xml_node_isname(node, nodename)
Definition xml.h:123

Check if XML node is state variable node

Parameters
nodeXML node

◆ MUPNP_STATEVARIABLE_NAME

#define MUPNP_STATEVARIABLE_NAME   "name"

Definition for state variable name element

◆ mupnp_statevariable_next

#define mupnp_statevariable_next ( statVar)
Value:

Get next element from state variable list

Parameters
statVarstate variable list node

◆ MUPNP_STATEVARIABLE_SENDEVENTS

#define MUPNP_STATEVARIABLE_SENDEVENTS   "sendEvents"

Definition for state variable send events element name

◆ MUPNP_STATEVARIABLE_SENDEVENTS_NO

#define MUPNP_STATEVARIABLE_SENDEVENTS_NO   "no"

Definition for state variable send events element value

◆ MUPNP_STATEVARIABLE_SENDEVENTS_YES

#define MUPNP_STATEVARIABLE_SENDEVENTS_YES   "yes"

Definition for state variable send events element value

◆ mupnp_statevariable_setdatatype

#define mupnp_statevariable_setdatatype ( statVar,
value )
Value:
void mupnp_xml_node_setchildnode(mUpnpXmlNode *node, const char *name, const char *value)
Definition xml_node.c:105

Set data type for state variable

Parameters
statVarState variable
valueData type

◆ mupnp_statevariable_setlistener

#define mupnp_statevariable_setlistener ( statVar,
func )
Value:
(statVar->listener = func)

Set listener callback for this state variable

Parameters
statVarState variable
funcListener function

◆ mupnp_statevariable_setname

#define mupnp_statevariable_setname ( statVar,
value )
Value:

Set state variable name

Parameters
statVarState variable
valueNew state variable name

◆ mupnp_statevariable_setsendevents

#define mupnp_statevariable_setsendevents ( statVar,
value )
Value:
#define mupnp_xml_node_setattribute(node, name, value)
Definition xml.h:165

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

Parameters
statVarState variable
valueNew value

◆ mupnp_statevariable_setservice

#define mupnp_statevariable_setservice ( statVar,
service )
Value:
(statVar->parentService = service)

Set service for this state variable

Parameters
statVarState variable
serviceService

◆ mupnp_statevariable_setstatuscode

#define mupnp_statevariable_setstatuscode ( statVar,
code )
Value:
mupnp_status_setcode(statVar->upnpStatus, code)
#define mupnp_status_setcode(upnpStat, value)
Definition upnp_status.h:70

Set status code for state variable

Parameters
statVarState variable
codeStatus code

◆ mupnp_statevariable_setstatusdescription

#define mupnp_statevariable_setstatusdescription ( statVar,
value )
Value:
mupnp_status_setdescription(statVar->upnpStatus, value)
#define mupnp_status_setdescription(upnpStat, value)
Definition upnp_status.h:85

Set status description for state variable

Parameters
statVarState variable
valueStatus description

◆ mupnp_statevariable_setuserdata

#define mupnp_statevariable_setuserdata ( statVar,
value )
Value:
(statVar->userData = value)

Set arbitrary user data associated with this state variable

Parameters
statVarState variable
valueData

Typedef Documentation

◆ MUPNP_STATEVARIABLE_LISTNER

typedef bool(* MUPNP_STATEVARIABLE_LISTNER) (mUpnpStateVariable *)

Type definition for state variable listener function

◆ mUpnpAllowedValue

◆ mUpnpAllowedValuesList

Data type for allowed state variables allowed values table

◆ mUpnpServiceStateTable

◆ mUpnpStateVariable

Data type for state variable and state table

Function Documentation

◆ mupnp_allowedvaluelist_new()

mUpnpAllowedValuesList * mupnp_allowedvaluelist_new ( void )

Create new allowed state variable values list

◆ mupnp_servicestatetable_delete()

void mupnp_servicestatetable_delete ( mUpnpServiceStateTable * servicestatetable)

Delete service state table object

Parameters
servicestatetableService state table

◆ mupnp_servicestatetable_new()

mUpnpServiceStateTable * mupnp_servicestatetable_new ( void )

Create service state table object

◆ mupnp_statevariable_delete()

void mupnp_statevariable_delete ( mUpnpStateVariable * statVar)

Delete state variable object

Parameters
statVarstate variable

◆ mupnp_statevariable_getallowedvaluelist()

mUpnpAllowedValuesList * mupnp_statevariable_getallowedvaluelist ( mUpnpStateVariable * statVar)

Get allowed value list

Parameters
statVarState variable
Returns
Allowed value list

◆ mupnp_statevariable_is_allowed_value()

int mupnp_statevariable_is_allowed_value ( mUpnpStateVariable * statVar,
const char * value )

Check if state variable allowes to receive value

@parap value value to be checked

Parameters
statVarState variable
Returns
0 if it does allowed to receive value

◆ mupnp_statevariable_new()

mUpnpStateVariable * mupnp_statevariable_new ( void )

Create new state variable object

◆ mupnp_statevariable_setstatevariablenode()

void mupnp_statevariable_setstatevariablenode ( mUpnpStateVariable * statVar,
mUpnpXmlNode * node )

Set XML node for this state variable

Parameters
statVarState variable
nodeXML node

◆ mupnp_statevariable_setvalue()

void mupnp_statevariable_setvalue ( mUpnpStateVariable * statVar,
const 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.

◆ mupnp_statevariable_setvaluewithoutnotify()

void mupnp_statevariable_setvaluewithoutnotify ( mUpnpStateVariable * statVar,
const char * data )

Set state variable value

Parameters
statVarState variable
dataNew value associated with this state variable