[svn r870] created function stop recording trunk
authorrenatofilho
Wed Oct 24 18:41:42 2007 +0100 (2007-10-24)
branchtrunk
changeset 86456cfd1feef30
parent 863 c25708b9b1e3
child 865 3eeb6b565018
[svn r870] created function stop recording
gmyth/src/gmyth_backendinfo.h
gmyth/src/gmyth_scheduler.c
gmyth/src/gmyth_scheduler.h
     1.1 --- a/gmyth/src/gmyth_backendinfo.h	Tue Oct 23 13:58:20 2007 +0100
     1.2 +++ b/gmyth/src/gmyth_backendinfo.h	Wed Oct 24 18:41:42 2007 +0100
     1.3 @@ -116,7 +116,6 @@
     1.4  gboolean            gmyth_backend_info_is_local_file    (GMythBackendInfo   *backend_info);
     1.5  GMythSocket*        gmyth_backend_info_get_connected_socket
     1.6                                                          (GMythBackendInfo   *backend_info);
     1.7 -                                                           
     1.8  
     1.9  G_END_DECLS
    1.10  #endif                          /* __GMYTH_BACKEND_INFO_H__ */
     2.1 --- a/gmyth/src/gmyth_scheduler.c	Tue Oct 23 13:58:20 2007 +0100
     2.2 +++ b/gmyth/src/gmyth_scheduler.c	Wed Oct 24 18:41:42 2007 +0100
     2.3 @@ -738,7 +738,7 @@
     2.4   */
     2.5  GMythProgramInfo*
     2.6  gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler,
     2.7 -                                     GString* channel)
     2.8 +                                     guint channel_id)
     2.9  {
    2.10      MYSQL_RES      *msql_res;
    2.11      GMythProgramInfo *proginfo = NULL;
    2.12 @@ -757,8 +757,8 @@
    2.13                      "category,findid,duplicate "
    2.14                      "FROM recorded " "LEFT JOIN channel "
    2.15                      "ON recorded.chanid = channel.chanid "
    2.16 -                    "WHERE recorded.chanid = \"%s\" "
    2.17 -                    "ORDER BY starttime DESC", channel->str);
    2.18 +                    "WHERE recorded.chanid = %d "
    2.19 +                    "ORDER BY starttime DESC", channel_id);
    2.20  
    2.21      msql_res =
    2.22          gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
    2.23 @@ -980,6 +980,116 @@
    2.24      return proginfo;
    2.25  }
    2.26  
    2.27 +gboolean
    2.28 +gmyth_scheduler_stop_recording (GMythScheduler * scheduler,
    2.29 +                                gint channel_id,
    2.30 +                                time_t start)
    2.31 +{
    2.32 +    GMythProgramInfo *program;
    2.33 +    GMythSocket    *socket;
    2.34 +    gboolean        res = FALSE;
    2.35 +    GMythStringList *slist;
    2.36 +
    2.37 +    socket = gmyth_backend_info_get_connected_socket (scheduler->backend_info);
    2.38 +    program = gmyth_scheduler_get_recorded_on_time (scheduler, channel_id);
    2.39 +
    2.40 +    if (program) {
    2.41 +        slist = gmyth_string_list_new();
    2.42 +        gmyth_string_list_append_char_array(slist, "STOP_RECORDING");
    2.43 +
    2.44 +        gmyth_string_list_append_string(slist, program->title);        /* 0 */
    2.45 +        gmyth_string_list_append_string(slist, program->subtitle);     /* 1 */
    2.46 +        gmyth_string_list_append_string(slist, program->description);  /* 2 */
    2.47 +        gmyth_string_list_append_string(slist, program->category);     /* 3 */
    2.48 +        gmyth_string_list_append_string(slist, program->chanid);       /* 4 */
    2.49 +        gmyth_string_list_append_string(slist, program->chanstr);      /* 5 */
    2.50 +        gmyth_string_list_append_string(slist, program->chansign);     /* 6 */
    2.51 +        gmyth_string_list_append_string(slist, program->channame);     /* 7 */
    2.52 +        gmyth_string_list_append_string(slist, program->pathname);     /* 8 */
    2.53 +        gmyth_string_list_append_int64(slist, program->filesize);      /* 9 */
    2.54 +
    2.55 +        if (program->startts)
    2.56 +            gmyth_string_list_append_int(slist, program->startts->tv_sec); /* 10 */
    2.57 +        else
    2.58 +            gmyth_string_list_append_int(slist, 0);
    2.59 +
    2.60 +        if (program->endts)
    2.61 +            gmyth_string_list_append_int(slist, program->endts->tv_sec);   /* 11 */
    2.62 +        else
    2.63 +            gmyth_string_list_append_int(slist, 0);
    2.64 +
    2.65 +        gmyth_string_list_append_int(slist, program->duplicate);   /* 12 */
    2.66 +        gmyth_string_list_append_int(slist, program->shareable);   /* 13 */
    2.67 +        gmyth_string_list_append_int(slist, program->findid);      /* 14 */
    2.68 +        gmyth_string_list_append_string(slist, program->hostname); /* 15 */
    2.69 +        gmyth_string_list_append_int(slist, program->sourceid);    /* 16 */
    2.70 +        gmyth_string_list_append_int(slist, program->cardid);      /* 17 */
    2.71 +        gmyth_string_list_append_int(slist, program->inputid);     /* 18 */
    2.72 +        gmyth_string_list_append_int(slist, program->recpriority); /* 19 */
    2.73 +
    2.74 +        // recstatus == recording
    2.75 +        gmyth_string_list_append_int(slist, -3);                   /* 20 */
    2.76 +
    2.77 +        gmyth_string_list_append_int(slist, program->recordid);    /* 21 */
    2.78 +        gmyth_string_list_append_int(slist, program->rectype);     /* 22 */
    2.79 +        gmyth_string_list_append_int(slist, program->dupin);       /* 23 */
    2.80 +        gmyth_string_list_append_int(slist, program->dupmethod);   /* 24 */
    2.81 +
    2.82 +
    2.83 +        //fixme
    2.84 +        program->recstartts->tv_sec -= (60*60);
    2.85 +
    2.86 +        gmyth_string_list_append_int(slist, 
    2.87 +                                     program->recstartts != NULL ?
    2.88 +                                     program->recstartts->tv_sec : 0);   /* 26 */
    2.89 +
    2.90 +        gmyth_string_list_append_int(slist, 
    2.91 +                                     program->recendts != NULL ?
    2.92 +                                     program->recendts->tv_sec : 0);    /* 27 */
    2.93 +
    2.94 +        gmyth_string_list_append_int(slist, program->repeat);       /* 28 */
    2.95 +        gmyth_string_list_append_int(slist, program->programflags); /* 29 */
    2.96 +
    2.97 +        gmyth_string_list_append_char_array(slist, 
    2.98 +                                            program->recgroup != NULL ?
    2.99 +                                            program->recgroup->str : "Default");  /* 30 */
   2.100 +
   2.101 +        gmyth_string_list_append_int(slist, program->chancommfree);         /* 31 */
   2.102 +        gmyth_string_list_append_string(slist, program->chanOutputFilters); /* 32 */
   2.103 +        gmyth_string_list_append_string(slist, program->seriesid);          /* 33 */
   2.104 +        gmyth_string_list_append_string(slist, program->programid);         /* 34 */
   2.105 +
   2.106 +        gmyth_string_list_append_int(slist,
   2.107 +                                     program->lastmodified != NULL ?
   2.108 +                                     program->lastmodified->tv_sec : 0);   /* 35 */
   2.109 +
   2.110 +        gmyth_string_list_append_float(slist, program->stars); /* 36 */
   2.111 +
   2.112 +        gmyth_string_list_append_int(slist,
   2.113 +                                     program->originalAirDate != NULL ?
   2.114 +                                     program->originalAirDate->tv_sec : 0); /* 37 */
   2.115 +
   2.116 +        gmyth_string_list_append_int(slist, program->hasAirDate);  /* 38 */
   2.117 +
   2.118 +        gmyth_string_list_append_char_array(slist,
   2.119 +                                            program->playgroup != NULL ?
   2.120 +                                            program->playgroup->str : "Default");  /* 39 */
   2.121 +
   2.122 +        gmyth_string_list_append_int(slist, program->recpriority2); /* 40 */
   2.123 +        gmyth_string_list_append_int(slist, program->recpriority2); /* 40 */
   2.124 +
   2.125 +        gmyth_socket_sendreceive_stringlist(socket, slist);
   2.126 +        res = (gmyth_string_list_get_int(slist, 0) == 1);
   2.127 +
   2.128 +        g_object_unref (program);
   2.129 +        g_object_unref (slist);
   2.130 +    }
   2.131 +
   2.132 +    g_object_unref (socket);
   2.133 +    return res;
   2.134 +}
   2.135 +
   2.136 +
   2.137  /** Notifies the backend of an update in the db.
   2.138   * 
   2.139   * @param record_id the id of the modified recording.
     3.1 --- a/gmyth/src/gmyth_scheduler.h	Tue Oct 23 13:58:20 2007 +0100
     3.2 +++ b/gmyth/src/gmyth_scheduler.h	Wed Oct 24 18:41:42 2007 +0100
     3.3 @@ -136,52 +136,55 @@
     3.4  } RecordedInfo;
     3.5  
     3.6  
     3.7 -GType           gmyth_scheduler_get_type            (void);
     3.8 +GType               gmyth_scheduler_get_type                (void);
     3.9  
    3.10 -GMythScheduler *gmyth_scheduler_new                 (void);
    3.11 -gboolean        gmyth_scheduler_connect             (GMythScheduler * scheduler,
    3.12 -                                                     GMythBackendInfo * backend_info);
    3.13 -gboolean        gmyth_scheduler_connect_with_timeout(GMythScheduler * scheduler,
    3.14 -                                                     GMythBackendInfo * backend_info,
    3.15 -                                                     guint timeout);
    3.16 -gboolean        gmyth_scheduler_disconnect          (GMythScheduler * scheduler);
    3.17 -gint            gmyth_scheduler_get_schedule_list   (GMythScheduler * scheduler,
    3.18 -                                                     GList ** sched_list);
    3.19 -gint            gmyth_scheduler_get_recorded_list   (GMythScheduler * scheduler,
    3.20 -                                                     GList ** rec_list);
    3.21 -RecordedInfo*   gmyth_scheduler_get_recorded_info   (GMythScheduler *scheduler,
    3.22 -                                                     const char *basename);
    3.23 +GMythScheduler*     gmyth_scheduler_new                     (void);
    3.24 +gboolean            gmyth_scheduler_connect                 (GMythScheduler * scheduler,
    3.25 +                                                             GMythBackendInfo * backend_info);
    3.26 +gboolean            gmyth_scheduler_connect_with_timeout    (GMythScheduler * scheduler,
    3.27 +                                                             GMythBackendInfo * backend_info,
    3.28 +                                                             guint timeout);
    3.29 +gboolean            gmyth_scheduler_disconnect              (GMythScheduler * scheduler);
    3.30 +gint                gmyth_scheduler_get_schedule_list       (GMythScheduler * scheduler,
    3.31 +                                                             GList ** sched_list);
    3.32 +gint                gmyth_scheduler_get_recorded_list       (GMythScheduler * scheduler,
    3.33 +                                                             GList ** rec_list);
    3.34 +RecordedInfo*       gmyth_scheduler_get_recorded_info       (GMythScheduler *scheduler,
    3.35 +                                                             const char *basename);
    3.36 +gboolean            gmyth_scheduler_was_recorded_before     (GMythScheduler* scheduler,
    3.37 +                                                             gint channel_id,
    3.38 +                                                             time_t start_time);
    3.39 +gboolean            gmyth_scheduler_reactivate_schedule     (GMythScheduler* scheduler,
    3.40 +                                                             gint channel_id,
    3.41 +                                                             time_t start_time);
    3.42 +GMythProgramInfo*   gmyth_scheduler_get_recorded_on_time    (GMythScheduler* scheduler,
    3.43 +                                                             guint channel_id);
    3.44 +GMythProgramInfo*   gmyth_scheduler_get_recorded            (GMythScheduler * scheduler,
    3.45 +                                                             GString * channel,
    3.46 +                                                             GTimeVal * starttime);
    3.47 +gint                gmyth_scheduler_add_schedule            (GMythScheduler * scheduler,
    3.48 +                                                             ScheduleInfo * schedule_info);
    3.49 +gboolean            gmyth_scheduler_add_schedule_full       (GMythScheduler * scheduler,
    3.50 +                                                             ScheduleInfo * schedule_info,
    3.51 +                                                             GMythScheduleType type);
    3.52 +gboolean            gmyth_scheduler_add_exception           (GMythScheduler *scheduler,
    3.53 +                                                             gint schedule_id,
    3.54 +                                                             ScheduleInfo *exception_info);
    3.55 +gint                gmyth_scheduler_delete_schedule         (GMythScheduler * scheduler,
    3.56 +                                                             gint record_id);
    3.57 +gint                gmyth_scheduler_delete_recorded         (GMythScheduler * scheduler,
    3.58 +                                                             gint record_id);
    3.59 +gboolean            gmyth_scheduler_stop_recording          (GMythScheduler * scheduler,
    3.60 +                                                             gint channel_id,
    3.61 +                                                             time_t start);
    3.62 +void                gmyth_scheduler_recorded_info_get_preview(RecordedInfo * info,
    3.63 +                                                             GByteArray * data);
    3.64  
    3.65 -gboolean gmyth_scheduler_was_recorded_before(GMythScheduler* scheduler, gint channel_id,
    3.66 -                                             time_t start_time);
    3.67  
    3.68 -gboolean gmyth_scheduler_reactivate_schedule(GMythScheduler* scheduler, gint channel_id,
    3.69 -                                             time_t start_time);
    3.70 -GMythProgramInfo*
    3.71 -gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler,
    3.72 -                                     GString* channel);
    3.73 -GMythProgramInfo *gmyth_scheduler_get_recorded      (GMythScheduler * scheduler,
    3.74 -                                                     GString * channel,
    3.75 -                                                     GTimeVal * starttime);
    3.76 -gint            gmyth_scheduler_add_schedule        (GMythScheduler * scheduler,
    3.77 -                                                     ScheduleInfo * schedule_info);
    3.78 -gboolean        gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler,
    3.79 -                             ScheduleInfo * schedule_info, GMythScheduleType type);
    3.80 -gboolean        gmyth_scheduler_add_exception (GMythScheduler *scheduler, gint schedule_id,
    3.81 -                             ScheduleInfo *exception_info);
    3.82 -
    3.83 -
    3.84 -gint            gmyth_scheduler_delete_schedule     (GMythScheduler * scheduler,
    3.85 -                                                     gint record_id);
    3.86 -gint            gmyth_scheduler_delete_recorded     (GMythScheduler * scheduler,
    3.87 -                                                     gint record_id);
    3.88 -void            gmyth_scheduler_recorded_info_get_preview
    3.89 -                                                    (RecordedInfo * info,
    3.90 -                                                     GByteArray * data);
    3.91 -void            gmyth_recorded_info_free            (RecordedInfo * info);
    3.92 -void            gmyth_schedule_info_free            (ScheduleInfo * info);
    3.93 -void            gmyth_recorded_info_list_free       (GList * list);
    3.94 -void            gmyth_schedule_info_list_free       (GList * list);
    3.95 +void                gmyth_recorded_info_free                (RecordedInfo * info);
    3.96 +void                gmyth_schedule_info_free                (ScheduleInfo * info);
    3.97 +void                gmyth_recorded_info_list_free           (GList * list);
    3.98 +void                gmyth_schedule_info_list_free           (GList * list);
    3.99  
   3.100  G_END_DECLS
   3.101  #endif                          /* __GMYTH_SCHEDULER_H__ */