<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
On 26/01/12 17:47, Jonathan Protzenko wrote:
<blockquote class=" cite" id="mid_4F2191A9_8090007_gmail_com"
cite="mid:4F2191A9.8090007@gmail.com" type="cite">On 01/26/2012
06:17 PM, David Bienvenu wrote:
<br>
<blockquote class=" cite" id="Cite_13" type="cite">On 1/26/2012
7:19 AM, Jonathan Protzenko wrote:
<br>
<blockquote class=" cite" id="Cite_14" type="cite">Hi everyone,
<br>
<br>
Ever since I started reading the mozilla.dev.apps.thunderbird
and mozilla.dev.extensions newsgroups, a recurring question
about Thunderbird has been "how can I modify the contents of a
message" from an addon? I recently (less than 7 days ago)
replied to this question twice, and my answer was basically:
<br>
- inject a message in a local folder,
<br>
- copy it to the destination folder,
<br>
- remove the old message.
<br>
<br>
I'm not sure there's a better way, but I guess not. My
question is: could we make that easier by implementing, say,
in C++, nsIMsgFolder::InjectMessageFromStream, making it of
course scriptable? The arguments are:
<br>
- this is something an addon will want to do, and it seems
legitimate that they should want to do so,
<br>
- it's better to provide a function for that than to have
someone do it real, real wrong.
<br>
</blockquote>
Yes, it would be great to provide an easy way for extensions to
do this, because extensions often forget about things like IMAP,
and going forward, things like pluggable stores.
<br>
<br>
I think JS code to do this would be better than c++ methods. I
think there's sufficient mechanisms in the backend to do this
already since detach attachment does it, but additional
method(s) would be helpful, we can add them.
<br>
</blockquote>
I'm not sure what is the right way to do this from JS. Do you have
some pseudo-code describing how one should proceed if they want to
modify, for instance, one of the headers? I somehow thought that
the code for detach was only calling nsMessenger::DetachAttachment
and that the rest of the process was driven from C++.
<br>
<br>
Thanks,
<br>
<br>
jonathan
<br>
</blockquote>
Jon, did you get my other email with the pseudo code?<br>
<br>
Let's say you create a new extended interface <tt><font
color="#ff0000">nsIMsgDBHdrWriteable</font></tt>. and add a
clone method to an email. The clone would be in memory until
finalized and stored.<br>
<br>
<tt>newmail = mail.<font color="#ff0000">clone</font>()<br>
hdr = newmail .QueryInterface(Ci.<font color="#ff0000">nsIMsgDBHdrWriteable</font>);<br>
msg.<font color="#ff0000">writeHeaderField</font>( 'Subject', "bla
bla");<br>
msg.<font color="#ff0000">resetHeaderField</font>('Author');<br>
msg.<font color="#ff0000">addHeaderField</font>('Author',author1);<br>
msg.<font color="#ff0000">addHeaderField</font>('Author',author2);<br>
</tt><tt>
newmail.<font color="#ff0000">finalize</font>(folder);</tt><br>
<tt>
newmail.<font color="#ff0000">store</font>();</tt><br>
<br>
something along these lines?<br>
Ax<br>
<br>
</body>
</html>