[svn r422] - Updated gmyth_http regarding new Myth's XML style and URL's standards
1.1 --- a/gmyth/src/gmyth_http.c Mon Mar 19 22:00:25 2007 +0000
1.2 +++ b/gmyth/src/gmyth_http.c Tue Mar 20 14:00:10 2007 +0000
1.3 @@ -176,24 +176,41 @@
1.4 */
1.5 void get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg* epg)
1.6 {
1.7 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"startChanId"), "%d", &(epg->startChanId));
1.8 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"endChanId"), "%d", &(epg->endChanId));
1.9
1.10 - epg->version = g_strdup((char *)xmlGetProp(nodeTab, (xmlChar *)"version"));
1.11 + xmlNode *ptr = nodeTab->children->next->children;
1.12 + epg->startTime = gmyth_util_string_to_time_val ((char *)ptr->content);
1.13
1.14 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"protoVer"), "%d", &(epg->protoVer));
1.15 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"totalCount"), "%d", &(epg->totalCount));
1.16 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"numOfChannels"), "%d", &(epg->numOfChannels));
1.17 + ptr = ptr->parent->next->next->children;
1.18 + epg->endTime = gmyth_util_string_to_time_val ((char *)ptr->content);
1.19
1.20 - epg->asOf = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf"));
1.21 - epg->startTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"startTime"));
1.22 - epg->endTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"endTime"));
1.23 + ptr = ptr->parent->next->next->children;
1.24 + sscanf ((char *)ptr->content, "%d", &(epg->startChanId));
1.25
1.26 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"details"), "%d", &(epg->details));
1.27 + ptr = ptr->parent->next->next->children;
1.28 + sscanf ((char *)ptr->content, "%d", &(epg->endChanId));
1.29
1.30 + ptr = ptr->parent->next->next->children;
1.31 + sscanf ((char *)ptr->content, "%d", &(epg->numOfChannels));
1.32 +
1.33 + ptr = ptr->parent->next->next->children;
1.34 + sscanf ((char *)ptr->content, "%d", &(epg->details));
1.35 +
1.36 + ptr = ptr->parent->next->next->children;
1.37 + sscanf ((char *)ptr->content, "%d", &(epg->totalCount));
1.38 +
1.39 + ptr = ptr->parent->next->next->children;
1.40 + epg->asOf = gmyth_util_string_to_time_val ((char *)ptr->content);
1.41 +
1.42 + ptr = ptr->parent->next->next->children;
1.43 + epg->version = g_strdup((char *)ptr->content);
1.44 +
1.45 + ptr = ptr->parent->next->next->children;
1.46 + sscanf ((char *)ptr->content, "%d", &(epg->protoVer));
1.47 +
1.48 + ptr = ptr->parent->next->next->children;
1.49 // go to Channel section and retrieve Channels and Programs
1.50 if ( epg->numOfChannels > 0 )
1.51 - get_Channel_List(nodeTab->children->next->children->next, epg);
1.52 + get_Channel_List(ptr, epg);
1.53 else
1.54 epg->channelList = NULL;
1.55 }
1.56 @@ -212,13 +229,13 @@
1.57 int i;
1.58 result = getXPath((xmlChar *)"/*", doc);
1.59
1.60 - if (result)
1.61 + if (result)
1.62 {
1.63 nodeset = result->nodesetval;
1.64 - for (i=0; i < nodeset->nodeNr; i++)
1.65 + for (i=0; i < nodeset->nodeNr; i++)
1.66 {
1.67 keyword = (xmlChar*)nodeset->nodeTab[i]->name;
1.68 - if (g_ascii_strcasecmp((char *)keyword, "ProgramGuide") == 0)
1.69 + if (g_ascii_strcasecmp((char *)keyword, "GetProgramGuideResponse") == 0)
1.70 {
1.71 get_ProgramGuide_Properties(nodeset->nodeTab[i], epg);
1.72 break;
1.73 @@ -254,7 +271,7 @@
1.74 endtime = (gchar*)xmlURIEscapeStr( (const xmlChar*)gmyth_util_time_to_mythformat_from_time_val(EndTime), NULL );
1.75
1.76 GString* command = g_string_new("");
1.77 - g_string_printf(command, "getProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" \
1.78 + g_string_printf(command, "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" \
1.79 "&NumOfChannels=%d&Details=%s", starttime, endtime, \
1.80 StartChanId, NumOfChannels, Details );
1.81 gmyth_debug ( "HTTP Request command = %s\n", command->str );
1.82 @@ -427,20 +444,23 @@
1.83 */
1.84 void get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded* recorded)
1.85 {
1.86 - recorded->version = g_strdup((char *)\
1.87 - xmlGetProp(nodeTab, (xmlChar *)"version"));
1.88 + xmlNode *ptr = nodeTab->children->next->children;
1.89 + sscanf ((char *)ptr->content, "%d", &(recorded->totalCount));
1.90
1.91 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\
1.92 - "protoVer"), "%d", &(recorded->protoVer));
1.93
1.94 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\
1.95 - "totalCount"), "%d", &(recorded->totalCount));
1.96 + ptr = ptr->parent->next->next->children;
1.97 + recorded->asOf = gmyth_util_string_to_time_val \
1.98 + ((char *)ptr->content);
1.99
1.100 - recorded->asOf = gmyth_util_string_to_time_val \
1.101 - ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf"));
1.102 + ptr = ptr->parent->next->next->children;
1.103 + recorded->version = g_strdup((char *)ptr->content);
1.104
1.105 + ptr = ptr->parent->next->next->children;
1.106 + sscanf ((char *)ptr->content, "%d", &(recorded->protoVer));
1.107 +
1.108 + ptr = ptr->parent->next->next->children;
1.109 if ( recorded->totalCount > 0)
1.110 - recorded->programList = get_Recorded_Programs(nodeTab->children->next);
1.111 + recorded->programList = get_Recorded_Programs(ptr->children);
1.112
1.113 }
1.114
1.115 @@ -459,13 +479,13 @@
1.116 int i;
1.117 result = getXPath((xmlChar *)"/*", doc);
1.118
1.119 - if (result)
1.120 + if (result)
1.121 {
1.122 nodeset = result->nodesetval;
1.123 - for (i=0; i < nodeset->nodeNr; i++)
1.124 + for (i=0; i < nodeset->nodeNr; i++)
1.125 {
1.126 keyword = (xmlChar*)nodeset->nodeTab[i]->name;
1.127 - if (g_ascii_strcasecmp((char *)keyword, "Recorded") == 0)
1.128 + if (g_ascii_strcasecmp((char *)keyword, "GetRecordedResponse") == 0)
1.129 {
1.130 get_Recorded_Properties(nodeset->nodeTab[i], recorded);
1.131 break;
1.132 @@ -489,7 +509,7 @@
1.133 chunk.size = 0;
1.134
1.135 GString* command = g_string_new("");
1.136 - g_string_printf(command, "getRecorded");
1.137 + g_string_printf(command, "GetRecorded");
1.138
1.139 chunk = gmyth_http_request(backend_info, command);
1.140 if (chunk.memory != NULL)
1.141 @@ -522,7 +542,7 @@
1.142 chunk.size = 0;
1.143
1.144 GString* command = g_string_new("");
1.145 - g_string_printf(command, "getSetting?Key=%s&HostName=%s&Default=NULL", \
1.146 + g_string_printf(command, "GetSetting?Key=%s&HostName=%s&Default=NULL", \
1.147 key, hostname);
1.148
1.149 chunk = gmyth_http_request(backend_info, command);
1.150 @@ -531,7 +551,7 @@
1.151 {
1.152 xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
1.153
1.154 - result = getXPath((xmlChar *)"/*", doc);
1.155 + result = getXPath((xmlChar *)"/GetSettingResponse/Values/*", doc);
1.156
1.157 if (result)
1.158 {
1.159 @@ -539,8 +559,8 @@
1.160 keyword = (xmlChar*)nodeset->nodeTab[0]->name;
1.161 if (g_ascii_strcasecmp((char *)keyword, "Value") == 0)
1.162 {
1.163 - // Here we have the value
1.164 - value = (gchar*)nodeset->nodeTab[0]->children->content;
1.165 + // Here we have the value
1.166 + value = (gchar*)nodeset->nodeTab[0]->children->content;
1.167 }
1.168 xmlXPathFreeObject (result);
1.169 }
1.170 @@ -707,7 +727,7 @@
1.171 chunk.size = 0;
1.172
1.173 GString* command = g_string_new("");
1.174 - g_string_printf(command, "getRecProfiles?groupname=%s", groupname);
1.175 + g_string_printf(command, "GetRecProfiles?groupname=%s", groupname);
1.176
1.177 chunk = gmyth_http_request(backend_info, command);
1.178
1.179 @@ -782,7 +802,7 @@
1.180 MemoryStruct *mem = (struct _MemoryStruct *)data;
1.181
1.182 mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
1.183 - if (mem->memory)
1.184 + if (mem->memory)
1.185 {
1.186 memcpy(&(mem->memory[mem->size]), ptr, realsize);
1.187 mem->size += realsize;
1.188 @@ -802,16 +822,16 @@
1.189 GString *command)
1.190 {
1.191 LIBXML_TEST_VERSION
1.192 -
1.193 +
1.194 size_t size = strlen(backend_info->hostname) + \
1.195 - strlen(command->str) + 14;
1.196 + strlen(command->str) + 20;
1.197
1.198 gchar *URL = (gchar *)g_malloc(sizeof(gchar)*size);
1.199 - g_snprintf(URL, size, "http://%s:%d/%s", \
1.200 + g_snprintf(URL, size, "http://%s:%d/Myth/%s", \
1.201 backend_info->hostname, \
1.202 backend_info->status_port, \
1.203 command->str);
1.204 -
1.205 +
1.206 CURL *curl_handle;
1.207
1.208 MemoryStruct chunk;
2.1 --- a/gmyth/tests/gmyth_test_http.c Mon Mar 19 22:00:25 2007 +0000
2.2 +++ b/gmyth/tests/gmyth_test_http.c Tue Mar 20 14:00:10 2007 +0000
2.3 @@ -11,28 +11,29 @@
2.4
2.5 backend_info = gmyth_backend_info_new ();
2.6
2.7 - gmyth_backend_info_set_hostname (backend_info, "192.168.3.165");
2.8 + gmyth_backend_info_set_hostname (backend_info, "127.0.0.1");
2.9 gmyth_backend_info_set_port (backend_info, 6543);
2.10 gmyth_backend_info_set_status_port (backend_info, 6544);
2.11
2.12 - GTimeVal* start = gmyth_util_string_to_time_val("2006-01-01T00:00:00");
2.13 - GTimeVal* end = gmyth_util_string_to_time_val("2007-03-10T00:00:00");
2.14 + //GTimeVal* start = gmyth_util_string_to_time_val("2006-01-01T00:00:00");
2.15 + //GTimeVal* end = gmyth_util_string_to_time_val("2007-03-10T00:00:00");
2.16 +
2.17 GMythEpg epg;
2.18 epg = gmyth_http_retrieve_epg(backend_info, start, end, 1000, 10000, "1");
2.19
2.20 - if ( NULL == epg.channelList || g_slist_length( epg.channelList ) <= 0 )
2.21 - printf( "Channel list is empty!!!" );
2.22 + //if ( NULL == epg.channelList || g_slist_length( epg.channelList ) <= 0 )
2.23 + // printf( "Channel list is empty!!!" );
2.24
2.25 //GMythRecorded recorded;
2.26 //recorded = gmyth_http_retrieve_recorded(backend_info);
2.27
2.28 - //GMythRecorded_Program* program = recorded.programList->data;
2.29 + //GMythRecorded_Program* program = recorded.ProgramList->data;
2.30
2.31 //GSList* profiles = gmyth_http_retrieve_rec_profiles(backend_info, "Transcoders");
2.32
2.33 //GMythRecProfile* prof = profiles->data;
2.34
2.35 -
2.36 + //gchar* sett = gmyth_http_retrieve_setting(backend_info, "JobQueueTranscodeCommand", "wakko");
2.37
2.38 GMythRecProfile* profile = gmyth_recprofile_new();
2.39