[svn r354] - Bug fixes in gmyth_http.c: node=node->next inside epg loop.
- Coded "retrieve_recorded" inside gmyth_http.c
- Added status_port to backend_info struct
1.1 --- a/gmyth/src/gmyth_backendinfo.c Sat Feb 10 22:12:54 2007 +0000
1.2 +++ b/gmyth/src/gmyth_backendinfo.c Mon Feb 12 13:31:29 2007 +0000
1.3 @@ -196,12 +196,25 @@
1.4
1.5 if ( port <= 0 )
1.6 {
1.7 - gmyth_debug ( "Error trying to set a hostname equals to NULL (it doesn't using UPnP)." );
1.8 + gmyth_debug ( "Error trying to set a port less than 0." );
1.9 } else {
1.10 backend_info->port = port;
1.11 }
1.12 }
1.13
1.14 +void
1.15 +gmyth_backend_info_set_status_port (GMythBackendInfo *backend_info, const gint port )
1.16 +{
1.17 + g_return_if_fail (backend_info != NULL);
1.18 +
1.19 + if ( port <= 0 )
1.20 + {
1.21 + gmyth_debug ( "Error trying to set the status port to less than zero." );
1.22 + } else {
1.23 + backend_info->status_port = port;
1.24 + }
1.25 +}
1.26 +
1.27 const gchar*
1.28 gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info)
1.29 {
2.1 --- a/gmyth/src/gmyth_backendinfo.h Sat Feb 10 22:12:54 2007 +0000
2.2 +++ b/gmyth/src/gmyth_backendinfo.h Mon Feb 12 13:31:29 2007 +0000
2.3 @@ -61,6 +61,7 @@
2.4 gchar *password;
2.5 gchar *db_name;
2.6 gint port;
2.7 + gint status_port;
2.8 gchar *path;
2.9
2.10 GMythURI* uri;
2.11 @@ -85,6 +86,8 @@
2.12 const gchar *db_name);
2.13 void gmyth_backend_info_set_port (GMythBackendInfo *backend_info,
2.14 gint port);
2.15 +void gmyth_backend_info_set_status_port (GMythBackendInfo *backend_info,
2.16 + gint port);
2.17 const gchar* gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info);
2.18 const gchar* gmyth_backend_info_get_username (GMythBackendInfo *backend_info);
2.19 const gchar* gmyth_backend_info_get_password (GMythBackendInfo *backend_info);
3.1 --- a/gmyth/src/gmyth_http.c Sat Feb 10 22:12:54 2007 +0000
3.2 +++ b/gmyth/src/gmyth_http.c Mon Feb 12 13:31:29 2007 +0000
3.3 @@ -42,21 +42,21 @@
3.4 xmlXPathObjectPtr
3.5 getnodeset(xmlDocPtr doc, xmlChar *xpath)
3.6 {
3.7 -
3.8 - xmlXPathContextPtr context;
3.9 - xmlXPathObjectPtr result;
3.10 -
3.11 - context = xmlXPathNewContext(doc);
3.12 - result = xmlXPathEvalExpression(xpath, context);
3.13 -
3.14 - if(xmlXPathNodeSetIsEmpty(result->nodesetval))
3.15 +
3.16 + xmlXPathContextPtr context;
3.17 + xmlXPathObjectPtr result;
3.18 +
3.19 + context = xmlXPathNewContext(doc);
3.20 + result = xmlXPathEvalExpression(xpath, context);
3.21 +
3.22 + if(xmlXPathNodeSetIsEmpty(result->nodesetval))
3.23 {
3.24 - g_fprintf(stderr, "Error: No result at XPath\n");
3.25 - return NULL;
3.26 + g_fprintf(stderr, "Error: No result at XPath\n");
3.27 + return NULL;
3.28 }
3.29 -
3.30 - xmlXPathFreeContext(context);
3.31 - return result;
3.32 +
3.33 + xmlXPathFreeContext(context);
3.34 + return result;
3.35 }
3.36
3.37
3.38 @@ -89,33 +89,43 @@
3.39 */
3.40 GSList* get_Program_List(xmlNodePtr node)
3.41 {
3.42 - GSList* program_list = NULL;
3.43 -
3.44 - while (node != NULL)
3.45 - {
3.46 - if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
3.47 - {
3.48 - GMythProgram* program = (GMythProgram*)g_malloc(sizeof(struct _GMythProgram));
3.49 + GSList* program_list = NULL;
3.50 +
3.51 + while (node != NULL)
3.52 + {
3.53 + if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
3.54 + {
3.55 + GMythProgram* program = (GMythProgram*)\
3.56 + g_malloc(sizeof(struct _GMythProgram));
3.57 +
3.58 + program->title = g_string_new((char *)\
3.59 + xmlGetProp(node, (xmlChar *)"title"));
3.60
3.61 - program->title = g_string_new((char *)xmlGetProp(node, (xmlChar *)"title"));
3.62 - program->subtitle = g_string_new((char *)xmlGetProp(node, (xmlChar *)"subtitle"));
3.63 - program->catType = g_string_new((char *)xmlGetProp(node, (xmlChar *)"catType"));
3.64 - program->category = g_string_new((char *)xmlGetProp(node, (xmlChar *)"category"));
3.65 -
3.66 - sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"), "%d", &(program->repeat));
3.67 + program->subtitle = g_string_new((char *)\
3.68 + xmlGetProp(node, (xmlChar *)"subtitle"));
3.69
3.70 - program->startTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(node, \
3.71 - (xmlChar *)"startTime"));
3.72 - program->endTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(node, \
3.73 - (xmlChar *)"endTime"));
3.74 + program->catType = g_string_new((char *)\
3.75 + xmlGetProp(node, (xmlChar *)"catType"));
3.76
3.77 - program_list = g_slist_append(program_list, program);
3.78 - }
3.79 + program->category = g_string_new((char *)\
3.80 + xmlGetProp(node, (xmlChar *)"category"));
3.81 +
3.82 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\
3.83 + "%d", &(program->repeat));
3.84 +
3.85 + program->startTime = gmyth_util_string_to_time_val \
3.86 + ((char *)xmlGetProp(node,(xmlChar *)"startTime"));
3.87
3.88 - node = node->next;
3.89 - }
3.90 -
3.91 - return program_list;
3.92 + program->endTime = gmyth_util_string_to_time_val \
3.93 + ((char *)xmlGetProp(node,(xmlChar *)"endTime"));
3.94 +
3.95 + program_list = g_slist_append(program_list, program);
3.96 + }
3.97 +
3.98 + node = node->next;
3.99 + }
3.100 +
3.101 + return program_list;
3.102 }
3.103
3.104 /** Retrieves the Channel List from the ProgramGuide
3.105 @@ -126,26 +136,36 @@
3.106 */
3.107 void get_Channel_List (xmlNodePtr node, GMythEpg* epg)
3.108 {
3.109 - int i;
3.110 - epg->channelList = NULL;
3.111 -
3.112 - if (node != NULL) {
3.113 -
3.114 - for (i=1; i <= epg->numOfChannels; i++)
3.115 - {
3.116 - GMythChannel* channel = (GMythChannel*)g_malloc(sizeof(struct _GMythChannel));
3.117 -
3.118 - channel->channelName = g_string_new((char *)xmlGetProp(node, (xmlChar *)"channelName"));
3.119 - channel->chanNum = g_string_new((char *)xmlGetProp(node, (xmlChar *)"chanNum"));
3.120 -
3.121 - sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"), "%d", &(channel->chanId));
3.122 - sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"), "%d", &(channel->callSign));
3.123 -
3.124 - channel->programList = get_Program_List(node->children);
3.125 -
3.126 - epg->channelList = g_slist_append(epg->channelList, channel);
3.127 - }
3.128 + epg->channelList = NULL;
3.129 +
3.130 + while (node != NULL) {
3.131 +
3.132 + if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
3.133 + {
3.134 + GMythChannel* channel = (GMythChannel*)g_malloc\
3.135 + (sizeof(struct _GMythChannel));
3.136 +
3.137 + channel->channelName = g_string_new((char *)\
3.138 + xmlGetProp(node,\
3.139 + (xmlChar *)"channelName"));
3.140 +
3.141 + channel->chanNum = g_string_new((char *)\
3.142 + xmlGetProp(node, (xmlChar *)"chanNum"));
3.143 +
3.144 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"),\
3.145 + "%d", &(channel->chanId));
3.146 +
3.147 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"),\
3.148 + "%d", &(channel->callSign));
3.149 +
3.150 + channel->programList = get_Program_List(node->children);
3.151 +
3.152 + epg->channelList = g_slist_append(epg->channelList, channel);
3.153 +
3.154 }
3.155 +
3.156 + node=node->next;
3.157 + }
3.158 }
3.159
3.160 /** Retrieves the properties from the ProgramGuide
3.161 @@ -156,26 +176,26 @@
3.162 */
3.163 void get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg* epg)
3.164 {
3.165 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"startChanId"), "%d", &(epg->startChanId));
3.166 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"endChanId"), "%d", &(epg->endChanId));
3.167 -
3.168 - epg->version = g_string_new((char *)xmlGetProp(nodeTab, (xmlChar *)"version"));
3.169 -
3.170 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"protoVer"), "%d", &(epg->protoVer));
3.171 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"totalCount"), "%d", &(epg->totalCount));
3.172 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"numOfChannels"), "%d", &(epg->numOfChannels));
3.173 -
3.174 - epg->asOf = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf"));
3.175 - epg->startTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"startTime"));
3.176 - epg->endTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"endTime"));
3.177 -
3.178 - sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"details"), "%d", &(epg->details));
3.179 -
3.180 - // go to Channel section and retrieve Channels and Programs
3.181 - if ( epg->numOfChannels > 0 )
3.182 - get_Channel_List(nodeTab->children->next->children->next, epg);
3.183 - else
3.184 - epg->channelList = NULL;
3.185 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"startChanId"), "%d", &(epg->startChanId));
3.186 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"endChanId"), "%d", &(epg->endChanId));
3.187 +
3.188 + epg->version = g_string_new((char *)xmlGetProp(nodeTab, (xmlChar *)"version"));
3.189 +
3.190 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"protoVer"), "%d", &(epg->protoVer));
3.191 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"totalCount"), "%d", &(epg->totalCount));
3.192 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"numOfChannels"), "%d", &(epg->numOfChannels));
3.193 +
3.194 + epg->asOf = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf"));
3.195 + epg->startTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"startTime"));
3.196 + epg->endTime = gmyth_util_string_to_time_val ((char *)xmlGetProp(nodeTab, (xmlChar *)"endTime"));
3.197 +
3.198 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)"details"), "%d", &(epg->details));
3.199 +
3.200 + // go to Channel section and retrieve Channels and Programs
3.201 + if ( epg->numOfChannels > 0 )
3.202 + get_Channel_List(nodeTab->children->next->children->next, epg);
3.203 + else
3.204 + epg->channelList = NULL;
3.205 }
3.206
3.207 /** Aux function to retrieve the Eletronic Program Guide
3.208 @@ -196,17 +216,303 @@
3.209 {
3.210 nodeset = result->nodesetval;
3.211 for (i=0; i < nodeset->nodeNr; i++)
3.212 - {
3.213 - keyword = (xmlChar*)nodeset->nodeTab[i]->name;
3.214 - if (g_ascii_strcasecmp((char *)keyword, "ProgramGuide") == 0)
3.215 - get_ProgramGuide_Properties(nodeset->nodeTab[i], epg);
3.216 - }
3.217 + {
3.218 + keyword = (xmlChar*)nodeset->nodeTab[i]->name;
3.219 + if (g_ascii_strcasecmp((char *)keyword, "ProgramGuide") == 0)
3.220 + {
3.221 + get_ProgramGuide_Properties(nodeset->nodeTab[i], epg);
3.222 + break;
3.223 + }
3.224 + }
3.225 xmlXPathFreeObject (result);
3.226 }
3.227
3.228 }
3.229
3.230
3.231 +
3.232 +/** Retrieves the Eletronic Program Guide from the backend
3.233 + *
3.234 + * @param doc An XML document (xmlDocPtr)
3.235 + * @return The epg
3.236 + */
3.237 +GMythEpg gmyth_http_retrieve_epg (GMythBackendInfo *backend_info, \
3.238 + GTimeVal* StartTime, GTimeVal* EndTime, \
3.239 + gint StartChanId, gint NumOfChannels, \
3.240 + gchar* Details)
3.241 +{
3.242 + GMythEpg epg;
3.243 + MemoryStruct chunk;
3.244 +
3.245 + chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
3.246 + chunk.size = 0; /* no data at this point */
3.247 +
3.248 + gchar* starttime = (gchar*)g_malloc(sizeof(gchar)*20);
3.249 + starttime = gmyth_util_time_to_mythformat_from_time_val(StartTime);
3.250 +
3.251 + gchar* endtime = (gchar*)g_malloc(sizeof(gchar)*20);
3.252 + endtime = gmyth_util_time_to_mythformat_from_time_val(EndTime);
3.253 +
3.254 + GString* command = g_string_new("");
3.255 + g_string_printf(command, "getProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d"
3.256 + "&NumOfChannels=%d&Details=%s", starttime, endtime, \
3.257 + StartChanId, NumOfChannels, Details);
3.258 +
3.259 + chunk = gmyth_http_request(backend_info, command);
3.260 + if (chunk.memory != NULL)
3.261 + {
3.262 + xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
3.263 + getEpg(doc, &epg);
3.264 + free(chunk.memory);
3.265 + }
3.266 +
3.267 + return epg;
3.268 +}
3.269 +
3.270 +
3.271 +GMythRecorded_Recording
3.272 +retrieve_recorded_recording (xmlNodePtr node)
3.273 +{
3.274 + GMythRecorded_Recording recording;
3.275 +
3.276 + if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
3.277 + {
3.278 +
3.279 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupInType"),\
3.280 + "%d", &(recording.dupInType));
3.281 +
3.282 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupMethod"),\
3.283 + "%d", &(recording.dupMethod));
3.284 +
3.285 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"preRollSeconds"),\
3.286 + "%d", &(recording.preRollSeconds));
3.287 +
3.288 + recording.playGroup = g_string_new((char *)\
3.289 + xmlGetProp(node, (xmlChar *)"playGroup"));
3.290 +
3.291 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"recPriority"),\
3.292 + "%d", &(recording.recPriority));
3.293 +
3.294 + recording.recStartTs = gmyth_util_string_to_time_val\
3.295 + ((char *)xmlGetProp(node, (xmlChar *)"recStartTs"));
3.296 + }
3.297 +
3.298 + return recording;
3.299 +}
3.300 +
3.301 +
3.302 +GMythRecorded_Channel retrieve_recorded_channel (xmlNodePtr node)
3.303 +{
3.304 + GMythRecorded_Channel channel;
3.305 +
3.306 + if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
3.307 + {
3.308 +
3.309 +
3.310 + channel.chanFilters = g_string_new((char *)\
3.311 + xmlGetProp(node, (xmlChar *)"chanFilters"));
3.312 +
3.313 + channel.channelName = g_string_new((char *)\
3.314 + xmlGetProp(node, (xmlChar *)"channelName"));
3.315 +
3.316 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanNum"),\
3.317 + "%d", &(channel.chanNum));
3.318 +
3.319 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"sourceId"),\
3.320 + "%d", &(channel.sourceId));
3.321 +
3.322 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"commFree"),\
3.323 + "%d", &(channel.commFree));
3.324 +
3.325 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"inputId"),\
3.326 + "%d", &(channel.inputId));
3.327 +
3.328 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"),\
3.329 + "%d", &(channel.chanId));
3.330 +
3.331 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"),\
3.332 + "%d", &(channel.callSign));
3.333 + }
3.334 +
3.335 + return channel;
3.336 +}
3.337 +
3.338 +
3.339 +
3.340 +/** Retrieves all the programs from Recorded XML
3.341 + *
3.342 + * @param nodeTab A pointer to a node inside the XML
3.343 + * @param recorded The struct where is the current epg
3.344 + * @return list with all the recorded programs
3.345 + */
3.346 +GSList* get_Recorded_Programs(xmlNodePtr node)
3.347 +{
3.348 + GSList* programList = NULL;
3.349 +
3.350 + while (node != NULL) {
3.351 +
3.352 + if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
3.353 + {
3.354 +
3.355 + GMythRecorded_Program* program = (GMythRecorded_Program*)g_malloc\
3.356 + (sizeof(struct _GMythRecorded_Program));
3.357 +
3.358 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"programFlags"),\
3.359 + "%d", &(program->programFlags));
3.360 +
3.361 + program->title = g_string_new((char *)\
3.362 + xmlGetProp(node, (xmlChar *)"title"));
3.363 +
3.364 +
3.365 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"programId"),\
3.366 + "%d", &(program->programId));
3.367 +
3.368 + program->catType = g_string_new((char *)\
3.369 + xmlGetProp(node, (xmlChar *)"catType"));
3.370 +
3.371 + program->category = g_string_new((char *)\
3.372 + xmlGetProp(node, (xmlChar *)"category"));
3.373 +
3.374 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"seriesId"),\
3.375 + "%d", &(program->seriesId));
3.376 +
3.377 +
3.378 + program->startTime = gmyth_util_string_to_time_val\
3.379 + ((char *)xmlGetProp(node, (xmlChar *)"startTime"));
3.380 +
3.381 + program->endTime = gmyth_util_string_to_time_val\
3.382 + ((char *)xmlGetProp(node, (xmlChar *)"endTime"));
3.383 +
3.384 + program->lastModified = gmyth_util_string_to_time_val\
3.385 + ((char *)xmlGetProp(node, (xmlChar *)"lastModified"));
3.386 +
3.387 + /* TODO: FIX ME at gmyth_util
3.388 + program->asOf = gmyth_util_string_to_time_val\
3.389 + ((char *)xmlGetProp(node, (xmlChar *)"airdate"));*/
3.390 +
3.391 +
3.392 + program->subTitle = g_string_new((char *)\
3.393 + xmlGetProp(node, (xmlChar *)"subTitle"));
3.394 +
3.395 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"stars"),\
3.396 + "%d", &(program->stars));
3.397 +
3.398 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\
3.399 + "%d", &(program->repeat));
3.400 +
3.401 + sscanf ((char *)xmlGetProp(node, (xmlChar *)"fileSize"),\
3.402 + "%d", &(program->repeat));
3.403 +
3.404 + program->hostname = g_string_new((char *)\
3.405 + xmlGetProp(node, (xmlChar *)"hostname"));
3.406 +
3.407 + program->channel = retrieve_recorded_channel(node->children);
3.408 +
3.409 + // Skip the \n
3.410 + program->recording = retrieve_recorded_recording(node->children->next->next);
3.411 +
3.412 + // add to the list
3.413 + programList = g_slist_append(programList, program);
3.414 + }
3.415 +
3.416 + node = node->next;
3.417 + }
3.418 +
3.419 + return programList;
3.420 +}
3.421 +
3.422 +/** Retrieves the properties from Recorded XML
3.423 + *
3.424 + * @param nodeTab A pointer to a node inside the XML
3.425 + * @param recorded The struct where is the current epg
3.426 + * @return "recorded" from "param" updated
3.427 + */
3.428 +void get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded* recorded)
3.429 +{
3.430 + recorded->version = g_string_new((char *)\
3.431 + xmlGetProp(nodeTab, (xmlChar *)"version"));
3.432 +
3.433 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\
3.434 + "protoVer"), "%d", &(recorded->protoVer));
3.435 +
3.436 + sscanf ((char *)xmlGetProp(nodeTab, (xmlChar *)\
3.437 + "totalCount"), "%d", &(recorded->totalCount));
3.438 +
3.439 +
3.440 + recorded->asOf = gmyth_util_string_to_time_val \
3.441 + ((char *)xmlGetProp(nodeTab, (xmlChar *)"asOf"));
3.442 +
3.443 + if ( recorded->totalCount > 0)
3.444 + recorded->programList = get_Recorded_Programs(nodeTab->children->next);
3.445 +
3.446 +}
3.447 +
3.448 +
3.449 +/** Aux function to retrieve Recorded programs
3.450 + *
3.451 + * @param doc An XML document (xmlDocPtr)
3.452 + * @return The recorded var updated
3.453 + */
3.454 +void getRecorded(xmlDocPtr doc, GMythRecorded* recorded)
3.455 +{
3.456 + xmlXPathObjectPtr result;
3.457 + xmlNodeSetPtr nodeset;
3.458 + xmlChar *keyword;
3.459 +
3.460 + int i;
3.461 + result = getXPath((xmlChar *)"/*", doc);
3.462 +
3.463 + if (result)
3.464 + {
3.465 + nodeset = result->nodesetval;
3.466 + for (i=0; i < nodeset->nodeNr; i++)
3.467 + {
3.468 + keyword = (xmlChar*)nodeset->nodeTab[i]->name;
3.469 + if (g_ascii_strcasecmp((char *)keyword, "Recorded") == 0)
3.470 + {
3.471 + get_Recorded_Properties(nodeset->nodeTab[i], recorded);
3.472 + break;
3.473 + }
3.474 + }
3.475 + xmlXPathFreeObject (result);
3.476 + }
3.477 +
3.478 +}
3.479 +
3.480 +
3.481 +/** Function to retrieve the files that are recorded
3.482 + *
3.483 + */
3.484 +GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo *backend_info)
3.485 +{
3.486 + GMythRecorded recorded;
3.487 + MemoryStruct chunk;
3.488 +
3.489 + chunk.memory = NULL;
3.490 + chunk.size = 0;
3.491 +
3.492 + GString* command = g_string_new("");
3.493 + g_string_printf(command, "getRecorded");
3.494 +
3.495 + chunk = gmyth_http_request(backend_info, command);
3.496 + if (chunk.memory != NULL)
3.497 + {
3.498 + xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
3.499 + getRecorded(doc, &recorded);
3.500 + free(chunk.memory);
3.501 + }
3.502 +
3.503 +
3.504 + return recorded;
3.505 +}
3.506 +
3.507 +/** Function to retrieve settings on the backend
3.508 + *
3.509 + * @param backend_info infos about the backend
3.510 + * @param key the key you want to retrieve
3.511 + * @param hostname the hostname that the key is set up
3.512 + * @return the value of the key
3.513 + */
3.514 gchar* gmyth_http_retrieve_setting (GMythBackendInfo *backend_info,\
3.515 gchar* key, gchar* hostname)
3.516 {
3.517 @@ -215,7 +521,7 @@
3.518 xmlChar *keyword;
3.519 MemoryStruct chunk;
3.520 gchar* value = NULL;
3.521 -
3.522 +
3.523 chunk.memory = NULL;
3.524 chunk.size = 0;
3.525
3.526 @@ -250,40 +556,7 @@
3.527 }
3.528
3.529
3.530 -/** Retrieves the Eletronic Program Guide from the backend
3.531 - *
3.532 - * @param doc An XML document (xmlDocPtr)
3.533 - * @return The epg
3.534 - */
3.535 -GMythEpg retrieve_epg (GMythBackendInfo *backend_info, int port, \
3.536 - GTimeVal* StartTime, GTimeVal* EndTime, \
3.537 - gint StartChanId, gint NumOfChannels, \
3.538 - gchar* Details)
3.539 -{
3.540 - GMythEpg epg;
3.541 - MemoryStruct chunk;
3.542
3.543 - chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
3.544 - chunk.size = 0; /* no data at this point */
3.545 -
3.546 - gchar* starttime = (gchar*)g_malloc(sizeof(gchar)*20);
3.547 - starttime = gmyth_util_time_to_mythformat_from_time_val(StartTime);
3.548 -
3.549 - gchar* endtime = (gchar*)g_malloc(sizeof(gchar)*20);
3.550 - endtime = gmyth_util_time_to_mythformat_from_time_val(EndTime);
3.551 -
3.552 - GString* command = g_string_new("");
3.553 - g_string_printf(command, "getProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d"
3.554 - "&NumOfChannels=%d&Details=%s", starttime, endtime, \
3.555 - StartChanId, NumOfChannels, Details);
3.556 -
3.557 - chunk = gmyth_http_request(backend_info, command);
3.558 - xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
3.559 - getEpg(doc, &epg);
3.560 - free(chunk.memory);
3.561 -
3.562 - return epg;
3.563 -}
3.564
3.565 /* Aux functions got from libcurl */
3.566 void *myrealloc (void *ptr, size_t size)
3.567 @@ -351,13 +624,19 @@
3.568 * @return A string with the response from the server
3.569 * NULL if there is no response.
3.570 */
3.571 -MemoryStruct gmyth_http_request (GMythBackendInfo *backend_info, GString *command)
3.572 +MemoryStruct gmyth_http_request (GMythBackendInfo *backend_info, \
3.573 + GString *command)
3.574 {
3.575 LIBXML_TEST_VERSION
3.576
3.577 - size_t size = strlen(backend_info->hostname) + strlen(command->str) + 14;
3.578 + size_t size = strlen(backend_info->hostname) + \
3.579 + strlen(command->str) + 14;
3.580 +
3.581 gchar *URL = (gchar *)g_malloc(sizeof(gchar)*size);
3.582 - g_snprintf(URL, size, "http://%s:6544/%s", backend_info->hostname, command->str);
3.583 + g_snprintf(URL, size, "http://%s:%d/%s", \
3.584 + backend_info->hostname, \
3.585 + backend_info->status_port, \
3.586 + command->str);
3.587
3.588 CURL *curl_handle;
3.589
4.1 --- a/gmyth/src/gmyth_http.h Sat Feb 10 22:12:54 2007 +0000
4.2 +++ b/gmyth/src/gmyth_http.h Mon Feb 12 13:31:29 2007 +0000
4.3 @@ -48,60 +48,122 @@
4.4
4.5 #define MYTH_PORT_STATUS 6544
4.6
4.7 +typedef struct _GMythRecorded_Recording GMythRecorded_Recording;
4.8 +typedef struct _GMythRecorded_Channel GMythRecorded_Channel;
4.9 +typedef struct _GMythRecorded_Program GMythRecorded_Program;
4.10 +typedef struct _GMythRecorded GMythRecorded;
4.11 typedef struct _GMythProgram GMythProgram;
4.12 typedef struct _GMythChannel GMythChannel;
4.13 -typedef struct _GMythEpg GMythEpg;
4.14 -typedef struct _MemoryStruct MemoryStruct;
4.15 +typedef struct _GMythEpg GMythEpg;
4.16 +typedef struct _MemoryStruct MemoryStruct;
4.17
4.18 struct _MemoryStruct
4.19 {
4.20 - char *memory;
4.21 - size_t size;
4.22 + char *memory;
4.23 + size_t size;
4.24 };
4.25
4.26
4.27 struct _GMythProgram
4.28 {
4.29 - GString* title;
4.30 - GString* subtitle;
4.31 - GString* catType;
4.32 - GString* category;
4.33 - gint repeat;
4.34 - GTimeVal* startTime;
4.35 - GTimeVal* endTime;
4.36 + GString* title;
4.37 + GString* subtitle;
4.38 + GString* catType;
4.39 + GString* category;
4.40 + gint repeat;
4.41 + GTimeVal* startTime;
4.42 + GTimeVal* endTime;
4.43 };
4.44
4.45 struct _GMythChannel
4.46 {
4.47 - GString* channelName;
4.48 - GString* chanNum;
4.49 - gint chanId;
4.50 - gint callSign;
4.51 - GSList* programList;
4.52 + GString* channelName;
4.53 + GString* chanNum;
4.54 + gint chanId;
4.55 + gint callSign;
4.56 + GSList* programList;
4.57 };
4.58
4.59 struct _GMythEpg
4.60 {
4.61 - gint startChanId;
4.62 - gint endChanId;
4.63 - GString* version;
4.64 - gint protoVer;
4.65 - gint totalCount;
4.66 - gint numOfChannels;
4.67 - GTimeVal* asOf;
4.68 - GTimeVal* startTime;
4.69 - GTimeVal* endTime;
4.70 - gint details;
4.71 - GSList* channelList;
4.72 + gint startChanId;
4.73 + gint endChanId;
4.74 + GString* version;
4.75 + gint protoVer;
4.76 + gint totalCount;
4.77 + gint numOfChannels;
4.78 + GTimeVal* asOf;
4.79 + GTimeVal* startTime;
4.80 + GTimeVal* endTime;
4.81 + gint details;
4.82 + GSList* channelList;
4.83 };
4.84
4.85 +
4.86 +struct _GMythRecorded_Recording
4.87 +{
4.88 + gint dupInType;
4.89 + gint dupMethod;
4.90 + gint preRollSeconds;
4.91 + GString* playGroup;
4.92 + gint recPriority;
4.93 + GTimeVal* recStartTs;
4.94 +};
4.95 +
4.96 +
4.97 +struct _GMythRecorded_Channel
4.98 +{
4.99 + GString* chanFilters;
4.100 + GString* channelName;
4.101 + gint chanNum;
4.102 + gint sourceId;
4.103 + gint commFree;
4.104 + gint inputId;
4.105 + gint chanId;
4.106 + gint callSign;
4.107 +};
4.108 +
4.109 +
4.110 +struct _GMythRecorded_Program
4.111 +{
4.112 + gint programFlags;
4.113 + GString* title;
4.114 + gint programId;
4.115 + GString* catType;
4.116 + GString* category;
4.117 + gint seriesId;
4.118 + GTimeVal* startTime;
4.119 + GTimeVal* endTime;
4.120 + GTimeVal* airdate; //?
4.121 + GTimeVal* lastModified;
4.122 + GString* subTitle;
4.123 + gint stars;
4.124 + gint repeat;
4.125 + gint fileSize;
4.126 + GString* hostname;
4.127 + GMythRecorded_Channel channel;
4.128 + GMythRecorded_Recording recording;
4.129 +};
4.130 +
4.131 +struct _GMythRecorded
4.132 +{
4.133 + GString* version;
4.134 + gint protoVer;
4.135 + gint totalCount;
4.136 + GTimeVal* asOf;
4.137 + GSList* programList;
4.138 +};
4.139 +
4.140 +
4.141 gchar* gmyth_http_retrieve_setting (GMythBackendInfo *backend_info,\
4.142 - gchar* key, gchar* hostname);
4.143 + gchar* key, gchar* hostname);
4.144
4.145 -GMythEpg retrieve_epg(GMythBackendInfo *backend_info, int port,\
4.146 +GMythEpg gmyth_http_retrieve_epg(GMythBackendInfo *backend_info, \
4.147 GTimeVal* StartTime, GTimeVal* EndTime, \
4.148 gint StartChanId, gint NumOfChannels, gchar* Details);
4.149
4.150 +GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo *backend_info);
4.151 +
4.152 MemoryStruct gmyth_http_request (GMythBackendInfo *backend_info, GString *command);
4.153
4.154 G_END_DECLS
5.1 --- a/gmyth/tests/gmyth_test_http.c Sat Feb 10 22:12:54 2007 +0000
5.2 +++ b/gmyth/tests/gmyth_test_http.c Mon Feb 12 13:31:29 2007 +0000
5.3 @@ -11,14 +11,19 @@
5.4
5.5 backend_info = gmyth_backend_info_new ();
5.6
5.7 - gmyth_backend_info_set_hostname (backend_info, "192.168.3.165");
5.8 + gmyth_backend_info_set_hostname (backend_info, "127.0.0.1");
5.9 gmyth_backend_info_set_port (backend_info, 6543);
5.10 + gmyth_backend_info_set_status_port (backend_info, 6544);
5.11
5.12 GTimeVal* start = gmyth_util_string_to_time_val("2006-01-01T00:00");
5.13 GTimeVal* end = gmyth_util_string_to_time_val("2007-01-01T00:00");
5.14 GMythEpg epg;
5.15 - epg = retrieve_epg(backend_info, 6544, start, end, 0, 2, "True");
5.16 + epg = gmyth_http_retrieve_epg(backend_info, start, end, 0, 2, "True");
5.17
5.18 + GMythRecorded recorded;
5.19 + recorded = gmyth_http_retrieve_recorded(backend_info);
5.20 +
5.21 + GMythRecorded_Program* program = recorded.programList->data;
5.22
5.23 return 0;
5.24 }