emit the status
authorChangeLog <jpr@ximian.com>
Tue, 11 Nov 2003 16:59:04 +0000 (16:59 +0000)
committerJP Rosevear <jpr@src.gnome.org>
Tue, 11 Nov 2003 16:59:04 +0000 (16:59 +0000)
2003-11-11  ChangeLog <jpr@ximian.com>

* libecal/e-cal.c (e_cal_class_init): emit the status

* libecal/e-cal.h: remove open status enums, use calendar status
instead

* libecal/client-test.c (create_client): just directly open the
calendar, no need to be async

calendar/ChangeLog
calendar/libecal/client-test.c
calendar/libecal/e-cal.c
calendar/libecal/e-cal.h

index d66a048..7433a61 100644 (file)
@@ -1,3 +1,13 @@
+2003-11-11  ChangeLog <jpr@ximian.com>
+
+       * libecal/e-cal.c (e_cal_class_init): emit the status
+
+       * libecal/e-cal.h: remove open status enums, use calendar status
+       instead
+
+       * libecal/client-test.c (create_client): just directly open the
+       calendar, no need to be async
+
 2003-11-11  Dan Winship  <danw@ximian.com>
 
        * libedata-cal/e-cal-backend-sexp.c: Make the time-related sexp
index 7d57d0b..a7a5c5e 100644 (file)
@@ -73,9 +73,9 @@ objects_removed_cb (GObject *object, GList *objects, gpointer data)
 }
 
 static void
-query_done_cb (GObject *object, ECalendarStatus status, gpointer data)
+view_done_cb (GObject *object, ECalendarStatus status, gpointer data)
 {
-       cl_printf (data, "Query done\n");
+       cl_printf (data, "View done\n");
 }
 
 /* Lists the UIDs of objects in a calendar, called as an idle handler */
@@ -121,40 +121,6 @@ list_uids (gpointer data)
        return FALSE;
 }
 
-/* Callback used when a calendar is opened */
-static void
-cal_opened_cb (ECal *client, ECalOpenStatus status, gpointer data)
-{
-       ECalView *query;
-       
-       cl_printf (client, "Load/create %s\n",
-                  ((status == E_CAL_OPEN_SUCCESS) ? "success" :
-                   (status == E_CAL_OPEN_ERROR) ? "error" :
-                   (status == E_CAL_OPEN_NOT_FOUND) ? "not found" :
-                   (status == E_CAL_OPEN_METHOD_NOT_SUPPORTED) ? "method not supported" :
-                   "unknown status value"));
-
-       if (status == E_CAL_OPEN_SUCCESS) {
-               if (!e_cal_get_query (client, "(contains? \"any\" \"Test4\")", &query, NULL))
-                       g_warning (G_STRLOC ": Unable to obtain query");
-
-               g_signal_connect (G_OBJECT (query), "objects_added", 
-                                 G_CALLBACK (objects_added_cb), client);
-               g_signal_connect (G_OBJECT (query), "objects_modified", 
-                                 G_CALLBACK (objects_modified_cb), client);
-               g_signal_connect (G_OBJECT (query), "objects_removed", 
-                                 G_CALLBACK (objects_removed_cb), client);
-               g_signal_connect (G_OBJECT (query), "query_done",
-                                 G_CALLBACK (query_done_cb), client);
-
-               e_cal_view_start (query);
-               
-               g_idle_add (list_uids, client);
-       }
-       else
-               g_object_unref (client);
-}
-
 /* Callback used when a client is destroyed */
 static void
 client_destroy_cb (gpointer data, GObject *object)
@@ -174,6 +140,9 @@ client_destroy_cb (gpointer data, GObject *object)
 static void
 create_client (ECal **client, const char *uri, CalObjType type, gboolean only_if_exists)
 {
+       ECalView *query;
+       GError *error = NULL;
+       
        *client = e_cal_new (uri, type);
        if (!*client) {
                g_message (G_STRLOC ": could not create the client");
@@ -182,17 +151,30 @@ create_client (ECal **client, const char *uri, CalObjType type, gboolean only_if
 
        g_object_weak_ref (G_OBJECT (*client), client_destroy_cb, NULL);
 
-       g_signal_connect (*client, "cal_opened",
-                         G_CALLBACK (cal_opened_cb),
-                         NULL);
-
-       printf ("Calendar loading `%s'...\n", uri);
-
-       if (!e_cal_open (*client, only_if_exists, NULL)) {
-               g_message (G_STRLOC ": failure when issuing calendar open request `%s'",
-                          uri);
+       cl_printf (*client, "Calendar loading `%s'...\n", uri);
+       if (!e_cal_open (*client, only_if_exists, &error)) {
+               cl_printf (*client, "Load/create %s\n", error->message);
                exit (1);
        }
+       g_clear_error (&error);
+       
+       if (!e_cal_get_query (*client, "(contains? \"any\" \"Test4\")", &query, NULL)) {
+               cl_printf (*client, G_STRLOC ": Unable to obtain query");
+               exit (1);               
+       }
+       
+       g_signal_connect (G_OBJECT (query), "objects_added", 
+                         G_CALLBACK (objects_added_cb), client);
+       g_signal_connect (G_OBJECT (query), "objects_modified", 
+                         G_CALLBACK (objects_modified_cb), client);
+       g_signal_connect (G_OBJECT (query), "objects_removed", 
+                         G_CALLBACK (objects_removed_cb), client);
+       g_signal_connect (G_OBJECT (query), "view_done",
+                         G_CALLBACK (view_done_cb), client);
+       
+       e_cal_view_start (query);
+       
+       g_idle_add (list_uids, *client);
 }
 
 int
index d2160d7..eafb934 100644 (file)
@@ -146,27 +146,6 @@ e_calendar_error_quark (void)
 }
 
 GType
-e_cal_open_status_enum_get_type (void)
-{
-       static GType e_cal_open_status_enum_type = 0;
-
-       if (!e_cal_open_status_enum_type) {
-               static GEnumValue values [] = {
-                 { E_CAL_OPEN_SUCCESS,              "ECalOpenSuccess",            "success"     },
-                 { E_CAL_OPEN_ERROR,                "ECalOpenError",              "error"       },
-                 { E_CAL_OPEN_NOT_FOUND,            "ECalOpenNotFound",           "not-found"   },
-                 { E_CAL_OPEN_PERMISSION_DENIED,    "ECalOpenPermissionDenied",   "denied"      },
-                 { E_CAL_OPEN_METHOD_NOT_SUPPORTED, "ECalOpenMethodNotSupported", "unsupported" },
-                 { -1,                                   NULL,                              NULL          }
-               };
-
-               e_cal_open_status_enum_type = g_enum_register_static ("ECalOpenStatusEnum", values);
-       }
-
-       return e_cal_open_status_enum_type;
-}
-
-GType
 e_cal_set_mode_status_enum_get_type (void)
 {
        static GType e_cal_set_mode_status_enum_type = 0;
@@ -875,7 +854,7 @@ cal_set_mode_cb (ECalListener *listener,
        ecal = E_CAL (data);
        priv = ecal->priv;
 
-       ecal_status = E_CAL_OPEN_ERROR;
+       ecal_status = E_CAL_SET_MODE_ERROR;
 
        switch (status) {
        case GNOME_Evolution_Calendar_CalListener_MODE_SET:
@@ -1129,9 +1108,8 @@ e_cal_class_init (ECalClass *klass)
                              G_SIGNAL_RUN_FIRST,
                              G_STRUCT_OFFSET (ECalClass, cal_opened),
                              NULL, NULL,
-                             g_cclosure_marshal_VOID__ENUM,
-                             G_TYPE_NONE, 1,
-                             E_CAL_OPEN_STATUS_ENUM_TYPE);
+                             g_cclosure_marshal_VOID__INT,
+                             G_TYPE_NONE, 1, G_TYPE_INT);
        e_cal_signals[CAL_SET_MODE] =
                g_signal_new ("cal_set_mode",
                              G_TYPE_FROM_CLASS (klass),
index 7f224f2..8fb12dd 100644 (file)
@@ -37,7 +37,6 @@ G_BEGIN_DECLS
 #define E_IS_CAL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL))
 #define E_IS_CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL))
 
-#define E_CAL_OPEN_STATUS_ENUM_TYPE     (e_cal_open_status_enum_get_type ())
 #define E_CAL_SET_MODE_STATUS_ENUM_TYPE (e_cal_set_mode_status_enum_get_type ())
 #define CAL_MODE_ENUM_TYPE                   (cal_mode_enum_get_type ())
 
@@ -45,15 +44,6 @@ typedef struct _ECal ECal;
 typedef struct _ECalClass ECalClass;
 typedef struct _ECalPrivate ECalPrivate;
 
-/* Open status for the cal_opened signal */
-typedef enum {
-       E_CAL_OPEN_SUCCESS,
-       E_CAL_OPEN_ERROR,
-       E_CAL_OPEN_NOT_FOUND,
-       E_CAL_OPEN_PERMISSION_DENIED,
-       E_CAL_OPEN_METHOD_NOT_SUPPORTED
-} ECalOpenStatus;
-
 /* Set mode status for the e_cal_set_mode function */
 typedef enum {
        E_CAL_SET_MODE_SUCCESS,
@@ -80,7 +70,7 @@ struct _ECalClass {
 
        /* Notification signals */
 
-       void (* cal_opened) (ECal *ecal, ECalOpenStatus status);
+       void (* cal_opened) (ECal *ecal, ECalendarStatus status);
        void (* cal_set_mode) (ECal *ecal, ECalSetModeStatus status, CalMode mode);     
 
        void (* backend_error) (ECal *ecal, const char *message);