aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client/cal-client.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-09-26 14:40:50 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-09-26 14:40:50 +0800
commit943c0e6e2393607a1adf380db102cc2bad61ff52 (patch)
treec8bcf65617509c8c40e74fcbd82ff956c9584026 /calendar/cal-client/cal-client.c
parent225b147233ea335927385c2f867218b6abfb3994 (diff)
downloadgsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.gz
gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.zst
gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.zip
new proto
2001-09-26 JP Rosevear <jpr@ximian.com> * pcs/cal.h: new proto * pcs/cal.c (impl_Cal_set_mode): implement set mode method (cal_class_init): set setMode function in epv (cal_notify_mode): notify listener of mode change * pcs/cal-factory.c (add_uri): deal with UriType renaming * pcs/cal-backend.h: add new virtual methods and protos * pcs/cal-backend.c (cal_backend_class_init): init new virtual methods to null (cal_backend_set_mode): sets mode (cal_backend_get_mode): gets mode * pcs/cal-backend-file.c (cal_backend_file_class_init): overide get_mode and set_mode methods (cal_backend_file_get_mode): return mode (notify_mode): have listeners notified of the set mode call (cal_backend_file_set_mode): set the mode by indicating not supported * cal-client/cal-listener.h: update proto * cal-client/cal-listener.c (impl_notifyCalSetMode): implement set mode callback (cal_listener_construct): take set mode callback (cal_listener_new): ditto * cal-client/cal-client.h: update protos, add signal proto * cal-client/cal-client.c (cal_client_class_init): add cal_set_mode signal (cal_set_mode_cb): handle set mode callback from listener (cal_client_open_calendar): pass additional param to cal_listener_new (cal_client_set_mode): wrapper to set the calendar mode * idl/evolution-calendar.idl: make UriType into CalMode, add SetModeStatus enum and notifyCalSetMode method to the listener * gui/calendar-offline-handler.c (create_connection_list): fetch the uri list ourselves (impl_prepareForOffline): reflect param change of create_connect_list (update_offline): ditto (backend_cal_set_mode): set mode call back (backend_cal_opened): cal opened call back, set mode to local (impl_goOffline): reflect UriType renaming * cal-util/cal-util.h: rename UriType to CalMode svn path=/trunk/; revision=13142
Diffstat (limited to 'calendar/cal-client/cal-client.c')
-rw-r--r--calendar/cal-client/cal-client.c88
1 files changed, 86 insertions, 2 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 78d31eeab6..27c827cbac 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -70,6 +70,7 @@ struct _CalClientPrivate {
/* Signal IDs */
enum {
CAL_OPENED,
+ CAL_SET_MODE,
OBJ_UPDATED,
OBJ_REMOVED,
CATEGORIES_CHANGED,
@@ -128,6 +129,8 @@ cal_client_get_type (void)
return cal_client_type;
}
+#define marshal_NONE__ENUM_ENUM gtk_marshal_NONE__INT_INT
+
/* Class initialization function for the calendar client */
static void
cal_client_class_init (CalClientClass *class)
@@ -146,6 +149,15 @@ cal_client_class_init (CalClientClass *class)
gtk_marshal_NONE__ENUM,
GTK_TYPE_NONE, 1,
GTK_TYPE_ENUM);
+ cal_client_signals[CAL_SET_MODE] =
+ gtk_signal_new ("cal_set_mode",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (CalClientClass, cal_set_mode),
+ marshal_NONE__ENUM_ENUM,
+ GTK_TYPE_NONE, 2,
+ GTK_TYPE_ENUM,
+ GTK_TYPE_ENUM);
cal_client_signals[OBJ_UPDATED] =
gtk_signal_new ("obj_updated",
GTK_RUN_FIRST,
@@ -443,6 +455,53 @@ cal_opened_cb (CalListener *listener,
gtk_object_unref (GTK_OBJECT (client));
}
+/* Handle the cal_set_mode notification from the listener */
+static void
+cal_set_mode_cb (CalListener *listener,
+ GNOME_Evolution_Calendar_Listener_SetModeStatus status,
+ GNOME_Evolution_Calendar_CalMode mode,
+ gpointer data)
+{
+ CalClient *client;
+ CalClientPrivate *priv;
+ CalClientSetModeStatus client_status;
+
+ client = CAL_CLIENT (data);
+ priv = client->priv;
+
+ g_assert (priv->load_state == CAL_CLIENT_LOAD_LOADING);
+ g_assert (priv->uri != NULL);
+
+ client_status = CAL_CLIENT_OPEN_ERROR;
+
+ switch (status) {
+ case GNOME_Evolution_Calendar_Listener_MODE_SET:
+ client_status = CAL_CLIENT_SET_MODE_SUCCESS;
+ break;
+ case GNOME_Evolution_Calendar_Listener_MODE_NOT_SET:
+ client_status = CAL_CLIENT_SET_MODE_ERROR;
+ break;
+ case GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED:
+ client_status = CAL_CLIENT_SET_MODE_NOT_SUPPORTED;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ /* We are *not* inside a signal handler (this is just a simple callback
+ * called from the listener), so there is not a temporary reference to
+ * the client object. We ref() so that we can safely emit our own
+ * signal and clean up.
+ */
+
+ gtk_object_ref (GTK_OBJECT (client));
+
+ gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_SET_MODE],
+ client_status, mode);
+
+ gtk_object_unref (GTK_OBJECT (client));
+}
+
/* Handle the obj_updated signal from the listener */
static void
obj_updated_cb (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID uid, gpointer data)
@@ -655,6 +714,7 @@ cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_
g_return_val_if_fail (str_uri != NULL, FALSE);
priv->listener = cal_listener_new (cal_opened_cb,
+ cal_set_mode_cb,
obj_updated_cb,
obj_removed_cb,
categories_changed_cb,
@@ -716,7 +776,7 @@ build_uri_list (GNOME_Evolution_Calendar_StringSeq *seq)
* Return value: A list of URI's open on the wombat
**/
GList *
-cal_client_uri_list (CalClient *client, CalUriType type)
+cal_client_uri_list (CalClient *client, CalMode mode)
{
CalClientPrivate *priv;
GNOME_Evolution_Calendar_StringSeq *uri_seq;
@@ -730,7 +790,7 @@ cal_client_uri_list (CalClient *client, CalUriType type)
CORBA_exception_init (&ev);
- uri_seq = GNOME_Evolution_Calendar_CalFactory_uriList (priv->factory, type, &ev);
+ uri_seq = GNOME_Evolution_Calendar_CalFactory_uriList (priv->factory, mode, &ev);
if (BONOBO_EX (&ev))
g_message ("cal_client_uri_list(): request failed");
@@ -794,6 +854,30 @@ corba_obj_type (CalObjType type)
| ((type & CALOBJ_TYPE_JOURNAL) ? GNOME_Evolution_Calendar_TYPE_JOURNAL : 0));
}
+gboolean
+cal_client_set_mode (CalClient *client, CalMode mode)
+{
+ CalClientPrivate *priv;
+ gboolean retval = TRUE;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (client != NULL, -1);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), -1);
+
+ priv = client->priv;
+ g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, -1);
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_Calendar_Cal_setMode (priv->cal, mode, &ev);
+
+ if (BONOBO_EX (&ev))
+ retval = FALSE;
+
+ CORBA_exception_free (&ev);
+
+ return retval;
+}
+
/**
* cal_client_get_n_objects:
* @client: A calendar client.