diff options
author | JP Rosevear <jpr@ximian.com> | 2001-09-26 00:35:40 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-09-26 00:35:40 +0800 |
commit | ce71400f35232aa9122fceb3436dfc56b8b206e8 (patch) | |
tree | 67fae3fc60b7549edad8d2ccf6965cb7a622fead /calendar/gui | |
parent | 240af05417b2f326140a2ac8fe4043f457b00976 (diff) | |
download | gsoc2013-evolution-ce71400f35232aa9122fceb3436dfc56b8b206e8.tar.gz 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')
-rw-r--r-- | calendar/gui/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/gui/calendar-component.c | 28 | ||||
-rw-r--r-- | calendar/gui/calendar-offline-handler.c | 267 | ||||
-rw-r--r-- | calendar/gui/calendar-offline-handler.h | 70 | ||||
-rw-r--r-- | calendar/gui/component-factory.c | 28 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-itip-control.c | 3 |
7 files changed, 357 insertions, 43 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 06134d5485..c598bc2150 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -72,6 +72,8 @@ evolution_calendar_SOURCES = \ calendar-commands.h \ calendar-model.c \ calendar-model.h \ + calendar-offline-handler.c \ + calendar-offline-handler.h \ calendar-view.c \ calendar-view.h \ calendar-view-factory.c \ diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 574a700e76..e13a3f8a50 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -34,6 +34,7 @@ #include <bonobo/bonobo-generic-factory.h> #include <bonobo/bonobo-context.h> #include "evolution-shell-component.h" +#include "calendar-offline-handler.h" #include "component-factory.h" #include "tasks-control-factory.h" #include "control-factory.h" @@ -544,18 +545,6 @@ sc_user_create_new_item_cb (EvolutionShellComponent *shell_component, g_assert_not_reached (); } -#if 0 -static void -destroy_cb (EvolutionShellComponent *shell_component, - gpointer user_data) -{ - shells = g_list_remove (shells, shell_component); - - if (g_list_length (shells) == 0) - gtk_main_quit (); -} -#endif - /* The factory function. */ @@ -563,7 +552,8 @@ static BonoboObject * create_object (void) { EvolutionShellComponent *shell_component; - + CalendarOfflineHandler *offline_handler; + shell_component = evolution_shell_component_new (folder_types, NULL, create_view, @@ -574,18 +564,16 @@ create_object (void) NULL, /* get_dnd_selection_fn */ NULL /* closure */); + /* Offline handler */ + offline_handler = calendar_offline_handler_new (); + bonobo_object_add_interface (BONOBO_OBJECT (shell_component), + BONOBO_OBJECT (offline_handler)); + gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", GTK_SIGNAL_FUNC (owner_set_cb), NULL); gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", GTK_SIGNAL_FUNC (owner_unset_cb), NULL); -#if 0 - gtk_signal_connect (GTK_OBJECT (shell_component), "destroy", - GTK_SIGNAL_FUNC (destroy_cb), NULL); - - shells = g_list_append (shells, shell_component); -#endif - /* User creatable items */ evolution_shell_component_add_user_creatable_item (shell_component, 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); diff --git a/calendar/gui/calendar-offline-handler.h b/calendar/gui/calendar-offline-handler.h new file mode 100644 index 0000000000..e1becb1979 --- /dev/null +++ b/calendar/gui/calendar-offline-handler.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* calendar-offline-handler.h + * + * 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. + * + * Author: Ettore Perazzoli <ettore@ximian.com> + */ + +#ifndef _CALENDAR_OFFLINE_HANDLER_H_ +#define _CALENDAR_OFFLINE_HANDLER_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo/bonobo-xobject.h> +#include "Evolution.h" + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define CALENDAR_TYPE_OFFLINE_HANDLER (calendar_offline_handler_get_type ()) +#define CALENDAR_OFFLINE_HANDLER(obj) (GTK_CHECK_CAST ((obj), CALENDAR_TYPE_OFFLINE_HANDLER, CalendarOfflineHandler)) +#define CALENDAR_OFFLINE_HANDLER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CALENDAR_TYPE_OFFLINE_HANDLER, CalendarOfflineHandlerClass)) +#define CALENDAR_IS_OFFLINE_HANDLER(obj) (GTK_CHECK_TYPE ((obj), CALENDAR_TYPE_OFFLINE_HANDLER)) +#define CALENDAR_IS_OFFLINE_HANDLER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), CALENDAR_TYPE_OFFLINE_HANDLER)) + + +typedef struct _CalendarOfflineHandler CalendarOfflineHandler; +typedef struct _CalendarOfflineHandlerPrivate CalendarOfflineHandlerPrivate; +typedef struct _CalendarOfflineHandlerClass CalendarOfflineHandlerClass; + +struct _CalendarOfflineHandler { + BonoboXObject parent; + + CalendarOfflineHandlerPrivate *priv; +}; + +struct _CalendarOfflineHandlerClass { + BonoboXObjectClass parent_class; + + POA_GNOME_Evolution_Offline__epv epv; +}; + + +GtkType calendar_offline_handler_get_type (void); +CalendarOfflineHandler *calendar_offline_handler_new (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _CALENDAR_OFFLINE_HANDLER_H_ */ diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c index 574a700e76..e13a3f8a50 100644 --- a/calendar/gui/component-factory.c +++ b/calendar/gui/component-factory.c @@ -34,6 +34,7 @@ #include <bonobo/bonobo-generic-factory.h> #include <bonobo/bonobo-context.h> #include "evolution-shell-component.h" +#include "calendar-offline-handler.h" #include "component-factory.h" #include "tasks-control-factory.h" #include "control-factory.h" @@ -544,18 +545,6 @@ sc_user_create_new_item_cb (EvolutionShellComponent *shell_component, g_assert_not_reached (); } -#if 0 -static void -destroy_cb (EvolutionShellComponent *shell_component, - gpointer user_data) -{ - shells = g_list_remove (shells, shell_component); - - if (g_list_length (shells) == 0) - gtk_main_quit (); -} -#endif - /* The factory function. */ @@ -563,7 +552,8 @@ static BonoboObject * create_object (void) { EvolutionShellComponent *shell_component; - + CalendarOfflineHandler *offline_handler; + shell_component = evolution_shell_component_new (folder_types, NULL, create_view, @@ -574,18 +564,16 @@ create_object (void) NULL, /* get_dnd_selection_fn */ NULL /* closure */); + /* Offline handler */ + offline_handler = calendar_offline_handler_new (); + bonobo_object_add_interface (BONOBO_OBJECT (shell_component), + BONOBO_OBJECT (offline_handler)); + gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", GTK_SIGNAL_FUNC (owner_set_cb), NULL); gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", GTK_SIGNAL_FUNC (owner_unset_cb), NULL); -#if 0 - gtk_signal_connect (GTK_OBJECT (shell_component), "destroy", - GTK_SIGNAL_FUNC (destroy_cb), NULL); - - shells = g_list_append (shells, shell_component); -#endif - /* User creatable items */ evolution_shell_component_add_user_creatable_item (shell_component, diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 1b114d9ecf..f88c6d2de6 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -254,7 +254,7 @@ comp_editor_destroy (GtkObject *object) } if (priv->comp) { - gtk_object_unref (priv->comp); + gtk_object_unref (GTK_OBJECT (priv->comp)); priv->comp = NULL; } diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 426abd83e0..5b42b75a4b 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -428,7 +428,7 @@ set_button_status (EItipControl *itip) } static void -write_label_piece (time_t t, char *buffer, int size, char *stext, char *etext) +write_label_piece (time_t t, char *buffer, int size, const char *stext, const char *etext) { struct tm *tmp_tm; int len; @@ -1220,7 +1220,6 @@ static void send_freebusy (EItipControl *itip) { EItipControlPrivate *priv; - CalComponent *comp; CalComponentDateTime datetime; time_t start, end; GtkWidget *dialog; |