Re: Calls to camel_mime_message_set_* to send mails
- From: Sergio Villar Senin <svillar igalia com>
- To: Philip Van Hoof <pvanhoof gnome org>
- Cc: Dirk-Jan Binnema nokia com, tinymail-devel-list gnome org
- Subject: Re: Calls to camel_mime_message_set_* to send mails
- Date: Fri, 03 Nov 2006 19:37:07 +0100
Philip Van Hoof wrote:
> On Thu, 2006-11-02 at 15:45 +0100, Sergio Villar Senin wrote:
>> Hi,
>>
>> I realized that when you're using tinymail with the camel backend, and
>> you want to send a message with tny_transport_account_send(), this
>> function does not call any of the camel_mime_message_set_* stuff. I know
>> that for example Evolution does it in the UI side (for example in the
>> e_msg_composer_hdrs_to_message_internal() call), but don't you think
>> that it would be very useful to have all these stuff inside
>> tny_camel_transport_account_send?
>>
>> I mean, the client of tny_transport_account_send could do it, but why
>> force it to fill both the TnyMessage and the CamelMimeMessage objects?
>
> Perhaps you are indeed right. I have not yet developed a lot on the
> sending of messages part of tinymail.
I was wrong though :). All these calls are currently in the code of
Tinymail. The problem was the next, TnyCamelMsg creates a
CamelMessageInfo when it's created and TnyCamelHeader could create
another different if you call any of the
tny_camel_header_set_(to,from...) methods without calling before
_tny_camel_header_set_camel_mime_message with the same object that is
referenced by TnyCamelMsg.
One possible fix is the attached patch. This patch just adds the call to
_tny_camel_header_set_camel_mime_message() inside the
tny_camel_msg_set_header() call. Note that if you're developing some app
with tinymail you must use the calls in a particular order. This is the
right one:
tny_msg_set_header (msg, header);
tny_header_set_from (header, from);
tny_header_set_to (header, to);
.....
because if you do:
tny_header_set_from (header, from);
tny_header_set_to (header, to);
....
tny_msg_set_header (msg, header);
then you'll loose all your sets to the header and get a funny warning:
g_warning ("Strange behaviour: Overwriting existing message info");
Br.
PD: the patch also includes a fix to a problem in the function
_foreach_email_add_to_inet_addr. If you call this function with a NULL
email argument then strtok_r will give you a very weird outcome.
Index: libtinymail-camel/tny-camel-common.c
===================================================================
--- libtinymail-camel/tny-camel-common.c (revision 1085)
+++ libtinymail-camel/tny-camel-common.c (working copy)
@@ -123,6 +123,9 @@
char *dup = g_strdup (emails);
char *tok, *save;
+ if (!emails)
+ return;
+
tok = strtok_r (dup, ",;", &save);
while (G_LIKELY (tok != NULL))
Index: libtinymail-camel/tny-camel-msg.c
===================================================================
--- libtinymail-camel/tny-camel-msg.c (revision 1085)
+++ libtinymail-camel/tny-camel-msg.c (working copy)
@@ -274,6 +274,7 @@
static void
tny_camel_msg_set_header (TnyMsg *self, TnyHeader *header)
{
+ TnyCamelMsg *msg;
TnyCamelMsgPriv *priv = TNY_CAMEL_MSG_GET_PRIVATE (self);
g_mutex_lock (priv->header_lock);
@@ -284,6 +285,10 @@
priv->header = header;
+ msg = _tny_camel_msg_get_camel_mime_message (TNY_CAMEL_MSG (self));
+ _tny_camel_header_set_camel_mime_message (TNY_CAMEL_HEADER (priv->header),
+ msg);
+
g_mutex_unlock (priv->header_lock);
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]