aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/component-factory.c1565
-rw-r--r--mail/component-factory.h30
-rw-r--r--mail/folder-browser.c2679
-rw-r--r--mail/folder-browser.h192
4 files changed, 0 insertions, 4466 deletions
diff --git a/mail/component-factory.c b/mail/component-factory.c
deleted file mode 100644
index 9f361ec5fc..0000000000
--- a/mail/component-factory.c
+++ /dev/null
@@ -1,1565 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* component-factory.c
- *
- * Authors: Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- */
-
-/* EPFIXME: This file should go away. */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <signal.h>
-
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
-
-#include <camel/camel.h>
-#include <camel/camel-vee-store.h>
-
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-shlib-factory.h>
-
-#include <gal/widgets/e-gui-utils.h>
-
-#include "e-util/e-dialog-utils.h"
-
-#include "Evolution.h"
-#include "evolution-storage.h"
-#include "evolution-wizard.h"
-#include "evolution-composer.h"
-
-#include "folder-browser-factory.h"
-#include "evolution-shell-component.h"
-#include "evolution-shell-component-dnd.h"
-#include "folder-info.h"
-#include "mail.h"
-#include "mail-config.h"
-#include "mail-config-factory.h"
-#include "mail-preferences.h"
-#include "mail-component.h"
-#include "mail-composer-prefs.h"
-#include "mail-tools.h"
-#include "mail-ops.h"
-#include "mail-offline-handler.h"
-#include "mail-local.h"
-#include "mail-session.h"
-#include "mail-mt.h"
-#include "mail-importer.h"
-#include "mail-folder-cache.h"
-#include "em-utils.h"
-#include "component-factory.h"
-
-#include "mail-send-recv.h"
-
-#include "mail-vfolder.h"
-#include "mail-autofilter.h"
-
-#define d(x)
-
-char *default_drafts_folder_uri;
-CamelFolder *drafts_folder = NULL;
-char *default_sent_folder_uri;
-CamelFolder *sent_folder = NULL;
-char *default_outbox_folder_uri;
-CamelFolder *outbox_folder = NULL;
-
-EvolutionShellClient *global_shell_client = NULL;
-
-RuleContext *search_context = NULL;
-
-static MailAsyncEvent *async_event = NULL;
-
-static GHashTable *storages_hash;
-static EvolutionShellComponent *shell_component;
-
-enum {
- ACCEPTED_DND_TYPE_MESSAGE_RFC822,
- ACCEPTED_DND_TYPE_X_EVOLUTION_MESSAGE,
- ACCEPTED_DND_TYPE_TEXT_URI_LIST,
-};
-
-static char *accepted_dnd_types[] = {
- "message/rfc822",
- "x-evolution-message", /* ...from an evolution message list... */
- "text/uri-list", /* ...from nautilus... */
- NULL
-};
-
-enum {
- EXPORTED_DND_TYPE_TEXT_URI_LIST,
-};
-
-static char *exported_dnd_types[] = {
- "text/uri-list", /* we have to export to nautilus as text/uri-list */
- NULL
-};
-
-static const EvolutionShellComponentFolderType folder_types[] = {
- { "mail", "evolution-inbox.png", N_("Mail"), N_("Folder containing mail"), TRUE, accepted_dnd_types, exported_dnd_types },
- { "mail/public", "evolution-inbox.png", N_("Public Mail"), N_("Public folder containing mail"), FALSE, accepted_dnd_types, exported_dnd_types },
- { "vtrash", "evolution-trash.png", N_("Virtual Trash"), N_("Virtual Trash folder"), FALSE, accepted_dnd_types, exported_dnd_types },
- { NULL, NULL, NULL, NULL, FALSE, NULL, NULL }
-};
-
-static const char *schema_types[] = {
- "mailto",
- NULL
-};
-
-static inline gboolean
-type_is_mail (const char *type)
-{
- return !strcmp (type, "mail") || !strcmp (type, "mail/public");
-}
-
-static inline gboolean
-type_is_vtrash (const char *type)
-{
- return !strcmp (type, "vtrash");
-}
-
-
-/* Forward decls just to get it to compile without warnings. EPFIXME: This is
- all junk at this point in the refactoring anyways, so it will all die. */
-static void mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const char *name);
-static void mail_load_storages (GNOME_Evolution_Shell shell, EAccountList *accounts);
-static void mail_hash_storage (CamelService *store, EvolutionStorage *storage);
-
-
-/* EvolutionShellComponent methods and signals. */
-
-static BonoboControl *
-create_noselect_control (void)
-{
- GtkWidget *label;
-
- label = gtk_label_new (_("This folder cannot contain messages."));
- gtk_widget_show (label);
- return bonobo_control_new (label);
-}
-
-static EvolutionShellComponentResult
-create_view (EvolutionShellComponent *shell_component,
- const char *physical_uri,
- const char *folder_type,
- const char *view_info,
- BonoboControl **control_return,
- void *closure)
-{
- EvolutionShellClient *shell_client;
- GNOME_Evolution_Shell corba_shell;
- BonoboControl *control;
-
- shell_client = evolution_shell_component_get_owner (shell_component);
- corba_shell = evolution_shell_client_corba_objref(shell_client);
-
- if (type_is_mail (folder_type)) {
- const char *noselect;
- CamelURL *url;
-
- url = camel_url_new (physical_uri, NULL);
- noselect = url ? camel_url_get_param (url, "noselect") : NULL;
- if (noselect && !strcasecmp (noselect, "yes"))
- control = create_noselect_control ();
- else
- control = folder_browser_factory_new_control (physical_uri,
- corba_shell);
- camel_url_free (url);
- } else if (type_is_vtrash (folder_type)) {
- if (!strncasecmp (physical_uri, "file:", 5))
- control = folder_browser_factory_new_control ("vtrash:file:/", corba_shell);
- else
- control = folder_browser_factory_new_control (physical_uri, corba_shell);
- } else
- return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE;
-
- if (!control)
- return EVOLUTION_SHELL_COMPONENT_NOTFOUND;
-
- *control_return = control;
- return EVOLUTION_SHELL_COMPONENT_OK;
-}
-
-static void
-create_folder_done (char *uri, CamelFolder *folder, void *data)
-{
- GNOME_Evolution_ShellComponentListener listener = data;
- GNOME_Evolution_ShellComponentListener_Result result;
- CORBA_Environment ev;
-
- if (folder) {
- result = GNOME_Evolution_ShellComponentListener_OK;
- } else {
- result = GNOME_Evolution_ShellComponentListener_INVALID_URI;
- }
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, result, &ev);
- CORBA_Object_release (listener, &ev);
- CORBA_exception_free (&ev);
-}
-
-static void
-create_folder (EvolutionShellComponent *shell_component,
- const char *physical_uri,
- const char *type,
- const GNOME_Evolution_ShellComponentListener listener,
- void *closure)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- if (type_is_mail (type)) {
- mail_get_folder (physical_uri, CAMEL_STORE_FOLDER_CREATE, create_folder_done,
- CORBA_Object_duplicate (listener, &ev), mail_thread_new);
- } else {
- GNOME_Evolution_ShellComponentListener_notifyResult (
- listener, GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, &ev);
- }
-
- CORBA_exception_free (&ev);
-}
-
-static void
-remove_folder_done (char *uri, gboolean removed, void *data)
-{
- GNOME_Evolution_ShellComponentListener listener = data;
- GNOME_Evolution_ShellComponentListener_Result result;
- CORBA_Environment ev;
-
- if (removed)
- result = GNOME_Evolution_ShellComponentListener_OK;
- else
- result = GNOME_Evolution_ShellComponentListener_INVALID_URI;
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, result, &ev);
- CORBA_Object_release (listener, &ev);
- CORBA_exception_free (&ev);
-}
-
-static void
-remove_folder (EvolutionShellComponent *shell_component,
- const char *physical_uri,
- const char *type,
- const GNOME_Evolution_ShellComponentListener listener,
- void *closure)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- if (!type_is_mail (type)) {
- GNOME_Evolution_ShellComponentListener_notifyResult (listener,
- GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, &ev);
- CORBA_exception_free (&ev);
- return;
- }
-
- mail_remove_folder (physical_uri, remove_folder_done, CORBA_Object_duplicate (listener, &ev));
- CORBA_exception_free (&ev);
-}
-
-typedef struct _xfer_folder_data {
- GNOME_Evolution_ShellComponentListener listener;
- gboolean remove_source;
- char *source_uri;
-} xfer_folder_data;
-
-static void
-xfer_folder_done (gboolean ok, void *data)
-{
- xfer_folder_data *xfd = (xfer_folder_data *)data;
- GNOME_Evolution_ShellComponentListener listener = xfd->listener;
- GNOME_Evolution_ShellComponentListener_Result result;
- CORBA_Environment ev;
-
- if (xfd->remove_source && ok) {
- mail_remove_folder (xfd->source_uri, remove_folder_done, xfd->listener);
- } else {
- if (ok)
- result = GNOME_Evolution_ShellComponentListener_OK;
- else
- result = GNOME_Evolution_ShellComponentListener_INVALID_URI;
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, result, &ev);
- CORBA_Object_release (listener, &ev);
- CORBA_exception_free (&ev);
- }
-
- g_free (xfd->source_uri);
- g_free (xfd);
-}
-
-static void
-xfer_folder (EvolutionShellComponent *shell_component,
- const char *source_physical_uri,
- const char *destination_physical_uri,
- const char *type,
- gboolean remove_source,
- const GNOME_Evolution_ShellComponentListener listener,
- void *closure)
-{
- CORBA_Environment ev;
- CamelFolder *source;
- CamelException ex;
- GPtrArray *uids;
- CamelURL *src, *dst;
-
- d(printf("Renaming folder '%s' to dest '%s' type '%s'\n", source_physical_uri, destination_physical_uri, type));
-
- CORBA_exception_init (&ev);
-
- if (!type_is_mail (type)) {
- GNOME_Evolution_ShellComponentListener_notifyResult (listener,
- GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, &ev);
- return;
- }
-
- src = camel_url_new(source_physical_uri, NULL);
- if (src == NULL) {
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev);
- return;
- }
-
- dst = camel_url_new(destination_physical_uri, NULL);
- if (dst == NULL) {
- camel_url_free(src);
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev);
- return;
- }
-
- if (camel_url_get_param(dst, "noselect") != NULL) {
- camel_url_free(src);
- camel_url_free(dst);
- GNOME_Evolution_ShellComponentListener_notifyResult (listener,
- GNOME_Evolution_ShellComponentListener_UNSUPPORTED_OPERATION, &ev);
- return;
- }
-
- camel_exception_init (&ex);
-
- /* If we are really doing a rename, implement it as a rename */
- if (remove && strcmp(src->protocol, dst->protocol) == 0) {
- char *sname, *dname;
- CamelStore *store;
-
- if (src->fragment)
- sname = src->fragment;
- else {
- if (src->path && *src->path)
- sname = src->path+1;
- else
- sname = "";
- }
-
- if (dst->fragment)
- dname = dst->fragment;
- else {
- if (dst->path && *dst->path)
- dname = dst->path+1;
- else
- dname = "";
- }
-
- store = camel_session_get_store(session, source_physical_uri, &ex);
- if (store != NULL)
- camel_store_rename_folder(store, sname, dname, &ex);
-
- if (camel_exception_is_set(&ex))
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev);
- else {
- /* Since the shell doesn't play nice with local folders, we have to do this manually */
- mail_vfolder_rename_uri(store, source_physical_uri, destination_physical_uri);
- mail_filter_rename_uri(store, source_physical_uri, destination_physical_uri);
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_OK, &ev);
- }
- camel_object_unref((CamelObject *)store);
- } else {
- source = mail_tool_uri_to_folder (source_physical_uri, 0, &ex);
-
- if (source) {
- xfer_folder_data *xfd;
-
- xfd = g_new0 (xfer_folder_data, 1);
- xfd->remove_source = remove_source;
- xfd->source_uri = g_strdup (source_physical_uri);
- xfd->listener = CORBA_Object_duplicate (listener, &ev);
-
- uids = camel_folder_get_uids (source);
- mail_transfer_messages (source, uids, remove_source, destination_physical_uri, CAMEL_STORE_FOLDER_CREATE, xfer_folder_done, xfd);
- camel_object_unref (CAMEL_OBJECT (source));
- } else
- GNOME_Evolution_ShellComponentListener_notifyResult (listener, GNOME_Evolution_ShellComponentListener_INVALID_URI, &ev);
- }
-
- CORBA_exception_free (&ev);
- camel_exception_clear (&ex);
-
- camel_url_free(src);
- camel_url_free(dst);
-}
-
-static void
-configure_folder_popup(BonoboUIComponent *component, void *user_data, const char *cname)
-{
- char *uri = user_data;
-
- /* FIXME: re-implement */
-
- if (strncmp(uri, "vfolder:", 8) == 0)
- vfolder_edit_rule(uri);
-#if 0
- else {
- struct _EMFolderBrowser *fb = folder_browser_factory_get_browser(uri);
-
- if (fb)
- configure_folder(component, fb, cname);
- else
- mail_local_reconfigure_folder(uri, NULL, NULL);
- }
-#endif
-}
-
-static void
-populate_folder_context_menu (EvolutionShellComponent *shell_component,
- BonoboUIComponent *uic,
- const char *physical_uri,
- const char *type,
- void *closure)
-{
-#ifdef TRANSLATORS_ONLY
- static char popup_xml_i18n[] = {N_("Properties..."), N_("Change this folder's properties")};
-#endif
- static char popup_xml[] =
- "<menuitem name=\"ChangeFolderPropertiesPopUp\" verb=\"ChangeFolderPropertiesPopUp\""
- " _label=\"Properties...\" _tip=\"Change this folder's properties\"/>";
-
- if (!type_is_mail (type))
- return;
-
- /* FIXME: handle other types */
-
- /* the unmatched test is a bit of a hack but it works */
- if ((strncmp(physical_uri, "vfolder:", 8) == 0
- && strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) == NULL)
- || strncmp(physical_uri, "file:", 5) == 0) {
- bonobo_ui_component_add_verb_full(uic, "ChangeFolderPropertiesPopUp",
- g_cclosure_new(G_CALLBACK(configure_folder_popup),
- g_strdup(physical_uri), (GClosureNotify)g_free));
- bonobo_ui_component_set_translate (uic, EVOLUTION_SHELL_COMPONENT_POPUP_PLACEHOLDER, popup_xml, NULL);
- }
-}
-
-static void
-unpopulate_folder_context_menu (EvolutionShellComponent *shell_component,
- BonoboUIComponent *uic,
- const char *physical_uri,
- const char *type,
- void *closure)
-{
- if (!type_is_mail (type))
- return;
-
- /* FIXME: handle other types */
-
- /* the unmatched test is a bit of a hack but it works */
- if ((strncmp(physical_uri, "vfolder:", 8) == 0
- && strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) == NULL)
- || strncmp(physical_uri, "file:", 5) == 0) {
- bonobo_ui_component_rm (uic, EVOLUTION_SHELL_COMPONENT_POPUP_PLACEHOLDER "/ChangeFolderPropertiesPopUp", NULL);
- }
-}
-
-static char *
-get_dnd_selection (EvolutionShellComponent *shell_component,
- const char *physical_uri,
- int type,
- int *format_return,
- const char **selection_return,
- int *selection_length_return,
- void *closure)
-{
- d(printf ("should get dnd selection for %s\n", physical_uri));
-
- return NULL;
-}
-
-/* Destination side DnD */
-static CORBA_boolean
-destination_folder_handle_motion (EvolutionShellComponentDndDestinationFolder *folder,
- const char *physical_uri,
- const char *folder_type,
- const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context *destination_context,
- GNOME_Evolution_ShellComponentDnd_Action *suggested_action_return,
- gpointer user_data)
-{
- const char *noselect;
- CamelURL *url;
-
- url = camel_url_new (physical_uri, NULL);
- noselect = url ? camel_url_get_param (url, "noselect") : NULL;
-
- if (noselect && !strcasecmp (noselect, "yes"))
- /* uh, no way to say "illegal" */
- *suggested_action_return = GNOME_Evolution_ShellComponentDnd_ACTION_DEFAULT;
- else
- *suggested_action_return = GNOME_Evolution_ShellComponentDnd_ACTION_MOVE;
-
- if (url)
- camel_url_free (url);
-
- return TRUE;
-}
-
-static gboolean
-message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex)
-{
- CamelMimeParser *mp;
- gboolean handled = FALSE;
-
- mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mp, TRUE);
- camel_mime_parser_init_with_stream (mp, stream);
-
- while (camel_mime_parser_step (mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM) {
- CamelMessageInfo *info;
- CamelMimeMessage *msg;
-
- handled = TRUE;
-
- msg = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mp) == -1) {
- camel_object_unref (msg);
- handled = FALSE;
- break;
- }
-
- /* append the message to the folder... */
- info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (dest, msg, info, NULL, ex);
- camel_object_unref (msg);
-
- if (camel_exception_is_set (ex)) {
- handled = FALSE;
- break;
- }
-
- /* skip over the FROM_END state */
- camel_mime_parser_step (mp, 0, 0);
- }
-
- camel_object_unref (mp);
-
- return handled;
-}
-
-static CORBA_boolean
-destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *dest_folder,
- const char *physical_uri,
- const char *folder_type,
- const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context *destination_context,
- const GNOME_Evolution_ShellComponentDnd_Action action,
- const GNOME_Evolution_ShellComponentDnd_Data *data,
- gpointer user_data)
-{
- char *tmp, *url, **urls;
- gboolean retval = FALSE;
- const char *noselect;
- CamelFolder *folder;
- CamelStream *stream;
- CamelException ex;
- GPtrArray *uids;
- CamelURL *uri;
- int i, type, fd;
-
- if (action == GNOME_Evolution_ShellComponentDnd_ACTION_LINK)
- return FALSE; /* we can't create links */
-
- /* this means the drag was cancelled */
- if (!data->bytes._buffer || data->bytes._length == -1)
- return FALSE;
-
- uri = camel_url_new (physical_uri, NULL);
- noselect = uri ? camel_url_get_param (uri, "noselect") : NULL;
- if (noselect && !strcasecmp (noselect, "yes")) {
- camel_url_free (uri);
- return FALSE;
- }
-
- if (uri)
- camel_url_free (uri);
-
- d(printf ("in destination_folder_handle_drop (%s)\n", physical_uri));
-
- for (type = 0; accepted_dnd_types[type]; type++)
- if (!strcmp (destination_context->dndType, accepted_dnd_types[type]))
- break;
-
- camel_exception_init (&ex);
-
- /* if this is a local vtrash folder, then it's uri is vtrash:file:/ */
- if (type_is_vtrash (folder_type) && !strncmp (physical_uri, "file:", 5))
- physical_uri = "vtrash:file:/";
-
- switch (type) {
- case ACCEPTED_DND_TYPE_TEXT_URI_LIST:
- folder = mail_tool_uri_to_folder (physical_uri, 0, &ex);
- if (!folder) {
- camel_exception_clear (&ex);
- return FALSE;
- }
-
- tmp = g_strndup (data->bytes._buffer, data->bytes._length);
- urls = g_strsplit (tmp, "\n", 0);
- g_free (tmp);
-
- retval = TRUE;
- for (i = 0; urls[i] != NULL && retval; i++) {
- /* get the path component */
- url = g_strstrip (urls[i]);
-
- uri = camel_url_new (url, NULL);
- g_free (url);
-
- if (!uri)
- continue;
-
- url = uri->path;
- uri->path = NULL;
- camel_url_free (uri);
-
- fd = open (url, O_RDONLY);
- if (fd == -1) {
- g_free (url);
- /* FIXME: okay, so what do we do in this case? */
- continue;
- }
-
- stream = camel_stream_fs_new_with_fd (fd);
- retval = message_rfc822_dnd (folder, stream, &ex);
- camel_object_unref (stream);
- camel_object_unref (folder);
-
- if (action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE && retval)
- unlink (url);
-
- g_free (url);
- }
-
- g_free (urls);
- break;
- case ACCEPTED_DND_TYPE_MESSAGE_RFC822:
- folder = mail_tool_uri_to_folder (physical_uri, 0, &ex);
- if (!folder) {
- camel_exception_clear (&ex);
- return FALSE;
- }
-
- /* write the message(s) out to a CamelStream so we can use it */
- stream = camel_stream_mem_new ();
- camel_stream_write (stream, data->bytes._buffer, data->bytes._length);
- camel_stream_reset (stream);
-
- retval = message_rfc822_dnd (folder, stream, &ex);
- camel_object_unref (stream);
- camel_object_unref (folder);
- break;
- case ACCEPTED_DND_TYPE_X_EVOLUTION_MESSAGE:
- folder = mail_tools_x_evolution_message_parse (data->bytes._buffer,
- data->bytes._length,
- &uids);
-
- if (!folder)
- return FALSE;
-
- mail_transfer_messages (folder, uids,
- action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE,
- physical_uri, 0, NULL, NULL);
-
- camel_object_unref (folder);
- break;
- default:
- break;
- }
-
- camel_exception_clear (&ex);
-
- return retval;
-}
-
-
-static struct {
- char *name, **uri;
- CamelFolder **folder;
-} standard_folders[] = {
- { "Drafts", &default_drafts_folder_uri, &drafts_folder },
- { "Outbox", &default_outbox_folder_uri, &outbox_folder },
- { "Sent", &default_sent_folder_uri, &sent_folder },
-};
-
-static void
-unref_standard_folders (void)
-{
- int i;
-
- for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++) {
- if (standard_folders[i].folder) {
- CamelFolder *folder = *standard_folders[i].folder;
-
- *standard_folders[i].folder = NULL;
-
- if (CAMEL_OBJECT (folder)->ref_count == 1)
- d(printf ("About to finalise folder %s\n", folder->full_name));
- else
- d(printf ("Folder %s still has %d extra ref%s on it\n", folder->full_name,
- CAMEL_OBJECT (folder)->ref_count - 1,
- CAMEL_OBJECT (folder)->ref_count - 1 == 1 ? "" : "s"));
-
- camel_object_unref (CAMEL_OBJECT (folder));
- }
- }
-}
-
-static void
-got_folder (char *uri, CamelFolder *folder, void *data)
-{
- CamelFolder **fp = data;
-
- *fp = folder;
-
- if (folder) {
- camel_object_ref (CAMEL_OBJECT (folder));
-
- /* emit a changed event, this is a little hack so that the folderinfo cache
- will update knowing whether this is the outbox_folder or not, etc */
- if (folder == outbox_folder) {
- CamelFolderChangeInfo *changes = camel_folder_change_info_new();
-
- camel_object_trigger_event((CamelObject *)folder, "folder_changed", changes);
- camel_folder_change_info_free(changes);
- }
- }
-}
-
-static void
-shell_client_destroy (GtkObject *object)
-{
- global_shell_client = NULL;
-}
-
-static void
-owner_set_cb (EvolutionShellComponent *shell_component,
- EvolutionShellClient *shell_client,
- const char *evolution_homedir,
- gpointer user_data)
-{
-#if 0
- GNOME_Evolution_Shell corba_shell;
- EAccountList *accounts;
- int i;
-
- /* FIXME: should we ref this? */
- global_shell_client = shell_client;
- g_object_weak_ref ((GObject *) shell_client, (GWeakNotify) shell_client_destroy, NULL);
-
- mail_session_init ();
-
- async_event = mail_async_event_new();
-
- storages_hash = g_hash_table_new (NULL, NULL);
-
- corba_shell = evolution_shell_client_corba_objref (shell_client);
-
- for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++)
- *standard_folders[i].uri = g_strdup_printf ("file://%s/local/%s", evolution_dir, standard_folders[i].name);
-
- vfolder_load_storage(corba_shell);
-
- accounts = mail_config_get_accounts ();
- mail_load_storages (corba_shell, accounts);
-
- mail_local_storage_startup (shell_client, evolution_dir);
- mail_importer_init (shell_client);
-
- for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++) {
- mail_msg_wait (mail_get_folder (*standard_folders[i].uri, CAMEL_STORE_FOLDER_CREATE,
- got_folder, standard_folders[i].folder, mail_thread_new));
- }
-
- mail_autoreceive_setup ();
-
- {
- /* setup the global quick-search context */
- char *user = g_strdup_printf ("%s/searches.xml", evolution_dir);
- char *system = g_strdup (EVOLUTION_PRIVDATADIR "/searchtypes.xml");
-
- search_context = rule_context_new ();
- g_object_set_data_full(G_OBJECT(search_context), "user", user, g_free);
- g_object_set_data_full(G_OBJECT(search_context), "system", system, g_free);
-
- rule_context_add_part_set (search_context, "partset", filter_part_get_type (),
- rule_context_add_part, rule_context_next_part);
-
- rule_context_add_rule_set (search_context, "ruleset", filter_rule_get_type (),
- rule_context_add_rule, rule_context_next_rule);
-
- rule_context_load (search_context, system, user);
- }
-
- if (mail_config_is_corrupt ()) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
- _("Some of your mail settings seem corrupt, "
- "please check that everything is in order."));
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
- gtk_widget_show (dialog);
- }
-
- /* Everything should be ready now */
- evolution_folder_info_notify_ready ();
-#endif
-}
-
-static void
-free_storage (gpointer service, gpointer storage, gpointer data)
-{
- if (service) {
- mail_note_store_remove((CamelStore *)service);
- camel_service_disconnect (CAMEL_SERVICE (service), TRUE, NULL);
- camel_object_unref (CAMEL_OBJECT (service));
- }
-
- if (storage)
- bonobo_object_unref (BONOBO_OBJECT (storage));
-}
-
-static void
-debug_cb (EvolutionShellComponent *shell_component, gpointer user_data)
-{
- extern gboolean camel_verbose_debug;
-
- camel_verbose_debug = 1;
-}
-
-static void
-interactive_cb (EvolutionShellComponent *shell_component, gboolean on,
- gulong new_view_xid, gpointer user_data)
-{
- mail_session_set_interactive (on);
-
- if (on)
- /* how do we get the parent window? */
- e_msg_composer_check_autosave(NULL);
-}
-
-static void
-handle_external_uri_cb (EvolutionShellComponent *shell_component,
- const char *uri,
- void *data)
-{
- if (strncmp (uri, "mailto:", 7) != 0) {
- /* FIXME: Exception? The EvolutionShellComponent object should
- give me a chance to do so, but currently it doesn't. */
- g_warning ("Invalid URI requested to mail component -- %s", uri);
- return;
- }
-
- /* FIXME: Sigh. This shouldn't be here. But the code is messy, so
- I'll just put it here anyway. */
- em_utils_compose_new_message_with_mailto(NULL, uri);
-}
-
-static void
-user_create_new_item_cb (EvolutionShellComponent *shell_component,
- const char *id,
- const char *parent_folder_physical_uri,
- const char *parent_folder_type,
- gpointer data)
-{
- if (!strcmp (id, "message")) {
- em_utils_compose_new_message_with_mailto(NULL, NULL);
- /*send_to_url (NULL, parent_folder_physical_uri);*/
- return;
- } else if (!strcmp (id, "post")) {
- em_utils_post_to_url (NULL, parent_folder_physical_uri);
- return;
- }
-
- g_warning ("Don't know how to create item of type \"%s\"", id);
-}
-
-static void owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data);
-
-/* Table for signal handler setup/cleanup */
-static struct {
- char *sig;
- GCallback func;
- int hand;
-} shell_component_handlers[] = {
- { "owner_set", G_CALLBACK(owner_set_cb), },
- { "owner_unset", G_CALLBACK(owner_unset_cb), },
- { "debug", G_CALLBACK(debug_cb), },
- { "interactive", G_CALLBACK(interactive_cb) },
- { "destroy", G_CALLBACK(owner_unset_cb), },
- { "handle_external_uri", G_CALLBACK(handle_external_uri_cb), },
- { "user_create_new_item", G_CALLBACK(user_create_new_item_cb) }
-};
-
-static void
-owner_unset_cb (EvolutionShellComponent *shell_component, gpointer user_data)
-{
- CORBA_Environment ev;
- GConfClient *gconf;
- int i;
- EIterator *it;
-
- gconf = mail_config_get_gconf_client ();
-
- for (i=0;i<sizeof(shell_component_handlers)/sizeof(shell_component_handlers[0]);i++)
- g_signal_handler_disconnect((GtkObject *)shell_component, shell_component_handlers[i].hand);
-
- if (gconf_client_get_bool (gconf, "/apps/evolution/mail/trash/empty_on_exit", NULL))
- em_utils_empty_trash(NULL);
-
- unref_standard_folders ();
- mail_local_storage_shutdown ();
- mail_importer_uninit ();
-
- global_shell_client = NULL;
- mail_session_set_interactive (FALSE);
-
- g_object_unref (search_context);
- search_context = NULL;
-
- /* force de-activate of all controls, tho only one should be active anyway? */
- CORBA_exception_init(&ev);
- for (it = e_list_get_iterator(folder_browser_factory_get_control_list());
- e_iterator_is_valid(it);
- e_iterator_next(it)) {
- Bonobo_Control_activate(bonobo_object_corba_objref((BonoboObject *)e_iterator_get(it)),
- FALSE, &ev);
- }
- CORBA_exception_free(&ev);
-
- for (i= 0;i<3;i++) {
- /* need to flush any outstanding tasks before proceeding */
-
- /* NOTE!! This may cause a deadlock situation, if we were
- called from a deeper main loop than the top level
- - is there a way to detect this?
- - is this a very big problem?
- FIXME: should use semaphores or something to wait rather than polling */
- while (e_thread_busy(NULL) || mail_msg_active(-1)) {
- if (g_main_context_pending(NULL))
- g_main_context_iteration(NULL, TRUE);
- else
- usleep(100000);
- }
-
- switch(i) {
- case 0:
- mail_vfolder_shutdown();
- break;
- case 1:
- if (mail_async_event_destroy(async_event) == -1) {
- g_warning("Cannot destroy async event: would deadlock");
- g_warning(" system may be unstable at exit");
- }
- break;
- case 2:
- g_hash_table_foreach (storages_hash, free_storage, NULL);
- g_hash_table_destroy (storages_hash);
- storages_hash = NULL;
- break;
- }
- }
-}
-
-static void
-send_receive_cb (EvolutionShellComponent *shell_component,
- gboolean show_dialog,
- void *data)
-{
- EAccount *account;
- GtkWidget *dialog;
-
- /* FIXME: configure_mail() should be changed to work without a
- FolderBrowser, and then we will be able to call configure_mail from
- here properly. */
- if (!mail_config_is_configured () /* && !configure_mail (fb) */)
- return;
-
- account = mail_config_get_default_account ();
- if (!account || !account->transport->url) {
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- _("You have not set a mail transport method"));
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
- gtk_widget_show (dialog);
- } else {
- dialog = mail_send_receive ();
- e_dialog_set_transient_for_xid((GtkWindow *)dialog, evolution_shell_component_get_parent_view_xid(shell_component));
- }
-}
-
-static gboolean
-request_quit (EvolutionShellComponent *shell_component,
- void *closure)
-{
- GtkWidget *dialog;
- int resp;
-
- if (!e_msg_composer_request_close_all ())
- return FALSE;
-
- if (!outbox_folder || !camel_folder_get_message_count (outbox_folder))
- return TRUE;
-
- dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_YES_NO,
- _("You have unsent messages, do you wish to quit anyway?"));
- gtk_dialog_set_default_response((GtkDialog *)dialog, GTK_RESPONSE_NO);
- resp = gtk_dialog_run((GtkDialog *)dialog);
- gtk_widget_destroy(dialog);
-
- return resp == GTK_RESPONSE_YES;
-}
-
-static BonoboObject *
-create_shell_component (void)
-{
- EvolutionShellComponentDndDestinationFolder *destination_interface;
- MailOfflineHandler *offline_handler;
- GdkPixbuf *icon;
- int i;
-
- shell_component = evolution_shell_component_new (folder_types,
- schema_types,
- create_view,
- create_folder,
- remove_folder,
- xfer_folder,
- populate_folder_context_menu,
- unpopulate_folder_context_menu,
- get_dnd_selection,
- request_quit,
- NULL);
-
- g_signal_connect((shell_component), "send_receive",
- G_CALLBACK (send_receive_cb), NULL);
-
- destination_interface = evolution_shell_component_dnd_destination_folder_new (destination_folder_handle_motion,
- destination_folder_handle_drop,
- shell_component);
-
- bonobo_object_add_interface (BONOBO_OBJECT (shell_component),
- BONOBO_OBJECT (destination_interface));
-
- icon = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/new-message.xpm", NULL);
- evolution_shell_component_add_user_creatable_item (shell_component, "message",
- _("New Mail Message"), _("_Mail Message"),
- _("Compose a new mail message"),
- "mail", 'm',
- icon);
- if (icon != NULL)
- g_object_unref (icon);
-
- icon = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/post-message-16.png", NULL);
- evolution_shell_component_add_user_creatable_item (shell_component, "post",
- _("New Message Post"), _("_Post Message"),
- _("Post a new mail message"),
- "mail/public", 'p',
- icon);
- if (icon != NULL)
- g_object_unref (icon);
-
- for (i=0;i<sizeof(shell_component_handlers)/sizeof(shell_component_handlers[0]);i++) {
- shell_component_handlers[i].hand = g_signal_connect((shell_component),
- shell_component_handlers[i].sig,
- shell_component_handlers[i].func, NULL);
- }
-
- offline_handler = mail_offline_handler_new ();
- bonobo_object_add_interface (BONOBO_OBJECT (shell_component), BONOBO_OBJECT (offline_handler));
-
- return BONOBO_OBJECT (shell_component);
-}
-
-static void
-notify_listener (const Bonobo_Listener listener,
- GNOME_Evolution_Storage_Result corba_result)
-{
- CORBA_any any;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- any._type = TC_GNOME_Evolution_Storage_Result;
- any._value = &corba_result;
-
- Bonobo_Listener_event (listener, "result", &any, &ev);
-
- CORBA_exception_free (&ev);
-}
-
-static void
-notify_listener_exception(const Bonobo_Listener listener, CamelException *ex)
-{
- GNOME_Evolution_Storage_Result result;
-
- switch(camel_exception_get_id(ex)) {
- case CAMEL_EXCEPTION_SERVICE_UNAVAILABLE:
- result = GNOME_Evolution_Storage_NOT_ONLINE;
- break;
- case CAMEL_EXCEPTION_NONE:
- result = GNOME_Evolution_Storage_OK;
- break;
- case CAMEL_EXCEPTION_FOLDER_INVALID_PATH:
- case CAMEL_EXCEPTION_SERVICE_URL_INVALID:
- result = GNOME_Evolution_Storage_INVALID_URI;
- break;
- default:
- result = GNOME_Evolution_Storage_GENERIC_ERROR;
- break;
- }
-
- notify_listener(listener, result);
-}
-
-static void
-storage_create_folder (EvolutionStorage *storage,
- const Bonobo_Listener listener,
- const char *path,
- const char *type,
- const char *description,
- const char *parent_physical_uri,
- gpointer user_data)
-{
- CamelStore *store = user_data;
- CamelFolderInfo *root, *fi;
- char *name;
- CamelURL *url;
- CamelException ex;
-
- /* We could just use 'path' always here? */
-
- if (!type_is_mail (type)) {
- notify_listener (listener, GNOME_Evolution_Storage_UNSUPPORTED_TYPE);
- return;
- }
-
- name = strrchr (path, '/');
- if (!name) {
- notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI);
- return;
- }
- name++;
-
- /* we can not directly create folders on a vfolder store, so fudge it */
- if (CAMEL_IS_VEE_STORE(store)) {
- VfolderRule *rule;
- rule = vfolder_rule_new();
-
- filter_rule_set_name((FilterRule *)rule, path+1);
- vfolder_gui_add_rule(rule);
- } else {
- camel_exception_init (&ex);
- if (*parent_physical_uri) {
- url = camel_url_new (parent_physical_uri, NULL);
- if (!url) {
- notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI);
- return;
- }
-
- root = camel_store_create_folder (store, url->fragment?url->fragment:url->path + 1, name, &ex);
- camel_url_free (url);
- } else
- root = camel_store_create_folder (store, NULL, name, &ex);
-
- if (camel_exception_is_set (&ex)) {
- notify_listener_exception(listener, &ex);
- camel_exception_clear (&ex);
- return;
- }
-
- if (camel_store_supports_subscriptions (store)) {
- for (fi = root; fi; fi = fi->child)
- camel_store_subscribe_folder (store, fi->full_name, NULL);
- }
-
- camel_store_free_folder_info (store, root);
- }
-
- notify_listener (listener, GNOME_Evolution_Storage_OK);
-}
-
-static void
-storage_remove_folder_recursive (EvolutionStorage *storage, CamelStore *store, CamelFolderInfo *root, CamelException *ex)
-{
- CamelFolderInfo *fi;
-
- /* delete all children */
- fi = root->child;
- while (fi && !camel_exception_is_set (ex)) {
- storage_remove_folder_recursive (storage, store, fi, ex);
- fi = fi->sibling;
- }
-
- if (!camel_exception_is_set (ex)) {
- if (camel_store_supports_subscriptions (store))
- camel_store_unsubscribe_folder (store, root->full_name, NULL);
-
- camel_store_delete_folder (store, root->full_name, ex);
-
- if (!camel_exception_is_set (ex))
- evolution_storage_removed_folder (storage, root->path);
- }
-}
-
-static void
-storage_remove_folder (EvolutionStorage *storage,
- const Bonobo_Listener listener,
- const char *path,
- const char *physical_uri,
- gpointer user_data)
-{
- CamelStore *store = user_data;
- CamelFolderInfo *root, *fi;
- CamelURL *url = NULL;
- CamelException ex;
- char *name;
-
- g_warning ("storage_remove_folder: path=\"%s\"; uri=\"%s\"", path, physical_uri);
-
- if (!path || !*path || !physical_uri || !strncmp (physical_uri, "vtrash:", 7)) {
- notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI);
- return;
- }
-
- url = camel_url_new (physical_uri, NULL);
- if (!url) {
- notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI);
- return;
- }
-
- if (url->fragment)
- name = url->fragment;
- else if (url->path && url->path[0])
- name = url->path+1;
- else
- name = "";
-
- camel_exception_init (&ex);
-
- root = camel_store_get_folder_info (store, name, CAMEL_STORE_FOLDER_INFO_FAST |
- CAMEL_STORE_FOLDER_INFO_RECURSIVE, &ex);
-
- if (!root || camel_exception_is_set (&ex)) {
- notify_listener_exception (listener, &ex);
- camel_exception_clear (&ex);
- camel_url_free (url);
- return;
- }
-
- /* walk the tree until we find the particular child folder we want to delete */
- fi = root;
- while (fi) {
- if (!strcmp (fi->full_name, name))
- break;
- fi = fi->child;
- }
-
- camel_url_free (url);
-
- if (!fi) {
- notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI);
- camel_store_free_folder_info (store, root);
- return;
- }
-
- storage_remove_folder_recursive (storage, store, fi, &ex);
- camel_store_free_folder_info (store, root);
- if (camel_exception_is_set (&ex)) {
- notify_listener_exception (listener, &ex);
- camel_exception_clear (&ex);
- } else {
- notify_listener (listener, GNOME_Evolution_Storage_OK);
- }
-}
-
-static void
-storage_xfer_folder (EvolutionStorage *storage,
- const Bonobo_Listener listener,
- const char *source_path,
- const char *destination_path,
- gboolean remove_source,
- CamelStore *store)
-{
- CamelException ex;
- char *src, *dst;
- char sep;
-
- d(printf("Transfer folder on store source = '%s' dest = '%s'\n", source_path, destination_path));
-
- /* FIXME: this is totally not gonna work once we have namespaces */
-
- /* Remap the 'path' to the camel friendly name based on the store dir separator */
- sep = store->dir_sep;
- src = g_strdup(source_path[0]=='/'?source_path+1:source_path);
- dst = g_strdup(destination_path[0]=='/'?destination_path+1:destination_path);
- camel_exception_init (&ex);
- if (remove_source) {
- d(printf("trying to rename\n"));
- camel_store_rename_folder(store, src, dst, &ex);
- notify_listener_exception(listener, &ex);
- } else {
- d(printf("No remove, can't rename\n"));
- /* FIXME: Implement folder 'copy' for remote stores */
- /* This exception never goes anywhere, so it doesn't need translating or using */
- notify_listener (listener, GNOME_Evolution_Storage_UNSUPPORTED_OPERATION);
- }
-
- g_free(src);
- g_free(dst);
-
- camel_exception_clear (&ex);
-}
-
-#if 0 /* EPFIXME */
-static void
-storage_connected (CamelStore *store, CamelFolderInfo *info, void *listener)
-{
- notify_listener (listener, (info ? GNOME_Evolution_Storage_OK :
- GNOME_Evolution_Storage_GENERIC_ERROR));
-}
-#endif
-
-static void
-storage_connect (EvolutionStorage *storage,
- const Bonobo_Listener listener,
- const char *path,
- CamelStore *store)
-{
-#if 0 /* EPFIXME */
- mail_note_store (CAMEL_STORE (store), NULL, storage, CORBA_OBJECT_NIL,
- storage_connected, listener);
-#endif
-}
-
-static void
-add_storage (const char *name, const char *uri, CamelService *store,
- GNOME_Evolution_Shell corba_shell, CamelException *ex)
-{
- EvolutionStorage *storage;
- EvolutionStorageResult res;
-
- storage = evolution_storage_new (name, FALSE);
- g_signal_connect(storage, "open_folder", G_CALLBACK(storage_connect), store);
- g_signal_connect(storage, "create_folder", G_CALLBACK(storage_create_folder), store);
- g_signal_connect(storage, "remove_folder", G_CALLBACK(storage_remove_folder), store);
- g_signal_connect(storage, "xfer_folder", G_CALLBACK(storage_xfer_folder), store);
-
- res = evolution_storage_register_on_shell (storage, corba_shell);
-
- switch (res) {
- case EVOLUTION_STORAGE_OK:
- evolution_storage_has_subfolders (storage, "/", _("Connecting..."));
- mail_hash_storage (store, storage);
- /*if (auto_connect)*/
- /* EPFIXME mail_note_store ((CamelStore *) store, NULL, storage, CORBA_OBJECT_NIL, NULL, NULL); */
- /* falllll */
- case EVOLUTION_STORAGE_ERROR_ALREADYREGISTERED:
- case EVOLUTION_STORAGE_ERROR_EXISTS:
- bonobo_object_unref (BONOBO_OBJECT (storage));
- return;
- default:
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Cannot register storage with shell"));
- break;
- }
-}
-
-static void
-mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const char *name)
-{
- CamelException ex;
- CamelService *store;
- CamelProvider *prov;
-
- camel_exception_init (&ex);
-
- /* Load the service (don't connect!). Check its provider and
- * see if this belongs in the shell's folder list. If so, add
- * it.
- */
-
- prov = camel_session_get_provider (session, uri, &ex);
- if (prov == NULL) {
- /* FIXME: real error dialog */
- g_warning ("couldn't get service %s: %s\n", uri,
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- return;
- }
-
- if (!(prov->flags & CAMEL_PROVIDER_IS_STORAGE) ||
- (prov->flags & CAMEL_PROVIDER_IS_EXTERNAL))
- return;
-
- store = camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex);
- if (store == NULL) {
- /* FIXME: real error dialog */
- g_warning ("couldn't get service %s: %s\n", uri,
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- return;
- }
-
- if (name == NULL) {
- char *service_name;
-
- service_name = camel_service_get_name (store, TRUE);
- add_storage (service_name, uri, store, shell, &ex);
- g_free (service_name);
- } else
- add_storage (name, uri, store, shell, &ex);
-
- if (camel_exception_is_set (&ex)) {
- /* FIXME: real error dialog */
- g_warning ("Cannot load storage: %s",
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- }
-
- camel_object_unref (CAMEL_OBJECT (store));
-}
-
-static void
-mail_load_storages (GNOME_Evolution_Shell shell, EAccountList *accounts)
-{
- CamelException ex;
- EIterator *iter;
-
- camel_exception_init (&ex);
-
- /* Load each service (don't connect!). Check its provider and
- * see if this belongs in the shell's folder list. If so, add
- * it.
- */
-
- iter = e_list_get_iterator ((EList *) accounts);
- while (e_iterator_is_valid (iter)) {
- EAccountService *service;
- EAccount *account;
- const char *name;
-
- account = (EAccount *) e_iterator_get (iter);
- service = account->source;
- name = account->name;
-
- if (account->enabled && service->url != NULL)
- mail_load_storage_by_uri (shell, service->url, name);
-
- e_iterator_next (iter);
- }
-
- g_object_unref (iter);
-}
-
-static void
-mail_hash_storage (CamelService *store, EvolutionStorage *storage)
-{
- camel_object_ref (CAMEL_OBJECT (store));
- g_hash_table_insert (storages_hash, store, storage);
-}
-
-#if 0
-static void
-store_disconnect(CamelStore *store, void *event_data, void *data)
-{
- camel_service_disconnect (CAMEL_SERVICE (store), TRUE, NULL);
- camel_object_unref (CAMEL_OBJECT (store));
-}
-#endif
-
-#define FACTORY_ID "OAFIID:GNOME_Evolution_Mail_Factory_2"
-
-#define MAIL_CONFIG_IID "OAFIID:GNOME_Evolution_MailConfig"
-#define WIZARD_IID "OAFIID:GNOME_Evolution_Mail_Wizard"
-#define FOLDER_INFO_IID "OAFIID:GNOME_Evolution_FolderInfo"
-#define COMPOSER_IID "OAFIID:GNOME_Evolution_Mail_Composer"
-
-static BonoboObject *
-factory (BonoboGenericFactory *factory,
- const char *component_id,
- void *closure)
-{
- if (strcmp (component_id, SHELL_COMPONENT_ID) == 0)
- return create_shell_component();
- else if (strcmp (component_id, COMPONENT_ID) == 0) {
- MailComponent *component = mail_component_peek ();
-
- bonobo_object_ref (BONOBO_OBJECT (component));
- return BONOBO_OBJECT (component);
- } else if (strcmp(component_id, MAIL_CONFIG_IID) == 0)
- return (BonoboObject *)g_object_new (evolution_mail_config_get_type (), NULL);
- else if (strcmp(component_id, FOLDER_INFO_IID) == 0)
- return evolution_folder_info_new();
- else if (strcmp(component_id, WIZARD_IID) == 0)
- return evolution_mail_config_wizard_new();
- else if (strcmp (component_id, MAIL_ACCOUNTS_CONTROL_ID) == 0
- || strcmp (component_id, MAIL_PREFERENCES_CONTROL_ID) == 0
- || strcmp (component_id, MAIL_COMPOSER_PREFS_CONTROL_ID) == 0)
- return mail_config_control_factory_cb (factory, component_id, evolution_shell_client_corba_objref (global_shell_client));
- else if (strcmp(component_id, COMPOSER_IID) == 0)
- return (BonoboObject *)evolution_composer_new(em_utils_composer_send_cb, em_utils_composer_save_draft_cb);
-
- g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
- return NULL;
-}
-
-static Bonobo_Unknown
-make_factory (PortableServer_POA poa, const char *iid, gpointer impl_ptr, CORBA_Environment *ev)
-{
- static int init = 0;
-
- if (!init) {
- /* init ? */
- mail_config_init ();
- mail_msg_init ();
- init = 1;
- }
-
- return bonobo_shlib_factory_std (FACTORY_ID, poa, impl_ptr, factory, NULL, ev);
-}
-
-static BonoboActivationPluginObject plugin_list[] = {
- {FACTORY_ID, make_factory},
- { NULL }
-};
-const BonoboActivationPlugin Bonobo_Plugin_info = {
- plugin_list, "Evolution Mail component factory"
-};
-
diff --git a/mail/component-factory.h b/mail/component-factory.h
deleted file mode 100644
index fdc7c4056f..0000000000
--- a/mail/component-factory.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* component-factory.h
- *
- * Copyright (C) 2000 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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
- */
-
-#ifndef COMPONENT_FACTORY_H
-#define COMPONENT_FACTORY_H
-
-#define COMPONENT_ID "OAFIID:GNOME_Evolution_Mail_Component2"
-#define SHELL_COMPONENT_ID "OAFIID:GNOME_Evolution_Mail_ShellComponent"
-#define SUMMARY_FACTORY_ID "OAFIID:GNOME_Evolution_Mail_ExecutiveSummaryComponentFactory"
-
-#endif
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
deleted file mode 100644
index 6d7deb2bdb..0000000000
--- a/mail/folder-browser.c
+++ /dev/null
@@ -1,2679 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors: Miguel De Icaza <miguel@ximian.com>
- * Jeffrey Stedfast <fejj@ximian.com>
- *
- * Copyright 2000-2003 Ximian, Inc. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkinvisible.h>
-#include <gal/e-table/e-table.h>
-#include <gal/util/e-util.h>
-#include <gal/widgets/e-gui-utils.h>
-#include <gal/widgets/e-popup-menu.h>
-
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
-
-#include <libgnomeui/gnome-dialog-util.h>
-#include <libgnomeui/gnome-pixmap.h>
-
-#include <gtkhtml/htmlengine.h>
-#include <gtkhtml/htmlobject.h>
-#include <gtkhtml/htmlinterval.h>
-#include <gtkhtml/htmlengine-edit-cut-and-paste.h>
-
-#include "filter/vfolder-rule.h"
-#include "filter/vfolder-context.h"
-#include "filter/filter-option.h"
-#include "filter/filter-input.h"
-#include "filter/filter-label.h"
-
-#include "e-util/e-sexp.h"
-#include "e-util/e-mktemp.h"
-#include "e-util/e-meta.h"
-#include "folder-browser.h"
-#include "e-searching-tokenizer.h"
-#include "mail.h"
-#include "mail-callbacks.h"
-#include "mail-component.h"
-#include "mail-tools.h"
-#include "mail-ops.h"
-#include "mail-vfolder.h"
-#include "mail-autofilter.h"
-#include "mail-mt.h"
-#include "mail-folder-cache.h"
-#include "folder-browser-ui.h"
-
-#include "mail-local.h"
-#include "mail-config.h"
-
-#include <camel/camel-mime-message.h>
-#include <camel/camel-stream-mem.h>
-
-/* maybe this shooudlnt be private ... */
-#include "camel/camel-search-private.h"
-
-#define d(x)
-
-#define PARENT_TYPE (gtk_table_get_type ())
-
-static void folder_changed(CamelObject *o, void *event_data, void *data);
-static void main_folder_changed(CamelObject *o, void *event_data, void *data);
-
-#define X_EVOLUTION_MESSAGE_TYPE "x-evolution-message"
-#define MESSAGE_RFC822_TYPE "message/rfc822"
-#define TEXT_URI_LIST_TYPE "text/uri-list"
-#define TEXT_PLAIN_TYPE "text/plain"
-
-/* Drag & Drop types */
-enum DndTargetType {
- DND_TARGET_TYPE_X_EVOLUTION_MESSAGE,
- DND_TARGET_TYPE_MESSAGE_RFC822,
- DND_TARGET_TYPE_TEXT_URI_LIST,
-};
-
-static GtkTargetEntry drag_types[] = {
- { X_EVOLUTION_MESSAGE_TYPE, 0, DND_TARGET_TYPE_X_EVOLUTION_MESSAGE },
- { MESSAGE_RFC822_TYPE, 0, DND_TARGET_TYPE_MESSAGE_RFC822 },
- { TEXT_URI_LIST_TYPE, 0, DND_TARGET_TYPE_TEXT_URI_LIST },
-};
-
-static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
-
-enum PasteTargetType {
- PASTE_TARGET_TYPE_X_EVOLUTION_MESSAGE,
- PASTE_TARGET_TYPE_TEXT_PLAIN,
-};
-
-static GtkTargetPair paste_types[] = {
- { 0, 0, PASTE_TARGET_TYPE_X_EVOLUTION_MESSAGE },
- { GDK_SELECTION_TYPE_STRING, 0, PASTE_TARGET_TYPE_TEXT_PLAIN },
-};
-
-static const int num_paste_types = sizeof (paste_types) / sizeof (paste_types[0]);
-
-static GdkAtom clipboard_atom = GDK_NONE;
-
-static GtkTableClass *parent_class = NULL;
-
-enum {
- FOLDER_LOADED,
- MESSAGE_LOADED,
- LAST_SIGNAL
-};
-
-static guint folder_browser_signals [LAST_SIGNAL] = {0, };
-
-static void
-folder_browser_finalise (GObject *object)
-{
- FolderBrowser *folder_browser;
-
- folder_browser = FOLDER_BROWSER (object);
-
- g_free (folder_browser->loading_uid);
- g_free (folder_browser->pending_uid);
- g_free (folder_browser->new_uid);
- g_free (folder_browser->loaded_uid);
-
- g_free (folder_browser->uri);
- folder_browser->uri = NULL;
-
- if (folder_browser->clipboard_selection)
- g_byte_array_free (folder_browser->clipboard_selection, TRUE);
-
- if (folder_browser->sensitise_state) {
- g_hash_table_destroy (folder_browser->sensitise_state);
- folder_browser->sensitise_state = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-folder_browser_destroy (GtkObject *object)
-{
- FolderBrowser *folder_browser;
- CORBA_Environment ev;
-
- folder_browser = FOLDER_BROWSER (object);
-
- CORBA_exception_init (&ev);
-
- if (folder_browser->seen_id != 0) {
- g_source_remove (folder_browser->seen_id);
- folder_browser->seen_id = 0;
- }
-
- if (folder_browser->loading_id != 0) {
- g_source_remove(folder_browser->loading_id);
- folder_browser->loading_id = 0;
- }
-
- if (folder_browser->message_list) {
- gtk_widget_destroy (GTK_WIDGET (folder_browser->message_list));
- folder_browser->message_list = NULL;
- }
-
- if (folder_browser->mail_display) {
- gtk_widget_destroy (GTK_WIDGET (folder_browser->mail_display));
- folder_browser->mail_display = NULL;
- }
-
- if (folder_browser->view_instance) {
- g_object_unref (folder_browser->view_instance);
- folder_browser->view_instance = NULL;
- }
-
- if (folder_browser->view_menus) {
- g_object_unref (folder_browser->view_menus);
- folder_browser->view_menus = NULL;
- }
-
- /* wait for all outstanding async events against us */
- if (folder_browser->async_event) {
- mail_async_event_destroy (folder_browser->async_event);
- folder_browser->async_event = NULL;
- }
-
- if (folder_browser->search_full) {
- g_object_unref (folder_browser->search_full);
- folder_browser->search_full = NULL;
- }
-
- if (folder_browser->sensitize_timeout_id) {
- g_source_remove (folder_browser->sensitize_timeout_id);
- folder_browser->sensitize_timeout_id = 0;
- }
-
- if (folder_browser->shell_view != CORBA_OBJECT_NIL) {
- CORBA_Object_release (folder_browser->shell_view, &ev);
- folder_browser->shell_view = CORBA_OBJECT_NIL;
- }
-
- if (folder_browser->uicomp) {
- bonobo_object_unref (BONOBO_OBJECT (folder_browser->uicomp));
- folder_browser->uicomp = NULL;
- }
-
- if (folder_browser->invisible) {
- g_object_unref (folder_browser->invisible);
- folder_browser->invisible = NULL;
- }
-
- if (folder_browser->get_id != -1) {
- mail_msg_cancel (folder_browser->get_id);
- folder_browser->get_id = -1;
- }
-
- if (folder_browser->folder) {
- camel_object_unhook_event (CAMEL_OBJECT (folder_browser->folder), "folder_changed",
- folder_changed, folder_browser);
- camel_object_unhook_event (CAMEL_OBJECT (folder_browser->folder), "message_changed",
- folder_changed, folder_browser);
- mail_sync_folder (folder_browser->folder, NULL, NULL);
- camel_object_unref (folder_browser->folder);
- folder_browser->folder = NULL;
- }
-
- CORBA_exception_free (&ev);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-folder_browser_class_init (FolderBrowserClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_ref(PARENT_TYPE);
-
- object_class->destroy = folder_browser_destroy;
- gobject_class->finalize = folder_browser_finalise;
-
- folder_browser_signals[FOLDER_LOADED] =
- g_signal_new ("folder_loaded",
- FOLDER_BROWSER_TYPE,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (FolderBrowserClass, folder_loaded),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- folder_browser_signals[MESSAGE_LOADED] =
- g_signal_new ("message_loaded",
- FOLDER_BROWSER_TYPE,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (FolderBrowserClass, message_loaded),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- /* clipboard atom */
- if (!clipboard_atom)
- clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
-
- if (!paste_types[0].target)
- paste_types[0].target = gdk_atom_intern (X_EVOLUTION_MESSAGE_TYPE, FALSE);
-}
-
-static void
-add_uid (MessageList *ml, const char *uid, gpointer data)
-{
- g_ptr_array_add ((GPtrArray *) data, g_strdup (uid));
-}
-
-static void
-message_list_drag_data_get (ETree *tree, int row, ETreePath path, int col,
- GdkDragContext *context, GtkSelectionData *selection_data,
- guint info, guint time, gpointer user_data)
-{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- GPtrArray *uids = NULL;
- int i;
-
- uids = g_ptr_array_new ();
- message_list_foreach (fb->message_list, add_uid, uids);
- if (uids->len == 0) {
- g_ptr_array_free (uids, TRUE);
- return;
- }
-
- switch (info) {
- case DND_TARGET_TYPE_TEXT_URI_LIST:
- {
- const char *filename, *tmpdir;
- CamelMimeMessage *message;
- CamelMimeFilter *filter;
- CamelStream *fstream;
- CamelStreamFilter *stream;
- char *uri_list;
- int fd;
-
- tmpdir = e_mkdtemp ("drag-n-drop-XXXXXX");
-
- if (!tmpdir) {
- char *msg = g_strdup_printf (_("Could not create temporary "
- "directory: %s"),
- g_strerror (errno));
- gnome_error_dialog (msg);
- /* cleanup and abort */
- for (i = 0; i < uids->len; i++)
- g_free (uids->pdata[i]);
- g_ptr_array_free (uids, TRUE);
- g_free (msg);
- return;
- }
-
- message = camel_folder_get_message (fb->folder, uids->pdata[0], NULL);
- g_free (uids->pdata[0]);
-
- if (uids->len == 1) {
- filename = camel_mime_message_get_subject (message);
- if (!filename)
- filename = _("Unknown");
- } else
- filename = "mbox";
-
- uri_list = g_strdup_printf ("file://%s/%s", tmpdir, filename);
-
- fd = open (uri_list + 7, O_WRONLY | O_CREAT | O_EXCL, 0600);
- if (fd == -1) {
- /* cleanup and abort */
- camel_object_unref (message);
- for (i = 1; i < uids->len; i++)
- g_free (uids->pdata[i]);
- g_ptr_array_free (uids, TRUE);
- g_free (uri_list);
- return;
- }
-
- fstream = camel_stream_fs_new_with_fd (fd);
-
- stream = camel_stream_filter_new_with_stream (fstream);
- filter = camel_mime_filter_from_new ();
- camel_stream_filter_add (stream, filter);
- camel_object_unref (filter);
-
- camel_stream_write (fstream, "From - \n", 8);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (stream));
- camel_object_unref (message);
- camel_stream_flush (CAMEL_STREAM (stream));
-
- for (i = 1; i < uids->len; i++) {
- message = camel_folder_get_message (fb->folder, uids->pdata[i], NULL);
- camel_stream_write (fstream, "From - \n", 8);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (stream));
- camel_object_unref (message);
- camel_stream_flush (CAMEL_STREAM (stream));
- g_free (uids->pdata[i]);
- }
-
- g_ptr_array_free (uids, TRUE);
-
- camel_object_unref (stream);
- camel_object_unref (fstream);
-
- gtk_selection_data_set (selection_data, selection_data->target, 8,
- uri_list, strlen (uri_list));
- g_free (uri_list);
- }
- break;
- case DND_TARGET_TYPE_MESSAGE_RFC822:
- {
- CamelMimeFilter *filter;
- CamelStream *stream;
- CamelStream *mem;
-
- mem = camel_stream_mem_new ();
-
- stream = camel_stream_filter_new_with_stream (mem);
- filter = camel_mime_filter_from_new ();
- camel_stream_filter_add (CAMEL_STREAM_FILTER (stream), filter);
- camel_object_unref (filter);
-
- for (i = 0; i < uids->len; i++) {
- CamelMimeMessage *message;
-
- message = camel_folder_get_message (fb->folder, uids->pdata[i], NULL);
- g_free (uids->pdata[i]);
-
- if (message) {
- camel_stream_write (mem, "From - \n", 8);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream);
- camel_object_unref (message);
- camel_stream_flush (stream);
- }
- }
-
- g_ptr_array_free (uids, TRUE);
- camel_object_unref (stream);
-
- gtk_selection_data_set (selection_data, selection_data->target, 8,
- CAMEL_STREAM_MEM (mem)->buffer->data,
- CAMEL_STREAM_MEM (mem)->buffer->len);
-
- camel_object_unref (mem);
- }
- break;
- case DND_TARGET_TYPE_X_EVOLUTION_MESSAGE:
- {
- GByteArray *array;
-
- /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn" */
-
- /* write the uri portion */
- array = g_byte_array_new ();
- g_byte_array_append (array, fb->uri, strlen (fb->uri));
- g_byte_array_append (array, "", 1);
-
- /* write the uids */
- for (i = 0; i < uids->len; i++) {
- g_byte_array_append (array, uids->pdata[i], strlen (uids->pdata[i]));
- g_free (uids->pdata[i]);
-
- if (i + 1 < uids->len)
- g_byte_array_append (array, "", 1);
- }
-
- g_ptr_array_free (uids, TRUE);
-
- gtk_selection_data_set (selection_data, selection_data->target, 8,
- array->data, array->len);
-
- g_byte_array_free (array, TRUE);
- }
- break;
- default:
- for (i = 0; i < uids->len; i++)
- g_free (uids->pdata[i]);
-
- g_ptr_array_free (uids, TRUE);
- break;
- }
-}
-
-static void
-message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex)
-{
- CamelMimeParser *mp;
-
- mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mp, TRUE);
- camel_mime_parser_init_with_stream (mp, stream);
-
- while (camel_mime_parser_step (mp, 0, 0) == HSCAN_FROM) {
- CamelMessageInfo *info;
- CamelMimeMessage *msg;
-
- msg = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mp) == -1) {
- camel_object_unref (CAMEL_OBJECT (msg));
- break;
- }
-
- /* append the message to the folder... */
- info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (dest, msg, info, NULL, ex);
- camel_object_unref (CAMEL_OBJECT (msg));
-
- if (camel_exception_is_set (ex))
- break;
-
- /* skip over the FROM_END state */
- camel_mime_parser_step (mp, 0, 0);
- }
-
- camel_object_unref (CAMEL_OBJECT (mp));
-}
-
-static void
-message_list_drag_data_received (ETree *tree, int row, ETreePath path, int col,
- GdkDragContext *context, gint x, gint y,
- GtkSelectionData *selection_data, guint info,
- guint time, gpointer user_data)
-{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- CamelFolder *folder = NULL;
- char *tmp, *url, **urls;
- GPtrArray *uids = NULL;
- CamelStream *stream;
- CamelException ex;
- CamelURL *uri;
- int i, fd;
-
- /* this means we are receiving no data */
- if (!selection_data->data || selection_data->length == -1)
- return;
-
- camel_exception_init (&ex);
-
- switch (info) {
- case DND_TARGET_TYPE_TEXT_URI_LIST:
- tmp = g_strndup (selection_data->data, selection_data->length);
- urls = g_strsplit (tmp, "\n", 0);
- g_free (tmp);
-
- for (i = 0; urls[i] != NULL; i++) {
- /* get the path component */
- url = g_strstrip (urls[i]);
-
- uri = camel_url_new (url, NULL);
- g_free (url);
-
- if (!uri)
- continue;
-
- url = uri->path;
- uri->path = NULL;
- camel_url_free (uri);
-
- fd = open (url, O_RDONLY);
- if (fd == -1) {
- g_free (url);
- /* FIXME: okay, what do we do in this case? */
- continue;
- }
-
- stream = camel_stream_fs_new_with_fd (fd);
- message_rfc822_dnd (fb->folder, stream, &ex);
- camel_object_unref (CAMEL_OBJECT (stream));
-
- if (context->action == GDK_ACTION_MOVE && !camel_exception_is_set (&ex))
- unlink (url);
-
- g_free (url);
- }
-
- g_free (urls);
- break;
- case DND_TARGET_TYPE_MESSAGE_RFC822:
- /* write the message(s) out to a CamelStream so we can use it */
- stream = camel_stream_mem_new ();
- camel_stream_write (stream, selection_data->data, selection_data->length);
- camel_stream_reset (stream);
-
- message_rfc822_dnd (fb->folder, stream, &ex);
- camel_object_unref (CAMEL_OBJECT (stream));
- break;
- case DND_TARGET_TYPE_X_EVOLUTION_MESSAGE:
- folder = mail_tools_x_evolution_message_parse (selection_data->data, selection_data->length, &uids);
- if (folder == NULL)
- goto fail;
-
- if (uids == NULL) {
- camel_object_unref (CAMEL_OBJECT (folder));
- goto fail;
- }
-
- mail_transfer_messages (folder, uids, context->action == GDK_ACTION_MOVE,
- fb->uri, 0, NULL, NULL);
-
- camel_object_unref (CAMEL_OBJECT (folder));
- break;
- }
-
- camel_exception_clear (&ex);
-
- gtk_drag_finish (context, TRUE, TRUE, GDK_CURRENT_TIME);
-
- fail:
- camel_exception_clear (&ex);
-
- gtk_drag_finish (context, FALSE, TRUE, GDK_CURRENT_TIME);
-}
-
-static void
-selection_get (GtkWidget *widget, GtkSelectionData *selection_data,
- guint info, guint time_stamp, FolderBrowser *fb)
-{
- if (fb->clipboard_selection == NULL)
- return;
-
- switch (info) {
- default:
- case PASTE_TARGET_TYPE_TEXT_PLAIN:
- {
- /* FIXME: this'll be fucking slow for the user... pthread this? */
- CamelFolder *source;
- CamelStream *stream;
- GByteArray *bytes;
- GPtrArray *uids;
- int i;
-
- bytes = fb->clipboard_selection;
-
- /* Note: source should == fb->folder, but we might as well use `source' instead of fb->folder */
- source = mail_tools_x_evolution_message_parse (bytes->data, bytes->len, &uids);
- if (source == NULL)
- return;
-
- if (uids == NULL) {
- camel_object_unref (CAMEL_OBJECT (source));
- return;
- }
-
- bytes = g_byte_array_new ();
- stream = camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), bytes);
-
- for (i = 0; i < uids->len; i++) {
- CamelMimeMessage *message;
-
- message = camel_folder_get_message (source, uids->pdata[i], NULL);
- g_free (uids->pdata[i]);
-
- if (message) {
- camel_stream_write (stream, "From - \n", 8);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream);
- camel_object_unref (CAMEL_OBJECT (message));
- }
- }
-
- g_ptr_array_free (uids, TRUE);
- camel_object_unref (CAMEL_OBJECT (stream));
- camel_object_unref (CAMEL_OBJECT (source));
-
- gtk_selection_data_set (selection_data, selection_data->target, 8,
- bytes->data, bytes->len);
-
- g_byte_array_free (bytes, FALSE);
- }
- break;
- case PASTE_TARGET_TYPE_X_EVOLUTION_MESSAGE:
- /* we already have our data in the correct form */
- gtk_selection_data_set (selection_data,
- selection_data->target, 8,
- fb->clipboard_selection->data,
- fb->clipboard_selection->len);
- break;
- }
-}
-
-static void
-selection_clear_event (GtkWidget *widget, GdkEventSelection *event, FolderBrowser *fb)
-{
- if (fb->clipboard_selection != NULL) {
- g_byte_array_free (fb->clipboard_selection, TRUE);
- fb->clipboard_selection = NULL;
- }
-}
-
-static void
-selection_received (GtkWidget *widget, GtkSelectionData *selection_data,
- guint time, FolderBrowser *fb)
-{
- CamelFolder *source = NULL;
- GPtrArray *uids = NULL;
-
- if (selection_data == NULL || selection_data->length == -1)
- return;
-
- source = mail_tools_x_evolution_message_parse (selection_data->data, selection_data->length, &uids);
- if (source == NULL)
- return;
-
- if (uids == NULL) {
- camel_object_unref (CAMEL_OBJECT (source));
- return;
- }
-
- mail_transfer_messages (source, uids, FALSE, fb->uri, 0, NULL, NULL);
-
- camel_object_unref (CAMEL_OBJECT (source));
-}
-
-void
-folder_browser_copy (GtkWidget *menuitem, FolderBrowser *fb)
-{
- GPtrArray *uids = NULL;
- GByteArray *bytes;
- gboolean cut;
- int i;
-
- if (fb->message_list == NULL)
- return;
-
- cut = menuitem == NULL;
-
- if (GTK_WIDGET_HAS_FOCUS (fb->mail_display->html)) {
- gtk_html_copy (fb->mail_display->html);
- return;
- }
-
- if (fb->clipboard_selection) {
- g_byte_array_free (fb->clipboard_selection, TRUE);
- fb->clipboard_selection = NULL;
- }
-
- uids = g_ptr_array_new ();
- message_list_foreach (fb->message_list, add_uid, uids);
-
- /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn" */
-
- /* write the uri portion */
- bytes = g_byte_array_new ();
- g_byte_array_append (bytes, fb->uri, strlen (fb->uri));
- g_byte_array_append (bytes, "", 1);
-
- /* write the uids */
- camel_folder_freeze (fb->folder);
- for (i = 0; i < uids->len; i++) {
- if (cut) {
- camel_folder_set_message_flags (fb->folder, uids->pdata[i],
- CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED,
- CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED);
- }
- g_byte_array_append (bytes, uids->pdata[i], strlen (uids->pdata[i]));
- g_free (uids->pdata[i]);
-
- if (i + 1 < uids->len)
- g_byte_array_append (bytes, "", 1);
- }
- camel_folder_thaw (fb->folder);
-
- g_ptr_array_free (uids, TRUE);
-
- fb->clipboard_selection = bytes;
-
- gtk_selection_owner_set (fb->invisible, clipboard_atom, GDK_CURRENT_TIME);
-}
-
-void
-folder_browser_cut (GtkWidget *menuitem, FolderBrowser *fb)
-{
- folder_browser_copy (NULL, fb);
-}
-
-void
-folder_browser_paste (GtkWidget *menuitem, FolderBrowser *fb)
-{
- gtk_selection_convert (fb->invisible, clipboard_atom,
- paste_types[0].target,
- GDK_CURRENT_TIME);
-}
-
-/* all this crap so we can give the user a whoopee doo status bar */
-static void
-update_status_bar (FolderBrowser *fb)
-{
- extern CamelFolder *outbox_folder, *sent_folder;
- CORBA_Environment ev;
- int tmp, total;
- GString *work;
-
- if (fb->folder == NULL
- || fb->message_list == NULL
- || fb->shell_view == CORBA_OBJECT_NIL)
- return;
-
- if (!fb->message_list->hidedeleted || !camel_folder_has_summary_capability (fb->folder)) {
- total = camel_folder_get_message_count (fb->folder);
- } else {
- GPtrArray *sum = camel_folder_get_summary (fb->folder);
- int i;
-
- if (sum) {
- total = 0;
- for (i = 0; i < sum->len; i++) {
- CamelMessageInfo *info = sum->pdata[i];
-
- if ((info->flags & CAMEL_MESSAGE_DELETED) == 0)
- total++;
- }
- camel_folder_free_summary (fb->folder, sum);
- } else {
- total = camel_folder_get_message_count (fb->folder);
- }
- }
-
- work = g_string_new ("");
- g_string_append_printf (work, _("%d new"), camel_folder_get_unread_message_count (fb->folder));
- tmp = message_list_hidden (fb->message_list);
- if (0 < tmp && tmp < total) {
- g_string_append (work, _(", "));
- if (tmp < total / 2)
- g_string_append_printf (work, _("%d hidden"), tmp);
- else
- g_string_append_printf (work, _("%d visible"), total - tmp);
- }
- tmp = e_selection_model_selected_count (e_tree_get_selection_model (fb->message_list->tree));
- if (tmp) {
- g_string_append (work, _(", "));
- g_string_append_printf (work, _("%d selected"), tmp);
- }
- g_string_append (work, _(", "));
-
- if (fb->folder == outbox_folder)
- g_string_append_printf (work, _("%d unsent"), total);
- else if (fb->folder == sent_folder)
- g_string_append_printf (work, _("%d sent"), total);
- else
- g_string_append_printf (work, _("%d total"), total);
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_ShellView_setFolderBarLabel (fb->shell_view, work->str, &ev);
- CORBA_exception_free (&ev);
-
- if (fb->update_status_bar_idle_id != 0) {
- g_source_remove (fb->update_status_bar_idle_id);
- fb->update_status_bar_idle_id = 0;
- }
-
- g_string_free (work, TRUE);
-}
-
-static gboolean
-update_status_bar_idle_cb(gpointer data)
-{
- FolderBrowser *fb = data;
-
-#if 0
- if (!GTK_OBJECT_DESTROYED (fb))
-#endif
- update_status_bar (fb);
-
- fb->update_status_bar_idle_id = 0;
- g_object_unref (fb);
-
- return FALSE;
-}
-
-static void
-update_status_bar_idle(FolderBrowser *fb)
-{
- if (fb->update_status_bar_idle_id == 0) {
- g_object_ref (fb);
- fb->update_status_bar_idle_id = g_idle_add (update_status_bar_idle_cb, fb);
- }
-}
-
-static void main_folder_changed(CamelObject *o, void *event_data, void *data)
-{
- FolderBrowser *fb = data;
-
- if (fb->message_list == NULL)
- return;
-
- /* so some corba unref doesnt blow us away while we're busy */
- g_object_ref (fb);
- update_status_bar (fb);
- folder_browser_ui_scan_selection (fb);
- g_object_unref (fb);
-}
-
-static void folder_changed (CamelObject *obj, void *event_data, void *user_data)
-{
- FolderBrowser *fb = user_data;
-
- mail_async_event_emit (fb->async_event, MAIL_ASYNC_GUI,
- (MailAsyncFunc) main_folder_changed,
- obj, NULL, user_data);
-}
-
-static void
-got_folder (char *uri, CamelFolder *folder, void *user_data)
-{
- FolderBrowser *fb = user_data;
- EMeta *meta;
-
- fb->get_id = -1;
-
- d(printf ("got folder '%s' = %p, previous folder was %p\n", uri, folder, fb->folder));
-
- if (fb->message_list == NULL)
- goto done;
-
- if (fb->folder) {
- camel_object_unhook_event (fb->folder, "folder_changed", folder_changed, fb);
- camel_object_unhook_event (fb->folder, "message_changed", folder_changed, fb);
- camel_object_unref (fb->folder);
- }
-
- if (folder) {
- fb->folder = folder;
- camel_object_ref (folder);
- meta = mail_tool_get_meta_data(fb->uri);
- if (meta != fb->meta) {
- g_object_unref(fb->meta);
- fb->meta = meta;
- } else {
- g_object_unref(meta);
- }
- } else {
- fb->folder = NULL;
- if (fb->meta) {
- g_object_unref(fb->meta);
- fb->meta = NULL;
- }
- goto done;
- }
-
-
- gtk_widget_set_sensitive (GTK_WIDGET (fb->search), camel_folder_has_search_capability (folder));
- message_list_set_folder (fb->message_list, folder,
- folder_browser_is_drafts (fb) ||
- folder_browser_is_sent (fb) ||
- folder_browser_is_outbox (fb));
-
- camel_object_hook_event (CAMEL_OBJECT (fb->folder), "folder_changed",
- folder_changed, fb);
- camel_object_hook_event (CAMEL_OBJECT (fb->folder), "message_changed",
- folder_changed, fb);
-
- if (fb->view_instance != NULL && fb->view_menus != NULL)
- folder_browser_ui_discard_view_menus (fb);
-
- folder_browser_ui_setup_view_menus (fb);
-
- /* when loading a new folder, nothing is selected initially */
-
- if (fb->uicomp)
- folder_browser_ui_set_selection_state (fb, FB_SELSTATE_NONE);
-
- done:
- g_signal_emit (fb, folder_browser_signals[FOLDER_LOADED], 0, fb->uri);
- g_object_unref (fb);
-}
-
-
-void
-folder_browser_reload (FolderBrowser *fb)
-{
- g_return_if_fail (IS_FOLDER_BROWSER (fb));
-
- if (fb->folder) {
- mail_refresh_folder (fb->folder, NULL, NULL);
- } else if (fb->uri && fb->get_id == -1) {
- g_object_ref (fb);
- fb->get_id = mail_get_folder (fb->uri, 0, got_folder, fb, mail_thread_new);
- }
-}
-
-void
-folder_browser_set_folder (FolderBrowser *fb, CamelFolder *folder, const char *uri)
-{
- g_return_if_fail (IS_FOLDER_BROWSER (fb));
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
-
- if (fb->get_id != -1) {
- /* FIXME: cancel the get_folder request? */
- }
-
- g_free (fb->uri);
- fb->uri = g_strdup (uri);
-
- g_object_ref (fb);
- got_folder (NULL, folder, fb);
-}
-
-void
-folder_browser_set_ui_component (FolderBrowser *fb, BonoboUIComponent *uicomp)
-{
- g_return_if_fail (IS_FOLDER_BROWSER (fb));
-
- if (fb->sensitize_timeout_id) {
- g_source_remove (fb->sensitize_timeout_id);
- fb->sensitize_timeout_id = 0;
- }
-
- if (fb->sensitise_state) {
- g_hash_table_destroy (fb->sensitise_state);
- fb->sensitise_state = NULL;
- }
-
- if (fb->uicomp)
- bonobo_object_unref (BONOBO_OBJECT (fb->uicomp));
-
- if (uicomp)
- bonobo_object_ref (BONOBO_OBJECT (uicomp));
-
- fb->uicomp = uicomp;
-}
-
-void
-folder_browser_set_shell_view(FolderBrowser *fb, GNOME_Evolution_ShellView shell_view)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init(&ev);
- if (fb->shell_view != CORBA_OBJECT_NIL)
- CORBA_Object_release (fb->shell_view, &ev);
- CORBA_exception_free (&ev);
-
- fb->shell_view = CORBA_Object_duplicate (shell_view, &ev);
- CORBA_exception_free (&ev);
-
- /* small hack, at this point we've just been activated */
- if (fb->shell_view != CORBA_OBJECT_NIL)
- update_status_bar (fb);
-}
-
-extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder;
-
-/**
- * folder_browser_is_drafts:
- * @fb: a FolderBrowser
- *
- * Return value: %TRUE if @fb refers to /local/Drafts or any other
- * configured Drafts folder.
- **/
-gboolean
-folder_browser_is_drafts (FolderBrowser *fb)
-{
- gboolean is_drafts = FALSE;
- EAccountList *accounts;
- EAccount *account;
- EIterator *iter;
-
- g_return_val_if_fail (IS_FOLDER_BROWSER (fb), FALSE);
-
- if (fb->uri == NULL || fb->folder == NULL)
- return FALSE;
-
- if (fb->folder == drafts_folder)
- return TRUE;
-
- accounts = mail_config_get_accounts ();
- iter = e_list_get_iterator ((EList *) accounts);
- while (e_iterator_is_valid (iter)) {
- account = (EAccount *) e_iterator_get (iter);
- if (account->drafts_folder_uri &&
- camel_store_uri_cmp (fb->folder->parent_store, account->drafts_folder_uri, fb->uri)) {
- is_drafts = TRUE;
- break;
- }
-
- e_iterator_next (iter);
- }
-
- g_object_unref (iter);
-
- return is_drafts;
-}
-
-/**
- * folder_browser_is_sent:
- * @fb: a FolderBrowser
- *
- * Return value: %TRUE if @fb refers to /local/Sent or any other
- * configured Sent folder.
- **/
-gboolean
-folder_browser_is_sent (FolderBrowser *fb)
-{
- gboolean is_sent = FALSE;
- EAccountList *accounts;
- EAccount *account;
- EIterator *iter;
-
- g_return_val_if_fail (IS_FOLDER_BROWSER (fb), FALSE);
-
- if (fb->uri == NULL || fb->folder == NULL)
- return FALSE;
-
- if (fb->folder == sent_folder)
- return TRUE;
-
- accounts = mail_config_get_accounts ();
- iter = e_list_get_iterator ((EList *) accounts);
- while (e_iterator_is_valid (iter)) {
- account = (EAccount *) e_iterator_get (iter);
- if (account->sent_folder_uri &&
- camel_store_uri_cmp (fb->folder->parent_store, account->sent_folder_uri, fb->uri)) {
- is_sent = TRUE;
- break;
- }
-
- e_iterator_next (iter);
- }
-
- g_object_unref (iter);
-
- return is_sent;
-}
-
-/**
- * folder_browser_is_outbox:
- * @fb: a FolderBrowser
- *
- * Return value: %TRUE if @fb refers to /local/Outbox or any other
- * configured Outbox folder.
- **/
-gboolean
-folder_browser_is_outbox (FolderBrowser *fb)
-{
- /* There can be only one. */
- return fb->folder == outbox_folder;
-}
-
-static int
-save_cursor_pos (FolderBrowser *fb)
-{
- ETreePath node;
- GtkAdjustment *adj;
- int row, y, height, paned_size;
- GConfClient *gconf;
-
- node = e_tree_get_cursor (fb->message_list->tree);
- if (!node)
- return -1;
-
- row = e_tree_row_of_node (fb->message_list->tree, node);
-
- if (row == -1)
- return 0;
-
- e_tree_get_cell_geometry (fb->message_list->tree, row, 0,
- NULL, &y, NULL, &height);
-
- gconf = mail_config_get_gconf_client ();
- paned_size = gconf_client_get_int (gconf, "/apps/evolution/mail/display/paned_size", NULL);
-
- adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (fb->message_list));
- y += adj->value - ((paned_size - height) / 2);
-
- return y;
-}
-
-static void
-set_cursor_pos (FolderBrowser *fb, int y)
-{
- GtkAdjustment *adj;
-
- if (y == -1)
- return;
-
- adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (fb->message_list));
- gtk_adjustment_set_value (adj, (gfloat)y);
-}
-
-static gboolean do_message_selected(FolderBrowser *fb);
-
-void
-folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show_preview)
-{
- GConfClient *gconf;
- int paned_size, y;
-
- if (folder_browser->preview_shown == show_preview
- || folder_browser->message_list == NULL)
- return;
-
- folder_browser->preview_shown = show_preview;
-
- gconf = mail_config_get_gconf_client ();
- paned_size = gconf_client_get_int (gconf, "/apps/evolution/mail/display/paned_size", NULL);
-
- if (show_preview) {
- y = save_cursor_pos (folder_browser);
- gtk_paned_set_position (GTK_PANED (folder_browser->vpaned), paned_size);
- gtk_widget_show (GTK_WIDGET (folder_browser->mail_display));
- do_message_selected (folder_browser);
- set_cursor_pos (folder_browser, y);
- } else {
- gtk_widget_hide (GTK_WIDGET (folder_browser->mail_display));
- mail_display_set_message (folder_browser->mail_display, NULL, NULL, NULL);
- folder_browser_ui_message_loaded (folder_browser);
- }
-}
-
-enum {
- ESB_SAVE,
-};
-
-static ESearchBarItem folder_browser_search_menu_items[] = {
- E_FILTERBAR_ADVANCED,
- { NULL, 0, NULL },
- E_FILTERBAR_SAVE,
- E_FILTERBAR_EDIT,
- { NULL, 0, NULL },
- { N_("Create _Virtual Folder From Search..."), ESB_SAVE, NULL },
- { NULL, -1, NULL }
-};
-
-static void
-folder_browser_search_menu_activated (ESearchBar *esb, int id, FolderBrowser *fb)
-{
- EFilterBar *efb = (EFilterBar *)esb;
-
- d(printf("menu activated\n"));
-
- switch (id) {
- case ESB_SAVE:
- d(printf("Save vfolder\n"));
- if (efb->current_query) {
- FilterRule *rule = vfolder_clone_rule(efb->current_query);
- char *name, *text;
-
- text = e_search_bar_get_text(esb);
- name = g_strdup_printf("%s %s", rule->name, (text&&text[0])?text:"''");
- g_free (text);
- filter_rule_set_name(rule, name);
- g_free (name);
-
- filter_rule_set_source(rule, FILTER_SOURCE_INCOMING);
- vfolder_rule_add_source((VfolderRule *)rule, fb->uri);
- vfolder_gui_add_rule((VfolderRule *)rule);
- }
- break;
- }
-}
-
-static void
-folder_browser_config_search (EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data)
-{
- FolderBrowser *fb = FOLDER_BROWSER (data);
- ESearchingTokenizer *st;
- GList *partl;
- struct _camel_search_words *words;
- int i;
-
- st = E_SEARCHING_TOKENIZER (fb->mail_display->html->engine->ht);
-
- e_searching_tokenizer_set_secondary_search_string (st, NULL);
-
- /* we scan the parts of a rule, and set all the types we know about to the query string */
- partl = rule->parts;
- while (partl) {
- FilterPart *part = partl->data;
-
- if (!strcmp(part->name, "subject")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "subject");
- if (input)
- filter_input_set_value(input, query);
- } else if (!strcmp(part->name, "body")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "word");
- if (input)
- filter_input_set_value(input, query);
-
- words = camel_search_words_split(query);
- for (i=0;i<words->len;i++)
- e_searching_tokenizer_add_secondary_search_string (st, words->words[i]->word);
- camel_search_words_free (words);
- } else if(!strcmp(part->name, "sender")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "sender");
- if (input)
- filter_input_set_value(input, query);
- } else if(!strcmp(part->name, "to")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "recipient");
- if (input)
- filter_input_set_value(input, query);
- }
-
- partl = partl->next;
- }
-
- d(printf("configuring search for search string '%s', rule is '%s'\n", query, rule->name));
-
- mail_display_redisplay (fb->mail_display, FALSE);
-}
-
-static void
-folder_browser_search_do_search (ESearchBar *esb, FolderBrowser *fb)
-{
- char *search_word;
-
- if (fb->message_list == NULL)
- return;
-
- d(printf("do search\n"));
-
- g_object_get (esb, "query", &search_word, NULL);
-
- message_list_set_search (fb->message_list, search_word);
-
- d(printf("query is %s\n", search_word));
- g_free (search_word);
-}
-
-static void
-folder_browser_query_changed (ESearchBar *esb, FolderBrowser *fb)
-{
- int id;
-
- id = e_search_bar_get_item_id (esb);
- if (id == E_FILTERBAR_ADVANCED_ID)
- folder_browser_search_do_search (esb, fb);
-}
-
-void
-folder_browser_toggle_preview (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- FolderBrowser *fb = user_data;
- gboolean bstate;
- GConfClient *gconf;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL)
- return;
-
- bstate = atoi(state);
- e_meta_set_bool(fb->meta, "show_preview", bstate);
-
- gconf = mail_config_get_gconf_client ();
- gconf_client_set_bool (gconf, "/apps/evolution/mail/display/show_preview", bstate, NULL);
-
- folder_browser_set_message_preview (fb, bstate);
-}
-
-void
-folder_browser_toggle_threads (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- FolderBrowser *fb = user_data;
- int prev_state;
- gboolean bstate;
- GConfClient *gconf;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL)
- return;
-
- bstate = atoi(state);
- e_meta_set_bool(fb->meta, "thread_list", bstate);
-
- gconf = mail_config_get_gconf_client ();
- gconf_client_set_bool (gconf, "/apps/evolution/mail/display/thread_list", bstate, NULL);
-
- message_list_set_threaded (fb->message_list, bstate);
-
- prev_state = fb->selection_state;
- fb->selection_state = FB_SELSTATE_UNDEFINED;
- folder_browser_ui_set_selection_state (fb, prev_state);
-}
-
-void
-folder_browser_toggle_hide_deleted (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- FolderBrowser *fb = user_data;
- GConfClient *gconf;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED || fb->message_list == NULL)
- return;
-
- gconf = mail_config_get_gconf_client ();
- gconf_client_set_bool (gconf, "/apps/evolution/mail/display/show_deleted",
- !atoi (state), NULL);
-
- if (!(fb->folder && (fb->folder->folder_flags & CAMEL_FOLDER_IS_TRASH)))
- message_list_set_hidedeleted (fb->message_list, atoi (state));
-}
-
-void
-folder_browser_toggle_caret_mode(BonoboUIComponent *component,
- const char * path,
- Bonobo_UIComponent_EventType type,
- const char * state,
- gpointer user_data)
-{
- GConfClient *gconf;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
-
- gconf = mail_config_get_gconf_client ();
- gconf_client_set_bool (gconf, "/apps/evolution/mail/display/caret_mode",
- atoi(state), NULL);
-}
-
-void
-folder_browser_set_message_display_style (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- extern char *message_display_styles[];
- FolderBrowser *fb = user_data;
- GConfClient *gconf;
- int i;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED
- || atoi (state) == 0
- || fb->message_list == NULL)
- return;
-
- gconf = mail_config_get_gconf_client ();
-
- for (i = 0; i < MAIL_CONFIG_DISPLAY_MAX; i++) {
- if (strstr (message_display_styles[i], path)) {
- fb->mail_display->display_style = i;
- mail_display_redisplay (fb->mail_display, TRUE);
-
- if (fb->pref_master)
- gconf_client_set_int (gconf, "/apps/evolution/mail/display/message_style", i, NULL);
-
- return;
- }
- }
-}
-
-void
-folder_browser_charset_changed (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- const char *charset;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED
- || fb->message_list == NULL)
- return;
-
- if (atoi (state)) {
- /* Charset menu names are "Charset-%s" where %s is the charset name */
- charset = path + strlen ("Charset-");
- if (!strcmp (charset, FB_DEFAULT_CHARSET))
- charset = NULL;
-
- mail_display_set_charset (fb->mail_display, charset);
- }
-}
-
-static void vfolder_type_uid(CamelFolder *folder, const char *uid, const char *uri, int type);
-
-static void
-vfolder_type_current(FolderBrowser *fb, int type)
-{
- GPtrArray *uids;
- int i;
-
- /* get uid */
- uids = g_ptr_array_new ();
- message_list_foreach (fb->message_list, enumerate_msg, uids);
-
- if (uids->len == 1)
- vfolder_type_uid (fb->folder, (char *)uids->pdata[0], fb->uri, type);
-
- for (i = 0; i < uids->len; i++)
- g_free (uids->pdata[i]);
- g_ptr_array_free (uids, TRUE);
-}
-
-/* external api to vfolder/filter on X, based on current message */
-void vfolder_subject (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_SUBJECT); }
-void vfolder_sender (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_FROM); }
-void vfolder_recipient (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_TO); }
-void vfolder_mlist (GtkWidget *w, FolderBrowser *fb) { vfolder_type_current(fb, AUTO_MLIST); }
-
-static void filter_type_uid (CamelFolder *folder, const char *uid, const char *source, int type);
-
-static void
-filter_type_current (FolderBrowser *fb, int type)
-{
- GPtrArray *uids;
- int i;
- const char *source;
-
- if (folder_browser_is_sent (fb) || folder_browser_is_outbox (fb))
- source = FILTER_SOURCE_OUTGOING;
- else
- source = FILTER_SOURCE_INCOMING;
-
- /* get uid */
- uids = g_ptr_array_new ();
- message_list_foreach (fb->message_list, enumerate_msg, uids);
-
- if (uids->len == 1)
- filter_type_uid (fb->folder, (char *)uids->pdata[0], source, type);
-
- for (i = 0; i < uids->len; i++)
- g_free (uids->pdata[i]);
- g_ptr_array_free (uids, TRUE);
-}
-
-void filter_subject (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_SUBJECT); }
-void filter_sender (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_FROM); }
-void filter_recipient (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_TO); }
-void filter_mlist (GtkWidget *w, FolderBrowser *fb) { filter_type_current (fb, AUTO_MLIST); }
-
-/* ************************************************************ */
-
-/* popup api to vfolder/filter on X, based on current selection */
-struct _filter_data {
- CamelFolder *folder;
- const char *source;
- char *uid;
- int type;
- char *uri;
- char *mlist;
-};
-
-static void
-filter_data_free (struct _filter_data *fdata)
-{
- g_free (fdata->uid);
- g_free (fdata->uri);
- if (fdata->folder)
- camel_object_unref (fdata->folder);
- g_free (fdata->mlist);
- g_free (fdata);
-}
-
-static void
-vfolder_type_got_message(CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *d)
-{
- struct _filter_data *data = d;
-
- if (msg)
- vfolder_gui_add_from_message(msg, data->type, data->uri);
-
- filter_data_free (data);
-}
-
-static void
-vfolder_type_uid(CamelFolder *folder, const char *uid, const char *uri, int type)
-{
- struct _filter_data *data;
-
- data = g_malloc0(sizeof(*data));
- data->type = type;
- data->uri = g_strdup(uri);
- mail_get_message(folder, uid, vfolder_type_got_message, data, mail_thread_new);
-}
-
-static void vfolder_subject_uid (GtkWidget *w, struct _filter_data *fdata) { vfolder_type_uid(fdata->folder, fdata->uid, fdata->uri, AUTO_SUBJECT); }
-static void vfolder_sender_uid(GtkWidget *w, struct _filter_data *fdata) { vfolder_type_uid(fdata->folder, fdata->uid, fdata->uri, AUTO_FROM); }
-static void vfolder_recipient_uid(GtkWidget *w, struct _filter_data *fdata) { vfolder_type_uid(fdata->folder, fdata->uid, fdata->uri, AUTO_TO); }
-static void vfolder_mlist_uid(GtkWidget *w, struct _filter_data *fdata) { vfolder_type_uid(fdata->folder, fdata->uid, fdata->uri, AUTO_MLIST); }
-
-static void
-filter_type_got_message(CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *d)
-{
- struct _filter_data *data = d;
-
- if (msg)
- filter_gui_add_from_message(msg, data->source, data->type);
-
- filter_data_free (data);
-}
-
-static void
-filter_type_uid(CamelFolder *folder, const char *uid, const char *source, int type)
-{
- struct _filter_data *data;
-
- data = g_malloc0(sizeof(*data));
- data->type = type;
- data->source = source;
- mail_get_message(folder, uid, filter_type_got_message, data, mail_thread_new);
-}
-
-static void filter_subject_uid (GtkWidget *w, struct _filter_data *fdata) { filter_type_uid(fdata->folder, fdata->uid, fdata->source, AUTO_SUBJECT); }
-static void filter_sender_uid(GtkWidget *w, struct _filter_data *fdata) { filter_type_uid(fdata->folder, fdata->uid, fdata->source, AUTO_FROM); }
-static void filter_recipient_uid(GtkWidget *w, struct _filter_data *fdata) { filter_type_uid(fdata->folder, fdata->uid, fdata->source, AUTO_TO); }
-static void filter_mlist_uid(GtkWidget *w, struct _filter_data *fdata) { filter_type_uid(fdata->folder, fdata->uid, fdata->source, AUTO_MLIST); }
-
-void
-hide_none(GtkWidget *w, FolderBrowser *fb)
-{
- message_list_hide_clear (fb->message_list);
-}
-
-void
-hide_selected(GtkWidget *w, FolderBrowser *fb)
-{
- GPtrArray *uids;
- int i;
-
- uids = g_ptr_array_new ();
- message_list_foreach (fb->message_list, enumerate_msg, uids);
- message_list_hide_uids (fb->message_list, uids);
- for (i = 0; i < uids->len; i++)
- g_free (uids->pdata[i]);
- g_ptr_array_free (uids, TRUE);
-}
-
-void
-hide_deleted(GtkWidget *w, FolderBrowser *fb)
-{
- MessageList *ml = fb->message_list;
-
- message_list_hide_add(ml, "(match-all (system-flag \"deleted\"))", ML_HIDE_SAME, ML_HIDE_SAME);
-}
-
-void
-hide_read(GtkWidget *w, FolderBrowser *fb)
-{
- MessageList *ml = fb->message_list;
-
- message_list_hide_add(ml, "(match-all (system-flag \"seen\"))", ML_HIDE_SAME, ML_HIDE_SAME);
-}
-
-/* dum de dum, about the 3rd copy of this function throughout the mailer/camel */
-static const char *
-strip_re(const char *subject)
-{
- const unsigned char *s, *p;
-
- s = (unsigned char *) subject;
-
- while (*s) {
- while(isspace (*s))
- s++;
- if (s[0] == 0)
- break;
- if ((s[0] == 'r' || s[0] == 'R')
- && (s[1] == 'e' || s[1] == 'E')) {
- p = s+2;
- while (isdigit(*p) || (ispunct(*p) && (*p != ':')))
- p++;
- if (*p == ':') {
- s = p + 1;
- } else
- break;
- } else
- break;
- }
- return (char *) s;
-}
-
-void
-hide_subject(GtkWidget *w, FolderBrowser *fb)
-{
- const char *subject;
- GString *expr;
-
- if (fb->mail_display->current_message) {
- subject = camel_mime_message_get_subject(fb->mail_display->current_message);
- if (subject) {
- subject = strip_re(subject);
- if (subject && subject[0]) {
- expr = g_string_new ("(match-all (header-contains \"subject\" ");
- e_sexp_encode_string (expr, subject);
- g_string_append (expr, "))");
- message_list_hide_add (fb->message_list, expr->str, ML_HIDE_SAME, ML_HIDE_SAME);
- g_string_free (expr, TRUE);
- return;
- }
- }
- }
-}
-
-void
-hide_sender (GtkWidget *w, FolderBrowser *fb)
-{
- const CamelInternetAddress *from;
- const char *real, *addr;
- GString *expr;
-
- if (fb->mail_display->current_message) {
- from = camel_mime_message_get_from (fb->mail_display->current_message);
- if (camel_internet_address_get (from, 0, &real, &addr)) {
- expr = g_string_new ("(match-all (header-contains \"from\" ");
- e_sexp_encode_string (expr, addr);
- g_string_append (expr, "))");
- message_list_hide_add (fb->message_list, expr->str, ML_HIDE_SAME, ML_HIDE_SAME);
- g_string_free (expr, TRUE);
- return;
- }
- }
-}
-
-struct _label_data {
- FolderBrowser *fb;
- const char *label;
-};
-
-static void
-set_msg_label (GtkWidget *widget, gpointer user_data)
-{
- struct _label_data *data = user_data;
- GPtrArray *uids;
- int i;
-
- uids = g_ptr_array_new ();
- message_list_foreach (data->fb->message_list, enumerate_msg, uids);
- for (i = 0; i < uids->len; i++)
- camel_folder_set_message_user_tag (data->fb->folder, uids->pdata[i], "label", data->label);
- g_ptr_array_free (uids, TRUE);
-}
-
-static void
-label_closures_free (GPtrArray *closures)
-{
- struct _label_data *data;
- int i;
-
- for (i = 0; i < closures->len; i++) {
- data = closures->pdata[i];
- g_object_unref (data->fb);
- g_free (data);
- }
- g_ptr_array_free (closures, TRUE);
-}
-
-static void
-mark_as_seen_cb (GtkWidget *widget, void *user_data)
-{
- mark_as_seen (NULL, user_data, NULL);
-}
-
-static void
-mark_as_unseen_cb (GtkWidget *widget, void *user_data)
-{
- mark_as_unseen (NULL, user_data, NULL);
-}
-
-static void
-mark_as_important_cb (GtkWidget *widget, void *user_data)
-{
- mark_as_important (NULL, user_data, NULL);
-}
-
-static void
-mark_as_unimportant_cb (GtkWidget *widget, void *user_data)
-{
- mark_as_unimportant (NULL, user_data, NULL);
-}
-
-enum {
- SELECTION_SET = 1<<1,
- CAN_MARK_READ = 1<<2,
- CAN_MARK_UNREAD = 1<<3,
- CAN_DELETE = 1<<4,
- CAN_UNDELETE = 1<<5,
- IS_MAILING_LIST = 1<<6,
- CAN_RESEND = 1<<7,
- CAN_MARK_IMPORTANT = 1<<8,
- CAN_MARK_UNIMPORTANT = 1<<9,
- CAN_FLAG_FOR_FOLLOWUP = 1<<10,
- CAN_FLAG_COMPLETED = 1<<11,
- CAN_CLEAR_FLAG = 1<<12,
- CAN_ADD_SENDER = 1<<13
-};
-
-#define MLIST_VFOLDER (3)
-#define MLIST_FILTER (8)
-
-static EPopupMenu filter_menu[] = {
- E_POPUP_ITEM_CC (N_("VFolder on _Subject"), G_CALLBACK (vfolder_subject_uid), NULL, SELECTION_SET),
- E_POPUP_ITEM_CC (N_("VFolder on Se_nder"), G_CALLBACK (vfolder_sender_uid), NULL, SELECTION_SET),
- E_POPUP_ITEM_CC (N_("VFolder on _Recipients"), G_CALLBACK (vfolder_recipient_uid), NULL, SELECTION_SET),
- E_POPUP_ITEM_CC (N_("VFolder on Mailing _List"), G_CALLBACK (vfolder_mlist_uid), NULL, SELECTION_SET | IS_MAILING_LIST),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM_CC (N_("Filter on Sub_ject"), G_CALLBACK (filter_subject_uid), NULL, SELECTION_SET),
- E_POPUP_ITEM_CC (N_("Filter on Sen_der"), G_CALLBACK (filter_sender_uid), NULL, SELECTION_SET),
- E_POPUP_ITEM_CC (N_("Filter on Re_cipients"), G_CALLBACK (filter_recipient_uid), NULL, SELECTION_SET),
- E_POPUP_ITEM_CC (N_("Filter on _Mailing List"), G_CALLBACK (filter_mlist_uid), NULL, SELECTION_SET | IS_MAILING_LIST),
-
- E_POPUP_TERMINATOR
-};
-
-static EPopupMenu label_menu[] = {
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (N_("None"), NULL, G_CALLBACK (set_msg_label), NULL, 0),
- E_POPUP_SEPARATOR,
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, G_CALLBACK (set_msg_label), NULL, 0),
- E_POPUP_TERMINATOR
-};
-
-static EPopupMenu context_menu[] = {
- E_POPUP_ITEM (N_("_Open"), G_CALLBACK (open_msg), 0),
- E_POPUP_ITEM (N_("_Edit as New Message..."), G_CALLBACK (resend_msg), CAN_RESEND),
- E_POPUP_ITEM (N_("_Save As..."), G_CALLBACK (save_msg), 0),
- E_POPUP_ITEM (N_("_Print"), G_CALLBACK (print_msg), 0),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("_Reply to Sender"), G_CALLBACK (reply_to_sender), 0),
- E_POPUP_ITEM (N_("Reply to _List"), G_CALLBACK (reply_to_list), 0),
- E_POPUP_ITEM (N_("Reply to _All"), G_CALLBACK (reply_to_all), 0),
- E_POPUP_ITEM (N_("_Forward"), G_CALLBACK (forward), 0),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Follo_w Up..."), G_CALLBACK (flag_for_followup), CAN_FLAG_FOR_FOLLOWUP),
- E_POPUP_ITEM (N_("Fla_g Completed"), G_CALLBACK (flag_followup_completed), CAN_FLAG_COMPLETED),
- E_POPUP_ITEM (N_("Cl_ear Flag"), G_CALLBACK (flag_followup_clear), CAN_CLEAR_FLAG),
-
- /* separator here? */
-
- E_POPUP_ITEM (N_("Mar_k as Read"), G_CALLBACK (mark_as_seen_cb), CAN_MARK_READ),
- E_POPUP_ITEM (N_("Mark as _Unread"), G_CALLBACK (mark_as_unseen_cb), CAN_MARK_UNREAD),
- E_POPUP_ITEM (N_("Mark as _Important"), G_CALLBACK (mark_as_important_cb), CAN_MARK_IMPORTANT),
- E_POPUP_ITEM (N_("_Mark as Unimportant"), G_CALLBACK (mark_as_unimportant_cb), CAN_MARK_UNIMPORTANT),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("_Delete"), G_CALLBACK (delete_msg), CAN_DELETE),
- E_POPUP_ITEM (N_("U_ndelete"), G_CALLBACK (undelete_msg), CAN_UNDELETE),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Mo_ve to Folder..."), G_CALLBACK (move_msg_cb), 0),
- E_POPUP_ITEM (N_("_Copy to Folder..."), G_CALLBACK (copy_msg_cb), 0),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_SUBMENU (N_("Label"), label_menu, 0),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Add Sender to Address_book"), G_CALLBACK (addrbook_sender), SELECTION_SET | CAN_ADD_SENDER),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_ITEM (N_("Appl_y Filters"), G_CALLBACK (apply_filters), 0),
-
- E_POPUP_SEPARATOR,
-
- E_POPUP_SUBMENU (N_("Crea_te Rule From Message"), filter_menu, SELECTION_SET),
-
- E_POPUP_TERMINATOR
-};
-
-/* Note: this must be kept in sync with the context_menu!!! */
-static char *context_pixmaps[] = {
- NULL, /* Open */
- NULL, /* Edit */
- "save-as-16.png",
- "print.xpm",
- NULL,
- "reply.xpm",
- NULL, /* Reply to List */
- "reply_to_all.xpm",
- "forward.xpm",
- NULL,
- "flag-for-followup-16.png",
- NULL, /* Flag */
- NULL, /* Clear */
- "mail-read.xpm",
- "mail-new.xpm",
- "priority-high.xpm",
- NULL, /* Mark as Unimportant */
- NULL,
- "evolution-trash-mini.png",
- "undelete_message-16.png",
- NULL,
- "move_message.xpm",
- "copy_16_message.xpm",
- NULL,
- NULL, /* Label */
- NULL,
- NULL, /* Add Sender to Addressbook */
- NULL,
- NULL, /* Apply Filters */
- NULL,
- NULL, /* Create Rule from Message */
-};
-
-struct cmpf_data {
- ETree *tree;
- int row, col;
-};
-
-static void
-context_menu_position_func (GtkMenu *menu, gint *x, gint *y,
- gboolean *push_in, gpointer user_data)
-{
- int tx, ty, tw, th;
- struct cmpf_data *closure = user_data;
-
- gdk_window_get_origin (GTK_WIDGET (closure->tree)->window, x, y);
- e_tree_get_cell_geometry (closure->tree, closure->row, closure->col,
- &tx, &ty, &tw, &th);
- *x += tx + tw / 2;
- *y += ty + th / 2;
-}
-
-static void
-setup_popup_icons (void)
-{
- int i;
-
- for (i = 0; context_menu[i].name; i++) {
- if (context_pixmaps[i]) {
- char *filename;
-
- filename = g_strdup_printf ("%s/%s", EVOLUTION_IMAGES, context_pixmaps[i]);
- context_menu[i].pixmap_widget = gtk_image_new_from_file (filename);
- g_free (filename);
- }
- }
-}
-
-/* handle context menu over message-list */
-static int
-on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, FolderBrowser *fb)
-{
- struct _filter_data *fdata = NULL;
- GPtrArray *uids, *closures;
- CamelMessageInfo *info;
- GSList *labels;
- int enable_mask = 0;
- int hide_mask = 0;
- char *mlist = NULL;
- GtkMenu *menu;
- int i;
-
- if (!folder_browser_is_sent (fb)) {
- enable_mask |= CAN_RESEND;
- hide_mask |= CAN_RESEND;
- } else {
- enable_mask |= CAN_ADD_SENDER;
- hide_mask |= CAN_ADD_SENDER;
- }
-
- if (folder_browser_is_drafts (fb)) {
- enable_mask |= CAN_ADD_SENDER;
- hide_mask |= CAN_ADD_SENDER;
- }
-
- if (fb->folder == outbox_folder) {
- enable_mask |= CAN_ADD_SENDER;
- hide_mask |= CAN_ADD_SENDER;
- }
-
- enable_mask |= SELECTION_SET;
-
- /* get a list of uids */
- uids = g_ptr_array_new ();
- message_list_foreach (fb->message_list, enumerate_msg, uids);
- if (uids->len >= 1) {
- /* gray-out any items we don't need */
- gboolean have_deleted = FALSE;
- gboolean have_undeleted = FALSE;
- gboolean have_seen = FALSE;
- gboolean have_unseen = FALSE;
- gboolean have_important = FALSE;
- gboolean have_unimportant = FALSE;
- gboolean have_flag_for_followup = FALSE;
- gboolean have_flag_completed = FALSE;
- gboolean have_flag_incomplete = FALSE;
- gboolean have_unflagged = FALSE;
- const char *tag;
-
- for (i = 0; i < uids->len; i++) {
- info = camel_folder_get_message_info (fb->folder, uids->pdata[i]);
- if (info == NULL)
- continue;
-
- if (i == 0 && uids->len == 1) {
- const char *mname, *p;
- char c, *o;
-
- /* used by filter/vfolder from X callbacks */
- fdata = g_malloc0(sizeof(*fdata));
- fdata->uid = g_strdup(uids->pdata[i]);
- fdata->uri = g_strdup(fb->uri);
- fdata->folder = fb->folder;
- camel_object_ref((CamelObject *)fdata->folder);
- if (folder_browser_is_sent (fb) || folder_browser_is_outbox (fb))
- fdata->source = FILTER_SOURCE_OUTGOING;
- else
- fdata->source = FILTER_SOURCE_INCOMING;
-
- enable_mask &= ~SELECTION_SET;
- mname = camel_message_info_mlist(info);
- if (mname && mname[0]) {
- fdata->mlist = g_strdup(mname);
-
- /* Escape the mailing list name before showing it */
- mlist = g_alloca ((strlen (mname) * 2) + 1);
- p = mname;
- o = mlist;
- while ((c = *p++)) {
- if (c == '_')
- *o++ = '_';
- *o++ = c;
- }
- *o = 0;
- }
- }
-
- if (info->flags & CAMEL_MESSAGE_SEEN)
- have_seen = TRUE;
- else
- have_unseen = TRUE;
-
- if (info->flags & CAMEL_MESSAGE_DELETED)
- have_deleted = TRUE;
- else
- have_undeleted = TRUE;
-
- if (info->flags & CAMEL_MESSAGE_FLAGGED)
- have_important = TRUE;
- else
- have_unimportant = TRUE;
-
- tag = camel_tag_get (&info->user_tags, "follow-up");
- if (tag && *tag) {
- have_flag_for_followup = TRUE;
- tag = camel_tag_get (&info->user_tags, "completed-on");
- if (tag && *tag)
- have_flag_completed = TRUE;
- else
- have_flag_incomplete = TRUE;
- } else
- have_unflagged = TRUE;
-
- camel_folder_free_message_info (fb->folder, info);
-
- if (have_seen && have_unseen && have_deleted && have_undeleted)
- break;
- }
-
- if (!have_unseen)
- enable_mask |= CAN_MARK_READ;
- if (!have_seen)
- enable_mask |= CAN_MARK_UNREAD;
-
- if (!have_undeleted)
- enable_mask |= CAN_DELETE;
- if (!have_deleted)
- enable_mask |= CAN_UNDELETE;
-
- if (!have_unimportant)
- enable_mask |= CAN_MARK_IMPORTANT;
- if (!have_important)
- enable_mask |= CAN_MARK_UNIMPORTANT;
-
- if (!have_flag_for_followup)
- enable_mask |= CAN_CLEAR_FLAG;
- if (!have_unflagged)
- enable_mask |= CAN_FLAG_FOR_FOLLOWUP;
- if (!have_flag_incomplete)
- enable_mask |= CAN_FLAG_COMPLETED;
-
- /*
- * Hide items that wont get used.
- */
- if (!(have_unseen && have_seen)) {
- if (have_seen)
- hide_mask |= CAN_MARK_READ;
- else
- hide_mask |= CAN_MARK_UNREAD;
- }
-
- if (!(have_undeleted && have_deleted)) {
- if (have_deleted)
- hide_mask |= CAN_DELETE;
- else
- hide_mask |= CAN_UNDELETE;
- }
-
- if (!(have_important && have_unimportant)) {
- if (have_important)
- hide_mask |= CAN_MARK_IMPORTANT;
- else
- hide_mask |= CAN_MARK_UNIMPORTANT;
- }
-
- if (!have_flag_for_followup)
- hide_mask |= CAN_CLEAR_FLAG;
- if (!have_unflagged)
- hide_mask |= CAN_FLAG_FOR_FOLLOWUP;
- if (!have_flag_incomplete)
- hide_mask |= CAN_FLAG_COMPLETED;
- }
-
- /* free uids */
- for (i = 0; i < uids->len; i++)
- g_free (uids->pdata[i]);
- g_ptr_array_free (uids, TRUE);
-
- /* generate the "Filter on Mailing List" menu item name */
- if (mlist == NULL) {
- enable_mask |= IS_MAILING_LIST;
- filter_menu[MLIST_FILTER].name = g_strdup (_("Filter on _Mailing List"));
- filter_menu[MLIST_VFOLDER].name = g_strdup (_("VFolder on M_ailing List"));
- } else {
- filter_menu[MLIST_FILTER].name = g_strdup_printf (_("Filter on _Mailing List (%s)"), mlist);
- filter_menu[MLIST_VFOLDER].name = g_strdup_printf (_("VFolder on M_ailing List (%s)"), mlist);
- }
-
- /* create the label/colour menu */
- closures = g_ptr_array_new ();
- label_menu[0].closure = g_new (struct _label_data, 1);
- g_ptr_array_add (closures, label_menu[0].closure);
- g_object_ref (fb);
- ((struct _label_data *) label_menu[0].closure)->fb = fb;
- ((struct _label_data *) label_menu[0].closure)->label = NULL;
-
- i = 0;
- labels = mail_config_get_labels ();
- while (labels != NULL && i < 5) {
- struct _label_data *closure;
- MailConfigLabel *label;
- GdkPixmap *pixmap;
- GdkColormap *map;
- GdkColor colour;
- GdkGC *gc;
-
- label = labels->data;
- gdk_color_parse (label->colour, &colour);
- map = gdk_colormap_get_system ();
- gdk_color_alloc (map, &colour);
-
- pixmap = gdk_pixmap_new (GTK_WIDGET (fb)->window, 16, 16, -1);
- gc = gdk_gc_new (GTK_WIDGET (fb)->window);
- gdk_gc_set_foreground (gc, &colour);
- gdk_draw_rectangle (pixmap, gc, TRUE, 0, 0, 16, 16);
- gdk_gc_unref (gc);
-
- closure = g_new (struct _label_data, 1);
- g_object_ref (fb);
- closure->fb = fb;
- closure->label = label->tag;
-
- g_ptr_array_add (closures, closure);
-
- label_menu[i + 2].name = label->name;
- label_menu[i + 2].pixmap_widget = gtk_image_new_from_pixmap (pixmap, NULL);
- label_menu[i + 2].closure = closure;
-
- i++;
- labels = labels->next;
- }
-
- setup_popup_icons ();
-
- for (i = 0; i < sizeof (filter_menu) / sizeof (filter_menu[0]); i++)
- filter_menu[i].closure = fdata;
-
- menu = e_popup_menu_create (context_menu, enable_mask, hide_mask, fb);
- e_auto_kill_popup_menu_on_selection_done (menu);
-
- g_object_set_data_full ((GObject *) menu, "label_closures", closures, (GtkDestroyNotify) label_closures_free);
-
- if (fdata)
- g_object_set_data_full ((GObject *) menu, "filter_data", fdata, (GtkDestroyNotify) filter_data_free);
-
- if (event->type == GDK_KEY_PRESS) {
- struct cmpf_data closure;
-
- closure.tree = tree;
- closure.row = row;
- closure.col = col;
- gtk_menu_popup (menu, NULL, NULL, context_menu_position_func,
- &closure, 0, event->key.time);
- } else {
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
- event->button.button, event->button.time);
- }
-
- g_free (filter_menu[MLIST_FILTER].name);
- g_free (filter_menu[MLIST_VFOLDER].name);
-
- return TRUE;
-}
-
-static int
-html_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- FolderBrowser *fb = data;
- HTMLEngine *engine;
- HTMLPoint *point;
- ETreePath *path;
- int row;
-
- if (event->type != GDK_BUTTON_PRESS || event->button != 3)
- return FALSE;
-
- engine = GTK_HTML (widget)->engine;
- point = html_engine_get_point_at (engine, event->x, event->y, FALSE);
-
- if (point) {
- /* don't popup a menu if the mouse is hovering over a
- url or a source image because those situations are
- handled in mail-display.c's button_press_event
- callback */
- const char *src, *url;
-
- url = html_object_get_url (point->object);
- src = html_object_get_src (point->object);
-
- if (url || src) {
- html_point_destroy (point);
- return FALSE;
- }
-
- html_point_destroy (point);
- }
-
- path = e_tree_get_cursor (fb->message_list->tree);
- row = e_tree_row_of_node (fb->message_list->tree, path);
-
- on_right_click (fb->message_list->tree, row, path, 2,
- (GdkEvent *) event, fb);
-
- return TRUE;
-}
-
-static int
-on_key_press (GtkWidget *widget, GdkEventKey *key, gpointer data)
-{
- FolderBrowser *fb = data;
- ETreePath *path;
- int row;
-
- if (key->state & GDK_CONTROL_MASK)
- return FALSE;
-
- path = e_tree_get_cursor (fb->message_list->tree);
- row = e_tree_row_of_node (fb->message_list->tree, path);
-
- switch (key->keyval) {
- case GDK_Delete:
- case GDK_KP_Delete:
- delete_msg (NULL, fb);
- return TRUE;
-
- case GDK_Menu:
- on_right_click (fb->message_list->tree, row, path, 2,
- (GdkEvent *)key, fb);
- return TRUE;
- case '!':
- toggle_as_important (NULL, fb, NULL);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static int
-etree_key (ETree *tree, int row, ETreePath path, int col, GdkEvent *ev, FolderBrowser *fb)
-{
- GtkAdjustment *vadj;
- gfloat page_size;
-
- if ((ev->key.state & GDK_CONTROL_MASK) != 0)
- return FALSE;
-
- vadj = gtk_scrolled_window_get_vadjustment (fb->mail_display->scroll);
- page_size = vadj->page_size - vadj->step_increment;
-
- switch (ev->key.keyval) {
- case GDK_space:
- /* Work around Ximian 4939 */
- if (vadj->upper < vadj->page_size)
- break;
- if (vadj->value < vadj->upper - vadj->page_size - page_size)
- vadj->value += page_size;
- else
- vadj->value = vadj->upper - vadj->page_size;
- gtk_adjustment_value_changed (vadj);
- break;
- case GDK_BackSpace:
- if (vadj->value > vadj->lower + page_size)
- vadj->value -= page_size;
- else
- vadj->value = vadj->lower;
- gtk_adjustment_value_changed (vadj);
- break;
- case GDK_Return:
- case GDK_KP_Enter:
- case GDK_ISO_Enter:
- open_msg (NULL, fb);
- break;
- default:
- return on_key_press ((GtkWidget *)tree, (GdkEventKey *)ev, fb);
- }
-
- return TRUE;
-}
-
-static void
-on_double_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, FolderBrowser *fb)
-{
- /* Ignore double-clicks on columns where single-click doesn't
- * just select.
- */
- if (MESSAGE_LIST_COLUMN_IS_ACTIVE (col))
- return;
-
- open_msg (NULL, fb);
-}
-
-static void
-on_selection_changed (GtkObject *obj, gpointer user_data)
-{
- FolderBrowser *fb = FOLDER_BROWSER (user_data);
- FolderBrowserSelectionState state;
-
- /* we can get this signal at strange times...
- * if no uicomp, don't even bother */
-
- if (fb->uicomp == NULL)
- return;
-
- switch (e_selection_model_selected_count (E_SELECTION_MODEL (obj))) {
- case 0:
- state = FB_SELSTATE_NONE;
- break;
- case 1:
- state = FB_SELSTATE_SINGLE;
- break;
- default:
- state = FB_SELSTATE_MULTIPLE;
- break;
- }
-
- folder_browser_ui_set_selection_state (fb, state);
-
- update_status_bar_idle (fb);
-}
-
-
-static void
-on_cursor_activated (ETree *tree, int row, ETreePath path, gpointer user_data)
-{
- on_selection_changed ((GtkObject *)tree, user_data);
-}
-
-static gboolean
-fb_resize_cb (GtkWidget *w, GdkEventButton *e, FolderBrowser *fb)
-{
- GConfClient *gconf;
-
- if (GTK_WIDGET_REALIZED (w) && fb->preview_shown) {
- gconf = mail_config_get_gconf_client ();
- gconf_client_set_int (gconf, "/apps/evolution/mail/display/paned_size", gtk_paned_get_position (GTK_PANED (w)), NULL);
- }
-
- return FALSE;
-}
-
-/* hack to get around the fact setting the paned size doesn't work */
-static void
-paned_realised(GtkWidget *w, FolderBrowser *fb)
-{
- GConfClient *gconf;
- int size;
-
- gconf = mail_config_get_gconf_client ();
- size = gconf_client_get_int (gconf, "/apps/evolution/mail/display/paned_size", NULL);
- gtk_paned_set_position (GTK_PANED (fb->vpaned), size);
-}
-
-static void
-folder_browser_gui_init (FolderBrowser *fb)
-{
- RuleContext *search_context = mail_component_peek_search_context (mail_component_peek ());
- ESelectionModel *esm;
-
- /* The panned container */
- fb->vpaned = gtk_vpaned_new ();
- g_signal_connect(fb->vpaned, "realize", G_CALLBACK(paned_realised), fb);
- gtk_widget_show (fb->vpaned);
-
- gtk_table_attach (GTK_TABLE (fb), fb->vpaned,
- 0, 1, 1, 3,
- GTK_FILL | GTK_EXPAND,
- GTK_FILL | GTK_EXPAND,
- 0, 0);
-
- /* quick-search bar */
- if (search_context) {
- const char *systemrules = g_object_get_data (G_OBJECT (search_context), "system");
- const char *userrules = g_object_get_data (G_OBJECT (search_context), "user");
-
- fb->search = e_filter_bar_new (search_context, systemrules, userrules,
- folder_browser_config_search, fb);
- e_search_bar_set_menu ((ESearchBar *)fb->search, folder_browser_search_menu_items);
- gtk_widget_show (GTK_WIDGET (fb->search));
-
- g_signal_connect (fb->search, "menu_activated",
- G_CALLBACK (folder_browser_search_menu_activated), fb);
- g_signal_connect (fb->search, "search_activated",
- G_CALLBACK (folder_browser_search_do_search), fb);
- g_signal_connect (fb->search, "query_changed",
- G_CALLBACK (folder_browser_query_changed), fb);
-
- gtk_table_attach (GTK_TABLE (fb), GTK_WIDGET (fb->search),
- 0, 1, 0, 1,
- GTK_FILL | GTK_EXPAND,
- 0,
- 0, 0);
- }
-
- esm = e_tree_get_selection_model (E_TREE (fb->message_list->tree));
- g_signal_connect (esm, "selection_changed", G_CALLBACK (on_selection_changed), fb);
- g_signal_connect (esm, "cursor_activated", G_CALLBACK (on_cursor_activated), fb);
- fb->selection_state = FB_SELSTATE_NONE; /* default to none */
-
- gtk_paned_add1 (GTK_PANED (fb->vpaned), GTK_WIDGET (fb->message_list));
- gtk_widget_show (GTK_WIDGET (fb->message_list));
-
- fb->paned_resize_id = g_signal_connect (fb->vpaned, "button_release_event",
- G_CALLBACK (fb_resize_cb), fb);
-
- gtk_paned_add2 (GTK_PANED (fb->vpaned), GTK_WIDGET (fb->mail_display));
- gtk_widget_show (GTK_WIDGET (fb->mail_display));
- gtk_widget_show (GTK_WIDGET (fb));
-}
-
-/* mark the message seen if the current message still matches */
-static gint
-do_mark_seen (gpointer data)
-{
- FolderBrowser *fb = FOLDER_BROWSER (data);
-
- if (fb->new_uid && fb->loaded_uid && !strcmp (fb->new_uid, fb->loaded_uid)) {
- camel_folder_set_message_flags (fb->folder, fb->new_uid,
- CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
- }
-
- return FALSE;
-}
-
-/* callback when we have the message to display, after async loading it (see below) */
-/* if we have pending uid's, it means another was selected before we finished displaying
- the last one - so we cycle through and start loading the pending one immediately now */
-static void
-done_message_selected (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data)
-{
- FolderBrowser *fb = data;
- CamelMessageInfo *info;
- GConfClient *gconf;
- int timeout;
-
- if (folder != fb->folder || fb->mail_display == NULL)
- return;
-
- gconf = mail_config_get_gconf_client ();
- timeout = gconf_client_get_int (gconf, "/apps/evolution/mail/display/mark_seen_timeout", NULL);
-
- info = camel_folder_get_message_info (fb->folder, uid);
- mail_display_set_message (fb->mail_display, (CamelMedium *) msg, fb->folder, info);
- if (info)
- camel_folder_free_message_info (fb->folder, info);
-
- /* FIXME: should this signal be emitted here?? */
- g_signal_emit (fb, folder_browser_signals[MESSAGE_LOADED], 0, uid);
-
- /* pain, if we have pending stuff, re-run */
- if (fb->pending_uid) {
- g_free (fb->loading_uid);
- fb->loading_uid = fb->pending_uid;
- fb->pending_uid = NULL;
-
- mail_get_message (fb->folder, fb->loading_uid, done_message_selected, fb, mail_thread_new);
- return;
- }
-
- g_free (fb->loaded_uid);
- fb->loaded_uid = fb->loading_uid;
- fb->loading_uid = NULL;
-
- folder_browser_ui_message_loaded (fb);
-
- /* if we are still on the same message, do the 'idle read' thing */
- if (fb->seen_id)
- g_source_remove (fb->seen_id);
-
- if (msg && gconf_client_get_bool (gconf, "/apps/evolution/mail/display/mark_seen", NULL)) {
- if (timeout > 0)
- fb->seen_id = g_timeout_add (timeout, do_mark_seen, fb);
- else
- do_mark_seen (fb);
- }
-}
-
-/* ok we waited enough, display it anyway (see below) */
-static gboolean
-do_message_selected (FolderBrowser *fb)
-{
- d(printf ("%p: selecting uid %s (delayed)\n", fb, fb->new_uid ? fb->new_uid : "NONE"));
-
- fb->loading_id = 0;
-
- /* if we are loading, then set a pending, but leave the loading, coudl cancel here (?) */
- if (fb->loading_uid) {
- if (fb->new_uid == NULL || fb->pending_uid == NULL || strcmp(fb->pending_uid, fb->new_uid) != 0) {
- g_free (fb->pending_uid);
- fb->pending_uid = g_strdup (fb->new_uid);
- }
- } else {
- if (fb->new_uid) {
- if (fb->loaded_uid == NULL || strcmp(fb->new_uid, fb->loaded_uid) != 0) {
- fb->loading_uid = g_strdup (fb->new_uid);
- mail_get_message (fb->folder, fb->loading_uid, done_message_selected, fb, mail_thread_new);
- }
- } else {
- mail_display_set_message (fb->mail_display, NULL, NULL, NULL);
- }
- }
-
- return FALSE;
-}
-
-/* when a message is selected, wait a while before trying to display it */
-static void
-on_message_selected (MessageList *ml, const char *uid, FolderBrowser *fb)
-{
- d(printf ("%p: selecting uid %s (direct)\n", fb, uid ? uid : "NONE"));
-
- if (fb->loading_id != 0)
- g_source_remove (fb->loading_id);
-
- g_free (fb->new_uid);
- fb->new_uid = g_strdup (uid);
-
- if (fb->preview_shown)
- fb->loading_id = g_timeout_add (100, (GtkFunction)do_message_selected, fb);
-}
-
-static gboolean
-on_message_list_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
-{
- FolderBrowser *fb = (FolderBrowser *) user_data;
-
- d(printf ("got focus!\n"));
- folder_browser_ui_message_list_focus (fb);
-
- return FALSE;
-}
-
-static gboolean
-on_message_list_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
-{
- FolderBrowser *fb = (FolderBrowser *) user_data;
-
- d(printf ("got unfocus!\n"));
- folder_browser_ui_message_list_unfocus (fb);
-
- return FALSE;
-}
-
-static void
-folder_browser_init (FolderBrowser *fb)
-{
- fb->async_event = mail_async_event_new ();
- fb->get_id = -1;
-}
-
-static void
-my_folder_browser_init (FolderBrowser *fb)
-{
- int i;
-
- fb->view_instance = NULL;
- fb->view_menus = NULL;
-
- fb->pref_master = FALSE;
-
- /*
- * Setup parent class fields.
- */
- GTK_TABLE (fb)->homogeneous = FALSE;
- gtk_table_resize (GTK_TABLE (fb), 1, 2);
-
- /*
- * Our instance data
- */
- fb->message_list = (MessageList *)message_list_new ();
- fb->mail_display = (MailDisplay *)mail_display_new ();
-
- fb->preview_shown = TRUE;
-
- g_signal_connect (fb->mail_display->html, "key_press_event",
- G_CALLBACK (on_key_press), fb);
- g_signal_connect (fb->mail_display->html, "button_press_event",
- G_CALLBACK (html_button_press_event), fb);
-
- g_signal_connect (fb->message_list->tree, "key_press",
- G_CALLBACK (etree_key), fb);
-
- g_signal_connect (fb->message_list->tree, "right_click",
- G_CALLBACK (on_right_click), fb);
-
- g_signal_connect (fb->message_list->tree, "double_click",
- G_CALLBACK (on_double_click), fb);
-
- g_signal_connect (fb->message_list, "focus_in_event",
- G_CALLBACK (on_message_list_focus_in), fb);
-
- g_signal_connect (fb->message_list, "focus_out_event",
- G_CALLBACK (on_message_list_focus_out), fb);
-
- g_signal_connect (fb->message_list, "message_selected",
- G_CALLBACK (on_message_selected), fb);
-
- /* drag & drop */
- e_tree_drag_source_set (fb->message_list->tree, GDK_BUTTON1_MASK,
- drag_types, num_drag_types, GDK_ACTION_MOVE | GDK_ACTION_COPY);
-
- g_signal_connect (fb->message_list->tree, "tree_drag_data_get",
- G_CALLBACK (message_list_drag_data_get), fb);
-
- e_tree_drag_dest_set (fb->message_list->tree, GTK_DEST_DEFAULT_ALL,
- drag_types, num_drag_types, GDK_ACTION_MOVE | GDK_ACTION_COPY);
-
- g_signal_connect (fb->message_list->tree, "tree_drag_data_received",
- G_CALLBACK (message_list_drag_data_received), fb);
-
- /* cut, copy & paste */
- fb->invisible = gtk_invisible_new ();
- g_object_ref (fb->invisible);
- gtk_object_sink ((GtkObject *) fb->invisible);
-
- for (i = 0; i < num_paste_types; i++)
- gtk_selection_add_target (fb->invisible, clipboard_atom,
- paste_types[i].target,
- paste_types[i].info);
-
- g_signal_connect (fb->invisible, "selection_get",
- G_CALLBACK (selection_get), fb);
- g_signal_connect (fb->invisible, "selection_clear_event",
- G_CALLBACK (selection_clear_event), fb);
- g_signal_connect (fb->invisible, "selection_received",
- G_CALLBACK (selection_received), fb);
-
- folder_browser_gui_init (fb);
-}
-
-GtkWidget *
-folder_browser_new (const char *uri)
-{
- CORBA_Environment ev;
- FolderBrowser *folder_browser;
-
- CORBA_exception_init (&ev);
-
- folder_browser = g_object_new (folder_browser_get_type (), NULL);
-
- my_folder_browser_init (folder_browser);
-
- CORBA_exception_free (&ev);
-
- if (uri) {
- folder_browser->uri = g_strdup (uri);
- folder_browser->meta = mail_tool_get_meta_data(uri);
- g_object_ref (folder_browser);
- folder_browser->get_id = mail_get_folder (folder_browser->uri, 0, got_folder,
- folder_browser, mail_thread_new);
- }
-
- return GTK_WIDGET (folder_browser);
-}
-
-
-E_MAKE_TYPE (folder_browser, "FolderBrowser", FolderBrowser, folder_browser_class_init, folder_browser_init, PARENT_TYPE);
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
deleted file mode 100644
index 1b03ec9efb..0000000000
--- a/mail/folder-browser.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-
-#ifndef _FOLDER_BROWSER_H_
-#define _FOLDER_BROWSER_H_
-
-#include <gtk/gtktable.h>
-#include "camel/camel-stream.h"
-#include <bonobo/bonobo-property-bag.h>
-#include <bonobo/bonobo-ui-component.h>
-#include <widgets/misc/e-filter-bar.h>
-#include "widgets/menus/gal-view-menus.h"
-#include "filter/filter-rule.h"
-#include "filter/filter-context.h" /*eek*/
-#include "message-list.h"
-#include "mail-display.h"
-#include "mail-types.h"
-#include "shell/Evolution.h"
-
-#define FOLDER_BROWSER_TYPE (folder_browser_get_type ())
-#define FOLDER_BROWSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), FOLDER_BROWSER_TYPE, FolderBrowser))
-#define FOLDER_BROWSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), FOLDER_BROWSER_TYPE, FolderBrowserClass))
-#define IS_FOLDER_BROWSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), FOLDER_BROWSER_TYPE))
-#define IS_FOLDER_BROWSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), FOLDER_BROWSER_TYPE))
-
-#define FB_DEFAULT_CHARSET _("Default")
-
-#define FOLDER_BROWSER_IS_DESTROYED(fb) (!fb || !fb->message_list || !fb->mail_display || !fb->folder)
-
-typedef enum _FolderBrowserSelectionState {
- FB_SELSTATE_NONE,
- FB_SELSTATE_SINGLE,
- FB_SELSTATE_MULTIPLE,
- FB_SELSTATE_UNDEFINED
-} FolderBrowserSelectionState;
-
-struct _FolderBrowser {
- GtkTable parent;
-
- BonoboPropertyBag *properties;
-
- GNOME_Evolution_ShellView shell_view;
-
- BonoboUIComponent *uicomp;
-
- /*
- * The current URI being displayed by the FolderBrowser
- */
- char *uri;
- CamelFolder *folder;
- int unread_count; /* last known unread message count */
-
- /* async loading stuff */
- char *loading_uid; /* what uid am i loading now */
- char *pending_uid; /* what uid should i load next */
- char *new_uid; /* place to save the next uid during idle timeout */
- char *loaded_uid; /* what we have loaded */
- guint loading_id;
- guint seen_id;
-
- gulong paned_resize_id;
-
- /* a folder we are expunging, dont use other than to compare the pointer value */
- CamelFolder *expunging;
- int expunge_mlfocussed; /* true if the ml was focussed before we expunged */
-
- MessageList *message_list;
- MailDisplay *mail_display;
- GtkWidget *vpaned;
-
- EFilterBar *search;
- FilterRule *search_full; /* if we have a full search active */
-
- struct _EMeta *meta; /* various per-folder meta-data */
-
- guint32 preview_shown : 1;
- guint32 threaded : 1;
- guint32 pref_master : 1;
-
- FolderBrowserSelectionState selection_state;
- GSList *sensitize_changes;
- GHashTable *sensitise_state; /* the last sent sensitise state, to avoid much bonobo overhead */
- int sensitize_timeout_id;
- int update_status_bar_idle_id;
-
- /* View instance and the menu handler object */
- GalViewInstance *view_instance;
- GalViewMenus *view_menus;
-
- GtkWidget *invisible;
- GByteArray *clipboard_selection;
-
- /* for async events */
- struct _MailAsyncEvent *async_event;
-
- int get_id; /* for getting folder op */
-
- /* info used by popup for filter/vfolder */
- struct _popup_filter_data *popup;
-};
-
-typedef struct {
- GtkTableClass parent_class;
-
- /* signals */
- void (*folder_loaded) (FolderBrowser *fb, const char *uri);
- void (*message_loaded) (FolderBrowser *fb, const char *uid);
-} FolderBrowserClass;
-
-struct fb_ondemand_closure {
- FilterRule *rule;
- FolderBrowser *fb;
- gchar *path;
-};
-
-GtkType folder_browser_get_type (void);
-GtkWidget *folder_browser_new (const char *uri);
-
-void folder_browser_set_folder (FolderBrowser *fb, CamelFolder *folder, const char *uri);
-
-void folder_browser_set_ui_component (FolderBrowser *fb, BonoboUIComponent *uicomp);
-void folder_browser_set_shell_view (FolderBrowser *fb, GNOME_Evolution_ShellView shell_view);
-
-void folder_browser_set_message_preview (FolderBrowser *folder_browser,
- gboolean show_message_preview);
-void folder_browser_clear_search (FolderBrowser *fb);
-
-void folder_browser_cut (GtkWidget *widget, FolderBrowser *fb);
-void folder_browser_copy (GtkWidget *widget, FolderBrowser *fb);
-void folder_browser_paste (GtkWidget *widget, FolderBrowser *fb);
-
-void folder_browser_reload (FolderBrowser *fb);
-
-/* callbacks for functions on the folder-browser */
-void vfolder_subject (GtkWidget *w, FolderBrowser *fb);
-void vfolder_sender (GtkWidget *w, FolderBrowser *fb);
-void vfolder_recipient (GtkWidget *w, FolderBrowser *fb);
-void vfolder_mlist (GtkWidget *w, FolderBrowser *fb);
-
-void filter_subject (GtkWidget *w, FolderBrowser *fb);
-void filter_sender (GtkWidget *w, FolderBrowser *fb);
-void filter_recipient (GtkWidget *w, FolderBrowser *fb);
-void filter_mlist (GtkWidget *w, FolderBrowser *fb);
-
-void hide_read(GtkWidget *w, FolderBrowser *fb);
-void hide_deleted(GtkWidget *w, FolderBrowser *fb);
-void hide_selected(GtkWidget *w, FolderBrowser *fb);
-void hide_none(GtkWidget *w, FolderBrowser *fb);
-void hide_subject(GtkWidget *w, FolderBrowser *fb);
-void hide_sender(GtkWidget *w, FolderBrowser *fb);
-
-void folder_browser_toggle_preview (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data);
-
-void folder_browser_toggle_threads (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data);
-
-void folder_browser_toggle_hide_deleted (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data);
-
-void folder_browser_toggle_caret_mode (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data);
-
-void folder_browser_set_message_display_style (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data);
-
-void folder_browser_charset_changed (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data);
-
-gboolean folder_browser_is_drafts (FolderBrowser *fb);
-gboolean folder_browser_is_sent (FolderBrowser *fb);
-gboolean folder_browser_is_outbox (FolderBrowser *fb);
-
-#endif /* _FOLDER_BROWSER_H_ */