aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-local.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-local.c')
-rw-r--r--mail/mail-local.c227
1 files changed, 111 insertions, 116 deletions
diff --git a/mail/mail-local.c b/mail/mail-local.c
index cbec89d89e..e73dc0fc71 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -29,15 +29,17 @@
#include <config.h>
#endif
-#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <libxml/xmlmemory.h>
+#include <gnome-xml/xmlmemory.h>
+#include <libgnomeui/gnome-dialog.h>
+#include <libgnomeui/gnome-dialog-util.h>
#include <glade/glade.h>
#include "e-util/e-path.h"
-#include "e-util/e-dialog-utils.h"
+#include <gal/widgets/e-gui-utils.h>
+#include <gal/util/e-unicode-i18n.h>
#include <gal/util/e-xml-utils.h>
#include "Evolution.h"
@@ -149,11 +151,11 @@ load_metainfo(const char *path)
if (doc == NULL)
goto dodefault;
- node = doc->children;
+ node = doc->root;
if (strcmp(node->name, "folderinfo"))
goto dodefault;
- node = node->children;
+ node = node->childs;
while (node) {
if (!strcmp(node->name, "folder")) {
char *index, *txt;
@@ -237,11 +239,11 @@ mlf_refresh_info(CamelFolder *folder, CamelException *ex)
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_refresh_info(f, ex);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
static void
@@ -252,11 +254,11 @@ mlf_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_sync(f, expunge, ex);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
static void
@@ -267,11 +269,11 @@ mlf_expunge(CamelFolder *folder, CamelException *ex)
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_expunge(f, ex);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
static void
@@ -282,11 +284,11 @@ mlf_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMe
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_append_message(f, message, info, appended_uid, ex);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
static CamelMimeMessage *
@@ -298,11 +300,11 @@ mlf_get_message(CamelFolder *folder, const char *uid, CamelException *ex)
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
ret = camel_folder_get_message(f, uid, ex);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
return ret;
}
@@ -316,11 +318,11 @@ mlf_search_by_expression(CamelFolder *folder, const char *expression, CamelExcep
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
ret = camel_folder_search_by_expression(f, expression, ex);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
return ret;
}
@@ -334,11 +336,11 @@ mlf_search_by_uids(CamelFolder *folder, const char *expression, GPtrArray *uids,
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
ret = camel_folder_search_by_uids(f, expression, uids, ex);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
return ret;
}
@@ -351,11 +353,11 @@ mlf_search_free(CamelFolder *folder, GPtrArray *result)
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_search_free(f, result);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
static void
@@ -366,11 +368,11 @@ mlf_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_set_message_flags(mlf->real_folder, uid, flags, set);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
static void
@@ -381,11 +383,11 @@ mlf_set_message_user_flag(CamelFolder *folder, const char *uid, const char *name
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_set_message_user_flag(mlf->real_folder, uid, name, value);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
static void
@@ -396,11 +398,11 @@ mlf_set_message_user_tag(CamelFolder *folder, const char *uid, const char *name,
LOCAL_FOLDER_LOCK(mlf);
f = mlf->real_folder;
- camel_object_ref(f);
+ camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
camel_folder_set_message_user_tag(mlf->real_folder, uid, name, value);
- camel_object_unref(f);
+ camel_object_unref((CamelObject *)f);
}
/* Internal store-rename call, update our strings */
@@ -435,13 +437,13 @@ mlf_rename(CamelFolder *folder, const char *new)
static void
mlf_proxy_message_changed(CamelObject *real_folder, gpointer event_data, gpointer user_data)
{
- camel_object_trigger_event(user_data, "message_changed", event_data);
+ camel_object_trigger_event((CamelObject *)user_data, "message_changed", event_data);
}
static void
mlf_proxy_folder_changed(CamelObject *real_folder, gpointer event_data, gpointer user_data)
{
- camel_object_trigger_event(user_data, "folder_changed", event_data);
+ camel_object_trigger_event((CamelObject *)user_data, "folder_changed", event_data);
}
static void
@@ -451,20 +453,20 @@ mlf_unset_folder (MailLocalFolder *mlf)
g_assert(mlf->real_folder);
- camel_object_unhook_event(mlf->real_folder,
+ camel_object_unhook_event(CAMEL_OBJECT(mlf->real_folder),
"message_changed",
mlf_proxy_message_changed,
mlf);
- camel_object_unhook_event(mlf->real_folder,
+ camel_object_unhook_event(CAMEL_OBJECT(mlf->real_folder),
"folder_changed",
mlf_proxy_folder_changed,
mlf);
- camel_object_unref(folder->summary);
+ camel_object_unref((CamelObject *)folder->summary);
folder->summary = NULL;
- camel_object_unref(mlf->real_folder);
+ camel_object_unref((CamelObject *)mlf->real_folder);
mlf->real_folder = NULL;
- camel_object_unref(mlf->real_store);
+ camel_object_unref((CamelObject *)mlf->real_store);
mlf->real_store = NULL;
folder->permanent_flags = 0;
@@ -500,14 +502,14 @@ mlf_set_folder(MailLocalFolder *mlf, guint32 flags, CamelException *ex)
if (mlf->real_folder->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY) {
folder->summary = mlf->real_folder->summary;
- camel_object_ref(mlf->real_folder->summary);
+ camel_object_ref((CamelObject *)mlf->real_folder->summary);
}
folder->permanent_flags = mlf->real_folder->permanent_flags;
folder->folder_flags = mlf->real_folder->folder_flags;
- camel_object_hook_event(mlf->real_folder, "message_changed", mlf_proxy_message_changed, mlf);
- camel_object_hook_event(mlf->real_folder, "folder_changed", mlf_proxy_folder_changed, mlf);
+ camel_object_hook_event((CamelObject *)mlf->real_folder, "message_changed", mlf_proxy_message_changed, mlf);
+ camel_object_hook_event((CamelObject *)mlf->real_folder, "folder_changed", mlf_proxy_folder_changed, mlf);
return TRUE;
}
@@ -534,9 +536,9 @@ mlf_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
/* string to describe a local folder as the location of a message */
pathlen = strlen(evolution_dir) + strlen("local") + 1;
if (strlen(folder->full_name) > pathlen)
- mlf->description = g_strdup_printf(_("Local folders/%s"), folder->full_name+pathlen);
+ mlf->description = g_strdup_printf(U_("Local folders/%s"), folder->full_name+pathlen);
else
- mlf->description = g_strdup_printf(_("Local folders/%s"), folder->name);
+ mlf->description = g_strdup_printf(U_("Local folders/%s"), folder->name);
}
*arg->ca_str = mlf->description;
break;
@@ -620,28 +622,30 @@ mail_local_folder_get_type (void)
NULL,
mlf_init,
mlf_finalize);
- mlf_parent_class = (CamelFolderClass *)CAMEL_FOLDER_TYPE;
+ mlf_parent_class = (CamelFolderClass *)camel_type_get_global_classfuncs (CAMEL_FOLDER_TYPE);
}
return mail_local_folder_type;
}
static MailLocalFolder *
-mail_local_folder_construct(MailLocalFolder *mlf, MailLocalStore *parent_store, const char *full_name, CamelException *ex)
+mail_local_folder_construct(MailLocalFolder *mlf, MailLocalStore *parent_store, const char *full_name, CamelException *ex)
{
- char *metapath, *name;
+ const char *name;
+ char *metapath;
- name = g_path_get_basename (full_name);
- d(printf ("constructing local folder: full = %s, name = %s\n", full_name, name));
- camel_folder_construct (CAMEL_FOLDER (mlf), CAMEL_STORE (parent_store), full_name, name);
- g_free (name);
-
- mlf->real_path = g_strdup (((CamelFolder *) mlf)->full_name);
-
- metapath = g_strdup_printf ("%s/%s/local-metadata.xml", ((CamelService *) parent_store)->url->path, full_name);
- mlf->meta = load_metainfo (metapath);
- g_free (metapath);
+ name = g_basename (full_name);
+ d(printf("constructing local folder: full = %s, name = %s\n", full_name, name));
+
+ camel_folder_construct(CAMEL_FOLDER (mlf), CAMEL_STORE(parent_store), full_name, name);
+
+ mlf->real_path = g_strdup(((CamelFolder *)mlf)->full_name);
+
+ metapath = g_strdup_printf("%s/%s/local-metadata.xml", ((CamelService *)parent_store)->url->path, full_name);
+ mlf->meta = load_metainfo(metapath);
+ g_free(metapath);
+
return mlf;
}
@@ -736,7 +740,7 @@ mail_local_folder_reconfigure (MailLocalFolder *mlf, const char *new_format, int
camel_folder_expunge(fromfolder, ex);
d(printf("delete old mbox ...\n"));
- camel_object_unref(fromfolder);
+ camel_object_unref(CAMEL_OBJECT(fromfolder));
fromfolder = NULL;
camel_store_delete_folder(fromstore, tmpname, ex);
@@ -759,9 +763,9 @@ mail_local_folder_reconfigure (MailLocalFolder *mlf, const char *new_format, int
if (mlf->real_folder == NULL)
mlf_set_folder (mlf, CAMEL_STORE_FOLDER_CREATE, ex);
if (fromfolder)
- camel_object_unref(fromfolder);
+ camel_object_unref((CamelObject *)fromfolder);
if (fromstore)
- camel_object_unref(fromstore);
+ camel_object_unref((CamelObject *)fromstore);
g_free(tmpname);
g_free(mbox);
@@ -794,7 +798,7 @@ mls_get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelE
return NULL;
if (!mlf_set_folder(folder, flags, ex)) {
- camel_object_unref(folder);
+ camel_object_unref(CAMEL_OBJECT(folder));
return NULL;
}
@@ -802,8 +806,8 @@ mls_get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelE
if (save_metainfo(folder->meta) == FALSE) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot save folder metainfo to %s: %s"),
- folder->meta->path, g_strerror(errno));
- camel_object_unref(folder);
+ folder->meta->path, strerror(errno));
+ camel_object_unref(CAMEL_OBJECT (folder));
return NULL;
}
}
@@ -832,7 +836,7 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex
if (real_store == NULL) {
g_free(metapath);
free_metainfo(meta);
- camel_object_unref(real_store);
+ camel_object_unref((CamelObject *)real_store);
return;
}
@@ -843,7 +847,7 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex
camel_exception_xfer(ex, &local_ex);
g_free(metapath);
free_metainfo(meta);
- camel_object_unref(real_store);
+ camel_object_unref((CamelObject *)real_store);
return;
}
@@ -854,7 +858,7 @@ mls_delete_folder(CamelStore *store, const char *folder_name, CamelException *ex
if (unlink(metapath) == -1) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot delete folder metadata %s: %s"),
- metapath, g_strerror(errno));
+ metapath, strerror(errno));
}
g_free(metapath);
@@ -934,7 +938,7 @@ mls_rename_folder(CamelStore *store, const char *old_name, const char *new_name,
reninfo.new = info;
reninfo.old_base = (char *)old_name;
- camel_object_trigger_event(store, "folder_renamed", &reninfo);
+ camel_object_trigger_event((CamelObject *)store, "folder_renamed", &reninfo);
} else {
g_free(newuri);
g_warning("Cannot find existing folder '%s' in table?\n", olduri);
@@ -948,7 +952,7 @@ mls_rename_folder(CamelStore *store, const char *old_name, const char *new_name,
g_free(newname);
g_free(oldname);
- camel_object_unref(real_store);
+ camel_object_unref((CamelObject *)real_store);
free_metainfo(meta);
@@ -1060,7 +1064,7 @@ static void mail_local_store_add_folder(MailLocalStore *mls, const char *uri, co
if (info) {
/* FIXME: should copy info, so we dont get a removed while we're using it? */
- camel_object_trigger_event(mls, "folder_created", info);
+ camel_object_trigger_event((CamelObject *)mls, "folder_created", info);
/* this is just so the folder is opened at least once to setup the folder
counts etc in the display. Joy eh? The result is discarded. */
@@ -1095,7 +1099,7 @@ static void mail_local_store_remove_folder(MailLocalStore *mls, const char *path
LOCAL_STORE_UNLOCK(mls);
if (data.info) {
- camel_object_trigger_event(mls, "folder_deleted", data.info);
+ camel_object_trigger_event((CamelObject *)mls, "folder_deleted", data.info);
g_free(data.info->url);
g_free(data.info->full_name);
@@ -1191,7 +1195,7 @@ local_storage_new_folder_cb (EvolutionStorageListener *storage_listener,
info.unread_message_count = 0;
info.path = (char *)path;
- camel_object_trigger_event(global_local_store, "folder_created", &info);
+ camel_object_trigger_event((CamelObject *)global_local_store, "folder_created", &info);
g_free(info.url);
camel_url_free(url);
}
@@ -1232,19 +1236,18 @@ storage_listener_startup (EvolutionShellClient *shellclient)
corba_local_storage_listener = evolution_storage_listener_corba_objref (
local_storage_listener);
- /* FIXME: is this supposed to be destroy? */
- g_signal_connect(local_storage_listener,
- "destroyed",
- G_CALLBACK (local_storage_destroyed_cb),
- corba_storage);
- g_signal_connect(local_storage_listener,
- "new_folder",
- G_CALLBACK (local_storage_new_folder_cb),
- corba_storage);
- g_signal_connect(local_storage_listener,
- "removed_folder",
- G_CALLBACK (local_storage_removed_folder_cb),
- corba_storage);
+ gtk_signal_connect (GTK_OBJECT (local_storage_listener),
+ "destroyed",
+ GTK_SIGNAL_FUNC (local_storage_destroyed_cb),
+ corba_storage);
+ gtk_signal_connect (GTK_OBJECT (local_storage_listener),
+ "new_folder",
+ GTK_SIGNAL_FUNC (local_storage_new_folder_cb),
+ corba_storage);
+ gtk_signal_connect (GTK_OBJECT (local_storage_listener),
+ "removed_folder",
+ GTK_SIGNAL_FUNC (local_storage_removed_folder_cb),
+ corba_storage);
CORBA_exception_init (&ev);
GNOME_Evolution_Storage_addListener (corba_storage,
@@ -1345,15 +1348,11 @@ static void
reconfigure_folder_reconfigured (struct _mail_msg *mm)
{
struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm;
- GtkWidget *dialog;
/*char *uri;*/
if (camel_exception_is_set (&mm->ex)) {
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK, "%s",
- _("If you can no longer open this mailbox, then\n"
- "you may need to repair it manually."));
- gtk_dialog_run (GTK_DIALOG (dialog));
+ gnome_error_dialog (_("If you can no longer open this mailbox, then\n"
+ "you may need to repair it manually."));
}
if (m->done)
@@ -1374,7 +1373,7 @@ reconfigure_folder_free (struct _mail_msg *mm)
}
if (m->folder)
- camel_object_unref (m->folder);
+ camel_object_unref (CAMEL_OBJECT (m->folder));
g_free(m->uri);
g_free (m->newtype);
}
@@ -1387,15 +1386,13 @@ static struct _mail_msg_op reconfigure_folder_op = {
};
static void
-reconfigure_response(GtkDialog *dialog, int button, struct _reconfigure_msg *m)
+reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m)
{
- switch(button) {
- case GTK_RESPONSE_OK: {
+ if (button == 0) {
GtkWidget *menu, *item;
-
menu = gtk_option_menu_get_menu(m->optionlist);
item = gtk_menu_get_active(GTK_MENU(menu));
- m->newtype = g_strdup(g_object_get_data ((GObject *)item, "type"));
+ m->newtype = g_strdup(gtk_object_get_data((GtkObject *)item, "type"));
m->index_body = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m->check_index_body));
gtk_widget_set_sensitive (m->frame, FALSE);
@@ -1403,23 +1400,21 @@ reconfigure_response(GtkDialog *dialog, int button, struct _reconfigure_msg *m)
gtk_widget_set_sensitive (m->cancel, FALSE);
e_thread_put (mail_thread_queued, (EMsg *)m);
- break; }
- case GTK_RESPONSE_CANCEL:
- default:
+ } else {
if (m->done)
m->done(m->uri, NULL, m->done_data);
mail_msg_free ((struct _mail_msg *)m);
- break;
}
-
- gtk_widget_destroy((GtkWidget *)dialog);
+
+ if (button != -1)
+ gnome_dialog_close (dialog);
}
static void
reconfigure_got_folder(char *uri, CamelFolder *folder, void *data)
{
GladeXML *gui;
- GtkDialog *gd;
+ GnomeDialog *gd;
struct _reconfigure_msg *m = data;
char *title;
GList *p;
@@ -1448,8 +1443,8 @@ reconfigure_got_folder(char *uri, CamelFolder *folder, void *data)
return;
}
- gui = glade_xml_new (EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format", NULL);
- gd = (GtkDialog *)glade_xml_get_widget (gui, "dialog_format");
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format");
+ gd = (GnomeDialog *)glade_xml_get_widget (gui, "dialog_format");
title = g_strdup_printf (_("Reconfigure /%s"),
camel_folder_get_full_name (folder));
@@ -1465,34 +1460,34 @@ reconfigure_got_folder(char *uri, CamelFolder *folder, void *data)
m->newtype = NULL;
m->folder = folder;
camel_object_ref(folder);
-
+
/* dynamically create the folder type list from camel */
/* we assume the list is static and never freed */
currentformat = MAIL_LOCAL_FOLDER (folder)->meta->format;
- p = camel_session_list_providers (session, TRUE);
- menu = gtk_menu_new ();
+ p = camel_session_list_providers(session, TRUE);
+ menu = gtk_menu_new();
while (p) {
CamelProvider *cp = p->data;
-
+
/* we only want local providers */
if (cp->flags & CAMEL_PROVIDER_IS_LOCAL) {
GtkWidget *item;
char *label;
-
- if (!strcmp (cp->protocol, currentformat))
+
+ if (strcmp(cp->protocol, currentformat) == 0)
history = index;
-
+
label = g_strdup_printf("%s (%s)", cp->protocol, _(cp->name));
- item = gtk_menu_item_new_with_label (label);
- g_free (label);
- g_object_set_data ((GObject *) item, "type", cp->protocol);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ item = gtk_menu_item_new_with_label(label);
+ g_free(label);
+ gtk_object_set_data((GtkObject *)item, "type", cp->protocol);
+ gtk_widget_show(item);
+ gtk_menu_append(GTK_MENU(menu), item);
index++;
}
p = p->next;
}
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (m->optionlist));
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU(m->optionlist));
gtk_option_menu_set_menu (GTK_OPTION_MENU(m->optionlist), menu);
gtk_option_menu_set_history(GTK_OPTION_MENU(m->optionlist), history);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m->check_index_body), MAIL_LOCAL_FOLDER (folder)->meta->indexed);
@@ -1500,8 +1495,8 @@ reconfigure_got_folder(char *uri, CamelFolder *folder, void *data)
gtk_label_set_text ((GtkLabel *)glade_xml_get_widget (gui, "label_format"),
MAIL_LOCAL_FOLDER (folder)->meta->format);
- g_signal_connect(gd, "response", G_CALLBACK(reconfigure_response), m);
- g_object_unref(gui);
+ gtk_signal_connect (GTK_OBJECT (gd), "clicked", reconfigure_clicked, m);
+ gtk_object_unref (GTK_OBJECT (gui));
g_hash_table_insert (reconfigure_folder_hash, (gpointer) folder, (gpointer) gd);
@@ -1514,7 +1509,7 @@ mail_local_reconfigure_folder(const char *uri, void (*done)(const char *uri, Cam
struct _reconfigure_msg *m;
if (strncmp(uri, "file:", 5) != 0) {
- e_notice (NULL, GTK_MESSAGE_WARNING,
+ e_notice (NULL, GNOME_MESSAGE_BOX_WARNING,
_("You cannot change the format of a non-local folder."));
if (done)
done(uri, NULL, done_data);