database integration: first draft

- using SQLite as backend

/!\ Not finished yet, break execution. SàT CAN'T LAUNCH PROPERLY IN THE CURRENT STATE
This commit is contained in:
Goffi 2011-10-30 23:13:40 +01:00
commit 1982eb79d8
4 changed files with 235 additions and 72 deletions

View file

@ -112,7 +112,6 @@ class SAT(service.Service):
self.trigger = TriggerManager() #trigger are used to change SàT behaviour
self.bridge=DBusBridge()
self.bridge.register("getVersion", lambda: self.get_const('client_version'))
self.bridge.register("getProfileName", self.memory.getProfileName)
@ -148,7 +147,12 @@ class SAT(service.Service):
self.bridge.register("getMenus", self.getMenus)
self.bridge.register("getMenuHelp", self.getMenuHelp)
self.bridge.register("callMenu", self.callMenu)
self.memory.initialized.addCallback(self._postMemoryInit)
def _postMemoryInit(self, ignore):
"""Method called after memory initialization is done"""
info(_("Memory initialised"))
self._import_plugins()
@ -156,8 +160,8 @@ class SAT(service.Service):
"""Import all plugins found in plugins directory"""
import sat.plugins
plugins_path = os.path.dirname(sat.plugins.__file__)
plug_lst = [os.path.splitext(plugin)[0] for plugin in map(os.path.basename,glob (os.path.join(plugins_path,"plugin*.py")))]
__plugins_to_import = {} #plugins will still have to import
plug_lst = [os.path.splitext(plugin)[0] for plugin in map(os.path.basename,glob(os.path.join(plugins_path,"plugin*.py")))]
__plugins_to_import = {} #plugins we still have to import
for plug in plug_lst:
plugin_path = 'sat.plugins.'+plug
__import__(plugin_path)
@ -215,37 +219,44 @@ class SAT(service.Service):
if callback:
callback()
return
current = self.profiles[profile] = xmpp.SatXMPPClient(self, profile,
jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key = profile), profile),
self.memory.getParamA("Password", "Connection", profile_key = profile),
self.memory.getParamA("Server", "Connection", profile_key = profile), 5222)
if callback and errback:
current.getConnectionDeferred().addCallbacks(lambda x:callback(), errback)
def afterMemoryInit(ignore):
"""This part must be called when we have loaded individual parameters from memory"""
current = self.profiles[profile] = xmpp.SatXMPPClient(self, profile,
jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key = profile), profile),
self.memory.getParamA("Password", "Connection", profile_key = profile),
self.memory.getParamA("Server", "Connection", profile_key = profile), 5222)
current.messageProt = xmpp.SatMessageProtocol(self)
current.messageProt.setHandlerParent(current)
current.roster = xmpp.SatRosterProtocol(self)
current.roster.setHandlerParent(current)
if callback and errback:
current.getConnectionDeferred().addCallbacks(lambda x:callback(), errback)
current.presence = xmpp.SatPresenceProtocol(self)
current.presence.setHandlerParent(current)
current.messageProt = xmpp.SatMessageProtocol(self)
current.messageProt.setHandlerParent(current)
current.roster = xmpp.SatRosterProtocol(self)
current.roster.setHandlerParent(current)
current.fallBack = xmpp.SatFallbackHandler(self)
current.fallBack.setHandlerParent(current)
current.presence = xmpp.SatPresenceProtocol(self)
current.presence.setHandlerParent(current)
current.versionHandler = xmpp.SatVersionHandler(self.get_const('client_name'),
self.get_const('client_version'))
current.versionHandler.setHandlerParent(current)
current.fallBack = xmpp.SatFallbackHandler(self)
current.fallBack.setHandlerParent(current)
debug (_("setting plugins parents"))
for plugin in self.plugins.iteritems():
if plugin[1].is_handler:
plugin[1].getHandler(profile).setHandlerParent(current)
current.versionHandler = xmpp.SatVersionHandler(self.get_const('client_name'),
self.get_const('client_version'))
current.versionHandler.setHandlerParent(current)
current.startService()
debug (_("setting plugins parents"))
for plugin in self.plugins.iteritems():
if plugin[1].is_handler:
plugin[1].getHandler(profile).setHandlerParent(current)
current.startService()
params_defer = self.memory.loadIndividualParams(profile).addCallback(afterMemoryInit)
if errback:
params_defer.addErrback(errback)
def disconnect(self, profile_key):
"""disconnect from jabber server"""