Commit 3b2104bd authored by Sophie Herold's avatar Sophie Herold

Last missing functionality

parent 9644fab0
Pipeline #2143 passed with stages
in 2 minutes and 13 seconds
This diff is collapsed.
......@@ -210,7 +210,7 @@ treeview.space { padding: 6px; }
button.flat.link { padding: 0; border: 0; }
/* Images */
.image-shadow { box-shadow: 1px 1px 2px; }
.image-shadow { box-shadow: @borders 1px 1px 2px; }
/*MessageWindow Notebook*/
.notebook-tab-label {min-width: 80px}
......
......@@ -99,6 +99,8 @@ class ContactInfo:
self.vcard = {'default': {}}
self.clients = {}
self.ui.from_subscription_switch.gajim_ignore_next = None
# Get real jid
if gc_contact:
# Don't use real jid if room is (semi-)anonymous
......@@ -113,13 +115,12 @@ class ContactInfo:
self.real_jid = gc_contact.get_full_jid()
self.real_jid_for_vcard = self.real_jid
self.real_resource = gc_contact.name
self.ui.groups_page_box.hide()
else:
self.real_jid = contact.get_full_jid()
self.real_resource = contact.resource
self.vcard_arrived = False
self.os_info_arrived = False
self.entity_time_arrived = False
self.time = 0
self.fill_jabber_page()
......@@ -158,6 +159,44 @@ class ContactInfo:
def destroy(self):
self.ui.window.destroy()
def on_from_subscription_switch_active_notify(self, widget, *args):
if widget.gajim_ignore_next is not None:
if widget.get_active() == widget.gajim_ignore_next:
widget.gajim_ignore_next = None
return
if widget.get_active():
app.connections[self.account].get_module('Presence').subscribed(
self.contact.jid)
else:
dialog = Gtk.MessageDialog(None,
0,
Gtk.MessageType.QUESTION,
Gtk.ButtonsType.NONE,
_('No longer show online status to contact? '));
dialog.set_transient_for(self.ui.window)
dialog.format_secondary_text(
_('The contact will be informed that you stopped sharing your status with them.'))
dialog.add_button(_('Cancel'), 1)
dialog.add_button(_('Stop showing online status'), 2)
result = dialog.run()
dialog.destroy()
if result == 2:
app.connections[self.account].get_module('Presence').unsubscribed(
self.contact.jid)
else:
widget.gajim_ignore_next = True
widget.set_active(True)
def on_to_subscription_button_clicked(self, *args):
app.connections[self.account].get_module('Presence').subscribe(
self.contact.jid)
self.ui.to_subscription_stack.set_visible_child_name('checkmark')
def on_groups_treeview_selection_changed(self, *args):
(_, iter_) = self.ui.groups_treeview.get_selection().get_selected()
self.ui.group_edit_button.set_sensitive(bool(iter_))
......@@ -452,6 +491,12 @@ class ContactInfo:
for key, client in self.clients.items():
self.client_grid.add_header(_('Resource "{}"').format(key))
self.client_grid.add_value(_('Priority'), str(client['priority']))
if client.get('status'):
self.client_grid.add_value(_('Status'),
helpers.get_uf_show(client['status']))
if client.get('message'):
self.client_grid.add_value(_('Status Message'),
client['message'])
if client.get('client'):
self.client_grid.add_value(_('Software'), client['client'])
if client.get('os'):
......@@ -478,36 +523,22 @@ class ContactInfo:
self.rebuild_client_grid()
def fill_status_label(self):
contact_list = app.contacts.get_contacts(self.account, self.contact.jid)
connected_contact_list = []
for c in contact_list:
if c.show not in ('offline', 'error'):
connected_contact_list.append(c)
if not connected_contact_list:
# no connected contact, get the offline one
connected_contact_list = contact_list
# stats holds show and status message
stats = ''
if connected_contact_list:
# Start with self.contact, as with resources
stats = helpers.get_uf_show(self.contact.show)
if self.contact.status:
stats += ': ' + self.contact.status
for c in connected_contact_list:
if c.resource != self.contact.resource:
stats += '\n'
stats += helpers.get_uf_show(c.show)
if c.status:
stats += ': ' + c.status
else: # Maybe gc_vcard ?
stats = helpers.get_uf_show(self.contact.show)
if self.contact.status:
stats += ': ' + self.contact.status
status_label = self.ui.status_label
status_label.set_text(stats)
status_label.set_tooltip_text(stats)
def show(status, message, **kwargs):
if message:
return '{}: {}'.format(helpers.get_uf_show(status), message)
else:
return helpers.get_uf_show(status)
def fill_jabber_page(self):
stats = list(map(lambda x: show(**x), self.clients.values()))
if len(set(stats)) == 1:
stats_str = stats[0]
else:
stats_str = '\n'.join(stats)
self.ui.status_label.set_text(stats_str)
def fill_information_page(self):
self.ui.shown_name_label.set_text(self.contact.get_shown_name())
self.ui.shown_name_entry.set_text(self.contact.get_shown_name())
self.ui.header_shown_name_label.set_text(self.contact.get_shown_name())
......@@ -521,22 +552,22 @@ class ContactInfo:
self._add_to_vcard('group_chat', 'AFFILIATION',
helpers.get_uf_affiliation(self.gc_contact.affiliation))
else:
uf_sub = helpers.get_uf_sub(self.contact.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.")
uf_ask = helpers.get_uf_ask(self.contact.ask)
if self.contact.ask == 'subscribe':
tt_text += ' ' + _("You are waiting contact's answer about your subscription request")
elif self.contact.sub != 'both':
tt_text += ' ' + _("There is no pending subscription request.")
if self.contact.sub in ('from', 'both'):
self.ui.from_subscription_switch.gajim_ignore_next = True
self.ui.from_subscription_switch.set_active(True)
if self.contact.sub in ('to', 'both'):
self.ui.to_subscription_label.set_text(_('Yes'))
self.ui.to_subscription_stack.hide()
elif self.contact.ask == 'subscribe':
self.ui.to_subscription_label.set_text(_('Requested'))
self.ui.to_subscription_button.set_label(_('Request Again'))
else:
self.ui.to_subscription_label.set_text(_('No'))
self.fill_status_label()
def fill_jabber_page(self):
if not self.contact.status:
self.contact.status = ''
......@@ -570,19 +601,27 @@ class ContactInfo:
GLib.idle_add(con.get_module('EntityTime').request_entity_time,
self.contact.jid, self.contact.resource)
self.clients[self.real_resource] = {'priority': self.contact.priority}
self.clients[self.real_resource] = {
'priority': self.contact.priority,
'status': self.contact.show,
'message': self.contact.status
}
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:
self.clients[c.resource] = {'priority': c.priority}
self.clients[c.resource] = {
'priority': c.priority,
'status': c.show,
'message': c.status
}
if c.show not in ('offline', 'error'):
GLib.idle_add(con.get_module('SoftwareVersion').request_os_info,
c.jid, c.resource)
GLib.idle_add(con.get_module('EntityTime').request_entity_time,
c.jid, c.resource)
self.fill_status_label()
self.fill_information_page()
if self.gc_contact:
con.get_module('VCardTemp').request_vcard(
......@@ -593,19 +632,6 @@ class ContactInfo:
con.get_module('VCardTemp').request_vcard(
self._nec_vcard_received, self.contact.jid)
class ListBoxSimple:
def __init__(self, listbox):
self.listbox = listbox
def add_row(self, key, text):
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
row.add(hbox)
label = Gtk.Label(text)
hbox.pack_start(label, False, False, 0)
row.gajim_id = key
self.listbox.add(row)
class InfoGrid:
......
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