# HG changeset patch # User melunko # Date 1164662457 0 # Node ID b90cf50ca3dcedeb7f0672253021a91bd1be32c6 # Parent e3cedfae0f2ee63144822fa0988e5d0209035bc9 [svn r118] Added GMythBackendInfo class to fit our architecture needs diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/Makefile.am --- a/gmyth/src/Makefile.am Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/Makefile.am Mon Nov 27 21:20:57 2006 +0000 @@ -4,11 +4,9 @@ libgmyth_la_SOURCES = \ gmyth_common.c \ - gmyth_context.c \ gmyth_epg.c \ gmyth_recorder.c \ gmyth_remote_util.c \ - gmyth_settings.c \ gmyth_tvchain.c \ gmyth_scheduler.c \ gmyth_util.c \ @@ -17,6 +15,7 @@ gmyth_stringlist.c \ gmyth_file_transfer.c \ gmyth_livetv.c \ + gmyth_backendinfo.c \ gmyth_uri.c libgmyth_la_CFLAGS = \ @@ -44,11 +43,9 @@ libgmyth_include_HEADERS = \ gmyth_common.h \ - gmyth_context.h \ gmyth_epg.h \ gmyth_recorder.h \ gmyth_scheduler.h \ - gmyth_settings.h \ gmyth_tvchain.h \ gmyth_util.h \ gmyth_query.h \ @@ -57,6 +54,7 @@ gmyth_stringlist.h \ gmyth_file_transfer.h \ gmyth_livetv.h \ + gmyth_backendinfo.h \ gmyth_uri.h CLEANFILES = $(BUILT_SOURCES) diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_backendinfo.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/src/gmyth_backendinfo.c Mon Nov 27 21:20:57 2006 +0000 @@ -0,0 +1,187 @@ + +/** + * GMyth Library + * + * @file gmyth/gmyth_backend_info.c + * + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. + * @author Hallyson Melo + * + *//* + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gmyth_backendinfo.h" + +static void gmyth_backend_info_class_init (GMythBackendInfoClass *klass); +static void gmyth_backend_info_init (GMythBackendInfo *object); + +static void gmyth_backend_info_dispose (GObject *object); +static void gmyth_backend_info_finalize (GObject *object); + +static gint get_record_id_from_database (GMythBackendInfo *scheduler); +static void update_backend (gint record_id); + +G_DEFINE_TYPE(GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT) + +static void +gmyth_backend_info_class_init (GMythBackendInfoClass *klass) +{ + GObjectClass *gobject_class; + + gobject_class = (GObjectClass *) klass; + + gobject_class->dispose = gmyth_backend_info_dispose; + gobject_class->finalize = gmyth_backend_info_finalize; +} + +static void +gmyth_backend_info_init (GMythBackendInfo *backend_info) +{ + backend_info->hostname = NULL; + backend_info->username = NULL; + backend_info->password = NULL; + backend_info->db_name = NULL; + backend_info->port = -1; +} + +static void +gmyth_backend_info_dispose (GObject *object) +{ + GMythBackendInfo *backend_info = GMYTH_BACKEND_INFO (object); + + g_free (backend_info->hostname); + g_free (backend_info->username); + g_free (backend_info->password); + g_free (backend_info->db_name); + + backend_info->hostname = NULL; + backend_info->username = NULL; + backend_info->password = NULL; + backend_info->db_name = NULL; + backend_info->port = -1; + + G_OBJECT_CLASS (gmyth_backend_info_parent_class)->dispose (object); +} + +static void +gmyth_backend_info_finalize (GObject *object) +{ + g_signal_handlers_destroy (object); + + G_OBJECT_CLASS (gmyth_backend_info_parent_class)->finalize (object); +} + +/** Creates a new instance of GMythBackendInfo. + * + * @return a new instance of GMythBackendInfo. + */ +GMythBackendInfo* +gmyth_backend_info_new () +{ + GMythBackendInfo *backend_info = + GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL)); + + return backend_info; +} + +GMythBackendInfo* +gmyth_backend_info_new_full (const char *hostname, const char *username, + const char *password, const char *db_name, gint port) +{ + GMythBackendInfo *backend_info = + GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL)); + + gmyth_backend_info_set_hostname (backend_info, hostname); + gmyth_backend_info_set_username (backend_info, username); + gmyth_backend_info_set_password (backend_info, password); + gmyth_backend_info_set_db_name (backend_info, db_name); + gmyth_backend_info_set_port (backend_info, port); + + return backend_info; +} + +void +gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const char *hostname) +{ + g_return_if_fail (backend_info != NULL); + + backend_info->hostname = g_strdup (hostname); +} + +void +gmyth_backend_info_set_username (GMythBackendInfo *backend_info, const char *username) +{ + g_return_if_fail (backend_info != NULL); + + backend_info->username = g_strdup (username); +} + +void +gmyth_backend_info_set_password (GMythBackendInfo *backend_info, const char *password) +{ + g_return_if_fail (backend_info != NULL); + + backend_info->password = g_strdup (password); +} + +void +gmyth_backend_info_set_db_name (GMythBackendInfo *backend_info, const char *db_name) +{ + g_return_if_fail (backend_info != NULL); + + backend_info->db_name = g_strdup (db_name); +} + +char* +gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info) +{ + g_return_val_if_fail (backend_info != NULL, NULL); + + return backend_info->hostname; +} + +char* +gmyth_backend_info_get_username (GMythBackendInfo *backend_info) +{ + g_return_val_if_fail (backend_info != NULL, NULL); + + return backend_info->username; +} + +char* +gmyth_backend_info_get_password (GMythBackendInfo *backend_info) +{ + g_return_val_if_fail (backend_info != NULL, NULL); + + return backend_info->password; +} + +char* +gmyth_backend_info_get_db_name (GMythBackendInfo *backend_info) +{ + g_return_val_if_fail (backend_info != NULL, NULL); + + return backend_info->db_name; +} + +gint +gmyth_backend_info_get_port (GMythBackendInfo *backend_info) +{ + g_return_val_if_fail (backend_info != NULL, -1); + + return backend_info->port; +} diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_backendinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/src/gmyth_backendinfo.h Mon Nov 27 21:20:57 2006 +0000 @@ -0,0 +1,88 @@ +/** + * GMyth Library + * + * @file gmyth/gmyth_backend_info.h + * + * + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. + * @author Hallyson Melo + * + *//* + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __GMYTH_BACKEND_INFO_H__ +#define __GMYTH_BACKEND_INFO_H__ + +#include + +G_BEGIN_DECLS + +#define GMYTH_BACKEND_INFO_TYPE (gmyth_backend_info_get_type ()) +#define GMYTH_BACKEND_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfo)) +#define GMYTH_BACKEND_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass)) +#define IS_GMYTH_BACKEND_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_BACKEND_INFO_TYPE)) +#define IS_GMYTH_BACKEND_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE)) +#define GMYTH_BACKEND_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass)) + + +typedef struct _GMythBackendInfo GMythBackendInfo; +typedef struct _GMythBackendInfoClass GMythBackendInfoClass; + +struct _GMythBackendInfoClass +{ + GObjectClass parent_class; + + /* callbacks */ + /* no one for now */ +}; + +struct _GMythBackendInfo +{ + GObject parent; + + gchar *hostname; + gchar *username; + gchar *password; + gchar *db_name; + gint port; +}; + + +GType gmyth_backend_info_get_type (void); + +GMythBackendInfo* gmyth_backend_info_new (); +GMythBackendInfo* gmyth_backend_info_new_full ( + const char *hostname, const char *username, const char *password, + const char *db_name, gint port); + +void gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const char *hostname); +void gmyth_backend_info_set_username (GMythBackendInfo *backend_info, const char *username); +void gmyth_backend_info_set_password (GMythBackendInfo *backend_info, const char *password); +void gmyth_backend_info_set_db_name (GMythBackendInfo *backend_info, const char *db_name); +void gmyth_backend_info_set_port (GMythBackendInfo *backend_info, gint port); + +char* gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info); +char* gmyth_backend_info_get_username (GMythBackendInfo *backend_info); +char* gmyth_backend_info_get_password (GMythBackendInfo *backend_info); +char* gmyth_backend_info_get_db_name (GMythBackendInfo *backend_info); +gint gmyth_backend_info_get_port (GMythBackendInfo *backend_info); + + +G_END_DECLS + +#endif /* __GMYTH_BACKEND_INFO_H__ */ + diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_context.c --- a/gmyth/src/gmyth_context.c Mon Nov 27 21:20:17 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,311 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_context.c - * - * @brief

GMythContext class contains general attributes and functions - * that express the connection state of each mythtvfrontend. - * - * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. - * @author Hallyson Luiz de Morais Melo - * - *//* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "gmyth_context.h" - -#include -#include -#include -#include -#include -#include - -#include "gmyth_query.h" -#include "gmyth_socket.h" - -static void gmyth_context_class_init (GMythContextClass *klass); -static void gmyth_context_init (GMythContext *object); - -static void gmyth_context_dispose (GObject *object); -static void gmyth_context_finalize (GObject *object); - - -G_DEFINE_TYPE(GMythContext, gmyth_context, G_TYPE_OBJECT) - -static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - -static GMythContext *gcontext = NULL; - -static void -gmyth_context_class_init (GMythContextClass *klass) -{ - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *) klass; - - gobject_class->dispose = gmyth_context_dispose; - gobject_class->finalize = gmyth_context_finalize; -} - -static void -gmyth_context_init (GMythContext *gmyth_context) -{ - -} - -static void -gmyth_context_dispose (GObject *object) -{ - GMythContext *gmyth_context = GMYTH_CONTEXT(object); - - if ( gmyth_context->gmyth_settings != NULL ) { - g_object_unref (gmyth_context->gmyth_settings); - gmyth_context->gmyth_settings = NULL; - } - - if ( gmyth_context->localhostname != NULL ) { - g_string_free ( gmyth_context->localhostname, TRUE ); - gmyth_context->localhostname = NULL; - } - - if (gmyth_context->server_socket != NULL) { - g_object_unref (gmyth_context->server_socket); - gmyth_context->server_socket = NULL; - } - - G_OBJECT_CLASS (gmyth_context_parent_class)->dispose (object); -} - -static void -gmyth_context_finalize (GObject *object) -{ - g_signal_handlers_destroy (object); - - G_OBJECT_CLASS (gmyth_context_parent_class)->finalize (object); -} - -/** Gets the some important address translation info, - * from the client socket that will open a connection. - * - * @return gint error number - */ -static gint -myth_context_toaddrinfo( gchar *addr, gint port, struct addrinfo **addrInfo ) -{ - struct addrinfo hints; - gchar *portStr = g_strnfill( 32, ' ' ); - gint errorn = EADDRNOTAVAIL; - - memset( &hints, 0, sizeof(hints) ); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - - /* hints.ai_flags = AI_NUMERICHOST; */ - if ( port != -1 ) - sprintf(portStr, "%d", port); - else - portStr = NULL; - - g_debug( "[%s] Address: %s, port: %s\n", __FUNCTION__, addr, portStr ); - if ( ( errorn = getaddrinfo(addr, portStr, &hints, addrInfo) ) != 0 ) { - g_printerr( "[%s] Socket ERROR: %s\n", __FUNCTION__, gai_strerror(errorn) ); - } - - return errorn; - -} - -/** Initializes the GMythContext object. It reads local system information - * load gmyth user settings and start connection to the database. - * - * @return TRUE if initialization was successfull, - * FALSE if any error happens. - */ -gboolean -gmyth_context_initialize () -{ - GString *localhost = NULL; - - if (gcontext == NULL) { - gcontext = GMYTH_CONTEXT ( g_object_new (GMYTH_CONTEXT_TYPE, FALSE)); - } - - localhost = gmyth_socket_get_local_hostname( ); - - if (localhost==NULL || localhost->len <=0 ) { - g_warning ("[%s] Could not determine local hostname. Setting to 127.0.0.1", __FUNCTION__); - gcontext->localhostname = g_string_new ("127.0.0.1"); - } else { - gcontext->localhostname = localhost; - } - - if (gcontext->gmyth_settings) { - g_object_unref (gcontext->gmyth_settings); - gcontext->gmyth_settings = NULL; - } - - gcontext->gmyth_settings = gmyth_settings_new (); - if (!gmyth_settings_load (gcontext->gmyth_settings)) { - g_warning ("GMythContext: Settings file not opened!\n"); - } else { - g_debug ("GMythContext: Settings file loaded"); - } - - if (gcontext->server_socket != NULL) { - g_object_unref (gcontext->server_socket); - gcontext->server_socket = NULL; - } - - GString *server_hostname = - gmyth_settings_get_backend_hostname(gcontext->gmyth_settings); - int server_port = gmyth_settings_get_backend_port(gcontext->gmyth_settings); - - gcontext->server_socket = gmyth_socket_new (); - if (!gmyth_socket_connect_to_backend ( gcontext->server_socket, - server_hostname->str, server_port, FALSE)) { - g_warning ("[%s] Socket connection to backend error!", __FUNCTION__); - g_object_unref (gcontext->server_socket); - gcontext->server_socket = NULL; - return FALSE; - } - - return TRUE; -} - -/** Formats a Mythtv protocol command based on strlist and sends it to - * the connected backend. The backend response is overwritten into strlist. - * - * @param strlist the string list to be sent, - * and on which the answer will be written. - * @return TRUE if command was sent and an answer was received, FALSE if any - * error happens. - */ -gboolean -gmyth_context_send_receive_stringlist (GMythStringList *strlist) -{ - gint ok = -1; - - if (!gcontext || !(gcontext->server_socket)) { - g_warning ("[%s] GMythContext not initialized", __FUNCTION__); - return FALSE; - } - - //g_static_mutex_lock( &mutex ); - - ok = gmyth_socket_sendreceive_stringlist (gcontext->server_socket, strlist); - - //g_static_mutex_unlock( &mutex ); - - if (!ok) { - g_warning ("Connection to backend server lost"); - } - - return (ok ? TRUE : FALSE); -} - -/** Gets the GMythSettings object associated to this context. - * - * @return The GMythSettings object currently valid or NULL if the settings - * were not opened. - */ -GMythSettings* -gmyth_context_get_settings () -{ - if (!gcontext) { - g_warning ("[%s] GMythContext not initialized\n", __FUNCTION__); - return NULL; - } - - return gcontext->gmyth_settings; -} - -/** Gets the machine local hostname. - * - * @param hostname a valid GString object to be overwritten with the local - * hostname. - * @return true if the hostname was read, false if any error happened. - */ -gboolean -gmyth_context_get_local_hostname (GString *hostname) -{ - if (!hostname) { - g_warning ("[%s] Received null argument", __FUNCTION__); - return FALSE; - } - - g_string_assign (hostname, gcontext->localhostname->str); - - return TRUE; -} - -/** Gets a setting information from the backend mysql database. - * - * @param key The setting key to be retrieved. - * @param host the hostname associated to the desired setting. - * @param default_value the default setting value if could not query from - * backend database. - * @return The setting value loaded from database, or the given default value - * if the query fails. - */ -GString* -gmyth_context_get_setting_onhost (GString *key, GString *host, GString *default_value) -{ - GString *query_str; - - // TODO: Reuse msql query in gmyth_context - GMythQuery *gmyth_query = gmyth_query_new (); - - if (gmyth_query_connect (gmyth_query)) { - MYSQL_RES *msql_res; - MYSQL_ROW msql_row; - - query_str = g_string_new (""); - g_string_printf (query_str, "SELECT data FROM settings WHERE value = \"%s\" " - "AND hostname = \"%s\" ;", key->str, host->str); - - msql_res = gmyth_query_process_statement (gmyth_query, query_str->str); - if (msql_res) { - msql_row = mysql_fetch_row (msql_res); - if (msql_row != NULL) { - return g_string_new (msql_row[0]); - } - } - - g_object_unref (gmyth_query); - } else { - g_warning ("Database not open while trying to load setting: %s", key->str); - } - - return default_value; -} - -/** Verify if the context is currently connected to a backend. - * - * @return true if connection was opened, false if not. - */ -gboolean -gmyth_context_check_connection () -{ - // FIXME: Check this based on socket states - if (!gcontext) { - g_warning ("[%s] GMythContext not initialized", __FUNCTION__); - return FALSE; - } - - return (gcontext->server_socket != NULL); -} diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_context.h --- a/gmyth/src/gmyth_context.h Mon Nov 27 21:20:17 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_context.h - * - * @brief

GMythContext class contains general attributes and functions - * that express the connection state of each mythtvfrontend. - * - * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. - * @author Hallyson Luiz de Morais Melo - * - *//* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __GMYTH_CONTEXT_H__ -#define __GMYTH_CONTEXT_H__ - -#include - -#include "gmyth_settings.h" -#include "gmyth_socket.h" -#include "gmyth_stringlist.h" - -G_BEGIN_DECLS - -#define GMYTH_CONTEXT_TYPE (gmyth_context_get_type ()) -#define GMYTH_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_CONTEXT_TYPE, GMythContext)) -#define GMYTH_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_CONTEXT_TYPE, GMythContextClass)) -#define IS_GMYTH_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_CONTEXT_TYPE)) -#define IS_GMYTH_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_CONTEXT_TYPE)) -#define GMYTH_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_CONTEXT_TYPE, GMythContextClass)) - -#define MYTHTV_VERSION_DEFAULT 30 - -typedef struct _GMythContext GMythContext; -typedef struct _GMythContextClass GMythContextClass; - -struct _GMythContextClass -{ - GObjectClass parent_class; - - /* callbacks */ - /* no one for now */ -}; - -struct _GMythContext -{ - GObject parent; - - GMythSettings *gmyth_settings; - GMythSocket *server_socket; - - GString *localhostname; -}; - - -GType gmyth_context_get_type (void); -void gmyth_context_create(); - -gboolean gmyth_context_initialize (); -gboolean gmyth_context_check_connection (); -GMythSettings* gmyth_context_get_settings (); - -gboolean gmyth_context_send_receive_stringlist (GMythStringList *strlist); - -GString* gmyth_context_get_setting_onhost (GString *key, GString *host, GString *default_value); -gboolean gmyth_context_get_local_hostname (GString *hostname); - -GString* gmyth_context_get_setting_onhost (GString *key, GString *host, GString *default_value); - - -G_END_DECLS - -#endif /* __GMYTH_CONTEXT_H__ */ diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_epg.c --- a/gmyth/src/gmyth_epg.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_epg.c Mon Nov 27 21:20:57 2006 +0000 @@ -56,7 +56,7 @@ static void gmyth_epg_init (GMythEPG *gmyth_epg) { - gmyth_epg->sqlquery = gmyth_query_new (); + } static void @@ -70,7 +70,7 @@ static void gmyth_epg_finalize (GObject *object) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy (object); G_OBJECT_CLASS (gmyth_epg_parent_class)->finalize (object); } @@ -95,16 +95,16 @@ * @return true if connection was success, false if failed. */ gboolean -gmyth_epg_connect (GMythEPG *gmyth_epg) +gmyth_epg_connect (GMythEPG *gmyth_epg, GMythBackendInfo *backend_info) { - assert(gmyth_epg); + assert(gmyth_epg); - if (gmyth_epg->sqlquery == NULL) { - g_warning ("[%s] GMythEPG db initializing", __FUNCTION__); - gmyth_epg->sqlquery = gmyth_query_new (); - } + if (gmyth_epg->sqlquery == NULL) { + g_debug ("[%s] Creating gmyth_query", __FUNCTION__); + gmyth_epg->sqlquery = gmyth_query_new ( ); + } - if (!gmyth_query_connect(gmyth_epg->sqlquery)) { + if (!gmyth_query_connect(gmyth_epg->sqlquery, backend_info)) { g_warning ("[%s] Error while connecting to db", __FUNCTION__); return FALSE; } diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_epg.h --- a/gmyth/src/gmyth_epg.h Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_epg.h Mon Nov 27 21:20:57 2006 +0000 @@ -65,7 +65,7 @@ GMythEPG* gmyth_epg_new (void); -gboolean gmyth_epg_connect (GMythEPG *gmyth_epg); +gboolean gmyth_epg_connect (GMythEPG *gmyth_epg, GMythBackendInfo *backend_info); gboolean gmyth_epg_disconnect (GMythEPG *gmyth_epg); gint gmyth_epg_get_channel_list (GMythEPG *gmyth_epg, GList **glist_ptr); diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Mon Nov 27 21:20:57 2006 +0000 @@ -37,7 +37,6 @@ #include "gmyth_livetv.h" #include "gmyth_util.h" #include "gmyth_socket.h" -#include "gmyth_context.h" #include "gmyth_stringlist.h" #include @@ -49,6 +48,7 @@ #include #include #include +#include #define GMYTHTV_QUERY_HEADER "QUERY_FILETRANSFER " @@ -74,8 +74,6 @@ #define GMYTHTV_ENABLE_DEBUG 1 #endif -//static gboolean has_io_access = TRUE; - enum myth_sock_types { GMYTH_PLAYBACK_TYPE = 0, GMYTH_MONITOR_TYPE, @@ -92,8 +90,6 @@ static GCond* io_watcher_cond = NULL; -static GMainContext *io_watcher_context = NULL; - static void gmyth_file_transfer_class_init (GMythFileTransferClass *klass); static void gmyth_file_transfer_init (GMythFileTransfer *object); @@ -101,7 +97,6 @@ static void gmyth_file_transfer_finalize (GObject *object); static gboolean gmyth_connect_to_backend (GMythFileTransfer *transfer); -//static gboolean myth_init_io_watchers( GMythFileTransfer *transfer ); void gmyth_file_transfer_close( GMythFileTransfer *transfer ); @@ -674,3 +669,11 @@ return TRUE; } + +guint64 +gmyth_file_transfer_get_filesize (GMythFileTransfer *transfer) +{ + assert (transfer); + + return transfer->filesize; +} diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_livetv.c Mon Nov 27 21:20:57 2006 +0000 @@ -25,9 +25,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "gmyth_context.h" #include "gmyth_remote_util.h" #include "gmyth_tvchain.h" +#include "gmyth_socket.h" #include "gmyth_livetv.h" #include "gmyth_file_transfer.h" @@ -111,25 +111,29 @@ } gboolean -gmyth_livetv_setup ( GMythLiveTV *livetv ) +gmyth_livetv_setup ( GMythLiveTV *livetv, GMythBackendInfo *backend_info ) { - GMythSettings *msettings = gmyth_context_get_settings (); gboolean res = TRUE; + char *hostname; - livetv->is_livetv = TRUE; + GMythSocket *socket = gmyth_socket_new (); - res = gmyth_context_check_connection(); + // FIME: Implement this at gmyth_socket + res = gmyth_socket_connect_to_backend (socket, backend_info->hostname, + backend_info->port, TRUE); if (!res) { g_warning ("[%s] LiveTV can not connect to backend", __FUNCTION__); res = FALSE; goto error; } - livetv->backend_hostname = gmyth_settings_get_backend_hostname(msettings); - livetv->backend_port = gmyth_settings_get_backend_port (msettings); + livetv->is_livetv = TRUE; - livetv->local_hostname = g_string_new(""); - gmyth_context_get_local_hostname (livetv->local_hostname); + hostname = gmyth_backend_info_get_hostname(backend_info); + livetv->backend_hostname = g_string_new (hostname); + livetv->backend_port = gmyth_backend_info_get_port (backend_info); + + livetv->local_hostname = gmyth_socket_get_local_hostname ( ); if ( livetv->local_hostname == NULL ) { res = FALSE; @@ -137,7 +141,8 @@ } // Gets the recorder num - livetv->recorder = remote_request_next_free_recorder (-1); + livetv->recorder = remote_request_next_free_recorder (socket, -1); + gmyth_socket_close_connection (socket); if ( livetv->recorder == NULL ) { g_warning ("[%s] None remote encoder available", __FUNCTION__); @@ -147,7 +152,7 @@ // Creates livetv chain handler livetv->tvchain = GMYTH_TVCHAIN ( g_object_new(GMYTH_TVCHAIN_TYPE, NULL) ); - gmyth_tvchain_initialize ( livetv->tvchain, livetv->local_hostname ); + gmyth_tvchain_initialize ( livetv->tvchain, backend_info ); if ( livetv->tvchain == NULL || livetv->tvchain->tvchain_id == NULL ) { res = FALSE; @@ -305,6 +310,7 @@ } } +// FIXME: put here just a wrapper function to call gmyth_recorder_is_recording()... gboolean gmyth_livetv_is_recording ( GMythLiveTV *livetv ) { diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_livetv.h --- a/gmyth/src/gmyth_livetv.h Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_livetv.h Mon Nov 27 21:20:57 2006 +0000 @@ -33,6 +33,7 @@ #include "gmyth_recorder.h" #include "gmyth_tvchain.h" #include "gmyth_common.h" +#include "gmyth_backendinfo.h" #include "gmyth_file_transfer.h" @@ -82,7 +83,7 @@ gboolean gmyth_livetv_is_recording ( GMythLiveTV *livetv ); -gboolean gmyth_livetv_setup (GMythLiveTV *livetv); +gboolean gmyth_livetv_setup (GMythLiveTV *livetv, GMythBackendInfo *backend_info); gboolean gmyth_livetv_next_program_chain ( GMythLiveTV *livetv ); #define G_END_DECLS diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_query.c --- a/gmyth/src/gmyth_query.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_query.c Mon Nov 27 21:20:57 2006 +0000 @@ -31,8 +31,6 @@ #include #include "gmyth_query.h" -#include "gmyth_settings.h" -#include "gmyth_context.h" static void gmyth_query_class_init (GMythQueryClass *klass); static void gmyth_query_init (GMythQuery *object); @@ -47,7 +45,7 @@ static void gmyth_query_class_init (GMythQueryClass *klass) { - GObjectClass *gobject_class; + GObjectClass *gobject_class; gobject_class = (GObjectClass *) klass; @@ -58,12 +56,7 @@ static void gmyth_query_init (GMythQuery *gmyth_query) { - GMythSettings *gmyth_settings = gmyth_context_get_settings (); - - gmyth_query->opt_host_name = gmyth_settings_get_backend_hostname(gmyth_settings); - gmyth_query->opt_user_name = gmyth_settings_get_username(gmyth_settings); - gmyth_query->opt_password = gmyth_settings_get_password(gmyth_settings); - gmyth_query->opt_db_name = gmyth_settings_get_dbname(gmyth_settings); + gmyth_query->backend_info = NULL; /* initialize connection handler */ gmyth_query->conn = mysql_init (NULL); @@ -78,16 +71,18 @@ { GMythQuery *gmyth_query = GMYTH_QUERY (object); - /* disconnect from server */ - gmyth_query_disconnect (gmyth_query); - - G_OBJECT_CLASS (gmyth_query_parent_class)->dispose (object); + if (gmyth_query->backend_info) { + g_object_unref (gmyth_query->backend_info); + gmyth_query->backend_info = NULL; + } + + G_OBJECT_CLASS (gmyth_query_parent_class)->dispose (object); } static void gmyth_query_finalize (GObject *object) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy (object); G_OBJECT_CLASS (gmyth_query_parent_class)->finalize (object); } @@ -105,35 +100,35 @@ } /** Connects to the Mysql database in the backend. The backend address - * is loaded from the GMythSettings instance. + * is loaded from the GMythBackendInfo instance. * * @param gmyth_query the GMythEPG instance to be connected. * @return true if connection was success, false if failed. */ gboolean -gmyth_query_connect (GMythQuery *gmyth_query) +gmyth_query_connect (GMythQuery *gmyth_query, GMythBackendInfo *backend_info) { - char *opt_host_name; - char *opt_user_name; - char *opt_password; - char *opt_db_name; + assert(gmyth_query); + g_return_val_if_fail (backend_info != NULL, FALSE); + g_return_val_if_fail (backend_info->hostname != NULL, FALSE); + g_return_val_if_fail (backend_info->username != NULL, FALSE); + g_return_val_if_fail (backend_info->password != NULL, FALSE); + g_return_val_if_fail (backend_info->db_name != NULL, FALSE); + + g_object_ref (backend_info); + gmyth_query->backend_info = backend_info; - assert(gmyth_query); - - opt_host_name = (gmyth_query->opt_host_name ? gmyth_query->opt_host_name->str : NULL); - opt_db_name = (gmyth_query->opt_db_name ? gmyth_query->opt_db_name->str : NULL); - opt_user_name = (gmyth_query->opt_user_name ? gmyth_query->opt_user_name->str : NULL); - opt_password = (gmyth_query->opt_password ? gmyth_query->opt_password->str : NULL); - - if (gmyth_query->conn == NULL) { gmyth_query_print_error (NULL, "mysql_init() failed (probably out of memory)"); return FALSE; } /* connect to server */ - if (mysql_real_connect (gmyth_query->conn, opt_host_name, - opt_user_name, opt_password, opt_db_name, + if (mysql_real_connect (gmyth_query->conn, + gmyth_query->backend_info->hostname, + gmyth_query->backend_info->username, + gmyth_query->backend_info->password, + gmyth_query->backend_info->db_name, 0, NULL, 0) == NULL) { gmyth_query_print_error (gmyth_query->conn, "mysql_real_connect() failed"); diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_query.h --- a/gmyth/src/gmyth_query.h Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_query.h Mon Nov 27 21:20:57 2006 +0000 @@ -34,6 +34,8 @@ /* MYSQL includes */ #include +#include "gmyth_backendinfo.h" + G_BEGIN_DECLS #define GMYTH_QUERY_TYPE (gmyth_query_get_type ()) @@ -59,24 +61,22 @@ { GObject parent; - GString *opt_host_name; /* server host (default=localhost) */ - GString *opt_user_name; /* username (default=login name) */ - GString *opt_password; /* password (default=none) */ - unsigned int opt_port_num; /* port number (use built-in value) */ + GMythBackendInfo *backend_info; + GString *opt_socket_name; /* socket name (use built-in value) */ - GString *opt_db_name; /* database name (default=none) */ unsigned int opt_flags; /* connection flags (none) */ + MYSQL *conn; /* pointer to connection handler */ }; GType gmyth_query_get_type (void); -GMythQuery* gmyth_query_new (); +GMythQuery* gmyth_query_new ( ); MYSQL_RES * gmyth_query_process_statement (GMythQuery *gmyth_query, char *stmt_str); -gboolean gmyth_query_connect (GMythQuery *gmyth_query); +gboolean gmyth_query_connect (GMythQuery *gmyth_query, GMythBackendInfo *backend_info); gboolean gmyth_query_disconnect (GMythQuery *gmyth_query); G_END_DECLS diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_recorder.c Mon Nov 27 21:20:57 2006 +0000 @@ -219,7 +219,7 @@ GMythStringList *str_list; GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); - g_debug ( "[%s] FRONTEND_READY with recorder id = %d\n", __FUNCTION__, recorder->recorder_num ); + g_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, recorder->recorder_num ); str_list = gmyth_string_list_new (); diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_remote_util.c --- a/gmyth/src/gmyth_remote_util.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_remote_util.c Mon Nov 27 21:20:57 2006 +0000 @@ -27,7 +27,6 @@ #include "gmyth_remote_util.h" -#include "gmyth_context.h" #include "gmyth_recorder.h" #include "gmyth_stringlist.h" @@ -37,20 +36,20 @@ * @return the remote encoder instance available, or NULL if any error happens. */ GMythRecorder* -remote_request_next_free_recorder (int curr) +remote_request_next_free_recorder (GMythSocket *socket, int curr) { - GMythRecorder *recorder = NULL; - GString *hostname; - int num, port; + GMythRecorder *recorder = NULL; + GString *hostname; + int num, port; - GMythStringList *strlist = gmyth_string_list_new(); + GMythStringList *strlist = gmyth_string_list_new(); - g_debug ("[%s] Request next free recorder in the backend", __FUNCTION__); + g_debug ("[%s] Request next free recorder in the backend", __FUNCTION__); gmyth_string_list_append_char_array (strlist, "GET_NEXT_FREE_RECORDER"); gmyth_string_list_append_int (strlist, curr); - if (!gmyth_context_send_receive_stringlist(strlist)) { + if (!gmyth_socket_sendreceive_stringlist(socket, strlist)) { g_warning ("GET_NEXT_FREE_RECORDER request error!\n"); return NULL; } diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_remote_util.h --- a/gmyth/src/gmyth_remote_util.h Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_remote_util.h Mon Nov 27 21:20:57 2006 +0000 @@ -30,10 +30,11 @@ #include #include "gmyth_recorder.h" +#include "gmyth_socket.h" G_BEGIN_DECLS -GMythRecorder* remote_request_next_free_recorder (int curr); +GMythRecorder* remote_request_next_free_recorder (GMythSocket *socket, int curr); G_END_DECLS diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_scheduler.c Mon Nov 27 21:20:57 2006 +0000 @@ -30,9 +30,9 @@ #include "gmyth_scheduler.h" -#include "gmyth_context.h" #include "gmyth_util.h" #include "gmyth_query.h" +#include "gmyth_socket.h" static void gmyth_scheduler_class_init (GMythSchedulerClass *klass); static void gmyth_scheduler_init (GMythScheduler *object); @@ -41,14 +41,14 @@ static void gmyth_scheduler_finalize (GObject *object); static gint get_record_id_from_database (GMythScheduler *scheduler); -static void update_backend (gint record_id); +static void update_backend (GMythScheduler *scheduler, gint record_id); G_DEFINE_TYPE(GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT) static void gmyth_scheduler_class_init (GMythSchedulerClass *klass) { - GObjectClass *gobject_class; + GObjectClass *gobject_class; gobject_class = (GObjectClass *) klass; @@ -59,7 +59,7 @@ static void gmyth_scheduler_init (GMythScheduler *sched) { - sched->recordid =0; + sched->recordid =0; sched->type = 0; sched->search = 0; sched->profile = g_string_new(""); @@ -97,13 +97,20 @@ static void gmyth_scheduler_dispose (GObject *object) { - G_OBJECT_CLASS (gmyth_scheduler_parent_class)->dispose (object); + GMythScheduler *scheduler = GMYTH_SCHEDULER (object); + + if (scheduler->backend_info) { + g_object_unref (scheduler->backend_info); + scheduler->backend_info = NULL; + } + + G_OBJECT_CLASS (gmyth_scheduler_parent_class)->dispose (object); } static void gmyth_scheduler_finalize (GObject *object) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy (object); G_OBJECT_CLASS (gmyth_scheduler_parent_class)->finalize (object); } @@ -128,16 +135,20 @@ * @return true if connection was success, false if failed. */ gboolean -gmyth_scheduler_connect (GMythScheduler *scheduler) +gmyth_scheduler_connect (GMythScheduler *scheduler, GMythBackendInfo *backend_info) { assert(scheduler); + g_return_val_if_fail (backend_info != NULL, FALSE); + + g_object_ref (backend_info); + scheduler->backend_info = backend_info; if (scheduler->msqlquery == NULL) { g_warning ("[%s] GMythScheduler db initializing", __FUNCTION__); scheduler->msqlquery = gmyth_query_new (); } - if (!gmyth_query_connect(scheduler->msqlquery)) { + if (!gmyth_query_connect(scheduler->msqlquery, scheduler->backend_info)) { g_warning ("[%s] Error while connecting to db", __FUNCTION__); return FALSE; } @@ -156,6 +167,7 @@ assert(scheduler); if (scheduler->msqlquery != NULL) { + gmyth_query_disconnect (scheduler->msqlquery); g_object_unref (scheduler->msqlquery); } @@ -171,8 +183,8 @@ gint gmyth_scheduler_get_schedule_list ( GMythScheduler *scheduler, GList **schedule_list) { - ScheduleInfo *schedule; - MYSQL_RES *msql_res; + ScheduleInfo *schedule; + MYSQL_RES *msql_res; GString *query_str = g_string_new (""); GString *date_time = g_string_new (""); @@ -182,10 +194,10 @@ "SELECT recordid,programid,chanid,starttime,startdate," "endtime,enddate,title,subtitle,description,category FROM record;"); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return -1; - } + if (scheduler->msqlquery == NULL) { + g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); + return -1; + } msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str); if (msql_res == NULL) { @@ -237,8 +249,8 @@ gint gmyth_scheduler_get_recorded_list (GMythScheduler *scheduler, GList **recorded_list) { - RecordedInfo *record; - MYSQL_RES *msql_res; + RecordedInfo *record; + MYSQL_RES *msql_res; GString *query_str = g_string_new (""); GString *date_time = g_string_new (""); @@ -317,29 +329,29 @@ struct tm start_tm; struct tm end_tm; - MYSQL_RES *msql_res; + MYSQL_RES *msql_res; GString *query_str = g_string_new (""); assert(scheduler); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return 0; - } + if (scheduler->msqlquery == NULL) { + g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); + return 0; + } /* manipulating time */ - if(localtime_r(&schedule_info->start_time, &start_tm) == NULL) { + if(localtime_r(&schedule_info->start_time, &start_tm) == NULL) { g_warning ("localtime_r error in libgmyth scheduler!\n"); return FALSE; } - if(localtime_r(&schedule_info->end_time, &end_tm) == NULL) { + if(localtime_r(&schedule_info->end_time, &end_tm) == NULL) { g_warning ("localtime_r error in libgmyth scheduler!\n"); return FALSE; } - //TODO: verify if this funtion realy does what it should do! - g_string_printf (query_str, "REPLACE INTO record " + //TODO: verify if this funtion realy does what it should do! + g_string_printf (query_str, "REPLACE INTO record " "(recordid, type, chanid, starttime, " "startdate, endtime, enddate, title," "profile, recpriority, maxnewest, inactive, " @@ -383,7 +395,7 @@ schedule_info->record_id = get_record_id_from_database(scheduler); /* Notify the backend of changes */ - update_backend(schedule_info->record_id); + update_backend(scheduler, schedule_info->record_id); /* free allocated memory */ mysql_free_result (msql_res); @@ -402,15 +414,15 @@ gmyth_scheduler_delete_schedule (GMythScheduler *scheduler, gint record_id) { - MYSQL_RES *msql_res; + MYSQL_RES *msql_res; GString *query_str = g_string_new (""); assert(scheduler); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return FALSE; - } + if (scheduler->msqlquery == NULL) { + g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); + return FALSE; + } //======================================== g_string_printf (query_str, @@ -423,12 +435,12 @@ return FALSE; } - update_backend(record_id);// Notify the backend of the changes + update_backend(scheduler, record_id);// Notify the backend of the changes mysql_free_result (msql_res); g_string_free(query_str, TRUE); - return TRUE; + return TRUE; } /** Requests the Mysql database in the backend to remove an existing recorded item. @@ -441,7 +453,8 @@ gmyth_scheduler_delete_recorded (GMythScheduler *scheduler, gint record_id) { - MYSQL_RES *msql_res; + MYSQL_RES *msql_res; + GString *query_str = g_string_new (""); assert(scheduler); @@ -457,12 +470,12 @@ msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str); - update_backend(record_id);// Notify the backend of the changes + update_backend(scheduler, record_id);// Notify the backend of the changes mysql_free_result (msql_res); g_string_free(query_str, TRUE); - return TRUE; + return TRUE; } /** Retrieves an existing recorded item information from database. The information @@ -595,15 +608,22 @@ * @param record_id the id of the modified recording. */ static void -update_backend(gint record_id)//fixme: put void and discovery record_id inside +update_backend(GMythScheduler *scheduler, gint record_id)//fixme: put void and discovery record_id inside { + GMythSocket *socket; GMythStringList *strlist = gmyth_string_list_new (); GString *datastr = g_string_new ("RESCHEDULE_RECORDINGS "); g_string_append_printf (datastr, "%d", record_id); gmyth_string_list_append_string (strlist, datastr); - gmyth_context_send_receive_stringlist (strlist); + socket = gmyth_socket_new (); + if (gmyth_socket_connect (socket, scheduler->backend_info->hostname, + scheduler->backend_info->port)) { + gmyth_socket_sendreceive_stringlist (socket, strlist); + } else { + g_warning ("[%s] Connection to backend failed!", __FUNCTION__); + } g_string_free(datastr, TRUE); g_object_unref(strlist); diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_scheduler.h --- a/gmyth/src/gmyth_scheduler.h Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_scheduler.h Mon Nov 27 21:20:57 2006 +0000 @@ -34,6 +34,7 @@ #include "gmyth_common.h" #include "gmyth_query.h" +#include "gmyth_backendinfo.h" G_BEGIN_DECLS @@ -93,6 +94,7 @@ GString *searchForWhat; GMythQuery *msqlquery; + GMythBackendInfo *backend_info; }; typedef struct { @@ -131,7 +133,7 @@ GType gmyth_scheduler_get_type (void); GMythScheduler* gmyth_scheduler_new (); -gboolean gmyth_scheduler_connect (GMythScheduler *scheduler); +gboolean gmyth_scheduler_connect (GMythScheduler *scheduler, GMythBackendInfo *backend_info); gboolean gmyth_scheduler_disconnect (GMythScheduler *scheduler); gint gmyth_scheduler_get_schedule_list (GMythScheduler *scheduler, diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_settings.c --- a/gmyth/src/gmyth_settings.c Mon Nov 27 21:20:17 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,417 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_settings.c - * - * @brief

This component contains functions acessing and modifying - * user and program settings. - * - * The standard settings file is created in the user home folder, in the - * file ~/.gmyth/settings.dat. - * - * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. - * @author Alexsandro Jose Virginio dos Santos - * - *//* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "gmyth_settings.h" - -#include -#include -#include -#include - -#include -#include -#include - -#define GMYTH_SETTINGS_FILE_NAME "settings.dat" -#define GMYTH_SETTINGS_DIR ".gmyth" - -static void gmyth_settings_class_init (GMythSettingsClass *klass); -static void gmyth_settings_init (GMythSettings *object); - -static void gmyth_settings_dispose (GObject *object); -static void gmyth_settings_finalize (GObject *object); - -static void fill_settings_data(GMythSettings *gmyth_settings, char* line); - -G_DEFINE_TYPE(GMythSettings, gmyth_settings, G_TYPE_OBJECT) - -static void -gmyth_settings_class_init (GMythSettingsClass *klass) -{ - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *) klass; - - gobject_class->dispose = gmyth_settings_dispose; - gobject_class->finalize = gmyth_settings_finalize; -} - -static void -gmyth_settings_init (GMythSettings *gmyth_settings) -{ - - gmyth_settings->settings_file = NULL; - - gmyth_settings->backend_hostname = g_string_new("127.0.0.1"); - gmyth_settings->backend_port = 6543; - gmyth_settings->mysql_dbname = g_string_new("mythconverg"); - gmyth_settings->mysql_username = g_string_new("mythtv"); - gmyth_settings->mysql_password = g_string_new("mythtv"); - gmyth_settings->database_type = g_string_new("mysql"); - -} - - -static void -gmyth_settings_dispose (GObject *object) -{ - GMythSettings *gmyth_settings = GMYTH_SETTINGS(object); - - if ( gmyth_settings->backend_hostname != NULL ) - g_string_free( gmyth_settings->backend_hostname, TRUE ); - if ( gmyth_settings->mysql_dbname != NULL ) - g_string_free( gmyth_settings->mysql_dbname, TRUE ); - if ( gmyth_settings->mysql_username != NULL ) - g_string_free( gmyth_settings->mysql_username, TRUE ); - if ( gmyth_settings->mysql_password != NULL ) - g_string_free( gmyth_settings->mysql_password, TRUE ); - if ( gmyth_settings->database_type != NULL ) - g_string_free( gmyth_settings->database_type, TRUE ); - - G_OBJECT_CLASS (gmyth_settings_parent_class)->dispose (object); -} - -static void -gmyth_settings_finalize (GObject *object) -{ - g_signal_handlers_destroy (object); - - G_OBJECT_CLASS (gmyth_settings_parent_class)->finalize (object); -} - -/** Creates a new instance of GMythSettings. - * - * @return a new instance of GMythSettings. - */ -GMythSettings* -gmyth_settings_new (void) -{ - GMythSettings *gmyth_settings = GMYTH_SETTINGS (g_object_new(GMYTH_SETTINGS_TYPE, NULL)); - - return gmyth_settings; -} - -static gboolean -gmyth_settings_ensure_dir_exists (const gchar *dir) -{ - - g_debug ("[%s] \tdir = %s\n", __FUNCTION__, dir); - - if (g_file_test (dir, G_FILE_TEST_IS_DIR) == FALSE) { - if (g_file_test (dir, G_FILE_TEST_EXISTS) == TRUE) { - g_warning ("%s exists, please move it out of the way.", dir); - return FALSE; - } - - if (mkdir (dir, 488) != 0) { - g_warning ("Failed to create directory %s.", dir); - return FALSE; - } - } - - return TRUE; -} - -static gboolean -gmyth_settings_ensure_file_exists (const gchar *file_name) { - - int file = 0; - - if ( g_file_test( file_name, G_FILE_TEST_EXISTS ) == FALSE ) { - g_debug ( "\n\tCreating %s file...\n", file_name ); - file = creat( file_name, S_IRWXU | S_IRWXO | S_IRWXG ); - - if ( close( file ) == -1 ) - return FALSE; - } - - return TRUE; -} - -/** Loads the GMyth settings from the given file. - * - * @param gmyth_settings the GMythSettings instance. - * @param filename The desired file to be opened. - * @return TRUE if success, FALSE if error. - */ -gboolean -gmyth_settings_load_from_file (GMythSettings *gmyth_settings, GString *filename) -{ - FILE *file_desc; - char line[100]; - - g_debug ("[%s] Loading GMyth settings file: %s", __FUNCTION__, filename->str); - - file_desc = fopen(filename->str, "r"); - if( file_desc == NULL) { - g_warning ("[%s] Settings file %s could not be opened", __FUNCTION__, filename->str); - return FALSE; - } - - gmyth_settings->settings_file = g_string_new (filename->str); - - while(fgets(line, 100, file_desc)) { - int i; - - /* Removes the new line characters from the end of line */ - for ( i = strlen(line)-1; i >= 0; i--) { - if ( !g_ascii_iscntrl (line[i]) ) { - line[i+1] = '\0'; - break; - } - } - - fill_settings_data(gmyth_settings, line); - } - - fclose (file_desc); - - return TRUE; -} - -/** Loads the GMyth settings from the standard settings file - * (~/.gmyth/settings.dat). - * - * @param gmyth_settings the GMythSettings instance. - * @return TRUE if success, FALSE if error. - */ -gboolean -gmyth_settings_load (GMythSettings *gmyth_settings) -{ - GString* file_full_path = g_string_new( g_build_filename( g_get_home_dir(), - GMYTH_SETTINGS_DIR, GMYTH_SETTINGS_FILE_NAME, NULL ) ); - - gmyth_settings->settings_file = file_full_path; - - gmyth_settings_ensure_dir_exists( g_build_filename( g_get_home_dir(), GMYTH_SETTINGS_DIR, NULL ) ); - - // Verifies if the file already exist - if ( g_file_test( file_full_path->str, G_FILE_TEST_EXISTS ) == FALSE ) { - g_debug ("[%s] Settings file does not exist. A new one will be created.\n", __FUNCTION__); - - if ( gmyth_settings_ensure_file_exists( file_full_path->str ) == FALSE ) - return FALSE; - - // Creates the file with default values (see _init function) - return gmyth_settings_save (gmyth_settings); - - } else { - g_debug ("[%s] Opening settings from file %s", __FUNCTION__, file_full_path->str); - - return gmyth_settings_load_from_file (gmyth_settings, file_full_path); - } -} - -/** Saves the current gmyth_settings to the settings file related to the - * given instance. - * - * @param gmyth_settings the GMythSettings instance. - * @return TRUE if success, FALSE if error. - */ -gboolean -gmyth_settings_save (GMythSettings *gmyth_settings) -{ - FILE *file_desc; - - if (gmyth_settings->settings_file == NULL) { - g_warning ("[%s] Settings were not loaded from file, could not save!", __FUNCTION__); - } - - file_desc = fopen(gmyth_settings->settings_file->str, "w"); - if( file_desc == NULL) { - g_warning ("GMYTH_SETTINGS: settings file %s not found", gmyth_settings->settings_file->str); - return FALSE; - } - - g_fprintf(file_desc, "#Maemo-Myth Settings\n"); - - g_fprintf(file_desc, "#General settings related with mythtv database\n"); - g_fprintf(file_desc, "dbname=%s\n", gmyth_settings->mysql_dbname->str); - g_fprintf(file_desc, "username=%s\n", gmyth_settings->mysql_username->str); - g_fprintf(file_desc, "password=%s\n", gmyth_settings->mysql_password->str); - - g_fprintf(file_desc, "\n#General settings related with mythtv backend\n"); - g_fprintf(file_desc, "hostname=%s\n", gmyth_settings->backend_hostname->str); - g_fprintf(file_desc, "backend_port=%d\n", gmyth_settings->backend_port); - - fclose (file_desc); - - g_debug ("[%s] Settings file saved", __FUNCTION__); - return TRUE; -} - -/** Gets the backend hostname from the settings. - * - * @param gmyth_settings the GMythSettings instance. - * @return The loaded backend hostname, or the default value "127.0.0.1" if settings - * file was not opened. - */ -GString* -gmyth_settings_get_backend_hostname (GMythSettings *gmyth_settings) -{ - return g_string_new (gmyth_settings->backend_hostname->str); -} - -/** Sets the backend hostname to the settings. - * - * @param gmyth_settings the GMythSettings instance. - * @param new_hostname The new hostname. - */ -void -gmyth_settings_set_backend_hostname (GMythSettings *gmyth_settings, GString *new_hostname) -{ - g_string_assign (gmyth_settings->backend_hostname, new_hostname->str); -} - -/** Gets the user name to connect to backend database. - * - * @param gmyth_settings the GMythSettings instance. - * @return The loaded user name, or the default value "mythtv" if settings - * file was not opened. - */ -GString* -gmyth_settings_get_username (GMythSettings *gmyth_settings) -{ - return g_string_new (gmyth_settings->mysql_username->str); -} - -/** Sets the username to connect to backend database. - * - * @param gmyth_settings the GMythSettings instance. - * @param new_username The new username. - */ -void -gmyth_settings_set_username (GMythSettings *gmyth_settings, GString *new_username) -{ - g_string_assign (gmyth_settings->mysql_username, new_username->str); -} - -/** Gets the database password from the settings file. - * - * @param gmyth_settings the GMythSettings instance. - * @return The loaded password, or the default value "mythtv" if settings - * file was not opened. - */ -GString* -gmyth_settings_get_password (GMythSettings *gmyth_settings) -{ - return g_string_new (gmyth_settings->mysql_password->str); -} - -/** Sets the database password. - * - * @param gmyth_settings the GMythSettings instance. - * @param new_password The new password. - */ - -void -gmyth_settings_set_password (GMythSettings *gmyth_settings, GString *new_password) -{ - g_string_assign (gmyth_settings->mysql_password, new_password->str); -} - -/** Gets the backend database name from the settings file. - * - * @param gmyth_settings the GMythSettings instance. - * @return The loaded database name, or the default value "mythconverg" if settings - * file was not opened. - */ -GString* -gmyth_settings_get_dbname (GMythSettings *gmyth_settings) -{ - return g_string_new (gmyth_settings->mysql_dbname->str); -} - -/** Sets the Mythtv database name to the settings. - * - * @param gmyth_settings the GMythSettings instance. - * @param new_dbname The new database name. - */ - -void -gmyth_settings_set_dbname (GMythSettings *gmyth_settings, GString *new_dbname) -{ - g_string_assign (gmyth_settings->mysql_dbname, new_dbname->str); -} - -/** Gets the backend port from the settings. - * - * @param gmyth_settings the GMythSettings instance. - * @return The loaded backend port, or the default value "6543" if settings - * file was not opened. - */ -int -gmyth_settings_get_backend_port (GMythSettings *gmyth_settings) -{ - return gmyth_settings->backend_port; -} - -/** Sets the backend port. - * - * @param gmyth_settings the GMythSettings instance. - * @param new_port The new port. - */ -void -gmyth_settings_set_backend_port (GMythSettings *gmyth_settings, gint new_port) -{ - gmyth_settings->backend_port = new_port; -} - - -static void -fill_settings_data(GMythSettings *gmyth_settings, char* line) -{ - gchar** str_splited; - - GString *gstr_splited; - gstr_splited = g_string_new(""); - str_splited = g_strsplit (line, "=", -1); - - if(!(strcmp(str_splited[0], "hostname"))){ - g_string_assign(gstr_splited, str_splited[1]); - gmyth_settings_set_backend_hostname(gmyth_settings, gstr_splited); - } - else if (!(strcmp(str_splited[0], "dbname"))){ - g_string_assign(gstr_splited, str_splited[1]); - gmyth_settings_set_dbname(gmyth_settings, gstr_splited); - } - else if (!(strcmp(str_splited[0], "username"))){ - g_string_assign(gstr_splited, str_splited[1]); - gmyth_settings_set_username(gmyth_settings, gstr_splited); - } - else if (!(strcmp(str_splited[0], "password"))){ - g_string_assign(gstr_splited, str_splited[1]); - gmyth_settings_set_password(gmyth_settings, gstr_splited); - } - else if (!(strcmp(str_splited[0], "backend_port"))){ - gmyth_settings_set_backend_port(gmyth_settings, atoi(str_splited[1])); - } -} diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_settings.h --- a/gmyth/src/gmyth_settings.h Mon Nov 27 21:20:17 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_settings.h - * - * @brief

This component contains functions acessing and modifying - * user and program settings. - * - * The standard settings file is created in the user home folder, in the - * file ~/.gmyth/settings.dat. - * - * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. - * @author Alexsandro Jose Virginio dos Santos - * - *//* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __GMYTH_SETTINGS_H__ -#define __GMYTH_SETTINGS_H__ - -#include - -G_BEGIN_DECLS - -#define GMYTH_SETTINGS_TYPE (gmyth_settings_get_type ()) -#define GMYTH_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SETTINGS_TYPE, GMythSettings)) -#define GMYTH_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SETTINGS_TYPE, GMythSettingsClass)) -#define IS_GMYTH_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SETTINGS_TYPE)) -#define IS_GMYTH_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SETTINGS_TYPE)) -#define GMYTH_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SETTINGS_TYPE, GMythSettingsClass)) - - -typedef struct _GMythSettings GMythSettings; -typedef struct _GMythSettingsClass GMythSettingsClass; - -struct _GMythSettingsClass -{ - GObjectClass parent_class; - - /* callbacks */ - /* no one for now */ -}; - -struct _GMythSettings -{ - GObject parent; - - GString *settings_file; - - GString *backend_hostname; - int backend_port; - - GString *mysql_dbname; - GString *mysql_username; - GString *mysql_password; - // FIXME: Why do we need database_type? Do we intend to support other dbs? - GString *database_type; -}; - - -GType gmyth_settings_get_type (void); - -GMythSettings* gmyth_settings_new (void); - -gboolean gmyth_settings_load_from_file (GMythSettings *gmyth_settings, - GString *filename); -gboolean gmyth_settings_load (GMythSettings *msettings); -gboolean gmyth_settings_save (GMythSettings *gmyth_settings); - -GString* gmyth_settings_get_backend_hostname (GMythSettings *gmyth_settings); -void gmyth_settings_set_backend_hostname (GMythSettings *gmyth_settings, - GString *new_hostname); - -GString* gmyth_settings_get_username (GMythSettings *gmyth_settings); -void gmyth_settings_set_username (GMythSettings *gmyth_settings, - GString *new_username); - -GString* gmyth_settings_get_password (GMythSettings *gmyth_settings); -void gmyth_settings_set_password (GMythSettings *gmyth_settings, - GString *new_password); - -GString* gmyth_settings_get_dbname (GMythSettings *gmyth_settings); -void gmyth_settings_set_dbname (GMythSettings *gmyth_settings, - GString *new_dbname); - -int gmyth_settings_get_backend_port (GMythSettings *gmyth_settings); -void gmyth_settings_set_backend_port (GMythSettings *gmyth_settings, - gint new_port); - -G_END_DECLS - -#endif /* __GMYTH_SETTINGS_H__ */ diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_socket.c Mon Nov 27 21:20:57 2006 +0000 @@ -58,7 +58,6 @@ #include "gmyth_socket.h" #include "gmyth_stringlist.h" -#include "gmyth_context.h" #include "gmyth_uri.h" #define BUFLEN 512 @@ -68,6 +67,9 @@ /* max number of iterations */ #define MYTHTV_MAX_VERSION_CHECKS 40 +// FIXME: put this in the right place +#define MYTHTV_VERSION_DEFAULT 30 + static GStaticMutex mutex = G_STATIC_MUTEX_INIT; static void gmyth_socket_class_init (GMythSocketClass *klass); diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_socket.h --- a/gmyth/src/gmyth_socket.h Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_socket.h Mon Nov 27 21:20:57 2006 +0000 @@ -82,7 +82,7 @@ GType gmyth_socket_get_type (void); -GMythSocket * gmyth_socket_new (void); +GMythSocket * gmyth_socket_new ( ); GIOChannel * gmyth_socket_get_io_channel (GMythSocket *gmyth_socket ); diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_tvchain.c --- a/gmyth/src/gmyth_tvchain.c Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_tvchain.c Mon Nov 27 21:20:57 2006 +0000 @@ -30,6 +30,7 @@ #include #include #include +#include #include "gmyth_epg.h" #include "gmyth_tvchain.h" @@ -70,32 +71,38 @@ static void gmyth_tvchain_dispose (GObject *object) { - GMythTVChain *tvchain = GMYTH_TVCHAIN(object); + GMythTVChain *tvchain = GMYTH_TVCHAIN(object); - if ( tvchain->tvchain_id != NULL ) { - g_string_free( tvchain->tvchain_id, TRUE ); - tvchain->tvchain_id = NULL; - } + if ( tvchain->tvchain_id != NULL ) { + g_string_free( tvchain->tvchain_id, TRUE ); + tvchain->tvchain_id = NULL; + } - if ( tvchain->tvchain_list != NULL ) { - g_list_free( tvchain->tvchain_list ); - tvchain->tvchain_list = NULL; - } + if ( tvchain->tvchain_list != NULL ) { + g_list_free( tvchain->tvchain_list ); + tvchain->tvchain_list = NULL; + } - if ( tvchain->cur_chanid != NULL ) { - g_string_free( tvchain->cur_chanid, TRUE ); - tvchain->cur_chanid = NULL; - } + if ( tvchain->cur_chanid != NULL ) { + g_string_free( tvchain->cur_chanid, TRUE ); + tvchain->cur_chanid = NULL; + } - G_OBJECT_CLASS (gmyth_tvchain_parent_class)->dispose (object); + if ( tvchain->backend_info) { + g_object_unref (tvchain->backend_info); + tvchain->backend_info = NULL; + } + + + G_OBJECT_CLASS (gmyth_tvchain_parent_class)->dispose (object); } static void gmyth_tvchain_finalize (GObject *object) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy (object); - G_OBJECT_CLASS (gmyth_tvchain_parent_class)->finalize (object); + G_OBJECT_CLASS (gmyth_tvchain_parent_class)->finalize (object); } /** Initializes the tvchain and generates the tvchain id. @@ -103,27 +110,38 @@ * @param tvchain The GMythTVChain instance. * @param hostname The local hostname used to generate the tvchain id. */ -void -gmyth_tvchain_initialize (GMythTVChain *tvchain, GString *hostname) +gboolean +gmyth_tvchain_initialize (GMythTVChain *tvchain, GMythBackendInfo *backend_info) { - if (tvchain->tvchain_id == NULL) { - GString *isodate; - time_t cur_time; + char *hostname; - time(&cur_time); - isodate = gmyth_util_time_to_isoformat (cur_time); + assert (tvchain); + g_return_val_if_fail (backend_info != NULL, FALSE); - tvchain->tvchain_id = g_string_sized_new(7 + hostname->len + isodate->len); - g_string_printf(tvchain->tvchain_id, - "live-%s-%s", hostname->str, isodate->str); + g_object_ref (backend_info); + tvchain->backend_info = backend_info; - g_print("tv_chain_id: %s\n", tvchain->tvchain_id->str); + hostname = gmyth_backend_info_get_hostname (backend_info); + + if (tvchain->tvchain_id == NULL) { + GString *isodate; + time_t cur_time; - g_string_free(isodate, TRUE); + time(&cur_time); + isodate = gmyth_util_time_to_isoformat (cur_time); - } else { - g_warning ("[%s] TVchain already initialized", __FUNCTION__); - } + tvchain->tvchain_id = g_string_sized_new (7 + strlen (hostname) + isodate->len); + g_string_printf(tvchain->tvchain_id, + "live-%s-%s", hostname, isodate->str); + + g_debug ("[%s] tv_chain_id: %s", __FUNCTION__, tvchain->tvchain_id->str); + + g_string_free(isodate, TRUE); + } else { + g_warning ("[%s] TVchain already initialized", __FUNCTION__); + } + + return TRUE; } /** Gets the tvchain id. @@ -168,7 +186,7 @@ // TODO: Reuse gmyth_query already connected from context gmyth_query = gmyth_query_new (); - if (!gmyth_query_connect (gmyth_query)) { + if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) { g_warning ("[%s] Could not connect to db", __FUNCTION__); g_static_mutex_unlock( &mutex ); @@ -349,7 +367,7 @@ GMythScheduler *scheduler = gmyth_scheduler_new (); - gmyth_scheduler_connect( scheduler ); + gmyth_scheduler_connect( scheduler, tvchain->backend_info ); proginfo = gmyth_scheduler_get_recorded (scheduler, entry->chanid, entry->starttime); gmyth_scheduler_disconnect( scheduler ); diff -r e3cedfae0f2e -r b90cf50ca3dc gmyth/src/gmyth_tvchain.h --- a/gmyth/src/gmyth_tvchain.h Mon Nov 27 21:20:17 2006 +0000 +++ b/gmyth/src/gmyth_tvchain.h Mon Nov 27 21:20:57 2006 +0000 @@ -33,6 +33,7 @@ #include #include "gmyth_common.h" +#include "gmyth_backendinfo.h" G_BEGIN_DECLS @@ -81,13 +82,15 @@ time_t cur_startts; GString *cur_chanid; int cur_pos; + + GMythBackendInfo *backend_info; }; GType gmyth_tvchain_get_type (void); -void gmyth_tvchain_initialize (GMythTVChain *tvchain, - GString *hostname); +gboolean gmyth_tvchain_initialize (GMythTVChain *tvchain, + GMythBackendInfo *backend_info); gboolean gmyth_tvchain_reload_all (GMythTVChain *tvchain); GString* gmyth_tvchain_get_id (GMythTVChain *tvchain); int gmyth_tvchain_program_is_at (GMythTVChain *tvchain,