Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
88:59f181e8433a | 89:23caf1051099 |
---|---|
380 #TODO: test xmppclient presence and register handler parent | 380 #TODO: test xmppclient presence and register handler parent |
381 | 381 |
382 def connect(self, profile_key = '@DEFAULT@'): | 382 def connect(self, profile_key = '@DEFAULT@'): |
383 """Connect to jabber server""" | 383 """Connect to jabber server""" |
384 | 384 |
385 | |
386 profile = self.memory.getProfileName(profile_key) | 385 profile = self.memory.getProfileName(profile_key) |
387 if not profile_key: | 386 if not profile_key: |
388 error (_('Trying to connect a non-exsitant profile')) | 387 error (_('Trying to connect a non-exsitant profile')) |
389 return | 388 return |
390 | 389 |
391 if (self.isConnected()): | 390 if (self.isConnected(profile)): |
392 info(_("already connected !")) | 391 info(_("already connected !")) |
393 return | 392 return |
394 print "connecting..." | |
395 current = self.profiles[profile] = SatXMPPClient(self, profile, | 393 current = self.profiles[profile] = SatXMPPClient(self, profile, |
396 jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key = profile_key), profile), | 394 jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key = profile_key), profile), |
397 self.memory.getParamA("Password", "Connection", profile_key = profile_key), | 395 self.memory.getParamA("Password", "Connection", profile_key = profile_key), |
398 self.memory.getParamA("Server", "Connection", profile_key = profile_key), 5222) | 396 self.memory.getParamA("Server", "Connection", profile_key = profile_key), 5222) |
399 | 397 |
602 profile = self.memory.getProfileName(profile_key) | 600 profile = self.memory.getProfileName(profile_key) |
603 assert(profile) | 601 assert(profile) |
604 to_jid = jid.JID(to) if to else None | 602 to_jid = jid.JID(to) if to else None |
605 self.profiles[profile].presence.available(to_jid, show, statuses, priority) | 603 self.profiles[profile].presence.available(to_jid, show, statuses, priority) |
606 | 604 |
607 def subscription(self, type, raw_jid, profile_key='@DEFAULT@'): | 605 def subscription(self, subs_type, raw_jid, profile_key='@DEFAULT@'): |
608 """Called to manage subscription""" | 606 """Called to manage subscription""" |
609 profile = self.memory.getProfileName(profile_key) | 607 profile = self.memory.getProfileName(profile_key) |
610 assert(profile) | 608 assert(profile) |
611 to_jid = jid.JID(raw_jid) | 609 to_jid = jid.JID(raw_jid) |
612 debug (_('subsciption request [%(type)s] for %(jid)s') % {'type':type, 'jid':to_jid.full()}) | 610 debug (_('subsciption request [%(subs_type)s] for %(jid)s') % {'subs_type':subs_type, 'jid':to_jid.full()}) |
613 if type=="subscribe": | 611 if subs_type=="subscribe": |
614 self.profiles[profile].presence.subscribe(to_jid) | 612 self.profiles[profile].presence.subscribe(to_jid) |
615 elif type=="subscribed": | 613 elif subs_type=="subscribed": |
616 self.profiles[profile].subscribed(to_jid) | 614 self.profiles[profile].presence.subscribed(to_jid) |
617 contact = self.memory.getContact(to_jid) | 615 contact = self.memory.getContact(to_jid) |
618 if not contact or not bool(contact['to']): #we automatically subscribe to 'to' presence | 616 if not contact or not bool(contact['to']): #we automatically subscribe to 'to' presence |
619 debug(_('sending automatic "to" subscription request')) | 617 debug(_('sending automatic "to" subscription request')) |
620 self.subscription('subscribe', to_jid.userhost()) | 618 self.subscription('subscribe', to_jid.userhost()) |
621 elif type=="unsubscribe": | 619 elif subs_type=="unsubscribe": |
622 self.profiles[profile].presence.unsubscribe(to_jid) | 620 self.profiles[profile].presence.unsubscribe(to_jid) |
623 elif type=="unsubscribed": | 621 elif subs_type=="unsubscribed": |
624 self.profiles[profile].presence.unsubscribed(to_jid) | 622 self.profiles[profile].presence.unsubscribed(to_jid) |
625 | 623 |
626 | 624 |
627 def addContact(self, to, profile_key='@DEFAULT@'): | 625 def addContact(self, to, profile_key='@DEFAULT@'): |
628 """Add a contact in roster list""" | 626 """Add a contact in roster list""" |