Merge branch 'serverinfo' into 'master'
Add ServerInfo Dialog See merge request !107
This commit is contained in:
commit
3a4a97dbf8
|
@ -6,6 +6,7 @@
|
|||
/* VCardWindow */
|
||||
.VCard-GtkLinkButton { padding-left: 5px; border-left: none; }
|
||||
|
||||
/* Emoticon Popover */
|
||||
popover#EmoticonPopover button { background: none; border: none; box-shadow:none; padding: 0px;}
|
||||
popover#EmoticonPopover button > label { font-size: 24px; }
|
||||
popover#EmoticonPopover flowboxchild > label { font-size: 24px; }
|
||||
|
@ -21,3 +22,10 @@ popover#EmoticonPopover flowboxchild { padding-top: 5px; padding-bottom: 5px; }
|
|||
#HistorySyncAssistant list > row.activatable > label { color: @theme_text_color; }
|
||||
#HistorySyncAssistant list > row.activatable:selected > label { color: @theme_selected_fg_color; }
|
||||
#FinishedLabel { font-size: 14px; font-weight: bold }
|
||||
|
||||
/* Server Info */
|
||||
#ServerInfoGrid > list { border: 1px solid; border-color: @borders; }
|
||||
#ServerInfoGrid > list > row:first-child { border-top: 1px solid; border-color: @borders; }
|
||||
#ServerInfoGrid > list > row { padding: 10px 20px 10px 10px; }
|
||||
#ServerInfoGrid > list > label { padding:10px; color: @insensitive_fg_color; font-weight: bold; }
|
||||
#ServerInfoGrid > list > row.activatable:active { box-shadow: none; }
|
||||
|
|
|
@ -32,6 +32,7 @@ import plugins.gui
|
|||
import history_window
|
||||
import disco
|
||||
from history_sync import HistorySyncAssistant
|
||||
from server_info import ServerInfoDialog
|
||||
|
||||
|
||||
class AppActions():
|
||||
|
@ -167,6 +168,14 @@ class AppActions():
|
|||
gajim.interface.instances[account]['privacy_lists'] = \
|
||||
dialogs.PrivacyListsWindow(account)
|
||||
|
||||
def on_server_info(self, action, param):
|
||||
account = param.get_string()
|
||||
if 'server_info' in gajim.interface.instances[account]:
|
||||
gajim.interface.instances[account]['server_info'].present()
|
||||
else:
|
||||
gajim.interface.instances[account]['server_info'] = \
|
||||
ServerInfoDialog(account)
|
||||
|
||||
def on_xml_console(self, action, param):
|
||||
account = param.get_string()
|
||||
if 'xml_console' in gajim.interface.instances[account]:
|
||||
|
|
|
@ -159,6 +159,7 @@ class CommonConnection:
|
|||
# the fake jid
|
||||
self.groupchat_jids = {} # {ID : groupchat_jid}
|
||||
|
||||
self.httpupload = False
|
||||
self.privacy_rules_supported = False
|
||||
self.vcard_supported = False
|
||||
self.private_storage_supported = False
|
||||
|
@ -1975,6 +1976,8 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
|
||||
self._continue_connection_request_privacy()
|
||||
|
||||
if nbxmpp.NS_HTTPUPLOAD in obj.features:
|
||||
self.httpupload = True
|
||||
if nbxmpp.NS_BYTESTREAM in obj.features and \
|
||||
gajim.config.get_per('accounts', self.name, 'use_ft_proxies'):
|
||||
our_fjid = helpers.parse_jid(our_jid + '/' + \
|
||||
|
|
|
@ -325,6 +325,7 @@ class GajimApplication(Gtk.Application):
|
|||
('-services', action.on_service_disco, 'online', 's'),
|
||||
('-profile', action.on_profile, 'feature', 's'),
|
||||
('-xml-console', action.on_xml_console, 'always', 's'),
|
||||
('-server-info', action.on_server_info, 'online', 's'),
|
||||
('-archive', action.on_archiving_preferences, 'feature', 's'),
|
||||
('-sync-history', action.on_history_sync, 'online', 's'),
|
||||
('-privacylists', action.on_privacy_lists, 'feature', 's'),
|
||||
|
|
|
@ -55,6 +55,8 @@ gtk_icon_theme.append_search_path(gajim.ICONS_DIR)
|
|||
|
||||
class Color:
|
||||
BLACK = Gdk.RGBA(red=0, green=0, blue=0, alpha=1)
|
||||
GREEN = Gdk.RGBA(red=115/255, green=210/255, blue=22/255, alpha=1)
|
||||
RED = Gdk.RGBA(red=204/255, green=0, blue=0, alpha=1)
|
||||
|
||||
def get_icon_pixmap(icon_name, size=16, color=None, quiet=False):
|
||||
try:
|
||||
|
|
|
@ -673,6 +673,7 @@ def get_account_menu(account):
|
|||
('-archive', _('Archiving Preferences')),
|
||||
('-sync-history', _('Synchronise History')),
|
||||
('-privacylists', _('Privacy Lists')),
|
||||
('-server-info', _('Server Info')),
|
||||
('-xml-console', _('XML Console'))
|
||||
]),
|
||||
('Admin', [
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2017 Philipp Hörist <philipp AT hoerist.com>
|
||||
#
|
||||
# This file is part of Gajim.
|
||||
#
|
||||
# Gajim is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Gajim is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
import nbxmpp
|
||||
from gi.repository import Gtk
|
||||
|
||||
from common import gajim
|
||||
from common import ged
|
||||
from gtkgui_helpers import get_icon_pixmap, Color
|
||||
|
||||
class ServerInfoDialog(Gtk.Dialog):
|
||||
def __init__(self, account):
|
||||
flags = Gtk.DialogFlags.DESTROY_WITH_PARENT
|
||||
super().__init__(_('Server Info'), None, flags)
|
||||
|
||||
self.account = account
|
||||
self.set_transient_for(gajim.interface.roster.window)
|
||||
self.set_resizable(False)
|
||||
|
||||
grid = Gtk.Grid()
|
||||
grid.set_name('ServerInfoGrid')
|
||||
grid.set_row_spacing(10)
|
||||
grid.set_hexpand(True)
|
||||
|
||||
self.info_listbox = Gtk.ListBox()
|
||||
self.info_listbox.set_selection_mode(Gtk.SelectionMode.NONE)
|
||||
self.info_listbox.set_header_func(self.header_func, 'Information')
|
||||
grid.attach(self.info_listbox, 0, 0, 1, 1)
|
||||
|
||||
self.feature_listbox = Gtk.ListBox()
|
||||
self.feature_listbox.set_selection_mode(Gtk.SelectionMode.NONE)
|
||||
self.feature_listbox.set_header_func(self.header_func, 'Features')
|
||||
grid.attach(self.feature_listbox, 0, 1, 1, 1)
|
||||
|
||||
box = self.get_content_area()
|
||||
box.pack_start(grid, True, True, 0)
|
||||
box.set_property('margin', 12)
|
||||
box.set_spacing(18)
|
||||
|
||||
self.connect('response', self.on_response)
|
||||
self.connect('destroy', self.on_destroy)
|
||||
|
||||
gajim.ged.register_event_handler('version-result-received',
|
||||
ged.CORE,
|
||||
self._nec_version_result_received)
|
||||
|
||||
gajim.ged.register_event_handler('agent-info-received',
|
||||
ged.GUI1,
|
||||
self._nec_agent_info_received)
|
||||
|
||||
self.version = ''
|
||||
self.hostname = gajim.get_hostname_from_account(account)
|
||||
gajim.connections[account].request_os_info(self.hostname, None)
|
||||
|
||||
for feature in self.get_features():
|
||||
self.add_feature(feature)
|
||||
|
||||
for info in self.get_infos():
|
||||
self.add_info(info)
|
||||
|
||||
self.show_all()
|
||||
|
||||
@staticmethod
|
||||
def header_func(row, before, user_data):
|
||||
if before:
|
||||
row.set_header(None)
|
||||
else:
|
||||
label = Gtk.Label(label=user_data)
|
||||
label.set_halign(Gtk.Align.START)
|
||||
row.set_header(label)
|
||||
|
||||
@staticmethod
|
||||
def update(func, listbox):
|
||||
for index, item in enumerate(func()):
|
||||
row = listbox.get_row_at_index(index)
|
||||
row.get_child().update(item)
|
||||
row.set_tooltip_text(item.tooltip)
|
||||
|
||||
def _nec_version_result_received(self, obj):
|
||||
if obj.jid != self.hostname:
|
||||
return
|
||||
self.version = obj.client_info
|
||||
self.update(self.get_infos, self.info_listbox)
|
||||
|
||||
def _nec_agent_info_received(self, obj):
|
||||
if not 'Gajim_' in obj.id_:
|
||||
return
|
||||
self.update(self.get_features, self.feature_listbox)
|
||||
|
||||
def add_feature(self, feature):
|
||||
item = FeatureItem(feature)
|
||||
self.feature_listbox.add(item)
|
||||
item.get_parent().set_tooltip_text(feature.tooltip)
|
||||
|
||||
def get_features(self):
|
||||
con = gajim.connections[self.account]
|
||||
Feature = namedtuple('Feature', ['name', 'enabled', 'tooltip'])
|
||||
|
||||
return [
|
||||
Feature('XEP-0016: Privacy Lists', con.privacy_rules_supported, None),
|
||||
Feature('XEP-0045: Multi-User Chat', con.muc_jid, None),
|
||||
Feature('XEP-0054: vcard-temp', con.vcard_supported, None),
|
||||
Feature('XEP-0163: Personal Eventing Protocol', con.pep_supported, None),
|
||||
Feature('XEP-0191: Blocking Command', con.blocking_supported, nbxmpp.NS_BLOCKING),
|
||||
Feature('XEP-0198: Stream Management', con.sm.enabled, nbxmpp.NS_STREAM_MGMT),
|
||||
Feature('XEP-0280: Message Carbons', con.carbons_enabled, nbxmpp.NS_CARBONS),
|
||||
Feature('XEP-0313: Message Archive Management', con.archiving_namespace, con.archiving_namespace),
|
||||
Feature('XEP-0363: HTTP File Upload', con.httpupload, nbxmpp.NS_HTTPUPLOAD)]
|
||||
|
||||
def add_info(self, info):
|
||||
self.info_listbox.add(ServerInfoItem(info))
|
||||
|
||||
def get_infos(self):
|
||||
Info = namedtuple('Info', ['name', 'value', 'tooltip'])
|
||||
return [
|
||||
Info(_('Hostname'), self.hostname, None),
|
||||
Info(_('Server Software'), self.version, None)]
|
||||
|
||||
def on_response(self, dialog, response):
|
||||
if response == Gtk.ResponseType.OK:
|
||||
self.destroy()
|
||||
|
||||
def on_destroy(self, *args):
|
||||
del gajim.interface.instances[self.account]['server_info']
|
||||
gajim.ged.remove_event_handler('version-result-received',
|
||||
ged.CORE,
|
||||
self._nec_version_result_received)
|
||||
|
||||
gajim.ged.remove_event_handler('agent-info-received',
|
||||
ged.GUI1,
|
||||
self._nec_agent_info_received)
|
||||
|
||||
class FeatureItem(Gtk.Grid):
|
||||
def __init__(self, feature):
|
||||
super().__init__()
|
||||
|
||||
self.set_column_spacing(6)
|
||||
|
||||
self.icon = Gtk.Image()
|
||||
self.feature_label = Gtk.Label(label=feature.name)
|
||||
self.set_feature_enabled(bool(feature.enabled))
|
||||
|
||||
self.add(self.icon)
|
||||
self.add(self.feature_label)
|
||||
|
||||
def set_feature_enabled(self, enabled):
|
||||
if enabled:
|
||||
self.icon.set_from_pixbuf(
|
||||
get_icon_pixmap('emblem-ok-symbolic', color=[Color.GREEN]))
|
||||
else:
|
||||
self.icon.set_from_pixbuf(
|
||||
get_icon_pixmap('window-close-symbolic', color=[Color.RED]))
|
||||
|
||||
def update(self, feature):
|
||||
self.set_feature_enabled(bool(feature.enabled))
|
||||
|
||||
class ServerInfoItem(Gtk.Grid):
|
||||
def __init__(self, info):
|
||||
super().__init__()
|
||||
|
||||
self.set_hexpand(True)
|
||||
self.insert_column(0)
|
||||
self.set_column_homogeneous(True)
|
||||
|
||||
self.info = Gtk.Label(label=info.name)
|
||||
self.info.set_halign(Gtk.Align.START)
|
||||
self.info.set_hexpand(True)
|
||||
self.value = Gtk.Label(label=info.value)
|
||||
self.value.set_halign(Gtk.Align.START)
|
||||
self.value.set_hexpand(True)
|
||||
|
||||
self.add(self.info)
|
||||
self.add(self.value)
|
||||
|
||||
def update(self, info):
|
||||
self.value.set_text(info.value)
|
Loading…
Reference in New Issue