/**************************************** * cg_upnp_event_notify_request_setpropertysetnode ****************************************/ BOOL cg_upnp_event_notify_request_setpropertysetnode(CgUpnpNotifyRequest *notifyReq, CgUpnpSubscriber *sub, /* CgUpnpService */void *pservice, CgUpnpStateVariable *statVar) { CgHttpRequest *httpReq; CgXmlNode *propSetNode; CgUpnpService* service; char server[CG_UPNP_SEVERNAME_MAXLEN]; cg_log_debug_l4("Entering...\n"); service = (CgUpnpService *)pservice; httpReq = cg_soap_request_gethttprequest(notifyReq); cg_http_request_setmethod(httpReq, CG_HTTP_NOTIFY); cg_http_request_setconnection(httpReq, CG_HTTP_CLOSE); cg_http_request_seturi(httpReq, cg_upnp_subscriber_getdeliverypath(sub)); cg_http_request_sethost(httpReq, cg_upnp_subscriber_getdeliveryhost(sub), cg_upnp_subscriber_getdeliveryport(sub)); cg_upnp_getservername(server, sizeof(server)); cg_http_packet_setheadervalue((CgHttpPacket*)httpReq, CG_HTTP_SERVER, server); cg_upnp_event_notify_request_setnt(notifyReq, CG_UPNP_NT_EVENT); cg_upnp_event_notify_request_setnts(notifyReq, CG_UPNP_NTS_PROPCHANGE); cg_upnp_event_notify_request_setsid(notifyReq, cg_upnp_subscriber_getsid(sub)); cg_upnp_event_notify_request_setseq(notifyReq, cg_upnp_subscriber_getnotifycount(sub)); propSetNode = cg_upnp_event_notify_request_createpropertysetnode(service, statVar); cg_soap_request_setcontent(notifyReq, propSetNode); cg_xml_node_delete(propSetNode); cg_log_debug_l4("Leaving...\n"); return TRUE; }
void cg_upnp_event_subscription_subscriberesponse_setresponse(CgUpnpSubscriptionResponse *subRes, int code) { char *server[CG_UPNP_SEVERNAME_MAXLEN]; cg_log_debug_l4("Entering...\n"); cg_http_response_setstatuscode(subRes, code); cg_upnp_getservername(server, sizeof(server)); cg_http_packet_setheadervalue(((CgHttpPacket*)subRes), CG_HTTP_SERVER, server); cg_http_response_setcontentlength(subRes, 0); cg_log_debug_l4("Leaving...\n"); }
void upnp_clock_device_httprequestrecieved(CgHttpRequest *httpReq) { CgTime currTime; CgUpnpDevice *dev; char *uri; char content[2048]; char sysTimeStr[SYSTEM_TIME_BUF_LEN]; char serverName[CG_UPNP_SEVERNAME_MAXLEN]; CgHttpResponse *httpRes; BOOL postRet; dev = (CgUpnpDevice *)cg_http_request_getuserdata(httpReq); uri = cg_http_request_geturi(httpReq); if (strcmp(uri, "/presentation") != 0) { cg_upnp_device_httprequestrecieved(httpReq); return; } currTime = cg_getcurrentsystemtime(); #if defined(HAVE_SNPRINTF) snprintf(content, sizeof(content), #else sprintf(content, #endif "<HTML>" "<HEAD>" "<TITLE>UPnP Clock Sample</TITLE>" "</HEAD>" "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=/presentation\">" "<BODY><CENTER>" "<H1>UPnP Clock Sample</H1>" "<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" "<TR>" "<TD style=\"width: 50px; height: 50px; background-color: rgb(176, 176, 176);\"></TD>" "<TD style=\"background-color: rgb(176, 176, 176);\"></TD>" "<TD style=\"width: 50px; height: 50px; background-color: rgb(176, 176, 176);\"></TD>" "</TR>" "<TR>" "<TD style=\"height: 50px; background-color: rgb(176, 176, 176);\"></TD>" "<TD style=\"height: 50px; background-color: rgb(221, 236, 245);\" align=\"center\"><H1>" "%s" "</H1></TD>" "<TD style=\"height: 50px; background-color: rgb(176, 176, 176);\"></TD>" "</TR>" "<TR>" "<TD style=\"height: 50px; background-color: rgb(176, 176, 176);\"></TD>" "<TD style=\"height: 50px; background-color: rgb(221, 236, 245);\" align=\"center\"><H3>" "Server : %s" "</H3></TD>" "<TD style=\"height: 30px; background-color: rgb(176, 176, 176);\"></TD>" "</TR>" "<TR>" "<TD style=\"width: 30px; height: 50px; background-color: rgb(176, 176, 176);\"></TD>" "<TD style=\"background-color: rgb(176, 176, 176);\"></TD>" "<TD style=\"width: 30px; height: 50px; background-color: rgb(176, 176, 176);\"></TD>" "</TR>" "</TABLE>" "<CENTER></BODY>" "</HTML>", GetSystemTimeString(currTime, sysTimeStr), cg_upnp_getservername(serverName, sizeof(serverName))); httpRes = cg_http_response_new(); cg_http_response_setstatuscode(httpRes, CG_HTTP_STATUS_OK); cg_http_response_setcontent(httpRes, content); cg_http_response_setcontenttype(httpRes, "text/html"); cg_http_response_setcontentlength(httpRes, strlen(content)); postRet = cg_http_request_postresponse(httpReq, httpRes); cg_http_response_delete(httpRes); }