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