# HG changeset patch # User ali@juiblex.co.uk # Date 1260910112 0 # Node ID 6308269b026e5af09475953bdf004228f179d469 # Parent 70e24f6fea25913ec7141d1c1af23a0ad5d50be9 Update gmyth-ls to work with a 0.22 backend diff -r 70e24f6fea25 -r 6308269b026e gmyth/gmyth/gmyth_programinfo.c --- a/gmyth/gmyth/gmyth_programinfo.c Sun Dec 13 23:02:37 2009 +0000 +++ b/gmyth/gmyth/gmyth_programinfo.c Tue Dec 15 20:48:32 2009 +0000 @@ -322,20 +322,18 @@ */ gmyth_string_list_append_string(slist, prog->seriesid); /* 33 */ gmyth_string_list_append_string(slist, prog->program_id); /* 34 */ - gmyth_string_list_append_char_array(slist, ""); /* 35 */ - gmyth_string_list_append_int(slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0); /* 36 - */// DATETIME_TO_LIST(lastmodified) - gmyth_string_list_append_int(slist, 0); /* 37 */// FLOAT_TO_LIST(stars) - gmyth_string_list_append_int(slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0); /* 38 - */// DATETIME_TO_LIST(QDateTime(originalAirDate)) - gmyth_string_list_append_int(slist, prog->hasAirDate); /* 39 */ - gmyth_string_list_append_char_array(slist, "Default"); /* 40 */// prog->(playgroup - // - // - // != "") ? - // playgroup : - // "Default") - gmyth_string_list_append_int(slist, prog->recpriority2); /* 41 */ + gmyth_string_list_append_int(slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0); /* 35 */ + gmyth_string_list_append_int(slist, 0); /* 36: stars */ + gmyth_string_list_append_int(slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0); /* 37 */ + gmyth_string_list_append_int(slist, prog->hasAirDate); /* 38 */ + gmyth_string_list_append_char_array(slist, "Default"); /* 39: playgroup */ + gmyth_string_list_append_int(slist, prog->recpriority2); /* 40 */ + gmyth_string_list_append_int(slist, 0); /* 41: parentid */ + gmyth_string_list_append_char_array(slist, "Default"); /* 42: storagegroup */ + gmyth_string_list_append_int(slist, 0); /* 43: audioproperties */ + gmyth_string_list_append_int(slist, 0); /* 44: videoproperties */ + gmyth_string_list_append_int(slist, 0); /* 45: subtitleType */ + gmyth_string_list_append_char_array(slist, ""); /* 46: year */ return slist; } @@ -410,25 +408,21 @@ // : // "Default") prog->chancommfree = gmyth_string_list_get_int(slist, pos + 31); - prog->chanOutputFilters = - gmyth_string_list_get_string(slist, pos + 32); + prog->chanOutputFilters = gmyth_string_list_get_string(slist, pos + 32); prog->seriesid = gmyth_string_list_get_string(slist, pos + 33); prog->program_id = gmyth_string_list_get_string(slist, pos + 34); - gmyth_string_list_get_string(slist, pos + 35); - prog->lastmodified = gmyth_util_string_to_time_val((gmyth_util_time_to_isoformat((time_t) gmyth_string_list_get_int(slist, pos + 36)))->str); // DATETIME_TO_LIST(lastmodified) - gmyth_string_list_get_int(slist, pos + 37); // FLOAT_TO_LIST(stars) - prog->originalAirDate = gmyth_util_string_to_time_val((gmyth_util_time_to_isoformat((time_t) gmyth_string_list_get_int(slist, pos + 38)))->str); // DATETIME_TO_LIST(QDateTime(originalAirDate)) - prog->hasAirDate = gmyth_string_list_get_int(slist, pos + 39); - prog->playgroup = gmyth_string_list_get_string(slist, pos + 40); // prog->(playgroup - // - // - // != - // "") - // ? - // playgroup - // : - // "Default") - prog->recpriority2 = gmyth_string_list_get_int(slist, pos + 41); + prog->lastmodified = gmyth_util_string_to_time_val((gmyth_util_time_to_isoformat((time_t) gmyth_string_list_get_int(slist, pos + 35)))->str); + gmyth_string_list_get_int(slist, pos + 36); // FLOAT_TO_LIST(stars) + prog->originalAirDate = gmyth_util_string_to_time_val((gmyth_util_time_to_isoformat((time_t) gmyth_string_list_get_int(slist, pos + 37)))->str); + prog->hasAirDate = gmyth_string_list_get_int(slist, pos + 38); + prog->playgroup = gmyth_string_list_get_string(slist, pos + 39); + prog->recpriority2 = gmyth_string_list_get_int(slist, pos + 40); + /* 41: parentid */ + /* 42: storagegroup */ + /* 43: audioproperties */ + /* 44: videoproperties */ + /* 45: subtitleType */ + /* 46: year */ return prog; } diff -r 70e24f6fea25 -r 6308269b026e gmyth/gmyth/gmyth_util.c --- a/gmyth/gmyth/gmyth_util.c Sun Dec 13 23:02:37 2009 +0000 +++ b/gmyth/gmyth/gmyth_util.c Tue Dec 15 20:48:32 2009 +0000 @@ -451,22 +451,44 @@ const gchar *filename) { gboolean res = FALSE; - gint length = 0; - GMythStringList *slist; - GMythProgramInfo *program = NULL; + GString *path; + GMythProgramInfo *program; program = gmyth_program_info_new(); program->pathname = g_string_new(filename); + path = gmyth_util_check_file_from_socket (sock, program); + + if (path) { + res = TRUE; + g_string_free(path, TRUE); + } + + g_object_unref(program); + + return res; +} + +GString * +gmyth_util_check_file_from_socket (GMythSocket *sock, + GMythProgramInfo *program) +{ + GString *res; + gint length; + GMythStringList *slist; + slist = gmyth_string_list_new(); gmyth_string_list_append_char_array(slist, "QUERY_CHECKFILE"); + if (gmyth_socket_get_protocol_version(sock) >= 32) + gmyth_string_list_append_int(slist, 1); gmyth_program_info_to_string_list(program, slist); length = gmyth_socket_sendreceive_stringlist (sock, slist); - if (length > 0) - res = (gmyth_string_list_get_int(slist, 0) == 1); + if (length > 1 && gmyth_string_list_get_int(slist, 0) == 1) + res = gmyth_string_list_get_string(slist, 1); + else + res = NULL; - g_object_unref(program); g_object_unref(slist); return res; @@ -526,25 +548,18 @@ backend_info->port, TRUE); if (res == TRUE) { - GMythStringList *slist; - GMythProgramInfo *program = NULL; + GMythProgramInfo *program; + GString *path; program = gmyth_program_info_new(); program->pathname = g_string_new(filename); - slist = gmyth_string_list_new(); - gmyth_string_list_append_char_array(slist, "QUERY_CHECKFILE"); + path = gmyth_util_check_file_from_socket (socket, program); - gmyth_program_info_to_string_list(program, slist); + res = !!path; - gmyth_socket_sendreceive_stringlist(socket, slist); - - res = (gmyth_string_list_get_int(slist, 0) == 1); - - if ((gmyth_string_list_length(slist) > 1) && - gmyth_string_list_get_char_array(slist, 1) != NULL) - *current_dir = - g_strdup(gmyth_string_list_get_char_array(slist, 1)); + if (path) + *current_dir = g_string_free(path, FALSE); if (*current_dir != NULL) gmyth_debug("Current directory = %s.", (*current_dir != NULL) @@ -552,8 +567,6 @@ g_object_unref(program); - g_object_unref(slist); - gmyth_socket_close_connection(socket); } g_object_unref(socket); diff -r 70e24f6fea25 -r 6308269b026e gmyth/gmyth/gmyth_util.h --- a/gmyth/gmyth/gmyth_util.h Sun Dec 13 23:02:37 2009 +0000 +++ b/gmyth/gmyth/gmyth_util.h Tue Dec 15 20:48:32 2009 +0000 @@ -67,6 +67,8 @@ const gchar * filename); gboolean gmyth_util_file_exists_from_socket (GMythSocket *sock, const gchar *filename); +GString* gmyth_util_check_file_from_socket (GMythSocket *sock, + GMythProgramInfo *program); gboolean gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *backend_info, const gchar *filename, gchar **current_dir); diff -r 70e24f6fea25 -r 6308269b026e gmyth/samples/gmyth_ls.c --- a/gmyth/samples/gmyth_ls.c Sun Dec 13 23:02:37 2009 +0000 +++ b/gmyth/samples/gmyth_ls.c Tue Dec 15 20:48:32 2009 +0000 @@ -120,6 +120,9 @@ *iter; gint res = 0, count = 0; + GMythSocket *socket; + GString *path; + GMythProgramInfo *program; g_return_val_if_fail(options != NULL, FALSE); g_return_val_if_fail(options->b_info != NULL, FALSE); @@ -145,17 +148,26 @@ } iter = list; + socket = gmyth_backend_info_get_connected_socket(options->b_info); while (iter) { RecordedInfo *recorded_info = (RecordedInfo *) iter->data; - if (gmyth_util_file_exists - (options->b_info, recorded_info->basename->str)) { + program = gmyth_program_info_new(); + program->pathname = g_string_new(recorded_info->basename->str); + program->channel_id = recorded_info->channel_id; + program->recstartts = g_memdup(recorded_info->start_time, + sizeof(*program->startts)); + path = gmyth_util_check_file_from_socket(socket, program); + if (path) { count++; g_print("%s\n", recorded_info->basename->str); + g_string_free(path, TRUE); } gmyth_recorded_info_free(recorded_info); + g_object_unref(program); iter = g_list_next(iter); } + g_object_unref(socket); if (!count) g_print("No recorded programs.\n");