gmyth/src/gmyth_scheduler.c
author renatofilho
Wed Oct 24 20:01:02 2007 +0100 (2007-10-24)
branchtrunk
changeset 865 3eeb6b565018
parent 864 56cfd1feef30
child 886 781db4177ba2
permissions -rw-r--r--
[svn r871] created myth dbus service
leo_sobral@1
     1
/**
leo_sobral@1
     2
 * GMyth Library
leo_sobral@1
     3
 *
leo_sobral@1
     4
 * @file gmyth/gmyth_scheduler.c
renatofilho@771
     5
 *
leo_sobral@1
     6
 * @brief <p> The scheduler encapsulates all functions for browsing, scheduling
leo_sobral@1
     7
 * and modifying the recorded content.
leo_sobral@1
     8
 *
leo_sobral@1
     9
 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
leo_sobral@1
    10
 * @author Alexsandro Jose Virginio dos Santos <alexsandro.santos@indt.org.br>
leo_sobral@1
    11
 *
renatofilho@771
    12
 *
rosfran@701
    13
 * This program is free software; you can redistribute it and/or modify
rosfran@701
    14
 * it under the terms of the GNU Lesser General Public License as published by
rosfran@701
    15
 * the Free Software Foundation; either version 2 of the License, or
rosfran@701
    16
 * (at your option) any later version.
rosfran@701
    17
 *
rosfran@701
    18
 * This program is distributed in the hope that it will be useful,
rosfran@701
    19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rosfran@701
    20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
rosfran@701
    21
 * GNU General Public License for more details.
rosfran@701
    22
 *
rosfran@701
    23
 * You should have received a copy of the GNU Lesser General Public License
rosfran@701
    24
 * along with this program; if not, write to the Free Software
rosfran@701
    25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
rosfran@701
    26
 */
rosfran@698
    27
leo_sobral@213
    28
#ifdef HAVE_CONFIG_H
leo_sobral@213
    29
#include "config.h"
leo_sobral@213
    30
#endif
leo_sobral@1
    31
leo_sobral@213
    32
#include <assert.h>
leo_sobral@1
    33
rosfran@214
    34
#include <glib/gprintf.h>
rosfran@214
    35
rosfran@214
    36
#include "gmyth_scheduler.h"
leo_sobral@1
    37
#include "gmyth_util.h"
leo_sobral@1
    38
#include "gmyth_query.h"
melunko@117
    39
#include "gmyth_socket.h"
renatofilho@131
    40
#include "gmyth_debug.h"
leo_sobral@1
    41
renatofilho@754
    42
static void     gmyth_scheduler_class_init(GMythSchedulerClass * klass);
renatofilho@754
    43
static void     gmyth_scheduler_init(GMythScheduler * object);
leo_sobral@1
    44
renatofilho@754
    45
static void     gmyth_scheduler_dispose(GObject * object);
renatofilho@754
    46
static void     gmyth_scheduler_finalize(GObject * object);
leo_sobral@1
    47
renatofilho@750
    48
static gboolean update_backend(GMythScheduler * scheduler, gint record_id);
leo_sobral@1
    49
renatofilho@750
    50
G_DEFINE_TYPE(GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT)
renatofilho@754
    51
    static void     gmyth_scheduler_class_init(GMythSchedulerClass * klass)
leo_sobral@1
    52
{
renatofilho@754
    53
    GObjectClass   *gobject_class;
leo_sobral@1
    54
renatofilho@754
    55
    gobject_class = (GObjectClass *) klass;
leo_sobral@1
    56
renatofilho@754
    57
    gobject_class->dispose = gmyth_scheduler_dispose;
renatofilho@754
    58
    gobject_class->finalize = gmyth_scheduler_finalize;
leo_sobral@1
    59
}
leo_sobral@1
    60
leo_sobral@1
    61
static void
renatofilho@750
    62
gmyth_scheduler_init(GMythScheduler * sched)
leo_sobral@1
    63
{
renatofilho@754
    64
    sched->recordid = 0;
renatofilho@754
    65
    sched->type = 0;
renatofilho@754
    66
    sched->search = 0;
renatofilho@754
    67
    sched->profile = g_string_new("");
rosfran@698
    68
renatofilho@754
    69
    sched->dupin = 0;
renatofilho@754
    70
    sched->dupmethod = 0;
renatofilho@754
    71
    sched->autoexpire = 0;
renatofilho@754
    72
    sched->autotranscode = 0;
renatofilho@754
    73
    sched->transcoder = 0;
leo_sobral@1
    74
renatofilho@754
    75
    sched->autocommflag = 0;
renatofilho@754
    76
    sched->autouserjob1 = 0;
renatofilho@754
    77
    sched->autouserjob2 = 0;
renatofilho@754
    78
    sched->autouserjob3 = 0;
renatofilho@754
    79
    sched->autouserjob4 = 0;
rosfran@698
    80
renatofilho@754
    81
    sched->startoffset = 0;
renatofilho@754
    82
    sched->endoffset = 0;
renatofilho@754
    83
    sched->maxepisodes = 0;
renatofilho@754
    84
    sched->maxnewest = 0;
leo_sobral@1
    85
renatofilho@754
    86
    sched->recpriority = 0;
renatofilho@754
    87
    sched->recgroup = g_string_new("");
renatofilho@754
    88
    sched->playgroup = g_string_new("");
rosfran@698
    89
renatofilho@754
    90
    sched->prefinput = 0;
renatofilho@754
    91
    sched->inactive = 0;
rosfran@698
    92
renatofilho@754
    93
    sched->search_type = g_string_new("");
renatofilho@754
    94
    sched->search_what = g_string_new("");
rosfran@698
    95
renatofilho@754
    96
    sched->msqlquery = gmyth_query_new();
leo_sobral@1
    97
}
leo_sobral@1
    98
leo_sobral@1
    99
static void
renatofilho@750
   100
gmyth_scheduler_dispose(GObject * object)
leo_sobral@1
   101
{
renatofilho@754
   102
    GMythScheduler *scheduler = GMYTH_SCHEDULER(object);
melunko@117
   103
renatofilho@754
   104
    if (scheduler->backend_info) {
renatofilho@754
   105
        g_object_unref(scheduler->backend_info);
renatofilho@754
   106
        scheduler->backend_info = NULL;
renatofilho@754
   107
    }
melunko@117
   108
renatofilho@754
   109
    if (scheduler->msqlquery) {
renatofilho@754
   110
        g_object_unref(scheduler->msqlquery);
renatofilho@754
   111
        scheduler->msqlquery = NULL;
renatofilho@754
   112
    }
leo_sobral@387
   113
renatofilho@754
   114
    g_string_free(scheduler->profile, TRUE);
renatofilho@754
   115
    g_string_free(scheduler->recgroup, TRUE);
renatofilho@754
   116
    g_string_free(scheduler->playgroup, TRUE);
renatofilho@754
   117
    g_string_free(scheduler->search_type, TRUE);
renatofilho@754
   118
    g_string_free(scheduler->search_what, TRUE);
leo_sobral@387
   119
renatofilho@754
   120
    G_OBJECT_CLASS(gmyth_scheduler_parent_class)->dispose(object);
leo_sobral@1
   121
}
leo_sobral@1
   122
leo_sobral@1
   123
static void
renatofilho@750
   124
gmyth_scheduler_finalize(GObject * object)
leo_sobral@1
   125
{
renatofilho@754
   126
    g_signal_handlers_destroy(object);
leo_sobral@1
   127
renatofilho@754
   128
    G_OBJECT_CLASS(gmyth_scheduler_parent_class)->finalize(object);
leo_sobral@1
   129
}
leo_sobral@1
   130
leo_sobral@1
   131
/** Creates a new instance of GMythScheduler.
leo_sobral@1
   132
 * 
leo_sobral@1
   133
 * @return a new instance of GMythScheduler.
leo_sobral@1
   134
 */
rosfran@698
   135
GMythScheduler *
renatofilho@750
   136
gmyth_scheduler_new()
leo_sobral@1
   137
{
renatofilho@754
   138
    GMythScheduler *scheduler =
renatofilho@754
   139
        GMYTH_SCHEDULER(g_object_new(GMYTH_SCHEDULER_TYPE, NULL));
rosfran@698
   140
renatofilho@754
   141
    return scheduler;
leo_sobral@1
   142
}
leo_sobral@1
   143
melunko@257
   144
gboolean
renatofilho@750
   145
gmyth_scheduler_connect(GMythScheduler * scheduler,
renatofilho@754
   146
                        GMythBackendInfo * backend_info)
melunko@257
   147
{
renatofilho@754
   148
    return gmyth_scheduler_connect_with_timeout(scheduler, backend_info,
renatofilho@754
   149
                                                0);
melunko@257
   150
}
melunko@257
   151
leo_sobral@1
   152
/** Connects to the Mysql database in the backend. The backend address
leo_sobral@1
   153
 * is loaded from the GMythSettings instance.
morphbr@766
   154
 *
leo_sobral@1
   155
 * @param scheduler the GMythScheduler instance to be connected.
leo_sobral@1
   156
 * @return true if connection was success, false if failed.
leo_sobral@1
   157
 */
leo_sobral@1
   158
gboolean
renatofilho@750
   159
gmyth_scheduler_connect_with_timeout(GMythScheduler * scheduler,
renatofilho@754
   160
                                     GMythBackendInfo * backend_info,
renatofilho@754
   161
                                     guint timeout)
leo_sobral@1
   162
{
renatofilho@754
   163
    assert(scheduler);
renatofilho@754
   164
    g_return_val_if_fail(backend_info != NULL, FALSE);
rosfran@698
   165
renatofilho@754
   166
    if (scheduler->backend_info)
renatofilho@754
   167
        g_object_unref(scheduler->backend_info);
rosfran@698
   168
renatofilho@754
   169
    scheduler->backend_info = g_object_ref(backend_info);
leo_sobral@1
   170
renatofilho@754
   171
    if (scheduler->msqlquery == NULL) {
renatofilho@754
   172
        g_warning("[%s] GMythScheduler db initializing", __FUNCTION__);
renatofilho@754
   173
        scheduler->msqlquery = gmyth_query_new();
renatofilho@754
   174
    }
leo_sobral@1
   175
renatofilho@754
   176
    if (!gmyth_query_connect_with_timeout(scheduler->msqlquery,
renatofilho@754
   177
                                          scheduler->backend_info,
renatofilho@754
   178
                                          timeout)) {
renatofilho@754
   179
        g_warning("[%s] Error while connecting to db", __FUNCTION__);
renatofilho@754
   180
        return FALSE;
renatofilho@754
   181
    }
leo_sobral@1
   182
renatofilho@754
   183
    return TRUE;
leo_sobral@1
   184
}
leo_sobral@1
   185
leo_sobral@1
   186
/** Disconnects from the Mysql database in the backend.
morphbr@766
   187
 *
leo_sobral@1
   188
 * @param scheduler the GMythScheduler instance to be disconnected
leo_sobral@1
   189
 * @return true if disconnection was success, false if failed.
leo_sobral@1
   190
 */
leo_sobral@1
   191
gboolean
renatofilho@750
   192
gmyth_scheduler_disconnect(GMythScheduler * scheduler)
leo_sobral@1
   193
{
renatofilho@754
   194
    assert(scheduler);
leo_sobral@1
   195
renatofilho@754
   196
    if (scheduler->msqlquery != NULL) {
renatofilho@754
   197
        gmyth_query_disconnect(scheduler->msqlquery);
renatofilho@754
   198
    }
leo_sobral@1
   199
renatofilho@754
   200
    return TRUE;
leo_sobral@1
   201
}
leo_sobral@1
   202
leo_sobral@1
   203
/** Retrieves from the backend Mysql database the list of recording schedules.
leo_sobral@1
   204
 * 
leo_sobral@1
   205
 * @param scheduler The GMythScheduler instance.
leo_sobral@1
   206
 * @param schedule_list the GList pointer to be filled with the loaded list of ScheduleInfo items.
leo_sobral@1
   207
 * @return The amount of schedules retrieved from database, or -1 if error.
leo_sobral@1
   208
 */
leo_sobral@1
   209
gint
renatofilho@750
   210
gmyth_scheduler_get_schedule_list(GMythScheduler * scheduler,
renatofilho@754
   211
                                  GList ** schedule_list)
leo_sobral@1
   212
{
renatofilho@754
   213
    ScheduleInfo   *schedule;
renatofilho@754
   214
    MYSQL_RES      *msql_res;
renatofilho@754
   215
    GString        *query_str = g_string_new("");
renatofilho@754
   216
    gchar          *date_time = NULL;
rosfran@698
   217
renatofilho@754
   218
    assert(scheduler);
rosfran@698
   219
renatofilho@754
   220
    g_string_printf(query_str,
renatofilho@754
   221
                    "SELECT recordid,programid,chanid,starttime,startdate,"
melunko@836
   222
                    "endtime,enddate,title,subtitle,description,category,type,parentid FROM record;");
leo_sobral@1
   223
renatofilho@754
   224
    if (scheduler->msqlquery == NULL) {
renatofilho@754
   225
        g_warning("[%s] Scheduler db connection not initialized",
renatofilho@754
   226
                  __FUNCTION__);
renatofilho@754
   227
        return -1;
renatofilho@754
   228
    }
renatofilho@754
   229
    msql_res =
renatofilho@754
   230
        gmyth_query_process_statement(scheduler->msqlquery,
renatofilho@754
   231
                                      query_str->str);
leo_sobral@1
   232
renatofilho@754
   233
    if (msql_res == NULL) {
renatofilho@754
   234
        g_warning("DB retrieval of schedule list failed");
renatofilho@754
   235
        return -1;
renatofilho@754
   236
    } else {
renatofilho@754
   237
        MYSQL_ROW       row;
rosfran@698
   238
renatofilho@754
   239
        *schedule_list = NULL;
rosfran@698
   240
renatofilho@754
   241
        while ((row = mysql_fetch_row(msql_res)) != NULL) {
renatofilho@754
   242
            schedule = g_new0(ScheduleInfo, 1);
melunko@836
   243
            gint type = 0;
rosfran@698
   244
renatofilho@754
   245
            schedule->schedule_id =
renatofilho@754
   246
                (guint) g_ascii_strtoull(row[0], NULL, 10);
renatofilho@754
   247
            schedule->program_id =
renatofilho@754
   248
                (guint) g_ascii_strtoull(row[1], NULL, 10);
renatofilho@754
   249
            schedule->channel_id =
renatofilho@754
   250
                (guint) g_ascii_strtoull(row[2], NULL, 10);
rosfran@698
   251
renatofilho@754
   252
            /*
renatofilho@754
   253
             * generate a time_t from a time and a date db field 
renatofilho@754
   254
             */
renatofilho@754
   255
            date_time = g_strdup_printf("%sT%s", row[4], row[3]);
renatofilho@754
   256
            schedule->start_time =
renatofilho@754
   257
                gmyth_util_string_to_time_val(date_time);
renatofilho@754
   258
            g_free(date_time);
rosfran@698
   259
renatofilho@754
   260
            /*
renatofilho@754
   261
             * generate a time_t from a time and a date db field 
renatofilho@754
   262
             */
renatofilho@754
   263
            date_time = g_strdup_printf("%sT%s", row[6], row[5]);
renatofilho@754
   264
            schedule->end_time = gmyth_util_string_to_time_val(date_time);
renatofilho@754
   265
            g_free(date_time);
leo_sobral@1
   266
renatofilho@754
   267
            schedule->title = g_string_new(row[7]);
renatofilho@754
   268
            schedule->subtitle = g_string_new(row[8]);
renatofilho@754
   269
            schedule->description = g_string_new(row[9]);
renatofilho@754
   270
            schedule->category = g_string_new(row[10]);
melunko@836
   271
            type = g_ascii_strtoull (row[11], NULL, 10);
melunko@836
   272
            if (type == 4) {
melunko@836
   273
                schedule->type = GMYTH_SCHEDULE_ALL_OCCURRENCES;
melunko@836
   274
            } else if (type == 1) {
melunko@836
   275
                schedule->type = GMYTH_SCHEDULE_ONE_OCCURRENCE;
melunko@836
   276
            } else if (type == 8) {
melunko@836
   277
                schedule->type = GMYTH_SCHEDULE_EXCEPTION;
melunko@836
   278
                schedule->parentid = (gint) g_ascii_strtoull (row[12], NULL, 10);
melunko@836
   279
            }
leo_sobral@1
   280
renatofilho@754
   281
            (*schedule_list) = g_list_append(*(schedule_list), schedule);
renatofilho@754
   282
        }
renatofilho@754
   283
    }
leo_sobral@1
   284
renatofilho@754
   285
    mysql_free_result(msql_res);
renatofilho@754
   286
    g_string_free(query_str, TRUE);
leo_sobral@1
   287
renatofilho@754
   288
    return (*schedule_list == NULL) ? 0 : g_list_length(*schedule_list);
leo_sobral@1
   289
}
leo_sobral@1
   290
leo_sobral@1
   291
/** Retrieves from the backend Mysql database the list of recorded programs.
leo_sobral@1
   292
 * 
leo_sobral@1
   293
 * @param scheduler The GMythScheduler instance.
leo_sobral@1
   294
 * @param recorded_list the GList pointer to be filled with the loaded RecordInfo items.
leo_sobral@1
   295
 * @return The amount of recorded retrieved from database, or -1 if error.
leo_sobral@1
   296
 */
leo_sobral@1
   297
gint
renatofilho@750
   298
gmyth_scheduler_get_recorded_list(GMythScheduler * scheduler,
renatofilho@754
   299
                                  GList ** recorded_list)
leo_sobral@1
   300
{
renatofilho@754
   301
    RecordedInfo   *record;
renatofilho@754
   302
    MYSQL_RES      *msql_res;
renatofilho@754
   303
    GString        *query_str = g_string_new("");
rosfran@698
   304
renatofilho@754
   305
    assert(scheduler);
rosfran@698
   306
renatofilho@754
   307
    g_string_printf(query_str,
renatofilho@754
   308
                    "SELECT recordid,programid,chanid,starttime,progstart,"
renatofilho@754
   309
                    "endtime,progend,title,subtitle,description,category,"
renatofilho@754
   310
                    "filesize,basename FROM recorded WHERE recgroup != 'LiveTV'");
leo_sobral@1
   311
renatofilho@754
   312
    if (scheduler->msqlquery == NULL) {
renatofilho@754
   313
        g_warning("[%s] Scheduler db connection not initialized",
renatofilho@754
   314
                  __FUNCTION__);
renatofilho@754
   315
        return -1;
renatofilho@754
   316
    }
leo_sobral@1
   317
renatofilho@754
   318
    msql_res =
renatofilho@754
   319
        gmyth_query_process_statement(scheduler->msqlquery,
renatofilho@754
   320
                                      query_str->str);
leo_sobral@1
   321
renatofilho@754
   322
    if (msql_res == NULL) {
renatofilho@754
   323
        g_warning("DB retrieval of recording list failed");
renatofilho@754
   324
        return -1;
renatofilho@754
   325
    } else {
renatofilho@754
   326
        MYSQL_ROW       row;
rosfran@698
   327
renatofilho@754
   328
        (*recorded_list) = NULL;
rosfran@698
   329
renatofilho@754
   330
        while ((row = mysql_fetch_row(msql_res)) != NULL) {
renatofilho@754
   331
            record = g_new0(RecordedInfo, 1);
rosfran@698
   332
renatofilho@754
   333
            record->record_id = (guint) g_ascii_strtoull(row[0], NULL, 10);
renatofilho@754
   334
            record->program_id =
renatofilho@754
   335
                (guint) g_ascii_strtoull(row[1], NULL, 10);
renatofilho@754
   336
            record->channel_id =
renatofilho@754
   337
                (guint) g_ascii_strtoull(row[2], NULL, 10);
rosfran@698
   338
renatofilho@754
   339
            record->start_time = gmyth_util_string_to_time_val(row[3]);
renatofilho@754
   340
            record->end_time = gmyth_util_string_to_time_val(row[5]);
rosfran@698
   341
renatofilho@754
   342
            record->title = g_string_new(row[7]);
renatofilho@754
   343
            record->subtitle = g_string_new(row[8]);
renatofilho@754
   344
            record->description = g_string_new(row[9]);
renatofilho@754
   345
            record->category = g_string_new(row[10]);
renatofilho@754
   346
            record->filesize = g_ascii_strtoull(row[11], NULL, 10);
renatofilho@754
   347
            record->basename = g_string_new(row[12]);
leo_sobral@1
   348
renatofilho@754
   349
            (*recorded_list) = g_list_append((*recorded_list), record);
renatofilho@754
   350
        }
renatofilho@754
   351
    }
rosfran@698
   352
renatofilho@754
   353
    mysql_free_result(msql_res);
renatofilho@754
   354
    g_string_free(query_str, TRUE);
leo_sobral@1
   355
renatofilho@754
   356
    return (*recorded_list == NULL) ? 0 : g_list_length(*recorded_list);
leo_sobral@1
   357
}
leo_sobral@1
   358
renatofilho@771
   359
RecordedInfo*
renatofilho@755
   360
gmyth_scheduler_get_recorded_info (GMythScheduler *scheduler,
renatofilho@771
   361
                                   const gchar* basename)
renatofilho@755
   362
{
renatofilho@769
   363
    RecordedInfo   *record = NULL;
renatofilho@755
   364
    MYSQL_RES      *msql_res;
renatofilho@755
   365
    GString        *query_str = g_string_new("");
renatofilho@755
   366
renatofilho@755
   367
    assert(scheduler);
renatofilho@755
   368
renatofilho@755
   369
    g_string_printf(query_str,
renatofilho@755
   370
                    "SELECT recordid,programid,chanid,starttime,progstart,"
renatofilho@755
   371
                    "endtime,progend,title,subtitle,description,category,"
renatofilho@755
   372
                    "filesize,basename FROM recorded "
renatofilho@771
   373
                    "WHERE recgroup != 'LiveTV' AND basename = '%s'", basename);
renatofilho@755
   374
renatofilho@755
   375
    if (scheduler->msqlquery == NULL) {
renatofilho@755
   376
        g_warning("[%s] Scheduler db connection not initialized", 
renatofilho@755
   377
                        __FUNCTION__);
renatofilho@769
   378
        return NULL;
renatofilho@755
   379
    }
renatofilho@755
   380
renatofilho@755
   381
    msql_res =
renatofilho@755
   382
        gmyth_query_process_statement(scheduler->msqlquery,
renatofilho@755
   383
                                      query_str->str);
renatofilho@755
   384
renatofilho@755
   385
    if (msql_res == NULL) {
renatofilho@755
   386
        g_warning("DB retrieval of recording list failed");
renatofilho@769
   387
        return NULL;
renatofilho@755
   388
    } else {
renatofilho@755
   389
        MYSQL_ROW       row;
renatofilho@755
   390
        row = mysql_fetch_row(msql_res);
renatofilho@755
   391
        if (row != NULL) {
renatofilho@755
   392
            record = g_new0(RecordedInfo, 1);
renatofilho@755
   393
            record->record_id = (guint) g_ascii_strtoull(row[0], NULL, 10);
renatofilho@755
   394
            record->program_id = (guint) g_ascii_strtoull(row[1], NULL, 10);
renatofilho@755
   395
            record->channel_id = (guint) g_ascii_strtoull(row[2], NULL, 10);
renatofilho@755
   396
            record->start_time = gmyth_util_string_to_time_val(row[3]);
renatofilho@755
   397
            record->end_time = gmyth_util_string_to_time_val(row[5]);
renatofilho@755
   398
            record->title = g_string_new(row[7]);
renatofilho@755
   399
            record->subtitle = g_string_new(row[8]);
renatofilho@755
   400
            record->description = g_string_new(row[9]);
renatofilho@755
   401
            record->category = g_string_new(row[10]);
renatofilho@755
   402
            record->filesize = g_ascii_strtoull(row[11], NULL, 10);
renatofilho@755
   403
            record->basename = g_string_new(row[12]);
renatofilho@755
   404
        }
renatofilho@755
   405
    }
renatofilho@755
   406
renatofilho@755
   407
    mysql_free_result(msql_res);
renatofilho@755
   408
    g_string_free(query_str, TRUE);
renatofilho@755
   409
renatofilho@755
   410
    return record;
renatofilho@755
   411
}
renatofilho@755
   412
renatofilho@755
   413
melunko@567
   414
static void
renatofilho@754
   415
_set_value(GMythQuery * myth_query, char *field, gchar * value,
renatofilho@754
   416
           gint rec_id)
melunko@567
   417
{
renatofilho@754
   418
    gchar          *query =
renatofilho@754
   419
        g_strdup_printf
renatofilho@754
   420
        ("UPDATE record SET recordid = %d, %s = \"%s\" WHERE recordid = %d;",
renatofilho@754
   421
         rec_id, field, value, rec_id);
melunko@567
   422
renatofilho@754
   423
    gmyth_query_process_statement(myth_query, query);
renatofilho@754
   424
    g_free(query);
melunko@567
   425
}
melunko@567
   426
melunko@567
   427
static void
renatofilho@754
   428
_set_int_value(GMythQuery * myth_query, char *field, gint value,
renatofilho@754
   429
               gint rec_id)
melunko@567
   430
{
melunko@814
   431
    gchar *str_value = g_strdup_printf("%d", value);
rosfran@698
   432
renatofilho@754
   433
    _set_value(myth_query, field, str_value, rec_id);
renatofilho@754
   434
    g_free(str_value);
melunko@567
   435
}
melunko@567
   436
leo_sobral@1
   437
gboolean
melunko@801
   438
gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler,
melunko@801
   439
                             ScheduleInfo * schedule_info, GMythScheduleType type)
leo_sobral@1
   440
{
renatofilho@754
   441
    MYSQL_RES      *msql_res;
renatofilho@754
   442
    gchar          *query_str = "INSERT record (recordid) VALUE (0);";
renatofilho@754
   443
    gchar          *station = NULL;
renatofilho@754
   444
    gulong          rec_id;
rosfran@698
   445
renatofilho@754
   446
    assert(scheduler);
rosfran@698
   447
renatofilho@754
   448
    if (scheduler->msqlquery == NULL) {
renatofilho@754
   449
        g_warning("[%s] Scheduler db connection not initialized",
renatofilho@754
   450
                  __FUNCTION__);
renatofilho@754
   451
        return FALSE;
renatofilho@754
   452
    }
melunko@567
   453
renatofilho@754
   454
    msql_res =
renatofilho@754
   455
        gmyth_query_process_statement_with_increment(scheduler->msqlquery,
renatofilho@754
   456
                                                     query_str, &rec_id);
renatofilho@754
   457
    mysql_free_result(msql_res);
rosfran@698
   458
renatofilho@754
   459
    // Retrieves the station info
renatofilho@754
   460
    query_str =
renatofilho@754
   461
        g_strdup_printf
renatofilho@754
   462
        ("SELECT callsign FROM channel WHERE chanid = \"%d\";",
renatofilho@754
   463
         schedule_info->channel_id);
renatofilho@754
   464
    msql_res =
renatofilho@754
   465
        gmyth_query_process_statement(scheduler->msqlquery, query_str);
renatofilho@754
   466
    if (msql_res == NULL) {
renatofilho@754
   467
        g_warning("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
renatofilho@754
   468
        return FALSE;
renatofilho@754
   469
    } else {
renatofilho@754
   470
        MYSQL_ROW       row;
rosfran@698
   471
renatofilho@754
   472
        if ((row = mysql_fetch_row(msql_res)) != NULL) {
renatofilho@754
   473
            station = g_strdup(row[0]);
renatofilho@754
   474
        }
renatofilho@754
   475
    }
renatofilho@754
   476
    mysql_free_result(msql_res);
renatofilho@754
   477
    g_free(query_str);
leo_sobral@1
   478
renatofilho@754
   479
    // _set_value (field, value, id);
renatofilho@754
   480
    _set_int_value(scheduler->msqlquery, "chanid",
renatofilho@754
   481
                   schedule_info->channel_id, rec_id);
renatofilho@754
   482
    _set_value(scheduler->msqlquery, "station", station, rec_id);
renatofilho@754
   483
    _set_value(scheduler->msqlquery, "title", schedule_info->title->str,
renatofilho@754
   484
               rec_id);
renatofilho@754
   485
    // / subtitle, description 
renatofilho@754
   486
    _set_value(scheduler->msqlquery, "starttime",
renatofilho@754
   487
               gmyth_util_time_to_string_only_time(schedule_info->
renatofilho@754
   488
                                                   start_time), rec_id);
renatofilho@754
   489
    _set_value(scheduler->msqlquery, "startdate",
renatofilho@754
   490
               gmyth_util_time_to_string_only_date(schedule_info->
renatofilho@754
   491
                                                   start_time), rec_id);
renatofilho@754
   492
    _set_value(scheduler->msqlquery, "endtime",
renatofilho@754
   493
               gmyth_util_time_to_string_only_time(schedule_info->
renatofilho@754
   494
                                                   end_time), rec_id);
renatofilho@754
   495
    _set_value(scheduler->msqlquery, "enddate",
renatofilho@754
   496
               gmyth_util_time_to_string_only_date(schedule_info->
renatofilho@754
   497
                                                   end_time), rec_id);
renatofilho@754
   498
    // / category, series id, program id
renatofilho@754
   499
    // _set_value (scheduler->msqlquery, "findday",
renatofilho@754
   500
    // (gmyth_util_time_val_to_date( schedule_info->start_time
renatofilho@754
   501
    // ))->tm_wday, rec_id);
renatofilho@754
   502
    // _set_value (scheduler->msqlquery, "findtime",
renatofilho@754
   503
    // gmyth_util_time_to_string_only_time( schedule_info->start_time),
renatofilho@754
   504
    // rec_id);
renatofilho@754
   505
    // _set_int_value (scheduler->msqlquery, "findid",
renatofilho@754
   506
    // (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528),
renatofilho@754
   507
    // rec_id);
melunko@801
   508
renatofilho@754
   509
    _set_value(scheduler->msqlquery, "parentid", "0", rec_id);
renatofilho@754
   510
    _set_value(scheduler->msqlquery, "search", "0", rec_id);
melunko@801
   511
melunko@801
   512
    if (type == GMYTH_SCHEDULE_ALL_OCCURRENCES) {
morphbr@841
   513
        _set_int_value(scheduler->msqlquery, "type", 3, rec_id);
melunko@814
   514
    } else if (type == GMYTH_SCHEDULE_ONE_OCCURRENCE) {
melunko@814
   515
        _set_int_value(scheduler->msqlquery, "type", 1, rec_id);
melunko@814
   516
    } else if (type == GMYTH_SCHEDULE_EXCEPTION) {
melunko@814
   517
        _set_int_value(scheduler->msqlquery, "type", 8, rec_id);
melunko@836
   518
        _set_int_value(scheduler->msqlquery, "parentid", schedule_info->parentid,
melunko@814
   519
		       rec_id);
melunko@801
   520
    }
melunko@801
   521
renatofilho@754
   522
    _set_value(scheduler->msqlquery, "recpriority", "0", rec_id);
renatofilho@754
   523
    _set_value(scheduler->msqlquery, "startoffset", "0", rec_id);
renatofilho@754
   524
    _set_value(scheduler->msqlquery, "endoffset", "0", rec_id);
renatofilho@754
   525
    _set_value(scheduler->msqlquery, "dupmethod", "6", rec_id); // ?
renatofilho@754
   526
    _set_value(scheduler->msqlquery, "dupin", "15", rec_id);    // ?
melunko@567
   527
renatofilho@754
   528
    _set_value(scheduler->msqlquery, "prefinput", "0", rec_id);
renatofilho@754
   529
    _set_value(scheduler->msqlquery, "inactive", "0", rec_id);
renatofilho@754
   530
    _set_value(scheduler->msqlquery, "profile", "Default", rec_id);
renatofilho@754
   531
    _set_value(scheduler->msqlquery, "recgroup", "Default", rec_id);
renatofilho@754
   532
    _set_value(scheduler->msqlquery, "storagegroup", "Default", rec_id);
renatofilho@754
   533
    _set_value(scheduler->msqlquery, "playgroup", "Default", rec_id);
renatofilho@754
   534
    _set_value(scheduler->msqlquery, "autoexpire", "1", rec_id);
renatofilho@754
   535
    _set_value(scheduler->msqlquery, "maxepisodes", "0", rec_id);
renatofilho@754
   536
    _set_value(scheduler->msqlquery, "maxnewest", "0", rec_id);
renatofilho@754
   537
    _set_value(scheduler->msqlquery, "autocommflag", "1", rec_id);
renatofilho@754
   538
    _set_value(scheduler->msqlquery, "autotranscode", "0", rec_id);
renatofilho@754
   539
    _set_value(scheduler->msqlquery, "transcoder", "0", rec_id);
melunko@567
   540
renatofilho@754
   541
    _set_value(scheduler->msqlquery, "autouserjob1", "0", rec_id);
renatofilho@754
   542
    _set_value(scheduler->msqlquery, "autouserjob2", "0", rec_id);
renatofilho@754
   543
    _set_value(scheduler->msqlquery, "autouserjob3", "0", rec_id);
renatofilho@754
   544
    _set_value(scheduler->msqlquery, "autouserjob4", "0", rec_id);
melunko@567
   545
renatofilho@754
   546
    schedule_info->schedule_id = rec_id;
melunko@581
   547
melunko@836
   548
    /* Notify the backend of changes */
renatofilho@754
   549
    return update_backend(scheduler, rec_id);
leo_sobral@1
   550
}
leo_sobral@1
   551
melunko@801
   552
/** Requests the Mysql database in the backend to add a new schedule.
melunko@801
   553
 * 
melunko@801
   554
 * @param scheduler the GMythScheduler instance.
melunko@801
   555
 * @param schedule_info the ScheduleInfo with recording schedule information
melunko@801
   556
 * to be added. record_id = -1 to add a new schedule, otherwise this
melunko@801
   557
 * function will update the schedule in the db
melunko@801
   558
 * @return gboolean returns FALSE if some error occurs, TRUE otherwise
melunko@801
   559
 */
melunko@801
   560
gboolean
melunko@801
   561
gmyth_scheduler_add_schedule (GMythScheduler * scheduler,
melunko@801
   562
                             ScheduleInfo * schedule_info)
melunko@801
   563
{
melunko@801
   564
    return gmyth_scheduler_add_schedule_full (scheduler, schedule_info, 
melunko@801
   565
                                              GMYTH_SCHEDULE_ONE_OCCURRENCE);
melunko@801
   566
}
melunko@801
   567
leo_sobral@1
   568
/** Requests the Mysql database in the backend to remove an existing schedule.
leo_sobral@1
   569
 * 
leo_sobral@1
   570
 * @param scheduler the GMythScheduler instance.
melunko@814
   571
 * @param schedule_id The schedule's record id to be removed
leo_sobral@1
   572
 * @return gboolean TRUE if success, FALSE if error
leo_sobral@1
   573
 */
leo_sobral@1
   574
gboolean
melunko@814
   575
gmyth_scheduler_delete_schedule(GMythScheduler * scheduler, gint schedule_id)
leo_sobral@1
   576
{
leo_sobral@1
   577
renatofilho@754
   578
    MYSQL_RES      *msql_res;
melunko@814
   579
    GString        *query_str = NULL;
leo_sobral@1
   580
melunko@814
   581
    g_return_val_if_fail (scheduler != NULL, FALSE);
melunko@814
   582
rosfran@698
   583
renatofilho@754
   584
    if (scheduler->msqlquery == NULL) {
renatofilho@754
   585
        g_warning("[%s] Scheduler db connection not initialized",
renatofilho@754
   586
                  __FUNCTION__);
renatofilho@754
   587
        return FALSE;
renatofilho@754
   588
    }
melunko@814
   589
melunko@814
   590
    query_str = g_string_new("");
renatofilho@754
   591
    g_string_printf(query_str,
melunko@814
   592
                    "DELETE FROM record WHERE recordid=%d", schedule_id);
leo_sobral@1
   593
renatofilho@754
   594
    msql_res =
renatofilho@754
   595
        gmyth_query_process_statement(scheduler->msqlquery,
renatofilho@754
   596
                                      query_str->str);
leo_sobral@1
   597
leo_sobral@1
   598
renatofilho@754
   599
    mysql_free_result(msql_res);
renatofilho@754
   600
    g_string_free(query_str, TRUE);
rosfran@698
   601
renatofilho@754
   602
    // Notify the backend of the changes
melunko@814
   603
    return update_backend(scheduler, schedule_id);
melunko@814
   604
}
melunko@814
   605
melunko@814
   606
/*
melunko@814
   607
 * Add an exception program to be removed from the schedule list, when programs
melunko@814
   608
 * where scheduled with the GMYTH_SCHEDULE_ALL_OCCURRENCES option.
melunko@814
   609
 * @param scheduler the GMythScheduler instance.
melunko@814
   610
 * @param schedule_id the schedule id of the all occurrence schedule to be changed
melunko@814
   611
 * @param exception_info the ScheduleInfo to be removed from all schedule occurrences
melunko@814
   612
 * @return TRUE if success, FALSE if any error happens
melunko@814
   613
 */
melunko@814
   614
gboolean
melunko@814
   615
gmyth_scheduler_add_exception (GMythScheduler *scheduler, gint schedule_id,
melunko@814
   616
			       ScheduleInfo *exception_info)
melunko@814
   617
{
melunko@814
   618
    gboolean res;
melunko@814
   619
melunko@814
   620
    g_return_val_if_fail (scheduler != NULL, FALSE);
melunko@814
   621
    g_return_val_if_fail (exception_info != NULL, FALSE);
melunko@814
   622
melunko@814
   623
    exception_info->parentid = schedule_id;
melunko@814
   624
    res = gmyth_scheduler_add_schedule_full (scheduler, exception_info, GMYTH_SCHEDULE_EXCEPTION);
melunko@814
   625
melunko@814
   626
    return res;
leo_sobral@1
   627
}
leo_sobral@1
   628
leo_sobral@1
   629
/** Requests the Mysql database in the backend to remove an existing recorded item.
leo_sobral@1
   630
 * 
leo_sobral@1
   631
 * @param scheduler the GMythScheduler instance.
leo_sobral@1
   632
 * @param record_id The recorded item id to be removed
leo_sobral@1
   633
 * @return gboolean TRUE if success, FALSE if error
leo_sobral@1
   634
 */
leo_sobral@1
   635
gboolean
renatofilho@750
   636
gmyth_scheduler_delete_recorded(GMythScheduler * scheduler, gint record_id)
leo_sobral@1
   637
{
leo_sobral@1
   638
renatofilho@754
   639
    MYSQL_RES      *msql_res;
melunko@117
   640
renatofilho@754
   641
    GString        *query_str = g_string_new("");
leo_sobral@1
   642
renatofilho@754
   643
    assert(scheduler);
rosfran@698
   644
renatofilho@754
   645
    if (scheduler->msqlquery == NULL) {
renatofilho@754
   646
        g_warning("[%s] Scheduler db connection not initialized",
renatofilho@754
   647
                  __FUNCTION__);
renatofilho@754
   648
        return FALSE;
renatofilho@754
   649
    }
renatofilho@754
   650
    // ========================================
renatofilho@754
   651
    g_string_printf(query_str,
renatofilho@754
   652
                    "DELETE FROM recorded WHERE recordid=%d", record_id);
leo_sobral@1
   653
renatofilho@754
   654
    // FIXME: Mythtv implementation runs also: DELETE FROM oldfind WHERE
renatofilho@754
   655
    // recordid = x
melunko@526
   656
renatofilho@754
   657
    msql_res =
renatofilho@754
   658
        gmyth_query_process_statement(scheduler->msqlquery,
renatofilho@754
   659
                                      query_str->str);
rosfran@698
   660
renatofilho@754
   661
    mysql_free_result(msql_res);
renatofilho@754
   662
    g_string_free(query_str, TRUE);
rosfran@698
   663
renatofilho@754
   664
    // Notify the backend of the changes
renatofilho@754
   665
    return update_backend(scheduler, record_id);
leo_sobral@1
   666
}
leo_sobral@1
   667
morphbr@841
   668
morphbr@841
   669
gboolean gmyth_scheduler_was_recorded_before(GMythScheduler* scheduler, gint channel_id,
morphbr@841
   670
                                             time_t start_time)
morphbr@841
   671
{
morphbr@841
   672
    MYSQL_RES      *msql_res;
morphbr@841
   673
    GString        *query_str = g_string_new("");
morphbr@841
   674
morphbr@841
   675
    assert(scheduler);
morphbr@841
   676
    g_string_printf(query_str, "SELECT callsign FROM channel "
morphbr@841
   677
                    "WHERE chanid = \"%d\"", channel_id);
morphbr@841
   678
morphbr@841
   679
    msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
morphbr@841
   680
morphbr@841
   681
    if (msql_res) {
morphbr@841
   682
        MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
morphbr@841
   683
        if (msql_row) {
morphbr@841
   684
            GString* callsign = g_string_new(msql_row[0]);
morphbr@841
   685
            GString* startts = gmyth_util_time_to_string(start_time);
morphbr@841
   686
            g_string_printf(query_str, "SELECT * FROM oldrecorded "
morphbr@841
   687
                            "WHERE station = \"%s\" AND starttime = \"%s\"",
morphbr@841
   688
                            callsign->str, startts->str);
morphbr@841
   689
            msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
morphbr@841
   690
            g_string_free(callsign, TRUE);
morphbr@841
   691
            g_string_free(startts, TRUE);
morphbr@841
   692
            g_string_free(query_str, TRUE);
morphbr@841
   693
            if (mysql_fetch_row(msql_res)) return TRUE;
morphbr@841
   694
        }
morphbr@841
   695
    }
morphbr@841
   696
    return FALSE;
morphbr@841
   697
}
morphbr@841
   698
morphbr@841
   699
morphbr@841
   700
gboolean gmyth_scheduler_reactivate_schedule(GMythScheduler* scheduler, gint channel_id,
morphbr@841
   701
                                             time_t start_time)
morphbr@841
   702
morphbr@841
   703
{
morphbr@841
   704
    MYSQL_RES      *msql_res;
morphbr@841
   705
    GString        *query_str = g_string_new("");
morphbr@841
   706
morphbr@841
   707
    assert(scheduler);
morphbr@841
   708
    g_string_printf(query_str, "SELECT callsign FROM channel "
morphbr@841
   709
                    "WHERE chanid = \"%d\"", channel_id);
morphbr@841
   710
morphbr@841
   711
    msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
morphbr@841
   712
    if (msql_res) {
morphbr@841
   713
        MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
morphbr@841
   714
        if (msql_row) {
morphbr@841
   715
            GString* callsign = g_string_new(msql_row[0]);
morphbr@841
   716
            GString* startts = gmyth_util_time_to_string(start_time);
morphbr@841
   717
            g_string_printf(query_str, "UPDATE oldrecorded SET reactivate = 1 "
morphbr@841
   718
                            "WHERE station = \"%s\" AND starttime = \"%s\"",
morphbr@841
   719
                            callsign->str, startts->str);
morphbr@841
   720
            gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
morphbr@841
   721
            g_string_free(callsign, TRUE);
morphbr@841
   722
            g_string_free(startts, TRUE);
morphbr@841
   723
            g_string_free(query_str, TRUE);
morphbr@841
   724
            return TRUE;
morphbr@841
   725
        }
morphbr@841
   726
morphbr@841
   727
    }
morphbr@841
   728
morphbr@841
   729
    return FALSE;
morphbr@841
   730
}
morphbr@841
   731
morphbr@841
   732
morphbr@841
   733
/*
morphbr@841
   734
 * This should only be used in special situations. We do not know the time that
morphbr@841
   735
 * the recording was set. We just know that it is an "ongoing" record and then
morphbr@841
   736
 * we have to use this to get it's info. It's always the oldest one -> first on list
morphbr@841
   737
 *
morphbr@841
   738
 */
morphbr@841
   739
GMythProgramInfo*
morphbr@841
   740
gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler,
renatofilho@864
   741
                                     guint channel_id)
morphbr@841
   742
{
morphbr@841
   743
    MYSQL_RES      *msql_res;
morphbr@841
   744
    GMythProgramInfo *proginfo = NULL;
morphbr@841
   745
    GString        *query_str = g_string_new("");
morphbr@841
   746
morphbr@841
   747
    assert(scheduler);
morphbr@841
   748
morphbr@841
   749
    g_string_printf(query_str,
morphbr@841
   750
                    "SELECT recorded.chanid,starttime,endtime,title,"
morphbr@841
   751
                    "subtitle,description,channel.channum,"
morphbr@841
   752
                    "channel.callsign,channel.name,channel.commfree,"
morphbr@841
   753
                    "channel.outputfilters,seriesid,programid,filesize,"
morphbr@841
   754
                    "lastmodified,stars,previouslyshown,originalairdate,"
morphbr@841
   755
                    "hostname,recordid,transcoder,playgroup,"
morphbr@841
   756
                    "recorded.recpriority,progstart,progend,basename,recgroup,"
morphbr@841
   757
                    "category,findid,duplicate "
morphbr@841
   758
                    "FROM recorded " "LEFT JOIN channel "
morphbr@841
   759
                    "ON recorded.chanid = channel.chanid "
renatofilho@864
   760
                    "WHERE recorded.chanid = %d "
renatofilho@864
   761
                    "ORDER BY starttime DESC", channel_id);
morphbr@841
   762
morphbr@841
   763
    msql_res =
morphbr@841
   764
        gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
morphbr@841
   765
morphbr@841
   766
    if (msql_res) {
morphbr@841
   767
        MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
morphbr@841
   768
morphbr@841
   769
        if (msql_row) {
morphbr@841
   770
            proginfo = gmyth_program_info_new();
morphbr@841
   771
morphbr@841
   772
            proginfo->chanid = g_string_new(msql_row[0]);
morphbr@841
   773
            proginfo->recstartts = gmyth_util_string_to_time_val(msql_row[1]);
morphbr@841
   774
            proginfo->recendts = gmyth_util_string_to_time_val(msql_row[2]);
morphbr@841
   775
morphbr@841
   776
            proginfo->title = g_string_new(msql_row[3]);
morphbr@841
   777
            proginfo->subtitle = g_string_new(msql_row[4]);
morphbr@841
   778
            proginfo->description = g_string_new(msql_row[5]);
morphbr@841
   779
morphbr@841
   780
            proginfo->chanstr = g_string_new(msql_row[6]);
morphbr@841
   781
            proginfo->chansign = g_string_new(msql_row[7]);
morphbr@841
   782
            proginfo->channame = g_string_new(msql_row[8]);
morphbr@841
   783
            proginfo->chancommfree = (gint) g_ascii_strtoull(msql_row[9], NULL, 10);
morphbr@841
   784
            proginfo->chanOutputFilters = g_string_new(msql_row[10]);
morphbr@841
   785
            proginfo->seriesid = g_string_new(msql_row[11]);
morphbr@841
   786
            proginfo->programid = g_string_new(msql_row[12]);
morphbr@841
   787
            proginfo->filesize = g_ascii_strtoull(msql_row[13], NULL, 10);
morphbr@841
   788
morphbr@841
   789
            proginfo->lastmodified = gmyth_util_string_to_time_val(msql_row[14]);
morphbr@841
   790
            proginfo->stars = g_ascii_strtod(msql_row[15], NULL);
morphbr@841
   791
            proginfo->repeat = (gint)g_ascii_strtoull(msql_row[16], NULL, 10);
morphbr@841
   792
morphbr@841
   793
            if (msql_row[17] == NULL) {
morphbr@841
   794
                proginfo->originalAirDate = 0;
morphbr@841
   795
                proginfo->hasAirDate = FALSE;
morphbr@841
   796
            } else {
morphbr@841
   797
                proginfo->originalAirDate = gmyth_util_string_to_time_val(msql_row[17]);
morphbr@841
   798
                proginfo->hasAirDate = TRUE;
morphbr@841
   799
            }
morphbr@841
   800
morphbr@841
   801
            proginfo->hostname = g_string_new(msql_row[18]);
morphbr@841
   802
            proginfo->recordid = (gint) g_ascii_strtoull(msql_row[19], NULL, 10);
morphbr@841
   803
            proginfo->transcoder = (gint) g_ascii_strtoull(msql_row[20], NULL, 10);
morphbr@841
   804
morphbr@841
   805
            proginfo->playgroup = g_string_new(msql_row[21]);
morphbr@841
   806
            proginfo->recpriority = (gint) g_ascii_strtoull(msql_row[22], NULL, 10);
morphbr@841
   807
morphbr@841
   808
            proginfo->startts = gmyth_util_string_to_time_val(msql_row[23]);
morphbr@841
   809
            proginfo->endts = gmyth_util_string_to_time_val(msql_row[24]);
morphbr@841
   810
            proginfo->pathname = g_string_new(g_strdup(msql_row[25]));
morphbr@841
   811
            proginfo->recgroup = g_string_new(msql_row[26]);
morphbr@841
   812
            proginfo->category = g_string_new(msql_row[27]);
morphbr@841
   813
            proginfo->findid = (gint) g_ascii_strtoull(msql_row[28], NULL, 10);
morphbr@841
   814
morphbr@841
   815
            proginfo->recpriority2 = 0;
morphbr@841
   816
morphbr@841
   817
            g_string_printf(query_str,
morphbr@841
   818
                            "SELECT dupmethod,dupin,parentid,type "
morphbr@841
   819
                            "FROM record WHERE recordid = \"%d\"", proginfo->recordid);
morphbr@841
   820
morphbr@841
   821
            msql_res =
morphbr@841
   822
                gmyth_query_process_statement(scheduler->msqlquery,
morphbr@841
   823
                                              query_str->str);
morphbr@841
   824
morphbr@841
   825
            if (msql_res) {
morphbr@841
   826
                MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
morphbr@841
   827
morphbr@841
   828
                if (msql_row) {
morphbr@841
   829
                    proginfo->dupmethod = (gint) g_ascii_strtoull(msql_row[0], NULL, 10);
morphbr@841
   830
                    proginfo->dupin = (gint) g_ascii_strtoull(msql_row[1], NULL, 10);
morphbr@841
   831
                    proginfo->parentid = (gint) g_ascii_strtoull(msql_row[2], NULL, 10);
morphbr@841
   832
                    proginfo->rectype = 0;
morphbr@841
   833
                }
morphbr@841
   834
            }
morphbr@841
   835
morphbr@841
   836
morphbr@841
   837
            g_string_printf(query_str,
morphbr@841
   838
                            "SELECT sourceid,cardid,cardinputid,shareable "
morphbr@841
   839
                            "FROM cardinput");
morphbr@841
   840
morphbr@841
   841
            msql_res =
morphbr@841
   842
                gmyth_query_process_statement(scheduler->msqlquery,
morphbr@841
   843
                                              query_str->str);
morphbr@841
   844
morphbr@841
   845
            if (msql_res) {
morphbr@841
   846
                MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
morphbr@841
   847
morphbr@841
   848
                if (msql_row) {
morphbr@841
   849
                    proginfo->sourceid = 0;
morphbr@841
   850
                    proginfo->cardid = 0;
morphbr@841
   851
                    proginfo->inputid = 0;
morphbr@841
   852
                    if (msql_row[3] != NULL && g_ascii_strcasecmp("Y", msql_row[3]) == 0)
morphbr@841
   853
                        proginfo->shareable = 1;
morphbr@841
   854
                    else
morphbr@841
   855
                        proginfo->shareable = 0;
morphbr@841
   856
                }
morphbr@841
   857
            }
morphbr@841
   858
morphbr@841
   859
morphbr@841
   860
morphbr@841
   861
        }
morphbr@841
   862
    }
morphbr@841
   863
morphbr@841
   864
    g_string_free(query_str, TRUE);
morphbr@841
   865
    return proginfo;
morphbr@841
   866
}
morphbr@841
   867
leo_sobral@1
   868
/** Retrieves an existing recorded item information from database. The information
leo_sobral@1
   869
 * is used to fill the returned GMythProgramInfo.
leo_sobral@1
   870
 * 
leo_sobral@1
   871
 * @param scheduler The GMythScheduler instance.
leo_sobral@1
   872
 * @param channel The channel associated to the record
leo_sobral@1
   873
 * @param starttime The record start time
leo_sobral@1
   874
 * @return A GMythProgramInfo struct with the requested record item
leo_sobral@1
   875
 * information, or NULL if error.
leo_sobral@1
   876
 */
rosfran@698
   877
GMythProgramInfo *
renatofilho@750
   878
gmyth_scheduler_get_recorded(GMythScheduler * scheduler,
renatofilho@754
   879
                             GString * channel, GTimeVal * starttime)
leo_sobral@1
   880
{
renatofilho@754
   881
    MYSQL_RES      *msql_res;
renatofilho@754
   882
    GMythProgramInfo *proginfo = NULL;
renatofilho@754
   883
    GString        *query_str = g_string_new("");
renatofilho@754
   884
    gchar          *time_str =
renatofilho@754
   885
        gmyth_util_time_to_string_from_time_val(starttime);
leo_sobral@1
   886
renatofilho@754
   887
    assert(scheduler);
melunko@412
   888
renatofilho@754
   889
    gmyth_debug("[%s] channel: %s", __FUNCTION__, channel->str);
rosfran@698
   890
renatofilho@754
   891
    if (scheduler->msqlquery == NULL) {
renatofilho@754
   892
        g_warning("[%s] Scheduler db connection not initialized",
renatofilho@754
   893
                  __FUNCTION__);
renatofilho@754
   894
        return NULL;
renatofilho@754
   895
    }
leo_sobral@1
   896
renatofilho@754
   897
    g_string_printf(query_str,
renatofilho@754
   898
                    "SELECT recorded.chanid,starttime,endtime,title, "
renatofilho@754
   899
                    "subtitle,description,channel.channum, "
renatofilho@754
   900
                    "channel.callsign,channel.name,channel.commfree, "
renatofilho@754
   901
                    "channel.outputfilters,seriesid,programid,filesize, "
renatofilho@754
   902
                    "lastmodified,stars,previouslyshown,originalairdate, "
renatofilho@754
   903
                    "hostname,recordid,transcoder,playgroup, "
renatofilho@754
   904
                    "recorded.recpriority,progstart,progend,basename,recgroup "
renatofilho@754
   905
                    "FROM recorded " "LEFT JOIN channel "
renatofilho@754
   906
                    "ON recorded.chanid = channel.chanid "
renatofilho@754
   907
                    "WHERE recorded.chanid = \"%s\" "
renatofilho@754
   908
                    "AND starttime = \"%s\" ;", channel->str, time_str);
leo_sobral@1
   909
renatofilho@754
   910
    msql_res =
renatofilho@754
   911
        gmyth_query_process_statement(scheduler->msqlquery,
renatofilho@754
   912
                                      query_str->str);
leo_sobral@1
   913
renatofilho@754
   914
    if (msql_res /* && query.size() > 0 */ ) {
renatofilho@754
   915
        MYSQL_ROW       msql_row = mysql_fetch_row(msql_res);
rosfran@698
   916
renatofilho@754
   917
        if (msql_row) {
renatofilho@754
   918
            proginfo = gmyth_program_info_new();
leo_sobral@1
   919
renatofilho@754
   920
            proginfo->chanid = g_string_new(msql_row[0]);
renatofilho@754
   921
            proginfo->startts =
renatofilho@754
   922
                gmyth_util_string_to_time_val(msql_row[23]);
renatofilho@754
   923
            proginfo->endts = gmyth_util_string_to_time_val(msql_row[24]);
renatofilho@754
   924
            proginfo->recstartts =
renatofilho@754
   925
                gmyth_util_string_to_time_val(msql_row[1]);
renatofilho@754
   926
            proginfo->recendts =
renatofilho@754
   927
                gmyth_util_string_to_time_val(msql_row[2]);
renatofilho@754
   928
            proginfo->title = g_string_new(msql_row[3]);
renatofilho@754
   929
            proginfo->subtitle = g_string_new(msql_row[4]);
renatofilho@754
   930
            proginfo->description = g_string_new(msql_row[5]);
leo_sobral@390
   931
renatofilho@754
   932
            proginfo->chanstr = g_string_new(msql_row[6]);
renatofilho@754
   933
            proginfo->chansign = g_string_new(msql_row[7]);
renatofilho@754
   934
            proginfo->channame = g_string_new(msql_row[0]);
renatofilho@754
   935
            proginfo->chancommfree =
renatofilho@754
   936
                (gint) g_ascii_strtoull(msql_row[9], NULL, 10);
renatofilho@754
   937
            proginfo->chanOutputFilters = g_string_new(msql_row[10]);
renatofilho@754
   938
            proginfo->seriesid = g_string_new(msql_row[11]);
renatofilho@754
   939
            proginfo->programid = g_string_new(msql_row[12]);
renatofilho@754
   940
            proginfo->filesize = g_ascii_strtoull(msql_row[13], NULL, 10);
leo_sobral@1
   941
renatofilho@754
   942
            proginfo->lastmodified =
renatofilho@754
   943
                gmyth_util_string_to_time_val(msql_row[14]);
renatofilho@754
   944
            proginfo->stars = g_ascii_strtod(msql_row[15], NULL);
renatofilho@754
   945
            proginfo->repeat =
renatofilho@754
   946
                (gint) g_ascii_strtoull(msql_row[16], NULL, 10);
leo_sobral@390
   947
renatofilho@754
   948
            if (msql_row[17] == NULL) {
renatofilho@754
   949
                proginfo->originalAirDate = 0;
renatofilho@754
   950
                proginfo->hasAirDate = FALSE;
renatofilho@754
   951
            } else {
renatofilho@754
   952
                proginfo->originalAirDate =
renatofilho@754
   953
                    gmyth_util_string_to_time_val(msql_row[17]);
renatofilho@754
   954
                proginfo->hasAirDate = TRUE;
renatofilho@754
   955
            }
leo_sobral@390
   956
renatofilho@754
   957
            proginfo->hostname = g_string_new(msql_row[18]);
renatofilho@754
   958
            proginfo->recordid =
renatofilho@754
   959
                (gint) g_ascii_strtoull(msql_row[19], NULL, 10);
renatofilho@754
   960
            proginfo->transcoder =
renatofilho@754
   961
                (gint) g_ascii_strtoull(msql_row[20], NULL, 10);
renatofilho@754
   962
            // proginfo->spread = -1;
renatofilho@754
   963
            // proginfo->programflags = proginfo->getProgramFlags();
leo_sobral@391
   964
renatofilho@754
   965
            proginfo->recgroup = g_string_new(msql_row[26]);
renatofilho@754
   966
            proginfo->playgroup = g_string_new(msql_row[21]);
renatofilho@754
   967
            proginfo->recpriority =
renatofilho@754
   968
                (gint) g_ascii_strtoull(msql_row[22], NULL, 10);
leo_sobral@391
   969
renatofilho@754
   970
            proginfo->pathname = g_string_new(g_strdup(msql_row[25]));
leo_sobral@391
   971
renatofilho@754
   972
            gmyth_debug("One program info loaded from mysql database\n");
renatofilho@754
   973
        }
renatofilho@754
   974
    }
leo_sobral@1
   975
renatofilho@754
   976
    mysql_free_result(msql_res);
renatofilho@754
   977
    g_string_free(query_str, TRUE);
renatofilho@754
   978
    g_free(time_str);
leo_sobral@1
   979
renatofilho@754
   980
    return proginfo;
leo_sobral@1
   981
}
leo_sobral@1
   982
renatofilho@864
   983
gboolean
renatofilho@864
   984
gmyth_scheduler_stop_recording (GMythScheduler * scheduler,
renatofilho@865
   985
                                gint channel_id)
renatofilho@864
   986
{
renatofilho@864
   987
    GMythProgramInfo *program;
renatofilho@864
   988
    GMythSocket    *socket;
renatofilho@864
   989
    gboolean        res = FALSE;
renatofilho@864
   990
    GMythStringList *slist;
renatofilho@864
   991
renatofilho@864
   992
    socket = gmyth_backend_info_get_connected_socket (scheduler->backend_info);
renatofilho@864
   993
    program = gmyth_scheduler_get_recorded_on_time (scheduler, channel_id);
renatofilho@864
   994
renatofilho@864
   995
    if (program) {
renatofilho@864
   996
        slist = gmyth_string_list_new();
renatofilho@864
   997
        gmyth_string_list_append_char_array(slist, "STOP_RECORDING");
renatofilho@864
   998
renatofilho@864
   999
        gmyth_string_list_append_string(slist, program->title);        /* 0 */
renatofilho@864
  1000
        gmyth_string_list_append_string(slist, program->subtitle);     /* 1 */
renatofilho@864
  1001
        gmyth_string_list_append_string(slist, program->description);  /* 2 */
renatofilho@864
  1002
        gmyth_string_list_append_string(slist, program->category);     /* 3 */
renatofilho@864
  1003
        gmyth_string_list_append_string(slist, program->chanid);       /* 4 */
renatofilho@864
  1004
        gmyth_string_list_append_string(slist, program->chanstr);      /* 5 */
renatofilho@864
  1005
        gmyth_string_list_append_string(slist, program->chansign);     /* 6 */
renatofilho@864
  1006
        gmyth_string_list_append_string(slist, program->channame);     /* 7 */
renatofilho@864
  1007
        gmyth_string_list_append_string(slist, program->pathname);     /* 8 */
renatofilho@864
  1008
        gmyth_string_list_append_int64(slist, program->filesize);      /* 9 */
renatofilho@864
  1009
renatofilho@864
  1010
        if (program->startts)
renatofilho@864
  1011
            gmyth_string_list_append_int(slist, program->startts->tv_sec); /* 10 */
renatofilho@864
  1012
        else
renatofilho@864
  1013
            gmyth_string_list_append_int(slist, 0);
renatofilho@864
  1014
renatofilho@864
  1015
        if (program->endts)
renatofilho@864
  1016
            gmyth_string_list_append_int(slist, program->endts->tv_sec);   /* 11 */
renatofilho@864
  1017
        else
renatofilho@864
  1018
            gmyth_string_list_append_int(slist, 0);
renatofilho@864
  1019
renatofilho@864
  1020
        gmyth_string_list_append_int(slist, program->duplicate);   /* 12 */
renatofilho@864
  1021
        gmyth_string_list_append_int(slist, program->shareable);   /* 13 */
renatofilho@864
  1022
        gmyth_string_list_append_int(slist, program->findid);      /* 14 */
renatofilho@864
  1023
        gmyth_string_list_append_string(slist, program->hostname); /* 15 */
renatofilho@864
  1024
        gmyth_string_list_append_int(slist, program->sourceid);    /* 16 */
renatofilho@864
  1025
        gmyth_string_list_append_int(slist, program->cardid);      /* 17 */
renatofilho@864
  1026
        gmyth_string_list_append_int(slist, program->inputid);     /* 18 */
renatofilho@864
  1027
        gmyth_string_list_append_int(slist, program->recpriority); /* 19 */
renatofilho@864
  1028
renatofilho@864
  1029
        // recstatus == recording
renatofilho@864
  1030
        gmyth_string_list_append_int(slist, -3);                   /* 20 */
renatofilho@864
  1031
renatofilho@864
  1032
        gmyth_string_list_append_int(slist, program->recordid);    /* 21 */
renatofilho@864
  1033
        gmyth_string_list_append_int(slist, program->rectype);     /* 22 */
renatofilho@864
  1034
        gmyth_string_list_append_int(slist, program->dupin);       /* 23 */
renatofilho@864
  1035
        gmyth_string_list_append_int(slist, program->dupmethod);   /* 24 */
renatofilho@864
  1036
renatofilho@864
  1037
renatofilho@864
  1038
        //fixme
renatofilho@864
  1039
        program->recstartts->tv_sec -= (60*60);
renatofilho@864
  1040
renatofilho@864
  1041
        gmyth_string_list_append_int(slist, 
renatofilho@864
  1042
                                     program->recstartts != NULL ?
renatofilho@864
  1043
                                     program->recstartts->tv_sec : 0);   /* 26 */
renatofilho@864
  1044
renatofilho@864
  1045
        gmyth_string_list_append_int(slist, 
renatofilho@864
  1046
                                     program->recendts != NULL ?
renatofilho@864
  1047
                                     program->recendts->tv_sec : 0);    /* 27 */
renatofilho@864
  1048
renatofilho@864
  1049
        gmyth_string_list_append_int(slist, program->repeat);       /* 28 */
renatofilho@864
  1050
        gmyth_string_list_append_int(slist, program->programflags); /* 29 */
renatofilho@864
  1051
renatofilho@864
  1052
        gmyth_string_list_append_char_array(slist, 
renatofilho@864
  1053
                                            program->recgroup != NULL ?
renatofilho@864
  1054
                                            program->recgroup->str : "Default");  /* 30 */
renatofilho@864
  1055
renatofilho@864
  1056
        gmyth_string_list_append_int(slist, program->chancommfree);         /* 31 */
renatofilho@864
  1057
        gmyth_string_list_append_string(slist, program->chanOutputFilters); /* 32 */
renatofilho@864
  1058
        gmyth_string_list_append_string(slist, program->seriesid);          /* 33 */
renatofilho@864
  1059
        gmyth_string_list_append_string(slist, program->programid);         /* 34 */
renatofilho@864
  1060
renatofilho@864
  1061
        gmyth_string_list_append_int(slist,
renatofilho@864
  1062
                                     program->lastmodified != NULL ?
renatofilho@864
  1063
                                     program->lastmodified->tv_sec : 0);   /* 35 */
renatofilho@864
  1064
renatofilho@864
  1065
        gmyth_string_list_append_float(slist, program->stars); /* 36 */
renatofilho@864
  1066
renatofilho@864
  1067
        gmyth_string_list_append_int(slist,
renatofilho@864
  1068
                                     program->originalAirDate != NULL ?
renatofilho@864
  1069
                                     program->originalAirDate->tv_sec : 0); /* 37 */
renatofilho@864
  1070
renatofilho@864
  1071
        gmyth_string_list_append_int(slist, program->hasAirDate);  /* 38 */
renatofilho@864
  1072
renatofilho@864
  1073
        gmyth_string_list_append_char_array(slist,
renatofilho@864
  1074
                                            program->playgroup != NULL ?
renatofilho@864
  1075
                                            program->playgroup->str : "Default");  /* 39 */
renatofilho@864
  1076
renatofilho@864
  1077
        gmyth_string_list_append_int(slist, program->recpriority2); /* 40 */
renatofilho@864
  1078
        gmyth_string_list_append_int(slist, program->recpriority2); /* 40 */
renatofilho@864
  1079
renatofilho@864
  1080
        gmyth_socket_sendreceive_stringlist(socket, slist);
renatofilho@864
  1081
        res = (gmyth_string_list_get_int(slist, 0) == 1);
renatofilho@864
  1082
renatofilho@864
  1083
        g_object_unref (program);
renatofilho@864
  1084
        g_object_unref (slist);
renatofilho@864
  1085
    }
renatofilho@864
  1086
renatofilho@864
  1087
    g_object_unref (socket);
renatofilho@864
  1088
    return res;
renatofilho@864
  1089
}
renatofilho@864
  1090
renatofilho@864
  1091
leo_sobral@1
  1092
/** Notifies the backend of an update in the db.
leo_sobral@1
  1093
 * 
leo_sobral@1
  1094
 * @param record_id the id of the modified recording.
leo_sobral@1
  1095
 */
renatofilho@769
  1096
// fixme: put void and discovery record_id inside
renatofilho@769
  1097
static gboolean
renatofilho@769
  1098
update_backend (GMythScheduler * scheduler, 
renatofilho@769
  1099
                gint record_id)  
leo_sobral@1
  1100
{
renatofilho@754
  1101
    GMythSocket    *socket;
renatofilho@754
  1102
    GMythStringList *strlist = gmyth_string_list_new();
renatofilho@754
  1103
    GString        *datastr = g_string_new("RESCHEDULE_RECORDINGS ");
renatofilho@754
  1104
    gboolean        ret = FALSE;
leo_sobral@1
  1105
renatofilho@754
  1106
    g_string_append_printf(datastr, "%d", record_id);
renatofilho@754
  1107
    gmyth_string_list_append_string(strlist, datastr);
leo_sobral@1
  1108
renatofilho@769
  1109
    socket = gmyth_backend_info_get_connected_socket (scheduler->backend_info);
renatofilho@769
  1110
    if (socket != NULL) { 
renatofilho@754
  1111
        ret = (gmyth_socket_sendreceive_stringlist(socket, strlist) > 0);
renatofilho@769
  1112
        g_object_unref (socket);
renatofilho@754
  1113
    } else {
renatofilho@754
  1114
        g_warning("[%s] Connection to backend failed!", __FUNCTION__);
renatofilho@754
  1115
    }
rosfran@698
  1116
renatofilho@754
  1117
    g_string_free(datastr, TRUE);
renatofilho@754
  1118
    g_object_unref(strlist);
renatofilho@754
  1119
    return ret;
leo_sobral@1
  1120
}
renatofilho@129
  1121
renatofilho@129
  1122
void
renatofilho@750
  1123
gmyth_scheduler_recorded_info_get_preview(RecordedInfo * info,
renatofilho@754
  1124
                                          GByteArray * data)
renatofilho@129
  1125
{
renatofilho@129
  1126
}
renatofilho@129
  1127
renatofilho@129
  1128
void
renatofilho@750
  1129
gmyth_recorded_info_free(RecordedInfo * info)
renatofilho@129
  1130
{
renatofilho@754
  1131
    if (info->title != NULL)
renatofilho@754
  1132
        g_string_free(info->title, TRUE);
renatofilho@129
  1133
renatofilho@754
  1134
    if (info->subtitle != NULL)
renatofilho@754
  1135
        g_string_free(info->subtitle, TRUE);
renatofilho@129
  1136
renatofilho@754
  1137
    if (info->description != NULL)
renatofilho@754
  1138
        g_string_free(info->description, TRUE);
renatofilho@129
  1139
renatofilho@754
  1140
    if (info->category != NULL)
renatofilho@754
  1141
        g_string_free(info->category, TRUE);
renatofilho@129
  1142
renatofilho@754
  1143
    if (info->basename != NULL)
renatofilho@754
  1144
        g_string_free(info->basename, TRUE);
renatofilho@129
  1145
renatofilho@754
  1146
    if (info != NULL)
renatofilho@754
  1147
        g_free(info->start_time);
leo_sobral@387
  1148
renatofilho@754
  1149
    if (info != NULL)
renatofilho@754
  1150
        g_free(info->end_time);
leo_sobral@387
  1151
renatofilho@754
  1152
    g_free(info);
renatofilho@129
  1153
}
renatofilho@129
  1154
melunko@591
  1155
static void
renatofilho@750
  1156
free_recorded_info_item(gpointer data, gpointer user_data)
melunko@591
  1157
{
renatofilho@754
  1158
    RecordedInfo   *info = (RecordedInfo *) data;
melunko@591
  1159
renatofilho@754
  1160
    gmyth_recorded_info_free(info);
melunko@591
  1161
}
melunko@591
  1162
renatofilho@129
  1163
void
renatofilho@750
  1164
gmyth_recorded_info_list_free(GList * list)
renatofilho@129
  1165
{
renatofilho@754
  1166
    g_return_if_fail(list != NULL);
melunko@591
  1167
renatofilho@754
  1168
    g_list_foreach(list, free_recorded_info_item, NULL);
renatofilho@754
  1169
    g_list_free(list);
melunko@591
  1170
}
melunko@591
  1171
melunko@591
  1172
void
renatofilho@750
  1173
gmyth_schedule_info_free(ScheduleInfo * info)
melunko@591
  1174
{
melunko@591
  1175
renatofilho@754
  1176
    g_return_if_fail(info != NULL);
melunko@591
  1177
renatofilho@754
  1178
    if (info->title != NULL)
renatofilho@754
  1179
        g_string_free(info->title, TRUE);
renatofilho@129
  1180
renatofilho@754
  1181
    if (info->subtitle != NULL)
renatofilho@754
  1182
        g_string_free(info->subtitle, TRUE);
renatofilho@129
  1183
renatofilho@754
  1184
    if (info->description != NULL)
renatofilho@754
  1185
        g_string_free(info->description, TRUE);
renatofilho@129
  1186
renatofilho@754
  1187
    if (info->category != NULL)
renatofilho@754
  1188
        g_string_free(info->category, TRUE);
renatofilho@129
  1189
renatofilho@754
  1190
    if (info != NULL)
renatofilho@754
  1191
        g_free(info->start_time);
leo_sobral@387
  1192
renatofilho@754
  1193
    if (info != NULL)
renatofilho@754
  1194
        g_free(info->end_time);
leo_sobral@387
  1195
renatofilho@754
  1196
    g_free(info);
renatofilho@129
  1197
}
renatofilho@129
  1198
melunko@591
  1199
static void
renatofilho@750
  1200
free_schedule_info_item(gpointer data, gpointer user_data)
melunko@591
  1201
{
renatofilho@754
  1202
    ScheduleInfo   *info = (ScheduleInfo *) data;
melunko@591
  1203
renatofilho@754
  1204
    gmyth_schedule_info_free(info);
melunko@591
  1205
}
melunko@591
  1206
melunko@591
  1207
void
renatofilho@750
  1208
gmyth_schedule_info_list_free(GList * list)
melunko@591
  1209
{
renatofilho@754
  1210
    g_return_if_fail(list != NULL);
melunko@591
  1211
renatofilho@754
  1212
    g_list_foreach(list, free_schedule_info_item, NULL);
renatofilho@754
  1213
    g_list_free(list);
melunko@591
  1214
}