From: <me...@us...> - 2007-08-21 15:02:20
|
Revision: 820 http://gmyth.svn.sourceforge.net/gmyth/?rev=820&view=rev Author: melunko Date: 2007-08-21 08:02:24 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Added gmyth_scheduler_add_exception() function to remove only one schedule when all occurrences options has been used. Modified Paths: -------------- trunk/gmyth/src/gmyth_scheduler.c trunk/gmyth/src/gmyth_scheduler.h Modified: trunk/gmyth/src/gmyth_scheduler.c =================================================================== --- trunk/gmyth/src/gmyth_scheduler.c 2007-08-20 20:26:20 UTC (rev 819) +++ trunk/gmyth/src/gmyth_scheduler.c 2007-08-21 15:02:24 UTC (rev 820) @@ -418,7 +418,7 @@ _set_int_value(GMythQuery * myth_query, char *field, gint value, gint rec_id) { - gchar *str_value = g_strdup_printf("%d", value); + gchar *str_value = g_strdup_printf("%d", value); _set_value(myth_query, field, str_value, rec_id); g_free(str_value); @@ -500,9 +500,13 @@ _set_value(scheduler->msqlquery, "search", "0", rec_id); if (type == GMYTH_SCHEDULE_ALL_OCCURRENCES) { - _set_value(scheduler->msqlquery, "type", "4", rec_id); - } else { - _set_value(scheduler->msqlquery, "type", "1", rec_id); + _set_int_value(scheduler->msqlquery, "type", 4, rec_id); + } else if (type == GMYTH_SCHEDULE_ONE_OCCURRENCE) { + _set_int_value(scheduler->msqlquery, "type", 1, rec_id); + } else if (type == GMYTH_SCHEDULE_EXCEPTION) { + _set_int_value(scheduler->msqlquery, "type", 8, rec_id); + _set_int_value(scheduler->msqlquery, "parentid", schedule_info->parentid, + rec_id); } _set_value(scheduler->msqlquery, "recpriority", "0", rec_id); @@ -556,26 +560,28 @@ /** Requests the Mysql database in the backend to remove an existing schedule. * * @param scheduler the GMythScheduler instance. - * @param record_id The schedule's record id to be removed + * @param schedule_id The schedule's record id to be removed * @return gboolean TRUE if success, FALSE if error */ gboolean -gmyth_scheduler_delete_schedule(GMythScheduler * scheduler, gint record_id) +gmyth_scheduler_delete_schedule(GMythScheduler * scheduler, gint schedule_id) { MYSQL_RES *msql_res; - GString *query_str = g_string_new(""); + GString *query_str = NULL; - assert(scheduler); + g_return_val_if_fail (scheduler != NULL, FALSE); + if (scheduler->msqlquery == NULL) { g_warning("[%s] Scheduler db connection not initialized", __FUNCTION__); return FALSE; } - // ======================================== + + query_str = g_string_new(""); g_string_printf(query_str, - "DELETE FROM record WHERE recordid=%d", record_id); + "DELETE FROM record WHERE recordid=%d", schedule_id); msql_res = gmyth_query_process_statement(scheduler->msqlquery, @@ -586,9 +592,33 @@ g_string_free(query_str, TRUE); // Notify the backend of the changes - return update_backend(scheduler, record_id); + return update_backend(scheduler, schedule_id); } +/* + * Add an exception program to be removed from the schedule list, when programs + * where scheduled with the GMYTH_SCHEDULE_ALL_OCCURRENCES option. + * @param scheduler the GMythScheduler instance. + * @param schedule_id the schedule id of the all occurrence schedule to be changed + * @param exception_info the ScheduleInfo to be removed from all schedule occurrences + * @return TRUE if success, FALSE if any error happens + */ +gboolean +gmyth_scheduler_add_exception (GMythScheduler *scheduler, gint schedule_id, + ScheduleInfo *exception_info) +{ + GString *query_str; + gboolean res; + + g_return_val_if_fail (scheduler != NULL, FALSE); + g_return_val_if_fail (exception_info != NULL, FALSE); + + exception_info->parentid = schedule_id; + res = gmyth_scheduler_add_schedule_full (scheduler, exception_info, GMYTH_SCHEDULE_EXCEPTION); + + return res; +} + /** Requests the Mysql database in the backend to remove an existing recorded item. * * @param scheduler the GMythScheduler instance. Modified: trunk/gmyth/src/gmyth_scheduler.h =================================================================== --- trunk/gmyth/src/gmyth_scheduler.h 2007-08-20 20:26:20 UTC (rev 819) +++ trunk/gmyth/src/gmyth_scheduler.h 2007-08-21 15:02:24 UTC (rev 820) @@ -39,7 +39,8 @@ typedef enum { GMYTH_SCHEDULE_ONE_OCCURRENCE, - GMYTH_SCHEDULE_ALL_OCCURRENCES + GMYTH_SCHEDULE_ALL_OCCURRENCES, + GMYTH_SCHEDULE_EXCEPTION } GMythScheduleType; @@ -109,6 +110,8 @@ GString *description; GString *category; + gint parentid; + } ScheduleInfo; typedef struct { @@ -153,7 +156,10 @@ ScheduleInfo * schedule_info); gboolean gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler, ScheduleInfo * schedule_info, GMythScheduleType type); +gboolean gmyth_scheduler_add_exception (GMythScheduler *scheduler, gint schedule_id, + ScheduleInfo *exception_info); + gint gmyth_scheduler_delete_schedule (GMythScheduler * scheduler, gint record_id); gint gmyth_scheduler_delete_recorded (GMythScheduler * scheduler, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |