New account types in JavaScript for Thunderbird (Part 1)

For the month of December, I took a reprieve from ExQuilla, my Exchange Web Services extension, and decided to tackle the issue of trying to create new account types in JavaScript in a Thunderbird extension. This blog post is an introduction to that project. More detailed posts on specific issues should follow shortly.

Introduction to SkinkGlue

I’ve learned a lot about how to create account types in an extension while working with ExQuilla. While ExQuilla is written principally in C++, many of its concepts could be adapted to javascript. I decided to write TweeQuilla, a demonstration extension in javascript that will implement Twitter as an account type in Thunderbird to test the concepts.

Unfortunately it is not as simple as just writing stuff in javascript, as Joshua Cranmer discovered in his never-finished series of blog posts attempting to do just that. There are complex interactions between javascript objects, C++ objects, and xpconnect that make it difficult or impossible with the existing core code to create a new account in javascript. I have not really solved that problem completely. Instead, I have created a C++ layer that I call Skinkglue. (Skink, as my loyal fans know, is my personal term for the mass of code that implements the basic mailnews functionality in Thunderbird and related products such as SeaMonkey.)

Now Skinkglue is written in C++, and needs to be available before the javascript-only TweeQuilla will work. But Skinkglue does not contain any twitter-specific functionality. In fact, the same Skinkglue code is also used by my ExQuilla addon to implement a new account type using C++.

My intentions are that Skinkglue will get implemented in core as a publically available interface. For that reason, I am making that code available using the standard MPL tri-license. Hopefully that would solve the issues of trying to use a C++ layer in an extension, as it would just be a part of the core that would be available in the standard distribution, so extension writers would not need to compile the C++.

Introduction to TweeQuilla

I chose Twitter as a demonstration because it is likely to be useful, because it is quite simple, and because there has been a lot of work already on the Mozilla platform in developing code for basic Twitter functionality. In particular, I am indebted to the SocialMail addon for the most recent set of updates to that work, though that addon built largely on earlier contributions.

I am not releasing TweeQuilla for public consumption yet on AMO because it is not at all ready (though I am starting to use it myself in my standard email profile.) But the main point is really to demonstrate that this can be done at all, and the extension as it stands makes that point.

Here are a few images of TweeQuilla:

A new twitter account is added using Account Actions in the Account Manager:

When you add a new twitter account, you must fill out an OAuth screen (this one is largely borrowed from SocialMail):

When the account is created, you see different types of twitter searches as mailnews folders. Currently I only have two implemented, one a list of the items that you have sent, and the other your full timeline:

For tweets that just consist of text, the “message body” and the subject are both just the text of the tweet. For tweets with embedded html links, I am currently loading the html link as the “message body”.

Getting the source

Both Skinkglue and TweeQuilla are available for the curious on my Mozilla mercurial site. The TweeQuilla version that exists there includes a compiled version of Skinkglue that will work if you are running Thunderbird on version 3.1.x under windows. Others are out of luck for now. The code at the moment is not easy to understand. I hope to remedy that by some comment cleanup, as well as documenting issues in further posts on this site.

Share

9 comments to New account types in JavaScript for Thunderbird (Part 1)

  • Jean Noel Prigent

    I am trying to install tweequilla addon for thunderbird
    I have this error in step 1(Chrome or firefox )

    ” Whoa there!
    There is no request token for this page. That’s the special key we need from applications
    asking to use your Twitter account. Please go back to the site or application that sent
    you here and try again; it was probably just a mistake. ”

    any hint ?
    Thanks

    • The problem that you are having is not common for TweeQuilla. This sounds to me like Thunderbird is have problems opening a web browser window correctly. I’m not sure what to recommend to you, other than that you try this after restarting your operating system. Twitter requires interaction through a web brower before TweeQuilla is allowed to access your account information.

  • Jean Noel Prigent

    Thanks for your reply

    Thunderbird opens correctly the Web Browser but
    the URL in the Web Browser is :
    “https://twitter.com/oauth/authorize?oauth_token=”

    Clearly the token is empty.

    Can I check some where some log from TweeQuilla ?

    May be I have to configure something in ThunderBird before strating the account creation process ?

  • Giving the URL was very helpful.

    Tracing back the origin of that URL, the missing pieces are supposed to come from a signed & timed request that was made to Twitter. If that request fails, then the pieces are not available. TweeQuilla should detect that error, but it is not.

    The likely source of that error is the time stamp. I can generate the same symptoms as you by using a timestamp that is off by about one day or more. Those requests are being rejected by Twitter. So I suspect that the clock in your computer is off, or there is something about your timezone that is causing issues.

    I’m in the process of updating TweeQuilla right now. I will at least add a console error message if there is a failure at this point.

  • Jean Noel Prigent

    Well, for me the timezone ( CET France) and computer date is OK

    But my laptop is running an english ( US ) version of XP.

    May be this could help

    JN

  • Jean Noel Prigent

    Tweequilla has been automatically updated feb 24
    It’s mow OK

    Thanks

  • Jonas

    I stumbled upon this when looking for a way to send SMS from Thunderbird.
    The only one I found was http://selma.meotec.de/index.php?lang=en where the developers have to add new providers.

    I then thought it would be handy to be able to add your own provider as a TB account and found your add-on. Unfortunately I am on Linux so I would not be able to use the current version.

    Was just wondering if you have had any luck with the javascript version?

    • “New Account Types” is intended as a demo of capability, so before you could use it to send SMS messages someone would have to develop another extension (like TweeQuilla which is usable for Twitter) that would implement SMS. And you would need the Linux version of course, but that would probably just take a couple of days of work for me. That is coming eventually though, as I am committed to Linux support for ExQuilla which uses the same technology for Exchange support, so once I support Linux on Exchange then I would also add it to TweeQuilla and New Account Types. My guess is this is 2 months away.

      But back to SMS. You could simply add a webpage link in Thunderbird to someone who does SMS from a webpage using the “WebApps Tabs” addon. If you just want to send, that would work. (With New Account Types, you would integrate SMS into Thunderbird so that it looked like an email message, having folders and such with lists of messages).

      I’ve actually though of SMS as a possible next project myself. Can you give me reasons why you would need a full integration of SMS into Thunderbird beyond what s simple weblink to a webpage provides?

      • Jonas

        Thanks a lot for your reply. I am aware that I would have to write a “TextQuilla”.

        Basically I thought it would be nice to add each SMS provider as an account sub type of SMS but when rethinking it I am not really sure. What I wanted was an easy way to specify login url, send url , receive url (if any) and usr name + pwd for SMS provider web interfaces so that it would be easy for super users to add their own providers.

        It now looks like it may be a bit overkill.

        Not sure what you mean by a simple weblink to a webpage (maybe what I have described above), as far as integration goes I would be happy to make something similar to Selma but letting super users configure their own providers.

        Most SMS provider web interfaces do not support incoming SMS so yep, definitely overkill. I would mainly target national mobile carriers as the most common web only sms providers are already in Selma anyway.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

To comment, click below to log in.