# HG changeset patch # User Goffi # Date 1472395768 -7200 # Node ID 286865bc013add7fa24f5cd481b9a50108487bf1 # Parent 7cac2d1a6f20906b335c1f2b9bdb6e47e2a6ab7f chat: joining MUC using header input is now working: in case of error, a simple log warning is used for now. TODO: need to display a proper notification diff -r 7cac2d1a6f20 -r 286865bc013a src/cagou/plugins/plugin_wid_chat.py --- a/src/cagou/plugins/plugin_wid_chat.py Sun Aug 28 16:11:07 2016 +0200 +++ b/src/cagou/plugins/plugin_wid_chat.py Sun Aug 28 16:49:28 2016 +0200 @@ -139,6 +139,23 @@ ) input_widget.text = '' + def _mucJoinCb(self, bare): + jid_ = jid.JID(bare) + self.changeWidget(jid_) + + def _mucJoinEb(self, failure): + log.warning(u"Can't join room: {}".format(failure)) + + def changeWidget(self, jid_): + """change current widget for a new one with given jid + + @param jid_(jid.JID): jid of the widget to create + """ + plugin_info = G.host.getPluginInfo(main=Chat) + factory = plugin_info['factory'] + G.host.switchWidget(self, factory(plugin_info, jid_, profiles=[self.profile])) + self.header_input.text = '' + def onHeaderInput(self): text = self.header_input.text.strip() try: @@ -152,13 +169,9 @@ def discoCb(disco): # TODO: check if plugin XEP-0045 is activated if "conference" in [i[0] for i in disco[1]]: - raise NotImplementedError(u"MUC not implemented yet") - # G.host.bridge.MUCJoin(unicode(jid_), "", "", self.profile) + G.host.bridge.mucJoin(unicode(jid_), "", "", self.profile, callback=self._mucJoinCb, errback=self._mucJoinEb) else: - plugin_info = G.host.getPluginInfo(main=Chat) - factory = plugin_info['factory'] - G.host.switchWidget(self, factory(plugin_info, jid_, profiles=[self.profile])) - self.header_input.text = '' + self.changeWidget(jid_) def discoEb(failure): log.warning(u"Disco failure, ignore this text: {}".format(failure))