# HG changeset patch # User morphbr # Date 1174399210 0 # Node ID a0de91f6be04de507d7a04ba67a50a681bd10601 # Parent f176c820707753c8914c94438d32f4934c67560a [svn r422] - Updated gmyth_http regarding new Myth's XML style and URL's standards diff -r f176c8207077 -r a0de91f6be04 gmyth/src/gmyth_http.c --- a/gmyth/src/gmyth_http.c Mon Mar 19 22:00:25 2007 +0000 +++ b/gmyth/src/gmyth_http.c Tue Mar 20 14:00:10 2007 +0000 @@ -176,24 +176,41 @@ */ void get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg* epg) { - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"startChanId"), "%d", &(epg->startChanId)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"endChanId"), "%d", &(epg->endChanId)); - epg->version = g_strdup((char *)xmlGetProp(nodeTab, (xmlChar *)"version")); + xmlNode *ptr = nodeTab->children->next->children; + epg->startTime = gmyth_util_string_to_time_val ((char *)ptr->content); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"protoVer"), "%d", &(epg->protoVer)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"totalCount"), "%d", &(epg->totalCount)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"numOfChannels"), "%d", &(epg->numOfChannels)); + ptr = ptr->parent->next->next->children; + epg->endTime = gmyth_util_string_to_time_val ((char *)ptr->content); - epg->asOf = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf")); - epg->startTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"startTime")); - epg->endTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"endTime")); + ptr = ptr->parent->next->next->children; + sscanf ((char *)ptr->content, "%d", &(epg->startChanId)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"details"), "%d", &(epg->details)); + ptr = ptr->parent->next->next->children; + sscanf ((char *)ptr->content, "%d", &(epg->endChanId)); + ptr = ptr->parent->next->next->children; + sscanf ((char *)ptr->content, "%d", &(epg->numOfChannels)); + + ptr = ptr->parent->next->next->children; + sscanf ((char *)ptr->content, "%d", &(epg->details)); + + ptr = ptr->parent->next->next->children; + sscanf ((char *)ptr->content, "%d", &(epg->totalCount)); + + ptr = ptr->parent->next->next->children; + epg->asOf = gmyth_util_string_to_time_val ((char *)ptr->content); + + ptr = ptr->parent->next->next->children; + epg->version = g_strdup((char *)ptr->content); + + ptr = ptr->parent->next->next->children; + sscanf ((char *)ptr->content, "%d", &(epg->protoVer)); + + ptr = ptr->parent->next->next->children; // go to Channel section and retrieve Channels and Programs if ( epg->numOfChannels > 0 ) - get_Channel_List(nodeTab->children->next->children->next, epg); + get_Channel_List(ptr, epg); else epg->channelList = NULL; } @@ -212,13 +229,13 @@ int i; result = getXPath((xmlChar *)"/*", doc); - if (result) + if (result) { nodeset = result->nodesetval; - for (i=0; i < nodeset->nodeNr; i++) + for (i=0; i < nodeset->nodeNr; i++) { keyword = (xmlChar*)nodeset->nodeTab[i]->name; - if (g_ascii_strcasecmp((char *)keyword, "ProgramGuide") == 0) + if (g_ascii_strcasecmp((char *)keyword, "GetProgramGuideResponse") == 0) { get_ProgramGuide_Properties(nodeset->nodeTab[i], epg); break; @@ -254,7 +271,7 @@ endtime = (gchar*)xmlURIEscapeStr( (const xmlChar*)gmyth_util_time_to_mythformat_from_time_val(EndTime), NULL ); GString* command = g_string_new(""); - g_string_printf(command, "getProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" \ + g_string_printf(command, "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" \ "&NumOfChannels=%d&Details=%s", starttime, endtime, \ StartChanId, NumOfChannels, Details ); gmyth_debug ( "HTTP Request command = %s\n", command->str ); @@ -427,20 +444,23 @@ */ void get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded* recorded) { - recorded->version = g_strdup((char *)\ - xmlGetProp(nodeTab, (xmlChar *)"version")); + xmlNode *ptr = nodeTab->children->next->children; + sscanf ((char *)ptr->content, "%d", &(recorded->totalCount)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\ - "protoVer"), "%d", &(recorded->protoVer)); - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\ - "totalCount"), "%d", &(recorded->totalCount)); + ptr = ptr->parent->next->next->children; + recorded->asOf = gmyth_util_string_to_time_val \ + ((char *)ptr->content); - recorded->asOf = gmyth_util_string_to_time_val \ - ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf")); + ptr = ptr->parent->next->next->children; + recorded->version = g_strdup((char *)ptr->content); + ptr = ptr->parent->next->next->children; + sscanf ((char *)ptr->content, "%d", &(recorded->protoVer)); + + ptr = ptr->parent->next->next->children; if ( recorded->totalCount > 0) - recorded->programList = get_Recorded_Programs(nodeTab->children->next); + recorded->programList = get_Recorded_Programs(ptr->children); } @@ -459,13 +479,13 @@ int i; result = getXPath((xmlChar *)"/*", doc); - if (result) + if (result) { nodeset = result->nodesetval; - for (i=0; i < nodeset->nodeNr; i++) + for (i=0; i < nodeset->nodeNr; i++) { keyword = (xmlChar*)nodeset->nodeTab[i]->name; - if (g_ascii_strcasecmp((char *)keyword, "Recorded") == 0) + if (g_ascii_strcasecmp((char *)keyword, "GetRecordedResponse") == 0) { get_Recorded_Properties(nodeset->nodeTab[i], recorded); break; @@ -489,7 +509,7 @@ chunk.size = 0; GString* command = g_string_new(""); - g_string_printf(command, "getRecorded"); + g_string_printf(command, "GetRecorded"); chunk = gmyth_http_request(backend_info, command); if (chunk.memory != NULL) @@ -522,7 +542,7 @@ chunk.size = 0; GString* command = g_string_new(""); - g_string_printf(command, "getSetting?Key=%s&HostName=%s&Default=NULL", \ + g_string_printf(command, "GetSetting?Key=%s&HostName=%s&Default=NULL", \ key, hostname); chunk = gmyth_http_request(backend_info, command); @@ -531,7 +551,7 @@ { xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory)); - result = getXPath((xmlChar *)"/*", doc); + result = getXPath((xmlChar *)"/GetSettingResponse/Values/*", doc); if (result) { @@ -539,8 +559,8 @@ keyword = (xmlChar*)nodeset->nodeTab[0]->name; if (g_ascii_strcasecmp((char *)keyword, "Value") == 0) { - // Here we have the value - value = (gchar*)nodeset->nodeTab[0]->children->content; + // Here we have the value + value = (gchar*)nodeset->nodeTab[0]->children->content; } xmlXPathFreeObject (result); } @@ -707,7 +727,7 @@ chunk.size = 0; GString* command = g_string_new(""); - g_string_printf(command, "getRecProfiles?groupname=%s", groupname); + g_string_printf(command, "GetRecProfiles?groupname=%s", groupname); chunk = gmyth_http_request(backend_info, command); @@ -782,7 +802,7 @@ MemoryStruct *mem = (struct _MemoryStruct *)data; mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1); - if (mem->memory) + if (mem->memory) { memcpy(&(mem->memory[mem->size]), ptr, realsize); mem->size += realsize; @@ -802,16 +822,16 @@ GString *command) { LIBXML_TEST_VERSION - + size_t size = strlen(backend_info->hostname) + \ - strlen(command->str) + 14; + strlen(command->str) + 20; gchar *URL = (gchar *)g_malloc(sizeof(gchar)*size); - g_snprintf(URL, size, "http://%s:%d/%s", \ + g_snprintf(URL, size, "http://%s:%d/Myth/%s", \ backend_info->hostname, \ backend_info->status_port, \ command->str); - + CURL *curl_handle; MemoryStruct chunk; diff -r f176c8207077 -r a0de91f6be04 gmyth/tests/gmyth_test_http.c --- a/gmyth/tests/gmyth_test_http.c Mon Mar 19 22:00:25 2007 +0000 +++ b/gmyth/tests/gmyth_test_http.c Tue Mar 20 14:00:10 2007 +0000 @@ -11,28 +11,29 @@ backend_info = gmyth_backend_info_new (); - gmyth_backend_info_set_hostname (backend_info, "192.168.3.165"); + gmyth_backend_info_set_hostname (backend_info, "127.0.0.1"); gmyth_backend_info_set_port (backend_info, 6543); gmyth_backend_info_set_status_port (backend_info, 6544); - GTimeVal* start = gmyth_util_string_to_time_val("2006-01-01T00:00:00"); - GTimeVal* end = gmyth_util_string_to_time_val("2007-03-10T00:00:00"); + //GTimeVal* start = gmyth_util_string_to_time_val("2006-01-01T00:00:00"); + //GTimeVal* end = gmyth_util_string_to_time_val("2007-03-10T00:00:00"); + GMythEpg epg; epg = gmyth_http_retrieve_epg(backend_info, start, end, 1000, 10000, "1"); - if ( NULL == epg.channelList || g_slist_length( epg.channelList ) <= 0 ) - printf( "Channel list is empty!!!" ); + //if ( NULL == epg.channelList || g_slist_length( epg.channelList ) <= 0 ) + // printf( "Channel list is empty!!!" ); //GMythRecorded recorded; //recorded = gmyth_http_retrieve_recorded(backend_info); - //GMythRecorded_Program* program = recorded.programList->data; + //GMythRecorded_Program* program = recorded.ProgramList->data; //GSList* profiles = gmyth_http_retrieve_rec_profiles(backend_info, "Transcoders"); //GMythRecProfile* prof = profiles->data; - + //gchar* sett = gmyth_http_retrieve_setting(backend_info, "JobQueueTranscodeCommand", "wakko"); GMythRecProfile* profile = gmyth_recprofile_new();