changeset 163:b887186e8fc8

browser side: get entity's microblogs for newly added contacts
author Goffi <goffi@goffi.org>
date Mon, 07 Jan 2013 22:43:50 +0100
parents 6ebf7f872a38
children d3437b3c88bd
files browser_side/panels.py libervia.py
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/panels.py	Mon Jan 07 22:43:00 2013 +0100
+++ b/browser_side/panels.py	Mon Jan 07 22:43:50 2013 +0100
@@ -591,7 +591,7 @@
             self.accepted_groups.append(group)
 
     def isJidAccepted(self, jid):
-        """Tell if a jid is actepted and show in this panel
+        """Tell if a jid is actepted and shown in this panel
         @param jid: jid
         @return: True if the jid is accepted"""
         if self.accept_all():
--- a/libervia.py	Mon Jan 07 22:43:00 2013 +0100
+++ b/libervia.py	Mon Jan 07 22:43:50 2013 +0100
@@ -357,6 +357,14 @@
             _groups, mblog_entry = cache_entry 
             self.addBlogEntry(mblog_panel, self.whoami.bare, *cache_entry)
 
+    def getEntityMBlog(self, entity):
+        print "geting mblog for entity [%s]" % (entity,)
+        for lib_wid in self.libervia_widgets:
+            if isinstance(lib_wid, panels.MicroblogPanel):
+                if lib_wid.isJidAccepted(entity):
+                    self.bridge.call('getMassiveLastMblogs', lib_wid.massiveInsert, 'JID', [entity], 10)
+
+
     def _newMessageCb(self, from_jid, msg, msg_type, to_jid):
         _from = JID(from_jid)
         _to = JID(to_jid)
@@ -441,9 +449,11 @@
     def _subscribeCb(self, sub_type, entity):
         if sub_type == 'subscribed':
             dialog.InfoDialog('Subscription confirmation', 'The contact <b>%s</b> has added you to his/her contact list' % html_sanitize(entity)).show()
+            self.getEntityMBlog(entity)
 
         elif sub_type == 'unsubscribed':
             dialog.InfoDialog('Subscription refusal', 'The contact <b>%s</b> has refused to add you in his/her contact list' % html_sanitize(entity)).show()
+            #TODO: remove microblogs from panels
 
         elif sub_type == 'subscribe':
             #The user want to subscribe to our presence