def draw_group(self, group): group_iter = self._get_group_iter(group) if not group_iter: return if group in ('owner', 'admin'): group_text = get_uf_affiliation(group, plural=True) else: group_text = get_uf_role(group, plural=True) total_users = self._get_total_user_count() group_users = self._store.iter_n_children(group_iter) group_text += ' (%s/%s)' % (group_users, total_users) self._store[group_iter][Column.TEXT] = group_text
def names(self, verbose=False): ggc = app.contacts.get_gc_contact gnl = app.contacts.get_nick_list get_contact = lambda nick: ggc(self.account, self.room_jid, nick) get_role = lambda nick: get_contact(nick).role nicks = gnl(self.account, self.room_jid) nicks = sorted(nicks) nicks = sorted(nicks, key=get_role) if not verbose: return ", ".join(nicks) for nick in nicks: contact = get_contact(nick) role = helpers.get_uf_role(contact.role) affiliation = helpers.get_uf_affiliation(contact.affiliation) self.echo("%s - %s - %s" % (nick, role, affiliation))
def _get_group_from_contact(contact): if contact.affiliation in (Affiliation.OWNER, Affiliation.ADMIN): return contact.affiliation.value, get_uf_affiliation( contact.affiliation, plural=True) return contact.role.value, get_uf_role(contact.role, plural=True)
def fill_jabber_page(self): self.xml.get_object('nickname_label').set_markup( '<b><span size="x-large">' + self.contact.get_shown_name() + '</span></b>') self.xml.get_object('jid_label').set_text(self.contact.jid) subscription_label = self.xml.get_object('subscription_label') ask_label = self.xml.get_object('ask_label') if self.gc_contact: self.xml.get_object('subscription_title_label').set_markup( Q_("?Role in Group Chat:<b>Role:</b>")) uf_role = helpers.get_uf_role(self.gc_contact.role) subscription_label.set_text(uf_role) self.xml.get_object('ask_title_label').set_markup( _("<b>Affiliation:</b>")) uf_affiliation = helpers.get_uf_affiliation( self.gc_contact.affiliation) ask_label.set_text(uf_affiliation) else: uf_sub = helpers.get_uf_sub(self.contact.sub) subscription_label.set_text(uf_sub) if self.contact.sub == 'from': tt_text = _( "This contact is interested in your presence information, but you are not interested in their presence" ) elif self.contact.sub == 'to': tt_text = _( "You are interested in the contact's presence information, but it is not mutual" ) elif self.contact.sub == 'both': tt_text = _( "The contact and you want to exchange presence information" ) else: # None tt_text = _( "You and the contact have a mutual disinterest in each-others presence information" ) subscription_label.set_tooltip_text(tt_text) uf_ask = helpers.get_uf_ask(self.contact.ask) ask_label.set_text(uf_ask) if self.contact.ask == 'subscribe': tt_text = _( "You are waiting contact's answer about your subscription request" ) else: tt_text = _("There is no pending subscription request.") ask_label.set_tooltip_text(tt_text) resources = '%s (%s)' % (self.contact.resource, str(self.contact.priority)) uf_resources = self.contact.resource + _(' resource with priority ')\ + str(self.contact.priority) if not self.contact.status: self.contact.status = '' con = app.connections[self.account] # do not wait for os_info if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.os_info_arrived = True else: # Request os info if contact is connected if self.gc_contact: con.get_module('SoftwareVersion').request_software_version( self.real_jid, callback=self.set_os_info, user_data=self.real_jid) else: jid = self.contact.get_full_jid() con.get_module('SoftwareVersion').request_software_version( jid, callback=self.set_os_info, user_data=jid) # do not wait for entity_time if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.entity_time_arrived = True else: # Request entity time if contact is connected if self.gc_contact: j, r = app.get_room_and_nick_from_fjid(self.real_jid) GLib.idle_add( con.get_module('EntityTime').request_entity_time, j, r) else: GLib.idle_add( con.get_module('EntityTime').request_entity_time, self.contact.jid, self.contact.resource) self.os_info = { 0: { 'resource': self.real_resource, 'client': '', 'os': '' } } self.time_info = {0: {'resource': self.real_resource, 'time': ''}} i = 1 contact_list = app.contacts.get_contacts(self.account, self.contact.jid) if contact_list: for c in contact_list: if c.resource != self.contact.resource: resources += '\n%s (%s)' % (c.resource, str(c.priority)) uf_resources += '\n' + c.resource + \ _(' resource with priority ') + str(c.priority) if c.show not in ('offline', 'error'): jid = c.get_full_jid() con.get_module( 'SoftwareVersion').request_software_version( jid, callback=self.set_os_info, user_data=jid) GLib.idle_add( con.get_module('EntityTime').request_entity_time, c.jid, c.resource) self.os_info[i] = { 'resource': c.resource, 'client': '', 'os': '' } self.time_info[i] = {'resource': c.resource, 'time': ''} i += 1 self.xml.get_object('resource_prio_label').set_text(resources) resource_prio_label_eventbox = self.xml.get_object( 'resource_prio_label_eventbox') resource_prio_label_eventbox.set_tooltip_text(uf_resources) self.fill_status_label() if self.gc_contact: con.get_module('VCardTemp').request_vcard( self._nec_vcard_received, self.gc_contact.get_full_jid(), room=True) else: con.get_module('VCardTemp').request_vcard(self._nec_vcard_received, self.contact.jid)