예제 #1
0
	def newMessage(self,jid,contactName,message,ringtone,vibration,picture=None,callback=False):
	  
		message = message.replace("<br />", "\n").replace("&lt;", "<").replace("&gt;", ">").replace("&quot;", "\"").replace("&amp;", "&")
		
		self._d("NEW NOTIFICATION! Ringtone: " + ringtone + " - Vibrate: " + str(vibration))

		activeConvJId = self.ui.getActiveConversation()
		
		max_len = min(len(message),20)
		
		if self.enabled:
			
			if(activeConvJId == jid or activeConvJId == ""):
				if self.audio and ringtone!= WAConstants.NO_SOUND:
					soundPath = WAConstants.DEFAULT_BEEP_NOTIFICATION;
					self._d(soundPath)
					self.playSound(soundPath)


				if self.vibra and vibration:
					self.vibra.start()

				return



			if self.audio and ringtone!=WAConstants.NO_SOUND:
				soundPath = self.getCurrentSoundPath(ringtone);
				self._d(soundPath)
				self.playSound(soundPath)

			
			n = MNotification("wazapp.message.new",contactName, message);
			n.image = picture
			n.manager = self.manager;
			action = lambda: self.notificationCallback(jid)
			
			n.setAction(action);
		
			notifications = n.notifications();
			
			if self.notifications.has_key(jid):
				nId = self.notifications[jid]['id'];
				
				for notify in notifications:
					if int(notify[0]) == nId:
						n.id = nId
						break
				
				if n.id != nId:
					del self.notifications[jid]
			
				
			if(n.publish()):
				nId = n.id;
				self.saveNotification(jid,{"id":nId,"callback":callback});
		
		
			if self.vibra and vibration:
				self.vibra.start()
예제 #2
0
	def newMessage(self,jid,contactName,message,picture=None,callback=False):
		
		activeConvJId = self.ui.getActiveConversation()
		
		max_len = min(len(message),20)
		
		if self.enabled:
			
			
			if(activeConvJId == jid or activeConvJId == ""):
				if self.vibra:
					self.vibra.start()
				return
			
			n = MNotification("wazapp.message.new",contactName, message);
			n.image = picture
			n.manager = self.manager;
			action = lambda: self.notificationCallback(jid)
			
			n.setAction(action);
		
			notifications = n.notifications();
			
			
			if self.notifications.has_key(jid):
				nId = self.notifications[jid]['id'];
				
				
				for notify in notifications:
					if int(notify[0]) == nId:
						n.id = nId
						break
				
				if n.id != nId:
					del self.notifications[jid]
			
				
			if(n.publish()):
				nId = n.id;
				self.saveNotification(jid,{"id":nId,"callback":callback});
		
		
		#if self.vibra:
		#	self.vibra.start()
		
		if self.audio:
			soundPath = self.getCurrentSoundPath();
			self._d(soundPath)
			self.audio.setMedia(QUrl.fromLocalFile(soundPath));
			self.audio.play();
예제 #3
0
	def newMessage(self,jid,contactName,message,picture=None,callback=False):
		
		activeConvJId = self.ui.getActiveConversation()
		
		max_len = min(len(message),20)
		
		if self.enabled:
			
			
			if(activeConvJId == jid or activeConvJId == ""):
				if self.vibra:
					self.vibra.start()
				return
			
			n = MNotification("wazapp.message.new",contactName, message);
			n.image = picture
			n.manager = self.manager;
			action = lambda: self.notificationCallback(jid)
			
			n.setAction(action);
		
			notifications = n.notifications();
			
			
			if self.notifications.has_key(jid):
				nId = self.notifications[jid]['id'];
				
				
				for notify in notifications:
					if int(notify[0]) == nId:
						n.id = nId
						break
				
				if n.id != nId:
					del self.notifications[jid]
			
				
			if(n.publish()):
				nId = n.id;
				self.saveNotification(jid,{"id":nId,"callback":callback});
		
		
		#if self.vibra:
		#	self.vibra.start()
		
		if self.audio:
			soundPath = self.getCurrentSoundPath();
			print soundPath
			self.audio.setMedia(QUrl.fromLocalFile(soundPath));
			self.audio.play();