Robert J. Accettura
2004-01-25 02:16:24 UTC
I just got a vx6000, and being a mozilla advocate, and cronic tester, I
want to see Mozilla sync!
So I sent a few IM's, and got some info for you all, perhaps to start
with. It's not perfect, but it's a start.
It is all below, some commentary, and some code. Hopefully someone can
make use of it Would make quite a feature.
Here's some sample python code I wrote that shows basically what you
have to do:
from xpcom import components
import xpcom.components
------------------------------------------------------
dirServiceClass =
components.classes["@mozilla.org/file/directory_service;1"]
dirService = dirServiceClass.getService(components.interfaces.nsIProperties)
messengerClass = components.classes["@mozilla.org/messenger;1"]
appShellClass =
components.classes["@mozilla.org/appshell/appShellService;1"]
# need to get the IID of nsIFile
file = dirService.get("MozBinD", components.interfaces.nsIFile)
dirService.set("ProfD", file)
file.append("prefs.js")
dirService.set("PrefF", file)
# acctMgr =
components.classes["@mozilla.org/messenger/account-manager;1"].getService(components.interfaces.nsIMsgAccountManager)
# do I need to do this? shouldn't it just happen?
prefsservice = components.classes["@mozilla.org/preferences-service;1"]
prefs = prefsservice.getService(components.interfaces.nsIPrefService)
prefs.readUserPrefs(None)
cls = components.classes["@mozilla.org/messenger/account-manager;1"]
acctMgr = cls.getService(components.interfaces.nsIMsgAccountManager)
# nsIMsgAccountManager defines accounts - getting them will load the
accounts
accounts = acctMgr.accounts
print "%d accounts" % accounts.Count()
for i in range(accounts.Count()):
account = accounts.QueryElementAt(i, components.interfaces.nsIMsgAccount)
print i, account.key
defaultServer = acctMgr.defaultAccount.incomingServer
------------------------------------------------------
then, you'd get create an AB from a uri
then, open the db on the ab, and enumerate the card
it's not that bad, actually - the only trick is getting the profile to load
ok. now that I remember, that code doesn't actually use the mozilla
profile, but a special profile
from xpcom import components
------------------------------------------------------
import xpcom.components
messengerClass = components.classes["@mozilla.org/messenger;1"]
cls = components.classes["@mozilla.org/messenger/account-manager;1"]
acctMgr = cls.getService(components.interfaces.nsIMsgAccountManager)
# nsIMsgAccountManager defines accounts - getting them will load the
accounts
accounts = acctMgr.accounts
print "%d accounts" % accounts.Count()
for i in range(accounts.Count()):
account = accounts.QueryElementAt(i, components.interfaces.nsIMsgAccount)
print i, account.key
------------------------------------------------------
that's just some sample code. But you do need to load the right profile...
and I don't quite know how to do that off the top of my head.
want to see Mozilla sync!
So I sent a few IM's, and got some info for you all, perhaps to start
with. It's not perfect, but it's a start.
It is all below, some commentary, and some code. Hopefully someone can
make use of it Would make quite a feature.
Here's some sample python code I wrote that shows basically what you
have to do:
from xpcom import components
import xpcom.components
------------------------------------------------------
dirServiceClass =
components.classes["@mozilla.org/file/directory_service;1"]
dirService = dirServiceClass.getService(components.interfaces.nsIProperties)
messengerClass = components.classes["@mozilla.org/messenger;1"]
appShellClass =
components.classes["@mozilla.org/appshell/appShellService;1"]
# need to get the IID of nsIFile
file = dirService.get("MozBinD", components.interfaces.nsIFile)
dirService.set("ProfD", file)
file.append("prefs.js")
dirService.set("PrefF", file)
# acctMgr =
components.classes["@mozilla.org/messenger/account-manager;1"].getService(components.interfaces.nsIMsgAccountManager)
# do I need to do this? shouldn't it just happen?
prefsservice = components.classes["@mozilla.org/preferences-service;1"]
prefs = prefsservice.getService(components.interfaces.nsIPrefService)
prefs.readUserPrefs(None)
cls = components.classes["@mozilla.org/messenger/account-manager;1"]
acctMgr = cls.getService(components.interfaces.nsIMsgAccountManager)
# nsIMsgAccountManager defines accounts - getting them will load the
accounts
accounts = acctMgr.accounts
print "%d accounts" % accounts.Count()
for i in range(accounts.Count()):
account = accounts.QueryElementAt(i, components.interfaces.nsIMsgAccount)
print i, account.key
defaultServer = acctMgr.defaultAccount.incomingServer
------------------------------------------------------
then, you'd get create an AB from a uri
then, open the db on the ab, and enumerate the card
it's not that bad, actually - the only trick is getting the profile to load
ok. now that I remember, that code doesn't actually use the mozilla
profile, but a special profile
from xpcom import components
------------------------------------------------------
import xpcom.components
messengerClass = components.classes["@mozilla.org/messenger;1"]
cls = components.classes["@mozilla.org/messenger/account-manager;1"]
acctMgr = cls.getService(components.interfaces.nsIMsgAccountManager)
# nsIMsgAccountManager defines accounts - getting them will load the
accounts
accounts = acctMgr.accounts
print "%d accounts" % accounts.Count()
for i in range(accounts.Count()):
account = accounts.QueryElementAt(i, components.interfaces.nsIMsgAccount)
print i, account.key
------------------------------------------------------
that's just some sample code. But you do need to load the right profile...
and I don't quite know how to do that off the top of my head.
--
Robert J. Accettura
***@accettura.com
Robert J. Accettura
***@accettura.com