mUPnP for C
statevariable.c File Reference
#include <mupnp/service.h>
#include <mupnp/statevariable.h>
#include <mupnp/util/log.h>
#include <string.h>

Functions

mUpnpStateVariablemupnp_statevariable_new (void)
 Create a new UPnP state variable.
 
void mupnp_statevariable_delete (mUpnpStateVariable *statVar)
 Destroy a UPnP state variable and free resources.
 
void mupnp_statevariable_setstatevariablenode (mUpnpStateVariable *statVar, mUpnpXmlNode *node)
 
static void mupnp_statevariable_setvaluewithnotify (mUpnpStateVariable *statVar, const char *data, bool doNotify)
 
void mupnp_statevariable_setvalue (mUpnpStateVariable *statVar, const char *data)
 
void mupnp_statevariable_setvaluewithoutnotify (mUpnpStateVariable *statVar, const char *data)
 
mUpnpAllowedValuesListmupnp_allowedvaluelist_new (void)
 
mUpnpAllowedValuesListmupnp_statevariable_getallowedvaluelist (mUpnpStateVariable *statVar)
 
int mupnp_statevariable_is_allowed_value (mUpnpStateVariable *statVar, const char *value)
 

Function Documentation

◆ mupnp_allowedvaluelist_new()

mUpnpAllowedValuesList * mupnp_allowedvaluelist_new ( void )

Create new allowed state variable values list

◆ mupnp_statevariable_delete()

void mupnp_statevariable_delete ( mUpnpStateVariable * statVar)

Destroy a UPnP state variable and free resources.

Releases all resources associated with the state variable, including:

  • The current value string
  • Allowed values list (if any)
  • XML node references
  • UPnP status object
Parameters
statVarThe state variable to destroy. May be NULL (no-op if NULL).
Note
After calling this function, the statVar pointer is invalid.
Thread-safe: Must not be called concurrently on the same state variable.
See also
mupnp_statevariable_new()

◆ 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 a new UPnP state variable.

Allocates and initializes a new state variable object. State variables represent the state of a UPnP service and can be:

  • Evented (sendEvents="yes") - Changes trigger event notifications
  • Non-evented (sendEvents="no") - Query-only via action arguments

State variables have:

  • A name (identifier)
  • A data type (string, int, boolean, etc.)
  • An optional list of allowed values
  • A current value
  • Optional eventing configuration

State variables are typically created during SCPD parsing and added to the service state table.

Returns
A newly-created mUpnpStateVariable on success, or NULL if memory allocation fails.
Note
The returned state variable must be freed with mupnp_statevariable_delete() when no longer needed.
Thread-safe: Can be called concurrently from multiple threads.
For device implementations, set a query listener to handle QueryStateVariable requests.
See also
mupnp_statevariable_delete()
mupnp_statevariable_setvalue()
mupnp_statevariable_issendevents()

◆ 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_setvaluewithnotify()

static void mupnp_statevariable_setvaluewithnotify ( mUpnpStateVariable * statVar,
const char * data,
bool doNotify )
static

◆ 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