Esempio n. 1
0
    def set_from_disco_info(self, info):
        self._info = info
        # Set name
        if self._account is None:
            name = info.muc_name
        else:
            con = app.connections[self._account]
            name = get_groupchat_name(con, info.jid)
        self._ui.name.set_text(name)
        self._ui.name.set_visible(True)

        # Set description
        has_desc = bool(info.muc_description)
        self._ui.description.set_text(info.muc_description or '')
        self._ui.description.set_visible(has_desc)
        self._ui.description_label.set_visible(has_desc)

        # Set subject
        self.set_subject(info.muc_subject)

        # Set user
        has_users = info.muc_users is not None
        self._ui.users.set_text(info.muc_users or '')
        self._ui.users.set_visible(has_users)
        self._ui.users_image.set_visible(has_users)

        # Set address
        self._ui.address.set_text(str(info.jid))

        # Set contacts
        self._ui.contact_box.foreach(self._ui.contact_box.remove)
        has_contacts = bool(info.muc_contacts)
        if has_contacts:
            for contact in info.muc_contacts:
                self._ui.contact_box.add(self._get_contact_button(contact))

        self._ui.contact_box.set_visible(has_contacts)
        self._ui.contact_label.set_visible(has_contacts)

        # Set discussion logs
        has_log_uri = bool(info.muc_log_uri)
        self._ui.logs.set_uri(info.muc_log_uri or '')
        self._ui.logs.set_label('Website')
        self._ui.logs.set_visible(has_log_uri)
        self._ui.logs_label.set_visible(has_log_uri)

        # Set room language
        has_lang = bool(info.muc_lang)
        lang = ''
        if has_lang:
            lang = RFC5646_LANGUAGE_TAGS.get(info.muc_lang, info.muc_lang)
        self._ui.lang.set_text(lang)
        self._ui.lang.set_visible(has_lang)
        self._ui.lang_image.set_visible(has_lang)

        self._add_features(info.features)
Esempio n. 2
0
 def _add_groupchats(self):
     show_account = len(self._accounts) > 1
     for account, _label in self._accounts:
         self.new_groupchat_rows[account] = None
         con = app.connections[account]
         bookmarks = con.get_module('Bookmarks').bookmarks
         for bookmark in bookmarks:
             jid = str(bookmark.jid)
             name = get_groupchat_name(con, jid)
             row = ContactRow(account, None, jid, name, show_account, True)
             self._ui.listbox.add(row)
Esempio n. 3
0
    def get_muc_surface(self, account, jid, size, scale):
        surface = self._cache[jid].get((size, scale))
        if surface is not None:
            return surface

        avatar_sha = app.logger.get_muc_avatar_sha(jid)
        if avatar_sha is not None:
            surface = self.surface_from_filename(avatar_sha, size, scale)
            if surface is None:
                return None
            surface = clip_circle(surface)
            self._cache[jid][(size, scale)] = surface
            return surface

        con = app.connections[account]
        name = get_groupchat_name(con, jid)
        letter = self._generate_letter(name)
        surface = self._generate_default_avatar(letter, jid, size, scale)
        self._cache[jid][(size, scale)] = surface
        return surface
Esempio n. 4
0
 def _get_groupchat_name(self):
     from gajim.common import app
     from gajim.common.helpers import get_groupchat_name
     con = app.connections[self.account.name]
     return get_groupchat_name(con, self.jid)