diff options
author | Dan Winship <danw@src.gnome.org> | 2002-10-01 02:41:05 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2002-10-01 02:41:05 +0800 |
commit | 45fd1767502d711d72087cae76c3d1acd7f46066 (patch) | |
tree | 78efae6fd605a5e867fe7b0f24ae8fb9dbce9443 /shell | |
parent | b887e5c2f6fdb8e7437093c3bc49fd439155e346 (diff) | |
download | gsoc2013-evolution-45fd1767502d711d72087cae76c3d1acd7f46066.tar.gz gsoc2013-evolution-45fd1767502d711d72087cae76c3d1acd7f46066.tar.zst gsoc2013-evolution-45fd1767502d711d72087cae76c3d1acd7f46066.zip |
Calls e_shell_command_remove_shared_folder. (file_verbs): Set up
* e-shell-view-menu.c (command_remove_other_users_folder): Calls
e_shell_command_remove_shared_folder.
(file_verbs): Set up command_remove_other_users_folder.
* e-shell-folder-commands.c
(e_shell_command_remove_shared_folder): New. Calls
e_storage_set_async_remove_shared_folder with a callback to pop up
an error dialog if it fails.
* e-storage-set.c (e_storage_set_async_remove_shared_folder):
Implement. Mostly like async_remove_folder.
* e-storage.c (e_storage_supports_shared_folders,
e_storage_async_discover_shared_folder,
e_storage_async_remove_shared_folder): New methods. Default
implementations return FALSE, NOTIMPLEMENTED, and NOTIMPLEMENTED.
* e-corba-storage.c (supports_shared_folders,
async_discover_shared_folder, async_remove_shared_folder):
Implement using CORBA.
* Evolution-Storage.idl: add Storage_asyncRemoveSharedFolder
* e-shell-shared-folder-picker-dialog.c: Remove all the CORBA
stuff from here and use the new EStorage methods.
(setup_server_option_menu): Use e_storage_supports_shared_folders.
(discover_folder): Use e_storage_async_discover_shared_folder.
* evolution-storage.c (impl_Storage_asyncRemoveSharedFolder):
Implement this by emitting a REMOVE_SHARED_FOLDER signal.
(impl_Storage_asyncDiscoverSharedFolder): Make the
DISCOVER_SHARED_FOLDER signal put the Bonobo_Listener first like
all the other signals do.
(class_init): Set up REMOVE_SHARED_FOLDER signal.
svn path=/trunk/; revision=18265
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 37 | ||||
-rw-r--r-- | shell/Evolution-Storage.idl | 2 | ||||
-rw-r--r-- | shell/e-corba-storage.c | 123 | ||||
-rw-r--r-- | shell/e-shell-folder-commands.c | 41 | ||||
-rw-r--r-- | shell/e-shell-folder-commands.h | 2 | ||||
-rw-r--r-- | shell/e-shell-shared-folder-picker-dialog.c | 107 | ||||
-rw-r--r-- | shell/e-shell-view-menu.c | 15 | ||||
-rw-r--r-- | shell/e-storage-set.c | 32 | ||||
-rw-r--r-- | shell/e-storage-set.h | 5 | ||||
-rw-r--r-- | shell/e-storage.c | 70 | ||||
-rw-r--r-- | shell/e-storage.h | 57 | ||||
-rw-r--r-- | shell/evolution-storage.c | 36 | ||||
-rw-r--r-- | shell/evolution-storage.h | 8 |
13 files changed, 433 insertions, 102 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 659d5a191d..d8b359a08e 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,5 +1,42 @@ 2002-09-30 Dan Winship <danw@ximian.com> + * e-shell-view-menu.c (command_remove_other_users_folder): Calls + e_shell_command_remove_shared_folder. + (file_verbs): Set up command_remove_other_users_folder. + + * e-shell-folder-commands.c + (e_shell_command_remove_shared_folder): New. Calls + e_storage_set_async_remove_shared_folder with a callback to pop up + an error dialog if it fails. + + * e-storage-set.c (e_storage_set_async_remove_shared_folder): + Implement. Mostly like async_remove_folder. + + * e-storage.c (e_storage_supports_shared_folders, + e_storage_async_discover_shared_folder, + e_storage_async_remove_shared_folder): New methods. Default + implementations return FALSE, NOTIMPLEMENTED, and NOTIMPLEMENTED. + + * e-corba-storage.c (supports_shared_folders, + async_discover_shared_folder, async_remove_shared_folder): + Implement using CORBA. + + * Evolution-Storage.idl: add Storage_asyncRemoveSharedFolder + + * e-shell-shared-folder-picker-dialog.c: Remove all the CORBA + stuff from here and use the new EStorage methods. + (setup_server_option_menu): Use e_storage_supports_shared_folders. + (discover_folder): Use e_storage_async_discover_shared_folder. + + * evolution-storage.c (impl_Storage_asyncRemoveSharedFolder): + Implement this by emitting a REMOVE_SHARED_FOLDER signal. + (impl_Storage_asyncDiscoverSharedFolder): Make the + DISCOVER_SHARED_FOLDER signal put the Bonobo_Listener first like + all the other signals do. + (class_init): Set up REMOVE_SHARED_FOLDER signal. + +2002-09-30 Dan Winship <danw@ximian.com> + * evolution-folder-selector-button.c (clicked): If we return from evolution_shell_client_user_select_folder to find that our parent window has been destroyed, unref it and bail out, since that means diff --git a/shell/Evolution-Storage.idl b/shell/Evolution-Storage.idl index 02506af4ec..d6374e4577 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 asyncRemoveSharedFolder (in string path, + in Bonobo::Listener listener); /* Listener handling. */ void addListener (in StorageListener listener) diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c index d50a01e921..b640ff22b9 100644 --- a/shell/e-corba-storage.c +++ b/shell/e-corba-storage.c @@ -474,6 +474,126 @@ async_open_folder (EStorage *storage, } +/* Shared folders. */ + +static gboolean +supports_shared_folders (EStorage *storage) +{ + GNOME_Evolution_Storage storage_iface; + CORBA_boolean has_shared_folders; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + storage_iface = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage)); + g_assert (storage_iface != CORBA_OBJECT_NIL); + + has_shared_folders = GNOME_Evolution_Storage__get_hasSharedFolders (storage_iface, &ev); + if (BONOBO_EX (&ev)) + has_shared_folders = FALSE; + + CORBA_exception_free (&ev); + + return has_shared_folders; +} + +static void +async_folder_discovery_cb (BonoboListener *listener, char *event_name, + CORBA_any *any, CORBA_Environment *ev, + gpointer user_data) +{ + struct async_folder_closure *closure = user_data; + GNOME_Evolution_Storage_FolderResult *corba_result; + EStorageDiscoveryCallback callback; + EStorageResult result; + char *path; + + corba_result = any->_value; + result = e_corba_storage_corba_result_to_storage_result (corba_result->result); + if (result == E_STORAGE_OK) + path = corba_result->path; + else + path = NULL; + + callback = (EStorageDiscoveryCallback)closure->callback; + (* callback) (closure->storage, result, path, closure->data); + + bonobo_object_unref (BONOBO_OBJECT (listener)); + g_free (closure); +} + +static void +async_discover_shared_folder (EStorage *storage, + const char *owner, + const char *folder_name, + EStorageDiscoveryCallback callback, + void *data) +{ + ECorbaStorage *corba_storage; + ECorbaStoragePrivate *priv; + BonoboListener *listener; + Bonobo_Listener corba_listener; + CORBA_Environment ev; + struct async_folder_closure *closure; + + corba_storage = E_CORBA_STORAGE (storage); + priv = corba_storage->priv; + + closure = g_new (struct async_folder_closure, 1); + closure->callback = (EStorageResultCallback)callback; + closure->storage = storage; + closure->data = data; + listener = bonobo_listener_new (async_folder_discovery_cb, closure); + corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); + + CORBA_exception_init (&ev); + GNOME_Evolution_Storage_asyncDiscoverSharedFolder (priv->storage_interface, + owner, folder_name, + corba_listener, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + (* callback) (storage, E_STORAGE_GENERICERROR, NULL, data); + bonobo_object_unref (BONOBO_OBJECT (listener)); + g_free (closure); + } + CORBA_exception_free (&ev); +} + +static void +async_remove_shared_folder (EStorage *storage, + const char *path, + EStorageResultCallback callback, + void *data) +{ + ECorbaStorage *corba_storage; + ECorbaStoragePrivate *priv; + BonoboListener *listener; + Bonobo_Listener corba_listener; + CORBA_Environment ev; + struct async_folder_closure *closure; + + corba_storage = E_CORBA_STORAGE (storage); + priv = corba_storage->priv; + + closure = g_new (struct async_folder_closure, 1); + closure->callback = callback; + closure->storage = storage; + closure->data = data; + listener = bonobo_listener_new (async_folder_cb, closure); + corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); + + CORBA_exception_init (&ev); + GNOME_Evolution_Storage_asyncRemoveSharedFolder (priv->storage_interface, + path, corba_listener, + &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + (* callback) (storage, E_STORAGE_GENERICERROR, data); + bonobo_object_unref (BONOBO_OBJECT (listener)); + g_free (closure); + } + CORBA_exception_free (&ev); +} + + static void corba_class_init (void) { @@ -511,6 +631,9 @@ class_init (ECorbaStorageClass *klass) 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; corba_class_init (); diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c index 884fa97c05..4af143c920 100644 --- a/shell/e-shell-folder-commands.c +++ b/shell/e-shell-folder-commands.c @@ -571,6 +571,47 @@ e_shell_command_rename_folder (EShell *shell, } +static void +remove_shared_cb (EStorageSet *storage_set, + EStorageResult result, + void *data) +{ + EShellView *shell_view; + + shell_view = E_SHELL_VIEW (data); + + if (result == E_STORAGE_NOTIMPLEMENTED || + result == E_STORAGE_UNSUPPORTEDOPERATION) + e_notice (GTK_WINDOW (shell_view), GNOME_MESSAGE_BOX_ERROR, + _("Selected folder does not belong to another user")); + else if (result != E_STORAGE_OK) + e_notice (GTK_WINDOW (shell_view), GNOME_MESSAGE_BOX_ERROR, + _("Cannot remove folder:\n%s"), e_storage_result_to_string (result)); +} + +void +e_shell_command_remove_shared_folder (EShell *shell, + EShellView *shell_view, + const char *folder_path) +{ + EStorageSet *storage_set; + + g_return_if_fail (shell != NULL); + g_return_if_fail (E_IS_SHELL (shell)); + g_return_if_fail (shell_view != NULL || folder_path != NULL); + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + g_return_if_fail (folder_path != NULL || g_path_is_absolute (folder_path)); + + storage_set = e_shell_get_storage_set (shell); + + if (folder_path == NULL) + folder_path = e_shell_view_get_current_path (shell_view); + + e_storage_set_async_remove_shared_folder (storage_set, folder_path, + remove_shared_cb, shell_view); +} + + void e_shell_command_add_to_shortcut_bar (EShell *shell, EShellView *shell_view, diff --git a/shell/e-shell-folder-commands.h b/shell/e-shell-folder-commands.h index 5e573ef566..72b7ba0b0e 100644 --- a/shell/e-shell-folder-commands.h +++ b/shell/e-shell-folder-commands.h @@ -35,6 +35,8 @@ void e_shell_command_move_folder (EShell *shell, EShellView *shell_view, con void e_shell_command_delete_folder (EShell *shell, EShellView *shell_view, const char *folder_path); void e_shell_command_rename_folder (EShell *shell, EShellView *shell_view, const char *folder_path); +void e_shell_command_remove_shared_folder (EShell *shell, EShellView *shell_view, const char *folder_path); + void e_shell_command_add_to_shortcut_bar (EShell *shell, EShellView *shell_view, const char *folder_path); #endif diff --git a/shell/e-shell-shared-folder-picker-dialog.c b/shell/e-shell-shared-folder-picker-dialog.c index 830dbb3b9e..5316b2f8fb 100644 --- a/shell/e-shell-shared-folder-picker-dialog.c +++ b/shell/e-shell-shared-folder-picker-dialog.c @@ -179,48 +179,26 @@ setup_server_option_menu (EShell *shell, *storage_name_return = NULL; storages = e_storage_set_get_storage_list (e_shell_get_storage_set (shell)); for (p = storages; p != NULL; p = p->next) { - GNOME_Evolution_Storage storage_iface; - CORBA_boolean has_shared_folders; - CORBA_Environment ev; + GtkWidget *menu_item; + const char *storage_name; - /* FIXME FIXME FIXME. - - OK, this sucks. Only CORBA storages can be used as shared - folder servers. Eventually, there will only be CORBA - storages so the special case will go away automatically. For - the time being, we are left with this ugliness, but it makes - my life easier. */ - - if (! E_IS_CORBA_STORAGE (p->data)) + if (!e_storage_supports_shared_folders (p->data)) continue; - CORBA_exception_init (&ev); - - storage_iface = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (p->data)); - g_assert (storage_iface != CORBA_OBJECT_NIL); + storage_name = e_storage_get_name (E_STORAGE (p->data)); - has_shared_folders = GNOME_Evolution_Storage__get_hasSharedFolders (storage_iface, &ev); - if (! BONOBO_EX (&ev) && has_shared_folders) { - GtkWidget *menu_item; - const char *storage_name; + menu_item = gtk_menu_item_new_with_label (storage_name); + gtk_signal_connect (GTK_OBJECT (menu_item), "activate", + GTK_SIGNAL_FUNC (server_option_menu_item_activate_callback), + storage_name_return); + gtk_object_set_data_full (GTK_OBJECT (menu_item), "storage_name", + g_strdup (storage_name), g_free); - storage_name = e_storage_get_name (E_STORAGE (p->data)); + gtk_widget_show (menu_item); + gtk_menu_append (GTK_MENU (menu), menu_item); - menu_item = gtk_menu_item_new_with_label (storage_name); - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", - GTK_SIGNAL_FUNC (server_option_menu_item_activate_callback), - storage_name_return); - gtk_object_set_data_full (GTK_OBJECT (menu_item), "storage_name", - g_strdup (storage_name), g_free); - - gtk_widget_show (menu_item); - gtk_menu_append (GTK_MENU (menu), menu_item); - - if (*storage_name_return == NULL) - *storage_name_return = g_strdup (storage_name); - } - - CORBA_exception_free (&ev); + if (*storage_name_return == NULL) + *storage_name_return = g_strdup (storage_name); } gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu); @@ -283,7 +261,6 @@ struct _DiscoveryData { EShell *shell; EShellView *parent; GtkWidget *dialog; - EStorage *storage; char *user; char *folder_name; }; @@ -425,47 +402,38 @@ storage_destroy_callback (GtkObject *object, } static void -shared_folder_discovery_listener_callback (BonoboListener *listener, - char *event_name, - CORBA_any *value, - CORBA_Environment *ev, - void *data) +shared_folder_discovery_callback (EStorage *storage, + EStorageResult result, + const char *path, + void *data) { - GNOME_Evolution_Storage_FolderResult *result; DiscoveryData *discovery_data; EShell *shell; EShellView *parent; - EStorage *storage; discovery_data = (DiscoveryData *) data; shell = discovery_data->shell; parent = discovery_data->parent; - storage = discovery_data->storage; /* Make sure the progress dialog doesn't show up now. */ cleanup_discovery (discovery_data); - result = (GNOME_Evolution_Storage_FolderResult *) value->_value; - if (result->result == GNOME_Evolution_Storage_OK) { + if (result == E_STORAGE_OK) { char *uri; uri = g_strconcat (E_SHELL_URI_PREFIX, "/", e_storage_get_name (storage), - result->path, - NULL); + path, NULL); if (discovery_data->parent != NULL) e_shell_view_display_uri (parent, uri, TRUE); else e_shell_create_view (shell, uri, NULL); } else { - EStorageResult storage_result; - - storage_result = e_corba_storage_corba_result_to_storage_result (result->result); e_notice (parent ? GTK_WINDOW (parent) : NULL, GNOME_MESSAGE_BOX_ERROR, _("Could not open shared folder: %s."), - e_storage_result_to_string (storage_result)); + e_storage_result_to_string (result)); } } @@ -479,22 +447,14 @@ discover_folder (EShell *shell, EStorageSet *storage_set; EStorage *storage; GtkWidget *dialog; - BonoboListener *listener; - GNOME_Evolution_Storage corba_iface; - CORBA_Environment ev; DiscoveryData *discovery_data; - discovery_data = NULL; - dialog = NULL; - - CORBA_exception_init (&ev); - storage_set = e_shell_get_storage_set (shell); if (storage_set == NULL) goto error; storage = e_storage_set_get_storage (storage_set, storage_name); - if (storage == NULL || ! E_IS_CORBA_STORAGE (storage)) + if (storage == NULL || ! e_storage_supports_shared_folders (storage)) goto error; dialog = create_progress_dialog (shell, storage, user_email_address, folder_name); @@ -503,7 +463,6 @@ discover_folder (EShell *shell, discovery_data->dialog = dialog; discovery_data->shell = shell; discovery_data->parent = parent; - discovery_data->storage = storage; discovery_data->user = g_strdup (user_email_address); discovery_data->folder_name = g_strdup (folder_name); @@ -516,29 +475,17 @@ discover_folder (EShell *shell, gtk_signal_connect (GTK_OBJECT (storage), "destroy", GTK_SIGNAL_FUNC (storage_destroy_callback), discovery_data); - listener = bonobo_listener_new (shared_folder_discovery_listener_callback, discovery_data); - - corba_iface = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage)); - GNOME_Evolution_Storage_asyncDiscoverSharedFolder (corba_iface, - user_email_address, folder_name, - BONOBO_OBJREF (listener), - &ev); - if (BONOBO_EX (&ev)) - goto error; - - CORBA_exception_free (&ev); - + e_storage_async_discover_shared_folder (storage, + user_email_address, + folder_name, + shared_folder_discovery_callback, + discovery_data); return; error: - if (discovery_data != NULL) - cleanup_discovery (discovery_data); - /* FIXME: Be more verbose? */ e_notice (GTK_WINDOW (parent), GNOME_MESSAGE_BOX_ERROR, _("Cannot find the specified shared folder.")); - - CORBA_exception_free (&ev); } diff --git a/shell/e-shell-view-menu.c b/shell/e-shell-view-menu.c index c8ee62123c..253c8f6169 100644 --- a/shell/e-shell-view-menu.c +++ b/shell/e-shell-view-menu.c @@ -429,7 +429,7 @@ command_add_folder_to_shortcut_bar (BonoboUIComponent *uih, } -/* Opening other users' folders. */ +/* Opening and removing other users' folders. */ static void command_open_other_users_folder (BonoboUIComponent *uih, @@ -445,6 +445,18 @@ command_open_other_users_folder (BonoboUIComponent *uih, e_shell_show_shared_folder_picker_dialog (shell, shell_view); } +static void +command_remove_other_users_folder (BonoboUIComponent *uih, + void *data, + const char *path) +{ + EShellView *shell_view; + + shell_view = E_SHELL_VIEW (data); + e_shell_command_remove_shared_folder (e_shell_view_get_shell (shell_view), shell_view, + get_path_for_folder_op (shell_view)); +} + /* Going to a folder. */ @@ -667,6 +679,7 @@ static BonoboUIVerb new_verbs [] = { static BonoboUIVerb file_verbs [] = { BONOBO_UI_VERB ("FileImporter", (BonoboUIVerbFn) show_import_wizard), BONOBO_UI_VERB ("FileOpenOtherUsersFolder", command_open_other_users_folder), + BONOBO_UI_VERB ("FileRemoveOtherUsersFolder", command_remove_other_users_folder), BONOBO_UI_VERB ("FileGoToFolder", command_goto_folder), BONOBO_UI_VERB ("FileCreateFolder", command_create_folder), BONOBO_UI_VERB ("FileClose", command_close), diff --git a/shell/e-storage-set.c b/shell/e-storage-set.c index 6303ef9320..a7043df577 100644 --- a/shell/e-storage-set.c +++ b/shell/e-storage-set.c @@ -774,6 +774,38 @@ e_storage_set_async_xfer_folder (EStorageSet *storage_set, storage_callback, storage_callback_data); } +void +e_storage_set_async_remove_shared_folder (EStorageSet *storage_set, + const char *path, + EStorageSetResultCallback callback, + void *data) +{ + EStorage *storage; + const char *subpath; + StorageCallbackData *storage_callback_data; + + g_return_if_fail (storage_set != NULL); + g_return_if_fail (E_IS_STORAGE_SET (storage_set)); + g_return_if_fail (path != NULL); + g_return_if_fail (g_path_is_absolute (path)); + g_return_if_fail (callback != NULL); + + storage = get_storage_for_path (storage_set, path, &subpath); + + if (!e_storage_supports_shared_folders (storage)) { + (* callback) (storage_set, E_STORAGE_NOTIMPLEMENTED, data); + return; + } + + storage_callback_data = storage_callback_data_new (storage_set, callback, + path, NULL, OPERATION_REMOVE, + data); + + e_storage_async_remove_shared_folder (storage, subpath, + storage_callback, + storage_callback_data); +} + EFolderTypeRegistry * e_storage_set_get_folder_type_registry (EStorageSet *storage_set) diff --git a/shell/e-storage-set.h b/shell/e-storage-set.h index f614e70ffc..35c83a3eb5 100644 --- a/shell/e-storage-set.h +++ b/shell/e-storage-set.h @@ -104,6 +104,11 @@ void e_storage_set_async_xfer_folder (EStorageSet *storage_set EStorageSetResultCallback callback, void *data); +void e_storage_set_async_remove_shared_folder (EStorageSet *storage_set, + const char *path, + EStorageSetResultCallback callback, + void *data); + EFolderTypeRegistry *e_storage_set_get_folder_type_registry (EStorageSet *storage_set); /* Utility functions. */ diff --git a/shell/e-storage.c b/shell/e-storage.c index df8a21faa1..6be864ffa9 100644 --- a/shell/e-storage.c +++ b/shell/e-storage.c @@ -231,6 +231,31 @@ impl_async_open_folder (EStorage *storage, ; } +static gboolean +impl_supports_shared_folders (EStorage *storage) +{ + return FALSE; +} + +static void +impl_async_discover_shared_folder (EStorage *storage, + const char *owner, + const char *folder_name, + EStorageDiscoveryCallback callback, + void *data) +{ + (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, NULL, data); +} + +static void +impl_async_remove_shared_folder (EStorage *storage, + const char *path, + EStorageResultCallback callback, + void *data) +{ + (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data); +} + /* Initialization. */ @@ -252,6 +277,10 @@ 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; + signals[NEW_FOLDER] = gtk_signal_new ("new_folder", GTK_RUN_FIRST, @@ -478,6 +507,47 @@ e_storage_async_open_folder (EStorage *storage, } +/* Shared folders. */ + +gboolean +e_storage_supports_shared_folders (EStorage *storage) +{ + g_return_val_if_fail (storage != NULL, FALSE); + g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); + + return (* ES_CLASS (storage)->supports_shared_folders) (storage); +} + +void +e_storage_async_discover_shared_folder (EStorage *storage, + const char *owner, + const char *folder_name, + EStorageDiscoveryCallback callback, + void *data) +{ + g_return_if_fail (storage != NULL); + g_return_if_fail (E_IS_STORAGE (storage)); + g_return_if_fail (owner != NULL); + g_return_if_fail (folder_name != NULL); + + (* ES_CLASS (storage)->async_discover_shared_folder) (storage, owner, folder_name, callback, data); +} + +void +e_storage_async_remove_shared_folder (EStorage *storage, + const char *path, + EStorageResultCallback callback, + void *data) +{ + g_return_if_fail (storage != NULL); + g_return_if_fail (E_IS_STORAGE (storage)); + g_return_if_fail (path != NULL); + g_return_if_fail (g_path_is_absolute (path)); + + (* ES_CLASS (storage)->async_remove_shared_folder) (storage, path, callback, data); +} + + const char * e_storage_result_to_string (EStorageResult result) { diff --git a/shell/e-storage.h b/shell/e-storage.h index 43ad6f442b..f017cacc1d 100644 --- a/shell/e-storage.h +++ b/shell/e-storage.h @@ -64,6 +64,7 @@ enum _EStorageResult { typedef enum _EStorageResult EStorageResult; typedef void (* EStorageResultCallback) (EStorage *storage, EStorageResult result, void *data); +typedef void (* EStorageDiscoveryCallback) (EStorage *storage, EStorageResult result, const char *path, void *data); #include "e-folder.h" @@ -85,9 +86,11 @@ struct _EStorageClass { /* Virtual methods. */ - GList * (* get_subfolder_paths) (EStorage *storage, const char *path); - EFolder * (* get_folder) (EStorage *storage, const char *path); - const char * (* get_name) (EStorage *storage); + GList * (* get_subfolder_paths) (EStorage *storage, + const char *path); + EFolder * (* get_folder) (EStorage *storage, + const char *path); + const char * (* get_name) (EStorage *storage); void (* async_create_folder) (EStorage *storage, const char *path, @@ -111,25 +114,35 @@ 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); }; -GtkType e_storage_get_type (void); -void e_storage_construct (EStorage *storage, - const char *name, - EFolder *root_folder); -EStorage *e_storage_new (const char *name, - EFolder *root_folder); +GtkType e_storage_get_type (void); +void e_storage_construct (EStorage *storage, + const char *name, + EFolder *root_folder); +EStorage *e_storage_new (const char *name, + EFolder *root_folder); -gboolean e_storage_path_is_relative (const char *path); -gboolean e_storage_path_is_absolute (const char *path); +gboolean e_storage_path_is_relative (const char *path); +gboolean e_storage_path_is_absolute (const char *path); -GList *e_storage_get_subfolder_paths (EStorage *storage, - const char *path); -EFolder *e_storage_get_folder (EStorage *storage, - const char *path); +GList *e_storage_get_subfolder_paths (EStorage *storage, + const char *path); +EFolder *e_storage_get_folder (EStorage *storage, + const char *path); -const char *e_storage_get_name (EStorage *storage); +const char *e_storage_get_name (EStorage *storage); /* Folder operations. */ @@ -154,6 +167,18 @@ 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); + /* Utility functions. */ char *e_storage_get_path_for_physical_uri (EStorage *storage, diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c index e5d63404ab..141feff758 100644 --- a/shell/evolution-storage.c +++ b/shell/evolution-storage.c @@ -83,6 +83,7 @@ enum { UPDATE_FOLDER, OPEN_FOLDER, DISCOVER_SHARED_FOLDER, + REMOVE_SHARED_FOLDER, SHOW_FOLDER_PROPERTIES, LAST_SIGNAL @@ -501,7 +502,25 @@ impl_Storage_asyncDiscoverSharedFolder (PortableServer_Servant servant, obj_dup = CORBA_Object_duplicate (listener, ev); gtk_signal_emit (GTK_OBJECT (storage), signals[DISCOVER_SHARED_FOLDER], - user, folder_name, obj_dup); + obj_dup, user, folder_name); +} + +static void +impl_Storage_asyncRemoveSharedFolder (PortableServer_Servant servant, + const CORBA_char *path, + const Bonobo_Listener listener, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionStorage *storage; + CORBA_Object obj_dup; + + bonobo_object = bonobo_object_from_servant (servant); + storage = EVOLUTION_STORAGE (bonobo_object); + + obj_dup = CORBA_Object_duplicate (listener, ev); + gtk_signal_emit (GTK_OBJECT (storage), signals[REMOVE_SHARED_FOLDER], + obj_dup, path); } static void @@ -782,9 +801,19 @@ class_init (EvolutionStorageClass *klass) discover_shared_folder), e_marshal_NONE__POINTER_POINTER_POINTER, GTK_TYPE_NONE, 3, + GTK_TYPE_POINTER, GTK_TYPE_STRING, - GTK_TYPE_STRING, - GTK_TYPE_POINTER); + GTK_TYPE_STRING); + + signals[REMOVE_SHARED_FOLDER] = gtk_signal_new ("remove_shared_folder", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionStorageClass, + remove_shared_folder), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, + GTK_TYPE_STRING, + GTK_TYPE_POINTER); signals[SHOW_FOLDER_PROPERTIES] = gtk_signal_new ("show_folder_properties", GTK_RUN_LAST, @@ -835,6 +864,7 @@ evolution_storage_get_epv (void) 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; diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h index 751e9e55d5..b0f55642ce 100644 --- a/shell/evolution-storage.h +++ b/shell/evolution-storage.h @@ -109,9 +109,13 @@ struct _EvolutionStorageClass { int unread_count); void (*discover_shared_folder) (EvolutionStorage *storage, + Bonobo_Listener listener, const char *user, - const char *folder_name, - Bonobo_Listener listener); + const char *folder_name); + + void (*remove_shared_folder) (EvolutionStorage *storage, + Bonobo_Listener listener, + const char *path); void (*show_folder_properties) (EvolutionStorage *storage, const char *path, |