static CgXmlNode *cg_upnp_event_notify_request_createpropertysetnode(CgUpnpService* service, CgUpnpStateVariable *statVar) { CgXmlNode *propSetNode; CgXmlNode *propNode; CgXmlNode *varNode; cg_log_debug_l4("Entering...\n"); propSetNode = cg_xml_node_new(); cg_xml_node_setname(propSetNode, CG_UPNP_NOTIFY_XMLNS CG_SOAP_DELIM CG_UPNP_NOTIFY_PROPERTYSET); cg_xml_node_setnamespace(propSetNode, CG_UPNP_NOTIFY_XMLNS, CG_UPNP_SUBSCRIPTION_XMLNS); if (service) { for (statVar = cg_upnp_service_getstatevariables(service); statVar != NULL; statVar = cg_upnp_statevariable_next(statVar)) { if (!cg_upnp_statevariable_issendevents(statVar)) continue; propNode = cg_xml_node_new(); if (!propNode) continue; cg_xml_node_setname(propNode, CG_UPNP_NOTIFY_XMLNS CG_SOAP_DELIM CG_UPNP_NOTIFY_PROPERTY); cg_xml_node_addchildnode(propSetNode, propNode); varNode = cg_xml_node_new(); if (!varNode) { cg_xml_node_delete(propNode); continue; } cg_xml_node_setname(varNode, cg_upnp_statevariable_getname(statVar)); cg_xml_node_setvalue(varNode, cg_upnp_statevariable_getvalue(statVar)); cg_xml_node_addchildnode(propNode, varNode); } } else if (statVar) { propNode = cg_xml_node_new(); if (propNode) { cg_xml_node_setname(propNode, CG_UPNP_NOTIFY_XMLNS CG_SOAP_DELIM CG_UPNP_NOTIFY_PROPERTY); cg_xml_node_addchildnode(propSetNode, propNode); varNode = cg_xml_node_new(); if (varNode) { cg_xml_node_setname(varNode, cg_upnp_statevariable_getname(statVar)); cg_xml_node_setvalue(varNode, cg_upnp_statevariable_getvalue(statVar)); cg_xml_node_addchildnode(propNode, varNode); } else cg_xml_node_delete(propNode); } } cg_log_debug_l4("Leaving...\n"); return propSetNode; }
static void cg_upnp_statevariable_setvaluewithnotify(CgUpnpStateVariable *statVar, char *data, BOOL doNotify) { CgUpnpService *service; cg_log_debug_l4("Entering...\n"); cg_string_setvalue(statVar->value, data); #if !defined(CG_UPNP_NOUSE_SUBSCRIPTION) /**** notify event ****/ if (doNotify) { if (cg_upnp_statevariable_issendevents(statVar) == FALSE) return; service = cg_upnp_statevariable_getservice(statVar); if (service == NULL) return; cg_upnp_service_notify(service, statVar); } #endif cg_log_debug_l4("Leaving...\n"); }