![]() |
Using the Account Manager APIBy Alec Flett alecf@netscape.comStructureThe account system consists of:
(You'll have to pardon the crude drawing for now)
Account Manager
+- Account 1
| +- Incoming Server 1 (imap.mywork.com IMAP Server, my work account)
| +- Identity 1 (Alec Flett <alecf@mywork.com>)
+- Account 2
| +- Incoming Server 2 (pop.myisp.com POP Server, my ISP account)
| +- Identity 2 (Alec Flett <alecf@myisp.com>)
+- Account 3
| +- Incoming Server 3 (news.myisp.com NNTP server, my ISP's server)
| +- Identity 3 (Alec Flett <alecfNOSPAM@myisp.com>)
+- Account 4
+- Incoming Server 4 (news.mozilla.org NNTP server, mozilla devel)
+- Identity 2 (Alec Flett <alecf@myisp.com>)
+- Identity 3 (Alec Flett <alecfNOSPAM@myisp.com>)
This is the internal structure that the mail client maintains, but it is presented to the user in a few different ways. (You may have noticed that Identities 2 and 3 are shared between a few accounts...more on that later) Server viewThis view is used in the folder pane, and in any place where the user must browse or choose folders, such as the new folder dialog, search, filters, etc. This view shows a flat, unified view of all the servers. The above example would look like this:
alecf on imap.mywork.com
+- INBOX
+- Trash
+- (etc)
alecf on pop.myisp.com
+- INBOX
+- Trash
+- (etc)
news.myisp.com
+- comp.os.linux.announce
+- etc..
news.mozilla.org
+- netscape.public.mozilla.announce
+- netscape.public.mozilla.mail-news
Relevant API calls:
Identity viewThis view gives a unified, uniquified list of all identities. If identities are shared between accounts, you will only see that identity once in the list. This view is used any time an identity needs to be chosen, such as when you choose an identity for the From header in the compose window.In the above example, the list of identities would be as follows:
Alec Flett <alecf@mywork.com>)
Alec Flett <alecf@myisp.com>)
Alec Flett <alecfNOSPAM@myisp.com>)
Relevant API calls:
StorageThe accounts are stored in the preferences. The accounts, identities, and servers are all linked via keys. Keys are simply internal strings that uniquely identify each account, identity and server. The keys are also used to decide the name of each of the preferences that hold the object's data. As an example, the above structure would be represented in your preferences like this:
user_pref("mail.accountmanager.accounts", "account1,account2,account3");
user_pref("mail.account.account1.server", "server1");
user_pref("mail.account.account1.identities", "id1");
user_pref("mail.account.account2.server", "server2");
user_pref("mail.account.account2.identities", "id3");
user_pref("mail.account.account3.server", "server3");
user_pref("mail.account.account3.identities", "id3");
user_pref("mail.account.account4.server", "server4");
user_pref("mail.account.account4.identities", "id2,id3");
user_pref("mail.server.server1.hostname", "imap.mywork.com");
user_pref("mail.server.server2.hostname", "pop.myisp.com");
user_pref("mail.server.server3.hostname", "news.myisp.com");
user_pref("mail.server.server4.hostname", "news.mozilla.org");
user_pref("mail.identity.id1.useremail", "alecf@mywork.com");
user_pref("mail.identity.id2.useremail", "alecf@myisp.com");
user_pref("mail.identity.id3.useremail", "alecfNOSPAM@myisp.com");
There is a lot of information missing here of course. The keys used here are the account1, server1, id1, etc. These keys are listed in the value of some of these preferences, such as "mail.accountmanager.accounts", and are used to construct the preference names, such as "mail.account.account1.server". This the way accounts know which server and which identities they contain. Account creation/deletionIt is possible to create and modify accounts through the account manager API. The account manager is responsible for the creation of all accounts, incoming servers, and identities. You should not use CreateInstance() to create any of the relevant objects because the account manager needs to keep track of all of these objects as they are created. Relevant API calls:
|
|||||||
| Copyright © 1998-1999 The Mozilla Organization. | |||||||