create own plugin for Thunderbird or Zarafa? - plugins

I want to enhance my thunderbird (or zarafa), so that i can rightclick on a mail, and get a dialog, where i can fill in some information (like an article reference, an issue number or an invoice) and press "send", and this information alongside with the email and (logged-in) user-information will be sent to another webservice (i.e. a XML-RPC-call, but anything else will also do) which then handles the e-mail (for example attaching the content to the invoice, to the issue resp. the article)? [i need the thunderbird/zarafa part]
thanks for any help (even if it is an answer like "not possible")

This should be quite possible using an extension. First of all you should look into the basics of creating a Thunderbird extension or creating a Mozilla extension in general.
What you then want to do is create an overlay for the context menu, which adds a menuitem that opens your custom dialog. If you use the openDialog method you can pass additional arguments to the dialog, like the currently selected message header (gFolderDisplay.selectedMessage).
From there you can get mail headers, selectedMessage is of the type nsIMsgHdr. Getting the body of the message is a bit more complicated because you have to stream the body and then parse the mime body, but its still possible using the js mime emitter. There are some changes underway that might make this easier in the future, so please double check if there is not an easier way to stream the body.
With that information, you can easily use standard methods (i.e XMLHttpRequest) to send your data to a web service.

Related

What is the right way to rewrite Mozilla Thunderbird's thread pane?

I have an idea about alternate standard view of e-mail clients, like Mozilla Thunderbird. I need to display expanded message bodies in one feed (like Google Reader displays RSS) instead of headers list + one message body.
Let me visualize this. Standard view: http://i.stack.imgur.com/R5OZ4.jpg. Google reader view: http://i.stack.imgur.com/CRBoM.jpg
I suppose that correct way is to hide XUL elements like threadPaneBox and messagepanebox and instead insert one new element. On startup i will load current folder's messages and render them in this new container.
So, question is - Is it right way to customize message view in Thunderbird? What is the right way to do this? What is the right place to ask this question (maybe it will be better go to some Thunderbird developers forum)? And finally, is writing extension for Thunderbird is best method to bring my idea to live?

How to show a User view in GWT app by typing in browser address bar

I have this gwt app which say, runs on http://mygwtapp.com/ (which is actually: http://mygwtapp.com/index.html)
The app host a database of users, queried by searching usernames using the search view and results are shown in the user results view. Pretty useful enough. However I need to bb add a way that user view can be viewed by just typing http://myapp.com/user123
I am thinking that the question I have here, the answer is a server side solution. However if there's a client side solution, please let me know.
One fellow here in StackOVerflow suggested that the format would be like this:
mygwtapp.com/index.html#user123
However the format is important to be like: http://myapp.com/user123
The 'something' in 'http://host/path#something' is a Fragment identifier. FIs have a specific feature: the page isn't reloaded if only FI part in URL changes, but they still take part in browser history.
FI's are a browser mechanism that GWT uses to create "pages", i.e. parts of GWT application that are bookmarkable and have history support.
You can try to use an URL without # (the FI separator), but then you will have a normal URL, that reloads the page with every change and it could not be (easily) a part of a normal GWT app.
mygwtapp.com/index.html#user123
That would be using the History mechanism (http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsHistory.html) which I would add is the recommended way of doing it.
However, if you insist on using something like http://myapp.com/user123, one of the possible ways is to have a servlet which accepts this request (you might have to switch to something like http://myapp.com/details?id=user123). The servlet will look up the DB and return your host html back. Before returning it will inject the required details as a Dictionary entry in the page (http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/i18n/client/Dictionary.html) On the client you can read this data and display on the UI

File Upload using GWT with a Dialog box to browse to the File

I am working on a GWT web application where users are pushing in updates(something like twitter). The update is text+attachment. I want user to type in a update, optionally Hit the upload button , which gives a pop up to browse to the file and then when they are done finally hit the "send update" button. The text+attachment will be stored in a row in mysql. The text as ususal varchar and the file as a blob. The file size will be small.
I am clueless on how to achieve this at the moment. Looking at the API and googling I found the "FileUpload" widget being used. Docs say It is used to be used with a FormPanel. I am not sure if I really get the whole thing and how do I apply it in my case.
How can I solve my problem?
Typical way for browsers to upload files is to use input type='file' form field. There is no way to upload file using AJAX without form. At least I could not find any. I think, it's a security measure.
Therefore, to have file upload available, you must provide a form with file input. The form will have to be submitted via regular request, not AJAX.
So you must define FormPanel and add FileUpload to it. Example:
final FormPanel form = new FormPanel();
form.setAction("my.action");
// Because we're going to add a FileUpload widget, we'll need to set the
// form to use the POST method, and multipart MIME encoding.
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
// Create a FileUpload widget.
fileUpload = new FileUpload();
fileUpload.setName("fileUpload");
form.add(fileUpload);
// Add other components to form
Other components would include user text entry. There are may be options for handling them differently, but I think the best is to handle them via the same form submission.
Now, you have to add something to trigger form submission.
submitButton = new Button("Upload", new ClickHandler() {
public void onClick(ClickEvent event) {
form.submit();
}
});
formPanel.add(submitButton);
Finally, you must handle upload. You can do it in multiple ways but it must be regular request handling, not via AJAX or GWT. I personally like using Spring MVC for that. But you can use you framework of your choice. I am not going to cover details here. You can write Perl script, if you wish.
There are alternatives to this approach. You can use Flash, you can use Adobe AIR and there are may be other approaches. There are widgets for those approaches in different libraries. Check this site: http://google.wikia.com/wiki/Google_Web_Toolkit.
Disclaimer: This is approach that I used. I may have missed something and there are may be other approaches that I would love to learn about.

How to create a To field like the one in Mail or Facebook app?

Does anyone know how to create a 'To field' like the one in Mail or Facebook app?
When an address is added from the A-Z list, a blue component that represents the address will be added to the text field. Is there a class provided for this functionality, or do we have to implement by ourselves?
There's no built-in framework. You'll either need to implement it yourself or use one of the open source components, such as Three20 (which includes the one used in the Facebook app).
In Three20's author's blog I found these few lines:
Message composer
TTMessageController emulates the
message composer in Apple's Mail app.
You can customize it to send any kind
of message you want. Include your own
set of message fields, or use the
standard "To:" and "Subject:".
Recipient names can be autocompleted
from a data source that you provide.
Maybe you should take a look at its source code at github.

with tinymce, do you have to handle html markup?

If you use tinymce, does that mean you have to handle the parsing of the HTML on the postback (when saving the data to the db)?
i.e. you have to parse the output and make sure no hacky script was posted back or can you have tinymce convert the html into a safe markup?
You can't ever rely on the client to make sure that the content it posts to your server is safe.
Its much too easy for a potential attacker to disable those client-side measures and submit any dangerous content that he wants to.
Therefore you will always have to check your content on the server side, no matter what editor you use in the browser.
Yes, always!!! Just think if they turn off the editor or don't have javascript enabled.
We use the 'valid elements' check to ensure we only get standard HTML out of the editor. No scripts, no events on tags pasted in (e.g anchor tags with onclick events). Just boring, ordinary HTML.
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements