changeset 909:e8b133b77aa4

browser, server: update to get compatibility with 0.7-dev (not finished): Q&D update to restore compatibility - version changed to 0.7D - contact list has been modified to be compatible with changes, but it doesn't take profit of improvment yet - messageSend partially work, there is a disconnection and an error in console logs when sending a message - message are not received yet
author Goffi <goffi@goffi.org>
date Tue, 09 Aug 2016 01:07:15 +0200
parents f38b8be94131
children bc2082685234
files src/browser/libervia_main.py src/browser/sat_browser/chat.py src/browser/sat_browser/contact_list.py src/browser/sat_browser/contact_widget.py src/browser/sat_browser/json.py src/browser/sat_browser/plugin_sec_otr.py src/common/constants.py src/server/server.py
diffstat 8 files changed, 43 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/browser/libervia_main.py	Tue Aug 09 01:07:15 2016 +0200
@@ -366,10 +366,15 @@
     def profilePlugged(self, dummy):
         self._profile_plugged = True
         QuickApp.profilePlugged(self, C.PROF_KEY_NONE)
+        contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None, profile=C.PROF_KEY_NONE)
+        self.panel.addContactList(contact_list)
+
+        # FIXME: the contact list height has to be set manually the first time
+        self.resize()
+
         # XXX: as contact_list.update() is slow and it's called a lot of time
         #      during profile plugging, we prevent it before it's plugged
         #      and do all at once now
-        contact_list = self.contact_list
         contact_list.update()
 
         try:
@@ -404,16 +409,7 @@
 
         def gotDefaultMUC(default_muc):
             self.default_muc = default_muc
-        self.bridge.getDefaultMUC(profile=None, callback=gotDefaultMUC)
-
-    def addContactList(self, dummy):
-        contact_list = ContactList(self)
-        self.panel.addContactList(contact_list)
-
-        # FIXME: the contact list height has to be set manually the first time
-        self.resize()
-
-        return contact_list
+        self.bridge.mucGetDefaultService(profile=None, callback=gotDefaultMUC)
 
     def newWidget(self, wid):
         log.debug(u"newWidget: {}".format(wid))
--- a/src/browser/sat_browser/chat.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/browser/sat_browser/chat.py	Tue Aug 09 01:07:15 2016 +0200
@@ -162,9 +162,11 @@
         return ("ONE2ONE" if self.type == C.CHAT_ONE2ONE else "GROUP", msg)
 
     def onTextEntered(self, text):
-        self.host.sendMessage(self.target,
-                              text,
-                              mess_type=C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT,
+        self.host.messageSend(self.target,
+                              {'': text},
+                              {},
+                              C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT,
+                              {},
                               errback=self.host.sendError,
                               profile_key=C.PROF_KEY_NONE
                               )
--- a/src/browser/sat_browser/contact_list.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/browser/sat_browser/contact_list.py	Tue Aug 09 01:07:15 2016 +0200
@@ -63,7 +63,10 @@
         VerticalPanel.__init__(self)
         self.setStyleName('groupPanel')
         self._parent = parent
-        self._groups = set()
+
+    @property
+    def _groups(self):
+        return self._parent.contact_list._groups
 
     def add(self, group):
         if group in self._groups:
@@ -99,7 +102,7 @@
         return None
 
     def getGroups(self):
-        return self._groups
+        return set([g for g in self._groups if g is not None])
 
 
 class ContactTitleLabel(libervia_widget.DragLabel, Label, ClickHandler):
@@ -118,8 +121,9 @@
 class ContactList(SimplePanel, QuickContactList):
     """Manage the contacts and groups"""
 
-    def __init__(self, host):
+    def __init__(self, host, target, on_click=None, on_change=None, user_data=None, profiles=None):
         QuickContactList.__init__(self, host, C.PROF_KEY_NONE)
+        self.contact_list = self.host.contact_list
         SimplePanel.__init__(self)
         self.host = host
         self.scroll_panel = ScrollPanel()
@@ -146,6 +150,7 @@
         # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword)
         self.avatarListener = self.onAvatarUpdate
         host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE])
+        self.postInit()
 
     @property
     def profile(self):
@@ -155,13 +160,13 @@
         QuickContactList.onDelete(self)
         self.host.removeListener('avatar', self.avatarListener)
 
-    def update(self):
+    def update(self, entities=None, type_=None, profile=None):
         # XXX: as update is slow, we avoid many updates on profile plugs
         # and do them all at once at the end
-        if not self.host._profile_plugged:
+        if not self.host._profile_plugged:  # FIXME: should not be necessary anymore (done in QuickFrontend)
             return
         ### GROUPS ###
-        _keys = self._groups.keys()
+        _keys = self.contact_list._groups.keys()
         try:
             # XXX: Pyjamas doesn't do the set casting if None is present
             _keys.remove(None)
@@ -177,7 +182,7 @@
             self._group_panel.remove(group)
 
         ### JIDS ###
-        to_show = [jid_ for jid_ in self.roster_entities if self.entityToShow(jid_) and jid_ != self.whoami.bare]
+        to_show = [jid_ for jid_ in self.contact_list.roster if self.contact_list.entityToShow(jid_) and jid_ != self.contact_list.whoami.bare]
         to_show.sort()
 
         self._contacts_panel.setList(to_show)
@@ -197,7 +202,7 @@
         return False
 
     def getGroups(self):
-        return self.groups.keys()
+        return self._group_panel.getGroups()
 
     def onMouseMove(self, sender, x, y):
         pass
--- a/src/browser/sat_browser/contact_widget.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/browser/sat_browser/contact_widget.py	Tue Aug 09 01:07:15 2016 +0200
@@ -31,7 +31,6 @@
 import html_tools
 import base_widget
 import libervia_widget
-import contact_list
 
 unicode = str # XXX: pyjama doesn't manage unicode
 
@@ -57,7 +56,8 @@
 
     def update(self):
         clist = self.host.contact_list
-        alerts_count = clist.getAlerts(self.jid, use_bare_jid=not self.jid.resource)
+        notifs = list(self.host.getNotifs(self.jid, exact_jid=False, profile=C.PROF_KEY_NONE))
+        alerts_count = len(notifs)
         alert_html = ("<strong>(%i)</strong>&nbsp;" % alerts_count) if alerts_count else ""
 
         contact_raw = None
--- a/src/browser/sat_browser/json.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/browser/sat_browser/json.py	Tue Aug 09 01:07:15 2016 +0200
@@ -173,18 +173,18 @@
 class BridgeCall(LiberviaJsonProxy):
     def __init__(self):
         LiberviaJsonProxy.__init__(self, "/json_api",
-                        ["getContacts", "addContact", "sendMessage",
+                        ["getContacts", "addContact", "messageSend",
                          "psDeleteNode", "psRetractItem", "psRetractItems",
                          "mbSend", "mbRetract", "mbGet", "mbGetFromMany", "mbGetFromManyRTResult",
                          "mbGetFromManyWithComments", "mbGetFromManyWithCommentsRTResult",
-                         "getHistory", "getPresenceStatuses", "joinMUC", "mucLeave", "getRoomsJoined",
-                         "getRoomsSubjects", "inviteMUC", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady",
+                         "getHistory", "getPresenceStatuses", "joinMUC", "mucLeave", "mucGetRoomsJoined",
+                         "inviteMUC", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady",
                          "tarotGamePlayCards", "launchRadioCollective",
                          "getWaitingSub", "subscription", "delContact", "updateContact", "getCard",
                          "getEntityData", "getParamsUI", "asyncGetParamA", "setParam", "launchAction",
                          "disconnect", "chatStateComposing", "getNewAccountDomain", "confirmationAnswer",
                          "syntaxConvert", "getAccountDialogUI", "getMainResource", "getWaitingConf", "getEntitiesData",
-                         "getVersion", "getLiberviaVersion", "getDefaultMUC", "getFeatures",
+                         "getVersion", "getLiberviaVersion", "mucGetDefaultService", "getFeatures",
                         ])
 
     def __call__(self, *args, **kwargs):
--- a/src/browser/sat_browser/plugin_sec_otr.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/browser/sat_browser/plugin_sec_otr.py	Tue Aug 09 01:07:15 2016 +0200
@@ -388,7 +388,7 @@
         self.host = host
         self.context_manager = None
         self.host.bridge._registerMethods(["skipOTR"])
-        self.host.trigger.add("newMessageTrigger", self.newMessageTg, priority=trigger.TriggerManager.MAX_PRIORITY)
+        self.host.trigger.add("messageNewTrigger", self.newMessageTg, priority=trigger.TriggerManager.MAX_PRIORITY) # FIXME: need to be fixed after message refactoring
         self.host.trigger.add("sendMessageTrigger", self.sendMessageTg, priority=trigger.TriggerManager.MAX_PRIORITY)
 
         # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword)
--- a/src/common/constants.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/common/constants.py	Tue Aug 09 01:07:15 2016 +0200
@@ -25,7 +25,7 @@
 
     # XXX: we don't want to use the APP_VERSION inherited from sat.core.constants version
     #      as we use this version to check that there is not a mismatch with backend
-    APP_VERSION = u'0.6.1'  # Please add 'D' at the end for dev versions
+    APP_VERSION = u'0.7.0D'  # Please add 'D' at the end for dev versions
     LIBERVIA_MAIN_PAGE = "libervia.html"
 
     # MISC
--- a/src/server/server.py	Wed Jul 13 22:45:54 2016 +0200
+++ b/src/server/server.py	Tue Aug 09 01:07:15 2016 +0200
@@ -463,10 +463,10 @@
         profile = ISATSession(self.session).profile
         self.sat_host.bridge.setPresence('', presence, {'': status}, profile)
 
-    def jsonrpc_sendMessage(self, to_jid, msg, subject, type_, options={}):
+    def jsonrpc_messageSend(self, to_jid, msg, subject, type_, extra={}):
         """send message"""
         profile = ISATSession(self.session).profile
-        return self.asyncBridgeCall("sendMessage", to_jid, msg, subject, type_, options, profile)
+        return self.asyncBridgeCall("messageSend", to_jid, msg, subject, type_, extra, profile)
 
     ## PubSub ##
 
@@ -713,7 +713,7 @@
         d.addCallback(show)
         return d
 
-    def jsonrpc_joinMUC(self, room_jid, nick):
+    def jsonrpc_mucJoin(self, room_jid, nick):
         """Join a Multi-User Chat room
 
         @param room_jid (unicode): room JID or empty string to generate a unique name
@@ -744,19 +744,14 @@
             return
         self.sat_host.bridge.mucLeave(room_jid.userhost(), profile)
 
-    def jsonrpc_getRoomsJoined(self):
+    def jsonrpc_mucGetRoomsJoined(self):
         """Return list of room already joined by user"""
         profile = ISATSession(self.session).profile
-        return self.sat_host.bridge.getRoomsJoined(profile)
+        return self.sat_host.bridge.mucGetRoomsJoined(profile)
 
-    def jsonrpc_getRoomsSubjects(self):
-        """Return list of room subjects"""
-        profile = ISATSession(self.session).profile
-        return self.sat_host.bridge.getRoomsSubjects(profile)
-
-    def jsonrpc_getDefaultMUC(self):
+    def jsonrpc_mucGetDefaultService(self):
         """@return: the default MUC"""
-        d = self.asyncBridgeCall("getDefaultMUC")
+        d = self.asyncBridgeCall("mucGetDefaultService")
         return d
 
     def jsonrpc_launchTarotGame(self, other_players, room_jid=""):
@@ -1509,16 +1504,16 @@
             self.bridge.register("disconnected", self.signal_handler.disconnected)
             self.bridge.register("actionResult", self.action_handler.actionResultCb)
             #core
-            for signal_name in ['presenceUpdate', 'newMessage', 'subscribe', 'contactDeleted',
+            for signal_name in ['presenceUpdate', 'messageNew', 'subscribe', 'contactDeleted',
                                 'newContact', 'entityDataUpdated', 'askConfirmation', 'newAlert', 'paramUpdate']:
                 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name))
             # XXX: actionNew is handled separately because the handler must manage security_limit
             self.bridge.register('actionNew', self.signal_handler.actionNewHandler)
             #plugins
-            for signal_name in ['psEvent', 'roomJoined', 'roomUserJoined', 'roomUserLeft', 'tarotGameStarted', 'tarotGameNew', 'tarotGameChooseContrat',
+            for signal_name in ['psEvent', 'mucRoomJoined', 'tarotGameStarted', 'tarotGameNew', 'tarotGameChooseContrat',
                                 'tarotGameShowCards', 'tarotGameInvalidCards', 'tarotGameCardsPlayed', 'tarotGameYourTurn', 'tarotGameScore', 'tarotGamePlayers',
                                 'radiocolStarted', 'radiocolPreload', 'radiocolPlay', 'radiocolNoUpload', 'radiocolUploadOk', 'radiocolSongRejected', 'radiocolPlayers',
-                                'roomLeft', 'roomUserChangedNick', 'chatStateReceived']:
+                                'mucRoomLeft', 'mucRoomUserChangedNick', 'chatStateReceived']:
                 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name), "plugin")
             self.media_dir = self.bridge.getConfig('', 'media_dir')
             self.local_dir = self.bridge.getConfig('', 'local_dir')