[Dicson] add support for key 'body' in the Message Action, and add jid via roster command. Fixes #5195
This commit is contained in:
		
							parent
							
								
									770b21fa60
								
							
						
					
					
						commit
						b83f9ae5d6
					
				
					 3 changed files with 38 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -120,7 +120,10 @@ class GajimRemote:
 | 
			
		|||
						('jid', _('JID of the contact that you want to chat with'),
 | 
			
		||||
							True),
 | 
			
		||||
						(_('account'), _('if specified, contact is taken from the '
 | 
			
		||||
						'contact list of this account'), False)
 | 
			
		||||
							'contact list of this account'), False),
 | 
			
		||||
						(_('message'),
 | 
			
		||||
							_('message content. The account must be specified or ""'),
 | 
			
		||||
							False)
 | 
			
		||||
					]
 | 
			
		||||
				],
 | 
			
		||||
			'send_chat_message':[
 | 
			
		||||
| 
						 | 
				
			
			@ -257,7 +260,8 @@ class GajimRemote:
 | 
			
		|||
					[
 | 
			
		||||
						(_('uri'), _('URI to handle'), True),
 | 
			
		||||
						(_('account'), _('Account in which you want to handle it'),
 | 
			
		||||
							False)
 | 
			
		||||
							False),
 | 
			
		||||
						(_('message'), _('Message content'), False)
 | 
			
		||||
					]
 | 
			
		||||
				],
 | 
			
		||||
			'join_room': [
 | 
			
		||||
| 
						 | 
				
			
			@ -282,7 +286,7 @@ class GajimRemote:
 | 
			
		|||
			}
 | 
			
		||||
 | 
			
		||||
		self.sbus = None
 | 
			
		||||
		if self.argv_len  < 2 or sys.argv[1] not in self.commands.keys():
 | 
			
		||||
		if self.argv_len < 2 or sys.argv[1] not in self.commands.keys():
 | 
			
		||||
			# no args or bad args
 | 
			
		||||
			send_error(self.compose_help())
 | 
			
		||||
		self.command = sys.argv[1]
 | 
			
		||||
| 
						 | 
				
			
			@ -405,7 +409,7 @@ class GajimRemote:
 | 
			
		|||
			if len(command_props[1]) > 0:
 | 
			
		||||
				str_ += '\n\n' + _('Arguments:') + '\n'
 | 
			
		||||
				for argument in command_props[1]:
 | 
			
		||||
					str_ += ' ' +  argument[0] + ' - ' + argument[1] + '\n'
 | 
			
		||||
					str_ += ' ' + argument[0] + ' - ' + argument[1] + '\n'
 | 
			
		||||
			return str_
 | 
			
		||||
		send_error(_('%s not found') % command)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -506,6 +510,25 @@ class GajimRemote:
 | 
			
		|||
		if not '?' in uri:
 | 
			
		||||
			self.command = sys.argv[1] = 'open_chat'
 | 
			
		||||
			return
 | 
			
		||||
		if 'body=' in uri:
 | 
			
		||||
			# Open chat window and paste the text in the input message dialog
 | 
			
		||||
			self.command = sys.argv[1] = 'open_chat'
 | 
			
		||||
			message = uri.split('body=')
 | 
			
		||||
			message = message[1].split(';')[0]
 | 
			
		||||
			try:
 | 
			
		||||
				message = urllib.unquote(message)
 | 
			
		||||
			except UnicodeDecodeError:
 | 
			
		||||
				pass
 | 
			
		||||
			sys.argv[2] = uri.split('?')[0]
 | 
			
		||||
			if len(sys.argv) == 4:
 | 
			
		||||
				# jid in the sys.argv
 | 
			
		||||
				sys.argv.append(message)
 | 
			
		||||
			else:
 | 
			
		||||
				sys.argv.append('')
 | 
			
		||||
				sys.argv.append(message)
 | 
			
		||||
				sys.argv[3] = ''
 | 
			
		||||
				sys.argv[4] = message
 | 
			
		||||
			return
 | 
			
		||||
		(jid, action) = uri.split('?', 1)
 | 
			
		||||
		try:
 | 
			
		||||
			jid = urllib.unquote(jid)
 | 
			
		||||
| 
						 | 
				
			
			@ -519,7 +542,10 @@ class GajimRemote:
 | 
			
		|||
			sys.argv.append(sys.argv[3])
 | 
			
		||||
			sys.argv[3] = ''
 | 
			
		||||
			return
 | 
			
		||||
 | 
			
		||||
		if action.startswith('roster'):
 | 
			
		||||
			# Add contact to roster
 | 
			
		||||
			self.command = sys.argv[1] = 'add_contact'
 | 
			
		||||
			return
 | 
			
		||||
		sys.exit(0)
 | 
			
		||||
 | 
			
		||||
	def call_remote_method(self):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2887,7 +2887,7 @@ class Interface:
 | 
			
		|||
 | 
			
		||||
		return chat_control
 | 
			
		||||
 | 
			
		||||
	def new_chat_from_jid(self, account, fjid):
 | 
			
		||||
	def new_chat_from_jid(self, account, fjid, message=None):
 | 
			
		||||
		jid, resource = gajim.get_room_and_nick_from_fjid(fjid)
 | 
			
		||||
		contact = gajim.contacts.get_contact(account, jid, resource)
 | 
			
		||||
		added_to_roster = False
 | 
			
		||||
| 
						 | 
				
			
			@ -2904,6 +2904,9 @@ class Interface:
 | 
			
		|||
			if len(gajim.events.get_events(account, fjid)):
 | 
			
		||||
				ctrl.read_queue()
 | 
			
		||||
 | 
			
		||||
		if message:
 | 
			
		||||
			buffer = ctrl.msg_textview.get_buffer()
 | 
			
		||||
			buffer.set_text(message)
 | 
			
		||||
		mw = ctrl.parent_win
 | 
			
		||||
		mw.set_active_tab(ctrl)
 | 
			
		||||
		# For JEP-0172
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -329,8 +329,8 @@ class SignalObject(dbus.service.Object):
 | 
			
		|||
			return DBUS_BOOLEAN(True)
 | 
			
		||||
		return DBUS_BOOLEAN(False)
 | 
			
		||||
 | 
			
		||||
	@dbus.service.method(INTERFACE, in_signature='ss', out_signature='b')
 | 
			
		||||
	def open_chat(self, jid, account):
 | 
			
		||||
	@dbus.service.method(INTERFACE, in_signature='sss', out_signature='b')
 | 
			
		||||
	def open_chat(self, jid, account, message):
 | 
			
		||||
		'''Shows the tabbed window for new message to 'jid', using account
 | 
			
		||||
		(optional) 'account' '''
 | 
			
		||||
		if not jid:
 | 
			
		||||
| 
						 | 
				
			
			@ -372,7 +372,7 @@ class SignalObject(dbus.service.Object):
 | 
			
		|||
			connected_account = first_connected_acct
 | 
			
		||||
 | 
			
		||||
		if connected_account:
 | 
			
		||||
			gajim.interface.new_chat_from_jid(connected_account, jid)
 | 
			
		||||
			gajim.interface.new_chat_from_jid(connected_account, jid, message)
 | 
			
		||||
			# preserve the 'steal focus preservation'
 | 
			
		||||
			win = gajim.interface.msg_win_mgr.get_window(jid,
 | 
			
		||||
				connected_account).window
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue