SàT: multi-profiles: somes fixes in core
This commit is contained in:
parent
714cf1ed2f
commit
7b520ddc93
2 changed files with 31 additions and 21 deletions
47
sat.tac
47
sat.tac
|
|
@ -413,13 +413,14 @@ class SAT(service.Service):
|
||||||
|
|
||||||
current.startService()
|
current.startService()
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self, profile_key='@DEFAULT@'):
|
||||||
"""disconnect from jabber server"""
|
"""disconnect from jabber server"""
|
||||||
if (not self.isConnected()):
|
if (not self.isConnected(profile_key)):
|
||||||
info("not connected !")
|
info("not connected !")
|
||||||
return
|
return
|
||||||
|
profile = self.memory.getProfileName(profile_key)
|
||||||
info("Disconnecting...")
|
info("Disconnecting...")
|
||||||
self.xmppclient.stopService()
|
self.profiles[profile].stopService()
|
||||||
|
|
||||||
def startService(self):
|
def startService(self):
|
||||||
info("Salut à toi ô mon frère !")
|
info("Salut à toi ô mon frère !")
|
||||||
|
|
@ -511,10 +512,10 @@ class SAT(service.Service):
|
||||||
|
|
||||||
## Client management ##
|
## Client management ##
|
||||||
|
|
||||||
def setParam(self, name, value, category):
|
def setParam(self, name, value, category, profile_key='@DEFAULT@'):
|
||||||
"""set wanted paramater and notice observers"""
|
"""set wanted paramater and notice observers"""
|
||||||
info ("setting param: %s=%s in category %s", name, value, category)
|
info ("setting param: %s=%s in category %s", name, value, category)
|
||||||
self.memory.setParam(name, value, category)
|
self.memory.setParam(name, value, category, profile_key)
|
||||||
|
|
||||||
def isConnected(self, profile_key='@DEFAULT@'):
|
def isConnected(self, profile_key='@DEFAULT@'):
|
||||||
"""Return connection status of profile
|
"""Return connection status of profile
|
||||||
|
|
@ -568,41 +569,49 @@ class SAT(service.Service):
|
||||||
self.bridge.newMessage(message['from'], unicode(msg), to=message['to']) #We send back the message, so all clients are aware of it
|
self.bridge.newMessage(message['from'], unicode(msg), to=message['to']) #We send back the message, so all clients are aware of it
|
||||||
|
|
||||||
|
|
||||||
def setPresence(self, to="", show="", priority = 0, statuses={}):
|
def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'):
|
||||||
"""Send our presence information"""
|
"""Send our presence information"""
|
||||||
|
profile = self.memory.getProfileName(profile_key)
|
||||||
|
assert(profile)
|
||||||
to_jid = jid.JID(to) if to else None
|
to_jid = jid.JID(to) if to else None
|
||||||
self.presence.available(to_jid, show, statuses, priority)
|
self.profiles[profile].presence.available(to_jid, show, statuses, priority)
|
||||||
|
|
||||||
def subscription(self, type, raw_jid):
|
def subscription(self, type, raw_jid, profile_key='@DEFAULT@'):
|
||||||
"""Called to manage subscription"""
|
"""Called to manage subscription"""
|
||||||
|
profile = self.memory.getProfileName(profile_key)
|
||||||
|
assert(profile)
|
||||||
to_jid = jid.JID(raw_jid)
|
to_jid = jid.JID(raw_jid)
|
||||||
debug ('subsciption request [%s] for %s', type, to_jid.full())
|
debug ('subsciption request [%s] for %s', type, to_jid.full())
|
||||||
if type=="subscribe":
|
if type=="subscribe":
|
||||||
self.presence.subscribe(to_jid)
|
self.profiles[profile].presence.subscribe(to_jid)
|
||||||
elif type=="subscribed":
|
elif type=="subscribed":
|
||||||
self.presence.subscribed(to_jid)
|
self.profiles[profile].subscribed(to_jid)
|
||||||
contact = self.memory.getContact(to_jid)
|
contact = self.memory.getContact(to_jid)
|
||||||
if not contact or not bool(contact['to']): #we automatically subscribe to 'to' presence
|
if not contact or not bool(contact['to']): #we automatically subscribe to 'to' presence
|
||||||
debug('sending automatic "to" subscription request')
|
debug('sending automatic "to" subscription request')
|
||||||
self.subscription('subscribe', to_jid.userhost())
|
self.subscription('subscribe', to_jid.userhost())
|
||||||
elif type=="unsubscribe":
|
elif type=="unsubscribe":
|
||||||
self.presence.unsubscribe(to_jid)
|
self.profiles[profile].presence.unsubscribe(to_jid)
|
||||||
elif type=="unsubscribed":
|
elif type=="unsubscribed":
|
||||||
self.presence.unsubscribed(to_jid)
|
self.profiles[profile].presence.unsubscribed(to_jid)
|
||||||
|
|
||||||
|
|
||||||
def addContact(self, to):
|
def addContact(self, to, profile_key='@DEFAULT@'):
|
||||||
"""Add a contact in roster list"""
|
"""Add a contact in roster list"""
|
||||||
|
profile = self.memory.getProfileName(profile_key)
|
||||||
|
assert(profile)
|
||||||
to_jid=jid.JID(to)
|
to_jid=jid.JID(to)
|
||||||
self.roster.addItem(to_jid)
|
self.profiles[profile].roster.addItem(to_jid)
|
||||||
self.presence.subscribe(to_jid)
|
self.profiles[profile].presence.subscribe(to_jid)
|
||||||
|
|
||||||
def delContact(self, to):
|
def delContact(self, to, profile_key='@DEFAULT@'):
|
||||||
"""Remove contact from roster list"""
|
"""Remove contact from roster list"""
|
||||||
|
profile = self.memory.getProfileName(profile_key)
|
||||||
|
assert(profile)
|
||||||
to_jid=jid.JID(to)
|
to_jid=jid.JID(to)
|
||||||
self.roster.removeItem(to_jid)
|
self.profiles[profile].roster.removeItem(to_jid)
|
||||||
self.presence.unsubscribe(to_jid)
|
self.profiles[profile].presence.unsubscribe(to_jid)
|
||||||
self.bridge.contactDeleted(to)
|
self.profiles[profile].bridge.contactDeleted(to)
|
||||||
|
|
||||||
|
|
||||||
## callbacks ##
|
## callbacks ##
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ class Param():
|
||||||
import_node(self.dom.documentElement, src_dom.documentElement)
|
import_node(self.dom.documentElement, src_dom.documentElement)
|
||||||
|
|
||||||
def __default_ok(self, value, name, category):
|
def __default_ok(self, value, name, category):
|
||||||
|
#FIXME: gof: will not work with individual parameters
|
||||||
self.setParam(name, value, category) #FIXME: better to set param xml value ???
|
self.setParam(name, value, category) #FIXME: better to set param xml value ???
|
||||||
|
|
||||||
def __default_ko(self, failure, name, category):
|
def __default_ko(self, failure, name, category):
|
||||||
|
|
@ -561,8 +562,8 @@ class Memory:
|
||||||
def getParamsCategories(self):
|
def getParamsCategories(self):
|
||||||
return self.params.getParamsCategories()
|
return self.params.getParamsCategories()
|
||||||
|
|
||||||
def setParam(self, name, value, category):
|
def setParam(self, name, value, category, profile_key='@DEFAULT@'):
|
||||||
return self.params.setParam(name, value, category)
|
return self.params.setParam(name, value, category, profile_key)
|
||||||
|
|
||||||
def importParams(self, xml):
|
def importParams(self, xml):
|
||||||
return self.params.importParams(xml)
|
return self.params.importParams(xml)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue