# HG changeset patch # User melunko # Date 1186753536 -3600 # Node ID 19626dc62c16a610c6dd97fc59da56253065a227 # Parent 7563dc4ed8d5dd0b60c318dc3b11a9c9877e88a0 [svn r804] Added function to retrieve backend details (total space, free space, etc) diff -r 7563dc4ed8d5 -r 19626dc62c16 gmyth/samples/gmyth_cat.c --- a/gmyth/samples/gmyth_cat.c Tue Aug 07 16:00:49 2007 +0100 +++ b/gmyth/samples/gmyth_cat.c Fri Aug 10 14:45:36 2007 +0100 @@ -124,7 +124,7 @@ } size = gmyth_file_transfer_get_filesize(transfer); - fprintf(stderr, "Size:%d\n", size); + fprintf(stderr, "Size:%" G_GUINT64_FORMAT "\n", size); array = g_array_new(FALSE, TRUE, sizeof(gchar)); @@ -145,7 +145,7 @@ fflush(stdout); total += array->len; - fprintf(stderr, "%d\n", total); + fprintf(stderr, "%" G_GUINT64_FORMAT "\n", total); g_array_remove_range(array, 0, array->len); // usleep(300000); } diff -r 7563dc4ed8d5 -r 19626dc62c16 gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Tue Aug 07 16:00:49 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.c Fri Aug 10 14:45:36 2007 +0100 @@ -737,7 +737,7 @@ static gint get_record_id_from_database(GMythScheduler * scheduler) { - gint record_id; + gint record_id; assert(scheduler); diff -r 7563dc4ed8d5 -r 19626dc62c16 gmyth/src/gmyth_util.c --- a/gmyth/src/gmyth_util.c Tue Aug 07 16:00:49 2007 +0100 +++ b/gmyth/src/gmyth_util.c Fri Aug 10 14:45:36 2007 +0100 @@ -42,10 +42,11 @@ #include "gmyth_socket.h" #include "gmyth_recorder.h" -#include "gmyth_backendinfo.h" #include "gmyth_common.h" #include "gmyth_debug.h" +#include "gmyth_util.h" + #if !GLIB_CHECK_VERSION (2, 10, 0) gchar *g_time_val_to_iso8601(GTimeVal * time_); gboolean g_time_val_from_iso8601(const gchar * iso_date, @@ -449,7 +450,8 @@ gmyth_util_file_exists_from_socket (GMythSocket *sock, const gchar *filename) { - gboolean res; + gboolean res = FALSE; + gint length = 0; GMythStringList *slist; GMythProgramInfo *program = NULL; @@ -458,17 +460,47 @@ slist = gmyth_string_list_new(); gmyth_string_list_append_char_array(slist, "QUERY_CHECKFILE"); + gmyth_program_info_to_string_list(program, slist); - gmyth_program_info_to_string_list(program, slist); - gmyth_socket_sendreceive_stringlist (sock, slist); - res = (gmyth_string_list_get_int(slist, 0) == 1); + length = gmyth_socket_sendreceive_stringlist (sock, slist); + if (length > 0) + res = (gmyth_string_list_get_int(slist, 0) == 1); g_object_unref(program); g_object_unref(slist); return res; } - + +gboolean +gmyth_util_get_backend_details (GMythSocket *sock, GMythBackendDetails **details) +{ + gboolean res = FALSE; + gint length = 0; + GMythStringList *slist; + + slist = gmyth_string_list_new(); + gmyth_string_list_append_char_array(slist, "QUERY_FREE_SPACE"); + + length = gmyth_socket_sendreceive_stringlist (sock, slist); + if (length >= 8) { + *details = g_new0 (GMythBackendDetails, 1); + (*details)->total_space = gmyth_string_list_get_uint64 (slist, 4); + (*details)->used_space = gmyth_string_list_get_uint64 (slist, 6); + res = TRUE; + } + + g_object_unref(slist); + + return res; +} + +void +gmyth_util_backend_details_free (GMythBackendDetails *details) +{ + g_free (details); +} + /** * Checks if the given remote file exists, and gets its remote directory. diff -r 7563dc4ed8d5 -r 19626dc62c16 gmyth/src/gmyth_util.h --- a/gmyth/src/gmyth_util.h Tue Aug 07 16:00:49 2007 +0100 +++ b/gmyth/src/gmyth_util.h Fri Aug 10 14:45:36 2007 +0100 @@ -38,6 +38,11 @@ G_BEGIN_DECLS +typedef struct { + guint64 total_space; + guint64 used_space; +} GMythBackendDetails; + GString* gmyth_util_time_to_isoformat (time_t time_value); GString* gmyth_util_time_to_string (time_t time_value); @@ -54,10 +59,14 @@ gchar* gmyth_util_time_to_string_only_time (const GTimeVal *time); gchar* gmyth_util_time_to_string_from_time_val (const GTimeVal *time_val); struct tm* gmyth_util_time_val_to_date (const GTimeVal * time); + +gboolean gmyth_util_get_backend_details (GMythSocket *sock, GMythBackendDetails **details); +void gmyth_util_backend_details_free (GMythBackendDetails *details); + +gboolean gmyth_util_file_exists (GMythBackendInfo *backend_info, + const gchar * filename); gboolean gmyth_util_file_exists_from_socket (GMythSocket *sock, const gchar *filename); -gboolean gmyth_util_file_exists (GMythBackendInfo *backend_info, - const gchar * filename); gboolean gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *backend_info, const gchar *filename, gchar **current_dir);