CgUpnpDevice *upnp_clock_device_new() { CgUpnpDevice *clockDev; CgUpnpService *timeService; clockDev = cg_upnp_device_new(); if (cg_upnp_device_parsedescription(clockDev, CLOCK_DEVICE_DESCRIPTION, strlen(CLOCK_DEVICE_DESCRIPTION)) == FALSE) { cg_upnp_device_delete(clockDev); return NULL; } timeService = cg_upnp_device_getservicebyexacttype(clockDev, "urn:schemas-upnp-org:service:timer:1"); if (timeService == NULL) { cg_upnp_device_delete(clockDev); return NULL; } if (cg_upnp_service_parsedescription(timeService, CLOCK_SERVICE_DESCRIPTION, strlen(CLOCK_SERVICE_DESCRIPTION)) == FALSE) { cg_upnp_device_delete(clockDev); return NULL; } cg_upnp_device_setactionlistener(clockDev, upnp_clock_actionreceived); cg_upnp_device_setquerylistener(clockDev, upnp_clock_queryreceived); cg_upnp_device_sethttplistener(clockDev, upnp_clock_device_httprequestrecieved); return clockDev; }
/** * Parse the service description from the service's SCPD URL. Do not call * this from user applications. * * @param service The service in question * @return TRUE if successful; otherwise FALSE */ BOOL cg_upnp_controlpoint_parsescservicescpd(CgUpnpService *service) { CgNetURL *scpdURL; BOOL scpdParseSuccess; cg_log_debug_l4("Entering...\n"); scpdURL = cg_upnp_service_getscpdurl(service); if ( NULL == scpdURL ) return FALSE; cg_log_debug_s("SCPD URL: %s\n", cg_net_url_getrequest(scpdURL)); scpdParseSuccess = cg_upnp_service_parsedescriptionurl(service, scpdURL); cg_net_url_delete(scpdURL); if (scpdParseSuccess == TRUE) return TRUE; #if defined(CG_UPNP_USE_STDDCP) if (cg_upnp_service_hasstddcp(service)) { char *stdDCP = cg_upnp_service_getstddcp(service); scpdParseSuccess = cg_upnp_service_parsedescription(service, stdDCP, cg_strlen(stdDCP)); } #endif cg_log_debug_l4("Leaving...\n"); return scpdParseSuccess; }
BOOL cg_upnpav_dms_conmgr_init(CgUpnpAvServer* dms) { CgUpnpDevice* dev; CgUpnpService* service; CgUpnpAction* action; dev = cg_upnpav_dms_getdevice(dms); if (!dev) return FALSE; service = cg_upnp_device_getservicebytype(dev, CG_UPNPAV_DMS_CONNECTIONMANAGER_SERVICE_TYPE); if (!service) return FALSE; if (cg_upnp_service_parsedescription(service, CG_UPNPAV_DMS_CONNECTIONMANAGER_SERVICE_DESCRIPTION, cg_strlen(CG_UPNPAV_DMS_CONNECTIONMANAGER_SERVICE_DESCRIPTION)) == FALSE) return FALSE; cg_upnp_service_setuserdata(service, dms); for (action = cg_upnp_service_getactions(service); action; action = cg_upnp_action_next(action)) cg_upnp_action_setuserdata(action, dms); return TRUE; }