Commit a5c13198 authored by Philipp Hörist's avatar Philipp Hörist

MUC: Store service jid in MUC module

- light refactoring of code which uses the service jid
parent d4053801
......@@ -598,8 +598,6 @@ def get_name_from_jid(account, jid):
actor = jid
return actor
def get_muc_domain(account):
return connections[account].muc_jid.get('jabber', None)
def get_recent_groupchats(account):
recent_groupchats = config.get_per(
......
......@@ -114,7 +114,6 @@ class CommonConnection:
self.roster_supported = True
self.avatar_conversion = False
self.muc_jid = {} # jid of muc server for each transport type
self._stun_servers = [] # STUN servers of our jabber server
# Tracks the calls of the connect_machine() method
......
......@@ -117,6 +117,15 @@ class MUC(BaseModule):
self._rejoin_muc = set()
self._join_timeouts = {}
self._rejoin_timeouts = {}
self._muc_service_jid = None
@property
def supported(self):
return self._muc_service_jid is not None
@property
def service_jid(self):
return self._muc_service_jid
def get_manager(self):
return self._manager
......@@ -129,8 +138,7 @@ class MUC(BaseModule):
continue
if nbxmpp.NS_MUC in info.features:
self._log.info('Discovered MUC: %s', info.jid)
# TODO: make this nicer
self._con.muc_jid['jabber'] = str(info.jid)
self._muc_service_jid = info.jid
raise nbxmpp.NodeProcessed
def join(self, muc_data):
......
......@@ -61,6 +61,10 @@ class CreateGroupchatWindow(Gtk.ApplicationWindow):
self.show_all()
self.set_focus(self._ui.address_entry)
def _get_muc_service_jid(self):
con = app.connections[self._account]
return str(con.get_module('MUC').service_jid or 'muc.example.com')
def _fill_account_combo(self, account):
accounts = app.get_enabled_accounts_with_labels(connected_only=True)
account_liststore = self._ui.account_combo.get_model()
......@@ -91,7 +95,7 @@ class CreateGroupchatWindow(Gtk.ApplicationWindow):
def _fill_placeholders(self):
placeholder = random.choice(MUC_CREATION_EXAMPLES)
server = app.get_muc_domain(self._account) or 'muc.example.com'
server = self._get_muc_service_jid()
self._ui.name_entry.set_placeholder_text(
placeholder[0] + _(' (optional)...'))
......@@ -116,7 +120,7 @@ class CreateGroupchatWindow(Gtk.ApplicationWindow):
model = entry.get_completion().get_model()
model.clear()
server = app.get_muc_domain(self._account) or 'muc.example.com'
server = self._get_muc_service_jid()
model.append(['%s@%s' % (text, server)])
def _validate_jid(self, text):
......
......@@ -283,7 +283,8 @@ class ServerInfo(Gtk.ApplicationWindow, EventHelper):
return [
Feature('XEP-0016: Privacy Lists',
con.get_module('PrivacyLists').supported),
Feature('XEP-0045: Multi-User Chat', con.muc_jid),
Feature('XEP-0045: Multi-User Chat',
con.get_module('MUC').supported),
Feature('XEP-0054: vcard-temp',
con.get_module('VCardTemp').supported),
Feature('XEP-0163: Personal Eventing Protocol',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment