comparison sat.tac @ 60:9764e027ecc0

SàT: multi-profile parameters, first draft - new bridge methods getProfilesList and createProfile - param xml now use two types: general and individual, general are common parameters, individual parameters are linked to profiles - indidual xml are constructed from param xml and saved values /!\ params values are not saved yet
author Goffi <goffi@goffi.org>
date Thu, 28 Jan 2010 02:32:27 +1100
parents d660d1e5cee4
children 93cb45a7420f
comparison
equal deleted inserted replaced
59:3e5abe3bbead 60:9764e027ecc0
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 CONST = { 22 CONST = {
23 'client_name' : u'SàT (Salut à toi)', 23 'client_name' : u'SàT (Salut à toi)',
24 'client_version' : u'0.0.2', #Please add 'D' at the end for dev versions 24 'client_version' : u'0.0.2D', #Please add 'D' at the end for dev versions
25 'local_dir' : '~/.sat' 25 'local_dir' : '~/.sat'
26 } 26 }
27 27
28 from twisted.application import internet, service 28 from twisted.application import internet, service
29 from twisted.internet import glib2reactor, protocol, task 29 from twisted.internet import glib2reactor, protocol, task
310 310
311 self.memory=Memory(self) 311 self.memory=Memory(self)
312 self.server_features=[] #XXX: temp dic, need to be transfered into self.memory in the future 312 self.server_features=[] #XXX: temp dic, need to be transfered into self.memory in the future
313 313
314 self.bridge=DBusBridge() 314 self.bridge=DBusBridge()
315 self.bridge.register("getProfilesList", self.memory.getProfilesList)
316 self.bridge.register("createProfile", self.memory.createProfile)
315 self.bridge.register("registerNewAccount", self.registerNewAccount) 317 self.bridge.register("registerNewAccount", self.registerNewAccount)
316 self.bridge.register("connect", self.connect) 318 self.bridge.register("connect", self.connect)
317 self.bridge.register("disconnect", self.disconnect) 319 self.bridge.register("disconnect", self.disconnect)
318 self.bridge.register("getContacts", self.memory.getContacts) 320 self.bridge.register("getContacts", self.memory.getContacts)
319 self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus) 321 self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus)
349 plug_info = mod.PLUGIN_INFO 351 plug_info = mod.PLUGIN_INFO
350 info ("importing plugin: %s", plug_info['name']) 352 info ("importing plugin: %s", plug_info['name'])
351 self.plugins[plug_info['import_name']] = getattr(mod, plug_info['main'])(self) 353 self.plugins[plug_info['import_name']] = getattr(mod, plug_info['main'])(self)
352 #TODO: test xmppclient presence and register handler parent 354 #TODO: test xmppclient presence and register handler parent
353 355
354 def connect(self): 356 def getJidFrProfile(self, profile):
357 """Return jid from source"""
358 if profile == "@DEFAULT@":
359 return jid.JID(self.memory.getParamA("JabberID", "Connection"))
360
361 def connect(self, profile = '@DEFAULT@'):
355 """Connect to jabber server""" 362 """Connect to jabber server"""
356 363
357 if (self.isConnected()): 364 if (self.isConnected()):
358 info("already connected !") 365 info("already connected !")
359 return 366 return
360 print "connecting..." 367 print "connecting..."
361 self.me = jid.JID(self.memory.getParamA("JabberID", "Connection")) 368 self.me = self.getJidFrProfile(profile)
362 self.xmppclient = SatXMPPClient(self.bridge, self.me, self.memory.getParamA("Password", "Connection"), 369 self.xmppclient = SatXMPPClient(self.bridge, self.me, self.memory.getParamA("Password", "Connection"),
363 self.memory.getParamA("Server", "Connection"), 5222) 370 self.memory.getParamA("Server", "Connection"), 5222)
364 self.xmppclient.streamInitialized = self.streamInitialized 371 self.xmppclient.streamInitialized = self.streamInitialized
365 372
366 self.messageProt = SatMessageProtocol(self) 373 self.messageProt = SatMessageProtocol(self)