# HG changeset patch # User melunko # Date 1170190355 0 # Node ID f8d246310650eabd2b8cc1c36b8555d67f603004 # Parent 8587b24643e874920f316159acbcd42240d194b3 [svn r314] A lot of bug fixed. Test recordings program added. diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_debug.h --- a/gmyth/src/gmyth_debug.h Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_debug.h Tue Jan 30 20:52:35 2007 +0000 @@ -33,11 +33,11 @@ G_BEGIN_DECLS -#ifdef GMYTH_USE_DEBUG +//#ifdef GMYTH_USE_DEBUG #define gmyth_debug(...) gmyth_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__) -#else -#define gmyth_debug(...) -#endif +//#else +//#define gmyth_debug(...) +//#endif void gmyth_debug_real (const char *func, const char *file, diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_epg.c --- a/gmyth/src/gmyth_epg.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_epg.c Tue Jan 30 20:52:35 2007 +0000 @@ -189,13 +189,19 @@ gmyth_epg_get_program_list (GMythEPG *gmyth_epg, GList **proglist, const gint chan_num, GTimeVal *starttime, GTimeVal *endtime) { +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); + gchar *startts = gmyth_util_time_to_string_from_time_val(starttime); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); gchar *endts = gmyth_util_time_to_string_from_time_val(endtime); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); MYSQL_ROW row; GString *querystr; +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); assert(gmyth_epg); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); querystr = g_string_new( "SELECT DISTINCT program.chanid, program.starttime, program.endtime, " " program.title, program.subtitle, program.description, " @@ -214,6 +220,7 @@ " program.starttime = oldrecstatus.starttime " ); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); g_string_append_printf (querystr, "WHERE program.chanid = %d " " AND program.endtime >= '%s' " @@ -221,34 +228,51 @@ " AND program.manualid = 0 ", chan_num, startts, endts); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if (!g_strrstr(querystr->str, " GROUP BY ")) querystr = g_string_append(querystr, " GROUP BY program.starttime, channel.channum, " " channel.callsign, program.title "); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if (!g_strrstr(querystr->str, " LIMIT ")) querystr = g_string_append(querystr, " LIMIT 1000 "); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); MYSQL_RES *res_set = gmyth_query_process_statement(gmyth_epg->sqlquery, querystr->str); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if (res_set == NULL) { g_warning ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__); return -1; } +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); (*proglist) = NULL; while ((row = mysql_fetch_row (res_set)) != NULL) { +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); GMythProgramInfo *p = gmyth_program_info_new (); p->chanid = g_string_new (row[0]); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); p->startts = gmyth_util_string_to_time_val (row[1]); p->endts = gmyth_util_string_to_time_val (row[2]); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); - p->recstartts = p->startts; - p->recendts = p->endts; - p->lastmodified = p->startts; + p->recstartts = g_new0 (GTimeVal, 1); + p->recstartts->tv_sec = p->startts->tv_sec; + p->recstartts->tv_usec = p->startts->tv_usec; + + p->recendts = g_new0 (GTimeVal, 1); + p->recendts->tv_sec = p->endts->tv_sec; + p->recendts->tv_usec = p->endts->tv_usec; + + p->lastmodified = g_new0 (GTimeVal, 1); + p->lastmodified->tv_sec = p->startts->tv_sec; + p->lastmodified->tv_usec = p->startts->tv_usec; +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); p->title = g_string_new (row[3]); p->subtitle = g_string_new (row[4]); @@ -265,6 +289,7 @@ p->year = g_string_new (row[15]); p->stars = g_ascii_strtod(row[16], NULL); +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if (!row[17] || !strcmp(row[17], "")) { p->originalAirDate = 0; p->hasAirDate = FALSE; @@ -273,6 +298,7 @@ p->hasAirDate = TRUE; } +printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); p->catType = g_string_new (row[18]); *proglist = g_list_append((*proglist), p); diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Tue Jan 30 20:52:35 2007 +0000 @@ -62,7 +62,7 @@ #define GMYTHTV_RETRIES -1 #define GMYTHTV_FILE_SIZE 0 -#define GMYTHTV_BUFFER_SIZE 8*1024 +#define GMYTHTV_BUFFER_SIZE 64*1024 #define GMYTHTV_VERSION 30 diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_programinfo.c --- a/gmyth/src/gmyth_programinfo.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_programinfo.c Tue Jan 30 20:52:35 2007 +0000 @@ -105,19 +105,22 @@ gmyth_program_info_dispose (GObject *object) { GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object); - + + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->chanid != NULL ) { g_string_free( gmyth_program_info->chanid, TRUE ); gmyth_program_info->chanid = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The program start time. */ if ( gmyth_program_info->startts != NULL ) { g_free( gmyth_program_info->startts); gmyth_program_info->startts = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The program end time. */ if ( gmyth_program_info->endts != NULL ) @@ -125,6 +128,7 @@ g_free( gmyth_program_info->endts ); gmyth_program_info->endts = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The recording schedule start time. */ if ( gmyth_program_info->recstartts != NULL ) @@ -133,12 +137,14 @@ gmyth_program_info->recstartts = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The recording schedule end time */ if ( gmyth_program_info->recendts != NULL ) { g_free(gmyth_program_info->recendts); gmyth_program_info->recendts = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The program title. */ if (gmyth_program_info->title != NULL ) @@ -146,6 +152,7 @@ g_string_free(gmyth_program_info->title, TRUE); gmyth_program_info->title = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The program subtitle. */ if (gmyth_program_info->subtitle != NULL ) @@ -153,12 +160,14 @@ g_string_free(gmyth_program_info->subtitle, TRUE ); gmyth_program_info->subtitle = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The program description. */ if ( gmyth_program_info->description != NULL ) { g_string_free( gmyth_program_info->description, TRUE ); gmyth_program_info->description = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The program category. */ if ( gmyth_program_info->category != NULL ) @@ -166,35 +175,41 @@ g_string_free( gmyth_program_info->category, TRUE ); gmyth_program_info->category = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->chanstr != NULL ) { g_string_free( gmyth_program_info->chanstr, TRUE ); gmyth_program_info->chanstr = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->chansign != NULL ) { g_string_free( gmyth_program_info->chansign, TRUE ); gmyth_program_info->chansign = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The associated channel name. */ if ( gmyth_program_info->channame != NULL ) { g_string_free( gmyth_program_info->channame, TRUE ); gmyth_program_info->channame = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->chanOutputFilters != NULL ) { g_string_free( gmyth_program_info->chanOutputFilters, TRUE ); gmyth_program_info->chanOutputFilters = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->seriesid != NULL ) { - g_string_free( gmyth_program_info->chanOutputFilters, TRUE ); + g_string_free( gmyth_program_info->seriesid, TRUE ); gmyth_program_info->chanOutputFilters = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The program unique id. */ if ( gmyth_program_info->programid != NULL ) { @@ -202,12 +217,14 @@ gmyth_program_info->programid = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->catType != NULL ) { g_string_free( gmyth_program_info->catType, TRUE ); gmyth_program_info->catType = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->sortTitle != NULL ) { @@ -215,6 +232,7 @@ gmyth_program_info->sortTitle = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->year != NULL ) { @@ -222,29 +240,35 @@ gmyth_program_info->year = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->originalAirDate != NULL ) { g_free( gmyth_program_info->originalAirDate); gmyth_program_info->originalAirDate = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->lastmodified != NULL ) { g_free( gmyth_program_info->lastmodified ); gmyth_program_info->lastmodified = NULL; + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if (gmyth_program_info->lastInUseTime != NULL) { g_free( gmyth_program_info->lastInUseTime ); gmyth_program_info->lastInUseTime = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->schedulerid != NULL ) { g_string_free( gmyth_program_info->schedulerid, TRUE ); gmyth_program_info->schedulerid = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->recgroup != NULL ) { @@ -256,6 +280,7 @@ g_string_free( gmyth_program_info->playgroup, TRUE ); gmyth_program_info->playgroup = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); /** The file name of the recorded program.*/ if ( gmyth_program_info->pathname != NULL) @@ -263,11 +288,13 @@ g_string_free( gmyth_program_info->pathname, TRUE ); gmyth_program_info->pathname = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); if ( gmyth_program_info->hostname != NULL ) { g_string_free( gmyth_program_info->hostname, TRUE ); gmyth_program_info->hostname = NULL; } + printf ("XXXX %s %d\n", __FUNCTION__, __LINE__); G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object); } diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_query.c --- a/gmyth/src/gmyth_query.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_query.c Tue Jan 30 20:52:35 2007 +0000 @@ -111,7 +111,6 @@ { assert(gmyth_query); g_return_val_if_fail (gmyth_query->conn != NULL, FALSE); -printf ("XXXXXXXXX timeout %d\n", timeout); if (timeout != 0) { /* sets connection timeout */ mysql_options (gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT, (gchar*) &timeout); @@ -156,7 +155,7 @@ return FALSE; } - gmyth_debug ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "\ + g_debug ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "\ "password = %s, db name = %s)", __FUNCTION__, gmyth_query->backend_info->hostname, gmyth_query->backend_info->username, gmyth_query->backend_info->password, gmyth_query->backend_info->db_name ); @@ -175,7 +174,7 @@ assert(gmyth_query); /* TODO: Check how to return error */ - gmyth_debug ("[%s] Closing gmyth_query->conn", __FUNCTION__); + g_debug ("[%s] Closing gmyth_query->conn", __FUNCTION__); mysql_close (gmyth_query->conn); return TRUE; @@ -214,7 +213,7 @@ assert(gmyth_query); - gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str); + g_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str); if (gmyth_query == NULL) return NULL; @@ -230,7 +229,7 @@ if (res_set) { return res_set; } else if (mysql_field_count (gmyth_query->conn) == 0) { - gmyth_debug ("%lu rows affected\n", + g_debug ("%lu rows affected\n", (unsigned long) mysql_affected_rows (gmyth_query->conn)); } else { gmyth_query_print_error (gmyth_query->conn, "Could not retrieve result set"); diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_scheduler.c Tue Jan 30 20:52:35 2007 +0000 @@ -266,7 +266,6 @@ RecordedInfo *record; MYSQL_RES *msql_res; GString *query_str = g_string_new (""); - gchar *date_time = NULL; assert(scheduler); @@ -274,42 +273,29 @@ "SELECT recordid,programid,chanid,starttime,progstart," "endtime,progend,title,subtitle,description,category,filesize,basename FROM recorded WHERE recgroup != 'LiveTV'"); - 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) { g_warning ("DB retrieval of recording list failed"); return -1; - } else { + } else { MYSQL_ROW row; *recorded_list = NULL; while((row = mysql_fetch_row (msql_res))!=NULL){ - record = g_new0(RecordedInfo, 1); + record = g_new0(RecordedInfo, 1); record->record_id = (guint) g_ascii_strtoull (row[0], NULL, 10); record->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10); record->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10); - /* the db field time already contains the date. therefore - * we are not using the date field */ - /* generate a time_t from a time and a date db field */ - /* g_string_printf (date_time, "%s %s", row[4], row[3]); */ - g_sprintf (date_time, "%sT%s", row[4], row[3]); - - record->start_time = gmyth_util_string_to_time_val (date_time); - - /* the db field time already contains the date. therefore - * we are not using the date field */ - /* generate a time_t from a time and a date db field */ - /* g_string_printf (date_time, "%s %s", row[6], row[5]); */ - g_sprintf (date_time, "%sT%s", row[6], row[5]); - - record->end_time = gmyth_util_string_to_time_val (date_time); + record->start_time = gmyth_util_string_to_time_val (row[3]); + record->end_time = gmyth_util_string_to_time_val (row[5]); record->title = g_string_new (row[7]); record->subtitle = g_string_new (row[8]); @@ -324,7 +310,6 @@ mysql_free_result (msql_res); g_string_free(query_str, TRUE); - g_free(date_time); return (*recorded_list == NULL) ? 0 : g_list_length (*recorded_list); } @@ -339,7 +324,7 @@ */ gboolean gmyth_scheduler_add_schedule (GMythScheduler *scheduler, - ScheduleInfo *schedule_info) + ScheduleInfo *schedule_info) { //GTimeVal *start_tm; //GTimeVal *end_tm; @@ -534,10 +519,15 @@ proginfo = gmyth_program_info_new(); proginfo->chanid = g_string_new (msql_row[0]); + printf ("xxxxxx %s %d\n", __FUNCTION__, __LINE__); proginfo->startts = gmyth_util_string_to_time_val (msql_row[23]); + printf ("xxxxxx %s %d\n", __FUNCTION__, __LINE__); proginfo->endts = gmyth_util_string_to_time_val (msql_row[24]); + printf ("xxxxxx %s %d\n", __FUNCTION__, __LINE__); proginfo->recstartts = gmyth_util_string_to_time_val (msql_row[1]); + printf ("xxxxxx %s %d\n", __FUNCTION__, __LINE__); proginfo->recendts = gmyth_util_string_to_time_val (msql_row[2]); + printf ("xxxxxx %s %d\n", __FUNCTION__, __LINE__); proginfo->title = g_string_new (msql_row[3]); proginfo->subtitle = g_string_new (msql_row[4]); proginfo->description = g_string_new (msql_row[5]); @@ -551,6 +541,7 @@ proginfo->programid = g_string_new (msql_row[12]); proginfo->filesize = g_ascii_strtoull (msql_row[13], NULL, 10); + printf ("xxxxxx %s %d\n", __FUNCTION__, __LINE__); proginfo->lastmodified = gmyth_util_string_to_time_val (msql_row[14]); proginfo->stars = g_ascii_strtod (msql_row[15], NULL); @@ -560,6 +551,7 @@ proginfo->originalAirDate = 0; proginfo->hasAirDate = FALSE; } else { + printf ("xxxxxx %s %d\n", __FUNCTION__, __LINE__); proginfo->originalAirDate = gmyth_util_string_to_time_val (msql_row[17]); proginfo->hasAirDate = TRUE; } @@ -581,7 +573,7 @@ } } - mysql_free_result (msql_res); + mysql_free_result (msql_res); g_string_free(query_str, TRUE); g_free(time_str); diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_socket.c Tue Jan 30 20:52:35 2007 +0000 @@ -53,18 +53,14 @@ #include #include -#if defined(HAVE_IFADDRS_H) - #include -#else - #include -#endif +#include #include "gmyth_stringlist.h" #include "gmyth_uri.h" #include "gmyth_debug.h" -#define BUFLEN 512 -#define MYTH_SEPARATOR "[]:[]" +#define BUFLEN 512 +#define MYTH_SEPARATOR "[]:[]" #define MYTH_PROTOCOL_FIELD_SIZE 8 /* max number of iterations */ @@ -117,6 +113,7 @@ gint errorn = EADDRNOTAVAIL; g_return_val_if_fail ( addr != NULL, -1 ); + g_debug ("Calling %s\n", __FUNCTION__); /* hints = g_malloc0 ( sizeof(struct addrinfo) ); */ memset ( &hints, 0, sizeof(struct addrinfo) ); @@ -127,7 +124,9 @@ if ( port != -1 ) portStr = g_strdup_printf ( "%d", port ); else - portStr = NULL; + portStr = NULL; + + gmyth_debug ("Getting name resolution for: %s, %d\n", addr, port); if ( ( errorn = getaddrinfo(addr, portStr, &hints, addrInfo) ) != 0 ) { g_printerr( "[%s] Socket ERROR: %s\n", __FUNCTION__, gai_strerror(errorn) ); @@ -149,65 +148,6 @@ } -#if defined(HAVE_IFADDRS_H) - -/** Gets the list of all local network interfaces. - * - * @param current_connections A list with all the network interfaces are valid, - * to be applied just like a filter. - * @return List with all the local net interfaces. - */ -static GList * -gmyth_socket_get_local_addrs( GList *current_connections ) { - - GList *local_addrs = NULL; - - struct ifaddrs *ifaddr = g_malloc0( sizeof(struct ifaddrs) ); - struct ifaddrs *i = g_malloc0( sizeof(struct ifaddrs) ); - - gchar *addr = g_new0( gchar, NI_MAXHOST+1 ); - gchar *ifname; - gint ifIdx; - - if (getifaddrs(&ifaddr) != 0) - { - g_printerr("No addresses for interfaces!\n"); - return NULL; - } - - for ( i = ifaddr; i != NULL; i = i->ifa_next ) { - if (!(i->ifa_flags & IFF_UP)) - continue; - if (i->ifa_flags & IFF_LOOPBACK) - continue; - if ( getnameinfo(i->ifa_addr, sizeof(struct sockaddr), addr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == 0 ) { - - ifname = i->ifa_name; - ifIdx = if_nametoindex(ifname); - - if ( current_connections == NULL || ( current_connections != NULL && - g_list_find_custom( current_connections, (gchar *)addr, - (GCompareFunc)gmyth_socket_find_match_address_uri ) == NULL ) ) - { - local_addrs = g_list_append( local_addrs, g_strdup( addr ) ); - } - - if ( addr != NULL ) { - g_free( addr ); - addr = g_new0( gchar, NI_MAXHOST+1 ); - } - - } - } /* iterates over network interfaces */ - - freeifaddrs(ifaddr); - - return local_addrs; - -} - -#else - static const gchar *PATH_PROC_NET_DEV = "/proc/net/dev"; /** Gets the list of all local network interfaces (using the /proc/net/dev directory). @@ -266,7 +206,6 @@ } -#endif /** * Get only the local addresses from the primary interface @@ -304,6 +243,18 @@ GString * gmyth_socket_get_local_hostname () { + + char hname[50]; + gint res = gethostname (hname, 50); + + if (res == -1) { + g_debug ("Error while getting hostname"); + return NULL; + } + + return g_string_new (hname); + +#if 0 GString *str = NULL; if ( local_hostname != NULL && strlen(local_hostname) > 0 ) @@ -315,6 +266,7 @@ struct sockaddr_in* sa = NULL; gchar localhostname[MAXHOSTNAMELEN]; + if (gethostname (localhostname, MAXHOSTNAMELEN) != 0 ) { gmyth_debug ( "Error on gethostname" ); } @@ -375,6 +327,7 @@ local_hostname = g_strdup( str->str ); return str; +#endif } static void @@ -762,6 +715,10 @@ GString *hostname = NULL; hostname = gmyth_socket_get_local_hostname(); + if (hostname == NULL) { + g_debug ("Hostname not available, setting to n800frontend\n"); + hostname = g_strdup ("n800frontend"); + } g_string_printf(base_str, "ANN %s %s %u", (blocking_client ? "Playback" : "Monitor"), diff -r 8587b24643e8 -r f8d246310650 gmyth/src/gmyth_util.c --- a/gmyth/src/gmyth_util.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/src/gmyth_util.c Tue Jan 30 20:52:35 2007 +0000 @@ -73,9 +73,9 @@ g_static_mutex_lock ( &mutex ); if (localtime_r(&time_value, &tm_time) == NULL) { - g_static_mutex_unlock ( &mutex ); - g_warning ("gmyth_util_time_to_isoformat convertion error!\n"); - return NULL; + g_static_mutex_unlock ( &mutex ); + g_warning ("gmyth_util_time_to_isoformat convertion error!\n"); + return NULL; } result = g_string_sized_new(20); @@ -88,8 +88,6 @@ g_static_mutex_unlock ( &mutex ); return result; - - } /** Converts a time_t struct in a GString at ISO standard format @@ -104,7 +102,6 @@ gchar* gmyth_util_time_to_isoformat_from_time_val_fmt ( const gchar *fmt_string, const GTimeVal* time_val ) { - gchar *result = NULL; struct tm *tm_time = NULL; @@ -133,7 +130,7 @@ return NULL; } strftime( result, buffer_len + 1, fmt_string, tm_time ); - gmyth_debug( "Dateline (ISO result): %s\n", result ); + gmyth_debug( "Dateline (ISO result): %s", result ); } } @@ -271,7 +268,7 @@ { gint year, month, day, hour, min, sec; - gmyth_debug( "[%s] time_str = %s. [%s]\n", __FUNCTION__, time_str != NULL ? + gmyth_debug( "[%s] time_str = %s. [%s]", __FUNCTION__, time_str != NULL ? time_str->str : "[time string is NULL!]", time_str->str ); if ( sscanf (time_str->str, "%04d-%02d-%02d %02d:%02d:%02d", @@ -317,7 +314,7 @@ return NULL; } - gmyth_debug( "Converted from GTimeVal == %s to GDate\n", asctime( date ) ); + gmyth_debug( "Converted from GTimeVal == %s to GDate", asctime( date ) ); return date; } @@ -334,8 +331,9 @@ GTimeVal *time = g_new0( GTimeVal, 1 ); struct tm* tm_time = NULL; time_t time_micros; + gint result; - gmyth_debug( "[%s] time_str = %s. [%s]\n", time_str, time_str != NULL ? + gmyth_debug( "[%s] time_str = %s. [%s]", time_str, time_str != NULL ? time_str : "[time string is NULL!]", time_str ); if ( NULL == time_str ) @@ -348,18 +346,25 @@ tm_time = g_malloc0( sizeof(struct tm) ); - if (strptime( time_str, "%Y-%m-%dT%H:%M:%S", tm_time ) == NULL) - if (strptime( time_str, "%Y-%m-%dT%H:%M", tm_time ) == NULL) - if (strptime( time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time ) == NULL) - if (strptime( time_str, "%Y-%m-%d %H:%M:%S", tm_time ) == NULL) - { - g_static_mutex_unlock ( &mutex ); - gmyth_debug( "Error with Dateline. Not recognised"); - return NULL; - } - - time_micros = mktime( tm_time ); - + /* we first check the return of strftime to allocate a buffer of the correct size */ + result = strptime( time_str, "%Y-%m-%dT%H:%M:%S", tm_time ); + if ( NULL == result ) { + /* we first check the return of strftime to allocate a buffer of the correct size */ + result = strptime( time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time ); + if ( NULL == result ) { + /* we first check the return of strftime to allocate a buffer of the correct size */ + result = strptime( time_str, "%Y-%m-%d %H:%M:%S", tm_time ); + if ( NULL == result ) { + g_static_mutex_unlock ( &mutex ); + gmyth_debug( "Dateline (ISO result): %s", result ); + time = NULL; + //goto done; + } + } + } + + time_micros = mktime( tm_time ); + time->tv_sec = time_micros; // + (gint)( time_val->tv_usec / G_USEC_PER_SEC ); gmyth_debug( "After mktime call... = %s", asctime(tm_time) ); diff -r 8587b24643e8 -r f8d246310650 gmyth/tests/compile_test_connection --- a/gmyth/tests/compile_test_connection Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/tests/compile_test_connection Tue Jan 30 20:52:35 2007 +0000 @@ -1,1 +1,1 @@ -gcc -o gmyth_test_connection gmyth_test_connection.c `pkg-config --cflags --libs gmyth-0.1` +gcc -o gmyth_test_connection gmyth_test_connection.c `pkg-config --cflags --libs gmyth-0.1 glib-2.0` diff -r 8587b24643e8 -r f8d246310650 gmyth/tests/compile_test_recordings --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/compile_test_recordings Tue Jan 30 20:52:35 2007 +0000 @@ -0,0 +1,1 @@ +gcc -o gmyth_test_recordings gmyth_test_recordings.c `pkg-config --cflags --libs gmyth-0.1 glib-2.0` diff -r 8587b24643e8 -r f8d246310650 gmyth/tests/gmyth_test_connection.c --- a/gmyth/tests/gmyth_test_connection.c Tue Jan 30 19:17:41 2007 +0000 +++ b/gmyth/tests/gmyth_test_connection.c Tue Jan 30 20:52:35 2007 +0000 @@ -12,7 +12,24 @@ if (gmyth_socket_connect_with_timeout (socket, gmyth_backend_info_get_hostname (backend_info), gmyth_backend_info_get_port (backend_info), 4) == TRUE) { - g_debug ("Connection success"); + g_debug ("Socket connection success"); + return TRUE; + } else { + g_debug ("Connection failed"); + return FALSE; + } +} + +static gboolean +test_backend_connection2 (GMythBackendInfo *backend_info) +{ + GMythSocket *socket = gmyth_socket_new (); + if (gmyth_socket_connect_to_backend (socket, + gmyth_backend_info_get_hostname (backend_info), + gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) { + + + g_debug ("Backend socket connection success"); return TRUE; } else { g_debug ("Connection failed"); @@ -43,11 +60,12 @@ GMythBackendInfo *backend_info; g_type_init (); - g_thread_init (NULL); + //g_thread_init (NULL); backend_info = gmyth_backend_info_new_with_uri (argv[1]); test_backend_connection1 (backend_info); + test_backend_connection2 (backend_info); test_mysql_connection1 (backend_info); } diff -r 8587b24643e8 -r f8d246310650 gmyth/tests/gmyth_test_recordings.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/gmyth_test_recordings.c Tue Jan 30 20:52:35 2007 +0000 @@ -0,0 +1,59 @@ +#include + +#include "gmyth_uri.h" +#include "gmyth_backendinfo.h" +#include "gmyth_scheduler.h" +#include "gmyth_epg.h" +#include "gmyth_common.h" + +static gboolean +test_recording_list (GMythBackendInfo *backend_info) +{ + GList *list = NULL; + gint length = 0; + GMythScheduler *scheduler = gmyth_scheduler_new (); + + if (gmyth_scheduler_connect_with_timeout (scheduler, + backend_info, 10) == TRUE) { + g_debug ("===== Scheduler connection success ====="); + } else { + g_debug ("===== Scheduler connection failed ====="); + return FALSE; + } + + length = gmyth_scheduler_get_recorded_list (scheduler, &list); + + g_debug ("===== %d Recordings found =====\n", length); + length--; + while (length >= 0) { + RecordedInfo *record = (RecordedInfo*) g_list_nth_data (list, length); + if (record == 0) { + g_debug ("===== Recorded list returned NULL pointer =====\n"); + length--; + continue; + } + g_debug ("===== Record id = %d =====\n", record->record_id); + g_debug ("===== Record name = %s =====\n", (record ? record->basename->str : "NULL")); + length--; + } + + gmyth_scheduler_disconnect (scheduler); + +} + +int +main (int args, const char **argv) +{ + const char* uri = argv[1]; + + GMythBackendInfo *backend_info; + g_type_init (); + + backend_info = gmyth_backend_info_new_with_uri (argv[1]); + + test_recording_list (backend_info); +} + + + +