ability to send a file to a groupchat occupant if we know his real JID
This commit is contained in:
		
							parent
							
								
									2adf3dc837
								
							
						
					
					
						commit
						0758be7c14
					
				
					 3 changed files with 44 additions and 6 deletions
				
			
		|  | @ -87,6 +87,20 @@ | |||
|         </child> | ||||
|       </widget> | ||||
|     </child> | ||||
|     <child> | ||||
|       <widget class="GtkImageMenuItem" id="send_file_menuitem"> | ||||
|         <property name="visible">True</property> | ||||
|         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | ||||
|         <property name="label" translatable="yes">Send _File</property> | ||||
|         <property name="use_underline">True</property> | ||||
|         <child internal-child="image"> | ||||
|           <widget class="GtkImage" id="menu-item-image4"> | ||||
|             <property name="stock">gtk-save</property> | ||||
|             <property name="icon_size">1</property> | ||||
|           </widget> | ||||
|         </child> | ||||
|       </widget> | ||||
|     </child> | ||||
|     <child> | ||||
|       <widget class="GtkSeparatorMenuItem" id="separator6"> | ||||
|         <property name="visible">True</property> | ||||
|  |  | |||
|  | @ -1504,7 +1504,10 @@ class ChatControl(ChatControlBase): | |||
| 		 | ||||
| 		# If we don't have resource, we can't do file transfer | ||||
| 		# in transports, contact holds our info we need to disable it too | ||||
| 		if contact.resource and contact.jid.find('@') != -1: | ||||
| 		if self.TYPE_ID == message_control.TYPE_PM and self.gc_contact.jid and \ | ||||
| 		self.gc_contact.resource: | ||||
| 			send_file_menuitem.set_sensitive(True) | ||||
| 		elif contact.resource and contact.jid.find('@') != -1: | ||||
| 			send_file_menuitem.set_sensitive(True) | ||||
| 		else: | ||||
| 			send_file_menuitem.set_sensitive(False) | ||||
|  | @ -1721,7 +1724,11 @@ class ChatControl(ChatControlBase): | |||
| 	def _on_drag_data_received(self, widget, context, x, y, selection, | ||||
| 		target_type, timestamp): | ||||
| 		# If not resource, we can't send file | ||||
| 		if not self.contact.resource: | ||||
| 		if self.TYPE_ID == message_control.TYPE_PM: | ||||
| 			c = self.gc_contact | ||||
| 		else: | ||||
| 			c = self.contact | ||||
| 		if not c.resource: | ||||
| 			return | ||||
| 		if target_type == self.TARGET_TYPE_URI_LIST: | ||||
| 			uri = selection.data.strip() | ||||
|  | @ -1730,7 +1737,7 @@ class ChatControl(ChatControlBase): | |||
| 				path = helpers.get_file_path_from_dnd_dropped_uri(uri) | ||||
| 				if os.path.isfile(path): # is it file? | ||||
| 					ft = gajim.interface.instances['file_transfers'] | ||||
| 					ft.send_file(self.account, self.contact, path) | ||||
| 					ft.send_file(self.account, c, path) | ||||
| 
 | ||||
| 	def _on_message_tv_buffer_changed(self, textbuffer): | ||||
| 		self.kbd_activity_in_last_5_secs = True | ||||
|  | @ -1929,8 +1936,12 @@ class ChatControl(ChatControlBase): | |||
| 		self.bigger_avatar_window.window.set_cursor(cursor) | ||||
| 
 | ||||
| 	def _on_send_file_menuitem_activate(self, widget): | ||||
| 		if self.TYPE_ID == message_control.TYPE_PM: | ||||
| 			c = self.gc_contact | ||||
| 		else: | ||||
| 			c = self.contact | ||||
| 		gajim.interface.instances['file_transfers'].show_file_send_request(  | ||||
| 			self.account, self.contact) | ||||
| 			self.account, c) | ||||
| 
 | ||||
| 	def _on_add_to_roster_menuitem_activate(self, widget): | ||||
| 		dialogs.AddNewContactWindow(self.account, self.contact.jid) | ||||
|  |  | |||
|  | @ -822,6 +822,11 @@ class GroupchatControl(ChatControlBase): | |||
| 			gajim.interface.msg_win_mgr.get_control(fjid, self.account).\ | ||||
| 				send_message(msg) | ||||
| 
 | ||||
| 	def on_send_file(self, widget, gc_contact): | ||||
| 		'''sends a file to a contact in the room''' | ||||
| 		gajim.interface.instances['file_transfers'].show_file_send_request( | ||||
| 			self.account, gc_contact) | ||||
| 
 | ||||
| 	def draw_contact(self, nick, selected=False, focus=False): | ||||
| 		iter = self.get_contact_iter(nick) | ||||
| 		if not iter: | ||||
|  | @ -1848,13 +1853,21 @@ class GroupchatControl(ChatControlBase): | |||
| 		item = xml.get_widget('add_to_roster_menuitem') | ||||
| 		if not jid: | ||||
| 			item.set_sensitive(False) | ||||
| 		id = item.connect('activate', self.on_add_to_roster, jid) | ||||
| 		self.handlers[id] = item | ||||
| 		else: | ||||
| 			id = item.connect('activate', self.on_add_to_roster, jid) | ||||
| 			self.handlers[id] = item | ||||
| 
 | ||||
| 		item = xml.get_widget('send_private_message_menuitem') | ||||
| 		id = item.connect('activate', self.on_send_pm, model, iter) | ||||
| 		self.handlers[id] = item | ||||
| 
 | ||||
| 		item = xml.get_widget('send_file_menuitem') | ||||
| 		if not c.resource: | ||||
| 			item.set_sensitive(False) | ||||
| 		else: | ||||
| 			id = item.connect('activate', self.on_send_file, c) | ||||
| 			self.handlers[id] = item | ||||
| 
 | ||||
| 		# show the popup now! | ||||
| 		menu = xml.get_widget('gc_occupants_menu') | ||||
| 		menu.show_all() | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue