diff sat.tac @ 89:23caf1051099

multi-profile/subscription misc fixes
author Goffi <goffi@goffi.org>
date Thu, 13 May 2010 16:27:48 +0930
parents db0a0f000e37
children 4020931569b8
line wrap: on
line diff
--- a/sat.tac	Wed May 12 11:55:18 2010 +0930
+++ b/sat.tac	Thu May 13 16:27:48 2010 +0930
@@ -382,16 +382,14 @@
     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 @@
         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)