author | morphbr |
Fri Jun 01 13:48:21 2007 +0100 (2007-06-01) | |
branch | trunk |
changeset 736 | 1bc4c47e4ad8 |
parent 597 | 945d3f5da6fc |
child 750 | 312d6bc514f3 |
permissions | -rw-r--r-- |
rosfran@597 | 1 |
#include <glib-object.h> |
rosfran@597 | 2 |
|
rosfran@597 | 3 |
#include "common.h" |
rosfran@597 | 4 |
|
rosfran@618 | 5 |
#include <gmyth/gmyth_uri.h> |
rosfran@618 | 6 |
#include <gmyth/gmyth_backendinfo.h> |
rosfran@618 | 7 |
#include <gmyth/gmyth_livetv.h> |
rosfran@618 | 8 |
#include <gmyth/gmyth_file.h> |
rosfran@618 | 9 |
#include <gmyth/gmyth_file_transfer.h> |
rosfran@618 | 10 |
#include <gmyth/gmyth_file_local.h> |
rosfran@618 | 11 |
#include <gmyth/gmyth_common.h> |
rosfran@597 | 12 |
|
rosfran@597 | 13 |
#define URI_FILE_TRANSFER_DEFAULT "myth://192.168.3.165:6543/" |
rosfran@597 | 14 |
|
rosfran@597 | 15 |
static gboolean |
rosfran@597 | 16 |
test_file_transfer_setup( gchar *uri ) { |
rosfran@597 | 17 |
GMythFile *file = NULL; |
rosfran@597 | 18 |
gboolean ret = TRUE; |
rosfran@597 | 19 |
|
rosfran@597 | 20 |
if ( NULL == uri) |
rosfran@597 | 21 |
uri = g_strdup( URI_FILE_TRANSFER_DEFAULT ); |
rosfran@597 | 22 |
|
rosfran@597 | 23 |
GMythURI *gmyth_uri = gmyth_uri_new_with_value( uri); |
rosfran@597 | 24 |
|
rosfran@597 | 25 |
GMythBackendInfo* backend_info = gmyth_backend_info_new_with_uri(uri); |
rosfran@597 | 26 |
|
rosfran@597 | 27 |
/* Check if the file is local to this specific client renderer, and tries to open |
rosfran@597 | 28 |
* a local connection |
rosfran@597 | 29 |
*/ |
rosfran@597 | 30 |
if ( gmyth_uri_is_local_file(gmyth_uri)) { |
rosfran@597 | 31 |
g_debug( "Opening local file connection to download..."); |
rosfran@597 | 32 |
file = GMYTH_FILE(gmyth_file_local_new(backend_info)); |
rosfran@597 | 33 |
ret = gmyth_file_local_open( GMYTH_FILE_LOCAL( file ) ); |
rosfran@597 | 34 |
} else { |
rosfran@597 | 35 |
g_debug( "Opening remote file connection to download..."); |
rosfran@597 | 36 |
file = GMYTH_FILE(gmyth_file_transfer_new(backend_info)); |
rosfran@597 | 37 |
ret = gmyth_file_transfer_open( GMYTH_FILE_TRANSFER(file), uri); |
rosfran@597 | 38 |
} |
rosfran@597 | 39 |
|
rosfran@597 | 40 |
if (NULL == file) { |
rosfran@597 | 41 |
g_debug("FileTransfer is NULL"); |
rosfran@597 | 42 |
ret = FALSE; |
rosfran@597 | 43 |
goto init_failed; |
rosfran@597 | 44 |
} |
rosfran@597 | 45 |
|
rosfran@597 | 46 |
g_debug( "uri = %s", uri); |
rosfran@597 | 47 |
|
rosfran@597 | 48 |
if (ret == FALSE) { |
rosfran@597 | 49 |
g_debug("MythTV FileTransfer request failed when setting up socket connection!"); |
rosfran@597 | 50 |
goto init_failed; |
rosfran@597 | 51 |
} |
rosfran@597 | 52 |
|
rosfran@597 | 53 |
g_debug( "MythTV FileTransfer filesize = %lld", |
rosfran@597 | 54 |
gmyth_file_get_filesize( file)); |
rosfran@597 | 55 |
|
rosfran@618 | 56 |
init_failed: |
rosfran@597 | 57 |
|
rosfran@597 | 58 |
if ( file != NULL) |
rosfran@597 | 59 |
g_object_unref(file); |
rosfran@597 | 60 |
|
rosfran@597 | 61 |
if ( gmyth_uri != NULL) |
rosfran@597 | 62 |
g_object_unref( gmyth_uri); |
rosfran@597 | 63 |
|
rosfran@597 | 64 |
if ( backend_info != NULL) |
rosfran@597 | 65 |
g_object_unref( backend_info); |
rosfran@597 | 66 |
|
rosfran@597 | 67 |
return ret; |
rosfran@597 | 68 |
|
rosfran@597 | 69 |
} |
rosfran@597 | 70 |
|
rosfran@597 | 71 |
gint |
rosfran@597 | 72 |
main(gint args, const gchar **argv) { |
rosfran@597 | 73 |
gboolean ret = FALSE; |
rosfran@597 | 74 |
|
rosfran@597 | 75 |
g_type_init(); |
rosfran@597 | 76 |
|
rosfran@597 | 77 |
g_thread_init(NULL); |
rosfran@597 | 78 |
|
rosfran@597 | 79 |
fprintf(stdout, SYNC_STRING); |
rosfran@597 | 80 |
fflush(NULL); |
rosfran@597 | 81 |
getchar(); |
rosfran@597 | 82 |
|
rosfran@597 | 83 |
if ( args > 1) |
rosfran@597 | 84 |
ret = test_file_transfer_setup( argv[1]); |
rosfran@597 | 85 |
|
rosfran@597 | 86 |
if ( !ret) |
rosfran@597 | 87 |
g_debug("Error when running LiveTV setup test script!"); |
rosfran@597 | 88 |
else |
rosfran@597 | 89 |
g_debug("LiveTV setup test script finished with success."); |
rosfran@597 | 90 |
|
rosfran@597 | 91 |
return (0); |
rosfran@597 | 92 |
} |
rosfran@597 | 93 |