Show
Ignore:
Timestamp:
08/09/07 17:39:18 (17 months ago)
Author:
asterix
Message:

merge diff from trunk to pep branch

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/pep/src/common/commands.py

    r8014 r8478  
    237237 
    238238 
     239class ForwardMessagesCommand(AdHocCommand): 
     240        # http://www.xmpp.org/extensions/xep-0146.html#forward 
     241        commandnode = 'forward-messages' 
     242        commandname = _('Forward unread messages') 
     243 
     244        @staticmethod 
     245        def isVisibleFor(samejid): 
     246                ''' Change status is visible only if the entity has the same bare jid. ''' 
     247                return samejid 
     248 
     249        def execute(self, request): 
     250                account = self.connection.name 
     251                # Forward messages 
     252                events = gajim.events.get_events(account, types=['chat', 'normal']) 
     253                j, resource = gajim.get_room_and_nick_from_fjid(self.jid) 
     254                for jid in events: 
     255                        for event in events[jid]: 
     256                                self.connection.send_message(j, event.parameters[0], '', 
     257                                        type=event.type_, subject=event.parameters[1], 
     258                                        resource=resource, forward_from=jid) 
     259 
     260                # Inform other client of completion 
     261                response, cmd = self.buildResponse(request, status = 'completed') 
     262                cmd.addChild('note', {}, _('All unread messages have been forwarded.')) 
     263 
     264                self.connection.connection.send(response) 
     265 
     266                return False    # finish the session 
     267 
    239268class ConnectionCommands: 
    240269        ''' This class depends on that it is a part of Connection() class. ''' 
     
    242271                # a list of all commands exposed: node -> command class 
    243272                self.__commands = {} 
    244                 for cmdobj in (ChangeStatusCommand, LeaveGroupchatsCommand): 
     273                for cmdobj in (ChangeStatusCommand, ForwardMessagesCommand, 
     274                LeaveGroupchatsCommand): 
    245275                        self.__commands[cmdobj.commandnode] = cmdobj 
    246276