diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 16 | ||||
-rw-r--r-- | mail/component-factory.c | 30 | ||||
-rw-r--r-- | mail/folder-browser.c | 47 | ||||
-rw-r--r-- | mail/mail-tools.c | 42 | ||||
-rw-r--r-- | mail/mail-tools.h | 2 |
5 files changed, 69 insertions, 68 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 3f326d4dbe..0cf084d159 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,19 @@ +2001-11-08 Jeffrey Stedfast <fejj@ximian.com> + + * mail-tools.c (mail_tools_x_evolution_message_parse): Was + x_evolution_message_parse from folder-browser.c. A space char is + no longer used to separate the folder URI and the first uid, + instead this is now done with a nul-char so update to parse the + newer/better format. + + * component-factory.c (destination_folder_handle_drop): Update to + parse the new/better format. + + * folder-browser.c (x_evolution_message_parse): Moved to + mail-tools.c + (message_list_drag_data_get): Instead of placing a space char + after the folder URI, instead use a nul-char. + 2001-11-06 Jeffrey Stedfast <fejj@ximian.com> * mail-accounts.c (pgp_path_changed): Call diff --git a/mail/component-factory.c b/mail/component-factory.c index 9d501ba815..f77f76fa1b 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -623,34 +623,12 @@ destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *des camel_object_unref (CAMEL_OBJECT (folder)); break; case ACCEPTED_DND_TYPE_X_EVOLUTION_MESSAGE: - /* format: "uri uid1\0uid2\0uid3\0...\0uidn" */ + folder = mail_tools_x_evolution_message_parse (data->bytes._buffer, + data->bytes._length, + &uids); - in = data->bytes._buffer; - inend = in + data->bytes._length; - - inptr = strchr (in, ' '); - url = g_strndup (in, inptr - in); - - folder = mail_tool_uri_to_folder (url, 0, &ex); - g_free (url); - - if (!folder) { - camel_exception_clear (&ex); + if (!folder) return FALSE; - } - - /* split the uids */ - inptr++; - uids = g_ptr_array_new (); - while (inptr < inend) { - char *start = inptr; - - while (inptr < inend && *inptr) - inptr++; - - g_ptr_array_add (uids, g_strndup (start, inptr - start)); - inptr++; - } mail_transfer_messages (folder, uids, action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE, diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 0a06090adf..85e1bcd4fb 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -384,12 +384,12 @@ message_list_drag_data_get (ETree *tree, int row, ETreePath path, int col, { GByteArray *array; - /* format: "uri uid1\0uid2\0uid3\0...\0uidn" */ + /* 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); + g_byte_array_append (array, "", 1); /* write the uids */ for (i = 0; i < uids->len; i++) { @@ -451,43 +451,6 @@ message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex) camel_object_unref (CAMEL_OBJECT (mp)); } -static CamelFolder * -x_evolution_message_parse (char *in, unsigned int inlen, GPtrArray **uids) -{ - /* format: "uri uid1\0uid2\0uid3\0...\0uidn" */ - char *inptr, *inend, *uri; - CamelFolder *folder; - - if (in == NULL) - return NULL; - - inend = in + inlen; - - inptr = strchr (in, ' '); - uri = g_strndup (in, inptr - in); - - folder = mail_tool_uri_to_folder (uri, 0, NULL); - g_free (uri); - - if (!folder) - return NULL; - - /* split the uids */ - inptr++; - *uids = g_ptr_array_new (); - while (inptr < inend) { - char *start = inptr; - - while (inptr < inend && *inptr) - inptr++; - - g_ptr_array_add (*uids, g_strndup (start, inptr - start)); - inptr++; - } - - return folder; -} - static void message_list_drag_data_received (ETree *tree, int row, ETreePath path, int col, GdkDragContext *context, gint x, gint y, @@ -554,7 +517,7 @@ message_list_drag_data_received (ETree *tree, int row, ETreePath path, int col, camel_object_unref (CAMEL_OBJECT (stream)); break; case DND_TARGET_TYPE_X_EVOLUTION_MESSAGE: - folder = x_evolution_message_parse (selection_data->data, selection_data->length, &uids); + folder = mail_tools_x_evolution_message_parse (selection_data->data, selection_data->length, &uids); if (folder == NULL) goto fail; @@ -601,7 +564,7 @@ selection_get (GtkWidget *widget, GtkSelectionData *selection_data, bytes = fb->clipboard_selection; /* Note: source should == fb->folder, but we might as well use `source' instead of fb->folder */ - source = x_evolution_message_parse (bytes->data, bytes->len, &uids); + source = mail_tools_x_evolution_message_parse (bytes->data, bytes->len, &uids); if (source == NULL) return; @@ -666,7 +629,7 @@ selection_received (GtkWidget *widget, GtkSelectionData *selection_data, if (selection_data == NULL || selection_data->length == -1) return; - source = x_evolution_message_parse (selection_data->data, selection_data->length, &uids); + source = mail_tools_x_evolution_message_parse (selection_data->data, selection_data->length, &uids); if (source == NULL) return; diff --git a/mail/mail-tools.c b/mail/mail-tools.c index f403514c66..9d94fb1e78 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -396,3 +396,45 @@ mail_tool_forward_message (CamelMimeMessage *message, gboolean quoted) g_free (body); return ret; } + + +/** + * mail_tools_x_evolution_message_parse: + * @in: GtkSelectionData->data + * @inlen: GtkSelectionData->length + * @uids: pointer to a gptrarray that will be filled with uids on success + * + * Parses the GtkSelectionData and returns a CamelFolder and a list of + * UIDs specified by the selection. + **/ +CamelFolder * +mail_tools_x_evolution_message_parse (char *in, unsigned int inlen, GPtrArray **uids) +{ + /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn" */ + char *inptr, *inend; + CamelFolder *folder; + + if (in == NULL) + return NULL; + + folder = mail_tool_uri_to_folder (in, 0, NULL); + + if (!folder) + return NULL; + + /* split the uids */ + inend = in + inlen; + inptr = in + strlen (in) + 1; + *uids = g_ptr_array_new (); + while (inptr < inend) { + char *start = inptr; + + while (inptr < inend && *inptr) + inptr++; + + g_ptr_array_add (*uids, g_strndup (start, inptr - start)); + inptr++; + } + + return folder; +} diff --git a/mail/mail-tools.h b/mail/mail-tools.h index 2c94f09c0b..1414eec99f 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -81,4 +81,6 @@ gchar *mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...) gchar *mail_tool_forward_message (CamelMimeMessage *message, gboolean quoted); +CamelFolder *mail_tools_x_evolution_message_parse (char *in, unsigned int inlen, GPtrArray **uids); + #endif |