My second blog - mozilla2014-05-02T20:53:24+02:00urn:md5:a212d8d3f8ae72ec23761ea75660cf35DotclearShutting down my (now redundant) comm-central clone on githuburn:md5:9697ea99040ee364bb36a3404a0a489b2014-04-20T19:51:00+02:002014-05-02T21:51:36+02:00Jonathan Protzenkomozilla <p>This is just a public service announcement: I'm shutting down the <a href="https://github.com/protz/comm-central">comm-central repository on github</a> I've been maintaining since 2011. Please use <a href="https://github.com/mozilla/releases-comm-central/">the official version</a>: <em>they share the same hashes</em> so it's just a matter of modifying the url in your .git/config. Plus, the official repo has all the cool tags baked in.</p>
<p>(Turns out that due to yet-another hg repository corruption, the repo has been broken since early March. Since no one complained, I suspect no one's really using this anymore. I'm pretty sure the folks at Mozilla are much better at avoiding hg repository corruptions than I am, so here's the end of it!).</p>Freedom of speech in the Mozilla Communityurn:md5:14030c7ea8ce2ec89359e768d9ff28742014-04-04T14:55:00+02:002014-04-06T22:25:41+02:00Jonathan Protzenkomozilla <p>I read this morning Andrew Truong's blog on planet:</p>
<blockquote><p>I guess it's okay to speak out about how we truly feel when somebody resigns over a controversial topic but not to speak out during the controversy? We should ALWAYS speak out. Freedom of Speech.</p></blockquote>
<p>The reason why I didn't speak up is, just like many other Mozillians I suspect, for fear of retribution. Seeing the attacks perpetrated on Brendan, a well-respected member of the Mozilla community, I can only imagine the torrent of hatemail that I'm going to get for publishing this blog post. (<strong>Update:</strong> so far, I didn't get any hatemail. It seems like the fears were unjustified.) The other reason is, I didn't want to further encourage a debate which I hoped would fade off after a few days. I somehow hoped we could go back to "business as usual". We were unable to, and thus I see no reason to hold back this blog post anymore.</p>
<p>I live in Europe. We tend to have a different opinion on these matters. But in any case, before you go any further down, I should just mention that I do support the right for anyone to marry the one they love, and I voted according to that belief for the last few elections in my country. I am a straight person, though.</p>
<p>I'm going to quote a few blog posts that resonate with me, and add a few comments.</p>
<p>Daniel wrote:</p>
<blockquote><p>Who said "Mozilla Community"? Who said Openness? Pfffff. I've been a Mozillian for fourteen years and I'm not even sure I still recognize myself in today's Mozilla Community. Well done guys, well done. What's the next step? 100% political correctness? Is it still possible to have a legally valid personal opinion while being at Mozilla and express it in public?</p></blockquote>
<p>From private conversations I had with other (mostly European) Mozillians, I know for certain that people have opinions that they are afraid to express in the Mozilla Community. Some people are religious, and will take great care _not_ to reveal that fact. Some people may have other beliefs that do not align with the dominant, Silicon-Valley progressive ideology. They also make sure that these are not apparent. Andrew Truong mentions freedom of speech. I believe there is freedom of speech in the Mozilla community as long as you happen to have the right opinions.</p>
<p>In my personal case, I fortunately happen to side with the prevalent ideology for most points, but I am now very afraid of slipping and expressing an opinion that is not considered progressive enough. I am now afraid of what is going to happen to me then: will I be kicked out? Will people call out for my name being removed from about:credits? Will people call on Twitter for my being ousted from Mozillians.org?</p>
<p>Ben Moskowitz wrote:</p>
<blockquote><p>For the record, I don’t believe Brendan Eich is a bigot. He’s stubborn, not hateful. He has an opinion. It’s certainly not my opinion, but it was the opinion of 52% of people who voted on Prop 8 just six years ago, and the world is changing fast.</p></blockquote>
<p>Again, my European point of view on the matter is simple: I interact in my daily life with many people who do not support same-sex marriage. I'm pretty sure some bosses up my hierarchy do not support that. I believe that, ultimately, there will be less and less such people, and that society will change enough that being against same-sex marriage will be a thing of the past. I also believe that as long as my bosses do their jobs, I'm fine with that. I do not care about the personal life of my president; I just care for him to run the country according to the values that his party adheres to. Same thing goes for Brendan.</p>
<p>Christie, who in a much better position that I am to speak about that, says:</p>
<blockquote><p>Certainly it would be problematic if Brendan’s behavior within Mozilla was explicitly discriminatory, or implicitly so in the form of repeated microagressions. I haven’t personally seen this (although to be clear, I was not part of Brendan’s reporting structure until today). To the contrary, over the years I have watched Brendan be an ally in many areas and bring clarity and leadership when needed. Furthermore, I trust the oversight Mozilla has in place in the form of our chairperson, Mitchell Baker, and our board of directors.</p></blockquote>
<p>The way people demanded a public apology reminded me of the glorious times of Soviet Russia and Communist China. What next? Should Brendan be photoshopped out of all the pictures? If we leave the matter as is, the only reasonable thing left to do is to add an extra round of interviews when hiring people: the political interview. There, we should make sure that the people we hire share the "right" political opinion. Otherwise, it seems like they is no space for them in the Mozilla Community.</p>
<p>Andrew Sullivan wrote:</p>
<blockquote><p>If this is the gay rights movement today – hounding our opponents with a fanaticism more like the religious right than anyone else – then count me out. If we are about intimidating the free speech of others, we are no better than the anti-gay bullies who came before us.</p></blockquote>
<p>While being a strong supporter of the movement, I really feel sad today: what legitimacy is there now for people who've been dragging through the mud an opponent, instead of treating them like a decent, human being? Is this what Mozilla is about?</p>
<p>(Comments are disabled on this post.)</p>So I figured out I should try out the Addon SDKurn:md5:28f4006e0b60ea2e7ffbc92309fa86bb2012-12-24T17:41:00+01:002012-12-25T23:33:49+01:00Jonathan Protzenkomozilla <p>So I figured out I should try out the Addon SDK. Jeff Griffiths and Erik Vold finally convinced me at the latest MozCamp that it was worth a try, so for my latest project (a lightweight revival of FireGPG), I decided to go the Addon SDK route. I'm a Thunderbird addons developer, so although I'm very familiar with all the Gecko and Thunderbird parts, I'm not familiar with Firefox-specific extensions. I thought the Addon SDK would save me the trouble of finding out which parts of the UI to overlay, and so on.</p>
<p>The short version is that it's been a very pleasant experience, and I believe it did save me a lot of time, but some of the shortcomings of the Addon SDK are really frustrating. Don't get me wrong: all in all, I believe it's an amazing experience for a newcomer, and I'm sure it's made developing addons much easier and much more fun than it used to be a few years ago.</p>
<p>The good parts:</p>
<ul>
<li>having well-written documentation is... quite a shocking experience for someone who's used to developing Thunderbird addons; what a joy!</li>
<li>the tutorial and the various guides are well-written all throughout,</li>
<li>there's an easy escape door as soon as you want to do something for which there is no API: <code>require("chrome")</code>,</li>
<li>converting a JSM module (the <code>ipccode</code> library in my case) into a RequireJS-style module was really seamless,</li>
<li>the <code>cfx</code> utility is really great for launching a Firefox with a fresh profile and the addon pre-installed; I could do it before with shell scripts, but having it all integrated is really life-changing!</li>
</ul>
<p>The weird parts:</p>
<ul>
<li>figuring out the two-way communication dance between content side and add-on side is quite strange for someone who's not used to it,</li>
<li>it took me a short while to understand that as soon as I wanted to manipulate a page's contents, I had to do it through a content script,</li>
<li>it feels weird to create a new file (<code>contentScriptFile</code>) just for a dozen lines,</li>
<li>the creation of workers and the message passing is slow: I can feel the various steps taking place; also, I'm unsure about the performance hit of creating so many workers all of the time;</li>
<li>the final XPI ends up being around 200kB -- so much for just a few dozen lines of code?</li>
<li>there's no clear explanation on how one is supposed to do two-way communication: should I used <code>tab.attach</code>, a <code>page-mod</code>, the worker that's created when using <code>context-menu</code>? The tutorials aren't well decided on whether to advertise <code>port</code>-style or <code>postMessage</code>-style communications, which adds to the confusion;</li>
<li>I don't want to source <code>bin/activate</code> as it messes up my <code>PS1</code>; does it do anything useful besides changing the <code>PATH</code>?</li>
<li><code>cfx</code> warned me about <code>mozrunner</code> being installed system-wide (I do use <code>mozregression</code>), but I couldn't tell if that was a severe problem or not.</li>
</ul>
<p>The frustrating parts:</p>
<ul>
<li>I cannot localize the attributes in my HTML file: the <code>placeholder</code> attribute of my <code>&lt;input&gt;</code> field and the <code>value</code> attribute of my <code>button</code> will remain in English...</li>
<li>I wanted to do a two-way communication between add-on side and content-side starting from a right-click event, and it tooks me three hours to figure out how to do so -- I guess I was just confused by the variety of options;</li>
<li>I'm stuck because the <code>context-menu</code> module won't work in GMail's composition area.</li>
</ul>
<p>For the last three items, bugs have been filed (respectively <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=824489">bug 824489</a>, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=824348">bug 824348</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=824482">bug 824482</a>). I'm really hoping for the latter to be fixed, since it basically makes half of my addon useless. In the event that no one has the time to fix it, I'll probably have to rewrite the addon to not use the SDK.</p>
<p>I would like to thank KWierso for his help in #jetpack, he was instrumental in achieving what I wanted to do. My warmest congratulations to the Addon SDK team for making the addon landscape usable, and my best encouragements for fixing the various shortcomings!</p>
<p>PS: for the curious, the code lives on <a href="https://github.com/protz/gpgfox">GitHub</a>.</p>Leveraging pdf.js in Thunderbirdurn:md5:b1bede4db1dcf4db94580507bafda1232011-12-03T23:54:00+01:002011-12-03T23:54:19+01:00Jonathan Protzenkomozilla <p><a href="https://addons.mozilla.org/en-US/thunderbird/addon/54035/">Thunderbird Conversations 2.2.1</a> has been released.</p>
<p><img src="http://blog.xulforum.org/public/Selection_023.png" alt="Open this PDF in a new tab" style="display:block; margin:0 auto;" title="Open this PDF in a new tab, Dec 2011" /></p>
<p>You can now view PDF attachments inside Thunderbird using pdf.js! You don't need an external viewer anymore. That's the pdf.js magic.</p>
<p><a href="http://blog.xulforum.org/public/Daily_019.png" title="PDF Viewer"><img src="http://blog.xulforum.org/public/.Daily_019_m.jpg" alt="PDF Viewer" style="display:block; margin:0 auto;" title="PDF Viewer, Dec 2011" /></a></p>
<p>Clicking the icon opens a new tab with a mini-viewer (very basic functionality). It works pretty well, and the plan is to add a viewer inside the conversation, so that you can get some sort of inline pdf viewer, just below the email. That's a reasonably sized chunk of work, but I'm really busy right now, so it's not going to happen anytime soon; therefore, anyone coming with a patch would be extremely well-received :).</p>MozCamp 2011 demo addonsurn:md5:1dcc4847c20da7faf6096db7e33852962011-11-12T09:28:00+01:002011-11-12T16:16:51+01:00Jonathan Protzenkomozilla <p><strong>EDIT</strong>: the slides are available at <a href="http://www.xulforum.org/mozcamp2011/presentation/" hreflang="en">http://www.xulforum.org/mozcamp2011/presentation/</a></p>
<p>I'm just writing it down so that it's easy for other people to find it. Here are the demo addons for my MozCamp talk this afternoon.</p>
<p><a href="http://www.xulforum.org/mozcamp2011/" hreflang="en">http://www.xulforum.org/mozcamp2011/</a></p>
<ul>
<li>Right-click, save link as.</li>
<li>In Thunderbird, Tools &gt; Add-ons</li>
<li>Wrench menu (next to the search field, top right), Install add-on from file</li>
<li>Restart</li>
</ul>
<p>Both add a new button to the main toolbar so <strong>you need to right-click the main toolbar and hit customize</strong>.</p>Git mirror of comm-centralurn:md5:28b0d5b2f9dd3ed2f3d6bee568ddfe0d2011-09-19T10:29:00+02:002011-09-19T10:29:00+02:00Jonathan Protzenkomozilla <p>Mozilla is the only project where I use hg, and because I'm more comfortable with git, I decided to follow <a href="http://www.bluishcoder.co.nz/2011/02/10/git-conversion-of-mozilla-central.html">Chris Double's instructions</a> and create a git mirror of comm-central. It now lives at <a href="https://github.com/protz/comm-central">https://github.com/protz/comm-central</a>. It will be updated regularly.</p>Restartless addons for Thunderbird Conversationsurn:md5:5836e9f01198e61799f92740b043b0862011-09-11T17:27:00+02:002011-09-11T17:27:00+02:00Jonathan Protzenkomozilla <p><a href="http://blog.xulforum.org/public/Selection_013.jpeg" title="OEmbed addon"><img src="http://blog.xulforum.org/public/.Selection_013_m.jpg" alt="OEmbed addon" style="display:block; margin:0 auto;" title="OEmbed addon, Sep 2011" /></a></p>
<p>Thunderbird Conversations can now have its own addons! I just created a sample plugin for Conversations that uses <a href="http://oembed.com/" hreflang="en">oembed</a> to analyze links to Flickr in emails. Once it's found a link, it displays a small version of the image below the email, with the title of the picture and its author. You can click the picture to open the original link to Flickr in a new tab. I packaged this plugin as a Thunderbird addon.</p>
<p>The good thing is <strong>this addon is restartless</strong>! As always, it's been a little bit of a fight to get it to work (I ♥ you restartless), but I managed to get it right. Enough talk, <a href="http://jonathan.xulforum.org/files/oembed.xpi" hreflang="en">download it now</a>.</p>
<p>Some remarks:</p>
<ul>
<li>this addon of course requires Thunderbird Conversations to be installed first,</li>
<li>this addon uses the <a href="http://blog.xulforum.org/index.php?post/2010/11/27/Thunderbird-Conversations-plugins" hreflang="en">plugin infrastructure</a> I described earlier,</li>
<li>it will not uninstall properly: there was no support for removing a plugin in Conversations, I just added support for that in the trunk version of Conversations,</li>
<li>I will not support this in any way. This is a proof of concept, and I'd love to see other people pick up the project, enhance it, and come up with new ideas in creative ways.</li>
<li>the source lives <a href="https://github.com/protz/GMail-Conversation-View/tree/master/other/oembed-addon" hreflang="en">on GitHub</a> if you want to fork it!</li>
</ul>
<p>Comments are welcome!</p>Collecting telemetry data for Thunderbirdurn:md5:b2e6c27af1b67af623869e8322ccf5492011-08-23T20:25:00+02:002011-08-23T20:25:00+02:00Jonathan Protzenkomozilla <p>To all of our testing community: we are now trying to gather anonymous performance data on Thunderbird, using the Telemetry infrastructure that the Firefox folks have so kindly pioneered. I've <a href="https://mail.mozilla.org/pipermail/tb-planning/2011-August/001322.html">written about that</a> on tb-planning, but in short: please hit <code>Preferences &gt; Advanced &gt; General &gt; Config Editor</code> and set <code>toolkit.telemetry.enabled</code> to <code>true</code>. Thanks!</p>Dealing with usersurn:md5:5e039770d7e66ee5fc299d48377c80cb2011-08-18T19:59:00+02:002011-08-19T04:06:48+02:00Jonathan Protzenkomozilla <p><a href="http://mozillalabs.com/messaging/2010/12/07/announcing-thunderbird-conversations/">Thunderbird Conversations</a> now has more than 50000 users, and with users, comes a lot of feedback. Right now, too much of the feedback goes like this:</p>
<p><q>Hi, I installed Thunderbird Conversations, but it doesn't take into account option X, which is really vital (usually all caps here) for any sane user / which sucks and I'm going to uninstall this piece of shit / which makes your addon useless / etc. etc. <em>Optional:</em> what in your right mind did you think? <em>Frequent:</em> if you don't fix this, I'm going to uninstall the addon!</q></p>
<p>Option X is usually one very, very specific option that I believe is used by a minority of users: detach or delete attachment, download headers only (allegedly for “security reasons"), put sent messages in the folder of the message being replied to. I wasn't even aware of the existence of such options. Even if these were heavily used, <strong>I'm not trying to replicate every single option Thunderbird has</strong>. If I did, I would end up... reimplementing Thunderbird, except there would be a conversation view. What's the point? If I were to offer all these options, Thunderbird Conversations would become a bloated mess of options with a UI that's cluttered with all these extra actions that seem to be so vital. These users would be happy, but that's not the Thunderbird I'm dreaming of.</p>
<p><strong>I'm trying to offer a new, more efficient, simpler, leaner way to read and reply to your emails.</strong> I'm already reimplementing a significant chunk of Thunderbird (I'm just re-doing entirely message display and message composition, mind you), and there's no way I can take into account all these options without becoming crazy. And I'm the only person working on this, to boot.</p>
<p>How can I make it clearer that <strong>my goal is not and never will be to reimplement every single Thunderbird feature</strong>? How can I tell people that yes, their favorite option that apparently their life depends on will not be implemented and that's just the way it is, they don't have to spam every other communication channel to insult me, write a super negative review on AMO, and encourage other users not to touch, and I'm quoting “this piece of $*§$%#”?</p>
<p>They just have to uninstall the addon.</p>Personas in Thunderbirdurn:md5:1ae65da9e256b8e6fb232a79a6a7e4242011-08-15T19:48:00+02:002011-08-15T19:48:00+02:00Jonathan Protzenkomozilla <p>There does not seem to be an easy way to set your Thunderbird to use a persona, so until we make it more discoverable in the UI, here's a snippet you can copy and paste in your error console (Tools &gt; Error Console) to <strong>make your Thunderbird use a nice Persona!</strong> Just copy the line below in Tools &gt; Error Console, and hit Enter. This will open a new tab allowing you to navigate getpersonas.com.</p>
<p><code>top.opener.document.getElementById("tabmail").openTab("contentTab", { contentPage: "https://www.getpersonas.com" });</code></p>MimeMessage API updateurn:md5:3dbe33f809c7305b0f399cab7c0aaf9a2011-08-10T20:42:00+02:002011-08-10T20:42:00+02:00Jonathan Protzenkomozilla <p>This is just a quick update to let all Thunderbird extension developers know that I've landed a series of improvements to the MimeMessage API. These improvements will be available in Thunderbird 8.</p>
<p><a href="http://blog.xulforum.org/public/Selection_016.png" title="MimeMessage updated API"><img src="http://blog.xulforum.org/public/.Selection_016_m.jpg" alt="MimeMessage updated API" style="display:block; margin:0 auto;" title="MimeMessage updated API, Aug 2011" /></a></p>
<p>If you are a Thunderbird addon developer, and you want to inspect the structure of a message, <a href="http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/mimemsg.js#180">MsgHdrToMimeMessage</a> is what you need. It will give you a nice hierarchical javascript-based representation of the structure of the message. Notable improvements are:</p>
<ul>
<li>you can now inspect encrypted messages (but you have to request that explicitly through the <code>examineEncryptedParts</code> option),</li>
<li>detached attachments are now supported,</li>
<li>uuencoded attachments are now supported,</li>
<li>if the message is stored on a remote IMAP server, you can use the <code>partsOnDemand</code> option that will not retrieve the full message in order to speed things up (the drawback is that you will get inaccurate attachment sizes, for instance).</li>
</ul>Thunderbird Conversations 2.0 releasedurn:md5:d37b97555606fdc82af125f0f615f4552011-06-28T00:46:00+02:002011-07-02T06:35:41+02:00Jonathan Protzenkomozilla <p><strong>Update: fixed the broken link for the manual</strong></p>
<p>It is my pleasure to announce that after almost one year in development, Thunderbird Conversations 2.0 has been released! Thunderbird Conversations goes along <a href="http://www.mozilla.org/en-US/thunderbird/" hreflang="en">Thunderbird 5</a>, so go get the latest Thunderbird and...</p>
<p><a href="https://addons.mozilla.org/en-US/thunderbird/addon/gmail-conversation-view/" hreflang="en"><img src="http://blog.xulforum.org/public/download.png" alt="Download now!" title="Download now!, Jun 2011" /></a></p>
<p>Thunderbird Conversations is a Thunderbird addon that, as the name implies, equips your favorite email program with a fully-featured conversation view. This addon has been developed in close collaboration with the Thunderbird team, and much effort went into Thunderbird to make this happen.</p>
<p><a href="http://blog.xulforum.org/public/1.png" title="Conversation teaser left"><img src="http://blog.xulforum.org/public/1.png" alt="Conversation teaser left" style="display:block; margin:0 auto;" title="Conversation teaser left, Sep 2010" /></a></p>
<p>Highlights include:</p>
<ul>
<li>a quick reply feature,</li>
<li>tight integration with your Thunderbird workflow,</li>
<li>contact tooltips,</li>
<li>support for viewing a conversation in a tab,</li>
<li>integration with other extensions (enigmail, lightning),</li>
<li>quote collapsing,</li>
<li>and many more.</li>
</ul>
<p><a href="http://blog.xulforum.org/public/quickreply-1.png" title="Quick reply"><img src="http://blog.xulforum.org/public/quickreply-1.png" alt="Quick reply" style="display:block; margin:0 auto;" title="Quick reply, Nov 2010" /></a></p>
<p>While this is still an experiment, we believe that it is sufficiently stable for you to try it out, hence the 2.0 version number. Documentation is available on my <a href="http://www.xulforum.org/gcvman.html" hreflang="en">personal website</a> (should be integrated in the Thunderbird FLOSS Manual when the next version comes out).</p>
<p>We welcome any kind of feedback. For general discussion, the right place is the <a href="https://groups.google.com/forum/#!topic/mozilla-labs/Jx8CxMvAoVk" hreflang="en">mozilla-labs google group</a>. For bugs, please direct them to our <a href="https://github.com/protz/GMail-Conversation-View/issues" hreflang="en">GitHub bug tracker</a>.</p>
<p>Known issues:</p>
<ul>
<li>many improvements have been made to Thunderbird to enhance its interaction with Conversations, which means only <a href="http://www.mozilla.org/en-US/thunderbird/" hreflang="en">Thunderbird 5.0</a> will be compatible with Conversations 2.0,</li>
<li>big messages (with attachments) that just arrived will be slow to render if you try to display them immediately: we have a fix both on the Thunderbird and the Conversations side, but we had to back it out due to a regression — we hope to have the fix included in Thunderbird 6,</li>
<li>the print command (from the menu) doesn't print the conversation – please use the print icon from the conversation view, or use a recent Thunderbird 7 nightly, the fix should land soon,</li>
<li>if you customized the default font settings, it might be that the conversation view has too small fonts: in that case, please revert your font settings to the defaults and read <a href="https://groups.google.com/d/topic/mozilla-labs/esb0LwLwQZo/discussion" hreflang="en">the thread on this topic</a>.</li>
</ul>
<p>Before reporting a bug, please try out both a recent nightly of Conversations (labeled "master", available at <a href="http://jonathan.xulforum.org/files/gcv-nightlies/" hreflang="en">http://jonathan.xulforum.org/files/gcv-nightlies/</a>) and a <a href="http://ftp.mozilla.org/pub/mozilla.org/thunderbird/nightly/latest-comm-central/" hreflang="en">recent build of Thunderbird 7</a>, known as "Daily". If the issue doesn't go away, we'd be glad to hear about it!</p>Wanna work on Thunderbird Conversations? We need help!urn:md5:da0a48f74687ab2f404e194669bb44402011-05-19T21:53:00+02:002011-05-20T09:40:01+02:00Jonathan Protzenkomozilla <p>I started working on <a href="https://addons.mozilla.org/en-US/thunderbird/addon/gmail-conversation-view/" hreflang="en">Thunderbird Conversations</a> pretty much 18 months ago, and it's grown from a quick hack to a fully-fledged re-implementation of the whole message-reading process in Thunderbird. It now integrates very nicely with the rest of Thunderbird, and I've put a lot of effort into making sure we comply with the bazillion options Thunderbird has. I believe it is a very viable replacement for the standard message reader, and I do have great hopes that the next version (compatible with the upcoming Thunderbird 3.3) will fulfill most people's desires when it comes to a conversation view.</p>
<p><img src="http://blog.xulforum.org/public/help1.png" alt="A poor choice of icon and colors" style="display:block; margin:0 auto;" title="A poor choice of icon and colors, May 2011" /></p>
<p>The development has been quiet for quite some time now, as Thunderbird Conversations is slowly becoming more and more feature complete. There's some big, low-priority items that I tackle when I feel really motivated, but apart from that, I'd say this works really fine on a day-to-day basis. However, I'm pretty much alone on this. Coding is fine, but I'm bad at design, and <strong>I need a hand to help me polish the UI before the final release</strong>.</p>
<p><img src="http://blog.xulforum.org/public/help2.png" alt="A nice window, but not consistent with the original design" style="float:left; margin: 0 1em 1em 0;" title="A nice window, but not consistent with the original design, May 2011" />
Here's a list of easy items that you can tackle if you have an hour or two:</p>
<ul>
<li><a href="https://github.com/protz/GMail-Conversation-View/issues/157" hreflang="en">bug 157</a>: experiment with a nicer look for nested blockquotes. Right now, we have this ugly set of colors that feels so 1998-ish, and we could probably use something more modern.</li>
<li><a href="https://github.com/protz/GMail-Conversation-View/issues/182" hreflang="en">bug 182</a> and <a href="https://github.com/protz/GMail-Conversation-View/issues/184" hreflang="en">bug 184</a>: there's a few windows that might pop up at some point ("Give feedback", "Indexing warning", "Setup assistant"). I designed these by shamelessly stealing the graphics from mozillamessaging.com. They could probably use some visual love, and be more consistent with the rest of the Conversations UI. We also have a phishing warning, but the icon doesn't blend well. This could use some help too.</li>
<li><a href="https://github.com/protz/GMail-Conversation-View/issues/189" hreflang="en">bug 189</a>: make sure people with a dark theme still can use Conversations. Right now, we assume the default text color is black. This is not always the case, and it breaks things for people who have dark themes. We don't necessarily want to respect the system colors, but we should at least make sure Conversations is usable.</li>
<li><a href="https://github.com/protz/GMail-Conversation-View/issues/257" hreflang="en">bug 257</a>: the icons in the conversation toolbar are not aligned.</li>
</ul>
<p>All these items are probably trivial for someone who's good at UI. I'm pretty bad at it, and most of these items would require me to spend too much time on them, for a less-than-satisfactory result in the end. So if you're good at these things, just drop me an email, or find me on irc.mozilla.org in #maildev (:protz). I'll provide guidance and help you get started with the Conversations source code.</p>
<p>Thanks!</p>A synchronous API for asynchronous calls to mozStorageurn:md5:22dfad12de3d2df487776f86ade92b532011-03-29T23:36:00+02:002011-03-29T23:36:00+02:00Jonathan Protzenkomozilla <p>Are you an extension developer using mozStorage? Do you wish you could switch your code to using asynchronous queries easily? Are you looking for a simple key/value storage system for your Firefox extension? I've written a small library that uses coroutines and the Javascript 1.7 Iterator stuff present in Gecko. It gives you access to a very simple key/value storage API, that's asynchronous, but that reads like synchronous code. If you're interested, read on :-).</p>
<p>I've previously <a href="http://blog.xulforum.org/index.php?post/2010/12/16/Dear-lazy-moz-web%2C">complained</a> about the lack of a simple, asynchronous API for storing key/value pairs when working in chrome. I now consider this problem solved with my <a href="https://github.com/protz/thunderbird-stdlib">new SimpleStorage API</a>, that I developed as part of a larger "thunderbird-stdlib" project.</p>
<p>This is how you can write boring code:</p>
<pre>
Cu.import(&quot;resource://myext/modules/SimpleStorage.js&quot;);
let ss = SimpleStorage.createCpsStyle(&quot;myExt&quot;); //myExt is the name of your storage &quot;table&quot;.
ss.has(&quot;myKey&quot;, function (aHas) {
ss.set(&quot;myKey&quot;, &quot;myVal&quot;, function (aWasSet) {
ss.get(&quot;myKey&quot;, function (aVal) {
// ... do stuff ...
});
});
});
</pre>
<p>This can easily become hard to manage. Here comes the new version, using iterators as coroutines:</p>
<pre>
let ss = SimpleStorage.createIteratorStyle(&quot;myExt&quot;);
SimpleStorage.spin(function anon () {
if (yield ss.has(&quot;myKey&quot;)) {
yield ss.set(&quot;myKey&quot;, &quot;myVal&quot;);
let v = yield ss.get(&quot;myKey&quot;);
yield ss.remove(&quot;myKey&quot;);
...
dump(&quot;Done&quot;);
yield SimpleStorage.kWorkDone;
// Nothing ever gets executed past that line. Don't use return!
}
});
dump(&quot;Woo!&quot;);
</pre>
<p>The code is now all sprinkled with calls to <code>yield</code>. Basically, you need to wrap everything with <code>spin</code> and make sure you prefix every call to a database function with <code>yield</code>. And also, don't forget the final <code>yield kWorkDone</code>.</p>
<p>The execution is not synchronous, in the sense that everytime you see <code>yield</code>, the <code>anon</code> function is suspended, the <code>spin</code> function takes care of running the query in the background, and when the result (asynchronously) arrives, <code>anon</code> is restarted with the result. The good thing is it makes code more readable, abstracts away the asynchronous nature of the storage queries, and allows you to write your code in a more concise way.</p>
<p>The cons are:</p>
<ul>
<li>this is counter-intuitive: only what's nested in a call to <code>spin</code> executes in sequence — this means that "Woo!" will probably be printed <strong>before</strong> "Done",</li>
<li>this requires that all the <code>yield</code> statements be topmost in the <code>anon</code> function ; if you move into another function, that one will have to wrap its own calls to <code>yield</code>, i.e. wrap everything inside another <code>spin</code> ; the inner function might even be scheduled after the outer function is done,</li>
<li>this seems dangerous because of some <a href="http://blog.cdleary.com/2010/12/a-generator-protocol-trap/">rare cases</a> that might happen after all,</li>
<li>it's easy to forget to return the final call to <code>yield</code>,</li>
<li>there's also the possibility of hardly understandable error messages.</li>
</ul>
<p>Does that sound acceptable for you? The code lives in my <a href="https://github.com/protz/thunderbird-stdlib" hreflang="en">thunderbird-stdlib</a> repository. There is <a href="http://protz.github.com/thunderbird-stdlib/doc/" hreflang="en">documentation</a> available. The code has been scarcely documented. Let's just say that I'm using function-expressions heavily.</p>
<p>Comments are welcome! This is just a prototype, and I'd be delighted to know how other extension authors feel about this. I'm pretty sure I'm not the only person who wants to store key/value pairs when working within an extension... I initially had planned on offering a third promises-style API, but I got busy with other stuff, and I don't think I will release it in the near future, so I figured out I might officially release this "as is".</p>
<h2>Note for the curious</h2>
<p>You can actually use <code>spin</code> to make your own asynchronous tasks look synchronous. Here's a useless example:</p>
<pre>
function myAsyncFunction (aReturn) {
// do something asynchronous, like...
setTimeout(function () {
// blah, blah, blah
aReturn(42); // this is how you return, don't use return!
});
}
SimpleStorage.spin(function () {
let result = yield myAsyncFunction; // you always yield a function that takes one parameter which is itself a function to send the result back
// result is now 42
yield SimpleStorage.kWorkDone;
});
</pre>
<h2>If you're reading the implementation</h2>
<p>The schema below might come in handy. Or not. But at least I tried!</p>
<p><a href="http://blog.xulforum.org/public/text2816.png" title="SimpleStorage"><img src="http://blog.xulforum.org/public/.text2816_m.jpg" alt="SimpleStorage" style="display:block; margin:0 auto;" title="SimpleStorage, Mar 2011" /></a></p>
<p>In the actual implementation of the spin function, <code>action</code> is called <code>asyncFunction</code>, and step 5 is done using a recursive function, because I assume (wrongly, I think) we have <a href="http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls" hreflang="en">proper tail calls</a>.</p>Thunderbird Conversations 2.0 alpha 3 releasedurn:md5:9afe3019977632f5bd5f855f6210a8d72011-03-15T22:29:00+01:002011-03-15T22:32:25+01:00Jonathan Protzenkomozilla <p>There's a <a href="https://addons.mozilla.org/en-US/thunderbird/addon/gmail-conversation-view/versions/">new release</a> of Thunderbird Conversations out there waiting for you to give it a try! (Pending review from the AMO team). Thunderbird Conversations is an addon for Thunderbird that enables a conversation view in the style of Gmail. You can read more about it in <a href="http://mozillalabs.com/messaging/2010/12/07/announcing-thunderbird-conversations/">our introductory blog post</a></p>
<p>There have been <a href="http://jonathan.xulforum.org/files/gcv-nightlies/Changelog_master">numerous improvements</a> since the last release, and this will be the last alpha. The software is stable enough so that I can start labeling the builds as "beta". There might be a feature or two coming up (we're thinking about forwarding an entire conversation, in a nice HTML formatting), but that's pretty much all. If you want to share your thoughts, <strong>we'd be happy to hear about your feedback on the <a href="https://groups.google.com/d/topic/mozilla-labs/Jx8CxMvAoVk/discussion">google groups thread</a></strong>.</p>
<p><a href="http://blog.xulforum.org/public/a3/2.png" title="The Gallery View"><img src="http://blog.xulforum.org/public/a3/2.png" alt="The Gallery View" style="display:block; margin:0 auto;" title="2, Mar 2011" /></a>
<em>This small link will show up if the message you're viewing contains any attached images.</em></p>
<p>Notable improvements include:</p>
<ul>
<li>conversation tabs will stay there, even if you close Thunderbird,</li>
<li>we now have a new gallery view,</li>
<li>support for marking a message as junk from the conversation UI,</li>
<li>support for phishing warnings,</li>
<li>support for Lightning events notifications (thanks go to Fallen),</li>
<li>several improvements to the quick reply,</li>
<li>fixed bugs in the setup assistant.</li>
</ul>
<p><a href="http://blog.xulforum.org/public/a3/3.png" title="Just click this button to open the conversation in a new tab"><img src="http://blog.xulforum.org/public/a3/3.png" alt="Just click this button to open the conversation in a new tab" style="display:block; margin:0 auto;" title="3, Mar 2011" /></a>
<em>This is the button that will allow you to open the conversation in a new tab. This allows you to have more space to read message, and you can also resize the quick reply area to have more space for replying.</em></p>
<p>There's also support for spell checking the quick reply, thanks to a series of patches I committed to Thunderbird. To set the language, just right-click in the quick reply area, and pick the language you want.</p>
<p><a href="http://blog.xulforum.org/public/a3/1.png" title="Spell checking support"><img src="http://blog.xulforum.org/public/a3/1.png" alt="Spell checking support" style="display:block; margin:0 auto;" title="1.png, Mar 2011" /></a>
<em>Spell checking is controlled by the context menu (right-click on the quick reply area), just like in Firefox.</em></p>
<p>As a side note, all of you who were running Thunderbird Conversations 2.0 alpha 2 should <strong>definitely check their preferences</strong>: there's a checkbox that the setup assistant used to disable in 2.0 alpha 2. This is not necessary anymore, so you should revert the change. To do so, just go to Preferences &gt; Advanced &gt; Reading and display, and check that "Automatically mark as read" has the value you want it to be.</p>
<p>As usual, the juicy bits are on <a href="https://github.com/protz/GMail-Conversation-View/">GitHub</a>. Come over there if you wish to contribute!</p>Basic MimeMessage demourn:md5:f998d5c223156ed01266724c423ad7552011-03-14T17:52:00+01:002011-03-15T10:02:01+01:00Jonathan Protzenkomozilla <p><strong>Edit</strong>: I added some screenshots and fixed a couple problems with the extension.</p>
<p>I've been talking for quite some time now about the new <code>MimeMessage</code> representation that allows you to conveniently inspect the structure of a Mime Message. It looks like the concept of callback is unclear to many of our extension developers. Coming from the functional programming community, I probably didn't realize I needed to be a little more specific. To tackle this issue, I've put together a very basic extension that should hopefully get you started :-).</p>
<p><img src="http://blog.xulforum.org/public/glodebug2.png" alt="The glodebug button" style="float:left; margin: 0 1em 1em 0;" title="The glodebug button, Mar 2011" /></p>
<ul>
<li>Get <a href="http://jonathan.xulforum.org/files/glodebug.xpi">the extension</a>.</li>
<li>Make sure you have <a href="https://developer.mozilla.org/en/Setting_up_extension_development_environment">dump enabled</a>.</li>
<li>Launch Thunderbird from a terminal.</li>
<li>Customize the main toolbar and add the "Glodebug" button.</li>
<li>Select any message, and hit the glodebug button.</li>
</ul>
<p>The result is a ton of colored information about the selected message in the console. The first half of <code>overlay.js</code> extracts the information through the <code>MimeMessage</code> representation. The other half uses a Gloda query to examine the information stored in the index. The last bit kicks a reindexing of the selected message in, so that in case you're writing a Gloda plugin, you can see how it performs.</p>
<p><img src="http://blog.xulforum.org/public/glodebug.png" alt="Glodebug console output" title="Glodebug console output, Mar 2011" /></p>
<p>I recommend reading my <a href="http://blog.xulforum.org/index.php?post/2011/01/03/An-overview-of-Thunderbird-Conversations">previous blog post</a> if you're interested in doing that kind of stuff with Thunderbird. I hope it will help some of our extension developers!</p>
<p>As a side note, this is the extension I'm using when I need to debug Gloda stuff, hence the name.</p>Fosdem 2011 slidesurn:md5:8d7d58a858834eb5345e84716bc331022011-02-06T13:05:00+01:002011-02-06T13:07:22+01:00Jonathan Protzenkomozilla <p>My presentation about Thunderbird addons and Gloda is <a href="http://jonathan.xulforum.org/files/fosdem2011.pdf" hreflang="en">now available online</a>. Here's a few links:</p>
<ul>
<li><a href="https://github.com/protz/Email-chat" hreflang="en">the email chat demo</a> (see <a href="https://developer.mozilla.org/en/Setting_up_extension_development_environment">this page</a> on the Mozilla developer network to find out how to get started with extension development),</li>
<li><a href="https://addons.mozilla.org/en-US/thunderbird/addon/54035/">thunderbird conversations</a> (<a href="http://jonathan.xulforum.org/files/gcv-nightlies/">dev builds</a> are available)</li>
<li><a href="https://developer.mozilla.org/en/Thunderbird/Creating_a_Gloda_message_query">gloda doc</a> (on MDN)</li>
<li><a href="http://blog.xulforum.org/index.php?post/2011/01/03/An-overview-of-Thunderbird-Conversations" hreflang="en">an offline version of my explanation</a> concerning the various parts of Thunderbird and how they interact together.</li>
</ul>
<p>And don't forget: find us on irc.mozilla.org #maildev: we're a friendly bunch :-). Thanks for your attention!</p>Thunderbird Conversations git subdmodule updateurn:md5:140b400771b0c7c576614f9b2ca6ff692011-01-15T01:31:00+01:002011-01-15T01:35:09+01:00Jonathan Protzenkomozilla <p>If you've been using the Git repository for Thunderbird Conversations, please note that the <a href="https://github.com/protz/thunderbird-stdlib" hreflang="en">thunderbird-stdlib project</a> has been spun off. While it's far for complete yet, it already hosts the <code>SimpleStorage</code> wrapper I've asked for a few blog posts earlier. This means Thunderbird Conversations now requires a checkout of thunderbird-stdlib to live in its source tree. Fortunately, git submodules make this easy to deal with: just run</p>
<pre>
git submodule init
git submodule update
</pre>
<p>from the root of your Thunderbird Conversations source tree. In the future, if you notice while pulling that the <code>.gitmodules</code> file has been updated, make sure you run <code>git submodule update</code> again.</p>
<p>Thanks for your attention!</p>
<p>PS: the <code>SimpleStorage</code> wrapper still lacks a Promises-style API, which is why I haven't blogged about it yet. Currently, there's only a callback-based API, and an iterator-style one, which Thunderbird Conversations now uses.</p>Thunderbird Conversations 2.0 alpha 2 releasedurn:md5:acb83aee72d09a0ecce7e9b9ed02f2632011-01-13T10:04:00+01:002011-01-13T10:05:05+01:00Jonathan Protzenkomozilla <p>I'm glad to announce that a <a href="https://addons.mozilla.org/en-US/thunderbird/addon/54035/">new version</a> of Thunderbird Conversations has been approved on AMO. If you've been reluctant to use Thunderbird Conversations because some bug would annoy you, there's good chances it's been fixed in the new version. If it hasn't, come and let us know about it on <a href="https://github.com/protz/GMail-Conversation-View/issues">our bugtracker</a>!</p>
<p>Highlights from the Changelog include:</p>
<ul>
<li>quick reply will now quote the text you're replying to,</li>
<li>new "send &amp; archive" feature,</li>
<li>fix character encoding issues in quick reply,</li>
<li>fix keyboard shorcuts sometimes not working when the conversation view has focus,</li>
<li>and much more.</li>
</ul>
<p>The next release will include more feature work, but there's no ETA yet.</p>Thunderbird: the global pictureurn:md5:271d132204dd82554dcde79e291f504f2011-01-03T15:07:00+01:002011-01-05T09:23:17+01:00Jonathan Protzenkomozilla <p>I've been working on Thunderbird Conversations for more than a year now, and I've learned a lot about Thunderbird internals over the past months. I thought I'd share some thoughts on the design of Thunderbird Conversations, in the hope that it helps would-be extension authors better grasp the design and the relationship between Gloda, libmime, the message headers, and the message database.</p>
<p>This is the first blog post in a series. In this post, I'll talk how various parts of Thunderbird interact together. In another post, I'll talk about the Thunderbird Conversations design.</p>
<p><strong>Thunderbird fellows, if I'm talking nonsense in this post, please make the right amendments in the comments. Thanks!</strong></p>
<h2>An introduction</h2>
<p>The mere fact of displaying a message involves a complex pipeline that's responsible from fetching the message to rendering it onto the users' screen. I'll focus on a small portion of the pipeline, and I believe this is the one most extension authors will be interested in.</p>
<p>I'll detail the following situations:</p>
<ul>
<li>displaying a message,</li>
<li>examining the structure of a message,</li>
<li>indexing (by gloda) of a message,</li>
<li>manipulation of a gloda message.</li>
</ul>
<h2>The basics</h2>
<p>At the core of Thunderbird is the <strong>message store</strong>. These are the big 4GB+ files in your "Mail" or "ImapMail" folders in your profile directory. As the name implies, they store all the messages that you have chosen to keep on your computer (this depends on your synchronization and storage settings). Presently, we have one big file for each folder.</p>
<p>Each folder has an <strong>summary file</strong> (some kind of an index): these are the .msf files that go along each one of the big files mentioned above. When you choose to open a given folder in Thunderbird, we do not re-read every single message in the folder. The point of the summary file is that it contains just the right amount of information so that one can build the message list from it, that is, the part of the screen that lists the contents of the selected folder. Summary files are usually rather small files.</p>
<p>The summary files contain only basic information: sender, recipients, date, and so on. Programatically speaking, they translate into <code>nsIMsgDbHdr</code> instances: all the information that's stored in the .msf files is reflected onto <code>nsIMsgDbHdr</code>s.</p>
<p>There are different execution pipelines, depending on what happens. Here's the simple case where the user chooses to display a message.</p>
<h2>Standard "message display" pipeline.</h2>
<p><a href="http://blog.xulforum.org/public/path7892.png" title="Gloda schema"><img src="http://blog.xulforum.org/public/.path7892_m.jpg" alt="Gloda schema" style="display:block; margin:0 auto;" title="Gloda schema, Jan 2011" /></a></p>
<p><strong>Fig. 1. A big schema that you should read alongside the explanations!</strong></p>
<p>How do we display the currently selected message in the message list?</p>
<p>What Thunderbird initially holds is a message header (extension authors, this is <code>gFolderDisplay.selectedMessage</code>, a <code>nsIMsgDbHdr</code>). The message store is queried to figure out whether we have this message locally, or if we need to download it. A download can happen if the message just arrived (think about IMAP), or if the user chose not to synchronize the folder the message is in. A partial download will occur, that is, we won't download heavy attachments, but seek so that we just read the associated metadata. Once we have downloaded the message body and all the attachments that are to be displayed alongside the message (text/plain attachments, for instance), libmime kicks in.</p>
<p>libmime is an old, ancient piece of software that lies at the core of Thunderbird. It is responsible for two completely unrelated tasks: parsing a message, and at the same time outputting the corresponding HTML for rendering. Because the two tasks correspond to distinct, separate logics, they naturally are horribly entangled in the libmime code ;-). Yay!</p>
<p>Libmime will parse the message structure, decode attachments, take care of various message encodings, output <code>&lt;hr&gt;</code>s to separate inline attachments, use <code>&lt;fieldset&gt;</code>s for attachment headers, and so on.</p>
<p>Finally, the output of libmime is fed into a XUL <code>&lt;browser&gt;</code> element whose task is to render HTML. This is the message reader, that sits in the bottom right corner of Thunderbird, and this is the part that's responsible for rendering the final HTML.</p>
<h2>I am an extension, give me a representation of the message</h2>
<p>If you are an extension author, there's good hope you'll want to examine a message at some point. What you hold is usually a <code>nsIMsgDbHdr</code>. There's absolutely no way you can disguise yourself as a libmime consumer, and talk to libmime directly. The ancient API is really hard to work with, plus, the data is not presented in an easily understandable way. What you'll probably do is use a module called <a href="http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/mimemsg.js">mimemsg.js</a>, that abstracts the libmime API away and offers you a nice, hierarchical vision of a message.</p>
<p>The pipeline goes like this: you call <code>MsgHdrToMimeMessage</code>, a function that, as the name implies, translates a <code>nsIMsgDbHdr</code> into a <code>MimeMessage</code> instance. The really nice thing is, <code>mimemsg.js</code> will talk to libmime for you, and will build a hierarchical representation of the message. Once it's done (this is asynchronous), the callback you passed to <code>MsgHdrToMimeMessage</code> will be called with the resulting <code>MimeMessage</code> instance as its second parameter.</p>
<pre>
let msgHdr = gFolderDisplay.selectedMessage;
MsgHdrToMimeMessage(msgHdr, null, function (aMsgHdr, aMimeMessage) {
// do something with aMimeMessage:
dump(aMimeMessage.coerceBodyToPlainText());
dump(aMimeMessage.allUserAttachments.length);
dump(aMimeMessage.size);
}, true);
</pre>
<p><strong>Fig. 2. <code>MsgHdrToMimeMessage</code> example. Read the documentation <a href="http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/mimemsg.js#171">here</a>.</strong></p>
<p><code>MimeMessage</code>, <code>MimeBody</code>, <code>MimeMessageAttachment</code> and <code>MimeUnknown</code> are all Javascript classes that represent parts of a message. They all have interesting properties: for instance, <code>MimeMessage</code> has some <code>allAttachments</code> and <code>allUserAttachments</code> properties, a <code>parts</code> property, a <code>body</code> property. <code>MimeMessageAttachment</code> has a <code>url</code> property, a <code>size</code> property, a <code>isReal</code> property, and so on. <code>mimemsg.js</code> is modern JS, is really well commented, easily readable, so if your are interested, you should definitely take a look.</p>
<h2>So I don't need Gloda, right? What is Gloda anyway?</h2>
<p>Gloda is a global index, kind of like the msf files, except it is Thunderbird-wide, uses an modern storage format, and is searchable efficiently. Gloda runs in the background, and indexes messages as they go: that is to say, it reads the interesting properties (sender, recipient, attachments, body) and stores them in a SQLite database that the user can search later.</p>
<p>Internally, when performing an indexing task, Gloda also starts with message headers. It requests a download of the message if not present in the offline store, obtains a <code>MimeMessage</code> representation of the message, and extracts relevant information from it. It inserts the information into a file called "global-messages.sqlite", and goes on indexing other messages. Indexing happens when new messages arrive, or in the background, in the case of an initial indexing.</p>
<h2>I'm an extension author, how am I interested?</h2>
<p>Gloda allows you to perform complex searches: this is the spine of Thunderbird Conversations. Gloda allows us to find out about the entire conversation even though only one message of it is currently available (because, say, the rest of the conversation is in other folders). Besides messages, Gloda also allows you to find contacts.</p>
<p>This is not the only reason you might want to use gloda. Gloda contains information that's much richer than what's stored in the message headers. For instance, the <code>allUserAttachments</code> property of <code>MimeMessage</code>s is also stored on Gloda messages (it's the <code>attachmentInfos</code> noun). That kind of information is not available with a bare <code>nsIMsgDbHdr</code>. Finally, while asking for a <code>MimeMessage</code> might require the message to be downloaded, querying Gloda is all done locally.</p>
<p>So now let's assume you hold a <code>nsIMsgDbHdr</code> and you want more information than what's stored in the .msf file (remember, that's what the <code>nsIMsgDbHdr</code> corresponds to). Your first reflex should be to find the corresponding <code>GlodaMessage</code> if present. If that doesn't work, you can re-trigger a download of the message (this will be slower) by requesting a <code>MimeMessage</code> representation. This should be your fallback plan.</p>
<pre>
Gloda.getMessageCollectionForHeaders([gFolderDisplay.selectedMessage], {
onItemsAdded: function (aItems) {},
onItemsModified: function () {},
onItemsRemoved: function () {},
onQueryCompleted: function (aCollection) {
let [glodaMsg] = aCollection.items;
dump(&quot;This message has &quot;+glodaMsg.attachmentInfos.length+&quot;\n&quot;);
let domNode = myDocument.getElementsByTagName(&quot;img&quot;)[0];
dump(&quot;We assume the first attachment is an image so we can display it\n&quot;);
domNode.setAttribute(&quot;src&quot;, glodaMsg.attachmentInfos[0].url);
},
}, null);
</pre>
<p><strong>Fig. 3. Obtaining a <code>GlodaMessage</code> starting with a <code>nsIMsgDbHdr</code></strong></p>
<p><strong>EDIT:</strong> as Andrew kindly pointed out, I'm being over-optimistic since I assume the message has been indexed already. The user might be running with indexing disabled, or the indexer might be busy doing some background task, and if the message just arrived, it might fail to index it in a timely manner. Here's a complete version with a fallback plan:</p>
<pre>
Gloda.getMessageCollectionForHeaders([gFolderDisplay.selectedMessage], {
onItemsAdded: function (aItems) {},
onItemsModified: function () {},
onItemsRemoved: function () {},
onQueryCompleted: function (aCollection) {
if (aCollection.items.length) {
let [glodaMsg] = aCollection.items;
dump(&quot;This message has &quot;+glodaMsg.attachmentInfos.length+&quot;\n&quot;);
let domNode = myDocument.getElementsByTagName(&quot;img&quot;)[0];
dump(&quot;We assume the first attachment is an image so we can display it\n&quot;);
domNode.setAttribute(&quot;src&quot;, glodaMsg.attachmentInfos[0].url);
} else {
MsgHdrToMimeMessage(gFolderDisplay.selectedMessage, null, function (aMsgHdr, aMimeMsg) {
// do the same thing with the MimeMessage API
dump(&quot;This message has &quot;+aMimeMsg.allUserAttachments.length+&quot;\n&quot;);
let domNode = myDocument.getElementsByTagName(&quot;img&quot;)[0];
dump(&quot;We assume the first attachment is an image so we can display it\n&quot;);
domNode.setAttribute(&quot;src&quot;, aMimeMsg.allUserAttachments[0].url);
}, true); // true means force the message into being downloaded... this might take some time!
}
},
}, null);
</pre>
<p><strong>Fig. 4. Complete sample that first tries to find the requested information with Gloda, and fallbacks to a complete streaming of the message with <code>MimeMessage</code> if the message isn't found in Gloda.</strong></p>
<h3>Gloda doesn't have the information I'm interested in</h3>
<p>I can hear astute readers telling me that manipulating <code>MimeMessage</code>s will always be better that manipulating <code>GlodaMessage</code>s: although it might be slower to obtain a <code>MimeMessage</code>, it has all the information: all the data, all the headers... <code>GlodaMessage</code>s only have what's needed for indexing and searching.</p>
<p>Surprise! You can write a Gloda plugin that will attach the custom information you want in the Gloda index. That way, you'll never have to re-stream a message to find out about a X-Whatever header: you just have to make sure you insert the X-Whatever information in the Gloda index, and voilà, you're good to go.</p>
<p>For instance, Thunderbird Conversations packages a gloda plugin that searches for bugzilla information and attaches it to the gloda message. The Gloda plugin we package is passed the <code>MimeMessage</code> representation Gloda obtained, extracts relevant information from it, and attaches it to the Gloda message that's to be stored in the database.</p>
<h3>I want complex information about the message, and I also want to display it</h3>
<p>You'll have to use Gloda or <code>mimemsg.js</code> to obtain the metadata you're interested in, and then trigger the streaming again into an iframe. This might result in the message being streamed twice if you go the <code>MimeMessage</code> way, but there's no easy way to work around this right now. Walking the <code>MimeMessage</code> and synthetizing the HTML to be rendered yourself is error-prone, so for the time being, you're better off leaving it all to libmime (remember, libmime not only decodes the raw messages but also decides how to display it).</p>
<h3>I walked into the gloda land, and I want to display one of the messages I just found</h3>
<p><code>GlodaMessage</code> instances have a <code>folderMessage</code> property (<strong>possibly null</strong>) that represents the original <code>nsIMsgDbHdr</code> if, say, you want to display it. That's true, Gloda sometimes remembers dead messages.</p>
<p>That's all folks. I'll try to write another blog post detailing the issues I've faced and the design choices I've made when writing Thunderbird Conversations. Thanks for reading!</p>