xs:boolean is '0', '1', 'true', 'false'. so update bookmark to handle the last two
This commit is contained in:
		
							parent
							
								
									c5a389f687
								
							
						
					
					
						commit
						bd0a5230d9
					
				
					 4 changed files with 24 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -1117,9 +1117,12 @@ class Connection:
 | 
			
		|||
			confs = storage.getTags('conference')
 | 
			
		||||
			urls = storage.getTags('url')
 | 
			
		||||
			for conf in confs:
 | 
			
		||||
				autojoin_val = conf.getAttr('autojoin')
 | 
			
		||||
				if autojoin_val is None: # not there (it's optional)
 | 
			
		||||
					autojoin_val == False
 | 
			
		||||
				bm = { 'name': conf.getAttr('name'),
 | 
			
		||||
				       'jid': conf.getAttr('jid'),
 | 
			
		||||
				       'autojoin': conf.getAttr('autojoin'),
 | 
			
		||||
				       'autojoin': autojoin_val,
 | 
			
		||||
				       'password': conf.getTagData('password'),
 | 
			
		||||
				       'nick': conf.getTagData('nick') }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -274,3 +274,14 @@ def get_file_path_from_dnd_dropped_uri(uri):
 | 
			
		|||
	elif path.startswith('file:'): # xffm
 | 
			
		||||
		path = path[5:] # 5 is len('file:')
 | 
			
		||||
	return path
 | 
			
		||||
 | 
			
		||||
def from_xs_boolean_to_python_boolean(value):
 | 
			
		||||
	# this is xs:boolean so 'true','false','1','0'
 | 
			
		||||
	# convert those to True/False (python booleans)
 | 
			
		||||
	if val in ('1', 'true'):
 | 
			
		||||
		val = True
 | 
			
		||||
	else: # '0', 'false' or anything else
 | 
			
		||||
		val = False
 | 
			
		||||
 | 
			
		||||
	return val
 | 
			
		||||
			
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2500,13 +2500,14 @@ class ManageBookmarksWindow:
 | 
			
		|||
 | 
			
		||||
			for bookmark in gajim.connections[account].bookmarks:
 | 
			
		||||
				if bookmark['name'] == '':
 | 
			
		||||
					#No name was given for this bookmark.
 | 
			
		||||
					#Use the first part of JID instead...
 | 
			
		||||
					# No name was given for this bookmark.
 | 
			
		||||
					# Use the first part of JID instead...
 | 
			
		||||
					name = bookmark['jid'].split("@")[0]
 | 
			
		||||
					bookmark['name'] = name
 | 
			
		||||
 | 
			
		||||
				#Convert '1'/'0' to True/False
 | 
			
		||||
				autojoin = bool(int(bookmark['autojoin']))
 | 
			
		||||
				# make '1', '0', 'true', 'false' (or other) to True/False
 | 
			
		||||
				autojoin = helpers.from_xs_boolean_to_python_boolean(
 | 
			
		||||
					bookmark['autojoin'])
 | 
			
		||||
				
 | 
			
		||||
				self.treestore.append( iter, [
 | 
			
		||||
						account,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -685,11 +685,11 @@ class Interface:
 | 
			
		|||
			self.remote.raise_signal('RosterInfo', (account, array))
 | 
			
		||||
 | 
			
		||||
	def handle_event_bookmarks(self, account, bms):
 | 
			
		||||
		#('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}])
 | 
			
		||||
		#We received a bookmark item from the server (JEP48)
 | 
			
		||||
		#Auto join GC windows if neccessary
 | 
			
		||||
		# ('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}])
 | 
			
		||||
		# We received a bookmark item from the server (JEP48)
 | 
			
		||||
		# Auto join GC windows if neccessary
 | 
			
		||||
		for bm in bms:
 | 
			
		||||
			if bm['autojoin'] == '1':
 | 
			
		||||
			if bm['autojoin'] in ('1', 'true'):
 | 
			
		||||
				self.roster.join_gc_room(account, bm['jid'], bm['nick'],
 | 
			
		||||
					bm['password'])
 | 
			
		||||
		self.roster.make_menu()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue