Example #1
0
void upnp_clock_device_update(CgUpnpDevice *clockDev)
{
    CgTime currTime;
    CgUpnpService *timeService;
    CgUpnpStateVariable *timeState;
    char sysTimeStr[SYSTEM_TIME_BUF_LEN];

    timeService = cg_upnp_device_getservicebyexacttype(clockDev, "urn:schemas-upnp-org:service:timer:1");
    if (timeService == NULL)
        return;

    timeState = cg_upnp_service_getstatevariablebyname(timeService, "Time");
    if (timeState == NULL)
        return;

    currTime = cg_getcurrentsystemtime();
    GetSystemTimeString(currTime, sysTimeStr);
    cg_upnp_statevariable_setvalue(timeState, sysTimeStr);

    printf("%s\n", sysTimeStr);
}
Example #2
0
void cg_upnpav_dmr_addprotocolinfo(CgUpnpAvRenderer* dmr, CgUpnpAvProtocolInfo* info)
{
  CgString* protocolInfos;
  CgUpnpAvProtocolInfo* protocolInfo;
  CgUpnpService* service;
  CgUpnpStateVariable* stateVar;

  cg_upnpav_protocolinfolist_add(dmr->protocolInfoList, info);

  protocolInfos = cg_string_new();
  for (protocolInfo = cg_upnpav_dmr_getprotocolinfos(dmr); protocolInfo; protocolInfo = cg_upnpav_protocolinfo_next(protocolInfo)) {
    if (0 < cg_string_length(protocolInfos))
      cg_string_addvalue(protocolInfos, ",");
    cg_string_addvalue(protocolInfos, cg_upnpav_protocolinfo_getstring(protocolInfo));
  }

  service = cg_upnp_device_getservicebyexacttype(dmr->dev, CG_UPNPAV_DMR_CONNECTIONMANAGER_SERVICE_TYPE);
  stateVar = cg_upnp_service_getstatevariablebyname(service, CG_UPNPAV_DMR_CONNECTIONMANAGER_SINKPROTOCOLINFO);
  cg_upnp_statevariable_setvalue(stateVar, cg_string_getvalue(protocolInfos));

  cg_string_delete(protocolInfos);
}
/**
 * When an event is received, update also the associated service's
 * state table to include the evented state variable.
 *
 * @param service The service, whose state table to update
 * @param prop The evented property from which to update
 */
void cg_upnp_controlpoint_updatestatetablefromproperty(CgUpnpService* service,
						       CgUpnpProperty* prop)
{
	CgUpnpStateVariable* var = NULL;
	
	cg_log_debug_l4("Entering...\n");

	if (service == NULL || prop == NULL)
	{
		return;
	}
	
	var = cg_upnp_service_getstatevariablebyname(service,
					       cg_upnp_property_getname(prop));
	
	if (var)
	{
		cg_upnp_statevariable_setvalue(var,
					       cg_upnp_property_getvalue(prop));
	}

	cg_log_debug_l4("Leaving...\n");
}