|
From: <me...@us...> - 2008-03-14 13:13:20
|
Revision: 953
http://gmyth.svn.sourceforge.net/gmyth/?rev=953&view=rev
Author: melunko
Date: 2008-03-14 06:13:18 -0700 (Fri, 14 Mar 2008)
Log Message:
-----------
Added several functions to handle with schedule exceptions
Modified Paths:
--------------
trunk/gmyth/gmyth/gmyth_remote_util.c
trunk/gmyth/gmyth/gmyth_scheduler.c
trunk/gmyth/gmyth/gmyth_scheduler.h
Modified: trunk/gmyth/gmyth/gmyth_remote_util.c
===================================================================
--- trunk/gmyth/gmyth/gmyth_remote_util.c 2008-03-14 12:45:05 UTC (rev 952)
+++ trunk/gmyth/gmyth/gmyth_remote_util.c 2008-03-14 13:13:18 UTC (rev 953)
@@ -158,7 +158,6 @@
gint recorder_num = (gint) g_ascii_strtoull (row[0], NULL, 10);
GString *hostname = g_string_new (binfo->hostname);
- g_debug ("XXXXXXXXXXXX Recorded found: %d", recorder_num);
recorder = gmyth_recorder_new (recorder_num, hostname, binfo->port);
if (gmyth_recorder_setup (recorder)) {
*list = g_list_append(*list, recorder);
Modified: trunk/gmyth/gmyth/gmyth_scheduler.c
===================================================================
--- trunk/gmyth/gmyth/gmyth_scheduler.c 2008-03-14 12:45:05 UTC (rev 952)
+++ trunk/gmyth/gmyth/gmyth_scheduler.c 2008-03-14 13:13:18 UTC (rev 953)
@@ -273,7 +273,6 @@
GList ** schedule_list,
gchar *filter)
{
-
ScheduleInfo *schedule;
MYSQL_RES *msql_res;
GString *query_str = g_string_new("");
@@ -965,6 +964,133 @@
return res;
}
+gboolean
+gmyth_scheduler_is_exception (GMythScheduler *scheduler, ScheduleInfo *sch_info,
+ gint *recordid, gint *parentid)
+{
+ MYSQL_RES *msql_res;
+ gboolean ret = FALSE;
+ gchar *query_str;
+ gchar *start_time, *start_date;
+ gchar *end_time, *end_date;
+
+ g_return_val_if_fail (scheduler != NULL, FALSE);
+ g_return_val_if_fail (sch_info != NULL, FALSE);
+
+ if (scheduler->msqlquery == NULL) {
+ g_warning("[%s] Scheduler db connection not initialized", __FUNCTION__);
+ return FALSE;
+ }
+
+ start_time = gmyth_util_time_to_string_only_time (sch_info->start_time);
+ start_date = gmyth_util_time_to_string_only_date (sch_info->start_time);
+
+ end_time = gmyth_util_time_to_string_only_time (sch_info->end_time);
+ end_date = gmyth_util_time_to_string_only_date (sch_info->end_time);
+
+ query_str = g_strdup_printf ("SELECT recordid,parentid FROM record WHERE type=8 and "
+ "chanid=\"%d\" and starttime=\"%s\" and startdate=\"%s\" and "
+ "endtime=\"%s\" and enddate=\"%s\";", sch_info->channel_id,
+ start_time, start_date, end_time, end_date);
+
+ msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str);
+
+ if (msql_res == NULL) {
+ g_warning("DB retrieval of exception schedule info failed");
+ goto clean_me;
+ } else {
+ MYSQL_ROW row = mysql_fetch_row(msql_res);
+ if (row) {
+ *recordid = g_ascii_strtoull (row[0], NULL, 10);
+ *parentid = g_ascii_strtoull (row[1], NULL, 10);
+
+ ret = TRUE;
+ }
+
+ mysql_free_result(msql_res);
+ }
+
+clean_me:
+ g_free (start_time);
+ g_free (start_date);
+ g_free (end_time);
+ g_free (end_date);
+ g_free (query_str);
+
+ return ret;
+}
+
+gboolean
+gmyth_scheduler_remove_all_exceptions (GMythScheduler *scheduler, gint parentid)
+{
+ MYSQL_RES *msql_res;
+ gboolean ret = FALSE;
+ gchar *list_query;
+
+ g_return_val_if_fail (scheduler != NULL, FALSE);
+
+ if (scheduler->msqlquery == NULL) {
+ g_warning("[%s] Scheduler db connection not initialized", __FUNCTION__);
+ return FALSE;
+ }
+
+ list_query = g_strdup_printf ("SELECT recordid FROM record WHERE parentid=%d;",
+ parentid);
+
+ msql_res = gmyth_query_process_statement(scheduler->msqlquery, list_query);
+
+ if (msql_res == NULL) {
+ g_warning("DB retrieval of schedule list failed");
+ goto clean_me;
+ } else {
+ MYSQL_ROW row;
+
+ while ((row = mysql_fetch_row(msql_res)) != NULL) {
+
+ gint recordid = g_ascii_strtoull (row[0], NULL, 10);
+ ret = gmyth_scheduler_remove_exception (scheduler, recordid);
+ if (!ret) {
+ g_warning ("Fail to remove schedule exception");
+ break;
+ }
+ }
+
+ mysql_free_result(msql_res);
+ }
+
+clean_me:
+ g_free (list_query);
+
+ return ret;
+}
+
+gboolean
+gmyth_scheduler_remove_exception (GMythScheduler *scheduler, gint scheduleid)
+{
+ MYSQL_RES *msql_res;
+ gchar *query_str = NULL;
+
+ 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_strdup_printf ("DELETE FROM record WHERE recordid=%d", scheduleid);
+
+ msql_res = gmyth_query_process_statement(scheduler->msqlquery,
+ query_str);
+
+ mysql_free_result(msql_res);
+ g_free (query_str);
+
+ // Notify the backend of the changes
+ return update_backend(scheduler, scheduleid);
+}
+
+
/** Requests the Mysql database in the backend to remove an existing recorded item.
*
* @param scheduler the GMythScheduler instance.
Modified: trunk/gmyth/gmyth/gmyth_scheduler.h
===================================================================
--- trunk/gmyth/gmyth/gmyth_scheduler.h 2008-03-14 12:45:05 UTC (rev 952)
+++ trunk/gmyth/gmyth/gmyth_scheduler.h 2008-03-14 13:13:18 UTC (rev 953)
@@ -167,9 +167,19 @@
gboolean gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler,
ScheduleInfo * schedule_info,
GMythScheduleType type);
+
+/* Schedule exception handling. When one program is not part of an "all schedule programs */
gboolean gmyth_scheduler_add_exception (GMythScheduler *scheduler,
gint schedule_id,
ScheduleInfo *exception_info);
+gboolean gmyth_scheduler_is_exception (GMythScheduler *scheduler,
+ ScheduleInfo *sch_info,
+ gint *recordid, gint *parentid);
+gboolean gmyth_scheduler_remove_all_exceptions (GMythScheduler *scheduler,
+ gint parentid);
+gboolean gmyth_scheduler_remove_exception (GMythScheduler *scheduler,
+ gint scheduleid);
+
gboolean 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.
|