gmyth/src/gmyth_util.c
branchtrunk
changeset 798 19626dc62c16
parent 770 800e6485ad15
child 799 13f38117f520
     1.1 --- a/gmyth/src/gmyth_util.c	Tue Jul 03 21:26:55 2007 +0100
     1.2 +++ b/gmyth/src/gmyth_util.c	Fri Aug 10 14:45:36 2007 +0100
     1.3 @@ -42,10 +42,11 @@
     1.4  
     1.5  #include "gmyth_socket.h"
     1.6  #include "gmyth_recorder.h"
     1.7 -#include "gmyth_backendinfo.h"
     1.8  #include "gmyth_common.h"
     1.9  #include "gmyth_debug.h"
    1.10  
    1.11 +#include "gmyth_util.h"
    1.12 +
    1.13  #if !GLIB_CHECK_VERSION (2, 10, 0)
    1.14  gchar          *g_time_val_to_iso8601(GTimeVal * time_);
    1.15  gboolean        g_time_val_from_iso8601(const gchar * iso_date,
    1.16 @@ -449,7 +450,8 @@
    1.17  gmyth_util_file_exists_from_socket (GMythSocket *sock, 
    1.18                                      const gchar *filename)
    1.19  {
    1.20 -    gboolean res;
    1.21 +    gboolean res = FALSE;
    1.22 +    gint length = 0;
    1.23      GMythStringList *slist;
    1.24      GMythProgramInfo *program = NULL;
    1.25  
    1.26 @@ -458,17 +460,47 @@
    1.27  
    1.28      slist = gmyth_string_list_new();
    1.29      gmyth_string_list_append_char_array(slist, "QUERY_CHECKFILE");
    1.30 +    gmyth_program_info_to_string_list(program, slist);
    1.31  
    1.32 -    gmyth_program_info_to_string_list(program, slist);
    1.33 -    gmyth_socket_sendreceive_stringlist (sock, slist);
    1.34 -    res = (gmyth_string_list_get_int(slist, 0) == 1);
    1.35 +    length = gmyth_socket_sendreceive_stringlist (sock, slist);
    1.36 +    if (length > 0)
    1.37 +        res = (gmyth_string_list_get_int(slist, 0) == 1);
    1.38  
    1.39      g_object_unref(program);
    1.40      g_object_unref(slist);
    1.41  
    1.42      return res;
    1.43  }
    1.44 -                 
    1.45 + 
    1.46 +gboolean
    1.47 +gmyth_util_get_backend_details (GMythSocket *sock, GMythBackendDetails **details)
    1.48 +{
    1.49 +    gboolean res = FALSE;
    1.50 +    gint length = 0;
    1.51 +    GMythStringList *slist;
    1.52 +
    1.53 +    slist = gmyth_string_list_new();
    1.54 +    gmyth_string_list_append_char_array(slist, "QUERY_FREE_SPACE");
    1.55 +
    1.56 +    length = gmyth_socket_sendreceive_stringlist (sock, slist);
    1.57 +    if (length >= 8) {
    1.58 +        *details = g_new0 (GMythBackendDetails, 1);
    1.59 +        (*details)->total_space = gmyth_string_list_get_uint64 (slist, 4);
    1.60 +        (*details)->used_space = gmyth_string_list_get_uint64 (slist, 6);
    1.61 +        res = TRUE;
    1.62 +    }
    1.63 +
    1.64 +    g_object_unref(slist);
    1.65 +
    1.66 +    return res;
    1.67 +}
    1.68 +
    1.69 +void
    1.70 +gmyth_util_backend_details_free (GMythBackendDetails *details)
    1.71 +{
    1.72 +    g_free (details);
    1.73 +}
    1.74 +                     
    1.75  
    1.76  /** 
    1.77   * Checks if the given remote file exists, and gets its remote directory.