Exemple #1
0
    def populate(self, contact):
        if not contact:
            return
        self.create_window()
        hbox = gtk.HBox()

        if contact.jid.strip() != "":
            info = '<span size="large" weight="bold">' + contact.jid + "</span>"
        else:
            info = '<span size="large" weight="bold">' + contact.name + "</span>"

        info += '\n<span weight="bold">' + _("Role: ") + "</span>" + helpers.get_uf_role(contact.role)

        info += '\n<span weight="bold">' + _("Affiliation: ") + "</span>" + contact.affiliation.capitalize()

        info += '\n<span weight="bold">' + _("Status: ") + "</span>" + helpers.get_uf_show(contact.show)

        if contact.status:
            status = contact.status.strip()
            if status != "":
                # escape markup entities
                info += " - " + gtkgui_helpers.escape_for_pango_markup(status)

        if contact.resource.strip() != "":
            info += (
                '\n<span weight="bold">'
                + _("Resource: ")
                + "</span>"
                + gtkgui_helpers.escape_for_pango_markup(contact.resource)
            )

        self.text_label.set_markup(info)
        hbox.add(self.text_label)
        self.win.add(hbox)
Exemple #2
0
    def names(self, verbose=False):
        ggc = gajim.contacts.get_gc_contact
        gnl = gajim.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))
Exemple #3
0
    def names(self, verbose=False):
        ggc = gajim.contacts.get_gc_contact
        gnl = gajim.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))
Exemple #4
0
    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)
            eb = self.xml.get_object('subscription_label_eventbox')
            if self.contact.sub == 'from':
                tt_text = _("This contact is interested in your presence information, but you are not interested in his/her presence")
            elif self.contact.sub == 'to':
                tt_text = _("You are interested in the contact's presence information, but he/she is not interested in yours")
            elif self.contact.sub == 'both':
                tt_text = _("You and the contact are interested in each other's presence information")
            else: # None
                tt_text = _("You are not interested in the contact's presence, and neither he/she is interested in yours")
            eb.set_tooltip_text(tt_text)

            uf_ask = helpers.get_uf_ask(self.contact.ask)
            ask_label.set_text(uf_ask)
            eb = self.xml.get_object('ask_label_eventbox')
            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.")
            eb.set_tooltip_text(tt_text)

        resources = '%s (%s)' % (self.contact.resource, unicode(
                self.contact.priority))
        uf_resources = self.contact.resource + _(' resource with priority ')\
                + unicode(self.contact.priority)
        if not self.contact.status:
            self.contact.status = ''

        # Request list time status only if contact is offline
        if self.contact.show == 'offline':
            if self.gc_contact:
                j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
                gajim.connections[self.account].request_last_status_time(j, r,
                        self.contact.jid)
            else:
                gajim.connections[self.account].request_last_status_time(
                        self.contact.jid, '')

        # 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:
                j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
                gobject.idle_add(gajim.connections[self.account].request_os_info,
                        j, r, self.contact.jid)
            else:
                gobject.idle_add(gajim.connections[self.account].request_os_info,
                        self.contact.jid, self.contact.resource)

        # 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 = gajim.get_room_and_nick_from_fjid(self.real_jid)
                gobject.idle_add(gajim.connections[self.account].\
                        request_entity_time, j, r, self.contact.jid)
            else:
                gobject.idle_add(gajim.connections[self.account].\
                        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 = gajim.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,
                            unicode(c.priority))
                    uf_resources += '\n' + c.resource + \
                            _(' resource with priority ') + unicode(c.priority)
                    if c.show not in ('offline', 'error'):
                        gobject.idle_add(
                                gajim.connections[self.account].request_os_info, c.jid,
                                c.resource)
                        gobject.idle_add(gajim.connections[self.account].\
                                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:
            # If we know the real jid, remove the resource from vcard request
            gajim.connections[self.account].request_vcard(self.real_jid_for_vcard,
                    self.gc_contact.get_full_jid())
        else:
            gajim.connections[self.account].request_vcard(self.contact.jid)
Exemple #5
0
    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)
            eb = self.xml.get_object("subscription_label_eventbox")
            if self.contact.sub == "from":
                tt_text = _(
                    "This contact is interested in your presence information, but you are not interested in his/her presence"
                )
            elif self.contact.sub == "to":
                tt_text = _(
                    "You are interested in the contact's presence information, but he/she is not interested in yours"
                )
            elif self.contact.sub == "both":
                tt_text = _("You and the contact are interested in each other's presence information")
            else:  # None
                tt_text = _(
                    "You are not interested in the contact's presence, and neither he/she is interested in yours"
                )
            eb.set_tooltip_text(tt_text)

            uf_ask = helpers.get_uf_ask(self.contact.ask)
            ask_label.set_text(uf_ask)
            eb = self.xml.get_object("ask_label_eventbox")
            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.")
            eb.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 = ""

        # Request list time status only if contact is offline
        if self.contact.show == "offline":
            if self.gc_contact:
                j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
                gajim.connections[self.account].request_last_status_time(j, r, self.contact.jid)
            else:
                gajim.connections[self.account].request_last_status_time(self.contact.jid, "")

        # 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:
                j, r = gajim.get_room_and_nick_from_fjid(self.real_jid)
                GLib.idle_add(gajim.connections[self.account].request_os_info, j, r, self.contact.jid)
            else:
                GLib.idle_add(gajim.connections[self.account].request_os_info, self.contact.jid, self.contact.resource)

        # 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 = gajim.get_room_and_nick_from_fjid(self.real_jid)
                GLib.idle_add(gajim.connections[self.account].request_entity_time, j, r, self.contact.jid)
            else:
                GLib.idle_add(
                    gajim.connections[self.account].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 = gajim.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"):
                        GLib.idle_add(gajim.connections[self.account].request_os_info, c.jid, c.resource)
                        GLib.idle_add(gajim.connections[self.account].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:
            # If we know the real jid, remove the resource from vcard request
            gajim.connections[self.account].request_vcard(self.real_jid_for_vcard, self.gc_contact.get_full_jid())
        else:
            gajim.connections[self.account].request_vcard(self.contact.jid)