Changeset 6488

Show
Ignore:
Timestamp:
06/16/06 18:09:46 (2 years ago)
Author:
jim++
Message:

[maciekp] Send single message with gajim-remote, fixes #2026.

Location:
trunk/src
Files:
2 modified

Legend:

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

    r6479 r6488  
    127127                                ], 
    128128                        'send_message':[ 
    129                                         _('Sends new message to a contact in the roster. Both OpenPGP key ' 
     129                                        _('Sends new chat message to a contact in the roster. Both OpenPGP key ' 
    130130                                        'and account are optional. If you want to set only \'account\', ' 
    131131                                        'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'),  
    132132                                        [ 
    133133                                                ('jid', _('JID of the contact that will receive the message'), True), 
     134                                                (_('message'), _('message contents'), True), 
     135                                                (_('pgp key'), _('if specified, the message will be encrypted ' 
     136                                                        'using this public key'), False), 
     137                                                (_('account'), _('if specified, the message will be sent ' 
     138                                                        'using this account'), False), 
     139                                        ] 
     140                                ], 
     141                        'send_single_message':[ 
     142                                        _('Sends new single message to a contact in the roster. Both OpenPGP key ' 
     143                                        'and account are optional. If you want to set only \'account\', ' 
     144                                        'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.'),  
     145                                        [ 
     146                                                ('jid', _('JID of the contact that will receive the message'), True), 
     147                                                (_('subject'), _('message subject'), True), 
    134148                                                (_('message'), _('message contents'), True), 
    135149                                                (_('pgp key'), _('if specified, the message will be encrypted ' 
     
    253267                ''' Print retrieved result to the output ''' 
    254268                if res is not None: 
    255                         if self.command in ('open_chat', 'send_message', 'start_chat'): 
    256                                 if self.command == 'send_message': 
     269                        if self.command in ('open_chat', 'send_message', 'send_single_message', 'start_chat'): 
     270                                if self.command in ('send_message', 'send_single_message'): 
    257271                                        self.argv_len -= 2 
    258272                                 
  • trunk/src/remote_control.py

    r6479 r6488  
    160160                                self.open_chat, 
    161161                                self.send_message, 
     162                                self.send_single_message, 
    162163                                self.contact_info, 
    163164                                self.send_file, 
     
    252253        def send_message(self, *args): 
    253254                ''' send_message(jid, message, keyID=None, account=None) 
    254                 send 'message' to 'jid', using account (optional) 'account'. 
     255                send chat 'message' to 'jid', using account (optional) 'account'. 
    255256                if keyID is specified, encrypt the message with the pgp key ''' 
    256257                jid, message, keyID, account = self._get_real_arguments(args, 4) 
     
    265266                        connection = gajim.connections[connected_account] 
    266267                        res = connection.send_message(jid, message, keyID) 
     268                        return True 
     269                return False 
     270 
     271        def send_single_message(self, *args): 
     272                ''' send_single_message(jid, subject, message, keyID=None, account=None) 
     273                send single 'message' to 'jid', using account (optional) 'account'. 
     274                if keyID is specified, encrypt the message with the pgp key ''' 
     275                jid, subject, message, keyID, account = self._get_real_arguments(args, 5) 
     276                if not jid or not message: 
     277                        return None # or raise error 
     278                if not keyID: 
     279                        keyID = '' 
     280                 
     281                connected_account, contact = self.get_account_and_contact(account, jid) 
     282                 
     283                if connected_account: 
     284                        connection = gajim.connections[connected_account] 
     285                        res = connection.send_message(jid, message, keyID, 
     286                                                      type='normal', 
     287                                                      subject=subject) 
    267288                        return True 
    268289                return False 
     
    579600        contact_info = method(INTERFACE)(contact_info) 
    580601        send_message = method(INTERFACE)(send_message) 
     602        send_single_message = method(INTERFACE)(send_single_message) 
    581603        send_file = method(INTERFACE)(send_file) 
    582604        prefs_list = method(INTERFACE)(prefs_list)