Changeset 8407

Show
Ignore:
Timestamp:
07/18/07 14:07:21 (17 months ago)
Author:
roidelapluie
Message:

Add send_groupchat_message to gajim-remote. Fix #2447.

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gajim-remote.py

    r7811 r8407  
    138138                                        ] 
    139139                                ],  
     140                        'send_groupchat_message':[ 
     141                                        _('Sends new message to a groupchat you\'ve joined.'),  
     142                                        [ 
     143                                                ('room_jid', _('JID of the room that will receive the message'), True), 
     144                                                (_('message'), _('message contents'), True), 
     145                                                (_('account'), _('if specified, the message will be sent ' 
     146                                                        'using this account'), False), 
     147                                        ] 
     148                                ], 
    140149                        'contact_info': [ 
    141150                                        _('Gets detailed info on a contact'),  
  • trunk/src/remote_control.py

    r8386 r8407  
    226226                return connected_account, contact 
    227227 
     228        def _get_account_for_groupchat(self, account, room_jid): 
     229                '''get the account which is connected to groupchat (if not given) 
     230                or check if the given account is connected to the groupchat''' 
     231                correct_account = None 
     232                accounts = gajim.contacts.get_accounts() 
     233                # if there is only one account in roster, take it as default 
     234                # if user did not ask for account 
     235                if not account and len(accounts) == 1: 
     236                        account = accounts[0] 
     237                if account: 
     238                        if gajim.connections[account].connected > 1 and \ 
     239                        room_jid in gajim.gc_connected[account] and \ 
     240                        gajim.gc_connected[account][room_jid]: 
     241                                # account and groupchat are connected 
     242                                connected_account = account 
     243                else: 
     244                        for account in accounts: 
     245                                if gajim.connections[account].connected > 1 and \ 
     246                                room_jid in gajim.gc_connected[account] and \ 
     247                                gajim.gc_connected[account][room_jid]: 
     248                                        # account and groupchat are connected 
     249                                        connected_account = account 
     250                                        break 
     251                return connected_account 
     252 
    228253        @dbus.service.method(INTERFACE, in_signature='sss', out_signature='b') 
    229254        def send_file(self, file_path, jid, account): 
     
    271296                jid = self._get_real_jid(jid, account) 
    272297                return self._send_message(jid, message, keyID, account, type, subject) 
     298 
     299        @dbus.service.method(INTERFACE, in_signature='sss', out_signature='b') 
     300        def send_groupchat_message(self, room_jid, message, account): 
     301                '''Send 'message' to groupchat 'room_jid', 
     302                using account (optional) 'account'.''' 
     303                if not room_jid or not message: 
     304                        return DBUS_BOOLEAN(False) 
     305                connected_account = self._get_account_for_groupchat(account, room_jid) 
     306                if connected_account: 
     307                        connection = gajim.connections[connected_account] 
     308                        connection.send_gc_message(room_jid, message) 
     309                        return DBUS_BOOLEAN(True) 
     310                return DBUS_BOOLEAN(False) 
    273311 
    274312        @dbus.service.method(INTERFACE, in_signature='ss', out_signature='b')