aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/calendar-offline-handler.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-09-26 00:35:40 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-09-26 00:35:40 +0800
commitce71400f35232aa9122fceb3436dfc56b8b206e8 (patch)
tree67fae3fc60b7549edad8d2ccf6965cb7a622fead /calendar/gui/calendar-offline-handler.c
parent240af05417b2f326140a2ac8fe4043f457b00976 (diff)
downloadgsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.gz
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.bz2
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.lz
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.xz
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.zst
gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.zip
use bonobo-exception stuff to clean code
2001-09-25 JP Rosevear <jpr@ximian.com> * pcs/cal.c: use bonobo-exception stuff to clean code * pcs/cal-factory.c (add_uri): add uri to the list if the type matches (impl_CalFactory_uriList): implement uriList method * pcs/cal-backend.h: new virtual function member * pcs/cal-backend.c (cal_backend_is_remote): call virtual function * pcs/cal-backend-file.c (cal_backend_file_class_init): override virtual function (cal_backend_file_is_remote): new virtual function, always return FALSE * idl/evolution-calendar.idl: uriList factory call, with flags for types to get * gui/dialogs/comp-editor.c (comp_editor_destroy): cast to remove warning * gui/e-itip-control.c (write_label_piece): kill warnings by take const char * * gui/component-factory.c (create_object): aggregate offline interface * gui/Makefile.am: compile new files * calobj.[hc]: Remove obsolete files * cal-util/cal-util.h: enum URI types for uriList call * cal-client/cal-client.c (build_uri_list): build list from string sequence (cal_client_uri_list): factory call to get uri list * cal-client/cal-client.h: new proto * cal-client/cal-client.c: use bonobo exception stuff to clean code * gui/calendar-offline-handler.[hc]: Start some skeleton routines for online/offline handling * pcs/cal-factory.c (launch_backend_for_uri): use accessor and remove FIXME svn path=/trunk/; revision=13110
Diffstat (limited to 'calendar/gui/calendar-offline-handler.c')
-rw-r--r--calendar/gui/calendar-offline-handler.c267
1 files changed, 267 insertions, 0 deletions
diff --git a/calendar/gui/calendar-offline-handler.c b/calendar/gui/calendar-offline-handler.c
new file mode 100644
index 0000000000..e57ba042ee
--- /dev/null
+++ b/calendar/gui/calendar-offline-handler.c
@@ -0,0 +1,267 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* calendar-offline-handler.c
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Ettore Perazzoli <ettore@ximian.com>
+ * Dan Winship <danw@ximian.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtkmain.h>
+#include <bonobo/bonobo-exception.h>
+#include <libgnomevfs/gnome-vfs-types.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
+#include <gal/util/e-util.h>
+#include <cal-client/cal-client.h>
+#include "calendar-offline-handler.h"
+
+#define PARENT_TYPE bonobo_x_object_get_type ()
+static BonoboXObjectClass *parent_class = NULL;
+
+struct _CalendarOfflineHandlerPrivate {
+ CalClient *client;
+
+ GNOME_Evolution_OfflineProgressListener listener_interface;
+
+ gboolean is_offline;
+};
+
+static void
+add_connection (gpointer data, gpointer user_data)
+{
+ GnomeVFSURI *uri = gnome_vfs_uri_new (data);
+ GNOME_Evolution_ConnectionList *list = user_data;
+
+ g_return_if_fail (uri != NULL);
+
+ list->_buffer[list->_length].hostName
+ = CORBA_string_dup (gnome_vfs_uri_get_host_name (uri));
+ list->_buffer[list->_length].type
+ = CORBA_string_dup (gnome_vfs_uri_get_scheme (uri));
+ list->_length++;
+
+ gnome_vfs_uri_unref (uri);
+}
+
+static GNOME_Evolution_ConnectionList *
+create_connection_list (GList *uris)
+{
+ GNOME_Evolution_ConnectionList *list;
+
+ list = GNOME_Evolution_ConnectionList__alloc ();
+ list->_length = 0;
+ list->_maximum = g_list_length (uris);
+ list->_buffer = CORBA_sequence_GNOME_Evolution_Connection_allocbuf (list->_maximum);
+
+ g_list_foreach (uris, add_connection, list);
+
+ return list;
+}
+
+/* GNOME::Evolution::Offline methods. */
+static CORBA_boolean
+impl__get_isOffline (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ CalendarOfflineHandler *offline_handler;
+ CalendarOfflineHandlerPrivate *priv;
+
+ offline_handler = CALENDAR_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
+ priv = offline_handler->priv;
+
+ return priv->is_offline;
+}
+
+static void
+impl_prepareForOffline (PortableServer_Servant servant,
+ GNOME_Evolution_ConnectionList **active_connection_list,
+ CORBA_Environment *ev)
+{
+ CalendarOfflineHandler *offline_handler;
+ CalendarOfflineHandlerPrivate *priv;
+ GList *uris;
+
+ offline_handler = CALENDAR_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
+ priv = offline_handler->priv;
+
+ uris = cal_client_uri_list (priv->client, CALURI_TYPE_REMOTE);
+
+ *active_connection_list = create_connection_list (uris);
+}
+
+static void
+update_offline (CalendarOfflineHandler *offline_handler)
+{
+ CalendarOfflineHandlerPrivate *priv;
+ GNOME_Evolution_ConnectionList *connection_list;
+ CORBA_Environment ev;
+
+ priv = offline_handler->priv;
+
+#if 0
+ connection_list = create_connection_list ();
+
+ CORBA_exception_init (&ev);
+
+ GNOME_Evolution_OfflineProgressListener_updateProgress (priv->listener_interface,
+ connection_list, &ev);
+
+ if (BONOBO_EX (&ev))
+ g_warning ("Error updating offline progress");
+
+ CORBA_exception_free (&ev);
+#endif
+}
+
+static void
+backend_cal_opened (CalClient *client, CalClientOpenStatus status, gpointer data)
+{
+ CalendarOfflineHandler *offline_handler = data;
+
+ if (status != CAL_CLIENT_OPEN_SUCCESS) {
+ update_offline (offline_handler);
+ gtk_object_unref (GTK_OBJECT (client));
+ return;
+ }
+}
+
+static void
+backend_go_offline (gpointer data, gpointer user_data)
+{
+ CalendarOfflineHandler *offline_handler = user_data;
+ char *uri = data;
+ CalClient *client;
+ gboolean success;
+
+ client = cal_client_new ();
+ success = cal_client_open_calendar (client, uri, TRUE);
+ if (!success) {
+ update_offline (offline_handler);
+ gtk_object_unref (GTK_OBJECT (client));
+ return;
+ }
+
+ gtk_signal_connect (GTK_OBJECT (client), "cal_opened",
+ backend_cal_opened, offline_handler);
+}
+
+static void
+impl_goOffline (PortableServer_Servant servant,
+ const GNOME_Evolution_OfflineProgressListener progress_listener,
+ CORBA_Environment *ev)
+{
+ CalendarOfflineHandler *offline_handler;
+ CalendarOfflineHandlerPrivate *priv;
+ GList *uris;
+
+ offline_handler = CALENDAR_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
+ priv = offline_handler->priv;
+
+ /* To update the status */
+ priv->listener_interface = CORBA_Object_duplicate (progress_listener, ev);
+
+ uris = cal_client_uri_list (priv->client, CALURI_TYPE_REMOTE);
+
+ g_list_foreach (uris, backend_go_offline, offline_handler);
+}
+
+static void
+impl_goOnline (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ CalendarOfflineHandler *offline_handler;
+ CalendarOfflineHandlerPrivate *priv;
+
+ offline_handler = CALENDAR_OFFLINE_HANDLER (bonobo_object_from_servant (servant));
+ priv = offline_handler->priv;
+}
+
+/* GtkObject methods. */
+
+static void
+impl_destroy (GtkObject *object)
+{
+ CalendarOfflineHandler *offline_handler;
+ CalendarOfflineHandlerPrivate *priv;
+
+ offline_handler = CALENDAR_OFFLINE_HANDLER (object);
+ priv = offline_handler->priv;
+
+ if (priv->listener_interface != CORBA_OBJECT_NIL) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ CORBA_Object_release (priv->listener_interface, &ev);
+ CORBA_exception_free (&ev);
+ }
+
+ g_free (priv);
+
+ if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+/* GTK+ type initialization. */
+
+static void
+calendar_offline_handler_class_init (CalendarOfflineHandlerClass *klass)
+{
+ GtkObjectClass *object_class;
+ POA_GNOME_Evolution_Offline__epv *epv;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = impl_destroy;
+
+ epv = & klass->epv;
+ epv->_get_isOffline = impl__get_isOffline;
+ epv->prepareForOffline = impl_prepareForOffline;
+ epv->goOffline = impl_goOffline;
+ epv->goOnline = impl_goOnline;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+}
+
+static void
+calendar_offline_handler_init (CalendarOfflineHandler *offline_handler)
+{
+ CalendarOfflineHandlerPrivate *priv;
+
+ priv = g_new (CalendarOfflineHandlerPrivate, 1);
+ offline_handler->priv = priv;
+
+ priv->client = cal_client_new ();
+ priv->listener_interface = CORBA_OBJECT_NIL;
+ priv->is_offline = FALSE;
+}
+
+CalendarOfflineHandler *
+calendar_offline_handler_new (void)
+{
+ CalendarOfflineHandler *new;
+
+ new = gtk_type_new (calendar_offline_handler_get_type ());
+
+ return new;
+}
+
+BONOBO_X_TYPE_FUNC_FULL (CalendarOfflineHandler, GNOME_Evolution_Offline, PARENT_TYPE, calendar_offline_handler);