4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
5 * @author Renato Filho <renato.filho@indt.org.br>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <glib/gi18n.h>
30 #include <gmyth/gmyth.h>
31 #include <dbus/dbus-glib-bindings.h>
33 #include "gmyth-dbus-common.h"
34 #include "gmyth-dbus-server.h"
36 #define MYTH_DEFAULT_DB "mythconverg"
40 GMYTH_DBUS_ERROR_MYTHTV,
41 GMYTH_DBUS_ERROR_CONNECTION,
43 GMYTH_DBUS_ERROR_SCHEDULE
46 #define GMYTH_DBUS_ERROR gmyth_dbus_error_quark ()
49 gmyth_dbus_error_quark (void)
51 return g_quark_from_static_string ("gmyth-dbus-error-quark");
54 typedef struct _GMythDbusServerPrivate GMythDbusServerPrivate;
56 struct _GMythDbusServerPrivate
58 GMythBackendInfo *myth_backend;
61 GMythScheduler *myth_scheduler;
64 #define GMYTH_DBUS_SERVER_GET_PRIVATE(o) \
65 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GMYTH_DBUS_SERVER_TYPE, GMythDbusServerPrivate))
67 static void gmyth_dbus_server_class_init (GMythDbusServerClass *klass);
68 static void gmyth_dbus_server_init (GMythDbusServer *self);
69 static void gmyth_dbus_server_dispose (GObject *object);
70 static void gmyth_dbus_server_finalize (GObject *object);
73 static gboolean gmyth_dbus_server_connect (GObject *obj,
77 const gchar *password,
80 static gboolean gmyth_dbus_server_get_channel_list (GObject *obj,
83 static gboolean gmyth_dbus_server_get_channel_info (GObject *obj,
87 static gboolean gmyth_dbus_server_file_exists (GObject *obj,
88 const gchar *file_name,
91 static gboolean gmyth_dbus_server_get_recorded_list (GObject *obj,
94 static gboolean gmyth_dbus_server_get_recorded_info (GObject *obj,
95 const gchar *basename,
98 static gboolean gmyth_dbus_server_get_program_list (GObject *obj,
100 const gchar *start_time,
101 const gchar *end_time,
102 GPtrArray **program_list,
104 static gboolean gmyth_dbus_server_get_schedule_list (GObject *obj,
105 GPtrArray **schedule_list,
107 static gboolean gmyth_dbus_server_connected (GObject *obj,
110 static gboolean gmyth_dbus_server_disconnect (GObject *obj,
112 static gboolean gmyth_dbus_server_get_server_info (GObject *obj,
113 guint64 *total_space,
117 static gboolean gmyth_dbus_server_get_thumbnail (GObject *obj,
121 static gboolean gmyth_dbus_server_get_channel_icon (GObject *obj,
125 static gboolean gmyth_dbus_server_stop_recording (GObject *obj,
129 static gboolean gmyth_dbus_server_add_schedule (GObject *obj,
132 const gchar *start_time,
133 const gchar *end_time,
135 const gchar *description,
138 static gboolean gmyth_dbus_server_add_exception (GObject *obj,
142 const gchar *start_time,
143 const gchar *end_time,
144 const gchar *description,
146 static gboolean gmyth_dbus_server_remove_schedule (GObject *obj,
151 #include "gmyth-dbus-server-glue.h"
154 G_DEFINE_TYPE (GMythDbusServer, gmyth_dbus_server, G_TYPE_OBJECT);
157 gmyth_dbus_server_class_init (GMythDbusServerClass *klass)
159 GObjectClass *object_class = G_OBJECT_CLASS (klass);
161 g_type_class_add_private (klass, sizeof (GMythDbusServerPrivate));
163 object_class->dispose = gmyth_dbus_server_dispose;
164 object_class->finalize = gmyth_dbus_server_finalize;
166 dbus_g_object_type_install_info (GMYTH_DBUS_SERVER_TYPE,
167 &dbus_glib_gmyth_dbus_server_object_info);
171 gmyth_dbus_server_init (GMythDbusServer *self)
176 gmyth_dbus_server_dispose (GObject *object)
178 G_OBJECT_CLASS (gmyth_dbus_server_parent_class)->dispose (object);
182 gmyth_dbus_server_finalize (GObject *object)
184 G_OBJECT_CLASS (gmyth_dbus_server_parent_class)->finalize (object);
188 gmyth_dbus_server_connect_epg (GMythDbusServer *server, GError **error)
190 GMythDbusServerPrivate *priv;
191 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (server);
193 if (!priv->connected)
197 GMYTH_DBUS_ERROR_CONNECTION,
205 priv->myth_epg = gmyth_epg_new();
206 if (!gmyth_epg_connect (priv->myth_epg, priv->myth_backend))
208 g_object_unref (priv->myth_epg);
209 priv->myth_epg = NULL;
213 GMYTH_DBUS_ERROR_EPG,
214 _("Fail to connect with EPG"));
224 gmyth_dbus_server_connect_scheduler (GMythDbusServer *server,
227 GMythDbusServerPrivate *priv;
228 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (server);
230 if (!priv->connected)
234 GMYTH_DBUS_ERROR_CONNECTION,
240 if (!priv->myth_scheduler)
242 priv->myth_scheduler = gmyth_scheduler_new ();
243 if (!gmyth_scheduler_connect (priv->myth_scheduler,
246 g_object_unref (priv->myth_scheduler);
247 priv->myth_scheduler = NULL;
251 GMYTH_DBUS_ERROR_SCHEDULE,
252 _("Fail to connect with Schedule"));
262 gmyth_dbus_server_connect (GObject *obj,
266 const gchar *password,
271 GMythDbusServerPrivate *priv;
273 g_debug ("%s:%d", __FUNCTION__, __LINE__);
275 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
279 gmyth_dbus_server_disconnect (obj, NULL);
282 priv->myth_backend = gmyth_backend_info_new_full (host,
288 s = gmyth_backend_info_get_connected_socket (priv->myth_backend);
296 g_object_unref (priv->myth_backend);
297 priv->myth_backend = NULL;
302 GMYTH_DBUS_ERROR_CONNECTION,
303 _("Fail to connect with backend"));
306 priv->connected = *result;
311 gmyth_dbus_server_connected (GObject *obj,
315 GMythDbusServerPrivate *priv;
317 g_debug ("%s:%d", __FUNCTION__, __LINE__);
319 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
321 if (priv->myth_backend)
329 gmyth_dbus_server_disconnect (GObject *obj,
332 GMythDbusServerPrivate *priv;
334 g_debug ("%s:%d", __FUNCTION__, __LINE__);
336 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
340 g_object_unref (priv->myth_epg);
341 priv->myth_epg = NULL;
345 if (priv->myth_backend)
347 g_object_unref (priv->myth_backend);
348 priv->myth_backend = NULL;
351 if (priv->myth_scheduler)
353 g_object_unref (priv->myth_scheduler);
354 priv->myth_scheduler = NULL;
362 gmyth_dbus_server_get_server_info (GObject *obj,
363 guint64 *total_space,
368 GMythBackendDetails *details;
369 GMythDbusServerPrivate *priv;
370 gboolean ret = FALSE;
373 g_debug ("%s:%d", __FUNCTION__, __LINE__);
374 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
376 g_return_val_if_fail (priv->myth_backend != NULL, FALSE);
378 socket = gmyth_backend_info_get_connected_socket (priv->myth_backend);
384 GMYTH_DBUS_ERROR_MYTHTV,
385 _("MythTv not avaliable"));
391 gmyth_util_get_backend_details (socket,
395 *total_space = details->total_space;
396 *used_space = details->used_space;
397 *free_space = *total_space - *used_space;
398 gmyth_util_backend_details_free (details);
406 GMYTH_DBUS_ERROR_MYTHTV,
407 _("Fail to get MythTv details"));
410 g_object_unref (socket);
417 gmyth_dbus_server_parse_channel_info (GMythChannelInfo *info,
420 dbus_g_type_struct_set (val,
422 1, info->channel_num->str,
423 2, info->channel_name->str,
424 3, info->channel_icon->str,
429 gmyth_dbus_server_get_channel_info (GObject *obj,
435 GMythChannelInfo *ch_info;
436 GMythDbusServerPrivate *priv;
438 g_debug ("%s:%d", __FUNCTION__, __LINE__);
439 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
441 g_return_val_if_fail (priv->myth_backend != NULL, FALSE);
443 if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj), error))
448 ch_type = GMYTH_DBUS_CHANNEL_G_TYPE;
450 ch_info = gmyth_epg_get_channel_info (priv->myth_epg, channel_id);
454 g_value_init (&v, ch_type);
455 g_value_take_boxed (&v, dbus_g_type_specialized_construct (ch_type));
456 gmyth_dbus_server_parse_channel_info (ch_info, &v);
458 *info = g_value_get_boxed (&v);
465 GMYTH_DBUS_ERROR_EPG,
466 _("no channel info avaliable"));
474 gmyth_dbus_server_get_channel_list (GObject *obj,
475 GPtrArray **channels,
482 GMythDbusServerPrivate *priv;
484 g_debug ("%s:%d", __FUNCTION__, __LINE__);
485 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
487 g_return_val_if_fail (priv->myth_backend != NULL, FALSE);
488 if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj), error))
493 len = gmyth_epg_get_channel_list (priv->myth_epg, &lst);
495 *channels = g_ptr_array_sized_new (len);
496 ch_type = GMYTH_DBUS_CHANNEL_G_TYPE;
498 for (walk = lst; walk != NULL; walk = walk->next)
501 GMythChannelInfo *data;
503 data = (GMythChannelInfo *) walk->data;
505 g_value_init (&ch, ch_type);
506 g_value_take_boxed (&ch, dbus_g_type_specialized_construct (ch_type));
507 gmyth_dbus_server_parse_channel_info (data, &ch);
508 g_ptr_array_add (*channels, g_value_get_boxed (&ch));
511 gmyth_free_channel_list (lst);
516 gmyth_dbus_server_file_exists (GObject *obj,
517 const gchar *file_name,
521 GMythDbusServerPrivate *priv;
522 g_debug ("%s:%d", __FUNCTION__, __LINE__);
523 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
525 g_return_val_if_fail (priv->myth_backend, FALSE);
527 *exists = gmyth_util_file_exists (priv->myth_backend, file_name);
533 gmyth_dbus_server_get_program_list (GObject *obj,
535 const gchar *start_time,
536 const gchar *end_time,
537 GPtrArray **programs,
544 GTimeVal start_time_val;
545 GTimeVal end_time_val;
546 GMythDbusServerPrivate *priv;
548 g_debug ("%s:%d", __FUNCTION__, __LINE__);
549 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
551 g_return_val_if_fail (priv->myth_backend, FALSE);
552 if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj), error))
555 g_time_val_from_iso8601 (start_time, &start_time_val);
556 g_time_val_from_iso8601 (end_time, &end_time_val);
559 len = gmyth_epg_get_program_list (priv->myth_epg,
565 *programs = g_ptr_array_sized_new (len);
566 program_type = GMYTH_DBUS_PROGRAM_G_TYPE;
568 for (walk = list; walk != NULL; walk = walk->next)
570 GValue program = { 0, };
573 GMythProgramInfo *data;
575 data = (GMythProgramInfo *) walk->data;
580 g_value_init (&program, program_type);
581 g_value_take_boxed (&program,
582 dbus_g_type_specialized_construct (program_type));
584 start_str = g_time_val_to_iso8601 (data->startts);
585 end_str = g_time_val_to_iso8601 (data->endts);
587 dbus_g_type_struct_set (&program,
588 0, data->chanid->str,
592 4, data->subtitle->str,
593 5, data->description->str,
594 6, data->category->str,
597 g_ptr_array_add (*programs, g_value_get_boxed (&program));
603 gmyth_free_program_list (list);
605 g_debug ("%s:%d", __FUNCTION__, __LINE__);
610 gmyth_dbus_server_parse_recorded_info (RecordedInfo *info,
616 start_str = g_time_val_to_iso8601 (info->start_time);
617 end_str = g_time_val_to_iso8601 (info->end_time);
619 dbus_g_type_struct_set (val,
626 6, info->subtitle->str,
627 7, info->description->str,
628 8, info->category->str,
629 9, info->basename->str,
637 gmyth_dbus_server_get_recorded_info (GObject *obj,
638 const gchar *basename,
643 GMythDbusServerPrivate *priv;
644 RecordedInfo *record_info;
647 g_debug ("%s:%d", __FUNCTION__, __LINE__);
648 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
650 g_return_val_if_fail (priv->myth_backend, FALSE);
652 if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
655 record_type = GMYTH_DBUS_RECORD_G_TYPE;
657 record_info = gmyth_scheduler_get_recorded_info (priv->myth_scheduler,
664 g_value_init (&r, record_type);
665 g_value_take_boxed (&r,
666 dbus_g_type_specialized_construct (record_type));
668 gmyth_dbus_server_parse_recorded_info (record_info, &r);
669 gmyth_recorded_info_free (record_info);
671 *info = g_value_get_boxed (&r);
679 GMYTH_DBUS_ERROR_EPG,
680 _("no record info avaliable"));
689 gmyth_dbus_server_get_recorded_list (GObject *obj,
697 GMythDbusServerPrivate *priv;
699 g_debug ("%s:%d", __FUNCTION__, __LINE__);
700 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
702 g_return_val_if_fail (priv->myth_backend != NULL, FALSE);
703 if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
707 len = gmyth_scheduler_get_recorded_list (priv->myth_scheduler,
710 record_type = GMYTH_DBUS_RECORD_G_TYPE;
711 *records = g_ptr_array_sized_new (len);
713 for (walk = list; walk != NULL; walk = walk->next)
715 GValue record = { 0, };
718 data = (RecordedInfo *) walk->data;
720 g_value_init (&record, record_type);
721 g_value_take_boxed (&record,
722 dbus_g_type_specialized_construct (record_type));
724 gmyth_dbus_server_parse_recorded_info (data, &record);
726 g_ptr_array_add (*records, g_value_get_boxed (&record));
727 //g_value_unset (&record);
730 gmyth_recorded_info_list_free (list);
737 gmyth_dbus_server_get_schedule_list (GObject *obj,
738 GPtrArray **schedules,
745 GMythDbusServerPrivate *priv;
747 g_debug ("%s:%d", __FUNCTION__, __LINE__);
748 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
750 g_return_val_if_fail (priv->myth_backend, FALSE);
751 if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
755 len = gmyth_scheduler_get_schedule_list (priv->myth_scheduler,
758 *schedules = g_ptr_array_sized_new (len);
759 schedule_type = GMYTH_DBUS_SCHEDULE_G_TYPE;
761 for (walk = list; walk != NULL; walk = walk->next)
763 GValue schedule = { 0, };
765 gchar *start_str_time;
768 data = (ScheduleInfo *) walk->data;
770 g_value_init (&schedule, schedule_type);
771 g_value_take_boxed (&schedule,
772 dbus_g_type_specialized_construct (schedule_type));
774 start_str_time = g_time_val_to_iso8601 (data->start_time);
775 end_str_time = g_time_val_to_iso8601 (data->end_time);
777 dbus_g_type_struct_set (&schedule,
778 0, data->schedule_id,
784 6, data->subtitle->str,
785 7, data->description->str,
786 8, data->category->str,
790 g_ptr_array_add (*schedules, g_value_get_boxed (&schedule));
792 g_free (start_str_time);
793 g_free (end_str_time);
796 gmyth_schedule_info_list_free (list);
803 gmyth_dbus_server_get_thumbnail (GObject *obj,
808 GMythFileTransfer *file_transfer;
810 GMythFileReadResult result;
811 GMythDbusServerPrivate *priv;
813 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
815 file_transfer = NULL;
817 g_return_val_if_fail (priv->myth_backend, FALSE);
819 if (!gmyth_util_file_exists (priv->myth_backend, uri))
823 GMYTH_DBUS_ERROR_MYTHTV,
824 _("File not exists"));
829 file_transfer = gmyth_file_transfer_new (priv->myth_backend);
831 if (!gmyth_file_transfer_open (file_transfer, uri))
835 GMYTH_DBUS_ERROR_MYTHTV,
836 _("Fail to open file"));
840 filesize = gmyth_file_transfer_get_filesize (file_transfer);
844 *image = g_byte_array_new ();
845 result = gmyth_file_transfer_read (file_transfer, *image, filesize, FALSE);
846 if (result == GMYTH_FILE_READ_ERROR)
850 GMYTH_DBUS_ERROR_MYTHTV,
851 _("Fail to read file"));
856 gmyth_file_transfer_close (file_transfer);
857 g_object_unref (file_transfer);
859 if (filesize > (*image)->len)
863 GMYTH_DBUS_ERROR_MYTHTV,
873 g_byte_array_free (*image, TRUE);
874 g_object_unref(file_transfer);
879 gmyth_dbus_server_get_channel_icon (GObject *obj,
884 GMythChannelInfo *channel = NULL;
887 GMythDbusServerPrivate *priv;
889 g_debug ("%s:%d", __FUNCTION__, __LINE__);
890 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
891 g_return_val_if_fail (priv->myth_backend, FALSE);
893 channel = gmyth_epg_get_channel_info (priv->myth_epg,
902 GMYTH_DBUS_ERROR_MYTHTV,
903 _("Invalid channel"));
908 if (!gmyth_epg_channel_has_icon(priv->myth_epg, channel))
910 gmyth_channel_info_free (channel);
913 GMYTH_DBUS_ERROR_MYTHTV,
914 _("Channel does not have icon available"));
921 if (!gmyth_epg_channel_get_icon (priv->myth_epg,
926 gmyth_channel_info_free (channel);
929 GMYTH_DBUS_ERROR_MYTHTV,
930 _("Could not get channel icon for channel id = %u"),
935 *icon = g_byte_array_sized_new (icon_length);
936 *icon = g_byte_array_append (*icon, icon_data, icon_length);
939 gmyth_channel_info_free(channel);
945 gmyth_dbus_server_stop_recording (GObject *obj,
950 gboolean ret = FALSE;
951 GMythDbusServerPrivate *priv;
953 g_debug ("%s:%d", __FUNCTION__, __LINE__);
954 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
956 g_return_val_if_fail (priv->myth_backend, FALSE);
957 if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
960 ret = gmyth_scheduler_stop_recording (priv->myth_scheduler,
967 gmyth_dbus_server_new_schedule_info (const gchar* description,
970 GTimeVal *start_vtime,
973 ScheduleInfo *new_sched_info;
975 new_sched_info = g_new0(ScheduleInfo, 1);
977 /* record_id == -1 for generating a new id */
978 new_sched_info->schedule_id = -1;
980 new_sched_info->channel_id = channel_id;
981 new_sched_info->program_id = program_id;
982 new_sched_info->start_time = g_new0 (GTimeVal, 1);
983 *new_sched_info->start_time = *start_vtime;
984 new_sched_info->end_time = g_new0 (GTimeVal, 1);
985 *new_sched_info->end_time = *end_vtime;
987 /* TODO: there is no frequency field */
988 /*new_sched_info->frequency = -1;*/
990 if (description != NULL) {
991 /* FIXME: description parameter is used as title and description */
992 new_sched_info->title = g_string_new(description);
993 new_sched_info->description = g_string_new(description);
996 return new_sched_info;
1000 gmyth_dbus_server_add_schedule (GObject *obj,
1003 const gchar *start_time,
1004 const gchar *end_time,
1006 const gchar *description,
1010 ScheduleInfo *sch_info;
1011 GTimeVal start_vtime;
1013 GMythDbusServerPrivate *priv;
1015 g_debug ("%s:%d", __FUNCTION__, __LINE__);
1016 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
1020 g_return_val_if_fail (priv->myth_backend, FALSE);
1022 if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
1026 g_time_val_from_iso8601 (start_time, &start_vtime);
1027 g_time_val_from_iso8601 (end_time, &end_vtime);
1028 sch_info = gmyth_dbus_server_new_schedule_info (description,
1033 if (sch_info != NULL) {
1034 GMythScheduleType type;
1036 gboolean has_record;
1039 GMYTH_SCHEDULE_ALL_OCCURRENCES :
1040 GMYTH_SCHEDULE_ONE_OCCURRENCE);
1042 g_get_current_time (&t_now);
1044 has_record = gmyth_scheduler_was_recorded_before (priv->myth_scheduler,
1046 (time_t) start_vtime.tv_sec);
1049 if ((t_now.tv_sec >= start_vtime.tv_sec)
1050 && (t_now.tv_sec <= end_vtime.tv_sec) && has_record)
1052 GMythSocket *socket;
1053 gboolean res = FALSE;
1055 socket = gmyth_backend_info_get_connected_socket (priv->myth_backend);
1056 res = gmyth_scheduler_reactivate_schedule(priv->myth_scheduler,
1058 (time_t) start_vtime.tv_sec);
1060 GMythStringList *slist = gmyth_string_list_new();
1062 gmyth_string_list_append_char_array(slist, "RESCHEDULE_RECORDINGS 0");
1063 gmyth_socket_sendreceive_stringlist(socket, slist);
1064 res = (gmyth_string_list_get_int(slist, 0) == 1);
1065 g_object_unref(slist);
1068 g_object_unref(socket);
1073 if (!gmyth_scheduler_add_schedule_full (priv->myth_scheduler,
1077 g_warning("Could not add schedule entry");
1081 (*schedule_id) = sch_info->schedule_id;
1082 gmyth_schedule_info_free (sch_info);
1090 gmyth_dbus_server_add_exception (GObject *obj,
1094 const gchar *start_time,
1095 const gchar *end_time,
1096 const gchar *description,
1099 ScheduleInfo *sch_info;
1100 GTimeVal start_vtime;
1102 GMythDbusServerPrivate *priv;
1104 g_debug ("%s:%d", __FUNCTION__, __LINE__);
1105 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
1107 g_return_val_if_fail (priv->myth_backend, FALSE);
1109 if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
1112 g_time_val_from_iso8601 (start_time, &start_vtime);
1113 g_time_val_from_iso8601 (end_time, &end_vtime);
1115 sch_info = gmyth_dbus_server_new_schedule_info (description,
1120 if (sch_info != NULL)
1122 if (!gmyth_scheduler_add_exception (priv->myth_scheduler,
1126 g_warning ("Could not add schedule exception");
1127 gmyth_schedule_info_free (sch_info);
1131 gmyth_schedule_info_free (sch_info);
1138 gmyth_dbus_server_remove_schedule (GObject *obj,
1142 GMythDbusServerPrivate *priv;
1144 g_debug ("%s:%d", __FUNCTION__, __LINE__);
1145 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
1147 g_return_val_if_fail (priv->myth_backend, FALSE);
1149 if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
1152 return gmyth_scheduler_delete_schedule (priv->myth_scheduler, schedule_id);
1156 gmyth_dbus_server_start_dbus_service (void)
1158 GError *error = NULL;
1160 DBusGConnection *bus;
1162 GMythDbusServer *self;
1164 self = g_object_new (GMYTH_DBUS_SERVER_TYPE, NULL);
1165 g_return_val_if_fail (self, FALSE);
1167 /* TODO: should verify if this service was already started */
1169 /* connect to session bus */
1170 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
1173 g_warning ("Could not connect to dbus: %s", error->message);
1174 g_error_free (error);
1178 /* register dbus object */
1179 dbus_g_connection_register_g_object (bus,
1180 GMYTH_DBUS_SERVER_PATH, G_OBJECT (self));
1182 proxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_DBUS,
1183 DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
1185 /* registering download manager service */
1186 if (!org_freedesktop_DBus_request_name (proxy, GMYTH_DBUS_SERVER_IFACE,
1187 0, &request_ret, &error))
1189 g_warning ("Unable to register dbus service: %d %s",
1190 error->code, error->message);
1191 g_error_free (error);
1195 if (request_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
1197 g_warning ("Got result code %u from requesting name", request_ret);
1204 g_object_unref (self);