1.1 --- a/gmyth/src/Makefile.am Mon Dec 04 20:43:16 2006 +0000
1.2 +++ b/gmyth/src/Makefile.am Mon Dec 04 22:00:41 2006 +0000
1.3 @@ -41,6 +41,7 @@
1.4 $(pkgincludedir)
1.5
1.6 libgmyth_include_HEADERS = \
1.7 + gmyth.h \
1.8 gmyth_common.h \
1.9 gmyth_debug.h \
1.10 gmyth_epg.h \
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/gmyth/src/gmyth.h Mon Dec 04 22:00:41 2006 +0000
2.3 @@ -0,0 +1,49 @@
2.4 +/**
2.5 + * GMyth Library
2.6 + *
2.7 + * @file gmyth/gmyth.h
2.8 + *
2.9 + *
2.10 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
2.11 + * @author Renato Filho <renato.filho@indt.org.br>
2.12 + *
2.13 + *//*
2.14 + *
2.15 + * This program is free software; you can redistribute it and/or modify
2.16 + * it under the terms of the GNU Lesser General Public License as published by
2.17 + * the Free Software Foundation; either version 2 of the License, or
2.18 + * (at your option) any later version.
2.19 + *
2.20 + * This program is distributed in the hope that it will be useful,
2.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.23 + * GNU General Public License for more details.
2.24 + *
2.25 + * You should have received a copy of the GNU Lesser General Public License
2.26 + * along with this program; if not, write to the Free Software
2.27 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2.28 + */
2.29 +
2.30 +
2.31 +
2.32 +#ifndef _GMYTH_H_
2.33 +#define _GMYTH_H_
2.34 +
2.35 +#include <gmyth_backendinfo.h>
2.36 +#include <gmyth_common.h>
2.37 +#include <gmyth_debug.h>
2.38 +#include <gmyth_epg.h>
2.39 +#include <gmyth_file_transfer.h>
2.40 +#include <gmyth_livetv.h>
2.41 +#include <gmyth_programinfo.h>
2.42 +#include <gmyth_query.h>
2.43 +#include <gmyth_recorder.h>
2.44 +#include <gmyth_remote_util.h>
2.45 +#include <gmyth_scheduler.h>
2.46 +#include <gmyth_socket.h>
2.47 +#include <gmyth_stringlist.h>
2.48 +#include <gmyth_tvchain.h>
2.49 +#include <gmyth_uri.h>
2.50 +#include <gmyth_util.h>
2.51 +
2.52 +#endif /* _GMYTH_H_ */
3.1 --- a/gmyth/src/gmyth_backendinfo.c Mon Dec 04 20:43:16 2006 +0000
3.2 +++ b/gmyth/src/gmyth_backendinfo.c Mon Dec 04 22:00:41 2006 +0000
3.3 @@ -55,7 +55,6 @@
3.4 backend_info->password = NULL;
3.5 backend_info->db_name = NULL;
3.6 backend_info->port = -1;
3.7 - backend_info->path = NULL;
3.8 }
3.9
3.10 static void
3.11 @@ -67,14 +66,12 @@
3.12 g_free (backend_info->username);
3.13 g_free (backend_info->password);
3.14 g_free (backend_info->db_name);
3.15 - g_free (backend_info->path);
3.16
3.17 backend_info->hostname = NULL;
3.18 backend_info->username = NULL;
3.19 backend_info->password = NULL;
3.20 backend_info->db_name = NULL;
3.21 backend_info->port = -1;
3.22 - backend_info->path = NULL;
3.23
3.24 G_OBJECT_CLASS (gmyth_backend_info_parent_class)->dispose (object);
3.25 }
3.26 @@ -122,24 +119,21 @@
3.27 GMythBackendInfo *backend_info =
3.28 GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
3.29
3.30 - gmyth_debug ("XXX %s %d\n", __FUNCTION__, __LINE__);
3.31 + gmyth_debug ("XXX %s %d\n", __FUNCTION__, __LINE__);
3.32 GMythURI* uri = gmyth_uri_new_with_value( uri_str );
3.33 - gmyth_debug ("XXX %s %d\n", __FUNCTION__, __LINE__);
3.34 + gmyth_debug ("XXX %s %d\n", __FUNCTION__, __LINE__);
3.35
3.36 gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri ) );
3.37 - gmyth_debug ("%s\n", gmyth_uri_get_host (uri ));
3.38 + gmyth_debug ("%s\n", gmyth_uri_get_host (uri ));
3.39 gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user( uri ) );
3.40 - gmyth_debug ("%s\n", gmyth_uri_get_user( uri ));
3.41 + gmyth_debug ("%s\n", gmyth_uri_get_user( uri ));
3.42 gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password( uri ) );
3.43 - gmyth_debug ("%s\n", gmyth_uri_get_password( uri ));
3.44 + gmyth_debug ("%s\n", gmyth_uri_get_password( uri ));
3.45 gmyth_backend_info_set_db_name (backend_info, strlen( gmyth_uri_get_fragment( uri ) ) > 0
3.46 ? gmyth_uri_get_fragment( uri ) : gmyth_uri_get_query( uri ) );
3.47 gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port( uri ) );
3.48 - gmyth_debug ("%s\n", gmyth_backend_info_get_db_name(backend_info) );
3.49 + gmyth_debug ("%s\n", gmyth_backend_info_get_db_name(backend_info) );
3.50
3.51 - gmyth_backend_info_set_path (backend_info, gmyth_uri_get_path( uri ) );
3.52 - gmyth_debug ("%s\n", gmyth_backend_info_get_path(backend_info) );
3.53 -
3.54 return backend_info;
3.55 }
3.56
3.57 @@ -183,14 +177,6 @@
3.58 backend_info->port = port;
3.59 }
3.60
3.61 -void
3.62 -gmyth_backend_info_set_path (GMythBackendInfo *backend_info, const gchar *path)
3.63 -{
3.64 - g_return_if_fail (backend_info != NULL);
3.65 -
3.66 - backend_info->path = g_strdup (path);
3.67 -}
3.68 -
3.69 gchar*
3.70 gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info)
3.71 {
3.72 @@ -231,10 +217,3 @@
3.73 return backend_info->port;
3.74 }
3.75
3.76 -gchar*
3.77 -gmyth_backend_info_get_path (GMythBackendInfo *backend_info)
3.78 -{
3.79 - g_return_val_if_fail (backend_info != NULL, NULL);
3.80 -
3.81 - return backend_info->path;
3.82 -}
4.1 --- a/gmyth/src/gmyth_file_transfer.c Mon Dec 04 20:43:16 2006 +0000
4.2 +++ b/gmyth/src/gmyth_file_transfer.c Mon Dec 04 22:00:41 2006 +0000
4.3 @@ -146,12 +146,43 @@
4.4 static void
4.5 gmyth_file_transfer_dispose (GObject *object)
4.6 {
4.7 + GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (object);
4.8 +
4.9 + g_free (transfer->filename);
4.10 + transfer->filename = NULL;
4.11 +
4.12 + if (transfer->backend_info != NULL) {
4.13 + g_object_unref (transfer->backend_info);
4.14 + transfer->backend_info = NULL;
4.15 + }
4.16 +
4.17 + if (transfer->control_sock != NULL) {
4.18 + g_object_unref (transfer->control_sock);
4.19 + transfer->control_sock = NULL;
4.20 + }
4.21 +
4.22 + if (transfer->event_sock != NULL) {
4.23 + g_object_unref (transfer->event_sock);
4.24 + transfer->event_sock = NULL;
4.25 + }
4.26 +
4.27 + if (transfer->sock != NULL) {
4.28 + g_object_unref (transfer->sock);
4.29 + transfer->sock = NULL;
4.30 + }
4.31 +
4.32 + if (transfer->monitor != NULL) {
4.33 + g_object_unref (transfer->monitor);
4.34 + transfer->monitor = NULL;
4.35 + }
4.36 +
4.37 G_OBJECT_CLASS (gmyth_file_transfer_parent_class)->dispose (object);
4.38 }
4.39
4.40 static void
4.41 gmyth_file_transfer_finalize (GObject *object)
4.42 {
4.43 +
4.44 g_signal_handlers_destroy (object);
4.45
4.46 G_OBJECT_CLASS (gmyth_file_transfer_parent_class)->finalize (object);
4.47 @@ -164,51 +195,40 @@
4.48 GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (g_object_new (GMYTH_FILE_TRANSFER_TYPE, NULL));
4.49
4.50 transfer->backend_info = (GMythBackendInfo *)backend_info;
4.51 + g_object_ref (transfer->backend_info);
4.52
4.53 return transfer;
4.54 }
4.55
4.56 GMythFileTransfer*
4.57 -gmyth_file_transfer_new_with_uri ( const gchar* uri_str )
4.58 +gmyth_file_transfer_new_with_uri (const gchar* uri_str)
4.59 {
4.60 GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (g_object_new (GMYTH_FILE_TRANSFER_TYPE, NULL));
4.61 -
4.62 - transfer->uri = gmyth_uri_new_with_value (uri_str);
4.63 - transfer->hostname = g_string_new( gmyth_uri_get_host(transfer->uri) );
4.64 - transfer->port = gmyth_uri_get_port( transfer->uri );
4.65 + GMythURI *uri = gmyth_uri_new_with_value (uri_str);
4.66
4.67 + transfer->backend_info = gmyth_backend_info_new_full (gmyth_uri_get_host(uri),
4.68 + NULL, NULL, NULL, gmyth_uri_get_port (uri));
4.69 +
4.70 + g_object_unref (uri);
4.71 return transfer;
4.72 }
4.73
4.74 gboolean
4.75 -gmyth_file_transfer_open ( GMythFileTransfer *transfer, const gchar* filename )
4.76 +gmyth_file_transfer_open (GMythFileTransfer *transfer, const gchar* filename)
4.77 {
4.78 gboolean ret = TRUE;
4.79
4.80 g_return_val_if_fail( transfer != NULL, FALSE );
4.81
4.82 - if ( filename != NULL )
4.83 + if (filename != NULL)
4.84 {
4.85 - transfer->filename = filename;
4.86 - gmyth_backend_info_set_path ( transfer->backend_info, filename );
4.87 + transfer->filename = g_strdup (filename);
4.88 }
4.89
4.90 - if ( transfer->backend_info != NULL )
4.91 - {
4.92 - //transfer->uri = gmyth_backend_info_full_uri( )
4.93 - transfer->hostname = g_string_new ( gmyth_backend_info_get_hostname(transfer->backend_info) );
4.94 - transfer->port = gmyth_backend_info_get_port (transfer->backend_info);
4.95 - }
4.96 -
4.97 - if ( transfer->uri )
4.98 - gmyth_debug ("[%s] URI: %s\n", __FUNCTION__, transfer->uri->uri->str);
4.99 -
4.100 - gmyth_debug ("hostname: %s, port %d\n", transfer->hostname->str, transfer->port);
4.101 -
4.102 /* configure the control socket */
4.103 if (transfer->control_sock == NULL) {
4.104 if (!gmyth_connect_to_backend (transfer)) {
4.105 - gmyth_debug( "Connection to backend failed (Control Socket).\n" );
4.106 + gmyth_debug ("Connection to backend failed (Control Socket).\n");
4.107 ret = FALSE;
4.108 }
4.109 } else {
4.110 @@ -246,7 +266,7 @@
4.111
4.112 // Connects the socket, send Mythtv ANN command and verify Mythtv protocol version
4.113 if (!gmyth_socket_connect_to_backend (transfer->control_sock,
4.114 - transfer->hostname->str, transfer->port, TRUE)) {
4.115 + transfer->backend_info->hostname, transfer->backend_info->port, TRUE)) {
4.116
4.117 g_object_unref (transfer->control_sock);
4.118 transfer->control_sock = NULL;
4.119 @@ -260,7 +280,7 @@
4.120 }
4.121
4.122 transfer->sock = gmyth_socket_new ();
4.123 - gmyth_socket_connect (transfer->sock, transfer->hostname->str, transfer->port);
4.124 + gmyth_socket_connect (transfer->sock, transfer->backend_info->hostname, transfer->backend_info->port);
4.125
4.126 strlist = gmyth_string_list_new();
4.127 hostname = gmyth_socket_get_local_hostname();
4.128 @@ -295,7 +315,7 @@
4.129
4.130 transfer->monitor = gmyth_monitor_handler_new ( );
4.131
4.132 - ret = gmyth_monitor_handler_open ( transfer->monitor, transfer->hostname->str, transfer->port );
4.133 + ret = gmyth_monitor_handler_open (transfer->monitor, transfer->backend_info->hostname, transfer->backend_info->port );
4.134
4.135 if ( ret == TRUE )
4.136 {
5.1 --- a/gmyth/src/gmyth_file_transfer.h Mon Dec 04 20:43:16 2006 +0000
5.2 +++ b/gmyth/src/gmyth_file_transfer.h Mon Dec 04 22:00:41 2006 +0000
5.3 @@ -73,9 +73,6 @@
5.4 GObject parent;
5.5
5.6 /* Myth URI structure */
5.7 - GMythURI *uri;
5.8 - GString* hostname;
5.9 - gint port;
5.10 gchar* filename;
5.11 GMythBackendInfo *backend_info;
5.12
5.13 @@ -91,31 +88,24 @@
5.14
5.15 gint64 readposition;
5.16 guint64 filesize;
5.17 -
5.18 gint file_id;
5.19 };
5.20
5.21 -GType gmyth_file_transfer_get_type (void);
5.22 -
5.23 -GMythFileTransfer* gmyth_file_transfer_new ( const GMythBackendInfo *backend_info );
5.24 -
5.25 -GMythFileTransfer* gmyth_file_transfer_new_with_uri ( const gchar* uri_str );
5.26 -
5.27 -gboolean gmyth_file_transfer_open ( GMythFileTransfer *transfer,
5.28 - const gchar* filename );
5.29 -
5.30 -void gmyth_file_transfer_close (GMythFileTransfer *transfer);
5.31 -
5.32 -gboolean gmyth_file_transfer_is_open (GMythFileTransfer *transfer);
5.33 -
5.34 -gint gmyth_file_transfer_read(GMythFileTransfer *transfer, GByteArray *data,
5.35 - gint size, gboolean read_unlimited);
5.36 -
5.37 -gint64 gmyth_file_transfer_seek(GMythFileTransfer *transfer, guint64 pos, gint whence);
5.38 -
5.39 -gboolean gmyth_file_transfer_settimeout( GMythFileTransfer *transfer, gboolean fast);
5.40 -
5.41 -guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer *transfer);
5.42 +GType gmyth_file_transfer_get_type (void);
5.43 +GMythFileTransfer *gmyth_file_transfer_new (const GMythBackendInfo *backend_info);
5.44 +gboolean gmyth_file_transfer_open (GMythFileTransfer *transfer,
5.45 + const gchar* filename);
5.46 +void gmyth_file_transfer_close (GMythFileTransfer *transfer);
5.47 +gboolean gmyth_file_transfer_is_open (GMythFileTransfer *transfer);
5.48 +gint gmyth_file_transfer_read (GMythFileTransfer *transfer,
5.49 + GByteArray *data,
5.50 + gint size,
5.51 + gboolean read_unlimited);
5.52 +gint64 gmyth_file_transfer_seek (GMythFileTransfer *transfer,
5.53 + guint64 pos,
5.54 + gint whence);
5.55 +gboolean gmyth_file_transfer_settimeout (GMythFileTransfer *transfer, gboolean fast);
5.56 +guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer *transfer);
5.57
5.58 #define G_END_DECLS
5.59
6.1 --- a/gmyth/src/gmyth_monitor_handler.c Mon Dec 04 20:43:16 2006 +0000
6.2 +++ b/gmyth/src/gmyth_monitor_handler.c Mon Dec 04 22:00:41 2006 +0000
6.3 @@ -79,8 +79,6 @@
6.4 GMYTH_RINGBUFFER_TYPE
6.5 };
6.6
6.7 -static GStaticMutex st_mutex = G_STATIC_MUTEX_INIT;
6.8 -
6.9 static gboolean* myth_control_sock_listener( GIOChannel *io_channel );
6.10 //static gboolean myth_control_sock_listener( GIOChannel *io_channel, GIOCondition condition,
6.11 // gpointer data );
6.12 @@ -89,8 +87,6 @@
6.13
6.14 static GCond* io_watcher_cond = NULL;
6.15
6.16 -static GMainContext* io_watcher_context = NULL;
6.17 -
6.18 static void gmyth_monitor_handler_class_init (GMythMonitorHandlerClass *klass);
6.19 static void gmyth_monitor_handler_init (GMythMonitorHandler *object);
6.20
6.21 @@ -101,10 +97,6 @@
6.22
6.23 void gmyth_monitor_handler_close( GMythMonitorHandler *monitor );
6.24
6.25 -static gboolean myth_control_acquire_context( gboolean do_wait );
6.26 -
6.27 -static gboolean myth_control_release_context( );
6.28 -
6.29 G_DEFINE_TYPE(GMythMonitorHandler, gmyth_monitor_handler, G_TYPE_OBJECT)
6.30
6.31 static void
6.32 @@ -316,49 +308,13 @@
6.33 gboolean
6.34 gmyth_monitor_handler_start (GMythMonitorHandler *monitor)
6.35 {
6.36 - gboolean ret = TRUE;
6.37 -
6.38 - if (!g_thread_supported ()) g_thread_init (NULL);
6.39 -
6.40 - monitor_th = g_thread_create( (GThreadFunc)myth_control_sock_listener,
6.41 + monitor_th = g_thread_create( (GThreadFunc)myth_control_sock_listener,
6.42 monitor->event_sock->sd_io_ch, TRUE, NULL );
6.43
6.44 -/*
6.45 - io_watcher_context = g_main_context_default();
6.46 - //GMainLoop *loop = g_main_loop_new( NULL, TRUE );
6.47 -
6.48 - GSource *source;
6.49 -
6.50 - if ( monitor->event_sock->sd_io_ch != NULL ) {
6.51 - source = g_io_create_watch( monitor->event_sock->sd_io_ch, G_IO_IN );
6.52 - //monitor->event_sock->sd_io_ch
6.53 - } else {
6.54 - ret = FALSE;
6.55 - goto cleanup;
6.56 - }
6.57 -
6.58 - g_source_set_callback ( source, (GSourceFunc)myth_control_sock_listener, NULL, NULL );
6.59 -
6.60 - g_source_attach( source, io_watcher_context );
6.61 -
6.62 - if (source==NULL) {
6.63 - gmyth_debug( "[%s] Error adding watch listener function to the IO control channel!\n", __FUNCTION__ );
6.64 - goto cleanup;
6.65 - }
6.66 - */
6.67 -
6.68 - gmyth_debug ( "[%s]\tOK! Starting listener on the MONITOR event socket...\n", __FUNCTION__ );
6.69 -
6.70 - //g_main_loop_run( loop );
6.71 -
6.72 -cleanup:
6.73 - //if ( source != NULL )
6.74 - // g_source_unref( source );
6.75 + gmyth_debug( "[%s] Watch listener function over the IO control channel? %s!!!\n",
6.76 + __FUNCTION__, ( ret == TRUE ? "YES" : "NO" ) );
6.77
6.78 - gmyth_debug( "[%s] Watch listener function over the IO control channel? %s!!!\n",
6.79 - __FUNCTION__, ( ret == TRUE ? "YES" : "NO" ) );
6.80 -
6.81 - return ret;
6.82 + return TRUE;
6.83 }
6.84
6.85 void
6.86 @@ -377,55 +333,3 @@
6.87
6.88 }
6.89
6.90 -static gboolean
6.91 -myth_control_acquire_context( gboolean do_wait )
6.92 -{
6.93 -
6.94 - gboolean ret = TRUE;
6.95 - //guint max_iter = 50;
6.96 -
6.97 - //g_mutex_lock( mutex );
6.98 -
6.99 - //while ( !has_io_access )
6.100 - // g_cond_wait( io_watcher_cond, mutex );
6.101 -
6.102 - //has_io_access = FALSE;
6.103 -
6.104 - //myth_control_acquire_context (FALSE);
6.105 -
6.106 - /*
6.107 - if ( do_wait ) {
6.108 - while ( --max_iter > 0 && !g_main_context_wait( io_watcher_context, io_watcher_cond, mutex ) )
6.109 - ret = FALSE;
6.110 - } else if ( !g_main_context_acquire( io_watcher_context ) )
6.111 - ret = FALSE;
6.112 - */
6.113 -
6.114 - //g_static_mutex_lock( &st_mutex );
6.115 -
6.116 - return ret;
6.117 -
6.118 -}
6.119 -
6.120 -static gboolean
6.121 -myth_control_release_context( )
6.122 -{
6.123 -
6.124 - gboolean ret = TRUE;
6.125 -
6.126 - //g_static_mutex_unlock( &st_mutex );
6.127 -
6.128 - //g_main_context_release( io_watcher_context );
6.129 -
6.130 - //g_main_context_wakeup( io_watcher_context );
6.131 -
6.132 - //has_io_access = TRUE;
6.133 -
6.134 - //g_cond_broadcast( io_watcher_cond );
6.135 -
6.136 - //g_mutex_unlock( mutex );
6.137 -
6.138 - return ret;
6.139 -
6.140 -}
6.141 -