| ... |
... |
@@ -26,7 +26,6 @@ import nbxmpp |
|
26
|
26
|
from gajim.common import helpers
|
|
27
|
27
|
from gajim.common import dataforms
|
|
28
|
28
|
from gajim.common import app
|
|
29
|
|
-from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
|
30
|
29
|
|
|
31
|
30
|
import logging
|
|
32
|
31
|
log = logging.getLogger('gajim.c.commands')
|
| ... |
... |
@@ -277,80 +276,6 @@ class LeaveGroupchatsCommand(AdHocCommand): |
|
277
|
276
|
return False
|
|
278
|
277
|
|
|
279
|
278
|
|
|
280
|
|
-class ForwardMessagesCommand(AdHocCommand):
|
|
281
|
|
- # http://www.xmpp.org/extensions/xep-0146.html#forward
|
|
282
|
|
- commandnode = 'forward-messages'
|
|
283
|
|
- commandname = _('Forward unread messages')
|
|
284
|
|
-
|
|
285
|
|
- @staticmethod
|
|
286
|
|
- def isVisibleFor(samejid):
|
|
287
|
|
- """
|
|
288
|
|
- Forward messages is visible only if the entity has the same bare jid
|
|
289
|
|
- """
|
|
290
|
|
- return samejid
|
|
291
|
|
-
|
|
292
|
|
- def execute(self, request):
|
|
293
|
|
- account = self.connection.name
|
|
294
|
|
- # Forward messages
|
|
295
|
|
- events = app.events.get_events(account, types=['chat', 'normal',
|
|
296
|
|
- 'printed_chat'])
|
|
297
|
|
- j, resource = app.get_room_and_nick_from_fjid(self.jid)
|
|
298
|
|
- for jid in events:
|
|
299
|
|
- for event in events[jid]:
|
|
300
|
|
- ev_typ = event.type_
|
|
301
|
|
- if ev_typ == 'printed_chat':
|
|
302
|
|
- ev_typ = 'chat'
|
|
303
|
|
- app.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
|
304
|
|
- account=account, jid=j, message=event.message, type_=ev_typ,
|
|
305
|
|
- subject=event.subject, resource=resource, forward_from=jid,
|
|
306
|
|
- delayed=event.time_))
|
|
307
|
|
-
|
|
308
|
|
- # Inform other client of completion
|
|
309
|
|
- response, cmd = self.buildResponse(request, status = 'completed')
|
|
310
|
|
- cmd.addChild('note', {}, _('All unread messages have been forwarded.'))
|
|
311
|
|
-
|
|
312
|
|
- self.connection.connection.send(response)
|
|
313
|
|
-
|
|
314
|
|
- return False # finish the session
|
|
315
|
|
-
|
|
316
|
|
-class FwdMsgThenDisconnectCommand(AdHocCommand):
|
|
317
|
|
- commandnode = 'fwd-msd-disconnect'
|
|
318
|
|
- commandname = _('Forward unread message then disconnect')
|
|
319
|
|
-
|
|
320
|
|
- @staticmethod
|
|
321
|
|
- def isVisibleFor(samejid):
|
|
322
|
|
- """
|
|
323
|
|
- Forward unread messages then disconnect is visible only if the entity has the same bare jid
|
|
324
|
|
- """
|
|
325
|
|
- return samejid
|
|
326
|
|
-
|
|
327
|
|
- def execute(self, request):
|
|
328
|
|
- account = self.connection.name
|
|
329
|
|
- # Forward messages
|
|
330
|
|
- events = app.events.get_events(account, types=['chat', 'normal'])
|
|
331
|
|
- j, resource = app.get_room_and_nick_from_fjid(self.jid)
|
|
332
|
|
- for jid in events:
|
|
333
|
|
- for event in events[jid]:
|
|
334
|
|
- ev_typ = event.type_
|
|
335
|
|
- if ev_typ == 'printed_chat':
|
|
336
|
|
- ev_typ = 'chat'
|
|
337
|
|
- app.nec.push_outgoing_event(MessageOutgoingEvent(None,
|
|
338
|
|
- account=account, jid=j, message=event.message, type_=ev_typ,
|
|
339
|
|
- subject=event.subject, resource=resource, forward_from=jid,
|
|
340
|
|
- delayed=event.time_, now=True))
|
|
341
|
|
-
|
|
342
|
|
- response, cmd = self.buildResponse(request, status = 'completed')
|
|
343
|
|
- cmd.addChild('note', {}, _('The status has been changed.'))
|
|
344
|
|
-
|
|
345
|
|
- # if going offline, we need to push response so it won't go into
|
|
346
|
|
- # queue and disappear
|
|
347
|
|
- self.connection.connection.send(response, now = True)
|
|
348
|
|
-
|
|
349
|
|
- # send new status
|
|
350
|
|
- app.interface.roster.send_status(self.connection.name, 'offline', '')
|
|
351
|
|
- # finish the session
|
|
352
|
|
- return False
|
|
353
|
|
-
|
|
354
|
279
|
class ConnectionCommands:
|
|
355
|
280
|
"""
|
|
356
|
281
|
This class depends on that it is a part of Connection() class
|
| ... |
... |
@@ -360,8 +285,7 @@ class ConnectionCommands: |
|
360
|
285
|
# a list of all commands exposed: node -> command class
|
|
361
|
286
|
self.__commands = {}
|
|
362
|
287
|
if app.config.get('remote_commands'):
|
|
363
|
|
- for cmdobj in (ChangeStatusCommand, ForwardMessagesCommand,
|
|
364
|
|
- LeaveGroupchatsCommand, FwdMsgThenDisconnectCommand):
|
|
|
288
|
+ for cmdobj in (ChangeStatusCommand, LeaveGroupchatsCommand):
|
|
365
|
289
|
self.__commands[cmdobj.commandnode] = cmdobj
|
|
366
|
290
|
|
|
367
|
291
|
# a list of sessions; keys are tuples (jid, sessionid, node)
|