the gui uses now the notification service

cusax-fix
Yana Stamcheva 19 years ago
parent 2a12eeb074
commit 8a3d92b5ac

@ -8,10 +8,6 @@
import java.util.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.login.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.browserlauncher.*;
@ -20,6 +16,7 @@
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.msghistory.*;
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@ -30,9 +27,10 @@
*
* @author Yana Stamcheva
*/
public class GuiActivator implements BundleActivator {
private static Logger logger = Logger.getLogger(GuiActivator.class.getName());
public class GuiActivator implements BundleActivator
{
private static Logger logger
= Logger.getLogger(GuiActivator.class.getName());
private static UIServiceImpl uiService = null;
@ -49,7 +47,9 @@ public class GuiActivator implements BundleActivator {
private static AudioNotifierService audioNotifierService;
private static BrowserLauncherService browserLauncherService;
private static NotificationService notificationService;
private static Map providerFactoriesMap = new Hashtable();
/**
@ -61,6 +61,9 @@ public void start(BundleContext bundleContext) throws Exception {
GuiActivator.bundleContext = bundleContext;
NotificationManager.registerGuiNotifications();
bundleContext.addServiceListener(new NotificationServiceListener());
ConfigurationManager.loadGuiConfigurations();
try {
@ -271,4 +274,63 @@ public static BrowserLauncherService getBrowserLauncher() {
public static UIServiceImpl getUIService() {
return uiService;
}
/**
* Returns the <tt>NotificationService</tt> obtained from the bundle context.
*
* @return the <tt>NotificationService</tt> obtained from the bundle context
*/
public static NotificationService getNotificationService()
{
if (notificationService == null)
{
ServiceReference serviceReference = bundleContext
.getServiceReference(NotificationService.class.getName());
notificationService = (NotificationService) bundleContext
.getService(serviceReference);
}
return notificationService;
}
/**
* Implements the <tt>ServiceListener</tt>. Verifies whether the
* passed event concerns a <tt>NotificationService</tt> and if so
* intiates the gui NotificationManager.
*/
private class NotificationServiceListener implements ServiceListener
{
/**
* Implements the <tt>ServiceListener</tt> method. Verifies whether the
* passed event concerns a <tt>NotificationService</tt> and if so
* initiates the NotificationManager.
*
* @param event The <tt>ServiceEvent</tt> object.
*/
public void serviceChanged(ServiceEvent event)
{
// if the event is caused by a bundle being stopped, we don't want
// to know
if (event.getServiceReference().getBundle().getState()
== Bundle.STOPPING)
{
return;
}
Object service = GuiActivator.bundleContext.getService(event
.getServiceReference());
// we don't care if the source service is not a notification service
if (!(service instanceof NotificationService))
{
return;
}
if (event.getType() == ServiceEvent.REGISTERED)
{
NotificationManager.registerGuiNotifications();
}
}
}
}

@ -174,10 +174,8 @@ public void actionPerformed(ActionEvent evt)
.getCallState() == CallState.CALL_INITIALIZATION)
{
GuiActivator.getAudioNotifier().createAudio(Sounds.BUSY).stop();
GuiActivator.getAudioNotifier().createAudio(
Sounds.INCOMING_CALL).stop();
NotificationManager.stopSound(NotificationManager.BUSY_CALL);
NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
CallPanel callPanel = (CallPanel) selectedPanel;
@ -283,11 +281,9 @@ else if (buttonName.equalsIgnoreCase("hangup"))
if (selectedPanel != null && selectedPanel instanceof CallPanel)
{
GuiActivator.getAudioNotifier().createAudio(Sounds.BUSY).stop();
GuiActivator.getAudioNotifier().createAudio(
Sounds.INCOMING_CALL).stop();
GuiActivator.getAudioNotifier().createAudio(
Sounds.OUTGOING_CALL).stop();
NotificationManager.stopSound(NotificationManager.BUSY_CALL);
NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);
CallPanel callPanel = (CallPanel) selectedPanel;
@ -507,8 +503,11 @@ public void incomingCallReceived(CallEvent event)
this.callButton.setEnabled(true);
this.hangupButton.setEnabled(true);
GuiActivator.getAudioNotifier().createAudio(Sounds.INCOMING_CALL)
.playInLoop(2000);
NotificationManager.fireNotification(
Sounds.INCOMING_CALL,
null,
"Incoming call recived from: "
+ sourceCall.getCallParticipants().next());
activeCalls.put(sourceCall, callPanel);
@ -524,11 +523,9 @@ public void callEnded(CallEvent event)
{
Call sourceCall = event.getSourceCall();
GuiActivator.getAudioNotifier().createAudio(Sounds.BUSY).stop();
GuiActivator.getAudioNotifier().createAudio(Sounds.INCOMING_CALL)
.stop();
GuiActivator.getAudioNotifier().createAudio(Sounds.OUTGOING_CALL)
.stop();
NotificationManager.stopSound(NotificationManager.BUSY_CALL);
NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);
if (activeCalls.get(sourceCall) != null)
{

@ -297,24 +297,20 @@ public void participantStateChanged(CallParticipantChangeEvent evt)
if(evt.getNewValue() == CallParticipantState.ALERTING_REMOTE_SIDE)
{
GuiActivator.getAudioNotifier()
.createAudio(Sounds.OUTGOING_CALL).playInLoop(3000);
NotificationManager
.fireNotification(NotificationManager.OUTGOING_CALL);
}
else if(evt.getNewValue() == CallParticipantState.BUSY)
{
GuiActivator.getAudioNotifier()
.createAudio(Sounds.OUTGOING_CALL).stop();
NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);
GuiActivator.getAudioNotifier()
.createAudio(Sounds.BUSY).playInLoop(0);
NotificationManager.fireNotification(NotificationManager.BUSY_CALL);
}
else if(evt.getNewValue() == CallParticipantState.CONNECTED) {
//start the timer that takes care of refreshing the time label
GuiActivator.getAudioNotifier()
.createAudio(Sounds.OUTGOING_CALL).stop();
GuiActivator.getAudioNotifier()
.createAudio(Sounds.INCOMING_CALL).stop();
NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);
NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
participantPanel.startCallTimer();
}

@ -119,7 +119,7 @@ public ChatInviteDialog (ChatPanel chatPanel)
}
/**
* Handles the <tt>ActionEvent</tt> triggered when one user clicks
* Handles the <tt>ActionEvent</tt> triggered when user clicks
* on one of the buttons.
*/
public void actionPerformed(ActionEvent e)

@ -16,6 +16,7 @@
import net.java.sip.communicator.impl.gui.main.chatroomslist.*;
import net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.impl.systray.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
@ -127,8 +128,14 @@ public void messageReceived(ChatRoomMessageReceivedEvent evt)
chatWindowManager.openChat(chatPanel, false);
GuiActivator.getAudioNotifier()
.createAudio(Sounds.INCOMING_MESSAGE).play();
// Fire notification
String title = Resources.getString("messageReceived") + " "
+ sourceMember.getName();
NotificationManager.fireNotification(
NotificationManager.INCOMING_MESSAGE,
title,
message.getContent());
}
/**

@ -14,7 +14,6 @@
import javax.swing.*;
import javax.swing.Timer;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
@ -214,17 +213,20 @@ public void messageReceived(MessageReceivedEvent evt)
.findMetaContactByContact(protocolContact);
if(metaContact != null)
{
ContactListModel clistModel = (ContactListModel) contactList.getModel();
{
// Show an envelope on the sender contact in the contact list.
ContactListModel clistModel
= (ContactListModel) contactList.getModel();
clistModel.addActiveContact(metaContact);
contactList.refreshContact(metaContact);
// Obtain the corresponding chat panel.
ChatPanel chatPanel = chatWindowManager.getContactChat(
metaContact, protocolContact, message.getMessageUID());
// Distinguish the message type, depending on the type of event that
// we have received.
String messageType = null;
if(eventType == MessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED)
@ -240,11 +242,18 @@ else if(eventType == MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED)
messageType, message.getContent(),
message.getContentType());
// Opens the chat panel with the new message.
chatWindowManager.openChat(chatPanel, false);
// Fire notification
String title = Messages.getI18NString("messageReceived").getText()
+ " " + evt.getSourceContact().getDisplayName();
NotificationManager.fireNotification(
NotificationManager.INCOMING_MESSAGE,
title,
message.getContent());
GuiActivator.getAudioNotifier()
.createAudio(Sounds.INCOMING_MESSAGE).play();
chatPanel.treatReceivedMessage(protocolContact);
}
else
@ -427,6 +436,15 @@ public void setChatNotificationMsg(MetaContact metaContact,
.setStatusMessage(notificationMsg);
}
/**
* Returns the right button menu of the contact list.
* @return the right button menu of the contact list
*/
public CommonRightButtonMenu getCommonRightButtonMenu()
{
return commonRightButtonMenu;
}
/**
* The TypingTimer is started after a PAUSED typing notification is
* received. It waits 5 seconds and if no other typing event occurs removes
@ -456,10 +474,5 @@ private void setMetaContact(MetaContact metaContact)
{
this.metaContact = metaContact;
}
}
public CommonRightButtonMenu getCommonRightButtonMenu()
{
return commonRightButtonMenu;
}
}
}

@ -21,6 +21,7 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.callhistory,
net.java.sip.communicator.service.callhistory.event,
net.java.sip.communicator.service.browserlauncher,
net.java.sip.communicator.service.notification,
javax.swing,
javax.swing.event,
javax.swing.table,

@ -0,0 +1,130 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.utils;
import java.util.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.service.notification.*;
public class NotificationManager
{
public static final String INCOMING_MESSAGE = "IncomingMessage";
public static final String INCOMING_CALL = "IncomingCall";
public static final String OUTGOING_CALL = "OutgoingCall";
public static final String BUSY_CALL = "BusyCall";
private static Hashtable soundHandlers = new Hashtable();
public static void registerGuiNotifications()
{
NotificationService notificationService
= GuiActivator.getNotificationService();
if(notificationService == null)
return;
// Register incoming message notifications.
notificationService.registerNotificationForEvent(
INCOMING_MESSAGE,
NotificationService.ACTION_POPUP_MESSAGE,
null,
null);
notificationService.registerNotificationForEvent(
INCOMING_MESSAGE,
NotificationService.ACTION_SOUND,
Sounds.INCOMING_MESSAGE,
null);
// Register incoming call notifications.
notificationService.registerNotificationForEvent(
INCOMING_CALL,
NotificationService.ACTION_POPUP_MESSAGE,
null,
null);
SoundNotificationHandler inCallSoundHandler
= (SoundNotificationHandler) notificationService
.createSoundNotificationHandler(Sounds.INCOMING_CALL, 2000);
notificationService.registerNotificationForEvent(
INCOMING_CALL,
NotificationService.ACTION_SOUND,
inCallSoundHandler);
soundHandlers.put(INCOMING_CALL, inCallSoundHandler);
// Register outgoing call notifications.
SoundNotificationHandler outCallSoundHandler
= (SoundNotificationHandler) notificationService
.createSoundNotificationHandler(Sounds.OUTGOING_CALL, 3000);
notificationService.registerNotificationForEvent(
OUTGOING_CALL,
NotificationService.ACTION_SOUND,
outCallSoundHandler);
soundHandlers.put(OUTGOING_CALL, outCallSoundHandler);
// Register busy call notifications.
SoundNotificationHandler busyCallSoundHandler
= (SoundNotificationHandler) notificationService
.createSoundNotificationHandler(Sounds.BUSY, 0);
notificationService.registerNotificationForEvent(
BUSY_CALL,
NotificationService.ACTION_SOUND,
busyCallSoundHandler);
soundHandlers.put(OUTGOING_CALL, outCallSoundHandler);
}
public static void fireNotification(String eventType,
String messageTitle,
String message)
{
NotificationService notificationService
= GuiActivator.getNotificationService();
if(notificationService == null)
return;
notificationService.fireNotification(eventType, messageTitle, message);
}
public static void fireNotification(String eventType)
{
NotificationService notificationService
= GuiActivator.getNotificationService();
if(notificationService == null)
return;
notificationService.fireNotification(eventType);
}
public static void stopSound(String eventType)
{
NotificationService notificationService
= GuiActivator.getNotificationService();
if(notificationService == null)
return;
SoundNotificationHandler soundHandler
= (SoundNotificationHandler) notificationService
.getEventNotificationActionHandler(
eventType, NotificationService.ACTION_SOUND);
soundHandler.stop();
}
}

@ -1,19 +1,19 @@
INCOMING_MESSAGE=net/java/sip/communicator/impl/gui/resources/sounds/ship-sink.wav
INCOMING_CALL=net/java/sip/communicator/impl/gui/resources/sounds/incomingCall.wav
OUTGOING_CALL=net/java/sip/communicator/impl/gui/resources/sounds/ring.wav
INCOMING_MESSAGE=resources/sounds/ship-sink.wav
INCOMING_CALL=resources/sounds/incomingCall.wav
OUTGOING_CALL=resources/sounds/ring.wav
DIAL_ZERO=net/java/sip/communicator/impl/gui/resources/sounds/one_1.wav
DIAL_ONE=net/java/sip/communicator/impl/gui/resources/sounds/one_1.wav
DIAL_TWO=net/java/sip/communicator/impl/gui/resources/sounds/two_2.wav
DIAL_THREE=net/java/sip/communicator/impl/gui/resources/sounds/three_3.wav
DIAL_FOUR=net/java/sip/communicator/impl/gui/resources/sounds/four_4.wav
DIAL_FIVE=net/java/sip/communicator/impl/gui/resources/sounds/five_5.wav
DIAL_SIX=net/java/sip/communicator/impl/gui/resources/sounds/six_6.wav
DIAL_SEVEN=net/java/sip/communicator/impl/gui/resources/sounds/seven_7.wav
DIAL_EIGHT=net/java/sip/communicator/impl/gui/resources/sounds/eight_8.wav
DIAL_NINE=net/java/sip/communicator/impl/gui/resources/sounds/nine_9.wav
DIAL_DIEZ=net/java/sip/communicator/impl/gui/resources/sounds/one_1.wav
DIAL_STAR=net/java/sip/communicator/impl/gui/resources/sounds/one_1.wav
DIAL_ZERO=resources/sounds/one_1.wav
DIAL_ONE=resources/sounds/one_1.wav
DIAL_TWO=resources/sounds/two_2.wav
DIAL_THREE=resources/sounds/three_3.wav
DIAL_FOUR=resources/sounds/four_4.wav
DIAL_FIVE=resources/sounds/five_5.wav
DIAL_SIX=resources/sounds/six_6.wav
DIAL_SEVEN=resources/sounds/seven_7.wav
DIAL_EIGHT=resources/sounds/eight_8.wav
DIAL_NINE=resources/sounds/nine_9.wav
DIAL_DIEZ=resources/sounds/one_1.wav
DIAL_STAR=resources/sounds/one_1.wav
DIALING=net/java/sip/communicator/impl/gui/resources/sounds/dialing.wav
BUSY=net/java/sip/communicator/impl/gui/resources/sounds/busy.wav
DIALING=resources/sounds/dialing.wav
BUSY=resources/sounds/busy.wav
Loading…
Cancel
Save