diff options
author | Not Zed <NotZed@Ximian.com> | 2004-05-17 11:50:56 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-05-17 11:50:56 +0800 |
commit | 81f6e6db484ce6978d9e69be9ee43200f612ef97 (patch) | |
tree | c402a25b13ab7a4521afcd93273833748297da9b /mail/em-utils.c | |
parent | 49686598a43ad861b6ab1cd1a550f124b5910500 (diff) | |
download | gsoc2013-evolution-81f6e6db484ce6978d9e69be9ee43200f612ef97.tar.gz gsoc2013-evolution-81f6e6db484ce6978d9e69be9ee43200f612ef97.tar.zst gsoc2013-evolution-81f6e6db484ce6978d9e69be9ee43200f612ef97.zip |
** Bug #6556.
2004-05-17 Not Zed <NotZed@Ximian.com>
** Bug #6556.
* message-list.c (ml_drop_async_desc, ml_drop_async_drop)
(ml_drop_async_done, ml_drop_async_free, ml_drag_data_action)
(ml_drop_popup_copy, ml_drop_popup_move, ml_drop_popup_cancel)
(ml_tree_drag_data_received): implement async drop operations and
the ask drop option menu.
2004-05-14 Not Zed <NotZed@Ximian.com>
** Bug #6556.
* message-list.c (ml_selection_received_uidlist): removed, not
needed anymore.
(ml_selection_received): call get_uidlist to paste the selection.
(ml_tree_drag_data_received): same here.
* em-folder-tree.c (emft_drop_uid_list): removed, not needed
because of below change.
* em-utils.c (em_utils_selection_get_uidlist): actually do the
copy now, don't just decode the data.
* em-folder-tree.c (tree_drag_data_received): just copy the
selection data data itself, dont decode yet.
(emft_import_message_rfc822): removed, not needed, use em utils
stuff instead.
(emft_drop_message_rfc822): same.
(emft_drop_text_uri_list): same.
(emft_drop_async_free): simply free stuff.
(emft_drop_async_drop): call em_utils stuff where they exist to do
the drop.
* message-list.c (ml_tree_drag_data_get): send x-mailbox instead
of message/rfc822 for the mailbox.
(ml_tree_drag_data_received): handle drop of x-mailbox differently
to message/rfc822.
(ml_tree_drag_motion): implement so proper options are setup
whilst dragging.
(message_list_construct): seutp the drag src/dest types for
changes typs and with ASK action.
* em-utils.c (em_utils_read_messages_from_stream): dont unref the
stream when we get it.
(em_utils_selection_get_mailbox): add an argument to scan from or
not, for message/rfc822 vs x-mailbox drops.
(em_utils_read_messages_from_stream): Same.
* em-folder-tree.c (tree_drag_motion): default to move properly.
* message-list.c (ml_selection_received_uidlist): take a move flag.
(ml_tree_drag_data_received): handle move action.
* em-folder-tree.c (em_folder_tree_new_with_model): got sick of
this bloody warning.
* em-format.c (default_headers[]): just remove x-mailer from the
header list, if it isn't on by default. This is the default list.
(em_format_default_headers): loop through everything.
svn path=/trunk/; revision=25915
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r-- | mail/em-utils.c | 103 |
1 files changed, 84 insertions, 19 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c index ca082a8423..e655b456c1 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -793,7 +793,6 @@ em_utils_read_messages_from_stream(CamelFolder *folder, CamelStream *stream) camel_mime_parser_scan_from(mp, TRUE); camel_mime_parser_init_with_stream(mp, stream); - camel_object_unref(stream); while (camel_mime_parser_step(mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM) { CamelMimeMessage *msg; @@ -872,6 +871,33 @@ em_utils_selection_get_mailbox(GtkSelectionData *data, CamelFolder *folder) } /** + * em_utils_selection_get_message: + * @data: + * @folder: + * + * get a message/rfc822 data. + **/ +void +em_utils_selection_get_message(GtkSelectionData *data, CamelFolder *folder) +{ + CamelStream *stream; + CamelException *ex; + CamelMimeMessage *msg; + + if (data->data == NULL || data->length == -1) + return; + + ex = camel_exception_new(); + stream = camel_stream_mem_new_with_buffer(data->data, data->length); + msg = camel_mime_message_new(); + if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) == 0) + camel_folder_append_message(folder, msg, NULL, NULL, ex); + camel_object_unref(msg); + camel_object_unref(stream); + camel_exception_free(ex); +} + +/** * em_utils_selection_set_uidlist: * @data: selection data * @uri: @@ -901,27 +927,22 @@ em_utils_selection_set_uidlist(GtkSelectionData *data, const char *uri, GPtrArra /** * em_utils_selection_get_uidlist: * @data: selection data - * @urip: Pointer to uri string, to be free'd by caller - * @uidsp: Pointer to an array of uid's. + * @move: do we delete the messages. * - * Convert an x-uid-list type to a uri and a uid list. + * Convert a uid list into a copy/move operation. * - * Return value: The number of uid's found. If 0, then @urip and - * @uidsp will be empty. + * Warning: Could take some time to run. **/ -int -em_utils_selection_get_uidlist(GtkSelectionData *data, char **urip, GPtrArray **uidsp) +void +em_utils_selection_get_uidlist(GtkSelectionData *data, CamelFolder *dest, int move, CamelException *ex) { /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn" */ char *inptr, *inend; GPtrArray *uids; - int res; - - *urip = NULL; - *uidsp = NULL; + CamelFolder *folder; if (data == NULL || data->data == NULL || data->length == -1) - return 0; + return; uids = g_ptr_array_new(); @@ -941,14 +962,16 @@ em_utils_selection_get_uidlist(GtkSelectionData *data, char **urip, GPtrArray ** if (uids->len == 0) { g_ptr_array_free(uids, TRUE); - res = 0; - } else { - *urip = g_strdup(data->data); - *uidsp = uids; - res = uids->len; + return; } - return res; + folder = mail_tool_uri_to_folder(data->data, 0, ex); + if (folder) { + camel_folder_transfer_messages_to(folder, uids, dest, NULL, move, ex); + camel_object_unref(folder); + } + + em_utils_uids_free(uids); } /** @@ -1011,6 +1034,48 @@ em_utils_selection_set_urilist(GtkSelectionData *data, CamelFolder *folder, GPtr } } +/** + * em_utils_selection_set_urilist: + * @data: + * @folder: + * @uids: + * + * Get the selection data @data from a uri list which points to a + * file, which is a berkely mailbox format mailbox. The file is + * automatically cleaned up when the application quits. + **/ +void +em_utils_selection_get_urilist(GtkSelectionData *data, CamelFolder *folder) +{ + CamelStream *stream; + CamelURL *url; + int fd, i, res = 0; + char *tmp, **uris; + + d(printf(" * drop uri list\n")); + + tmp = g_strndup(data->data, data->length); + uris = g_strsplit(tmp, "\n", 0); + g_free(tmp); + for (i=0;res == 0 && uris[i];i++) { + g_strstrip(uris[i]); + + url = camel_url_new(uris[i], NULL); + if (url == NULL) + continue; + + if (strcmp(url->protocol, "file") == 0 + && (fd = open(url->path, O_RDONLY)) != -1) { + stream = camel_stream_fs_new_with_fd(fd); + res = em_utils_read_messages_from_stream(folder, stream); + camel_object_unref(stream); + } + camel_url_free(url); + } + + g_strfreev(uris); +} + static void emu_save_part_done(CamelMimePart *part, char *name, int done, void *data) { |