Fix pylint errors
This commit is contained in:
parent
19ba1f669c
commit
6753c3e499
|
@ -404,7 +404,7 @@ class CommandWindow:
|
||||||
|
|
||||||
self.commandnode = command.getAttr('node')
|
self.commandnode = command.getAttr('node')
|
||||||
if command.getTag('x'):
|
if command.getTag('x'):
|
||||||
self.dataform = dataforms.ExtendForm(node=command.getTag('x'))
|
self.dataform = dataforms.extend_form(node=command.getTag('x'))
|
||||||
|
|
||||||
self.data_form_widget.set_sensitive(True)
|
self.data_form_widget.set_sensitive(True)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -588,7 +588,7 @@ class ChatControl(ChatControlBase):
|
||||||
|
|
||||||
def on_location_eventbox_button_release_event(self, widget, event):
|
def on_location_eventbox_button_release_event(self, widget, event):
|
||||||
if 'geoloc' in self.contact.pep:
|
if 'geoloc' in self.contact.pep:
|
||||||
location = self.contact.pep['geoloc']._pep_specific_data
|
location = self.contact.pep['geoloc'].data
|
||||||
if ('lat' in location) and ('lon' in location):
|
if ('lat' in location) and ('lon' in location):
|
||||||
uri = 'https://www.openstreetmap.org/?' + \
|
uri = 'https://www.openstreetmap.org/?' + \
|
||||||
'mlat=%(lat)s&mlon=%(lon)s&zoom=16' % {'lat': location['lat'],
|
'mlat=%(lat)s&mlon=%(lon)s&zoom=16' % {'lat': location['lat'],
|
||||||
|
|
|
@ -448,7 +448,7 @@ class MucCapsCache:
|
||||||
elif child.getName() == 'x':
|
elif child.getName() == 'x':
|
||||||
if child.getNamespace() == nbxmpp.NS_DATA:
|
if child.getNamespace() == nbxmpp.NS_DATA:
|
||||||
from gajim.common.modules import dataforms
|
from gajim.common.modules import dataforms
|
||||||
data.append(dataforms.ExtendForm(node=child))
|
data.append(dataforms.extend_form(node=child))
|
||||||
|
|
||||||
if nbxmpp.NS_MUC not in features:
|
if nbxmpp.NS_MUC not in features:
|
||||||
# Not a MUC, don't cache info
|
# Not a MUC, don't cache info
|
||||||
|
|
|
@ -382,14 +382,14 @@ class CommonConnection:
|
||||||
|
|
||||||
def update_contact(self, jid, name, groups):
|
def update_contact(self, jid, name, groups):
|
||||||
if self.connection:
|
if self.connection:
|
||||||
self.getRoster().setItem(jid=jid, name=name, groups=groups)
|
self.getRoster().set_item(jid=jid, name=name, groups=groups)
|
||||||
|
|
||||||
def update_contacts(self, contacts):
|
def update_contacts(self, contacts):
|
||||||
"""
|
"""
|
||||||
Update multiple roster items
|
Update multiple roster items
|
||||||
"""
|
"""
|
||||||
if self.connection:
|
if self.connection:
|
||||||
self.getRoster().setItemMulti(contacts)
|
self.getRoster().set_item_multi(contacts)
|
||||||
|
|
||||||
def new_account(self, name, config, sync=False):
|
def new_account(self, name, config, sync=False):
|
||||||
"""
|
"""
|
||||||
|
@ -1578,7 +1578,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
iq.setID(id_)
|
iq.setID(id_)
|
||||||
self.awaiting_answers[id_] = (AGENT_REMOVED, agent)
|
self.awaiting_answers[id_] = (AGENT_REMOVED, agent)
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
self.getRoster().delItem(agent)
|
self.getRoster().del_item(agent)
|
||||||
|
|
||||||
def send_new_account_infos(self, form, is_form):
|
def send_new_account_infos(self, form, is_form):
|
||||||
if is_form:
|
if is_form:
|
||||||
|
|
|
@ -926,7 +926,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
form_tag = feature_tag.getTag('x', namespace=nbxmpp.NS_DATA)
|
form_tag = feature_tag.getTag('x', namespace=nbxmpp.NS_DATA)
|
||||||
if not form_tag:
|
if not form_tag:
|
||||||
return
|
return
|
||||||
self.dataform = dataforms.ExtendForm(node=form_tag)
|
self.dataform = dataforms.extend_form(node=form_tag)
|
||||||
for f in self.dataform.iter_fields():
|
for f in self.dataform.iter_fields():
|
||||||
if f.var == 'stream-method' and f.type_ == 'list-single':
|
if f.var == 'stream-method' and f.type_ == 'list-single':
|
||||||
values = [o[1] for o in f.options]
|
values = [o[1] for o in f.options]
|
||||||
|
|
|
@ -39,7 +39,7 @@ class AdHocCommand:
|
||||||
commandfeatures = (nbxmpp.NS_DATA,)
|
commandfeatures = (nbxmpp.NS_DATA,)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def isVisibleFor(samejid):
|
def is_visible_for(_samejid):
|
||||||
"""
|
"""
|
||||||
This returns True if that command should be visible and invokable for
|
This returns True if that command should be visible and invokable for
|
||||||
others
|
others
|
||||||
|
@ -54,8 +54,8 @@ class AdHocCommand:
|
||||||
self.jid = jid
|
self.jid = jid
|
||||||
self.sessionid = sessionid
|
self.sessionid = sessionid
|
||||||
|
|
||||||
def buildResponse(self, request, status='executing', defaultaction=None,
|
def build_response(self, request, status='executing', defaultaction=None,
|
||||||
actions=None):
|
actions=None):
|
||||||
assert status in ('executing', 'completed', 'canceled')
|
assert status in ('executing', 'completed', 'canceled')
|
||||||
|
|
||||||
response = request.buildReply('result')
|
response = request.buildReply('result')
|
||||||
|
@ -74,12 +74,12 @@ class AdHocCommand:
|
||||||
cmd.addChild('actions', attrs, actions)
|
cmd.addChild('actions', attrs, actions)
|
||||||
return response, cmd
|
return response, cmd
|
||||||
|
|
||||||
def badRequest(self, stanza):
|
def bad_request(self, stanza):
|
||||||
self.connection.connection.send(
|
self.connection.connection.send(
|
||||||
nbxmpp.Error(stanza, nbxmpp.NS_STANZAS + ' bad-request'))
|
nbxmpp.Error(stanza, nbxmpp.NS_STANZAS + ' bad-request'))
|
||||||
|
|
||||||
def cancel(self, request):
|
def cancel(self, request):
|
||||||
response = self.buildResponse(request, status='canceled')[0]
|
response = self.build_response(request, status='canceled')[0]
|
||||||
self.connection.connection.send(response)
|
self.connection.connection.send(response)
|
||||||
return False # finish the session
|
return False # finish the session
|
||||||
|
|
||||||
|
@ -90,30 +90,30 @@ class ChangeStatusCommand(AdHocCommand):
|
||||||
|
|
||||||
def __init__(self, conn, jid, sessionid):
|
def __init__(self, conn, jid, sessionid):
|
||||||
AdHocCommand.__init__(self, conn, jid, sessionid)
|
AdHocCommand.__init__(self, conn, jid, sessionid)
|
||||||
self.cb = self.first_step
|
self._callback = self.first_step
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def isVisibleFor(samejid):
|
def is_visible_for(samejid):
|
||||||
"""
|
"""
|
||||||
Change status is visible only if the entity has the same bare jid
|
Change status is visible only if the entity has the same bare jid
|
||||||
"""
|
"""
|
||||||
return samejid
|
return samejid
|
||||||
|
|
||||||
def execute(self, request):
|
def execute(self, request):
|
||||||
return self.cb(request)
|
return self._callback(request)
|
||||||
|
|
||||||
def first_step(self, request):
|
def first_step(self, request):
|
||||||
# first query...
|
# first query...
|
||||||
response, cmd = self.buildResponse(request,
|
response, cmd = self.build_response(request,
|
||||||
defaultaction='execute',
|
defaultaction='execute',
|
||||||
actions=['execute'])
|
actions=['execute'])
|
||||||
|
|
||||||
cmd.addChild(
|
cmd.addChild(
|
||||||
node=dataforms.SimpleDataForm(
|
node=dataforms.SimpleDataForm(
|
||||||
title=_('Change status'),
|
title=_('Change status'),
|
||||||
instructions=_('Set the presence type and description'),
|
instructions=_('Set the presence type and description'),
|
||||||
fields=[
|
fields=[
|
||||||
dataforms.Field(
|
dataforms.create_field(
|
||||||
'list-single',
|
'list-single',
|
||||||
var='presence-type',
|
var='presence-type',
|
||||||
label='Type of presence:',
|
label='Type of presence:',
|
||||||
|
@ -126,7 +126,7 @@ class ChangeStatusCommand(AdHocCommand):
|
||||||
('offline', _('Offline - disconnect'))],
|
('offline', _('Offline - disconnect'))],
|
||||||
value='online',
|
value='online',
|
||||||
required=True),
|
required=True),
|
||||||
dataforms.Field(
|
dataforms.create_field(
|
||||||
'text-multi',
|
'text-multi',
|
||||||
var='presence-desc',
|
var='presence-desc',
|
||||||
label=_('Presence description:'))
|
label=_('Presence description:'))
|
||||||
|
@ -137,7 +137,7 @@ class ChangeStatusCommand(AdHocCommand):
|
||||||
self.connection.connection.send(response)
|
self.connection.connection.send(response)
|
||||||
|
|
||||||
# for next invocation
|
# for next invocation
|
||||||
self.cb = self.second_step
|
self._callback = self.second_step
|
||||||
|
|
||||||
return True # keep the session
|
return True # keep the session
|
||||||
|
|
||||||
|
@ -147,19 +147,19 @@ class ChangeStatusCommand(AdHocCommand):
|
||||||
form = dataforms.SimpleDataForm(
|
form = dataforms.SimpleDataForm(
|
||||||
extend=request.getTag('command').getTag('x'))
|
extend=request.getTag('command').getTag('x'))
|
||||||
except Exception:
|
except Exception:
|
||||||
self.badRequest(request)
|
self.bad_request(request)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
presencetype = form['presence-type'].value
|
presencetype = form['presence-type'].value
|
||||||
if presencetype not in ('chat', 'online', 'away',
|
if presencetype not in ('chat', 'online', 'away',
|
||||||
'xa', 'dnd', 'offline'):
|
'xa', 'dnd', 'offline'):
|
||||||
self.badRequest(request)
|
self.bad_request(request)
|
||||||
return False
|
return False
|
||||||
except Exception:
|
except Exception:
|
||||||
# KeyError if there's no presence-type field in form or
|
# KeyError if there's no presence-type field in form or
|
||||||
# AttributeError if that field is of wrong type
|
# AttributeError if that field is of wrong type
|
||||||
self.badRequest(request)
|
self.bad_request(request)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -167,7 +167,7 @@ class ChangeStatusCommand(AdHocCommand):
|
||||||
except Exception: # same exceptions as in last comment
|
except Exception: # same exceptions as in last comment
|
||||||
presencedesc = ''
|
presencedesc = ''
|
||||||
|
|
||||||
response, cmd = self.buildResponse(request, status='completed')
|
response, cmd = self.build_response(request, status='completed')
|
||||||
cmd.addChild('note', {}, _('The status has been changed.'))
|
cmd.addChild('note', {}, _('The status has been changed.'))
|
||||||
|
|
||||||
# if going offline, we need to push response so it won't go into
|
# if going offline, we need to push response so it won't go into
|
||||||
|
@ -206,23 +206,23 @@ class LeaveGroupchatsCommand(AdHocCommand):
|
||||||
|
|
||||||
def __init__(self, conn, jid, sessionid):
|
def __init__(self, conn, jid, sessionid):
|
||||||
AdHocCommand.__init__(self, conn, jid, sessionid)
|
AdHocCommand.__init__(self, conn, jid, sessionid)
|
||||||
self.cb = self.first_step
|
self._callback = self.first_step
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def isVisibleFor(samejid):
|
def is_visible_for(samejid):
|
||||||
"""
|
"""
|
||||||
Leave groupchats is visible only if the entity has the same bare jid
|
Leave groupchats is visible only if the entity has the same bare jid
|
||||||
"""
|
"""
|
||||||
return samejid
|
return samejid
|
||||||
|
|
||||||
def execute(self, request):
|
def execute(self, request):
|
||||||
return self.cb(request)
|
return self._callback(request)
|
||||||
|
|
||||||
def first_step(self, request):
|
def first_step(self, request):
|
||||||
# first query...
|
# first query...
|
||||||
response, cmd = self.buildResponse(request,
|
response, cmd = self.build_response(request,
|
||||||
defaultaction='execute',
|
defaultaction='execute',
|
||||||
actions=['execute'])
|
actions=['execute'])
|
||||||
options = []
|
options = []
|
||||||
account = self.connection.name
|
account = self.connection.name
|
||||||
for gc in find_current_groupchats(account):
|
for gc in find_current_groupchats(account):
|
||||||
|
@ -230,8 +230,8 @@ class LeaveGroupchatsCommand(AdHocCommand):
|
||||||
('%s' % gc[0],
|
('%s' % gc[0],
|
||||||
_('%(nickname)s on %(room_jid)s') % {'nickname': gc[1],
|
_('%(nickname)s on %(room_jid)s') % {'nickname': gc[1],
|
||||||
'room_jid': gc[0]}))
|
'room_jid': gc[0]}))
|
||||||
if not len(options):
|
if not options:
|
||||||
response, cmd = self.buildResponse(request, status='completed')
|
response, cmd = self.build_response(request, status='completed')
|
||||||
cmd.addChild('note', {}, _('You have not joined a groupchat.'))
|
cmd.addChild('note', {}, _('You have not joined a groupchat.'))
|
||||||
|
|
||||||
self.connection.connection.send(response)
|
self.connection.connection.send(response)
|
||||||
|
@ -242,7 +242,7 @@ class LeaveGroupchatsCommand(AdHocCommand):
|
||||||
title=_('Leave Groupchats'),
|
title=_('Leave Groupchats'),
|
||||||
instructions=_('Choose the groupchats you want to leave'),
|
instructions=_('Choose the groupchats you want to leave'),
|
||||||
fields=[
|
fields=[
|
||||||
dataforms.Field(
|
dataforms.create_field(
|
||||||
'list-multi',
|
'list-multi',
|
||||||
var='groupchats',
|
var='groupchats',
|
||||||
label=_('Groupchats'),
|
label=_('Groupchats'),
|
||||||
|
@ -255,7 +255,7 @@ class LeaveGroupchatsCommand(AdHocCommand):
|
||||||
self.connection.connection.send(response)
|
self.connection.connection.send(response)
|
||||||
|
|
||||||
# for next invocation
|
# for next invocation
|
||||||
self.cb = self.second_step
|
self._callback = self.second_step
|
||||||
|
|
||||||
return True # keep the session
|
return True # keep the session
|
||||||
|
|
||||||
|
@ -265,13 +265,13 @@ class LeaveGroupchatsCommand(AdHocCommand):
|
||||||
form = dataforms.SimpleDataForm(
|
form = dataforms.SimpleDataForm(
|
||||||
extend=request.getTag('command').getTag('x'))
|
extend=request.getTag('command').getTag('x'))
|
||||||
except Exception:
|
except Exception:
|
||||||
self.badRequest(request)
|
self.bad_request(request)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
gc = form['groupchats'].values
|
gc = form['groupchats'].values
|
||||||
except Exception: # KeyError if there's no groupchats in form
|
except Exception: # KeyError if there's no groupchats in form
|
||||||
self.badRequest(request)
|
self.bad_request(request)
|
||||||
return False
|
return False
|
||||||
account = self.connection.name
|
account = self.connection.name
|
||||||
try:
|
try:
|
||||||
|
@ -279,15 +279,16 @@ class LeaveGroupchatsCommand(AdHocCommand):
|
||||||
gc_control = app.interface.msg_win_mgr.get_gc_control(
|
gc_control = app.interface.msg_win_mgr.get_gc_control(
|
||||||
room_jid, account)
|
room_jid, account)
|
||||||
if not gc_control:
|
if not gc_control:
|
||||||
gc_control = app.interface.minimized_controls[account][room_jid]
|
minimized_controls = app.interface.minimized_controls
|
||||||
|
gc_control = minimized_controls[account][room_jid]
|
||||||
gc_control.shutdown()
|
gc_control.shutdown()
|
||||||
app.interface.roster.remove_groupchat(room_jid, account)
|
app.interface.roster.remove_groupchat(room_jid, account)
|
||||||
continue
|
continue
|
||||||
gc_control.parent_win.remove_tab(gc_control, None, force=True)
|
gc_control.parent_win.remove_tab(gc_control, None, force=True)
|
||||||
except Exception: # KeyError if there's no such room opened
|
except Exception: # KeyError if there's no such room opened
|
||||||
self.badRequest(request)
|
self.bad_request(request)
|
||||||
return False
|
return False
|
||||||
response, cmd = self.buildResponse(request, status='completed')
|
response, cmd = self.build_response(request, status='completed')
|
||||||
note = _('You left the following groupchats:')
|
note = _('You left the following groupchats:')
|
||||||
for room_jid in gc:
|
for room_jid in gc:
|
||||||
note += '\n\t' + room_jid
|
note += '\n\t' + room_jid
|
||||||
|
@ -327,13 +328,13 @@ class AdHocCommands:
|
||||||
def command_list_query(self, stanza):
|
def command_list_query(self, stanza):
|
||||||
iq = stanza.buildReply('result')
|
iq = stanza.buildReply('result')
|
||||||
jid = helpers.get_full_jid_from_iq(stanza)
|
jid = helpers.get_full_jid_from_iq(stanza)
|
||||||
q = iq.getTag('query')
|
query = iq.getTag('query')
|
||||||
# buildReply don't copy the node attribute. Re-add it
|
# buildReply don't copy the node attribute. Re-add it
|
||||||
q.setAttr('node', nbxmpp.NS_COMMANDS)
|
query.setAttr('node', nbxmpp.NS_COMMANDS)
|
||||||
|
|
||||||
for node, cmd in self._commands.items():
|
for node, cmd in self._commands.items():
|
||||||
if cmd.isVisibleFor(self.is_same_jid(jid)):
|
if cmd.is_visible_for(self.is_same_jid(jid)):
|
||||||
q.addChild('item', {
|
query.addChild('item', {
|
||||||
# TODO: find the jid
|
# TODO: find the jid
|
||||||
'jid': str(self._con.get_own_jid()),
|
'jid': str(self._con.get_own_jid()),
|
||||||
'node': node,
|
'node': node,
|
||||||
|
@ -349,7 +350,7 @@ class AdHocCommands:
|
||||||
try:
|
try:
|
||||||
jid = helpers.get_full_jid_from_iq(stanza)
|
jid = helpers.get_full_jid_from_iq(stanza)
|
||||||
except helpers.InvalidFormat:
|
except helpers.InvalidFormat:
|
||||||
log.warning('Invalid JID: %s, ignoring it' % stanza.getFrom())
|
log.warning('Invalid JID: %s, ignoring it', stanza.getFrom())
|
||||||
return
|
return
|
||||||
node = stanza.getTagAttr('query', 'node')
|
node = stanza.getTagAttr('query', 'node')
|
||||||
|
|
||||||
|
@ -357,16 +358,16 @@ class AdHocCommands:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
cmd = self._commands[node]
|
cmd = self._commands[node]
|
||||||
if cmd.isVisibleFor(self.is_same_jid(jid)):
|
if cmd.is_visible_for(self.is_same_jid(jid)):
|
||||||
iq = stanza.buildReply('result')
|
iq = stanza.buildReply('result')
|
||||||
q = iq.getTag('query')
|
query = iq.getTag('query')
|
||||||
q.addChild('identity',
|
query.addChild('identity',
|
||||||
attrs={'type': 'command-node',
|
attrs={'type': 'command-node',
|
||||||
'category': 'automation',
|
'category': 'automation',
|
||||||
'name': cmd.commandname})
|
'name': cmd.commandname})
|
||||||
q.addChild('feature', attrs={'var': nbxmpp.NS_COMMANDS})
|
query.addChild('feature', attrs={'var': nbxmpp.NS_COMMANDS})
|
||||||
for feature in cmd.commandfeatures:
|
for feature in cmd.commandfeatures:
|
||||||
q.addChild('feature', attrs={'var': feature})
|
query.addChild('feature', attrs={'var': feature})
|
||||||
|
|
||||||
self._con.connection.send(iq)
|
self._con.connection.send(iq)
|
||||||
return True
|
return True
|
||||||
|
@ -385,14 +386,14 @@ class AdHocCommands:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
cmd = self._commands[node]
|
cmd = self._commands[node]
|
||||||
if cmd.isVisibleFor(self.is_same_jid(jid)):
|
if cmd.is_visible_for(self.is_same_jid(jid)):
|
||||||
iq = stanza.buildReply('result')
|
iq = stanza.buildReply('result')
|
||||||
self._con.connection.send(iq)
|
self._con.connection.send(iq)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _execute_command_received(self, con, stanza):
|
def _execute_command_received(self, _con, stanza):
|
||||||
jid = helpers.get_full_jid_from_iq(stanza)
|
jid = helpers.get_full_jid_from_iq(stanza)
|
||||||
|
|
||||||
cmd = stanza.getTag('command')
|
cmd = stanza.getTag('command')
|
||||||
|
@ -417,7 +418,7 @@ class AdHocCommands:
|
||||||
raise nbxmpp.NodeProcessed
|
raise nbxmpp.NodeProcessed
|
||||||
|
|
||||||
newcmd = self._commands[node]
|
newcmd = self._commands[node]
|
||||||
if not newcmd.isVisibleFor(self.is_same_jid(jid)):
|
if not newcmd.is_visible_for(self.is_same_jid(jid)):
|
||||||
log.warning('Command not visible for jid: %s', jid)
|
log.warning('Command not visible for jid: %s', jid)
|
||||||
raise nbxmpp.NodeProcessed
|
raise nbxmpp.NodeProcessed
|
||||||
|
|
||||||
|
@ -492,7 +493,9 @@ class AdHocCommands:
|
||||||
items = stanza.getQueryPayload()
|
items = stanza.getQueryPayload()
|
||||||
commandlist = []
|
commandlist = []
|
||||||
if items:
|
if items:
|
||||||
commandlist = [(t.getAttr('node'), t.getAttr('name')) for t in items]
|
commandlist = [
|
||||||
|
(t.getAttr('node'), t.getAttr('name')) for t in items
|
||||||
|
]
|
||||||
|
|
||||||
log.info('Received: %s', commandlist)
|
log.info('Received: %s', commandlist)
|
||||||
app.nec.push_incoming_event(
|
app.nec.push_incoming_event(
|
||||||
|
@ -550,7 +553,8 @@ class AdHocCommands:
|
||||||
self._con.connection.SendAndCallForResponse(
|
self._con.connection.SendAndCallForResponse(
|
||||||
stanza, self._cancel_result_received)
|
stanza, self._cancel_result_received)
|
||||||
|
|
||||||
def _cancel_result_received(self, stanza):
|
@staticmethod
|
||||||
|
def _cancel_result_received(stanza):
|
||||||
if not nbxmpp.isResultNode(stanza):
|
if not nbxmpp.isResultNode(stanza):
|
||||||
log.warning('Error: %s', stanza.getError())
|
log.warning('Error: %s', stanza.getError())
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -44,10 +44,10 @@ class AtomData(AbstractPEPData):
|
||||||
type_ = PEPEventType.ATOM
|
type_ = PEPEventType.ATOM
|
||||||
|
|
||||||
def __init__(self, atom):
|
def __init__(self, atom):
|
||||||
self._pep_specific_data = atom
|
self.data = atom
|
||||||
|
|
||||||
def get_entry(self):
|
def get_entry(self):
|
||||||
return self._pep_specific_data
|
return self.data
|
||||||
|
|
||||||
|
|
||||||
class Atom(AbstractPEPModule):
|
class Atom(AbstractPEPModule):
|
||||||
|
|
|
@ -39,22 +39,22 @@ class WrongFieldValue(Error):
|
||||||
|
|
||||||
|
|
||||||
# helper class to change class of already existing object
|
# helper class to change class of already existing object
|
||||||
class ExtendedNode(nbxmpp.Node, object):
|
class ExtendedNode(nbxmpp.Node):
|
||||||
@classmethod
|
@classmethod
|
||||||
def __new__(cls, *a, **b):
|
def __new__(cls, *args, **kwargs):
|
||||||
if 'extend' not in b.keys() or not b['extend']:
|
if 'extend' not in kwargs.keys() or not kwargs['extend']:
|
||||||
return object.__new__(cls)
|
return object.__new__(cls)
|
||||||
|
|
||||||
extend = b['extend']
|
extend = kwargs['extend']
|
||||||
assert issubclass(cls, extend.__class__)
|
assert issubclass(cls, extend.__class__)
|
||||||
extend.__class__ = cls
|
extend.__class__ = cls
|
||||||
return extend
|
return extend
|
||||||
|
|
||||||
|
|
||||||
# helper to create fields from scratch
|
# helper to create fields from scratch
|
||||||
def Field(typ, **attrs):
|
def create_field(typ, **attrs):
|
||||||
''' Helper function to create a field of given type. '''
|
''' Helper function to create a field of given type. '''
|
||||||
f = {
|
field = {
|
||||||
'boolean': BooleanField,
|
'boolean': BooleanField,
|
||||||
'fixed': StringField,
|
'fixed': StringField,
|
||||||
'hidden': StringField,
|
'hidden': StringField,
|
||||||
|
@ -66,18 +66,18 @@ def Field(typ, **attrs):
|
||||||
'list-single': ListSingleField,
|
'list-single': ListSingleField,
|
||||||
'text-multi': TextMultiField,
|
'text-multi': TextMultiField,
|
||||||
}[typ](typ=typ, **attrs)
|
}[typ](typ=typ, **attrs)
|
||||||
return f
|
return field
|
||||||
|
|
||||||
|
|
||||||
def ExtendField(node):
|
def extend_field(node):
|
||||||
"""
|
"""
|
||||||
Helper function to extend a node to field of appropriate type
|
Helper function to extend a node to field of appropriate type
|
||||||
"""
|
"""
|
||||||
# when validation (XEP-122) will go in, we could have another classes
|
# when validation (XEP-122) will go in, we could have another classes
|
||||||
# like DateTimeField - so that dicts in Field() and ExtendField() will
|
# like DateTimeField - so that dicts in create_field() and
|
||||||
# be different...
|
# extend_field() will be different...
|
||||||
typ = node.getAttr('type')
|
typ = node.getAttr('type')
|
||||||
f = {
|
field = {
|
||||||
'boolean': BooleanField,
|
'boolean': BooleanField,
|
||||||
'fixed': StringField,
|
'fixed': StringField,
|
||||||
'hidden': StringField,
|
'hidden': StringField,
|
||||||
|
@ -89,25 +89,24 @@ def ExtendField(node):
|
||||||
'list-single': ListSingleField,
|
'list-single': ListSingleField,
|
||||||
'text-multi': TextMultiField,
|
'text-multi': TextMultiField,
|
||||||
}
|
}
|
||||||
if typ not in f:
|
if typ not in field:
|
||||||
typ = 'text-single'
|
typ = 'text-single'
|
||||||
return f[typ](extend=node)
|
return field[typ](extend=node)
|
||||||
|
|
||||||
|
|
||||||
def ExtendForm(node):
|
def extend_form(node):
|
||||||
"""
|
"""
|
||||||
Helper function to extend a node to form of appropriate type
|
Helper function to extend a node to form of appropriate type
|
||||||
"""
|
"""
|
||||||
if node.getTag('reported') is not None:
|
if node.getTag('reported') is not None:
|
||||||
return MultipleDataForm(extend=node)
|
return MultipleDataForm(extend=node)
|
||||||
else:
|
return SimpleDataForm(extend=node)
|
||||||
return SimpleDataForm(extend=node)
|
|
||||||
|
|
||||||
|
|
||||||
class DataField(ExtendedNode):
|
class DataField(ExtendedNode):
|
||||||
"""
|
"""
|
||||||
Keeps data about one field - var, field type, labels, instructions... Base
|
Keeps data about one field - var, field type, labels, instructions... Base
|
||||||
class for different kinds of fields. Use Field() function to construct one
|
class for different kinds of fields. Use create_field() function to construct one
|
||||||
of these
|
of these
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -136,10 +135,10 @@ class DataField(ExtendedNode):
|
||||||
'text-private', 'text-single'. If you set this to something different,
|
'text-private', 'text-single'. If you set this to something different,
|
||||||
DataField will store given name, but treat all data as text-single
|
DataField will store given name, but treat all data as text-single
|
||||||
"""
|
"""
|
||||||
t = self.getAttr('type')
|
type_ = self.getAttr('type')
|
||||||
if t is None:
|
if type_ is None:
|
||||||
return 'text-single'
|
return 'text-single'
|
||||||
return t
|
return type_
|
||||||
|
|
||||||
@type_.setter
|
@type_.setter
|
||||||
def type_(self, value):
|
def type_(self, value):
|
||||||
|
@ -199,9 +198,9 @@ class DataField(ExtendedNode):
|
||||||
|
|
||||||
@description.deleter
|
@description.deleter
|
||||||
def description(self):
|
def description(self):
|
||||||
t = self.getTag('desc')
|
desc = self.getTag('desc')
|
||||||
if t is not None:
|
if desc is not None:
|
||||||
self.delChild(t)
|
self.delChild(desc)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def required(self):
|
def required(self):
|
||||||
|
@ -212,10 +211,10 @@ class DataField(ExtendedNode):
|
||||||
|
|
||||||
@required.setter
|
@required.setter
|
||||||
def required(self, value):
|
def required(self, value):
|
||||||
t = self.getTag('required')
|
required = self.getTag('required')
|
||||||
if t and not value:
|
if required and not value:
|
||||||
self.delChild(t)
|
self.delChild(required)
|
||||||
elif not t and value:
|
elif not required and value:
|
||||||
self.addChild('required')
|
self.addChild('required')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -234,11 +233,12 @@ class DataField(ExtendedNode):
|
||||||
|
|
||||||
@media.deleter
|
@media.deleter
|
||||||
def media(self):
|
def media(self):
|
||||||
t = self.getTag('media')
|
media = self.getTag('media')
|
||||||
if t is not None:
|
if media is not None:
|
||||||
self.delChild(t)
|
self.delChild(media)
|
||||||
|
|
||||||
def is_valid(self):
|
@staticmethod
|
||||||
|
def is_valid():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,12 +306,12 @@ class BooleanField(DataField):
|
||||||
"""
|
"""
|
||||||
Value of field. May contain True, False or None
|
Value of field. May contain True, False or None
|
||||||
"""
|
"""
|
||||||
v = self.getTagData('value')
|
value = self.getTagData('value')
|
||||||
if v in ('0', 'false'):
|
if value in ('0', 'false'):
|
||||||
return False
|
return False
|
||||||
if v in ('1', 'true'):
|
if value in ('1', 'true'):
|
||||||
return True
|
return True
|
||||||
if v is None:
|
if value is None:
|
||||||
return False # default value is False
|
return False # default value is False
|
||||||
raise WrongFieldValue
|
raise WrongFieldValue
|
||||||
|
|
||||||
|
@ -321,9 +321,9 @@ class BooleanField(DataField):
|
||||||
|
|
||||||
@value.deleter
|
@value.deleter
|
||||||
def value(self):
|
def value(self):
|
||||||
t = self.getTag('value')
|
value = self.getTag('value')
|
||||||
if t is not None:
|
if value is not None:
|
||||||
self.delChild(t)
|
self.delChild(value)
|
||||||
|
|
||||||
|
|
||||||
class StringField(DataField):
|
class StringField(DataField):
|
||||||
|
@ -366,13 +366,13 @@ class ListField(DataField):
|
||||||
"""
|
"""
|
||||||
options = []
|
options = []
|
||||||
for element in self.getTags('option'):
|
for element in self.getTags('option'):
|
||||||
v = element.getTagData('value')
|
value = element.getTagData('value')
|
||||||
if v is None:
|
if value is None:
|
||||||
raise WrongFieldValue
|
raise WrongFieldValue
|
||||||
label = element.getAttr('label')
|
label = element.getAttr('label')
|
||||||
if not label:
|
if not label:
|
||||||
label = v
|
label = value
|
||||||
options.append((label, v))
|
options.append((label, value))
|
||||||
return options
|
return options
|
||||||
|
|
||||||
@options.setter
|
@options.setter
|
||||||
|
@ -389,13 +389,13 @@ class ListField(DataField):
|
||||||
|
|
||||||
def iter_options(self):
|
def iter_options(self):
|
||||||
for element in self.iterTags('option'):
|
for element in self.iterTags('option'):
|
||||||
v = element.getTagData('value')
|
value = element.getTagData('value')
|
||||||
if v is None:
|
if value is None:
|
||||||
raise WrongFieldValue
|
raise WrongFieldValue
|
||||||
label = element.getAttr('label')
|
label = element.getAttr('label')
|
||||||
if not label:
|
if not label:
|
||||||
label = v
|
label = value
|
||||||
yield (v, label)
|
yield (value, label)
|
||||||
|
|
||||||
|
|
||||||
class ListSingleField(ListField, StringField):
|
class ListSingleField(ListField, StringField):
|
||||||
|
@ -469,7 +469,7 @@ class JidMultiField(ListMultiField):
|
||||||
Covers jid-multi fields
|
Covers jid-multi fields
|
||||||
"""
|
"""
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
if len(self.values):
|
if self.values:
|
||||||
for value in self.values:
|
for value in self.values:
|
||||||
try:
|
try:
|
||||||
helpers.parse_jid(value)
|
helpers.parse_jid(value)
|
||||||
|
@ -526,7 +526,7 @@ class DataRecord(ExtendedNode):
|
||||||
if fields is None:
|
if fields is None:
|
||||||
for field in self.iterTags('field'):
|
for field in self.iterTags('field'):
|
||||||
if not isinstance(field, DataField):
|
if not isinstance(field, DataField):
|
||||||
ExtendField(field)
|
extend_field(field)
|
||||||
self.vars[field.var] = field
|
self.vars[field.var] = field
|
||||||
else:
|
else:
|
||||||
for field in self.getTags('field'):
|
for field in self.getTags('field'):
|
||||||
|
@ -545,7 +545,7 @@ class DataRecord(ExtendedNode):
|
||||||
del self.fields
|
del self.fields
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if not isinstance(field, DataField):
|
if not isinstance(field, DataField):
|
||||||
ExtendField(field)
|
extend_field(field)
|
||||||
self.addChild(node=field)
|
self.addChild(node=field)
|
||||||
|
|
||||||
@fields.deleter
|
@fields.deleter
|
||||||
|
@ -572,8 +572,8 @@ class DataRecord(ExtendedNode):
|
||||||
return self.vars[item]
|
return self.vars[item]
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
for f in self.iter_fields():
|
for field in self.iter_fields():
|
||||||
if not f.is_valid():
|
if not field.is_valid():
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -660,27 +660,29 @@ class SimpleDataForm(DataForm, DataRecord):
|
||||||
DataRecord.__init__(self, fields=fields, extend=self, associated=self)
|
DataRecord.__init__(self, fields=fields, extend=self, associated=self)
|
||||||
|
|
||||||
def get_purged(self):
|
def get_purged(self):
|
||||||
c = SimpleDataForm(extend=self)
|
simple_form = SimpleDataForm(extend=self)
|
||||||
del c.title
|
del simple_form.title
|
||||||
c.instructions = ''
|
simple_form.instructions = ''
|
||||||
to_be_removed = []
|
to_be_removed = []
|
||||||
for f in c.iter_fields():
|
for field in simple_form.iter_fields():
|
||||||
if f.required:
|
if field.required:
|
||||||
# add <value> if there is not
|
# add <value> if there is not
|
||||||
if hasattr(f, 'value') and not f.value:
|
if hasattr(field, 'value') and not field.value:
|
||||||
f.value = ''
|
field.value = ''
|
||||||
# Keep all required fields
|
# Keep all required fields
|
||||||
continue
|
continue
|
||||||
if ((hasattr(f, 'value') and not f.value and f.value != 0) or
|
if ((hasattr(field, 'value') and
|
||||||
(hasattr(f, 'values') and len(f.values) == 0)):
|
not field.value and
|
||||||
to_be_removed.append(f)
|
field.value != 0) or
|
||||||
|
(hasattr(field, 'values') and not field.values)):
|
||||||
|
to_be_removed.append(field)
|
||||||
else:
|
else:
|
||||||
del f.label
|
del field.label
|
||||||
del f.description
|
del field.description
|
||||||
del f.media
|
del field.media
|
||||||
for f in to_be_removed:
|
for field in to_be_removed:
|
||||||
c.delChild(f)
|
simple_form.delChild(field)
|
||||||
return c
|
return simple_form
|
||||||
|
|
||||||
|
|
||||||
class MultipleDataForm(DataForm):
|
class MultipleDataForm(DataForm):
|
||||||
|
|
|
@ -130,7 +130,7 @@ class MUC:
|
||||||
|
|
||||||
for form in payload:
|
for form in payload:
|
||||||
if form.getNamespace() == nbxmpp.NS_DATA:
|
if form.getNamespace() == nbxmpp.NS_DATA:
|
||||||
dataform = dataforms.ExtendForm(node=form)
|
dataform = dataforms.extend_form(node=form)
|
||||||
log.info('Config form received for %s', room_jid)
|
log.info('Config form received for %s', room_jid)
|
||||||
app.nec.push_incoming_event(MucOwnerReceivedEvent(
|
app.nec.push_incoming_event(MucOwnerReceivedEvent(
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -211,10 +211,10 @@ class AbstractPEPData:
|
||||||
return other == self.type_
|
return other == self.type_
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
return self._pep_specific_data is not None
|
return self.data is not None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self._pep_specific_data)
|
return str(self.data)
|
||||||
|
|
||||||
|
|
||||||
class PEPReceivedEvent(NetworkIncomingEvent):
|
class PEPReceivedEvent(NetworkIncomingEvent):
|
||||||
|
|
|
@ -138,15 +138,15 @@ class Presence:
|
||||||
if not app.account_is_connected(self._account):
|
if not app.account_is_connected(self._account):
|
||||||
return
|
return
|
||||||
if remove_auth:
|
if remove_auth:
|
||||||
self._con.getRoster().delItem(jid)
|
self._con.getRoster().del_item(jid)
|
||||||
jid_list = app.config.get_per('contacts')
|
jid_list = app.config.get_per('contacts')
|
||||||
for j in jid_list:
|
for j in jid_list:
|
||||||
if j.startswith(jid):
|
if j.startswith(jid):
|
||||||
app.config.del_per('contacts', j)
|
app.config.del_per('contacts', j)
|
||||||
else:
|
else:
|
||||||
log.info('Unsubscribe from %s', jid)
|
log.info('Unsubscribe from %s', jid)
|
||||||
self._con.getRoster().Unsubscribe(jid)
|
self._con.getRoster().unsubscribe(jid)
|
||||||
self._con.getRoster().setItem(jid)
|
self._con.getRoster().set_item(jid)
|
||||||
|
|
||||||
def subscribe(self, jid, msg=None, name='', groups=None, auto_auth=False):
|
def subscribe(self, jid, msg=None, name='', groups=None, auto_auth=False):
|
||||||
if not app.account_is_connected(self._account):
|
if not app.account_is_connected(self._account):
|
||||||
|
|
|
@ -254,7 +254,7 @@ class PubSub:
|
||||||
|
|
||||||
app.nec.push_incoming_event(PubSubConfigReceivedEvent(
|
app.nec.push_incoming_event(PubSubConfigReceivedEvent(
|
||||||
None, conn=self._con, node=node,
|
None, conn=self._con, node=node,
|
||||||
form=dataforms.ExtendForm(node=form)))
|
form=dataforms.extend_form(node=form)))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _default_callback(_con, stanza, *args, **kwargs):
|
def _default_callback(_con, stanza, *args, **kwargs):
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Roster:
|
||||||
account_jid = self._con.get_own_jid().getStripped()
|
account_jid = self._con.get_own_jid().getStripped()
|
||||||
data = app.logger.get_roster(account_jid)
|
data = app.logger.get_roster(account_jid)
|
||||||
if data:
|
if data:
|
||||||
self.setRaw(data)
|
self.set_raw(data)
|
||||||
for jid, item in self._data.items():
|
for jid, item in self._data.items():
|
||||||
app.nec.push_incoming_event(NetworkEvent(
|
app.nec.push_incoming_event(NetworkEvent(
|
||||||
'roster-info',
|
'roster-info',
|
||||||
|
@ -170,7 +170,7 @@ class Roster:
|
||||||
|
|
||||||
attrs = item.getAttrs()
|
attrs = item.getAttrs()
|
||||||
del attrs['jid']
|
del attrs['jid']
|
||||||
groups = set([group.getData() for group in item.getTags('group')])
|
groups = {group.getData() for group in item.getTags('group')}
|
||||||
attrs['groups'] = list(groups)
|
attrs['groups'] = list(groups)
|
||||||
|
|
||||||
if update:
|
if update:
|
||||||
|
@ -241,14 +241,14 @@ class Roster:
|
||||||
self._data[jid]['ask'],
|
self._data[jid]['ask'],
|
||||||
self._data[jid]['groups'])
|
self._data[jid]['groups'])
|
||||||
|
|
||||||
def _getItemData(self, jid, dataname):
|
def _get_item_data(self, jid, dataname):
|
||||||
"""
|
"""
|
||||||
Return specific jid's representation in internal format.
|
Return specific jid's representation in internal format.
|
||||||
"""
|
"""
|
||||||
jid = jid[:(jid + '/').find('/')]
|
jid = jid[:(jid + '/').find('/')]
|
||||||
return self._data[jid][dataname]
|
return self._data[jid][dataname]
|
||||||
|
|
||||||
def delItem(self, jid):
|
def del_item(self, jid):
|
||||||
"""
|
"""
|
||||||
Delete contact 'jid' from roster
|
Delete contact 'jid' from roster
|
||||||
"""
|
"""
|
||||||
|
@ -256,19 +256,19 @@ class Roster:
|
||||||
nbxmpp.Iq('set', nbxmpp.NS_ROSTER, payload=[
|
nbxmpp.Iq('set', nbxmpp.NS_ROSTER, payload=[
|
||||||
nbxmpp.Node('item', {'jid': jid, 'subscription': 'remove'})]))
|
nbxmpp.Node('item', {'jid': jid, 'subscription': 'remove'})]))
|
||||||
|
|
||||||
def getGroups(self, jid):
|
def get_groups(self, jid):
|
||||||
"""
|
"""
|
||||||
Return groups list that contact 'jid' belongs to
|
Return groups list that contact 'jid' belongs to
|
||||||
"""
|
"""
|
||||||
return self._getItemData(jid, 'groups')
|
return self._get_item_data(jid, 'groups')
|
||||||
|
|
||||||
def getName(self, jid):
|
def get_name(self, jid):
|
||||||
"""
|
"""
|
||||||
Return name of contact 'jid'
|
Return name of contact 'jid'
|
||||||
"""
|
"""
|
||||||
return self._getItemData(jid, 'name')
|
return self._get_item_data(jid, 'name')
|
||||||
|
|
||||||
def setItem(self, jid, name=None, groups=None):
|
def set_item(self, jid, name=None, groups=None):
|
||||||
"""
|
"""
|
||||||
Rename contact 'jid' and sets the groups list that it now belongs to
|
Rename contact 'jid' and sets the groups list that it now belongs to
|
||||||
"""
|
"""
|
||||||
|
@ -283,7 +283,7 @@ class Roster:
|
||||||
item.addChild(node=nbxmpp.Node('group', payload=[group]))
|
item.addChild(node=nbxmpp.Node('group', payload=[group]))
|
||||||
self._con.connection.send(iq)
|
self._con.connection.send(iq)
|
||||||
|
|
||||||
def setItemMulti(self, items):
|
def set_item_multi(self, items):
|
||||||
"""
|
"""
|
||||||
Rename multiple contacts and sets their group lists
|
Rename multiple contacts and sets their group lists
|
||||||
"""
|
"""
|
||||||
|
@ -298,7 +298,7 @@ class Roster:
|
||||||
item.addChild(node=nbxmpp.Node('group', payload=[group]))
|
item.addChild(node=nbxmpp.Node('group', payload=[group]))
|
||||||
self._con.connection.send(iq)
|
self._con.connection.send(iq)
|
||||||
|
|
||||||
def getItems(self):
|
def get_items(self):
|
||||||
"""
|
"""
|
||||||
Return list of all [bare] JIDs that the roster is currently tracks
|
Return list of all [bare] JIDs that the roster is currently tracks
|
||||||
"""
|
"""
|
||||||
|
@ -306,7 +306,7 @@ class Roster:
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
"""
|
"""
|
||||||
Same as getItems. Provided for the sake of dictionary interface
|
Same as get_items. Provided for the sake of dictionary interface
|
||||||
"""
|
"""
|
||||||
return list(self._data.keys())
|
return list(self._data.keys())
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ class Roster:
|
||||||
"""
|
"""
|
||||||
return self._data[item]
|
return self._data[item]
|
||||||
|
|
||||||
def getItem(self, item):
|
def get_item(self, item):
|
||||||
"""
|
"""
|
||||||
Get the contact in the internal format (or None if JID 'item' is not in
|
Get the contact in the internal format (or None if JID 'item' is not in
|
||||||
roster)
|
roster)
|
||||||
|
@ -325,19 +325,19 @@ class Roster:
|
||||||
if item in self._data:
|
if item in self._data:
|
||||||
return self._data[item]
|
return self._data[item]
|
||||||
|
|
||||||
def Unsubscribe(self, jid):
|
def unsubscribe(self, jid):
|
||||||
"""
|
"""
|
||||||
Ask for removing our subscription for JID 'jid'
|
Ask for removing our subscription for JID 'jid'
|
||||||
"""
|
"""
|
||||||
self._con.connection.send(nbxmpp.Presence(jid, 'unsubscribe'))
|
self._con.connection.send(nbxmpp.Presence(jid, 'unsubscribe'))
|
||||||
|
|
||||||
def getRaw(self):
|
def get_raw(self):
|
||||||
"""
|
"""
|
||||||
Return the internal data representation of the roster
|
Return the internal data representation of the roster
|
||||||
"""
|
"""
|
||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
def setRaw(self, data):
|
def set_raw(self, data):
|
||||||
"""
|
"""
|
||||||
Set the internal data representation of the roster
|
Set the internal data representation of the roster
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -31,10 +31,10 @@ class UserActivityData(AbstractPEPData):
|
||||||
type_ = PEPEventType.ACTIVITY
|
type_ = PEPEventType.ACTIVITY
|
||||||
|
|
||||||
def __init__(self, activity):
|
def __init__(self, activity):
|
||||||
self._pep_specific_data = activity
|
self.data = activity
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
pep = self._pep_specific_data
|
pep = self.data
|
||||||
activity = pep['activity']
|
activity = pep['activity']
|
||||||
subactivity = pep['subactivity'] if 'subactivity' in pep else None
|
subactivity = pep['subactivity'] if 'subactivity' in pep else None
|
||||||
text = pep['text'] if 'text' in pep else None
|
text = pep['text'] if 'text' in pep else None
|
||||||
|
|
|
@ -33,7 +33,7 @@ class UserAvatarData(AbstractPEPData):
|
||||||
type_ = PEPEventType.AVATAR
|
type_ = PEPEventType.AVATAR
|
||||||
|
|
||||||
def __init__(self, avatar):
|
def __init__(self, avatar):
|
||||||
self._pep_specific_data = avatar
|
self.data = avatar
|
||||||
|
|
||||||
|
|
||||||
class UserAvatar(AbstractPEPModule):
|
class UserAvatar(AbstractPEPModule):
|
||||||
|
@ -124,7 +124,7 @@ class UserAvatar(AbstractPEPModule):
|
||||||
return avatar or None
|
return avatar or None
|
||||||
|
|
||||||
def _notification_received(self, jid, user_pep):
|
def _notification_received(self, jid, user_pep):
|
||||||
avatar = user_pep._pep_specific_data
|
avatar = user_pep.data
|
||||||
own_jid = self._con.get_own_jid()
|
own_jid = self._con.get_own_jid()
|
||||||
if avatar is None:
|
if avatar is None:
|
||||||
# Remove avatar
|
# Remove avatar
|
||||||
|
|
|
@ -31,10 +31,12 @@ class UserLocationData(AbstractPEPData):
|
||||||
type_ = PEPEventType.LOCATION
|
type_ = PEPEventType.LOCATION
|
||||||
|
|
||||||
def __init__(self, location):
|
def __init__(self, location):
|
||||||
|
# set_location plugin uses self._pep_specific_data
|
||||||
self._pep_specific_data = location
|
self._pep_specific_data = location
|
||||||
|
self.data = location
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
location = self._pep_specific_data
|
location = self.data
|
||||||
location_string = ''
|
location_string = ''
|
||||||
|
|
||||||
for entry in location.keys():
|
for entry in location.keys():
|
||||||
|
|
|
@ -31,13 +31,13 @@ class UserMoodData(AbstractPEPData):
|
||||||
type_ = PEPEventType.MOOD
|
type_ = PEPEventType.MOOD
|
||||||
|
|
||||||
def __init__(self, mood):
|
def __init__(self, mood):
|
||||||
self._pep_specific_data = mood
|
self.data = mood
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
mood = self._translate_mood(self._pep_specific_data['mood'])
|
mood = self._translate_mood(self.data['mood'])
|
||||||
markuptext = '<b>%s</b>' % GLib.markup_escape_text(mood)
|
markuptext = '<b>%s</b>' % GLib.markup_escape_text(mood)
|
||||||
if 'text' in self._pep_specific_data:
|
if 'text' in self.data:
|
||||||
text = self._pep_specific_data['text']
|
text = self.data['text']
|
||||||
markuptext += ' (%s)' % GLib.markup_escape_text(text)
|
markuptext += ' (%s)' % GLib.markup_escape_text(text)
|
||||||
return markuptext
|
return markuptext
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@ class UserNicknameData(AbstractPEPData):
|
||||||
type_ = PEPEventType.NICKNAME
|
type_ = PEPEventType.NICKNAME
|
||||||
|
|
||||||
def __init__(self, nickname):
|
def __init__(self, nickname):
|
||||||
self._pep_specific_data = nickname
|
self.data = nickname
|
||||||
|
|
||||||
def get_nick(self):
|
def get_nick(self):
|
||||||
return self._pep_specific_data or ''
|
return self.data or ''
|
||||||
|
|
||||||
|
|
||||||
class UserNickname(AbstractPEPModule):
|
class UserNickname(AbstractPEPModule):
|
||||||
|
|
|
@ -31,10 +31,10 @@ class UserTuneData(AbstractPEPData):
|
||||||
type_ = PEPEventType.TUNE
|
type_ = PEPEventType.TUNE
|
||||||
|
|
||||||
def __init__(self, tune):
|
def __init__(self, tune):
|
||||||
self._pep_specific_data = tune
|
self.data = tune
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
tune = self._pep_specific_data
|
tune = self.data
|
||||||
|
|
||||||
artist = tune.get('artist', _('Unknown Artist'))
|
artist = tune.get('artist', _('Unknown Artist'))
|
||||||
artist = GLib.markup_escape_text(artist)
|
artist = GLib.markup_escape_text(artist)
|
||||||
|
|
|
@ -40,7 +40,7 @@ class AbstractPEP(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __init__(self, jid, account, items):
|
def __init__(self, jid, account, items):
|
||||||
self._pep_specific_data, self._retracted = self._extract_info(items)
|
self.data, self._retracted = self._extract_info(items)
|
||||||
|
|
||||||
self._update_contacts(jid, account)
|
self._update_contacts(jid, account)
|
||||||
if jid == app.get_jid_from_account(account):
|
if jid == app.get_jid_from_account(account):
|
||||||
|
|
|
@ -1554,7 +1554,7 @@ class DataFormWindow(Dialog):
|
||||||
self.set_resizable(True)
|
self.set_resizable(True)
|
||||||
gtkgui_helpers.resize_window(self, 600, 400)
|
gtkgui_helpers.resize_window(self, 600, 400)
|
||||||
self.dataform_widget = dataforms_widget.DataFormWidget()
|
self.dataform_widget = dataforms_widget.DataFormWidget()
|
||||||
self.dataform = dataforms.ExtendForm(node=form)
|
self.dataform = dataforms.extend_form(node=form)
|
||||||
self.dataform_widget.set_sensitive(True)
|
self.dataform_widget.set_sensitive(True)
|
||||||
self.dataform_widget.data_form = self.dataform
|
self.dataform_widget.data_form = self.dataform
|
||||||
self.dataform_widget.show_all()
|
self.dataform_widget.show_all()
|
||||||
|
|
|
@ -1200,7 +1200,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.form_widget.hide()
|
self.form_widget.hide()
|
||||||
self.form_widget.destroy()
|
self.form_widget.destroy()
|
||||||
self.btn_box.destroy()
|
self.btn_box.destroy()
|
||||||
dataform = dataforms.ExtendForm(node=obj.captcha_form)
|
dataform = dataforms.extend_form(node=obj.captcha_form)
|
||||||
self.form_widget = dataforms_widget.DataFormWidget(dataform)
|
self.form_widget = dataforms_widget.DataFormWidget(dataform)
|
||||||
|
|
||||||
def on_send_dataform_clicked(widget):
|
def on_send_dataform_clicked(widget):
|
||||||
|
|
|
@ -371,7 +371,7 @@ class AccountCreationWizard:
|
||||||
self.is_form = obj.is_form
|
self.is_form = obj.is_form
|
||||||
empty_config = True
|
empty_config = True
|
||||||
if obj.is_form:
|
if obj.is_form:
|
||||||
dataform = dataforms.ExtendForm(node=obj.config)
|
dataform = dataforms.extend_form(node=obj.config)
|
||||||
self.data_form_widget = dataforms_widget.DataFormWidget()
|
self.data_form_widget = dataforms_widget.DataFormWidget()
|
||||||
self.data_form_widget.selectable = True
|
self.data_form_widget.selectable = True
|
||||||
self.data_form_widget.set_data_form(dataform)
|
self.data_form_widget.set_data_form(dataform)
|
||||||
|
|
|
@ -86,7 +86,7 @@ class ServiceRegistration(Gtk.Assistant):
|
||||||
log.info('Show Form page')
|
log.info('Show Form page')
|
||||||
self._is_form = is_form
|
self._is_form = is_form
|
||||||
if is_form:
|
if is_form:
|
||||||
dataform = dataforms.ExtendForm(node=form)
|
dataform = dataforms.extend_form(node=form)
|
||||||
self._data_form_widget = DataFormWidget(dataform)
|
self._data_form_widget = DataFormWidget(dataform)
|
||||||
else:
|
else:
|
||||||
from gajim import config
|
from gajim import config
|
||||||
|
|
|
@ -79,7 +79,7 @@ class SingleMessageWindow:
|
||||||
parent_box = self.xml.get_object('conversation_scrolledwindow').\
|
parent_box = self.xml.get_object('conversation_scrolledwindow').\
|
||||||
get_parent()
|
get_parent()
|
||||||
if form_node:
|
if form_node:
|
||||||
dataform = dataforms.ExtendForm(node=form_node)
|
dataform = dataforms.extend_form(node=form_node)
|
||||||
dataform.type_ = 'submit'
|
dataform.type_ = 'submit'
|
||||||
self.form_widget = DataFormWidget(dataform)
|
self.form_widget = DataFormWidget(dataform)
|
||||||
self.form_widget.show_all()
|
self.form_widget.show_all()
|
||||||
|
|
|
@ -607,7 +607,7 @@ def load_activity_icon(category, activity = None):
|
||||||
|
|
||||||
def get_pep_as_pixbuf(pep_class):
|
def get_pep_as_pixbuf(pep_class):
|
||||||
if pep_class == PEPEventType.MOOD:
|
if pep_class == PEPEventType.MOOD:
|
||||||
received_mood = pep_class._pep_specific_data['mood']
|
received_mood = pep_class.data['mood']
|
||||||
mood = received_mood if received_mood in MOODS else 'unknown'
|
mood = received_mood if received_mood in MOODS else 'unknown'
|
||||||
pixbuf = load_mood_icon(mood).get_pixbuf()
|
pixbuf = load_mood_icon(mood).get_pixbuf()
|
||||||
return pixbuf
|
return pixbuf
|
||||||
|
@ -619,7 +619,7 @@ def get_pep_as_pixbuf(pep_class):
|
||||||
return GdkPixbuf.Pixbuf.new_from_file(path)
|
return GdkPixbuf.Pixbuf.new_from_file(path)
|
||||||
return icon
|
return icon
|
||||||
elif pep_class == PEPEventType.ACTIVITY:
|
elif pep_class == PEPEventType.ACTIVITY:
|
||||||
pep_ = pep_class._pep_specific_data
|
pep_ = pep_class.data
|
||||||
activity = pep_['activity']
|
activity = pep_['activity']
|
||||||
|
|
||||||
has_known_activity = activity in ACTIVITIES
|
has_known_activity = activity in ACTIVITIES
|
||||||
|
|
|
@ -2432,7 +2432,7 @@ class Interface:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_pep_icon(pep_obj):
|
def get_pep_icon(pep_obj):
|
||||||
if pep_obj == PEPEventType.MOOD:
|
if pep_obj == PEPEventType.MOOD:
|
||||||
received_mood = pep_obj._pep_specific_data['mood']
|
received_mood = pep_obj.data['mood']
|
||||||
mood = received_mood if received_mood in MOODS else 'unknown'
|
mood = received_mood if received_mood in MOODS else 'unknown'
|
||||||
return gtkgui_helpers.load_mood_icon(mood).get_pixbuf()
|
return gtkgui_helpers.load_mood_icon(mood).get_pixbuf()
|
||||||
elif pep_obj == PEPEventType.TUNE:
|
elif pep_obj == PEPEventType.TUNE:
|
||||||
|
@ -2440,7 +2440,7 @@ class Interface:
|
||||||
configpaths.get('DATA'), 'emoticons', 'static', 'music.png')
|
configpaths.get('DATA'), 'emoticons', 'static', 'music.png')
|
||||||
return GdkPixbuf.Pixbuf.new_from_file(path)
|
return GdkPixbuf.Pixbuf.new_from_file(path)
|
||||||
elif pep_obj == PEPEventType.ACTIVITY:
|
elif pep_obj == PEPEventType.ACTIVITY:
|
||||||
pep_ = pep_obj._pep_specific_data
|
pep_ = pep_obj.data
|
||||||
activity = pep_['activity']
|
activity = pep_['activity']
|
||||||
|
|
||||||
has_known_activity = activity in ACTIVITIES
|
has_known_activity = activity in ACTIVITIES
|
||||||
|
|
|
@ -136,7 +136,7 @@ class SearchWindow:
|
||||||
if obj.is_dataform:
|
if obj.is_dataform:
|
||||||
self.is_form = True
|
self.is_form = True
|
||||||
self.data_form_widget = dataforms_widget.DataFormWidget()
|
self.data_form_widget = dataforms_widget.DataFormWidget()
|
||||||
self.dataform = dataforms.ExtendForm(node=obj.data)
|
self.dataform = dataforms.extend_form(node=obj.data)
|
||||||
self.data_form_widget.set_sensitive(True)
|
self.data_form_widget.set_sensitive(True)
|
||||||
try:
|
try:
|
||||||
self.data_form_widget.data_form = self.dataform
|
self.data_form_widget.data_form = self.dataform
|
||||||
|
@ -208,7 +208,7 @@ class SearchWindow:
|
||||||
self.information_button.show()
|
self.information_button.show()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.dataform = dataforms.ExtendForm(node=obj.data)
|
self.dataform = dataforms.extend_form(node=obj.data)
|
||||||
if len(self.dataform.items) == 0:
|
if len(self.dataform.items) == 0:
|
||||||
# No result
|
# No result
|
||||||
self.label.set_text(_('No result'))
|
self.label.set_text(_('No result'))
|
||||||
|
|
Loading…
Reference in New Issue