Commit 668048c3 authored by Philipp Hörist's avatar Philipp Hörist

Contacts: Make is_groupchat a property

parent f828118f
......@@ -108,6 +108,10 @@ class CommonContact(XMPPEntity):
def is_pm_contact(self):
return self._is_pm_contact
@property
def is_groupchat(self):
return False
def get_full_jid(self):
raise NotImplementedError
......@@ -178,7 +182,7 @@ class Contact(CommonContact):
def get_shown_groups(self):
if self.is_observer():
return [_('Observers')]
if self.is_groupchat():
if self.is_groupchat:
return [_('Groupchats')]
if self.is_transport():
return [_('Transports')]
......@@ -211,6 +215,7 @@ class Contact(CommonContact):
is_observer = True
return is_observer
@property
def is_groupchat(self):
return self._is_groupchat
......@@ -524,7 +529,7 @@ class Contacts():
self._contacts = {}
def add_contact(self, contact):
if contact.jid not in self._contacts or contact.is_groupchat():
if contact.jid not in self._contacts or contact.is_groupchat:
self._contacts[contact.jid] = [contact]
return
contacts = self._contacts[contact.jid]
......@@ -591,7 +596,7 @@ class Contacts():
def get_groupchat_contact(self, jid):
if jid in self._contacts:
contacts = self._contacts[jid]
if contacts[0].is_groupchat():
if contacts[0].is_groupchat:
return contacts[0]
def get_avatar(self, jid, size, scale):
......@@ -630,7 +635,7 @@ class Contacts():
def get_contacts_jid_list(self):
return [jid for jid, contact in self._contacts.items() if not
contact[0].is_groupchat()]
contact[0].is_groupchat]
def get_contact_from_full_jid(self, fjid):
"""
......
......@@ -229,7 +229,7 @@ class Chatstate(BaseModule):
if self._get_chatstate_setting(contact) == 'disabled':
return None
if not contact.is_groupchat():
if not contact.is_groupchat:
# Dont send chatstates to ourself
if self._con.get_own_jid().bareMatch(contact.jid):
return None
......@@ -283,7 +283,7 @@ class Chatstate(BaseModule):
'jid': contact.jid,
'chatstate': str(State.ACTIVE)}
if contact.is_groupchat():
if contact.is_groupchat:
if contact.is_connected:
app.nec.push_outgoing_event(
GcMessageOutgoingEvent(None, **event_attrs))
......@@ -296,7 +296,7 @@ class Chatstate(BaseModule):
self._last_keyboard_activity.pop(contact.jid, None)
return
if not contact.is_groupchat():
if not contact.is_groupchat:
# Dont leak presence to contacts
# which are not allowed to see our status
if not contact.is_pm_contact:
......@@ -328,7 +328,7 @@ class Chatstate(BaseModule):
'jid': contact.jid,
'chatstate': str(state)}
if contact.is_groupchat():
if contact.is_groupchat:
if contact.is_connected:
app.nec.push_outgoing_event(
GcMessageOutgoingEvent(None, **event_attrs))
......@@ -355,7 +355,7 @@ class Chatstate(BaseModule):
@staticmethod
def _get_chatstate_setting(contact):
if contact.is_groupchat():
if contact.is_groupchat:
default = app.config.get('send_chatstate_muc_default')
return app.config.get_per(
'rooms', contact.jid, 'send_chatstate', default)
......
......@@ -145,7 +145,7 @@ class SingleMessageWindow(Gtk.ApplicationWindow):
if not c:
# Groupchat is maybe already destroyed
return
if c.is_groupchat() and self.from_whom not in \
if c.is_groupchat and self.from_whom not in \
app.interface.minimized_controls[self.account] and self.action == \
'receive' and app.events.get_nb_roster_events(self.account,
self.from_whom, types=['chat', 'normal']) == 0:
......
......@@ -1591,7 +1591,7 @@ class Interface:
"""
if app.contacts.get_contact(account, room_jid) and \
not app.contacts.get_contact(account, room_jid).is_groupchat():
not app.contacts.get_contact(account, room_jid).is_groupchat:
ErrorDialog(
_('This is not a group chat'),
_('%(room_jid)s is already in your roster. Please check '
......
......@@ -424,7 +424,7 @@ class RosterWindow:
if contact.is_transport():
typestr = 'agent'
elif contact.is_groupchat():
elif contact.is_groupchat:
typestr = 'groupchat'
else:
typestr = 'contact'
......@@ -836,7 +836,7 @@ class RosterWindow:
Remove groupchat from roster and redraw account and group
"""
contact = app.contacts.get_contact_with_highest_priority(account, jid)
if contact.is_groupchat():
if contact.is_groupchat:
if jid in app.interface.minimized_controls[account]:
del app.interface.minimized_controls[account][jid]
self.remove_contact(jid, account, force=True, backend=True, maximize=maximize)
......@@ -2179,7 +2179,7 @@ class RosterWindow:
keep_pep = any(c.show not in ('error', 'offline') for c in
contact_instances)
if not keep_pep and contact.jid != app.get_jid_from_account(account) \
and not contact.is_groupchat():
and not contact.is_groupchat:
self.delete_pep(contact.jid, account)
# Redraw everything and select the sender
......@@ -3622,7 +3622,7 @@ class RosterWindow:
resource = None
contact = app.contacts.get_contact_with_highest_priority(account, jid)
titer = model.get_iter(path)
if contact.is_groupchat():
if contact.is_groupchat:
first_ev = app.events.get_first_event(account, jid)
if first_ev and self.open_event(account, jid, first_ev):
# We are invited to a GC
......
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