...
 
Commits (6)
......@@ -296,6 +296,13 @@ class LeaveGroupchatsCommand(AdHocCommand):
class AdHocCommands(BaseModule):
_nbxmpp_extends = 'AdHoc'
_nbxmpp_methods = [
'request_command_list',
'execute_command',
]
def __init__(self, con):
BaseModule.__init__(self, con)
......@@ -469,38 +476,6 @@ class AdHocCommands(BaseModule):
raise nbxmpp.NodeProcessed
def request_command_list(self, jid):
"""
Request the command list.
"""
self._log.info('Request Command List: %s', jid)
query = nbxmpp.Iq(typ='get', to=jid, queryNS=nbxmpp.NS_DISCO_ITEMS)
query.setQuerynode(nbxmpp.NS_COMMANDS)
self._con.connection.SendAndCallForResponse(
query, self._command_list_received)
def _command_list_received(self, stanza):
if not nbxmpp.isResultNode(stanza):
self._log.info('Error: %s', stanza.getError())
app.nec.push_incoming_event(
AdHocCommandError(None, conn=self._con,
error=stanza.getError()))
return
items = stanza.getQueryPayload()
commandlist = []
if items:
commandlist = [
(t.getAttr('node'), t.getAttr('name')) for t in items
]
self._log.info('Received: %s', commandlist)
app.nec.push_incoming_event(
AdHocCommandListReceived(
None, conn=self._con, commandlist=commandlist))
def send_command(self, jid, node, session_id,
form, action='execute'):
"""
......@@ -563,10 +538,6 @@ class AdHocCommandError(NetworkIncomingEvent):
name = 'adhoc-command-error'
class AdHocCommandListReceived(NetworkIncomingEvent):
name = 'adhoc-command-list'
class AdHocCommandActionResponse(NetworkIncomingEvent):
name = 'adhoc-command-action-response'
......
......@@ -23,7 +23,7 @@ import struct
import hashlib
import os
import time
import platform
import sys
import logging
from errno import EWOULDBLOCK
from errno import ENOBUFS
......@@ -296,7 +296,7 @@ class SocksQueue:
def activate_proxy(self, idx):
if not self.isHashInSockObjs(self.senders, idx):
return
for key in self.senders:
for key in list(self.senders):
if idx in key:
sender = self.senders[key]
if sender.file_props.type_ != 's':
......@@ -1436,7 +1436,7 @@ class Socks5Listener(IdleObject):
# Under windows Vista, we need that to listen on ipv6 AND ipv4
# Doesn't work under windows XP
if os.name == 'nt':
if int(platform.win32_ver()[0]) >= 6: # Win Vista +
if sys.getwindowsversion().major >= 6: # Win Vista +
# 47 is socket.IPPROTO_IPV6
# 27 is socket.IPV6_V6ONLY under windows, but not defined ...
self._serv.setsockopt(41, 27, 0)
......
......@@ -244,10 +244,15 @@ button.flat.link { padding: 0; border: 0; }
/*Dataforms*/
.field-fixed { font-size: 16px; font-weight: bold; padding-top:5px;}
.data-form-title { font-size: 16px; font-weight: bold; }
.data-form-widget grid { margin: 18px; }
.data-form-widget grid { margin: 0px 18px 18px 18px; }
.data-form-widget treeview { padding: 5px; }
.data-form-widget scrolledwindow { border: 1px solid; border-color:@unfocused_borders; }
.data-form-widget textview { padding: 5px; }
/*Image Preview*/
.preview-image { box-shadow: 0px 0px 3px 0px alpha(@theme_text_color, 0.2); }
/* Treeview */
.adhoc-treeview { padding: 5px; }
.adhoc-scrolled { border: 1px solid; border-color:@unfocused_borders; }
......@@ -79,7 +79,7 @@ from gajim.gtk.filechoosers import AvatarChooserDialog
from gajim.gtk.add_contact import AddNewContactWindow
from gajim.gtk.tooltips import GCTooltip
from gajim.gtk.groupchat_config import GroupchatConfig
from gajim.gtk.adhoc_commands import CommandWindow
from gajim.gtk.adhoc import AdHocCommand
from gajim.gtk.dataform import DataFormWidget
from gajim.gtk.util import NickCompletionGenerator
from gajim.gtk.util import get_icon_name
......@@ -735,7 +735,7 @@ class GroupchatControl(ChatControlBase):
"""
Execute AdHoc commands on the current room
"""
CommandWindow(self.account, self.room_jid)
AdHocCommand(self.account, self.room_jid)
def _on_upload_avatar(self, action, param):
def _on_accept(filename):
......@@ -2815,7 +2815,7 @@ class GroupchatControl(ChatControlBase):
def _on_execute_command_occupant(self, widget, nick):
jid = self.room_jid + '/' + nick
CommandWindow(self.account, jid)
AdHocCommand(self.account, jid)
def on_row_activated(self, widget, path):
"""
......
This diff is collapsed.
This diff is collapsed.
......@@ -22,6 +22,8 @@ from gajim.gtkgui_helpers import scale_pixbuf_from_data
from gajim.common import app
from gajim.common.i18n import _
from gajim.gtk.util import MultiLineLabel
class DataFormWidget(Gtk.ScrolledWindow):
......@@ -32,6 +34,7 @@ class DataFormWidget(Gtk.ScrolledWindow):
self.set_hexpand(True)
self.set_vexpand(True)
self.get_style_context().add_class('data-form-widget')
self.set_overlay_scrolling(False)
self._form_node = form_node
......@@ -91,7 +94,7 @@ class FormGrid(Gtk.Grid):
if form_node.title is not None:
self.title = form_node.title
self._add_row(Title(form_node.title))
if form_node.instructions is not None:
if form_node.instructions:
self.instructions = form_node.instructions
self._add_row(Instructions(form_node.instructions))
......@@ -194,6 +197,7 @@ class Field:
self._field = field
self._form_grid = form_grid
self._validate_source_id = None
self._read_only = options.get('read-only', False)
self._label = Gtk.Label(label=field.label)
self._label.set_single_line_mode(False)
......@@ -213,6 +217,10 @@ class Field:
self._warning_box.set_size_request(16, -1)
self._warning_box.add(self._warning_image)
@property
def read_only(self):
return self._read_only
def add(self, form_grid, row_number):
form_grid.attach(self._label, 0, row_number, 1, 1)
form_grid.attach_next_to(self._widget,
......@@ -262,9 +270,14 @@ class BooleanField(Field):
def __init__(self, field, form_grid, options):
Field.__init__(self, field, form_grid, options)
self._widget = Gtk.CheckButton()
self._widget.set_active(field.value)
self._widget.connect('toggled', self._toggled)
if self.read_only:
label = _('Yes') if field.value else _('No')
self._widget = Gtk.Label(label=label)
self._widget.set_xalign(0)
else:
self._widget = Gtk.CheckButton()
self._widget.set_active(field.value)
self._widget.connect('toggled', self._toggled)
def _toggled(self, _widget):
self._field.value = self._widget.get_active()
......@@ -465,9 +478,13 @@ class TextSingleField(Field):
def __init__(self, field, form_grid, options):
Field.__init__(self, field, form_grid, options)
self._widget = Gtk.Entry()
self._widget.set_text(field.value)
self._widget.connect('changed', self._changed)
if self.read_only:
self._widget = Gtk.Label(label=field.value)
self._widget.set_xalign(0)
else:
self._widget = Gtk.Entry()
self._widget.set_text(field.value)
self._widget.connect('changed', self._changed)
def _changed(self, _widget):
self._field.value = self._widget.get_text()
......@@ -498,10 +515,16 @@ class TextMultiField(Field):
self._widget.set_min_content_height(100)
self._widget.set_max_content_height(300)
self._textview = Gtk.TextView()
self._textview.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self._textview.get_buffer().set_text(field.value)
self._textview.get_buffer().connect('changed', self._changed)
if self.read_only:
self._textview = MultiLineLabel(label=field.value)
self._textview.set_selectable(True)
self._textview.set_xalign(0)
self._textview.set_yalign(0)
else:
self._textview = Gtk.TextView()
self._textview.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self._textview.get_buffer().set_text(field.value)
self._textview.get_buffer().connect('changed', self._changed)
self._widget.add(self._textview)
......
......@@ -901,21 +901,23 @@ class CertificateDialog(Gtk.ApplicationWindow):
self._ui.label_cert_for_account.set_text(
_('Certificate for account\n%s') % account)
self._ui.data_it_common_name.set_text(subject.commonName)
self._ui.data_it_organization.set_text(subject.organizationName)
self._ui.data_it_common_name.set_text(subject.commonName or '')
self._ui.data_it_organization.set_text(subject.organizationName or '')
self._ui.data_it_organizational_unit.set_text(
subject.organizationalUnitName)
subject.organizationalUnitName or '')
self._ui.data_it_serial_number.set_text(str(cert.get_serial_number()))
self._ui.data_ib_common_name.set_text(issuer.commonName)
self._ui.data_ib_organization.set_text(issuer.organizationName)
self._ui.data_ib_common_name.set_text(issuer.commonName or '')
self._ui.data_ib_organization.set_text(issuer.organizationName or '')
self._ui.data_ib_organizational_unit.set_text(
issuer.organizationalUnitName)
issuer.organizationalUnitName or '')
issued = datetime.strptime(cert.get_notBefore().decode('ascii'), '%Y%m%d%H%M%SZ')
issued = datetime.strptime(cert.get_notBefore().decode('ascii'),
'%Y%m%d%H%M%SZ')
issued = issued.strftime('%B %d, %Y, %H:%M:%S %z')
self._ui.data_issued_on.set_text(issued)
expires = datetime.strptime(cert.get_notAfter().decode('ascii'), '%Y%m%d%H%M%SZ')
expires = datetime.strptime(cert.get_notAfter().decode('ascii'),
'%Y%m%d%H%M%SZ')
expires = expires.strftime('%B %d, %Y, %H:%M:%S %z')
self._ui.data_expires_on.set_text(expires)
......
......@@ -59,7 +59,7 @@ from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import InformationDialog
from gajim.gtk.service_registration import ServiceRegistration
from gajim.gtk.discovery_search import SearchWindow
from gajim.gtk.adhoc_commands import CommandWindow
from gajim.gtk.adhoc import AdHocCommand
from gajim.gtk.util import icon_exists
from gajim.gtk.util import get_builder
......@@ -1311,7 +1311,7 @@ class ToplevelAgentBrowser(AgentBrowser):
return
service = model[iter_][0]
node = model[iter_][1]
CommandWindow(self.account, service, commandnode=node)
AdHocCommand(self.account, service)
def on_register_button_clicked(self, widget=None):
"""
......
......@@ -31,6 +31,7 @@ from functools import wraps
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import Pango
import cairo
from gajim.common import app
......@@ -606,3 +607,19 @@ def format_fingerprint(fingerprint):
buf += '{0} '.format(fingerprint[w:w + wordsize])
buf = textwrap.fill(buf, width=36)
return buf.rstrip().upper()
def find_widget(name, container):
for child in container.get_children():
if Gtk.Buildable.get_name(child) == name:
return child
if isinstance(child, Gtk.Box):
return find_widget(name, child)
class MultiLineLabel(Gtk.Label):
def __init__(self, *args, **kwargs):
Gtk.Label.__init__(self, *args, **kwargs)
self.set_line_wrap(True)
self.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
self.set_single_line_mode(False)
......@@ -84,7 +84,7 @@ from gajim.gtk.service_registration import ServiceRegistration
from gajim.gtk.discovery import ServiceDiscoveryWindow
from gajim.gtk.accounts import AccountsWindow
from gajim.gtk.tooltips import RosterTooltip
from gajim.gtk.adhoc_commands import CommandWindow
from gajim.gtk.adhoc import AdHocCommand
from gajim.gtk.subscription_request import SubscriptionRequestWindow
from gajim.gtk.util import get_icon_name
from gajim.gtk.util import resize_window
......@@ -3635,7 +3635,7 @@ class RosterWindow:
jid = contact.jid
if resource is not None:
jid = jid + '/' + resource
CommandWindow(account, jid)
AdHocCommand(account, jid)
def on_roster_window_focus_in_event(self, widget, event):
# roster received focus, so if we had urgency REMOVE IT
......