Mercurial > libervia-web
diff src/browser/libervia_main.py @ 914:0c0551967bdf
server, browser: partial Libervia fix
Libervia was broken following the refactorings. This commit partially fixes it : Libervia is starting, avatar, blog and message are working again, but not everything is restablished yet.
following things have been fixed/changed:
- new dependency: shortuuid
- D-Bus bridge is working again
- fixed naming in several bridge methods
- register method changed to register_signal
- fixed Chat widget, which was not working anymore since the refactoring
- avatar now use avatarGet. Cache dir is accessible using a session specific uuid, to avoid cache leak (i.e. accessing cache of other profiles)
- server: new uuid attribute in session data
Browser code is not fully working yet, notably OTR and contact list are not fully fixed.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 26 Feb 2017 18:32:47 +0100 |
parents | 58f611481e6d |
children | 5d9f6d25c586 |
line wrap: on
line diff
--- a/src/browser/libervia_main.py Sun Aug 28 19:25:52 2016 +0200 +++ b/src/browser/libervia_main.py Sun Feb 26 18:32:47 2017 +0100 @@ -58,7 +58,6 @@ assert web_widget # XXX: just here to avoid pyflakes warning from sat_browser.constants import Const as C -import os.path try: @@ -79,7 +78,8 @@ def onModuleLoad(self): log.info("============ onModuleLoad ==============") self.bridge_signals = json.BridgeSignals(self) - QuickApp.__init__(self, json.BridgeCall, xmlui=xmlui) + QuickApp.__init__(self, json.BridgeCall, xmlui=xmlui, connect_bridge=False) + self.connectBridge() self._profile_plugged = False self.signals_cache[C.PROF_KEY_NONE] = [] self.panel = main_panel.MainPanel(self) @@ -93,7 +93,7 @@ DOM.addEventPreview(self) self.importPlugins() self._register = json.RegisterCall() - self._register.call('getMenus', self.gotMenus) + self._register.call('menusGet', self.gotMenus) self._register.call('registerParams', None) self._register.call('getSessionMetadata', self._getSessionMetadataCB) self.initialised = False @@ -170,7 +170,7 @@ else: callback = handler - self.bridge_signals.register(functionName, callback, with_profile=with_profile) + self.bridge_signals.register_signal(functionName, callback, with_profile=with_profile) def importPlugins(self): self.plugins = {} @@ -226,26 +226,16 @@ event.preventDefault() return True - # FIXME: must not call _entityDataUpdatedCb by itself - # should not get VCard, backend plugin must be fixed too def getAvatarURL(self, jid_): """Return avatar of a jid if in cache, else ask for it. @param jid_ (jid.JID): JID of the contact @return: the URL to the avatar (unicode) """ - assert isinstance(jid_, jid.JID) - contact_list = self.contact_list # pyjamas issue: need a temporary variable to call a property's method - avatar_hash = contact_list.getCache(jid_, 'avatar') - if avatar_hash is None: - # we set to empty string to avoid requesting vcard several times - contact_list.setCache(jid_, 'avatar', '') - # we have no value for avatar_hash, so we request the vcard - self.bridge.getCard(unicode(jid_), profile=C.PROF_KEY_NONE) - if not avatar_hash: - return C.DEFAULT_AVATAR_URL - ret = os.path.join(C.AVATARS_DIR, avatar_hash) - return ret + return self.getAvatar(jid_) or self.getDefaultAvatar() + + def getDefaultAvatar(self): + return C.DEFAULT_AVATAR_URL def registerWidget(self, wid): log.debug(u"Registering %s" % wid.getDebugName()) @@ -336,7 +326,7 @@ def _isConnectedCB(self, connected): if not connected: - self._register.call('asyncConnect', lambda x: self.logged()) + self._register.call('connect', lambda x: self.logged()) else: self.logged()