[svn r804] Added function to retrieve backend details (total space, free space, etc)
1.1 --- a/gmyth/samples/gmyth_cat.c Tue Aug 07 16:00:49 2007 +0100
1.2 +++ b/gmyth/samples/gmyth_cat.c Fri Aug 10 14:45:36 2007 +0100
1.3 @@ -124,7 +124,7 @@
1.4 }
1.5
1.6 size = gmyth_file_transfer_get_filesize(transfer);
1.7 - fprintf(stderr, "Size:%d\n", size);
1.8 + fprintf(stderr, "Size:%" G_GUINT64_FORMAT "\n", size);
1.9
1.10 array = g_array_new(FALSE, TRUE, sizeof(gchar));
1.11
1.12 @@ -145,7 +145,7 @@
1.13 fflush(stdout);
1.14
1.15 total += array->len;
1.16 - fprintf(stderr, "%d\n", total);
1.17 + fprintf(stderr, "%" G_GUINT64_FORMAT "\n", total);
1.18 g_array_remove_range(array, 0, array->len);
1.19 // usleep(300000);
1.20 }
2.1 --- a/gmyth/src/gmyth_scheduler.c Tue Aug 07 16:00:49 2007 +0100
2.2 +++ b/gmyth/src/gmyth_scheduler.c Fri Aug 10 14:45:36 2007 +0100
2.3 @@ -737,7 +737,7 @@
2.4 static gint
2.5 get_record_id_from_database(GMythScheduler * scheduler)
2.6 {
2.7 - gint record_id;
2.8 + gint record_id;
2.9
2.10 assert(scheduler);
2.11
3.1 --- a/gmyth/src/gmyth_util.c Tue Aug 07 16:00:49 2007 +0100
3.2 +++ b/gmyth/src/gmyth_util.c Fri Aug 10 14:45:36 2007 +0100
3.3 @@ -42,10 +42,11 @@
3.4
3.5 #include "gmyth_socket.h"
3.6 #include "gmyth_recorder.h"
3.7 -#include "gmyth_backendinfo.h"
3.8 #include "gmyth_common.h"
3.9 #include "gmyth_debug.h"
3.10
3.11 +#include "gmyth_util.h"
3.12 +
3.13 #if !GLIB_CHECK_VERSION (2, 10, 0)
3.14 gchar *g_time_val_to_iso8601(GTimeVal * time_);
3.15 gboolean g_time_val_from_iso8601(const gchar * iso_date,
3.16 @@ -449,7 +450,8 @@
3.17 gmyth_util_file_exists_from_socket (GMythSocket *sock,
3.18 const gchar *filename)
3.19 {
3.20 - gboolean res;
3.21 + gboolean res = FALSE;
3.22 + gint length = 0;
3.23 GMythStringList *slist;
3.24 GMythProgramInfo *program = NULL;
3.25
3.26 @@ -458,17 +460,47 @@
3.27
3.28 slist = gmyth_string_list_new();
3.29 gmyth_string_list_append_char_array(slist, "QUERY_CHECKFILE");
3.30 + gmyth_program_info_to_string_list(program, slist);
3.31
3.32 - gmyth_program_info_to_string_list(program, slist);
3.33 - gmyth_socket_sendreceive_stringlist (sock, slist);
3.34 - res = (gmyth_string_list_get_int(slist, 0) == 1);
3.35 + length = gmyth_socket_sendreceive_stringlist (sock, slist);
3.36 + if (length > 0)
3.37 + res = (gmyth_string_list_get_int(slist, 0) == 1);
3.38
3.39 g_object_unref(program);
3.40 g_object_unref(slist);
3.41
3.42 return res;
3.43 }
3.44 -
3.45 +
3.46 +gboolean
3.47 +gmyth_util_get_backend_details (GMythSocket *sock, GMythBackendDetails **details)
3.48 +{
3.49 + gboolean res = FALSE;
3.50 + gint length = 0;
3.51 + GMythStringList *slist;
3.52 +
3.53 + slist = gmyth_string_list_new();
3.54 + gmyth_string_list_append_char_array(slist, "QUERY_FREE_SPACE");
3.55 +
3.56 + length = gmyth_socket_sendreceive_stringlist (sock, slist);
3.57 + if (length >= 8) {
3.58 + *details = g_new0 (GMythBackendDetails, 1);
3.59 + (*details)->total_space = gmyth_string_list_get_uint64 (slist, 4);
3.60 + (*details)->used_space = gmyth_string_list_get_uint64 (slist, 6);
3.61 + res = TRUE;
3.62 + }
3.63 +
3.64 + g_object_unref(slist);
3.65 +
3.66 + return res;
3.67 +}
3.68 +
3.69 +void
3.70 +gmyth_util_backend_details_free (GMythBackendDetails *details)
3.71 +{
3.72 + g_free (details);
3.73 +}
3.74 +
3.75
3.76 /**
3.77 * Checks if the given remote file exists, and gets its remote directory.
4.1 --- a/gmyth/src/gmyth_util.h Tue Aug 07 16:00:49 2007 +0100
4.2 +++ b/gmyth/src/gmyth_util.h Fri Aug 10 14:45:36 2007 +0100
4.3 @@ -38,6 +38,11 @@
4.4
4.5 G_BEGIN_DECLS
4.6
4.7 +typedef struct {
4.8 + guint64 total_space;
4.9 + guint64 used_space;
4.10 +} GMythBackendDetails;
4.11 +
4.12
4.13 GString* gmyth_util_time_to_isoformat (time_t time_value);
4.14 GString* gmyth_util_time_to_string (time_t time_value);
4.15 @@ -54,10 +59,14 @@
4.16 gchar* gmyth_util_time_to_string_only_time (const GTimeVal *time);
4.17 gchar* gmyth_util_time_to_string_from_time_val (const GTimeVal *time_val);
4.18 struct tm* gmyth_util_time_val_to_date (const GTimeVal * time);
4.19 +
4.20 +gboolean gmyth_util_get_backend_details (GMythSocket *sock, GMythBackendDetails **details);
4.21 +void gmyth_util_backend_details_free (GMythBackendDetails *details);
4.22 +
4.23 +gboolean gmyth_util_file_exists (GMythBackendInfo *backend_info,
4.24 + const gchar * filename);
4.25 gboolean gmyth_util_file_exists_from_socket (GMythSocket *sock,
4.26 const gchar *filename);
4.27 -gboolean gmyth_util_file_exists (GMythBackendInfo *backend_info,
4.28 - const gchar * filename);
4.29 gboolean gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *backend_info,
4.30 const gchar *filename,
4.31 gchar **current_dir);