diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-10-18 04:47:06 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-10-18 04:47:06 +0800 |
commit | d91364b0562ad2d80186c8bc5e94a7792989a53d (patch) | |
tree | de24f00a6102a69bce5047e26726942ab87e895f | |
parent | d4e1fb42e0e1017919ca21b5b59cc84b38f794f7 (diff) | |
download | gsoc2013-evolution-d91364b0562ad2d80186c8bc5e94a7792989a53d.tar gsoc2013-evolution-d91364b0562ad2d80186c8bc5e94a7792989a53d.tar.gz gsoc2013-evolution-d91364b0562ad2d80186c8bc5e94a7792989a53d.tar.bz2 gsoc2013-evolution-d91364b0562ad2d80186c8bc5e94a7792989a53d.tar.lz gsoc2013-evolution-d91364b0562ad2d80186c8bc5e94a7792989a53d.tar.xz gsoc2013-evolution-d91364b0562ad2d80186c8bc5e94a7792989a53d.tar.zst gsoc2013-evolution-d91364b0562ad2d80186c8bc5e94a7792989a53d.zip |
New, implementation for the cancel_discover_shared_folder virtual method.
* e-corba-storage.c (cancel_discover_shared_folder): New,
implementation for the cancel_discover_shared_folder virtual
method.
(class_init): Install.
* evolution-test-component.c
(storage_discover_shared_folder_callback): Instead of passing the
listener to the timeout function, just pass the storage. Put the
listener and the timeout ID on the storage object by using
gtk_object_set_data().
(shared_folder_discovery_timeout_callback): Updated accordingly.
(storage_cancel_discover_shared_folder_callback): New, callback
for the cancel_discover_shared_folder signal.
(setup_custom_storage): Connect.
* e-shell-shared-folder-picker-dialog.c: New member storage in
struct DiscoveryData. While I am at it, rename member user to
user_email_address.
(discover_folder): Set the storage member.
(cleanup_discovery): Unref storage member.
(progress_dialog_clicked_callback): New, callback for the
"clicked" signal on the dialog.
(discover_folder): Connect.
* evolution-storage.c (class_init): Install signal
"cancel_discover_shared_folder".
(impl_Storage_cancelDiscoverSharedFolder): New, implementation for
the cancelDiscoverSharedFolder CORBA method; emit
"cancel_discover_shared_folder".
(evolution_storage_get_epv): Install CORBA method implementation.
* evolution-storage.h: Add signal cancel_discover_shared_folder.
* e-storage.c (e_storage_cancel_discover_shared_folder): New.
* e-storage.h: New virtual method cancel_discover_shared_folder.
* Evolution-Storage.idl (cancelDiscoverSharedFolder): New.
svn path=/trunk/; revision=18386
-rw-r--r-- | shell/ChangeLog | 44 | ||||
-rw-r--r-- | shell/Evolution-Storage.idl | 2 | ||||
-rw-r--r-- | shell/e-corba-storage.c | 35 | ||||
-rw-r--r-- | shell/e-shell-shared-folder-picker-dialog.c | 58 | ||||
-rw-r--r-- | shell/e-storage.c | 19 | ||||
-rw-r--r-- | shell/e-storage.h | 46 | ||||
-rw-r--r-- | shell/evolution-storage.c | 58 | ||||
-rw-r--r-- | shell/evolution-storage.h | 4 | ||||
-rw-r--r-- | shell/evolution-test-component.c | 50 |
9 files changed, 250 insertions, 66 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 191c41699b..dc6635ac9f 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,47 @@ +2002-10-17 Ettore Perazzoli <ettore@ximian.com> + + [Implement the Cancel button in the "Open other user's folder" + dialog, as per #27735.] + + * e-corba-storage.c (cancel_discover_shared_folder): New, + implementation for the cancel_discover_shared_folder virtual + method. + (class_init): Install. + + * evolution-test-component.c + (storage_discover_shared_folder_callback): Instead of passing the + listener to the timeout function, just pass the storage. Put the + listener and the timeout ID on the storage object by using + gtk_object_set_data(). + (shared_folder_discovery_timeout_callback): Updated accordingly. + (storage_cancel_discover_shared_folder_callback): New, callback + for the cancel_discover_shared_folder signal. + (setup_custom_storage): Connect. + + * e-shell-shared-folder-picker-dialog.c: New member storage in + struct DiscoveryData. While I am at it, rename member user to + user_email_address. + (discover_folder): Set the storage member. + (cleanup_discovery): Unref storage member. + (progress_dialog_clicked_callback): New, callback for the + "clicked" signal on the dialog. + (discover_folder): Connect. + + * evolution-storage.c (class_init): Install signal + "cancel_discover_shared_folder". + (impl_Storage_cancelDiscoverSharedFolder): New, implementation for + the cancelDiscoverSharedFolder CORBA method; emit + "cancel_discover_shared_folder". + (evolution_storage_get_epv): Install CORBA method implementation. + + * evolution-storage.h: Add signal cancel_discover_shared_folder. + + * e-storage.c (e_storage_cancel_discover_shared_folder): New. + + * e-storage.h: New virtual method cancel_discover_shared_folder. + + * Evolution-Storage.idl (cancelDiscoverSharedFolder): New. + 2002-10-07 Ettore Perazzoli <ettore@ximian.com> * e-shell-importer.c (choose_importer_from_list): Change the diff --git a/shell/Evolution-Storage.idl b/shell/Evolution-Storage.idl index d6374e4577..45aa3cb884 100644 --- a/shell/Evolution-Storage.idl +++ b/shell/Evolution-Storage.idl @@ -92,6 +92,8 @@ module Evolution { void asyncDiscoverSharedFolder (in string user, in string folder_name, in Bonobo::Listener listener); + void cancelDiscoverSharedFolder (in string user, + in string folder_name); void asyncRemoveSharedFolder (in string path, in Bonobo::Listener listener); diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c index b640ff22b9..4f5ca6dc1b 100644 --- a/shell/e-corba-storage.c +++ b/shell/e-corba-storage.c @@ -559,6 +559,26 @@ async_discover_shared_folder (EStorage *storage, } static void +cancel_discover_shared_folder (EStorage *storage, + const char *owner, + const char *folder_name) +{ + ECorbaStorage *corba_storage; + ECorbaStoragePrivate *priv; + CORBA_Environment ev; + + corba_storage = E_CORBA_STORAGE (storage); + priv = corba_storage->priv; + + CORBA_exception_init (&ev); + GNOME_Evolution_Storage_cancelDiscoverSharedFolder (priv->storage_interface, + owner, folder_name, &ev); + if (BONOBO_EX (&ev)) + g_warning ("Error invoking cancelDiscoverSharedFolder -- %s", BONOBO_EX_ID (&ev)); + CORBA_exception_free (&ev); +} + +static void async_remove_shared_folder (EStorage *storage, const char *path, EStorageResultCallback callback, @@ -627,13 +647,14 @@ class_init (ECorbaStorageClass *klass) object_class->destroy = destroy; storage_class = E_STORAGE_CLASS (klass); - storage_class->async_create_folder = async_create_folder; - storage_class->async_remove_folder = async_remove_folder; - storage_class->async_xfer_folder = async_xfer_folder; - storage_class->async_open_folder = async_open_folder; - storage_class->supports_shared_folders = supports_shared_folders; - storage_class->async_discover_shared_folder = async_discover_shared_folder; - storage_class->async_remove_shared_folder = async_remove_shared_folder; + storage_class->async_create_folder = async_create_folder; + storage_class->async_remove_folder = async_remove_folder; + storage_class->async_xfer_folder = async_xfer_folder; + storage_class->async_open_folder = async_open_folder; + storage_class->supports_shared_folders = supports_shared_folders; + storage_class->async_discover_shared_folder = async_discover_shared_folder; + storage_class->cancel_discover_shared_folder = cancel_discover_shared_folder; + storage_class->async_remove_shared_folder = async_remove_shared_folder; corba_class_init (); diff --git a/shell/e-shell-shared-folder-picker-dialog.c b/shell/e-shell-shared-folder-picker-dialog.c index 5316b2f8fb..cba839f880 100644 --- a/shell/e-shell-shared-folder-picker-dialog.c +++ b/shell/e-shell-shared-folder-picker-dialog.c @@ -261,11 +261,24 @@ struct _DiscoveryData { EShell *shell; EShellView *parent; GtkWidget *dialog; - char *user; + char *user_email_address; char *folder_name; + EStorage *storage; }; typedef struct _DiscoveryData DiscoveryData; +static void +cleanup_discovery (DiscoveryData *discovery_data) +{ + if (discovery_data->dialog != NULL) + gtk_widget_destroy (discovery_data->dialog); + + g_free (discovery_data->user_email_address); + g_free (discovery_data->folder_name); + gtk_object_unref (GTK_OBJECT (discovery_data->storage)); + g_free (discovery_data); +} + static int progress_bar_timeout_callback (void *data) { @@ -301,6 +314,23 @@ progress_dialog_close_callback (GnomeDialog *dialog, return TRUE; } +/* This is invoked if the "Cancel" button is clicked. */ +static void +progress_dialog_clicked_callback (GnomeDialog *dialog, + int button_number, + void *data) +{ + DiscoveryData *discovery_data; + + discovery_data = (DiscoveryData *) data; + + e_storage_cancel_discover_shared_folder (discovery_data->storage, + discovery_data->user_email_address, + discovery_data->folder_name); + + cleanup_discovery (discovery_data); +} + static int progress_dialog_show_timeout_callback (void *data) { @@ -358,17 +388,6 @@ create_progress_dialog (EShell *shell, } static void -cleanup_discovery (DiscoveryData *discovery_data) -{ - if (discovery_data->dialog != NULL) - gtk_widget_destroy (discovery_data->dialog); - - g_free (discovery_data->user); - g_free (discovery_data->folder_name); - g_free (discovery_data); -} - -static void shell_destroy_callback (GtkObject *object, void *data) { @@ -460,11 +479,13 @@ discover_folder (EShell *shell, dialog = create_progress_dialog (shell, storage, user_email_address, folder_name); discovery_data = g_new (DiscoveryData, 1); - discovery_data->dialog = dialog; - discovery_data->shell = shell; - discovery_data->parent = parent; - discovery_data->user = g_strdup (user_email_address); - discovery_data->folder_name = g_strdup (folder_name); + discovery_data->dialog = dialog; + discovery_data->shell = shell; + discovery_data->parent = parent; + discovery_data->user_email_address = g_strdup (user_email_address); + discovery_data->folder_name = g_strdup (folder_name); + discovery_data->storage = storage; + gtk_object_ref (GTK_OBJECT (storage)); gtk_signal_connect (GTK_OBJECT (shell), "destroy", GTK_SIGNAL_FUNC (shell_destroy_callback), discovery_data); @@ -475,6 +496,9 @@ discover_folder (EShell *shell, gtk_signal_connect (GTK_OBJECT (storage), "destroy", GTK_SIGNAL_FUNC (storage_destroy_callback), discovery_data); + gtk_signal_connect (GTK_OBJECT (dialog), "clicked", + GTK_SIGNAL_FUNC (progress_dialog_clicked_callback), discovery_data); + e_storage_async_discover_shared_folder (storage, user_email_address, folder_name, diff --git a/shell/e-storage.c b/shell/e-storage.c index 6be864ffa9..dcaeb5cf18 100644 --- a/shell/e-storage.c +++ b/shell/e-storage.c @@ -277,9 +277,9 @@ class_init (EStorageClass *class) class->async_xfer_folder = impl_async_xfer_folder; class->async_open_folder = impl_async_open_folder; - class->supports_shared_folders = impl_supports_shared_folders; - class->async_discover_shared_folder = impl_async_discover_shared_folder; - class->async_remove_shared_folder = impl_async_remove_shared_folder; + class->supports_shared_folders = impl_supports_shared_folders; + class->async_discover_shared_folder = impl_async_discover_shared_folder; + class->async_remove_shared_folder = impl_async_remove_shared_folder; signals[NEW_FOLDER] = gtk_signal_new ("new_folder", @@ -534,6 +534,19 @@ e_storage_async_discover_shared_folder (EStorage *storage, } void +e_storage_cancel_discover_shared_folder (EStorage *storage, + const char *owner, + const char *folder_name) +{ + g_return_if_fail (E_IS_STORAGE (storage)); + g_return_if_fail (owner != NULL); + g_return_if_fail (folder_name != NULL); + g_return_if_fail (ES_CLASS (storage)->cancel_discover_shared_folder != NULL); + + (* ES_CLASS (storage)->cancel_discover_shared_folder) (storage, owner, folder_name); +} + +void e_storage_async_remove_shared_folder (EStorage *storage, const char *path, EStorageResultCallback callback, diff --git a/shell/e-storage.h b/shell/e-storage.h index f017cacc1d..31d2ff7c1a 100644 --- a/shell/e-storage.h +++ b/shell/e-storage.h @@ -114,16 +114,19 @@ struct _EStorageClass { void (* async_open_folder) (EStorage *storage, const char *path); - gboolean (* supports_shared_folders) (EStorage *storage); - void (* async_discover_shared_folder) (EStorage *storage, - const char *owner, - const char *folder_name, - EStorageDiscoveryCallback callback, - void *data); - void (* async_remove_shared_folder) (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data); + gboolean (* supports_shared_folders) (EStorage *storage); + void (* async_discover_shared_folder) (EStorage *storage, + const char *owner, + const char *folder_name, + EStorageDiscoveryCallback callback, + void *data); + void (* cancel_discover_shared_folder) (EStorage *storage, + const char *owner, + const char *folder_name); + void (* async_remove_shared_folder) (EStorage *storage, + const char *path, + EStorageResultCallback callback, + void *data); }; @@ -168,16 +171,19 @@ void e_storage_async_open_folder (EStorage *storage, const char *e_storage_result_to_string (EStorageResult result); /* Shared folders. */ -gboolean e_storage_supports_shared_folders (EStorage *storage); -void e_storage_async_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name, - EStorageDiscoveryCallback callback, - void *data); -void e_storage_async_remove_shared_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data); +gboolean e_storage_supports_shared_folders (EStorage *storage); +void e_storage_async_discover_shared_folder (EStorage *storage, + const char *owner, + const char *folder_name, + EStorageDiscoveryCallback callback, + void *data); +void e_storage_cancel_discover_shared_folder (EStorage *storage, + const char *owner, + const char *folder_name); +void e_storage_async_remove_shared_folder (EStorage *storage, + const char *path, + EStorageResultCallback callback, + void *data); /* Utility functions. */ diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c index 141feff758..15be4e761e 100644 --- a/shell/evolution-storage.c +++ b/shell/evolution-storage.c @@ -83,6 +83,7 @@ enum { UPDATE_FOLDER, OPEN_FOLDER, DISCOVER_SHARED_FOLDER, + CANCEL_DISCOVER_SHARED_FOLDER, REMOVE_SHARED_FOLDER, SHOW_FOLDER_PROPERTIES, @@ -506,6 +507,22 @@ impl_Storage_asyncDiscoverSharedFolder (PortableServer_Servant servant, } static void +impl_Storage_cancelDiscoverSharedFolder (PortableServer_Servant servant, + const CORBA_char *user, + const CORBA_char *folder_name, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionStorage *storage; + + bonobo_object = bonobo_object_from_servant (servant); + storage = EVOLUTION_STORAGE (bonobo_object); + + gtk_signal_emit (GTK_OBJECT (storage), signals[CANCEL_DISCOVER_SHARED_FOLDER], + user, folder_name); +} + +static void impl_Storage_asyncRemoveSharedFolder (PortableServer_Servant servant, const CORBA_char *path, const Bonobo_Listener listener, @@ -805,6 +822,16 @@ class_init (EvolutionStorageClass *klass) GTK_TYPE_STRING, GTK_TYPE_STRING); + signals[CANCEL_DISCOVER_SHARED_FOLDER] = gtk_signal_new ("cancel_discover_shared_folder", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionStorageClass, + cancel_discover_shared_folder), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, + GTK_TYPE_STRING, + GTK_TYPE_STRING); + signals[REMOVE_SHARED_FOLDER] = gtk_signal_new ("remove_shared_folder", GTK_RUN_LAST, object_class->type, @@ -854,21 +881,22 @@ evolution_storage_get_epv (void) POA_GNOME_Evolution_Storage__epv *epv; epv = g_new0 (POA_GNOME_Evolution_Storage__epv, 1); - epv->_get_name = impl_Storage__get_name; - epv->_get_hasSharedFolders = impl_Storage__get_hasSharedFolders; - epv->getFolderAtPath = impl_Storage_getFolderAtPath; - epv->_get_folderList = impl_Storage__get_folderList; - epv->asyncCreateFolder = impl_Storage_asyncCreateFolder; - epv->asyncRemoveFolder = impl_Storage_asyncRemoveFolder; - epv->asyncXferFolder = impl_Storage_asyncXferFolder; - epv->asyncOpenFolder = impl_Storage_asyncOpenFolder; - epv->updateFolder = impl_Storage_updateFolder; - epv->asyncDiscoverSharedFolder = impl_Storage_asyncDiscoverSharedFolder; - epv->asyncRemoveSharedFolder = impl_Storage_asyncRemoveSharedFolder; - epv->addListener = impl_Storage_addListener; - epv->removeListener = impl_Storage_removeListener; - epv->showFolderProperties = impl_Storage_showFolderProperties; - epv->_get_folderPropertyItems = impl_Storage__get_folderPropertyItems; + epv->_get_name = impl_Storage__get_name; + epv->_get_hasSharedFolders = impl_Storage__get_hasSharedFolders; + epv->getFolderAtPath = impl_Storage_getFolderAtPath; + epv->_get_folderList = impl_Storage__get_folderList; + epv->asyncCreateFolder = impl_Storage_asyncCreateFolder; + epv->asyncRemoveFolder = impl_Storage_asyncRemoveFolder; + epv->asyncXferFolder = impl_Storage_asyncXferFolder; + epv->asyncOpenFolder = impl_Storage_asyncOpenFolder; + epv->updateFolder = impl_Storage_updateFolder; + epv->asyncDiscoverSharedFolder = impl_Storage_asyncDiscoverSharedFolder; + epv->cancelDiscoverSharedFolder = impl_Storage_cancelDiscoverSharedFolder; + epv->asyncRemoveSharedFolder = impl_Storage_asyncRemoveSharedFolder; + epv->addListener = impl_Storage_addListener; + epv->removeListener = impl_Storage_removeListener; + epv->showFolderProperties = impl_Storage_showFolderProperties; + epv->_get_folderPropertyItems = impl_Storage__get_folderPropertyItems; return epv; } diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h index b0f55642ce..439c883246 100644 --- a/shell/evolution-storage.h +++ b/shell/evolution-storage.h @@ -113,6 +113,10 @@ struct _EvolutionStorageClass { const char *user, const char *folder_name); + void (*cancel_discover_shared_folder) (EvolutionStorage *storage, + const char *user, + const char *folder_name); + void (*remove_shared_folder) (EvolutionStorage *storage, Bonobo_Listener listener, const char *path); diff --git a/shell/evolution-test-component.c b/shell/evolution-test-component.c index 18e11e65e7..2ddda0a7ce 100644 --- a/shell/evolution-test-component.c +++ b/shell/evolution-test-component.c @@ -264,12 +264,15 @@ create_new_folder_selector (EvolutionShellComponent *shell_component) static int shared_folder_discovery_timeout_callback (void *data) { + GNOME_Evolution_Storage_FolderResult result; CORBA_Environment ev; Bonobo_Listener listener; CORBA_any any; - GNOME_Evolution_Storage_FolderResult result; + EvolutionStorage *storage; + + storage = EVOLUTION_STORAGE (data); - listener = (Bonobo_Listener) data; + listener = (Bonobo_Listener) gtk_object_get_data (GTK_OBJECT (storage), "listener"); result.result = GNOME_Evolution_Storage_OK; result.path = "/Shared Folders/The Public Folder"; @@ -284,18 +287,22 @@ shared_folder_discovery_timeout_callback (void *data) g_warning ("Cannot report result for shared folder discovery -- %s", BONOBO_EX_ID (&ev)); + Bonobo_Unknown_unref (listener, &ev); CORBA_Object_release (listener, &ev); CORBA_exception_free (&ev); + gtk_object_set_data (GTK_OBJECT (storage), "listener", NULL); + gtk_object_set_data (GTK_OBJECT (storage), "timeout_id", NULL); + return FALSE; } static void storage_discover_shared_folder_callback (EvolutionStorage *storage, + Bonobo_Listener listener, const char *user, const char *folder_name, - Bonobo_Listener listener, void *data) { CORBA_Environment ev; @@ -303,9 +310,42 @@ storage_discover_shared_folder_callback (EvolutionStorage *storage, CORBA_exception_init (&ev); listener_copy = CORBA_Object_duplicate (listener, &ev); + Bonobo_Unknown_ref (listener, &ev); + CORBA_exception_free (&ev); + + g_print ("Listener copy %p\n", listener_copy); + + timeout_id = g_timeout_add (1000, shared_folder_discovery_timeout_callback, storage); + + gtk_object_set_data (GTK_OBJECT (storage), "listener", listener_copy); + gtk_object_set_data (GTK_OBJECT (storage), "timeout_id", GINT_TO_POINTER (timeout_id)); +} + +static void +storage_cancel_discover_shared_folder_callback (EvolutionStorage *storage, + const char *user, + const char *folder_name, + void *data) +{ + Bonobo_Listener listener; + CORBA_Environment ev; + int timeout_id; + + timeout_id = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (storage), "timeout_id")); + if (timeout_id == 0) + return; + + g_source_remove (timeout_id); + gtk_object_set_data (GTK_OBJECT (storage), "timeout_id", NULL); + + listener = (Bonobo_Listener) gtk_object_get_data (GTK_OBJECT (storage), "listener"); + + CORBA_exception_init (&ev); + Bonobo_Unknown_unref (listener, &ev); + CORBA_Object_release (listener, &ev); CORBA_exception_free (&ev); - g_timeout_add (1000, shared_folder_discovery_timeout_callback, listener_copy); + gtk_object_set_data (GTK_OBJECT (storage), "listener", NULL); } static void @@ -328,6 +368,8 @@ setup_custom_storage (EvolutionShellClient *shell_client) gtk_signal_connect (GTK_OBJECT (the_storage), "discover_shared_folder", GTK_SIGNAL_FUNC (storage_discover_shared_folder_callback), shell_client); + gtk_signal_connect (GTK_OBJECT (the_storage), "cancel_discover_shared_folder", + GTK_SIGNAL_FUNC (storage_cancel_discover_shared_folder_callback), shell_client); /* Add some custom "Properties" items. */ evolution_storage_add_property_item (the_storage, "Sharing...", |