multi-profile/subscription misc fixes

This commit is contained in:
Goffi 2010-05-13 16:27:48 +09:30
commit 6cfa6a1413
7 changed files with 21 additions and 23 deletions

View file

@ -281,9 +281,9 @@ class QuickApp():
# this is a subscriptionn request, we have to ask for user confirmation
answer = self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.short, _('Subscription confirmation'), 'yes/no')
if answer:
self.bridge.subscription("subscribed", entity.short)
self.bridge.subscription("subscribed", entity.short, profile_key = profile)
else:
self.bridge.subscribed("unsubscribed", entity.short)
self.bridge.subscription("unsubscribed", entity.short, profile_key = profile)
def showDialog(self, message, title, type="info"):
raise NotImplementedError

View file

@ -118,6 +118,7 @@ class MainWindow(wx.Frame, QuickApp):
def plug_profile(self, profile_key='@DEFAULT@'):
"""Hide profile panel then plug profile"""
debug (_('plugin profile %s' % profile_key))
self.profile_pan.Hide()
self.contactList.Show()
self.sizer.Layout()
@ -330,7 +331,7 @@ class MainWindow(wx.Frame, QuickApp):
def __updateStatus(self):
show = filter(lambda x:x[1] == self.statusBox.GetValue(), const_STATUS)[0][0]
status = self.statusTxt.GetValue()
self.bridge.setPresence(show=show, statuses={'default':status}) #FIXME: manage multilingual statuses
self.bridge.setPresence(show=show, statuses={'default':status}, profile_key=self.profile) #FIXME: manage multilingual statuses
def onStatusChange(self, e):
debug(_("Status change request"))
@ -352,7 +353,7 @@ class MainWindow(wx.Frame, QuickApp):
if dlg.ShowModal() == wx.ID_OK:
jid=JID(dlg.GetValue())
if jid.is_valid():
self.bridge.addContact(jid.short)
self.bridge.addContact(jid.short, profile_key=self.profile)
else:
error (_("'%s' is an invalid JID !"), jid)
#TODO: notice the user
@ -378,7 +379,7 @@ class MainWindow(wx.Frame, QuickApp):
if dlg.ShowModal() == wx.ID_YES:
info(_("Unsubscribing %s presence"), target.short)
self.bridge.delContact(target.short)
self.bridge.delContact(target.short, profile_key=self.profile)
dlg.Destroy()
@ -393,7 +394,7 @@ class MainWindow(wx.Frame, QuickApp):
dlg.ShowModal()
dlg.Destroy()
return
id = self.bridge.getCard(target.short)
id = self.bridge.getCard(target.short, profile_key=self.profile)
self.current_action_ids.add(id)
self.current_action_ids_cb[id] = self.onProfileReceived

View file

@ -57,7 +57,7 @@ class Param(wx.Frame):
panel=wx.Panel(self.notebook)
panel.sizer = wx.BoxSizer(wx.VERTICAL)
cat_dom = minidom.parseString(self.host.bridge.getParamsForCategory(category).encode('utf-8'))
cat_dom = minidom.parseString(self.host.bridge.getParamsForCategory(category, profile_key = self.host.profile).encode('utf-8'))
for param in cat_dom.documentElement.getElementsByTagName("param"):
name = param.getAttribute("name")
@ -115,7 +115,7 @@ class Param(wx.Frame):
def __save_parameters(self):
for param in self.modified:
self.host.bridge.setParam(param[0], self.modified[param], param[1])
self.host.bridge.setParam(param[0], self.modified[param], param[1], profile_key = self.host.profile)
self.modified.clear()
def onClose(self, event):

View file

@ -133,12 +133,12 @@ class ProfileManager(wx.Panel):
wx.MessageDialog(self, _("A profile name can't start with a @"), _("Bad profile name"), wx.ICON_ERROR).ShowModal()
return
profile = self.host.bridge.getProfileName(name)
if not profile:
debug(_("The profile is new, we create it"))
assert(profile)
old_jid = self.host.bridge.getParamA("JabberID", "Connection", profile_key=profile)
old_pass = self.host.bridge.getParamA("Password", "Connection", profile_key=profile)
new_jid = self.login_jid.GetValue()
new_pass = self.login_pass.GetValue()
print "old: %s, new: %s, old_pass: %s, new_pass: %s" % (old_jid, new_jid, old_pass, new_pass)
if old_jid != new_jid:
debug(_('Saving new JID and server'))
self.host.bridge.setParam("JabberID", new_jid, "Connection", profile)
@ -146,5 +146,5 @@ class ProfileManager(wx.Panel):
if old_pass != new_pass:
debug(_('Saving new password'))
self.host.bridge.setParam("Password", new_pass, "Connection", profile)
self.host.plug_profile(name)
self.host.plug_profile(profile)

View file

@ -102,7 +102,6 @@ class Tarot():
del(deck[:])
for player in players:
print "envoi de main a",player
self.host.sendMessage(room_jid+"/"+player, "/hand: %s" % str(hand[player]))
self.host.bridge.tarotGameNew(room_jid, hand[players[0]], profile)

18
sat.tac
View file

@ -382,16 +382,14 @@ class SAT(service.Service):
def connect(self, profile_key = '@DEFAULT@'):
"""Connect to jabber server"""
profile = self.memory.getProfileName(profile_key)
if not profile_key:
error (_('Trying to connect a non-exsitant profile'))
return
if (self.isConnected()):
if (self.isConnected(profile)):
info(_("already connected !"))
return
print "connecting..."
current = self.profiles[profile] = SatXMPPClient(self, profile,
jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key = profile_key), profile),
self.memory.getParamA("Password", "Connection", profile_key = profile_key),
@ -604,23 +602,23 @@ class SAT(service.Service):
to_jid = jid.JID(to) if to else None
self.profiles[profile].presence.available(to_jid, show, statuses, priority)
def subscription(self, type, raw_jid, profile_key='@DEFAULT@'):
def subscription(self, subs_type, raw_jid, profile_key='@DEFAULT@'):
"""Called to manage subscription"""
profile = self.memory.getProfileName(profile_key)
assert(profile)
to_jid = jid.JID(raw_jid)
debug (_('subsciption request [%(type)s] for %(jid)s') % {'type':type, 'jid':to_jid.full()})
if type=="subscribe":
debug (_('subsciption request [%(subs_type)s] for %(jid)s') % {'subs_type':subs_type, 'jid':to_jid.full()})
if subs_type=="subscribe":
self.profiles[profile].presence.subscribe(to_jid)
elif type=="subscribed":
self.profiles[profile].subscribed(to_jid)
elif subs_type=="subscribed":
self.profiles[profile].presence.subscribed(to_jid)
contact = self.memory.getContact(to_jid)
if not contact or not bool(contact['to']): #we automatically subscribe to 'to' presence
debug(_('sending automatic "to" subscription request'))
self.subscription('subscribe', to_jid.userhost())
elif type=="unsubscribe":
elif subs_type=="unsubscribe":
self.profiles[profile].presence.unsubscribe(to_jid)
elif type=="unsubscribed":
elif subs_type=="unsubscribed":
self.profiles[profile].presence.unsubscribed(to_jid)

View file

@ -138,7 +138,7 @@ class DbusObject(dbus.service.Object):
in_signature='s', out_signature='')
def connect(self, profile_key='@DEFAULT@'):
info ("Connection asked")
return self.cb["connect"]()
return self.cb["connect"](profile_key)
@dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
in_signature='s', out_signature='')