don't allow to bookmark a room on server that don't support private storage.
This commit is contained in:
		
							parent
							
								
									45046024aa
								
							
						
					
					
						commit
						176593db97
					
				
					 6 changed files with 34 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -151,7 +151,7 @@ class Connection(ConnectionHandlers):
 | 
			
		|||
		self.available_transports = {} # list of available transports on this
 | 
			
		||||
		# server {'icq': ['icq.server.com', 'icq2.server.com'], }
 | 
			
		||||
		self.vcard_supported = True
 | 
			
		||||
		self.metacontacts_supported = True
 | 
			
		||||
		self.private_storage_supported = True
 | 
			
		||||
	# END __init__
 | 
			
		||||
 | 
			
		||||
	def put_event(self, ev):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1072,7 +1072,7 @@ class ConnectionVcard:
 | 
			
		|||
						meta_list[tag] = [data]
 | 
			
		||||
				self.dispatch('METACONTACTS', meta_list)
 | 
			
		||||
			else:
 | 
			
		||||
				self.metacontacts_supported = False
 | 
			
		||||
				self.private_storage_supported = False
 | 
			
		||||
			# We can now continue connection by requesting the roster
 | 
			
		||||
			self.connection.initRoster()
 | 
			
		||||
		elif self.awaiting_answers[id][0] == PRIVACY_ARRIVED:
 | 
			
		||||
| 
						 | 
				
			
			@ -1286,7 +1286,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
 | 
			
		|||
		if storage_tag:
 | 
			
		||||
			ns = storage_tag.getNamespace()
 | 
			
		||||
			if ns == 'storage:metacontacts':
 | 
			
		||||
				self.metacontacts_supported = False
 | 
			
		||||
				self.private_storage_supported = False
 | 
			
		||||
				# Private XML Storage (XEP49) is not supported by server
 | 
			
		||||
				# Continue connecting
 | 
			
		||||
				self.connection.initRoster()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2676,6 +2676,8 @@ class ManageBookmarksWindow:
 | 
			
		|||
				continue
 | 
			
		||||
			if gajim.connections[account].is_zeroconf:
 | 
			
		||||
				continue
 | 
			
		||||
			if not gajim.connections[account].private_storage_supported:
 | 
			
		||||
				continue
 | 
			
		||||
			iter = self.treestore.append(None, [None, account, None, None,
 | 
			
		||||
				None, None, None, None])
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1289,6 +1289,9 @@ class JoinGroupchatWindow:
 | 
			
		|||
		if len(self._empty_required_widgets):
 | 
			
		||||
			self.xml.get_widget('join_button').set_sensitive(False)
 | 
			
		||||
 | 
			
		||||
		if not gajim.connections[account].private_storage_supported:
 | 
			
		||||
			self.xml.get_widget('auto_join_checkbutton').set_sensitive(False)
 | 
			
		||||
 | 
			
		||||
		self.window.show_all()
 | 
			
		||||
 | 
			
		||||
	def on_join_groupchat_window_destroy(self, widget):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -221,10 +221,10 @@ class GroupchatControl(ChatControlBase):
 | 
			
		|||
		# connect the menuitems to their respective functions
 | 
			
		||||
		xm = gtkgui_helpers.get_glade('gc_control_popup_menu.glade')
 | 
			
		||||
 | 
			
		||||
		widget = xm.get_widget('bookmark_room_menuitem')
 | 
			
		||||
		id = widget.connect('activate',
 | 
			
		||||
		self.bookmark_room_menuitem = xm.get_widget('bookmark_room_menuitem')
 | 
			
		||||
		id = self.bookmark_room_menuitem.connect('activate',
 | 
			
		||||
			self._on_bookmark_room_menuitem_activate)
 | 
			
		||||
		self.handlers[id] = widget
 | 
			
		||||
		self.handlers[id] = self.bookmark_room_menuitem
 | 
			
		||||
 | 
			
		||||
		self.change_nick_menuitem = xm.get_widget('change_nick_menuitem')
 | 
			
		||||
		id = self.change_nick_menuitem.connect('activate',
 | 
			
		||||
| 
						 | 
				
			
			@ -494,6 +494,8 @@ class GroupchatControl(ChatControlBase):
 | 
			
		|||
		if self.contact.jid in gajim.config.get_per('accounts', self.account,
 | 
			
		||||
		'minimized_gc').split(' '):
 | 
			
		||||
			self.minimize_menuitem.set_active(True)
 | 
			
		||||
		if not gajim.connections[self.account].private_storage_supported:
 | 
			
		||||
			self.bookmark_room_menuitem.set_sensitive(False)
 | 
			
		||||
		if gajim.gc_connected[self.account][self.room_jid]:
 | 
			
		||||
			c = gajim.contacts.get_gc_contact(self.account, self.room_jid,
 | 
			
		||||
				self.nick)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -970,6 +970,9 @@ class RosterWindow:
 | 
			
		|||
		join_gc_menuitem.set_submenu(gc_sub_menu)
 | 
			
		||||
 | 
			
		||||
		connected_accounts = gajim.get_number_of_connected_accounts()
 | 
			
		||||
 | 
			
		||||
		connected_accounts_with_private_storage = 0
 | 
			
		||||
 | 
			
		||||
		if connected_accounts > 1: # 2 or more accounts? make submenus
 | 
			
		||||
			add_sub_menu = gtk.Menu()
 | 
			
		||||
			disco_sub_menu = gtk.Menu()
 | 
			
		||||
| 
						 | 
				
			
			@ -993,15 +996,14 @@ class RosterWindow:
 | 
			
		|||
					continue
 | 
			
		||||
 | 
			
		||||
				# join gc
 | 
			
		||||
				if gajim.connections[account].private_storage_supported:
 | 
			
		||||
					connected_accounts_with_private_storage += 1
 | 
			
		||||
				gc_item = gtk.MenuItem(_('using account %s') % account, False)
 | 
			
		||||
				gc_sub_menu.append(gc_item)
 | 
			
		||||
				gc_menuitem_menu = gtk.Menu()
 | 
			
		||||
				self.add_bookmarks_list(gc_menuitem_menu, account)
 | 
			
		||||
				gc_item.set_submenu(gc_menuitem_menu)
 | 
			
		||||
 | 
			
		||||
				# the 'manage gc bookmarks' item is shown
 | 
			
		||||
				# below to avoid duplicate code
 | 
			
		||||
 | 
			
		||||
				# add
 | 
			
		||||
				add_item = gtk.MenuItem(_('to %s account') % account, False)
 | 
			
		||||
				add_sub_menu.append(add_item)
 | 
			
		||||
| 
						 | 
				
			
			@ -1013,7 +1015,6 @@ class RosterWindow:
 | 
			
		|||
				disco_item.connect('activate',
 | 
			
		||||
					self.on_service_disco_menuitem_activate, account)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			add_new_contact_menuitem.set_submenu(add_sub_menu)
 | 
			
		||||
			add_sub_menu.show_all()
 | 
			
		||||
			service_disco_menuitem.set_submenu(disco_sub_menu)
 | 
			
		||||
| 
						 | 
				
			
			@ -1026,7 +1027,10 @@ class RosterWindow:
 | 
			
		|||
			for account in gajim.connections:
 | 
			
		||||
				if gajim.account_is_connected(account): # THE connected account
 | 
			
		||||
					# gc
 | 
			
		||||
					if gajim.connections[account].private_storage_supported:
 | 
			
		||||
						connected_accounts_with_private_storage += 1
 | 
			
		||||
					self.add_bookmarks_list(gc_sub_menu, account)
 | 
			
		||||
					gc_sub_menu.show_all()
 | 
			
		||||
					# add
 | 
			
		||||
					if not self.add_new_contact_handler_id:
 | 
			
		||||
						self.add_new_contact_handler_id =\
 | 
			
		||||
| 
						 | 
				
			
			@ -1070,10 +1074,21 @@ class RosterWindow:
 | 
			
		|||
								add_new_contact_menuitem, service_disco_menuitem]:
 | 
			
		||||
							item.set_sensitive(False)
 | 
			
		||||
 | 
			
		||||
		if connected_accounts_with_private_storage > 0:
 | 
			
		||||
			# At least one account with private storage support
 | 
			
		||||
			# show the 'manage gc bookmarks' item
 | 
			
		||||
			newitem = gtk.SeparatorMenuItem() # separator
 | 
			
		||||
			gc_sub_menu.append(newitem)
 | 
			
		||||
 | 
			
		||||
			newitem = gtk.ImageMenuItem(_('_Manage Bookmarks...'))
 | 
			
		||||
			img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
 | 
			
		||||
				gtk.ICON_SIZE_MENU)
 | 
			
		||||
			newitem.set_image(img)
 | 
			
		||||
			newitem.connect('activate',
 | 
			
		||||
				self.on_manage_bookmarks_menuitem_activate)
 | 
			
		||||
			gc_sub_menu.append(newitem)
 | 
			
		||||
			gc_sub_menu.show_all()
 | 
			
		||||
 | 
			
		||||
		connected_accounts_with_vcard = []
 | 
			
		||||
		for account in gajim.connections:
 | 
			
		||||
			if gajim.account_is_connected(account) and \
 | 
			
		||||
| 
						 | 
				
			
			@ -1104,15 +1119,6 @@ class RosterWindow:
 | 
			
		|||
		else:
 | 
			
		||||
			profile_avatar_menuitem.set_sensitive(True)
 | 
			
		||||
 | 
			
		||||
			newitem = gtk.ImageMenuItem(_('_Manage Bookmarks...'))
 | 
			
		||||
			img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
 | 
			
		||||
				gtk.ICON_SIZE_MENU)
 | 
			
		||||
			newitem.set_image(img)
 | 
			
		||||
			newitem.connect('activate',
 | 
			
		||||
				self.on_manage_bookmarks_menuitem_activate)
 | 
			
		||||
			gc_sub_menu.append(newitem)
 | 
			
		||||
			gc_sub_menu.show_all()
 | 
			
		||||
 | 
			
		||||
		# Advanced Actions
 | 
			
		||||
		if len(gajim.connections) == 0: # user has no accounts
 | 
			
		||||
			advanced_menuitem.set_sensitive(False)
 | 
			
		||||
| 
						 | 
				
			
			@ -4691,8 +4697,8 @@ class RosterWindow:
 | 
			
		|||
 | 
			
		||||
	def on_drop_in_contact(self, widget, account_source, c_source, account_dest,
 | 
			
		||||
		c_dest, was_big_brother, context, etime):
 | 
			
		||||
		if not gajim.connections[account_source].metacontacts_supported or not \
 | 
			
		||||
		gajim.connections[account_dest].metacontacts_supported:
 | 
			
		||||
		if not gajim.connections[account_source].private_storage_supported or not\
 | 
			
		||||
		gajim.connections[account_dest].private_storage_supported:
 | 
			
		||||
			dialogs.WarningDialog(_('Metacontacts storage not supported by your '
 | 
			
		||||
				'server'),
 | 
			
		||||
				_('Your server does not support storing metacontacts information. '
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue