improvements, status messages in chat window
This commit is contained in:
		
							parent
							
								
									fd9c01fc4f
								
							
						
					
					
						commit
						11f74c9e30
					
				
					 3 changed files with 35 additions and 12 deletions
				
			
		
							
								
								
									
										10
									
								
								core/core.py
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								core/core.py
									
										
									
									
									
								
							|  | @ -78,11 +78,11 @@ class GajimCore: | |||
| 			log.debug("unsubscribe request from %s" % who) | ||||
| 		elif type == 'unsubscribed': | ||||
| 			log.debug("we are now unsubscribed to %s" % who) | ||||
| 			 | ||||
| 	# END presenceCB | ||||
| 
 | ||||
| 	def disconnectedCB(self, con): | ||||
| 		log.debug("disconnectedCB") | ||||
| 		self.con.disconnect() | ||||
| 	# END disconenctedCB | ||||
| 
 | ||||
| 	def connect(self, account): | ||||
|  | @ -95,14 +95,15 @@ class GajimCore: | |||
| 		try: | ||||
| 			self.con.connect() | ||||
| 		except IOError, e: | ||||
| 			log.debug("Couldn't connect to %s" % e) | ||||
| 			sys.exit(0) | ||||
| 			log.debug("Couldn't connect to %s %s" % (hostname, e)) | ||||
| 			return 0 | ||||
| 		else: | ||||
| 			log.debug("Connected to server") | ||||
| 
 | ||||
| 			self.con.setMessageHandler(self.messageCB) | ||||
| 			self.con.setPresenceHandler(self.presenceCB) | ||||
| 			self.con.setDisconnectHandler(self.disconnectedCB) | ||||
| 			#BUG in jabberpy library : if hostname is wrong : "boucle" | ||||
| 			if self.con.auth(name, password, ressource): | ||||
| 				self.con.requestRoster() | ||||
| 				roster = self.con.getRoster().getRaw() | ||||
|  | @ -112,7 +113,8 @@ class GajimCore: | |||
| 				self.con.sendInitPresence() | ||||
| 				self.connected = 1 | ||||
| 			else: | ||||
| 				sys.exit(1) | ||||
| 				log.debug("Couldn't authentificate to %s" % hostname) | ||||
| 				return 0 | ||||
| 	# END connect | ||||
| 
 | ||||
| 	def mainLoop(self): | ||||
|  |  | |||
							
								
								
									
										10
									
								
								doc/gajimrc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								doc/gajimrc
									
										
									
									
									
								
							|  | @ -1,9 +1,10 @@ | |||
| [Server] | ||||
| 
 | ||||
| hostname = SERVER HOSTNAME | ||||
| 
 | ||||
| [Profile] | ||||
| 
 | ||||
| accounts = Account1 | ||||
| 
 | ||||
| [Account1] | ||||
| 
 | ||||
| hostname = SERVER HOSTNAME | ||||
| name = LOGIN NAME | ||||
| password = PASSWORD | ||||
| ressource = gajim | ||||
|  | @ -20,6 +21,7 @@ modules = sock | |||
| showoffline = 0 | ||||
| inmsgcolor = red | ||||
| outmsgcolor = blue | ||||
| statusmsgcolor = green | ||||
| iconstyle = sun | ||||
| autopopup = 0 | ||||
| 
 | ||||
|  |  | |||
|  | @ -233,7 +233,12 @@ class message: | |||
| 	def print_conversation(self, txt, contact = None): | ||||
| 		end_iter = self.convTxtBuffer.get_end_iter() | ||||
| 		if contact: | ||||
| 			if contact == 'status': | ||||
| 				self.convTxtBuffer.insert_with_tags_by_name(end_iter, txt+'\n', \ | ||||
| 					'status') | ||||
| 			else: | ||||
| 				self.convTxtBuffer.insert_with_tags_by_name(end_iter, '<moi> ', 'outgoing') | ||||
| 				self.convTxtBuffer.insert(end_iter, txt+'\n') | ||||
| 		else: | ||||
| 			self.convTxtBuffer.insert_with_tags_by_name(end_iter, '<' + self.user.name + '> ', 'incoming') | ||||
| 			self.convTxtBuffer.insert(end_iter, txt+'\n') | ||||
|  | @ -287,12 +292,17 @@ class message: | |||
| 		self.tag = self.convTxtBuffer.create_tag("incoming") | ||||
| 		color = self.cfgParser.GtkGui_inmsgcolor | ||||
| 		if not color: | ||||
| 			color = red | ||||
| 			color = 'red' | ||||
| 		self.tag.set_property("foreground", color) | ||||
| 		self.tag = self.convTxtBuffer.create_tag("outgoing") | ||||
| 		color = self.cfgParser.GtkGui_outmsgcolor | ||||
| 		if not color: | ||||
| 			color = blue | ||||
| 			color = 'blue' | ||||
| 		self.tag.set_property("foreground", color) | ||||
| 		self.tag = self.convTxtBuffer.create_tag("status") | ||||
| 		color = self.cfgParser.GtkGui_statusmsgcolor | ||||
| 		if not color: | ||||
| 			color = 'green' | ||||
| 		self.tag.set_property("foreground", color) | ||||
| 
 | ||||
| class roster: | ||||
|  | @ -570,6 +580,15 @@ class plugin: | |||
| 				self.r.mkroster(ev[1]) | ||||
| 			elif ev[0] == 'NOTIFY': | ||||
| 				jid = string.split(ev[1][0], '/')[0] | ||||
| 				#Update user | ||||
| 				if self.r.l_contact.has_key(jid): | ||||
| 					u = self.r.l_contact[jid]['user'] | ||||
| 					u.show = ev[1][1] | ||||
| 					u.status = ev[1][2] | ||||
| 					#Print status in chat window | ||||
| 					if self.r.tab_messages.has_key(jid): | ||||
| 						self.r.tab_messages[jid].print_conversation(\ | ||||
| 							"%s is now %s (%s)" % (u.name, ev[1][1], ev[1][2]), 'status') | ||||
| 				if string.find(jid, "@") <= 0: | ||||
| 					#It must be an agent | ||||
| 					jid = string.replace(jid, '@', '') | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue