aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorPeter Williams <peterw@src.gnome.org>2000-08-16 03:10:45 +0800
committerPeter Williams <peterw@src.gnome.org>2000-08-16 03:10:45 +0800
commite3b786b5cf25c44e31d21019e7805b7674a33967 (patch)
treef0078615d455a4c920ff16a7bcc1337aec5a3c23 /mail
parent8e32b41a50e99502fb22c26c0b5de575fecc99b4 (diff)
downloadgsoc2013-evolution-e3b786b5cf25c44e31d21019e7805b7674a33967.tar.gz
gsoc2013-evolution-e3b786b5cf25c44e31d21019e7805b7674a33967.tar.zst
gsoc2013-evolution-e3b786b5cf25c44e31d21019e7805b7674a33967.zip
Add support for copying messages
svn path=/trunk/; revision=4845
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog15
-rw-r--r--mail/folder-browser-factory.c1
-rw-r--r--mail/mail-callbacks.c26
-rw-r--r--mail/mail-ops.c114
-rw-r--r--mail/mail-ops.h5
-rw-r--r--mail/mail.h1
-rw-r--r--mail/message-list.c1
7 files changed, 112 insertions, 51 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 35d84a2406..d2c7de41ea 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,6 +1,19 @@
2000-08-15 Peter Williams <peterw@helixcode.com>
-
+
+ * mail-ops.c (transfer_messages): Generalize move_messages into
+ transfer_messages so that we can copy too.
+
+ * mail-ops.h: Prototype the new mail_do_transfer_messages.
+
+ * folder-browser-factory.c: Add a UI hook for copy_msg.
+
+ * mail-callbacks.c (transfer_msg): Generalize move so that it supports
+ copy as well, and add a callback 'copy_msg'.
+
+ * message-list.c (on_right_click): Add a right-click hook for Copy Message.
+
* session.c (mail_request_dialog): Don't deadlock when in main thread.
+
2000-08-14 Peter Williams <peterw@helixcode.com>
* mail-threads.c (show_error): Fix the error dialogs.
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index 602cff09b4..2c29d78f26 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -43,6 +43,7 @@ static GnomeUIInfo gnome_toolbar [] = {
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK (N_("Move"), N_("Move message to a new folder"), move_msg, GNOME_STOCK_PIXMAP_MAIL_SND),
+ GNOMEUIINFO_ITEM_STOCK (N_("Copy"), N_("Copy message to a new folder"), copy_msg, GNOME_STOCK_PIXMAP_MAIL_SND),
GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), print_msg, GNOME_STOCK_PIXMAP_PRINT),
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 7850f9826c..2156145d59 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -370,13 +370,14 @@ forward_msg (GtkWidget *widget, gpointer user_data)
composer);
}
-void
-move_msg (GtkWidget *widget, gpointer user_data)
+static void
+transfer_msg (GtkWidget *widget, gpointer user_data, gboolean delete_from_source)
{
FolderBrowser *fb = user_data;
MessageList *ml = fb->message_list;
GPtrArray *uids;
char *uri, *physical, *path;
+ char *desc;
const char *allowed_types[] = { "mail", NULL };
extern EvolutionShellClient *global_shell_client;
static char *last = NULL;
@@ -384,8 +385,13 @@ move_msg (GtkWidget *widget, gpointer user_data)
if (last == NULL)
last = g_strdup ("");
+ if (delete_from_source)
+ desc = _("Move message(s) to");
+ else
+ desc = _("Copy message(s) to");
+
evolution_shell_client_user_select_folder (global_shell_client,
- _("Move message(s) to"),
+ desc,
last, allowed_types, &uri, &physical);
if (!uri)
return;
@@ -399,7 +405,19 @@ move_msg (GtkWidget *widget, gpointer user_data)
uids = g_ptr_array_new ();
message_list_foreach (ml, enumerate_msg, uids);
- mail_do_refile_messages (ml->folder, uids, physical);
+ mail_do_transfer_messages (ml->folder, uids, delete_from_source, physical);
+}
+
+void
+move_msg (GtkWidget *widget, gpointer user_data)
+{
+ transfer_msg (widget, user_data, TRUE);
+}
+
+void
+copy_msg (GtkWidget *widget, gpointer user_data)
+{
+ transfer_msg (widget, user_data, FALSE);
}
void
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 3262237e13..1996d12bc2 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -452,62 +452,78 @@ mail_do_expunge_folder (CamelFolder *folder)
mail_operation_queue (&op_expunge_folder, folder, FALSE);
}
-/* ** REFILE MESSAGES ***************************************************** */
+/* ** TRANSFER MESSAGES **************************************************** */
-typedef struct refile_messages_input_s
+typedef struct transfer_messages_input_s
{
CamelFolder *source;
GPtrArray *uids;
+ gboolean delete_from_source;
gchar *dest_uri;
}
-refile_messages_input_t;
+transfer_messages_input_t;
-static gchar *describe_refile_messages (gpointer in_data, gboolean gerund);
-static void setup_refile_messages (gpointer in_data, gpointer op_data,
+static gchar *describe_transfer_messages (gpointer in_data, gboolean gerund);
+static void setup_transfer_messages (gpointer in_data, gpointer op_data,
CamelException *ex);
-static void do_refile_messages (gpointer in_data, gpointer op_data,
+static void do_transfer_messages (gpointer in_data, gpointer op_data,
CamelException *ex);
-static void cleanup_refile_messages (gpointer in_data, gpointer op_data,
+static void cleanup_transfer_messages (gpointer in_data, gpointer op_data,
CamelException *ex);
static gchar *
-describe_refile_messages (gpointer in_data, gboolean gerund)
+describe_transfer_messages (gpointer in_data, gboolean gerund)
{
- refile_messages_input_t *input = (refile_messages_input_t *) in_data;
+ transfer_messages_input_t *input = (transfer_messages_input_t *) in_data;
+ char *format;
+
+ if (gerund) {
+ if (input->delete_from_source)
+ format = "Moving messages from \"%s\" into \"%s\"";
+ else
+ format = "Copying messages from \"%s\" into \"%s\"";
+ } else {
+ if (input->delete_from_source)
+ format = "Move messages from \"%s\" into \"%s\"";
+ else
+ format = "Copy messages from \"%s\" into \"%s\"";
+ }
- if (gerund)
- return
- g_strdup_printf
- ("Moving messages from \"%s\" into \"%s\"",
- mail_tool_get_folder_name (input->source), input->dest_uri);
- else
- return
- g_strdup_printf
- ("Move messages from \"%s\" into \"%s\"",
- mail_tool_get_folder_name (input->source), input->dest_uri);
+ return g_strdup_printf (format,
+ mail_tool_get_folder_name (input->source),
+ input->dest_uri);
}
static void
-setup_refile_messages (gpointer in_data, gpointer op_data,
+setup_transfer_messages (gpointer in_data, gpointer op_data,
CamelException *ex)
{
- refile_messages_input_t *input = (refile_messages_input_t *) in_data;
+ transfer_messages_input_t *input = (transfer_messages_input_t *) in_data;
+ char *verb;
+
+ if (input->delete_from_source)
+ verb = "move";
+ else
+ verb = "copy";
if (!CAMEL_IS_FOLDER (input->source)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
- "No source folder to refile messages from specified.");
+ camel_exception_setv (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No source folder to %s messages from specified.",
+ verb);
return;
}
if (input->uids == NULL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
- "No messages to refile have been specified.");
+ camel_exception_setv (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No messages to %s have been specified.",
+ verb);
return;
}
if (input->dest_uri == NULL) {
- camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
- "No URI to refile to has been specified.");
+ camel_exception_setv (ex, CAMEL_EXCEPTION_INVALID_PARAM,
+ "No URI to %s to has been specified.",
+ verb);
return;
}
@@ -515,11 +531,19 @@ setup_refile_messages (gpointer in_data, gpointer op_data,
}
static void
-do_refile_messages (gpointer in_data, gpointer op_data, CamelException *ex)
+do_transfer_messages (gpointer in_data, gpointer op_data, CamelException *ex)
{
- refile_messages_input_t *input = (refile_messages_input_t *) in_data;
+ transfer_messages_input_t *input = (transfer_messages_input_t *) in_data;
CamelFolder *dest;
gint i;
+ void (*func) (CamelFolder *, const char *,
+ CamelFolder *,
+ CamelException *);
+
+ if (input->delete_from_source)
+ func = camel_folder_move_message_to;
+ else
+ func = camel_folder_copy_message_to;
dest = mail_tool_uri_to_folder (input->dest_uri, ex);
if (camel_exception_is_set (ex))
@@ -530,9 +554,9 @@ do_refile_messages (gpointer in_data, gpointer op_data, CamelException *ex)
camel_folder_freeze (dest);
for (i = 0; i < input->uids->len; i++) {
- camel_folder_move_message_to (input->source,
- input->uids->pdata[i], dest,
- ex);
+ (func) (input->source,
+ input->uids->pdata[i], dest,
+ ex);
g_free (input->uids->pdata[i]);
if (camel_exception_is_set (ex))
break;
@@ -545,36 +569,38 @@ do_refile_messages (gpointer in_data, gpointer op_data, CamelException *ex)
}
static void
-cleanup_refile_messages (gpointer in_data, gpointer op_data,
+cleanup_transfer_messages (gpointer in_data, gpointer op_data,
CamelException *ex)
{
- refile_messages_input_t *input = (refile_messages_input_t *) in_data;
+ transfer_messages_input_t *input = (transfer_messages_input_t *) in_data;
camel_object_unref (CAMEL_OBJECT (input->source));
g_free (input->dest_uri);
g_ptr_array_free (input->uids, TRUE);
}
-static const mail_operation_spec op_refile_messages = {
- describe_refile_messages,
+static const mail_operation_spec op_transfer_messages = {
+ describe_transfer_messages,
0,
- setup_refile_messages,
- do_refile_messages,
- cleanup_refile_messages
+ setup_transfer_messages,
+ do_transfer_messages,
+ cleanup_transfer_messages
};
void
-mail_do_refile_messages (CamelFolder *source, GPtrArray *uids,
- gchar *dest_uri)
+mail_do_transfer_messages (CamelFolder *source, GPtrArray *uids,
+ gboolean delete_from_source,
+ gchar *dest_uri)
{
- refile_messages_input_t *input;
+ transfer_messages_input_t *input;
- input = g_new (refile_messages_input_t, 1);
+ input = g_new (transfer_messages_input_t, 1);
input->source = source;
input->uids = uids;
+ input->delete_from_source = delete_from_source;
input->dest_uri = g_strdup (dest_uri);
- mail_operation_queue (&op_refile_messages, input, TRUE);
+ mail_operation_queue (&op_transfer_messages, input, TRUE);
}
/* ** FLAG MESSAGES ******************************************************* */
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 77c82f19dc..3566c40116 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -39,8 +39,9 @@ void mail_do_send_mail (const char *xport_uri,
guint32 done_flags, GtkWidget *composer);
void mail_do_expunge_folder (CamelFolder *folder);
-void mail_do_refile_messages (CamelFolder *source, GPtrArray *uids,
- gchar *dest_uri);
+void mail_do_transfer_messages (CamelFolder *source, GPtrArray *uids,
+ gboolean delete_from_source,
+ gchar *dest_uri);
void mail_do_flag_messages (CamelFolder *source, GPtrArray *uids,
gboolean invert,
guint32 mask, guint32 set);
diff --git a/mail/mail.h b/mail/mail.h
index 48c7defcb0..03045e1075 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -61,6 +61,7 @@ void reply_to_sender (GtkWidget *widget, gpointer user_data);
void reply_to_all (GtkWidget *widget, gpointer user_data);
void delete_msg (GtkWidget *widget, gpointer user_data);
void move_msg (GtkWidget *widget, gpointer user_data);
+void copy_msg (GtkWidget *widget, gpointer user_data);
void print_msg (GtkWidget *widget, gpointer user_data);
void edit_msg (GtkWidget *widget, gpointer user_data);
void view_msg (GtkWidget *widget, gpointer user_data);
diff --git a/mail/message-list.c b/mail/message-list.c
index 6cbff44481..7e00d0ac14 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -1035,6 +1035,7 @@ on_right_click (ETableScrolled *table, gint row, gint col, GdkEvent *event, Mess
{ "", NULL, GTK_SIGNAL_FUNC (NULL), 0 },
{ "Delete Message", NULL, GTK_SIGNAL_FUNC (delete_msg), 0 },
{ "Move Message", NULL, GTK_SIGNAL_FUNC (move_msg), 0 },
+ { "Copy Message", NULL, GTK_SIGNAL_FUNC (copy_msg), 0 },
{ "", NULL, GTK_SIGNAL_FUNC (NULL), 0 },
{ "VFolder on Subject", NULL, GTK_SIGNAL_FUNC (vfolder_subject), 2 },
{ "VFolder on Sender", NULL, GTK_SIGNAL_FUNC (vfolder_sender), 2 },