Discussion:
[Bitpim-devel] Mozilla Sync
Robert J. Accettura
2004-01-25 02:16:24 UTC
Permalink
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.
--
Robert J. Accettura
***@accettura.com
Roger Binns
2004-01-25 05:18:34 UTC
Permalink
Post by Robert J. Accettura
I just got a vx6000, and being a mozilla advocate, and cronic tester, I
want to see Mozilla sync!
Note that sync is considerably harder than import/export.
Post by Robert J. Accettura
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.
BitPim is shipped as a binary distribution, just so that users don't have
to go through the hassle of installing Python and random bits of other
packages. It will take some investigation to ensure the license requirements
are appropriately met.

That said, do you have any pointers on how to actually get the stuff installed?
All I can find are source packages that have to be compiled and other fun
issues. I am also concerned about it being dependent on the version of
Mozilla installed.

Roger

Loading...