Saturday, 26 December 2009

The Final Bugzination! Final Release! Et3alemooha ba2a ya Mina!

I just submitted the patch for the thing i donez, i dont really think i did it correctly thought, bass eshta ba2a.. maleesh da3wa ya3ni ana khallasto ba2a.. homma 3ayzeen yestafado be shoghly.. kana beha... mesh 3ayzeen.. wallahi ya3ni...

The difference between the final release and 0.2 is the following:
- user can choose the forwarding headers he wants to include in the mails he forwards, and furthermore, the user can choose to automatically remove all original headers independent of the headers he is using at the moment. The screenshot shall explain more:


How Do ZAT?

(i added the 'forward headers' dropdown and the 'remove existing ...' checkbox, in case you are wondering what's new about this window.)

I Tell you nao!

First you need to add a "preference", which is passed on somehow to the preferences window and can be called to hold certain values for the properties.

A preference is added in the following way:

< id="mail.forward_message_header" name="mail.forward_message_header" type="int">"

< id="mail.forward_remove_headers" name="mail.forward_remove_headers" type="bool">"

The first one is the preference for the dropdown and the second one for the checkbox. I added these two lines to the compose.xul file located under comm-central/mail/components/preferences. Under the last folder you will find .xul files for most of the GUI components like, display.xul, general.xul, which are both tabs in the preferences windows, and so on.

Then, you add the actual box, that is displayed in the preferences window:

< align="center">
< value="&forwardHdr.label;" accesskey="forwardHdr.accesskey;" control="forwardMessageHeader">
< id="forwardMessageHeader" preference="mail.forward_message_header">
<>
< value="3" label="&noHeaders.label;">
< value="0" label="&minHeaders.label;">
< value="1" label="&normHeaders.label;">
< value="2" label="&maxHeaders.label;">

< /menulist>
< id="removeHeaders" label="&removeHeaders.label;" preference="mail.forward_remove_headers" accesskey="&removeHeaders.accesskey;">
< /hbox>

I will explain the labels and accesskeys later although they are really simple, so if you dont understand much from the previous "code" start by ignoring anything, that has label or accesskey.
The preference attribute for menulist just says which preference is controlled by this dropdown menu, and in this case it's the forward headers preference mentioned previously. Then we have some menuitems also with labels.
And next a checkbox which represents the checkbox we have and it is binded to the preference remove headers.

Labels and accesskeys are simple the label of each item or menu, so for example
< label="&removeHeaders.label;"> means that the checkbox has the label of the value inside the variabel removeHeaders. The accesskey defines which hotkey gets you to this menuitem, checkbox, ... . As an example take a look at the previous image, you will see that the 'h' in forward headers is underlined: this means, that its accesskey is 'h', and the label for the whole menu is "forward headers".

I dont know why something like: label="forward headers" is not used, but in all the source code i checked this way was applied.

The labels and accesskeys are all stored in two files:

1.comm-central/mail/locales/en-US/chrome/messenger/preferences/compose.dtd
2.comm-central/suite/locales/en_US/chrome/mailnews/pref/pref-composing-messages.dtd

That is where i added all the labels in the following way:

< !ENTITY forwardHdr.label "Forward headers:">
< !ENTITY noHeaders.label "No Headers">
< !ENTITY minHeaders.label "Minimum Headers">
< !ENTITY normHeaders.label "Normal Headers">
< !ENTITY maxHeaders.label "All Headers">
< !ENTITY removeHeaders.label "Remove existing headers from message">
< !ENTITY removeHeaders.accesskey "X">

That is basically it. The last thing having variables in your actual code, that take the value of the preferences:

(the following code is from mimedraft.cpp)

PRInt32 show_headers;
prefBranch->GetIntPref("mail.forward_message_header", &show_headers);

PRBool removeHeaders = PR_FALSE;
prefBranch->GetBoolPref("mail.forward_remove_headers", &removeHeaders);

This means that show_headers takes the value of the preferences "mail.forward_message_header" and the bool removeHeaders takes the value of "mail.forward_remove_headers".

The design has been changed a bit to be able to use the "remove original headers" function without having to be in anonymous forwarding mode:

if(removeHeaders)
mime_remove_headers(body, headers, composeFormat, mailcharset);

Which means that if the checkbox is ticked, then the function mime_remove_headers is called, and all the headers from the body are removed, then we move on to inserting the headers:

switch (show_headers)
{
case 0:
mime_insert_micro_headers(body, headers, composeFormat, mailcharset);
break;
case 1:
mime_insert_normal_headers(body, headers, composeFormat, mailcharset);
break;
case 2:
mime_insert_all_headers(body, headers, composeFormat, mailcharset);
break;
case 3:
mime_insert_no_headers(body, headers, composeFormat, mailcharset);
break;
}

in case 0 - 2 some headers are inserted (i crtd none of those functions) and in case 3 my function "mime_insert_no_headers" is called, which i changed to the same state it was in in Bug Release 0.1, which is being an empty function.

I am done bugging!

No comments:

Post a Comment