aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client
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
parent225b147233ea335927385c2f867218b6abfb3994 (diff)
downloadgsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar
gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.gz
gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.bz2
gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.lz
gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.xz
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')
-rw-r--r--calendar/cal-client/cal-client.c88
-rw-r--r--calendar/cal-client/cal-client.h14
-rw-r--r--calendar/cal-client/cal-listener.c31
-rw-r--r--calendar/cal-client/cal-listener.h7
4 files changed, 136 insertions, 4 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.
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index 4237563dc7..10614ef83f 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -51,6 +51,13 @@ typedef enum {
CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED
} CalClientOpenStatus;
+/* Set mode status for the cal_client_set_mode function */
+typedef enum {
+ CAL_CLIENT_SET_MODE_SUCCESS,
+ CAL_CLIENT_SET_MODE_ERROR,
+ CAL_CLIENT_SET_MODE_NOT_SUPPORTED
+} CalClientSetModeStatus;
+
/* Get status for the cal_client_get_object() function */
typedef enum {
CAL_CLIENT_GET_SUCCESS,
@@ -78,7 +85,8 @@ struct _CalClientClass {
/* Notification signals */
void (* cal_opened) (CalClient *client, CalClientOpenStatus status);
-
+ void (* cal_set_mode) (CalClient *client, CalClientSetModeStatus status, CalMode mode);
+
void (* obj_updated) (CalClient *client, const char *uid);
void (* obj_removed) (CalClient *client, const char *uid);
@@ -101,12 +109,14 @@ CalClient *cal_client_new (void);
void cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data);
gboolean cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists);
-GList *cal_client_uri_list (CalClient *client, CalUriType type);
+GList *cal_client_uri_list (CalClient *client, CalMode mode);
CalClientLoadState cal_client_get_load_state (CalClient *client);
const char *cal_client_get_uri (CalClient *client);
+gboolean cal_client_set_mode (CalClient *client, CalMode mode);
+
int cal_client_get_n_objects (CalClient *client, CalObjType type);
CalClientGetStatus cal_client_get_object (CalClient *client,
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
index 8d4d49c286..2623575151 100644
--- a/calendar/cal-client/cal-listener.c
+++ b/calendar/cal-client/cal-listener.c
@@ -28,6 +28,7 @@
struct CalListenerPrivate {
/* Notification functions and their closure data */
CalListenerCalOpenedFn cal_opened_fn;
+ CalListenerCalSetModeFn cal_set_mode_fn;
CalListenerObjUpdatedFn obj_updated_fn;
CalListenerObjRemovedFn obj_removed_fn;
CalListenerCategoriesChangedFn categories_changed_fn;
@@ -47,6 +48,10 @@ static void impl_notifyCalOpened (PortableServer_Servant servant,
GNOME_Evolution_Calendar_Listener_OpenStatus status,
GNOME_Evolution_Calendar_Cal cal,
CORBA_Environment *ev);
+static void impl_notifyCalSetMode (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_Listener_SetModeStatus status,
+ GNOME_Evolution_Calendar_CalMode mode,
+ CORBA_Environment *ev);
static void impl_notifyObjUpdated (PortableServer_Servant servant,
GNOME_Evolution_Calendar_CalObjUID uid,
CORBA_Environment *ev);
@@ -77,6 +82,7 @@ cal_listener_class_init (CalListenerClass *class)
parent_class = gtk_type_class (BONOBO_X_OBJECT_TYPE);
class->epv.notifyCalOpened = impl_notifyCalOpened;
+ class->epv.notifyCalSetMode = impl_notifyCalSetMode;
class->epv.notifyObjUpdated = impl_notifyObjUpdated;
class->epv.notifyObjRemoved = impl_notifyObjRemoved;
class->epv.notifyCategoriesChanged = impl_notifyCategoriesChanged;
@@ -165,6 +171,26 @@ impl_notifyCalOpened (PortableServer_Servant servant,
(* priv->cal_opened_fn) (listener, status, cal, priv->fn_data);
}
+/* ::notifyCalSetMode method */
+static void
+impl_notifyCalSetMode (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_Listener_SetModeStatus status,
+ GNOME_Evolution_Calendar_CalMode mode,
+ CORBA_Environment *ev)
+{
+ CalListener *listener;
+ CalListenerPrivate *priv;
+
+ listener = CAL_LISTENER (bonobo_object_from_servant (servant));
+ priv = listener->priv;
+
+ if (!priv->notify)
+ return;
+
+ g_assert (priv->cal_set_mode_fn != NULL);
+ (* priv->cal_set_mode_fn) (listener, status, mode, priv->fn_data);
+}
+
/* ::notifyObjUpdated method */
static void
impl_notifyObjUpdated (PortableServer_Servant servant,
@@ -246,6 +272,7 @@ impl_notifyCategoriesChanged (PortableServer_Servant servant,
CalListener *
cal_listener_construct (CalListener *listener,
CalListenerCalOpenedFn cal_opened_fn,
+ CalListenerCalSetModeFn cal_set_mode_fn,
CalListenerObjUpdatedFn obj_updated_fn,
CalListenerObjRemovedFn obj_removed_fn,
CalListenerCategoriesChangedFn categories_changed_fn,
@@ -256,6 +283,7 @@ cal_listener_construct (CalListener *listener,
g_return_val_if_fail (listener != NULL, NULL);
g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL);
g_return_val_if_fail (cal_opened_fn != NULL, NULL);
+ g_return_val_if_fail (cal_set_mode_fn != NULL, NULL);
g_return_val_if_fail (obj_updated_fn != NULL, NULL);
g_return_val_if_fail (obj_removed_fn != NULL, NULL);
g_return_val_if_fail (categories_changed_fn != NULL, NULL);
@@ -263,6 +291,7 @@ cal_listener_construct (CalListener *listener,
priv = listener->priv;
priv->cal_opened_fn = cal_opened_fn;
+ priv->cal_set_mode_fn = cal_set_mode_fn;
priv->obj_updated_fn = obj_updated_fn;
priv->obj_removed_fn = obj_removed_fn;
priv->categories_changed_fn = categories_changed_fn;
@@ -290,6 +319,7 @@ cal_listener_construct (CalListener *listener,
**/
CalListener *
cal_listener_new (CalListenerCalOpenedFn cal_opened_fn,
+ CalListenerCalSetModeFn cal_set_mode_fn,
CalListenerObjUpdatedFn obj_updated_fn,
CalListenerObjRemovedFn obj_removed_fn,
CalListenerCategoriesChangedFn categories_changed_fn,
@@ -305,6 +335,7 @@ cal_listener_new (CalListenerCalOpenedFn cal_opened_fn,
listener = gtk_type_new (CAL_LISTENER_TYPE);
return cal_listener_construct (listener,
cal_opened_fn,
+ cal_set_mode_fn,
obj_updated_fn,
obj_removed_fn,
categories_changed_fn,
diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h
index 87a4f892fe..350eafff15 100644
--- a/calendar/cal-client/cal-listener.h
+++ b/calendar/cal-client/cal-listener.h
@@ -58,6 +58,11 @@ typedef void (* CalListenerCalOpenedFn) (CalListener *listener,
GNOME_Evolution_Calendar_Cal cal,
gpointer data);
+typedef void (* CalListenerCalSetModeFn) (CalListener *listener,
+ GNOME_Evolution_Calendar_Listener_SetModeStatus status,
+ GNOME_Evolution_Calendar_CalMode mode,
+ gpointer data);
+
typedef void (* CalListenerObjUpdatedFn) (CalListener *listener,
const GNOME_Evolution_Calendar_CalObjUID uid,
gpointer data);
@@ -74,12 +79,14 @@ GtkType cal_listener_get_type (void);
CalListener *cal_listener_construct (CalListener *listener,
CalListenerCalOpenedFn cal_opened_fn,
+ CalListenerCalSetModeFn cal_set_mode_fn,
CalListenerObjUpdatedFn obj_updated_fn,
CalListenerObjRemovedFn obj_removed_fn,
CalListenerCategoriesChangedFn categories_changed_fn,
gpointer fn_data);
CalListener *cal_listener_new (CalListenerCalOpenedFn cal_opened_fn,
+ CalListenerCalSetModeFn cal_set_mode_fn,
CalListenerObjUpdatedFn obj_updated_fn,
CalListenerObjRemovedFn obj_removed_fn,
CalListenerCategoriesChangedFn categories_changed_fn,