Fixes to the notification system provided by Thomas Hofer.

cusax-fix
Yana Stamcheva 19 years ago
parent d851839291
commit b71c19e89a

@ -10,6 +10,7 @@
import java.util.*;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.util.*;
/**
* The implementation of the AudioNotifierService.
@ -19,14 +20,15 @@
public class AudioNotifierServiceImpl
implements AudioNotifierService
{
private Logger logger = Logger.getLogger(AudioNotifierServiceImpl.class);
private static Map audioClips = new HashMap();
private boolean isMute;
/**
* Creates an SCAudioClip from the given uri and adds it to the list of
* available audios.
* Creates an SCAudioClip from the given URI and adds it to the list of
* available audio-s.
*
* @param uri the path where the audio file could be found
*/
@ -45,6 +47,18 @@ public SCAudioClip createAudio(String uri)
URL url = AudioNotifierServiceImpl.class.getClassLoader()
.getResource(uri);
if (url == null)
{
// Not found by the class loader. Perhaps it's a local file.
try
{
url = new URL(uri);
}
catch (MalformedURLException e)
{
logger.error("The given uri could not be parsed.", e);
}
}
audioClip = new SCAudioClipImpl(url, this);
audioClips.put(uri, audioClip);

@ -15,7 +15,6 @@
import javax.swing.Timer;
import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
@ -504,7 +503,7 @@ public void incomingCallReceived(CallEvent event)
this.hangupButton.setEnabled(true);
NotificationManager.fireNotification(
Sounds.INCOMING_CALL,
NotificationManager.INCOMING_CALL,
null,
"Incoming call recived from: "
+ sourceCall.getCallParticipants().next());

@ -77,7 +77,7 @@ public static void registerGuiNotifications()
// Register busy call notifications.
SoundNotificationHandler busyCallSoundHandler
= (SoundNotificationHandler) notificationService
.createSoundNotificationHandler(Sounds.BUSY, 0);
.createSoundNotificationHandler(Sounds.BUSY, 1);
notificationService.registerNotificationForEvent(
BUSY_CALL,
@ -116,15 +116,15 @@ 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();
}
}

@ -105,7 +105,7 @@ public void registerNotificationForEvent( String eventType,
NotificationActionHandler handler)
{
EventNotification notification = null;
if(notificationsTable.containsKey(eventType))
notification = (EventNotification) notificationsTable.get(eventType);
else
@ -295,15 +295,15 @@ public NotificationActionHandler getEventNotificationActionHandler(
{
EventNotification notification
= (EventNotification) notificationsTable.get(eventType);
System.out.println("EVENT TYPE=================" + eventType + "NOTIFICATION=========" + notification);
if(notification == null)
return null;
EventNotification.Action action = notification.getAction(actionType);
System.out.println("ACTION=================" + actionType + "ACTION=========" + action);
if(action == null)
return null;
return action.getActionHandler();
}

@ -71,12 +71,12 @@ public void start()
{
AudioNotifierService audioNotifService
= NotificationActivator.getAudioNotifier();
if(audioNotifService == null)
return;
audio = audioNotifService.createAudio(soundFileDescriptor);
if(loopInterval > -1)
audio.playInLoop(loopInterval);
else
@ -90,10 +90,15 @@ public void stop()
{
AudioNotifierService audioNotifService
= NotificationActivator.getAudioNotifier();
if(audioNotifService == null)
return;
if(audio == null)
return;
audio.stop();
audioNotifService.destroyAudio(audio);
}

Loading…
Cancel
Save