mirror of https://github.com/sipwise/jitsi.git
parent
9a75641971
commit
f3df7dc1f6
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Jitsi, 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.neomedia;
|
||||
|
||||
import java.beans.*;
|
||||
import java.util.*;
|
||||
import javax.media.*;
|
||||
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.service.notification.*;
|
||||
import net.java.sip.communicator.service.systray.event.*;
|
||||
|
||||
import org.jitsi.impl.neomedia.device.*;
|
||||
import org.jitsi.service.resources.*;
|
||||
import org.osgi.framework.*;
|
||||
|
||||
/**
|
||||
* An abstract listener to the click on the popup message concerning
|
||||
* device configuration changes.
|
||||
*
|
||||
* @author Vincent Lucas
|
||||
*/
|
||||
public abstract class AbstractDeviceConfigurationListener
|
||||
implements PropertyChangeListener,
|
||||
SystrayPopupMessageListener
|
||||
{
|
||||
/**
|
||||
* The audio or video configuration form.
|
||||
*/
|
||||
private ConfigurationForm configurationForm;
|
||||
|
||||
/**
|
||||
* A boolean used to verify that this listener registers only once to
|
||||
* the popup message notification handler.
|
||||
*/
|
||||
private boolean isRegisteredToPopupMessageListener = false;
|
||||
|
||||
/**
|
||||
* Creates an abstract listener to the click on the popup message concerning
|
||||
* device configuration changes.
|
||||
*
|
||||
* @param configurationForm The audio or video configuration form.
|
||||
*/
|
||||
public AbstractDeviceConfigurationListener(
|
||||
ConfigurationForm configurationForm)
|
||||
{
|
||||
this.configurationForm = configurationForm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers or unregister as a popup message listener to detect when a
|
||||
* user click on notification saying that the device configuration has
|
||||
* changed.
|
||||
*
|
||||
* @param enable True to register to the popup message notifcation
|
||||
* handler. False to unregister.
|
||||
*/
|
||||
public void managePopupMessageListenerRegistration(boolean enable)
|
||||
{
|
||||
Iterator<NotificationHandler> notificationHandlers = NeomediaActivator
|
||||
.getNotificationService()
|
||||
.getActionHandlers(
|
||||
net.java.sip.communicator.service.notification.NotificationAction.ACTION_POPUP_MESSAGE)
|
||||
.iterator();
|
||||
NotificationHandler notificationHandler;
|
||||
while(notificationHandlers.hasNext())
|
||||
{
|
||||
notificationHandler = notificationHandlers.next();
|
||||
if(notificationHandler
|
||||
instanceof PopupMessageNotificationHandler)
|
||||
{
|
||||
// Register.
|
||||
if(enable)
|
||||
{
|
||||
((PopupMessageNotificationHandler) notificationHandler)
|
||||
.addPopupMessageListener(this);
|
||||
}
|
||||
// Unregister.
|
||||
else
|
||||
{
|
||||
((PopupMessageNotificationHandler) notificationHandler)
|
||||
.removePopupMessageListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when an audio device is plugged or unplugged.
|
||||
*
|
||||
* @param event The property change event which may concern the audio
|
||||
* device.
|
||||
*/
|
||||
public abstract void propertyChange(PropertyChangeEvent event);
|
||||
|
||||
/**
|
||||
* Shows a pop-up notification corresponding to a device configuration
|
||||
* change.
|
||||
*
|
||||
* @param title The title of the pop-up notification.
|
||||
* @param device The device which has been connected, disconnected or
|
||||
* selected as default device.
|
||||
* @param popUpEvent The event for a device which has fired this
|
||||
* notification: connected, disconnected or selected.
|
||||
*/
|
||||
public void showPopUpNotification(
|
||||
String title,
|
||||
CaptureDeviceInfo device,
|
||||
String popUpEvent)
|
||||
{
|
||||
// Shows the pop-up notification.
|
||||
if(title != null && device != null && popUpEvent != null)
|
||||
{
|
||||
NotificationService notificationService
|
||||
= NeomediaActivator.getNotificationService();
|
||||
|
||||
if(notificationService != null)
|
||||
{
|
||||
// Registers only once to the popup message notification
|
||||
// handler.
|
||||
if(!isRegisteredToPopupMessageListener)
|
||||
{
|
||||
isRegisteredToPopupMessageListener = true;
|
||||
managePopupMessageListenerRegistration(true);
|
||||
}
|
||||
|
||||
// Fires the popup notification.
|
||||
Map<String,Object> extras = new HashMap<String,Object>();
|
||||
extras.put(
|
||||
NotificationData.POPUP_MESSAGE_HANDLER_TAG_EXTRA,
|
||||
this);
|
||||
|
||||
ResourceManagementService resources
|
||||
= NeomediaActivator.getResources();
|
||||
|
||||
notificationService.fireNotification(
|
||||
popUpEvent,
|
||||
title,
|
||||
device.getName()
|
||||
+ "\r\n"
|
||||
+ resources.getI18NString(
|
||||
"impl.media.configform"
|
||||
+ ".AUDIO_DEVICE_CONFIG_MANAGMENT_CLICK"),
|
||||
null,
|
||||
extras);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that user has clicked on the systray popup message.
|
||||
*
|
||||
* @param evt the event triggered when user clicks on the systray popup
|
||||
* message
|
||||
*/
|
||||
public void popupMessageClicked(SystrayPopupMessageEvent evt)
|
||||
{
|
||||
// Checks if this event is fired from one click on one of our popup
|
||||
// message.
|
||||
//if(evt.getTag() == audioDeviceConfigurationPropertyChangeListener)
|
||||
if(evt.getTag() == this)
|
||||
{
|
||||
// Get the UI service
|
||||
BundleContext bundleContext = NeomediaActivator.getBundleContext();
|
||||
ServiceReference uiReference = bundleContext
|
||||
.getServiceReference(UIService.class.getName());
|
||||
|
||||
UIService uiService = (UIService) bundleContext
|
||||
.getService(uiReference);
|
||||
|
||||
if(uiService != null)
|
||||
{
|
||||
// Shows the audio configuration window.
|
||||
ConfigurationContainer configurationContainer
|
||||
= uiService.getConfigurationContainer();
|
||||
configurationContainer.setSelected(
|
||||
this.configurationForm);
|
||||
//NeomediaActivator.getAudioConfigurationForm());
|
||||
configurationContainer.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Jitsi, 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.neomedia;
|
||||
|
||||
import java.beans.*;
|
||||
import java.util.*;
|
||||
import javax.media.*;
|
||||
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.service.notification.*;
|
||||
import net.java.sip.communicator.service.systray.event.*;
|
||||
|
||||
import org.jitsi.impl.neomedia.device.*;
|
||||
import org.jitsi.service.resources.*;
|
||||
import org.osgi.framework.*;
|
||||
|
||||
/**
|
||||
* A listener to the click on the popup message concerning audio
|
||||
* device configuration changes.
|
||||
*
|
||||
* @author Vincent Lucas
|
||||
*/
|
||||
public class AudioDeviceConfigurationListener
|
||||
extends AbstractDeviceConfigurationListener
|
||||
{
|
||||
/**
|
||||
* Creates a listener to the click on the popup message concerning audio
|
||||
* device configuration changes.
|
||||
*
|
||||
* @param configurationForm The audio or video configuration form.
|
||||
*/
|
||||
public AudioDeviceConfigurationListener(
|
||||
ConfigurationForm configurationForm)
|
||||
{
|
||||
super(configurationForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when an audio device is plugged or unplugged.
|
||||
*
|
||||
* @param event The property change event which may concern the audio
|
||||
* device.
|
||||
*/
|
||||
public void propertyChange(PropertyChangeEvent event)
|
||||
{
|
||||
String popUpEvent = null;
|
||||
String title = null;
|
||||
CaptureDeviceInfo device = null;
|
||||
ResourceManagementService resources
|
||||
= NeomediaActivator.getResources();
|
||||
|
||||
// If the device configuration has changed: a device has been
|
||||
// plugged or un-plugged.
|
||||
if(DeviceConfiguration.PROP_AUDIO_SYSTEM_DEVICES
|
||||
.equals(event.getPropertyName()))
|
||||
{
|
||||
popUpEvent = NeomediaActivator.DEVICE_CONFIGURATION_HAS_CHANGED;
|
||||
// A device has been connected.
|
||||
if(event.getNewValue() != null)
|
||||
{
|
||||
title = resources.getI18NString(
|
||||
"impl.media.configform"
|
||||
+ ".AUDIO_DEVICE_CONNECTED");
|
||||
device = (CaptureDeviceInfo) event.getNewValue();
|
||||
}
|
||||
// A device has been disconnected.
|
||||
else if(event.getOldValue() != null)
|
||||
{
|
||||
title = resources.getI18NString(
|
||||
"impl.media.configform"
|
||||
+ ".AUDIO_DEVICE_DISCONNECTED");
|
||||
device = (CaptureDeviceInfo) event.getOldValue();
|
||||
}
|
||||
}
|
||||
// If a new capture device has been selected.
|
||||
else if(CaptureDevices.PROP_DEVICE.equals(event.getPropertyName()))
|
||||
{
|
||||
if(event.getNewValue() != null)
|
||||
{
|
||||
popUpEvent = NeomediaActivator.NEW_SELECTED_DEVICE;
|
||||
title = resources.getI18NString(
|
||||
"impl.media.configform"
|
||||
+ ".AUDIO_DEVICE_SELECTED_AUDIO_IN");
|
||||
device = (CaptureDeviceInfo) event.getNewValue();
|
||||
}
|
||||
}
|
||||
// If a new playback device has been selected.
|
||||
else if(PlaybackDevices.PROP_DEVICE.equals(event.getPropertyName()))
|
||||
{
|
||||
if(event.getNewValue() != null)
|
||||
{
|
||||
popUpEvent = NeomediaActivator.NEW_SELECTED_DEVICE;
|
||||
title = resources.getI18NString(
|
||||
"impl.media.configform"
|
||||
+ ".AUDIO_DEVICE_SELECTED_AUDIO_OUT");
|
||||
device = (CaptureDeviceInfo) event.getNewValue();
|
||||
}
|
||||
}
|
||||
// If a new notify device has been selected.
|
||||
else if(NotifyDevices.PROP_DEVICE.equals(event.getPropertyName()))
|
||||
{
|
||||
if(event.getNewValue() != null)
|
||||
{
|
||||
popUpEvent = NeomediaActivator.NEW_SELECTED_DEVICE;
|
||||
title = resources.getI18NString(
|
||||
"impl.media.configform"
|
||||
+ ".AUDIO_DEVICE_SELECTED_AUDIO_NOTIFICATIONS");
|
||||
device = (CaptureDeviceInfo) event.getNewValue();
|
||||
}
|
||||
}
|
||||
|
||||
// Shows the pop-up notification.
|
||||
super.showPopUpNotification(title, device, popUpEvent);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Jitsi, 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.neomedia;
|
||||
|
||||
import java.beans.*;
|
||||
import java.util.*;
|
||||
import javax.media.*;
|
||||
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.service.notification.*;
|
||||
import net.java.sip.communicator.service.systray.event.*;
|
||||
|
||||
import org.jitsi.impl.neomedia.device.*;
|
||||
import org.jitsi.service.resources.*;
|
||||
import org.osgi.framework.*;
|
||||
|
||||
/**
|
||||
* A listener to the click on the popup message concerning video
|
||||
* device configuration changes.
|
||||
*
|
||||
* @author Vincent Lucas
|
||||
*/
|
||||
public class VideoDeviceConfigurationListener
|
||||
extends AbstractDeviceConfigurationListener
|
||||
{
|
||||
/**
|
||||
* Creates a listener to the click on the popup message concerning video
|
||||
* device configuration changes.
|
||||
*
|
||||
* @param configurationForm The audio or video configuration form.
|
||||
*/
|
||||
public VideoDeviceConfigurationListener(
|
||||
ConfigurationForm configurationForm)
|
||||
{
|
||||
super(configurationForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when an audio device is plugged or unplugged.
|
||||
*
|
||||
* @param event The property change event which may concern the audio
|
||||
* device.
|
||||
*/
|
||||
public void propertyChange(PropertyChangeEvent event)
|
||||
{
|
||||
String popUpEvent = null;
|
||||
String title = null;
|
||||
CaptureDeviceInfo device = null;
|
||||
ResourceManagementService resources
|
||||
= NeomediaActivator.getResources();
|
||||
|
||||
// If a new video device has been selected.
|
||||
if(DeviceConfiguration.VIDEO_CAPTURE_DEVICE
|
||||
.equals(event.getPropertyName()))
|
||||
{
|
||||
if(event.getNewValue() != null)
|
||||
{
|
||||
popUpEvent = NeomediaActivator.NEW_SELECTED_DEVICE;
|
||||
title = resources.getI18NString(
|
||||
"impl.media.configform"
|
||||
+ ".VIDEO_DEVICE_SELECTED");
|
||||
device = (CaptureDeviceInfo) event.getNewValue();
|
||||
}
|
||||
}
|
||||
|
||||
// Shows the pop-up notification.
|
||||
this.showPopUpNotification(title, device, popUpEvent);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue