Sunday, January 17, 2010

el talta tabta

Finally, after installing Ubuntu and Thunderbird for the third time, it finally worked as it should.
So I tried the code I did for the user interface of the mini-project, and I t also worked. This made me excited to work on the final project bug and the mailto bug also. I started with the mailto bug just to be sure that it really worked :D.

I add more conditions to the if-statement in line 199, the first one is to check if we have a '.' right after the '@', the second condition is to check if we have more than one consecutive '.' after the '@' sign, the third condition is to check if the address ends with '.', finally we must check if the address starts with the '@' sign.

After testing I found out that the code had an error

(inString.CharAt(inString.Length()-1) != '.')

The letter ‘L’ in the method Length was in lower case and it should be in upper case.

So this is my final modified code:

if (aInString[pos] == '@')
{
nsDependentString inString(aInString, aInLength);
if ( (inString.FindChar('.', pos) != kNotFound) &&
(inString.CharAt(pos+1) != '.') &&
(inString.Find("..", pos) == kNotFound) &&
(inString.CharAt(inString.Length()-1) != '.')&&
(pos!=0))
{
aOutString.AssignLiteral("mailto:");
aOutString += aInString;
}
}

After testing it I worked :), I also tested it for common errors, afterwards I created a dummy bug and attached my patch to it. Finally I requested a review from Dr. Fatma.



As with the Final project bug, it was about checking all mail address in each one of the address fields (to, cc, bcc) before sending a mail.

In case we write invalid mail address (say, invalidmailaddress) in To/Cc/Bcc etc field, we'll see error dialog saying:

invalidmailaddress is not a valid e-mail address because it is not of
the form user@host. You must correct it before sending the e-mail.

But if we input at least one valid mail address, other fields will not be checked and thunderbird will send to the invalid mail address.
These are the examples of the normal and invalid behaviors:






* found the command that checks for each field (to, cc, bcc)
* edited the code so that it checks for all the emails in each field using the split method and for-loops.

function CheckValidEmailAddress(to, cc, bcc)
{
var invalidStr = null;
var i=0;
var j=0;
var k=0;
var arraybcc= bcc.split(",");
var arraycc= cc.split(",");
var arrayto= to.split(",");
if (arraybcc!=null)
{
for (k=0;k {
if (arraybcc[k].length > 0 && (arraybcc[k].indexOf("@") <= 0 ||
arraybcc[k].indexOf("@") == arraybcc[k].length - 1))
invalidStr = arraybcc[k];
}
}
if (arraycc!=null)
{
for (j=0;j {
if (arraycc[j].length > 0 && (arraycc[j].indexOf("@") <= 0 ||
arraycc[j].indexOf("@") == arraycc[j].length - 1))
invalidStr = arraycc[j];
}
}
if (arrayto!=null)
{
for (i=0;i {
if (arrayto[i].length > 0 && (arrayto[i].indexOf("@") <= 0 ||
arrayto[i].indexOf("@") == arrayto[i].length - 1))
invalidStr = arrayto[i];
}
}
if (invalidStr)
{
var bundle = document.getElementById("bundle_composeMsgs");
if (gPromptService)
gPromptService.alert(window, bundle.getString("addressInvalidTitle"),
bundle.getFormattedString("addressInvalid",
[invalidStr], 1));
return false;
}
return true;
}

* tested the code using the Thunderbird build.
* the compose window stopped working when I try to send any email.
* after testing the code [http://writecodeonline.com/javascript/ here] if found out that the error was caused because the method is passed null for each empty field.
* edited the code to avoided null exceptions.

function CheckValidEmailAddress(to, cc, bcc)
{
var invalidStr = null;
var i=0;
var j=0;
var k=0;
if (bcc!=null)
{
var arraybcc= bcc.split(",");
for (k=0;k {
if (arraybcc[k].length > 0 && (arraybcc[k].indexOf("@") <= 0 ||
arraybcc[k].indexOf("@") == arraybcc[k].length - 1))
invalidStr = arraybcc[k];
}
}
if (cc!=null)
{
var arraycc= cc.split(",");
for (j=0;j {
if (arraycc[j].length > 0 && (arraycc[j].indexOf("@") <= 0 ||
arraycc[j].indexOf("@") == arraycc[j].length - 1))
invalidStr = arraycc[j];
}
}
if (to!=null)
{
var arrayto= to.split(",");
for (i=0;i {
if (arrayto[i].length > 0 && (arrayto[i].indexOf("@") <= 0 ||
arrayto[i].indexOf("@") == arrayto[i].length - 1))
invalidStr = arrayto[i];
}
}
if (invalidStr)
{
var bundle = document.getElementById("bundle_composeMsgs");
if (gPromptService)
gPromptService.alert(window, bundle.getString("addressInvalidTitle"),
bundle.getFormattedString("addressInvalid",
[invalidStr], 1));
return false;
}
return true;
}

* tested the code again. (worked)
* created the patch.
* tested the patch for common errors [http://beaufour.dk/jst-review/ here].
* submitted the patch.
* bug fixed.

Thursday, November 12, 2009

Running Thunderbird

After building Thunderbird is finished it was very disappointing that there were no fireworks or even a "congratulations your build was successful" message, all what you get is this screen in the picture below :(.


















After running Thunderbird I tested it for the "mailto" bug, and as you can see it is still present.

Wednesday, November 11, 2009

Easy to follow steps for building Thunderbird on Ubuntu

1. Install cvs:

sudo apt-get install cvs


2. Installing build tools:

sudo apt-get build-dep thunderbird
sudo apt-get install mercurial libasound2-dev libcurl4-openssl-dev libnotify-dev


3. To get autoconf version 2.13:

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz
tar -xvzf autoconf-2.13.tar.gz
cd autoconf-2.13/
./configure --program-suffix=2.13
make
sudo make install


4. Get the source:

hg clone http://hg.mozilla.org/comm-central/
cd comm-central
python client.py checkout


5. To get missing packages such as mesa or header files such as iwlib.h:

sudo apt-get install mesa-common-dev libiw-dev


6. Create an empty file in comm-central directory and rename it to ".mozconfig"

7. Add the following lines in the ".mozconfig" file:

ac_add_options --enable-application=mail
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-tb-release
mk_add_options MOZ_MAKE_FLAGS="-j4"


8. Start the build:

make -f client.mk


It worked for me !!!, I tried to make it as easy as possible without any descriptions for my colleagues who don’t want to get into details of the build :), but if you want to ask about anything just post a comment and I hope that I can help you. Also I would like to thank Eng. Mina Metias for his post about building Thunderbird.

Note: It takes time to download the source code.

Sunday, November 8, 2009

Fixing the Thunderbird bug

The first step in fixing the bug is finding it in the source code, in my approach I used MXR (Cross-Reference), and you have to cleverly choose the very specific keywords used for searching, because the source code isn’t small. I used "mailto" as my searching keyword, the code related to the bug was in the mozTXTToHTMLConv.cpp file between lines 194 to 204.

if (aInString[pos] == '@')
{
// only pre-pend a mailto url if the string contains a .domain in it..
//i.e. we want to linkify johndoe@foo.com but not "let's meet @8pm"
nsDependentString inString(aInString, aInLength);
if (inString.FindChar('.', pos) != kNotFound) // if we have a '.' after the @ sign....
{
aOutString.AssignLiteral("mailto:");
aOutString += aInString;
}
}

This part of the code just checks if there is an '.' after the '@' sign and ignores a lot of other invalid cases of an email address.

Invalid Addresses
a@.
a@..
a@..f
a@....f
@.
@.com
@a.com
@a
@a.
@a..
@a...com
a@a.a..a

So we must add more conditions to the if-statement in line 199, the first one is to check if we have a '.' right after the '@', the second condition is to check if we have more than one consecutive '.' after the '@' sign, the third condition is to check if the address ends with '.', finally we must check if the address starts with the '@' sign.
So this is my modified code:

if (aInString[pos] == '@')
{
nsDependentString inString(aInString, aInLength);
if ( (inString.FindChar('.', pos) != kNotFound) &&
(inString.CharAt(pos+1) != '.') &&
(inString.Find("..", pos) == kNotFound) &&
(inString.CharAt(inString.length()-1) != '.')&&
(pos!=0))
{
aOutString.AssignLiteral("mailto:");
aOutString += aInString;
}
}


Unfortunately I didn’t test or patch it :( for a well known reason :D, so can some one test it for me ??

Monday, October 26, 2009

Processing.js First project

In the first Processing.js Project, I worked with Eng. Sarah Nagaty and Eng. Omar Roushdy, we worked on creating an interface to show the contributions of each user in a nice way, but we failed to get the values of the contributions in an array to be used in our Processing.js code, so we tried to get the names only, we got them in an XML file using a query, but unfortunately we couldn’t use it also, so we just entered the users in a static way in an array and used it, hopefully soon we will find out how to do it and we will make an new release ;).

The project we did just list objects of circles in an ordered way and assigns a name to each one, when the users enters the mouse inside the box of the circle the name of the user assigned to it will appear on the tip of the mouse. The colors of the circles are random degrees of blue.

Finally, I used the “Get Source” button of the web IDE provided by Processingjs.org to get a file that works without support of any other files, and I changed the code inside of it to our code, and it works :), but for the text to appear you have to use Firefox, in chrome the text didn’t appear :(, and of course on IE it worked perfectly (kidding :D).

In this post I discussed the work of our group altogether, not my individual work.

Windows 7

I posted this picture on the wiki in the community humor page, but I think no one checks this page, you have to try Eng. Omar Roushdy Ubiquity command to go to this page it is really easy.



Microsoft tried to torpedo the success of the Japan Linux Symposium by launching their Windows 7 product that same day. They even had setup a big promotion booth across the street from the conference center.

During a break, Linus went over there to make some fun of Microsoft. When he arrived there, Linus was sold immediately on the product as you can see in the picture. At least that's what the sales guy thought. He obviously had no idea who he was dealing with. But in the end Linus surprisingly did not buy a copy.

Both of them look very funny in this picture :D

Yet Another Review

Today I wrote a review on the reviewers of my review on the Cathedral and the Bazaar review :D, and then one of my reviewers will review my review on the reviewers of my review on the Cathedral and the Bazaar review, and more to come ..., as a very wise man said "till infinity and beyond" my friend Captain Buzz Lightyear, I hope I can see him in Toy Story 3 soon isA, for people who are interested the release date is 16 June 2010.




Back to the Cathedral and the Bazaar review, I think that after a while it will be something worth the wait, I wish Dr. Fatma best of luck in joining all the points together, and I have to say that I really admire your work and effort. :)