[svn r126] Added gmyth_util_file_exists() predicate function trunk
authormelunko
Tue Nov 28 03:15:55 2006 +0000 (2006-11-28)
branchtrunk
changeset 125420f3b9432db
parent 124 d2d5fe1c3997
child 126 9f1077ae5637
[svn r126] Added gmyth_util_file_exists() predicate function
gmyth/src/Makefile.am
gmyth/src/gmyth_file_transfer.c
gmyth/src/gmyth_socket.c
gmyth/src/gmyth_util.c
gmyth/src/gmyth_util.h
     1.1 --- a/gmyth/src/Makefile.am	Tue Nov 28 00:54:53 2006 +0000
     1.2 +++ b/gmyth/src/Makefile.am	Tue Nov 28 03:15:55 2006 +0000
     1.3 @@ -16,6 +16,7 @@
     1.4  	gmyth_file_transfer.c			\
     1.5  	gmyth_livetv.c				\
     1.6  	gmyth_backendinfo.c			\
     1.7 +	gmyth_programinfo.c			\
     1.8  	gmyth_uri.c
     1.9  
    1.10  libgmyth_la_CFLAGS = 			\
    1.11 @@ -55,6 +56,7 @@
    1.12  	gmyth_file_transfer.h			\
    1.13  	gmyth_livetv.h				\
    1.14  	gmyth_backendinfo.h			\
    1.15 +	gmyth_programinfo.h			\
    1.16  	gmyth_uri.h
    1.17  
    1.18  CLEANFILES = $(BUILT_SOURCES)
     2.1 --- a/gmyth/src/gmyth_file_transfer.c	Tue Nov 28 00:54:53 2006 +0000
     2.2 +++ b/gmyth/src/gmyth_file_transfer.c	Tue Nov 28 03:15:55 2006 +0000
     2.3 @@ -288,7 +288,7 @@
     2.4    g_print( "[%s] Got Monitor response from %s: %s\n", __FUNCTION__, base_str->str, resp->str );
     2.5    //g_thread_create( (GThreadFunc)myth_control_sock_listener, transfer->event_sock->sd_io_ch, TRUE, NULL );
     2.6    io_watcher_context = g_main_context_default();
     2.7 -  GMainLoop *loop = g_main_loop_new( NULL, TRUE );
     2.8 +  //GMainLoop *loop = g_main_loop_new( NULL, TRUE );
     2.9  
    2.10    //GSource *source;
    2.11  
     3.1 --- a/gmyth/src/gmyth_socket.c	Tue Nov 28 00:54:53 2006 +0000
     3.2 +++ b/gmyth/src/gmyth_socket.c	Tue Nov 28 03:15:55 2006 +0000
     3.3 @@ -942,8 +942,11 @@
     3.4      // FIXME: change this implementation!
     3.5      tmp_list = str_list->glist;
     3.6      for(; tmp_list; tmp_list = tmp_list->next) {
     3.7 -	if ( tmp_list->data != NULL )
     3.8 +	if ( tmp_list->data != NULL ) {
     3.9  	    g_ptr_array_add(ptr_array, ((GString*)tmp_list->data)->str);
    3.10 +	} else {
    3.11 +	    g_ptr_array_add (ptr_array, g_strdup (""));
    3.12 +	}
    3.13      }
    3.14      g_ptr_array_add(ptr_array, NULL); // g_str_joinv() needs a NULL terminated string
    3.15  
     4.1 --- a/gmyth/src/gmyth_util.c	Tue Nov 28 00:54:53 2006 +0000
     4.2 +++ b/gmyth/src/gmyth_util.c	Tue Nov 28 03:15:55 2006 +0000
     4.3 @@ -25,10 +25,16 @@
     4.4  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     4.5  */
     4.6  
     4.7 +#include <glib.h>
     4.8 +#include <glib/gprintf.h>
     4.9 +
    4.10  #include "gmyth_util.h"
    4.11  
    4.12 -#include <glib.h>
    4.13 -#include <glib/gprintf.h>
    4.14 +#include "gmyth_backendinfo.h"
    4.15 +#include "gmyth_socket.h"
    4.16 +#include "gmyth_programinfo.h"
    4.17 +#include "gmyth_common.h"
    4.18 +
    4.19  
    4.20  /** Converts a time_t struct in a GString at ISO standard format 
    4.21   * (e.g. 2006-07-20T09:56:41).
    4.22 @@ -138,4 +144,37 @@
    4.23  
    4.24  }
    4.25  
    4.26 +gboolean
    4.27 +gmyth_util_file_exists (GMythBackendInfo *backend_info, const char* filename)
    4.28 +{
    4.29 +    GMythSocket *socket;
    4.30 +    GMythProgramInfo *program;
    4.31 +    GMythStringList *slist;
    4.32 +    gboolean res;
    4.33 +    
    4.34 +    socket = gmyth_socket_new ();
    4.35 +    gmyth_socket_connect_to_backend (socket, backend_info->hostname,
    4.36 +		    backend_info->port, TRUE);
    4.37  
    4.38 +    program = g_new0 (GMythProgramInfo, 1);
    4.39 +    program->pathname = g_string_new (filename);
    4.40 +
    4.41 +    slist = gmyth_string_list_new ();
    4.42 +    gmyth_string_list_append_char_array (slist, "QUERY_CHECKFILE");
    4.43 +
    4.44 +    gmyth_program_info_to_string_list (program, slist);
    4.45 +    g_debug ("XXXXXXXX List size: %d\n", gmyth_string_list_length (slist));
    4.46 +
    4.47 +    gmyth_socket_sendreceive_stringlist (socket, slist);
    4.48 +
    4.49 +    res = (gmyth_string_list_get_int (slist, 0) == 1);
    4.50 +    
    4.51 +    // fixme: we should do this in a program_info_free() function
    4.52 +    g_string_free (program->pathname, FALSE);
    4.53 +    g_free (program);
    4.54 +
    4.55 +    g_object_unref (slist);
    4.56 +
    4.57 +    return res;    
    4.58 +}
    4.59 +
     5.1 --- a/gmyth/src/gmyth_util.h	Tue Nov 28 00:54:53 2006 +0000
     5.2 +++ b/gmyth/src/gmyth_util.h	Tue Nov 28 03:15:55 2006 +0000
     5.3 @@ -32,6 +32,7 @@
     5.4  #include <glib.h>
     5.5  
     5.6  #include "gmyth_stringlist.h"
     5.7 +#include "gmyth_backendinfo.h"
     5.8  
     5.9  G_BEGIN_DECLS
    5.10  
    5.11 @@ -40,6 +41,9 @@
    5.12  time_t      gmyth_util_string_to_time   (GString* time_str);
    5.13  gint64     gmyth_util_decode_long_long (GMythStringList *strlist, 
    5.14                                           guint offset);
    5.15 +
    5.16 +gboolean gmyth_util_file_exists (GMythBackendInfo *backend_info, const char* filename);
    5.17 +
    5.18  G_END_DECLS
    5.19  	
    5.20  #endif /*GMYTH_UTIL_H_*/