Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Thunderbird 3 Address Books

14 views
Skip to first unread message

Alan Lord (News)

unread,
Nov 16, 2009, 8:20:07 AM11/16/09
to
Hi,

I'm having a go at migrating a TB2 extension so it works with TB3. I've
managed to fix one set of functions by reading and hacking, but I am
stuck completely on the Address Book.

The extension offers a facility to import and export address books
to/from a CRM.

All I am trying to do to start with is to get a list of the address
books (Names and a URI) so I can display/select them in the UI.

Looking on this page: https://developer.mozilla.org/En/Address_Book_Examples

I have implemented the first function and got to this point

let abManager =
Components.classes["@mozilla.org/abmanager;1"].getService(Components.interfaces.nsIAbManager);


let allAddressBooks = abManager.directories;

while (allAddressBooks.hasMoreElements()) {
let addressBook = allAddressBooks.getNext();
if (addressBook instanceof Components.interfaces.nsIAbDirectory) {

But I am now completely stuck.

"addressBook" seems only to provide a funtion QueryInterface() but no
matter what I read I can't work out how to get two bits of information:

The Name and the URI (or some other kind of pointer) to each address
book the function is iterating through.

I've been looking at the interface descriptions but I don't understand
them really. How do I get information on this type of object?

http://mxr.mozilla.org/comm-central/source/mailnews/addrbook/public/nsIAbDirectory.idl


I'm sorry if this is a dumb question but it's the first time I've looked
at mozilla extensions & xul, and so am on a rather steep learning curve.

TIA

Al

Neil

unread,
Nov 16, 2009, 9:17:42 AM11/16/09
to
Alan Lord (News) wrote:

> let allAddressBooks = abManager.directories;
>
> while (allAddressBooks.hasMoreElements()) {
> let addressBook = allAddressBooks.getNext();
> if (addressBook instanceof Components.interfaces.nsIAbDirectory) {
>
> But I am now completely stuck.
>
> "addressBook" seems only to provide a funtion QueryInterface()

This is true immediately after the call to getNext, but if the
instanceof (or QueryInterface, which is what it calls) succeeds, then
all the properties listed in the document that you already linked to
become accessible.

--
Warning: May contain traces of nuts.

Alan Lord (News)

unread,
Nov 16, 2009, 9:29:03 AM11/16/09
to

Thanks, I am getting somewhere now. Perceverance is paying off, albeit
slowly.

When I examine the addressBook.URI property and I have three address
books in my profile I get the following output:

URI = moz-abmdbdirectory://abook.mab
URI = moz-abmdbdirectory://abook-1.mab
URI = moz-abmdbdirectory://history.mab

Which is fine. But I can't see where the real "names" of the address
books are kept. Can you point me in the right direction?

Thanks

Al

Neil

unread,
Nov 16, 2009, 9:41:20 AM11/16/09
to
Alan Lord (News) wrote:

> When I examine the addressBook.URI property and I have three address
> books in my profile I get the following output:
>
> URI = moz-abmdbdirectory://abook.mab
> URI = moz-abmdbdirectory://abook-1.mab
> URI = moz-abmdbdirectory://history.mab
>
> Which is fine. But I can't see where the real "names" of the address
> books are kept. Can you point me in the right direction?

.dirName perhaps?

Alan Lord (News)

unread,
Nov 17, 2009, 4:29:36 AM11/17/09
to

Duh - thanks.

I was sure I'd tried that earlier but your intervention seems to have
made it work ;-)

Thanks again.

Al

0 new messages