aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/planner.c31
-rw-r--r--src/planner.h38
2 files changed, 61 insertions, 8 deletions
diff --git a/src/planner.c b/src/planner.c
index 1643651..124aeae 100644
--- a/src/planner.c
+++ b/src/planner.c
@@ -178,17 +178,44 @@ compare_appointments_by_start_time (gconstpointer ga, gconstpointer gb)
return g_date_time_compare (a->begin, b->begin);
}
+void
+indicator_datetime_planner_get_appointments (IndicatorDatetimePlanner * self,
+ GDateTime * begin,
+ GDateTime * end,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ IndicatorDatetimePlannerClass * klass;
+
+ g_return_if_fail (INDICATOR_IS_DATETIME_PLANNER (self));
+
+ klass = INDICATOR_DATETIME_PLANNER_GET_CLASS (self);
+ g_return_if_fail (klass->get_appointments != NULL);
+ klass->get_appointments (self, begin, end, callback, user_data);
+}
+
GSList *
-indicator_datetime_planner_get_appointments (IndicatorDatetimePlanner * self, GDateTime * begin, GDateTime * end)
+indicator_datetime_planner_get_appointments_finish (IndicatorDatetimePlanner * self,
+ GAsyncResult * res,
+ GError ** error)
{
+ IndicatorDatetimePlannerClass * klass;
GSList * appointments;
g_return_val_if_fail (INDICATOR_IS_DATETIME_PLANNER (self), NULL);
- appointments = INDICATOR_DATETIME_PLANNER_GET_CLASS (self)->get_appointments (self, begin, end);
+ klass = INDICATOR_DATETIME_PLANNER_GET_CLASS (self);
+ g_return_val_if_fail (klass->get_appointments_finish != NULL, NULL);
+ appointments = klass->get_appointments_finish (self, res, error);
return g_slist_sort (appointments, compare_appointments_by_start_time);
}
+void
+indicator_datetime_planner_free_appointments (GSList * l)
+{
+ g_slist_free_full (l, (GDestroyNotify)indicator_datetime_appt_free);
+}
+
gboolean
indicator_datetime_planner_is_configured (IndicatorDatetimePlanner * self)
{
diff --git a/src/planner.h b/src/planner.h
index f6148c6..206bfe5 100644
--- a/src/planner.h
+++ b/src/planner.h
@@ -22,6 +22,7 @@
#include <glib.h>
#include <glib-object.h> /* parent class */
+#include <gio/gio.h>
G_BEGIN_DECLS
@@ -70,7 +71,16 @@ struct _IndicatorDatetimePlannerClass
/* virtual functions */
- GSList* (*get_appointments) (IndicatorDatetimePlanner * self, GDateTime * begin, GDateTime * end);
+ void (*get_appointments) (IndicatorDatetimePlanner * self,
+ GDateTime * begin,
+ GDateTime * end,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GSList* (*get_appointments_finish) (IndicatorDatetimePlanner * self,
+ GAsyncResult * res,
+ GError ** error);
+
gboolean (*is_configured) (IndicatorDatetimePlanner * self);
void (*activate) (IndicatorDatetimePlanner * self);
@@ -85,17 +95,33 @@ void indicator_datetime_appt_free (struct IndicatorDatetimeAppt * appt);
/**
* Get a list of appointments, sorted by start time.
+ */
+void indicator_datetime_planner_get_appointments (IndicatorDatetimePlanner * self,
+ GDateTime * begin,
+ GDateTime * end,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+/**
+ * Finishes the async call begun with indicator_datetime_planner_get_appointments()
*
- * An easy way to free the list properly in one step is as follows:
- *
- * g_slist_free_full (list, (GDestroyNotify)indicator_datetime_appt_free);
- *
+ * To free the list properly, use indicator_datetime_planner_free_appointments()
*
* Return value: (element-type IndicatorDatetimeAppt)
* (transfer full):
* list of appointments
*/
-GSList * indicator_datetime_planner_get_appointments (IndicatorDatetimePlanner * self, GDateTime * begin, GDateTime * end);
+GSList * indicator_datetime_planner_get_appointments_finish (IndicatorDatetimePlanner * self,
+ GAsyncResult * res,
+ GError ** error);
+
+/**
+ * Convenience function for freeing a GSList of IndicatorDatetimeAppt.
+ *
+ * Equivalent to g_slist_free_full (list, (GDestroyNotify)indicator_datetime_appt_free);
+ */
+void indicator_datetime_planner_free_appointments (GSList *);
+
/**
* Returns false if the planner's backend is not configured.