aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-06-16 03:34:54 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-06-16 03:34:54 +0800
commite088dbce225e56862a0076ed6465eb217a56a977 (patch)
treef9d9fca5398dd529295e7c0c189471c790f4c68d
parentb0bac93a1ef3963c1d432a06015e09e1042208d0 (diff)
downloadgsoc2013-evolution-e088dbce225e56862a0076ed6465eb217a56a977.tar
gsoc2013-evolution-e088dbce225e56862a0076ed6465eb217a56a977.tar.gz
gsoc2013-evolution-e088dbce225e56862a0076ed6465eb217a56a977.tar.bz2
gsoc2013-evolution-e088dbce225e56862a0076ed6465eb217a56a977.tar.lz
gsoc2013-evolution-e088dbce225e56862a0076ed6465eb217a56a977.tar.xz
gsoc2013-evolution-e088dbce225e56862a0076ed6465eb217a56a977.tar.zst
gsoc2013-evolution-e088dbce225e56862a0076ed6465eb217a56a977.zip
Fixed misuse of an uninitialized variable.
2001-06-15 Jeffrey Stedfast <fejj@ximian.com> * mail-ops.c (mail_send_message): Fixed misuse of an uninitialized variable. * component-factory.c (destination_folder_handle_drop): Implemented. * mail.h: Added prototype for evolution_folder_info_factory_init. * mail-ops.c (mail_do_transfer_messages): Now takes a const char* as the dest_uri. This works better all around since we strdup'd the string anyway. svn path=/trunk/; revision=10255
-rw-r--r--mail/ChangeLog13
-rw-r--r--mail/component-factory.c97
-rw-r--r--mail/mail-ops.c17
-rw-r--r--mail/mail-ops.h2
-rw-r--r--mail/mail.h3
5 files changed, 121 insertions, 11 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 672fb860fe..ceabc5f8a5 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,16 @@
+2001-06-15 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-ops.c (mail_send_message): Fixed misuse of an uninitialized
+ variable.
+
+ * component-factory.c (destination_folder_handle_drop): Implemented.
+
+ * mail.h: Added prototype for evolution_folder_info_factory_init.
+
+ * mail-ops.c (mail_do_transfer_messages): Now takes a const char*
+ as the dest_uri. This works better all around since we strdup'd
+ the string anyway.
+
2001-06-15 Dan Winship <danw@ximian.com>
* mail-format.c (mail_format_mime_message): We can't output
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 2ab6d7c825..a4b95c30aa 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -67,7 +67,8 @@ static BonoboGenericFactory *component_factory = NULL;
static GHashTable *storages_hash;
static char *accepted_dnd_types[] = {
- "message/rfc822",
+ "message/rfc822", /* if we drag from nautilus or something... */
+ "x-evolution-folder-dnd", /* if we drag from an evolution folder... */
NULL
};
@@ -273,6 +274,44 @@ destination_folder_handle_motion (EvolutionShellComponentDndDestinationFolder *f
return TRUE;
}
+static gboolean
+message_rfc822_dnd (CamelFolder *dest, CamelStream *stream)
+{
+ CamelMimeParser *mp;
+ CamelException *ex;
+
+ mp = camel_mime_parser_new ();
+ camel_mime_parser_scan_from (mp, TRUE);
+ camel_mime_parser_init_with_stream (mp, stream);
+
+ ex = camel_exception_new ();
+
+ 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, ex);
+ camel_exception_clear (ex);
+ camel_object_unref (CAMEL_OBJECT (msg));
+
+ /* skip over the FROM_END state */
+ camel_mime_parser_step (mp, 0, 0);
+ }
+
+ camel_object_unref (CAMEL_OBJECT (mp));
+ camel_exception_free (ex);
+
+ return TRUE;
+}
+
static CORBA_boolean
destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *folder,
const char *physical_uri,
@@ -281,14 +320,66 @@ destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *fol
const GNOME_Evolution_ShellComponentDnd_Data *data,
gpointer user_data)
{
- CamelStream *stream;
+ gboolean retval = FALSE;
if (action == GNOME_Evolution_ShellComponentDnd_ACTION_LINK)
return FALSE; /* we can't create links */
g_print ("in destination_folder_handle_drop (%s)\n", physical_uri);
- return TRUE;
+ if (data->format == 0) {
+ /* message/rfc822 */
+ CamelFolder *folder;
+ CamelStream *stream;
+
+ folder = mail_tool_uri_to_folder (physical_uri, NULL);
+ if (!folder)
+ 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);
+ camel_object_unref (CAMEL_OBJECT (stream));
+ } else {
+ /* x-evolution-dnd */
+ char *uri, *in, *inptr, *inend;
+ CamelFolder *source;
+ GPtrArray *uids;
+
+ /* format is "uri uid1\0uid2\0uid3\0...\0uidn" */
+
+ in = data->bytes._buffer;
+ inend = in + data->bytes._length;
+
+ inptr = strchr (in, ' ');
+ uri = g_strndup (data->bytes._buffer, inptr - in);
+ source = mail_tool_uri_to_folder (uri, NULL);
+ g_free (uri);
+
+ /* 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_do_transfer_messages (source, uids,
+ action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE,
+ physical_uri);
+ }
+
+ camel_object_unref (CAMEL_OBJECT (folder));
+
+ return retval;
}
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index de2a933249..f79857de69 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -501,7 +501,7 @@ mail_send_message(CamelMimeMessage *message, const char *destination, CamelFilte
/* Get information about the account this was composed by. */
acct_header = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Account"));
- if (header) {
+ if (acct_header) {
const MailConfigAccount *account;
account = mail_config_get_account_by_name (acct_header);
@@ -900,7 +900,8 @@ struct _transfer_msg {
char *dest_uri;
};
-static char *transfer_messages_desc(struct _mail_msg *mm, int done)
+static char *
+transfer_messages_desc (struct _mail_msg *mm, int done)
{
struct _transfer_msg *m = (struct _transfer_msg *)mm;
@@ -909,7 +910,8 @@ static char *transfer_messages_desc(struct _mail_msg *mm, int done)
}
-static void transfer_messages_transfer(struct _mail_msg *mm)
+static void
+transfer_messages_transfer (struct _mail_msg *mm)
{
struct _transfer_msg *m = (struct _transfer_msg *)mm;
CamelFolder *dest;
@@ -941,7 +943,8 @@ static void transfer_messages_transfer(struct _mail_msg *mm)
camel_object_unref((CamelObject *)dest);
}
-static void transfer_messages_free(struct _mail_msg *mm)
+static void
+transfer_messages_free (struct _mail_msg *mm)
{
struct _transfer_msg *m = (struct _transfer_msg *)mm;
int i;
@@ -964,14 +967,14 @@ static struct _mail_msg_op transfer_messages_op = {
void
mail_do_transfer_messages (CamelFolder *source, GPtrArray *uids,
gboolean delete_from_source,
- gchar *dest_uri)
+ const char *dest_uri)
{
struct _transfer_msg *m;
-
+
g_return_if_fail (CAMEL_IS_FOLDER (source));
g_return_if_fail (uids != NULL);
g_return_if_fail (dest_uri != NULL);
-
+
m = mail_msg_new(&transfer_messages_op, NULL, sizeof(*m));
m->source = source;
camel_object_ref((CamelObject *)source);
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 205684da94..078b684448 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -50,7 +50,7 @@ void mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMess
void mail_do_transfer_messages (CamelFolder *source, GPtrArray *uids,
gboolean delete_from_source,
- gchar *dest_uri);
+ const char *dest_uri);
/* get a single message, asynchronously */
void mail_get_message (CamelFolder *folder, const char *uid,
diff --git a/mail/mail.h b/mail/mail.h
index a024ff23e4..5c592a1263 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -72,3 +72,6 @@ void mail_hash_storage (CamelService *store, EvolutionStorage *storage);
EvolutionStorage *mail_lookup_storage (CamelStore *store);
void mail_storages_foreach (GHFunc func, gpointer data);
int mail_storages_count (void);
+
+
+void evolution_folder_info_factory_init (void);