Monday, December 8, 2008

A new address book public repo

Veteran readers may recall my old posting of the address book rewrite repository. My original idea did not turn out so well—I had about 5 heads at one point because of review comments and simultaneous patches. Not to mention the history (though fun to look at) was a pain to try to follow.

I therefore created a brand new version of the repo. In the new one, I'm structuring things a bit differently. Rather than trying to keep one branch going, I'm going to have multiple named branches.

The first one is default, or the comm-central import. The tip of the default branch is the tip of comm-central when I imported that.

One set of branches is the experimental let's-add-new-address-book-type branches. I already have a prototype SQL AB developement branch, sqlab. When I start experimenting with Evolution support, there will be an evolutionab branch. And so forth and so on. If you have custom AB types that you want to publish, email me a bundle and you'll get your very own named branch in this repo (for as long as it exists).

Another set of branches is the bugs I'll be working on. These branches will tangle around each other as a fix one bug or another, since some bugs depend on other bugs. I'll try to keep a last-idl tag up-to-date such that any changes on a branch after the last branch point or this tag (which ever comes later) do not change any IDL files.

Friday, December 5, 2008

Debugging palmsync

Also known as "An Exercise in Frustration and Self-Torture." As part of preliminary work for mailing list sanity, I need to make some changes to palmsync. It's not like I haven't changed this code before, but the work I need to do here is more than a simple s/a/b/g command. So, time to fire up the 'ole Windows partition and test.

Pain point number one: trying to get necessary stuff to work. First you need the Palm CDK. After getting that (complete with throw-away email account), you now need something to test the other end of palmsync—the PDA. Back at home, I have a monstrously old PDA whose functioning I would not guarantee. Fortunately, there's a nice palm emulator which I can install.

Now I just needed to Hotsync. Another non-trivial task, as my computer does not have two serial ports between which I could slap a cable (it doesn't even have one serial port…). After figuring that part out comes another problem. The palmsync failed to register. "No problem," I say, "I'll just reinstall it." And it still fails. Turns out that the necessary registry key used %ProgramFiles%. Don't you just love the registry?

That's all set up, so I click the sync button and… it fails. That wouldn't seem to be a problem, as I've already had to diagnose many errors to get to this point. Except I seem to have hit the critical unsupported limit:

  • I'm using a custom-built version of a program (that's really not saying much, though)
  • Said program is built with a technically unsupported compiler (VC 7.1)…
  • …which is unsupported on my OS (Windows Vista)…
  • …using and old SDK (Windows 2000)…
  • …and it's a 32-bit on a 64-bit machine.
  • The emulator officially supports neither Vista…
  • …nor a 64-bit machine.
  • Hotsync doesn't officially support the 64-bit machine either.

Debugging this proved to be a pain. The conduit logs didn't seem to function. Trying to get the VS debugger's nose in there proved a futile task until I did a world rebuild. Which takes 5.5 hours on my system (blame ext3). I finally got the debugger in, only to find a barrier thanks to COM. Some more work managed to shove the debugger in there and finally allowed me to pinpoint the error. Sorry, errors. Suffice to say that it's a mess in there.

So how did I get palmsync under the debugger? First off, let me describe my VS setup: I have mailnews as a project in VS (an NMake project, to be precise), set up such that clicking the build button actually builds in the mailnews directory (thanks to some custom hacking around msys). Based off of some external documentation for debugging Palm conduits, I created a new configuration (called "Palmsync," imaginative little me) whose command ran the hotsync program with -ic as its sole argument. Popping that under the debugger the normal way in VS allowed me to break on Palm's side of the conduit. On the Mozilla side, debugging is done by firing up an instance of TB under the debugger like normal, initiating the hotsync, and breaking and debugging as normal.

Modulo the fact that palmsync is in reality extremely fragile and apparently too buggy to support my nearly-empty testing profiling, it works now. Time to fix some more old bugs solely to be able to get to the point where I can work on the preliminary work for mailing list sanity.

Friday, November 28, 2008

ABC (meme)

Everyone's doing this, it seems.

A
ActiveSync
B
Bug 71728
C
CSS 2.1 spec
D
Pork (on MDC)
E
Hiragana (Wikipedia)
F
FailBlog
G
comp.lang.java.programmer
H
Hunter × Hunter (manga)
I
I can has cheezburger?
J
Java Language Specification, Third Edition
K
OpenJDK
L
I can has cheezburger?
M
[ School resource ]
N
[ School resource ]
O
Bleach (manga)
P
Planet Mozilla
Q
Questionable Content (webcomic)
R
[ Anime video site ]
S
/. (Slashdot)
T
[ School resource ]
U
BOFH (web... column)
V
VGCats (webcomic)
W
Worse Than Failure
X
XKCD (webcomic)
Y
YouTube (specifically, part of a walkthrough for Golden Sun)
Z
Zero Punctation (web video columnist)

A public service announcement

If you are a programmer who is writing code that will be released to the world as open source, this announcement is for you.

If your code will be seen by the world at large, one of your first tasks should be to write documentation. Document all functions as soon as you write them (before is also helpful). Provide samples on how to use code as soon as you finish a module (or earlier, if possible). Do not wait until your 5.0 release. Do not wait until your 1.0 release. Do not even wait until your 0.5 release. Do it as you write your code. The sooner, the better.

Users of your code will thank you profusely if you manage to provide comprehensive documentation along with the actual binaries of reference builds. DO NOT make them have to scour source code or bug developers in IRC channels to figure out a simple task like "get all cards from an address book" or "how do I write a synchronization conduit?"

Wednesday, November 5, 2008

Why I bemoan Tuesday

On Tuesday, November 4, the United States held its presidential and congressional elections. As I am sure most of my readers know by now, the outcome was to elect the Democratic nominee, Obama, as well as increase Democratic gains in the House and Senate (although probably not filibuster-proof). To many, this news was greeted with elation; I do not count myself as one of those people. Let me explain why.

First and foremost, I dislike the results because the United States missed out on an opportune time to make up for its polarization. A Republican presidential victory would leave the government divided, a prospect I feel would be ideal for the government. In lieu of a true multiparty system, we have two major parties who will, by necessary of definition, tend to stake opposite sides of issues and, furthermore, stake them at opposite ends of the spectrum. Giving the entire government solely to one party—actually more, giving it to one with strong enough majorities to evade some mild dissenters—would have the effect of hindering debate.

During the Constitutional Convention, one issue that the drafters considered was the tyranny of the majority. One of the Federalist papers, No. 10, dealt with this topic, mostly by the argument that a larger region would have more diverse parties. However, the two-party system (among other factors) tends to dilute the power of size; another mechanism should be present.

This second mechanism is the tortuous process of law creation. A common criticism of Congress is that it is slow to act. Yet why should lack of speed of action be a bad thing? If one wishes to expedite a bill, one has to cut something out. Almost all of the time it takes to pass a bill is spent on debate. So improving Congress's reaction time would mean that one has to debate less and therefore rely on the bill being correct as it is. We don't regret any rushed actions, do we?

A divided government would force moderation as the Democrats would not have enough votes to override a Republican veto, so a bill would have to amenable to both (and therefore moderate in effect) to pass. With a Democratic president, the extreme positions could show up in laws more easily without general discourse. The large gains in Congress give the Democrats more ability to cut off dissent; thankfully, though, the Senate looks to not be filibuster-proof.

I have discussed enough on the theory of divided government; I also support the Republican candidate on several issues. On social issues I vary between whether or not I agree with McCain, but I do not base my decision on these. Chiefly this is because I think the president has no real power to enforce these opinions on a national level or even be able to have one of these opinions enter into law.

The primary issues I concern myself are more economic in nature. I am an ardent supporter of free trades and no economic subsidies (especially agricultural ones). In terms of policies such as energy, I opine that the government should not favor one alternative over another in terms of, say, research funding, as history has shown the government to be bad at picking winners.

A more generalized position I hold is that I am not in favor of socializing certain fields. One such field is health care; the issue I have here is not one of universal versus non-universal health care but one of privatized versus socialized health care. I am skeptical of claims that socialized (as opposed to privatized) health care would control costs or make health care more efficient. All studies I have seen compare across countries without accounting for factors that would vary between countries.

Another problem with socialization is that government needs restraint. Historically, governments have shown much delight in stealing from funds to pay for general costs, such as Argentina's pension system. Indeed, the United States is quite guilty of this, as our budgetary deficits are partially ameliorated by taking funds from the Social Security Trust.

The final issue I am concerned about is that of regulation. The recent economic and financial crisis has renewed a call for increased regulation. Lack of regulation played little part in the causes of this crisis. In fact, the entire mess started with the mortgage industry, which is the most regulated financial industry. Similarly, calls for caps on executive wages and windfall taxes have increased, both of which are known to discourage innovation. Note how many major oil producers with nationalized oil companies (like Venezuela) are facing problems maintaining output.

On all of this issues, Obama's policies are in clash with my views. He has called to renegotiate NAFTA, create a single-payer health system, enact windfall taxes, and, naturally, called McCain out on supporting deregulation. At least McCain is candid that the economy is his weak point.

And, most importantly of all, he would likely be able to rush his ideas to completion with less discussion. Oh well, we won't get another National Recovery Administration… I hope.

Tuesday, October 28, 2008

Fakeserver

As of 8:18:19 PDT, comm-central now has a mostly-complete (but definitely usable) implementation of an IMAP fakeserver. This means we now have at least partial implementations of all 4 major mailnews protocols: POP, NNTP, IMAP, and SMTP.

Saturday, October 25, 2008

Synchronization

Since my original plan for mailing list sanity was upset by an underestimation of the insanity, I looked into fixing it in the various components. One place where this happened was in palm sync code. This code is so perilous I wouldn't be surprised to find that it broke somewhere along the line. As happens a lot, though, I got a little sidetracked. I tried to sit down and actually figure out what the heck goes on in there.

Like every other time I forayed into this code, I started thinking about how to improve it. What this code most needs is to be generic; there are bugs for adding support for SyncML, ActiveSync, OpenSync, BlackBerries, and even N-Gage devices. There are a few more bugs not citing a specific protocol or device; surprisingly, though, there are no bugs on supporting Microsoft's or Apple's synchronization APIs, as well as iSync. One might also consider something like Google Contacts to be a synchronization architecture.

In short, for Thunderbird and SeaMonkey to support most devices, they need to bridge at least six different APIs. So how can this be done? Fortunately, there are basic steps that need to be done that are common between them: registration, getting the data from the handheld and locally, resolving conflicts, and pushing between them. The primary differences I could find (aside from exact API semantics) were that some APIs requested changes from the applications (calling back when there were conflicts) while others just dumped handles to everything on the application and let the application figure it out.

How could these functions be abstracted from an API point of view? Here's a rough interface:

interface mozIExternalSynchronizer : nsISupports {
   /** The name that one would see in a dialog to enable/disable. */
   readonly attribute nsAUTF8String displayName;
   /** True if the OS sync manager will grab the changes. */
   readonly attribute boolean wantsChanges;
   /** Register this with the appropriate OS sync manager. */
   void enable();
   /** Unregister this with the appropriate OS sync manager. */
   void disable();
   /** Push a set of changes. (Called only if wantsChanges is true) */
   void pushChanges(in nsISimpleEnumerator changes);
   /** Get the records from the other end. (Called only if wantsChanges is false) */
   nsISimpleEnumerator getOtherRecords();
}

Hmm... if we can mostly abstract away the main sync manager stuff, why not abstract the other part? After all, if we're already doing work to synchronize the address book, it's not a large jump to synchronize calendars as well. And who knows what extension developers may be interested in synchronizing? The managers already abstract over various types; we would only need to provide a common glue over this.

Such a feature would need interfaces for defining what could be synchronized (and UI for doing those separately). I don't have these planned out (I need to look more at the APIs, an endeavor I do not have sufficient time for yet). One thing is certain, though: with these changes, Mozilla could add "cross-platform synchronization manager" to its list of features. Indeed, though my main impetus comes from mailnews's current palm sync feature, it does not need to be specific to Thunderbird and SeaMonkey.