| | 239 | class 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 | |