Instant refresh of call history with new calls, when we're in call history view. Improved call history interface. Making sure to remove all operation set related gui listeners when a protocol provider is unregistered.cusax-fix
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 965 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1013 B |
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.main;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>UINotification</tt> class represents a notification received in the
|
||||
* user interface. This could be a missed call, voicemail, email notification or
|
||||
* any other notification.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class UINotification
|
||||
{
|
||||
/**
|
||||
* The parent notification group.
|
||||
*/
|
||||
private final UINotificationGroup parentGroup;
|
||||
|
||||
/**
|
||||
* The name associated with this notification.
|
||||
*/
|
||||
private final String notificationName;
|
||||
|
||||
/**
|
||||
* The time when the notification was received.
|
||||
*/
|
||||
private final Date notificationTime;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>UINotification</tt> by specifying the
|
||||
* notification name and time.
|
||||
*
|
||||
* notification belongs
|
||||
* @param displayName the name associated to this notification
|
||||
* @param time the time when the notification was received
|
||||
* @param parentGroup the group of notifications, to which this notification
|
||||
* belongs
|
||||
*/
|
||||
public UINotification( String displayName,
|
||||
Date time,
|
||||
UINotificationGroup parentGroup)
|
||||
{
|
||||
this.notificationName = displayName;
|
||||
this.notificationTime = time;
|
||||
this.parentGroup = parentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name associated with this notification.
|
||||
*
|
||||
* @return the name associated with this notification
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return notificationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the notification was received.
|
||||
*
|
||||
* @return the time the notification was received
|
||||
*/
|
||||
public Date getTime()
|
||||
{
|
||||
return notificationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent notification group.
|
||||
*
|
||||
* @return the parent notification group
|
||||
*/
|
||||
public UINotificationGroup getGroup()
|
||||
{
|
||||
return parentGroup;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.main;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>UINotificationGroup</tt> class represents a group of notifications.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class UINotificationGroup
|
||||
{
|
||||
/**
|
||||
* A list of all unread notifications.
|
||||
*/
|
||||
private Collection<UINotification> unreadNotifications
|
||||
= new ArrayList<UINotification>();
|
||||
|
||||
/**
|
||||
* The name of the group to which this notification belongs.
|
||||
*/
|
||||
private final String groupName;
|
||||
|
||||
/**
|
||||
* The display name of the group to which this notification belongs.
|
||||
*/
|
||||
private final String groupDisplayName;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param groupName the name of the group to which this notification belongs
|
||||
* @param groupDisplayName the display name of the group to which this
|
||||
*/
|
||||
public UINotificationGroup(String groupName, String groupDisplayName)
|
||||
{
|
||||
this.groupName = groupName;
|
||||
this.groupDisplayName = groupDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the group, to which this notification belongs.
|
||||
*
|
||||
* @return the name of the group, to which this notification belongs
|
||||
*/
|
||||
public String getGroupName()
|
||||
{
|
||||
return groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the group, to which this notification
|
||||
* belongs.
|
||||
*
|
||||
* @return the display name of the group, to which this notification
|
||||
* belongs
|
||||
*/
|
||||
public String getGroupDisplayName()
|
||||
{
|
||||
return groupDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given notification to the list of unread notifications and
|
||||
* notifies interested listeners.
|
||||
*
|
||||
* @param notification the <tt>UINotification</tt> to add
|
||||
*/
|
||||
public void addNotification(UINotification notification)
|
||||
{
|
||||
synchronized (unreadNotifications)
|
||||
{
|
||||
unreadNotifications.add(notification);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all unread notifications.
|
||||
*/
|
||||
public void removeAllNotifications()
|
||||
{
|
||||
synchronized (unreadNotifications)
|
||||
{
|
||||
unreadNotifications.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all unread notifications.
|
||||
*
|
||||
* @return a list of all unread notifications
|
||||
*/
|
||||
public Iterator<UINotification> getUnreadNotifications()
|
||||
{
|
||||
return new ArrayList<UINotification>(unreadNotifications).iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count of unread notifications for this group.
|
||||
*
|
||||
* @return the count of unread notifications for this group
|
||||
*/
|
||||
public int getUnreadNotificationsCount()
|
||||
{
|
||||
synchronized (unreadNotifications)
|
||||
{
|
||||
return unreadNotifications.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.main;
|
||||
|
||||
/**
|
||||
* The <tt>UINotificationListener</tt> listens for new notifications received
|
||||
* in the user interface. Notifications could be for example missed calls,
|
||||
* voicemails or email messages.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface UINotificationListener
|
||||
{
|
||||
/**
|
||||
* Indicates that a new notification is received.
|
||||
*
|
||||
* @param notification the notification that was received
|
||||
*/
|
||||
public void notificationReceived(UINotification notification);
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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.main;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>UINotificationManager</tt> manages all notifications dedicated to
|
||||
* be shown in the main application window. These could be missed calls, voice
|
||||
* messages, etc.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class UINotificationManager
|
||||
{
|
||||
/**
|
||||
* The list of all notification groups.
|
||||
*/
|
||||
private static Collection<UINotificationGroup> notificationGroups
|
||||
= new ArrayList<UINotificationGroup>();
|
||||
|
||||
/**
|
||||
* Listener notified for changes in missed calls count.
|
||||
*/
|
||||
private static Collection<UINotificationListener> notificationListeners
|
||||
= new ArrayList<UINotificationListener>();
|
||||
|
||||
/**
|
||||
* Adds the given <tt>UINotificationListener</tt> to the list of listeners
|
||||
* that would be notified on any changes in missed calls count.
|
||||
*
|
||||
* @param l the <tt>UINotificationListener</tt> to add
|
||||
*/
|
||||
public static void addNotificationListener(UINotificationListener l)
|
||||
{
|
||||
synchronized (l)
|
||||
{
|
||||
notificationListeners.add(l);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given <tt>UINotificationListener</tt> from the list of
|
||||
* listeners that are notified on any changes in missed calls count.
|
||||
*
|
||||
* @param l the <tt>UINotificationListener</tt> to remove
|
||||
*/
|
||||
public static void removeNotificationListener(UINotificationListener l)
|
||||
{
|
||||
synchronized (l)
|
||||
{
|
||||
notificationListeners.remove(l);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given notification to the list of unread notifications and
|
||||
* notifies interested listeners.
|
||||
*
|
||||
* @param notification the <tt>UINotification</tt> to add
|
||||
*/
|
||||
public static void addNotification(UINotification notification)
|
||||
{
|
||||
UINotificationGroup group = notification.getGroup();
|
||||
|
||||
if (!notificationGroups.contains(group))
|
||||
notificationGroups.add(group);
|
||||
|
||||
group.addNotification(notification);
|
||||
|
||||
fireNotificationEvent(notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all unread notifications.
|
||||
*
|
||||
* @param group removes all unread notifications for the given notification
|
||||
* group
|
||||
*/
|
||||
public static void removeAllNotifications(UINotificationGroup group)
|
||||
{
|
||||
group.removeAllNotifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all unread notifications from all notification groups.
|
||||
*/
|
||||
public static void removeAllNotifications()
|
||||
{
|
||||
Iterator<UINotificationGroup> groups = notificationGroups.iterator();
|
||||
|
||||
while (groups.hasNext())
|
||||
{
|
||||
groups.next().removeAllNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all unread notifications.
|
||||
*
|
||||
* @param group the notification group, which notification we're looking
|
||||
* for
|
||||
* @return a list of all unread notifications
|
||||
*/
|
||||
public static Iterator<UINotification> getUnreadNotifications(
|
||||
UINotificationGroup group)
|
||||
{
|
||||
return group.getUnreadNotifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all notification groups.
|
||||
*
|
||||
* @return a list of all notification groups
|
||||
*/
|
||||
public static Collection<UINotificationGroup> getNotificationGroups()
|
||||
{
|
||||
return new ArrayList<UINotificationGroup>(notificationGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies interested <tt>UINotificationListener</tt> that a new
|
||||
* notification has been received.
|
||||
*
|
||||
* @param notification the new notification
|
||||
*/
|
||||
private static void fireNotificationEvent(UINotification notification)
|
||||
{
|
||||
synchronized (notificationListeners)
|
||||
{
|
||||
Iterator<UINotificationListener> listeners
|
||||
= notificationListeners.iterator();
|
||||
|
||||
while (listeners.hasNext())
|
||||
listeners.next().notificationReceived(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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.main.call;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>MissedCall</tt> class wraps a missed call in order to provide
|
||||
* information about the call later.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class MissedCall
|
||||
{
|
||||
private final String callName;
|
||||
|
||||
private final Date callTime;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>MissedCall</tt> by specifying the call name
|
||||
* and time.
|
||||
* @param callName the name associated to this call
|
||||
* @param callTime the time of the missed call
|
||||
*/
|
||||
public MissedCall(String callName, Date callTime)
|
||||
{
|
||||
this.callName = callName;
|
||||
this.callTime = callTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name associated with this call.
|
||||
* @return the name associated with this call
|
||||
*/
|
||||
public String getCallName()
|
||||
{
|
||||
return callName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the call was made.
|
||||
* @return the time the call was made
|
||||
*/
|
||||
public Date getCallTime()
|
||||
{
|
||||
return callTime;
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* 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.main.call;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>MissedCallsListener</tt> listens for changes in the missed calls
|
||||
* count. It is notified each time when a missed calls is registered by the
|
||||
* <tt>CallManager</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface MissedCallsListener
|
||||
{
|
||||
/**
|
||||
* Indicates the missed calls count has changed.
|
||||
* @param missedCalls the new missed calls list
|
||||
*/
|
||||
public void missedCallCountChanged(Collection<MissedCall> missedCalls);
|
||||
}
|
||||
@ -0,0 +1,456 @@
|
||||
/*
|
||||
* 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.main.contactlist.notifsource;
|
||||
|
||||
import java.beans.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.OperationSetMessageWaiting.MessageType;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
/**
|
||||
* The <tt>NotificationContact</tt> represents a notification entry shown in
|
||||
* the contact list history view. It could represent a voice message entry,
|
||||
* email notification or something else.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class NotificationContact
|
||||
implements UIContact,
|
||||
RegistrationStateChangeListener,
|
||||
ProviderPresenceStatusListener
|
||||
{
|
||||
/**
|
||||
* The tip explaining to the user how to hear its voice messages.
|
||||
*/
|
||||
private static final String VOICEMAIL_TIP
|
||||
= GuiActivator.getResources()
|
||||
.getI18NString("service.gui.VOICEMAIL_TIP");
|
||||
|
||||
/**
|
||||
* The parent contact list group.
|
||||
*/
|
||||
private NotificationGroup parentGroup;
|
||||
|
||||
/**
|
||||
* The corresponding protocol provider.
|
||||
*/
|
||||
private final ProtocolProviderService protocolProvider;
|
||||
|
||||
/**
|
||||
* The corresponding <tt>ContactNode</tt> in the contact list component
|
||||
* data model.
|
||||
*/
|
||||
private ContactNode contactNode;
|
||||
|
||||
/**
|
||||
* The notification detail.
|
||||
*/
|
||||
private UIContactDetail notificationDetail;
|
||||
|
||||
/**
|
||||
* The count of unread messages attached to this notification.
|
||||
*/
|
||||
private int unreadMessageCount = 0;
|
||||
|
||||
/**
|
||||
* The count of read messages attached to this notification.
|
||||
*/
|
||||
private int readMessageCount = 0;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>NotificationContact</tt> by specifying the
|
||||
* parent group and the corresponding <tt>ProtocolProviderService</tt>.
|
||||
*
|
||||
* @param group the parent group
|
||||
* @param protocolProvider the corresponding protocol provider
|
||||
*/
|
||||
public NotificationContact( NotificationGroup group,
|
||||
ProtocolProviderService protocolProvider)
|
||||
{
|
||||
this.parentGroup = group;
|
||||
this.protocolProvider = protocolProvider;
|
||||
|
||||
protocolProvider.addRegistrationStateChangeListener(this);
|
||||
|
||||
OperationSetPresence presenceOpSet
|
||||
= protocolProvider.getOperationSet(OperationSetPresence.class);
|
||||
|
||||
if (presenceOpSet != null)
|
||||
presenceOpSet.addProviderPresenceStatusListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptor of this contact.
|
||||
*
|
||||
* @return the descriptor of this contact
|
||||
*/
|
||||
public Object getDescriptor()
|
||||
{
|
||||
return protocolProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of this contact.
|
||||
*
|
||||
* @return the display name of this contact
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return protocolProvider.getAccountID().getAccountAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display details of this contact. These would be shown
|
||||
* whenever the contact is selected. In the <tt>NotificationContact</tt>
|
||||
* these contain information about unread and read messages.
|
||||
*
|
||||
* @return the display details of this contact
|
||||
*/
|
||||
public String getDisplayDetails()
|
||||
{
|
||||
String displayDetails;
|
||||
|
||||
ResourceManagementService resources = GuiActivator.getResources();
|
||||
|
||||
if (unreadMessageCount > 0 && readMessageCount > 0)
|
||||
{
|
||||
displayDetails = resources.getI18NString(
|
||||
"service.gui.VOICEMAIL_NEW_OLD_RECEIVED",
|
||||
new String[]{ Integer.toString(unreadMessageCount),
|
||||
Integer.toString(readMessageCount)});
|
||||
}
|
||||
else if (unreadMessageCount > 0)
|
||||
{
|
||||
displayDetails = resources.getI18NString(
|
||||
"service.gui.VOICEMAIL_NEW_RECEIVED",
|
||||
new String[]{ Integer.toString(unreadMessageCount)});
|
||||
}
|
||||
else if (readMessageCount > 0)
|
||||
{
|
||||
displayDetails = resources.getI18NString(
|
||||
"service.gui.VOICEMAIL_OLD_RECEIVED",
|
||||
new String[]{ Integer.toString(readMessageCount)});
|
||||
}
|
||||
else
|
||||
{
|
||||
displayDetails = resources.getI18NString(
|
||||
"service.gui.VOICEMAIL_NO_MESSAGES");
|
||||
}
|
||||
|
||||
return displayDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of this contact in its source.
|
||||
*
|
||||
* @return the source index
|
||||
*/
|
||||
public int getSourceIndex()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon indicating that this is a notification contact.
|
||||
*
|
||||
* @param isSelected indicates if the contact is selected
|
||||
* @param width the width of the avatar
|
||||
* @param height the height of the avatar
|
||||
* @return the avatar of this contact
|
||||
*/
|
||||
public ImageIcon getAvatar(boolean isSelected, int width, int height)
|
||||
{
|
||||
ImageIcon avatarIcon = null;
|
||||
if (parentGroup.getMessageType().equals(MessageType.VOICE))
|
||||
{
|
||||
avatarIcon = GuiActivator.getResources().getImage(
|
||||
"service.gui.icons.VOICEMAIL");
|
||||
}
|
||||
|
||||
return avatarIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status icon of this contact or null if no status is
|
||||
* available.
|
||||
*
|
||||
* @return the status icon of this contact or null if no status is
|
||||
* available
|
||||
*/
|
||||
public ImageIcon getStatusIcon()
|
||||
{
|
||||
OperationSetPresence presence = protocolProvider
|
||||
.getOperationSet(OperationSetPresence.class);
|
||||
|
||||
if (presence != null)
|
||||
{
|
||||
return new ImageIcon(
|
||||
Constants.getStatusIcon(presence.getPresenceStatus()));
|
||||
}
|
||||
else if (protocolProvider.isRegistered())
|
||||
{
|
||||
return new ImageIcon(
|
||||
Constants.getStatusIcon(Constants.ONLINE_STATUS));
|
||||
}
|
||||
|
||||
return new ImageIcon(
|
||||
Constants.getStatusIcon(Constants.OFFLINE_STATUS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a tool tip for this contact. If such tooltip is
|
||||
* provided it would be shown on mouse over over this <tt>UIContact</tt>.
|
||||
*
|
||||
* @return the tool tip for this contact descriptor
|
||||
*/
|
||||
/**
|
||||
* Returns the tool tip opened on mouse over.
|
||||
* @return the tool tip opened on mouse over
|
||||
*/
|
||||
public ExtendedTooltip getToolTip()
|
||||
{
|
||||
ExtendedTooltip tip = new ExtendedTooltip(true);
|
||||
|
||||
ImageIcon avatarImage = getAvatar(true, 64, 64);
|
||||
|
||||
if (avatarImage != null)
|
||||
tip.setImage(avatarImage);
|
||||
|
||||
tip.setTitle(getDisplayName());
|
||||
|
||||
tip.addLine(null, getDisplayDetails());
|
||||
|
||||
tip.setBottomText(VOICEMAIL_TIP);
|
||||
|
||||
return tip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate that no right button menu is provided for this
|
||||
* contact.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent group.
|
||||
*
|
||||
* @return the parent group
|
||||
*/
|
||||
public UIGroup getParentGroup()
|
||||
{
|
||||
return parentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given <tt>UIGroup</tt> to be the parent group of this
|
||||
* <tt>UIContact</tt>.
|
||||
*
|
||||
* @param parentGroup the parent <tt>UIGroup</tt> of this contact
|
||||
*/
|
||||
public void setParentGroup(UIGroup parentGroup)
|
||||
{
|
||||
if (!(parentGroup instanceof NotificationGroup))
|
||||
return;
|
||||
|
||||
this.parentGroup = (NotificationGroup) parentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* No search strings are provided for this contact.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public Iterator<String> getSearchStrings()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding <tt>ContactNode</tt>. The <tt>ContactNode</tt>
|
||||
* is the real node that is stored in the contact list component data model.
|
||||
*
|
||||
* @return the corresponding <tt>ContactNode</tt>
|
||||
*/
|
||||
public ContactNode getContactNode()
|
||||
{
|
||||
return contactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given <tt>contactNode</tt>. The <tt>ContactNode</tt>
|
||||
* is the real node that is stored in the contact list component data model.
|
||||
*
|
||||
* @param contactNode the <tt>ContactNode</tt> that corresponds to this
|
||||
* <tt>UIGroup</tt>
|
||||
*/
|
||||
public void setContactNode(ContactNode contactNode)
|
||||
{
|
||||
this.contactNode = contactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class.
|
||||
*
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're interested in
|
||||
* @return the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class
|
||||
*/
|
||||
public UIContactDetail getDefaultContactDetail(
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
if (opSetClass.equals(OperationSetBasicTelephony.class))
|
||||
return notificationDetail;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of <tt>UIContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class.
|
||||
*
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're interested in
|
||||
* @return a list of <tt>UIContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class
|
||||
*/
|
||||
public List<UIContactDetail> getContactDetailsForOperationSet(
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
List<UIContactDetail> resultList = new LinkedList<UIContactDetail>();
|
||||
|
||||
if (opSetClass.equals(OperationSetBasicTelephony.class))
|
||||
resultList.add(notificationDetail);
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the corresponding message account.
|
||||
*
|
||||
* @param messageAccount the message account corresponding to the contained
|
||||
* notification
|
||||
*/
|
||||
public void setMessageAccount(String messageAccount)
|
||||
{
|
||||
notificationDetail
|
||||
= new MessageWaitingDetail(protocolProvider, messageAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of unread messages, this notification is about.
|
||||
*
|
||||
* @param count the number of unread messages, this notification is about
|
||||
*/
|
||||
public void setUnreadMessageCount(int count)
|
||||
{
|
||||
this.unreadMessageCount = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of unread messages, this notification is about.
|
||||
*
|
||||
* @return the number of unread messages, this notification is about
|
||||
*/
|
||||
public int getUnreadMessageCount()
|
||||
{
|
||||
return unreadMessageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of read messages, this notification is about.
|
||||
*
|
||||
* @param count the number of read messages, this notification is about
|
||||
*/
|
||||
public void setReadMessageCount(int count)
|
||||
{
|
||||
this.readMessageCount = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* The implementation of the <tt>UIContactDetail</tt> interface for the
|
||||
* external source <tt>ContactDetail</tt>s.
|
||||
*/
|
||||
private class MessageWaitingDetail
|
||||
extends UIContactDetail
|
||||
{
|
||||
/**
|
||||
* Creates an instance of <tt>SourceContactDetail</tt> by specifying
|
||||
* the underlying <tt>detail</tt> and the <tt>OperationSet</tt> class
|
||||
* for it.
|
||||
*
|
||||
* @param protocolProvider the protocol provider corresponding to this
|
||||
* detail
|
||||
* @param messageAccount the message account corresponding to this
|
||||
* detail
|
||||
*/
|
||||
public MessageWaitingDetail(ProtocolProviderService protocolProvider,
|
||||
String messageAccount)
|
||||
{
|
||||
super( messageAccount,
|
||||
messageAccount,
|
||||
protocolProvider,
|
||||
protocolProvider.getProtocolName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate that this detail doesn't support presence.
|
||||
* @return null
|
||||
*/
|
||||
public PresenceStatus getPresenceStatus()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the notification contact corresponding the the attached provider
|
||||
* in order to better reflect its state.
|
||||
*
|
||||
* @param evt the <tt>ProviderPresenceStatusChangeEvent</tt> that has
|
||||
* notified us of the state change
|
||||
*/
|
||||
public void registrationStateChanged(RegistrationStateChangeEvent evt)
|
||||
{
|
||||
RegistrationState newState = evt.getNewState();
|
||||
if (newState.equals(RegistrationState.UNREGISTERED)
|
||||
|| newState.equals(RegistrationState.REGISTERED))
|
||||
{
|
||||
TreeContactList contactList = GuiActivator.getContactList();
|
||||
|
||||
contactList.refreshContact(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the notification contact corresponding the the attached provider
|
||||
* in order to better reflect its status.
|
||||
*
|
||||
* @param evt the <tt>ProviderPresenceStatusChangeEvent</tt> that has
|
||||
* notified us of the status change
|
||||
*/
|
||||
public void providerStatusChanged(ProviderPresenceStatusChangeEvent evt)
|
||||
{
|
||||
TreeContactList contactList = GuiActivator.getContactList();
|
||||
|
||||
contactList.refreshContact(this);
|
||||
}
|
||||
|
||||
public void providerStatusMessageChanged(PropertyChangeEvent evt) {}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.main.contactlist.notifsource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.service.protocol.OperationSetMessageWaiting.MessageType;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>NotificationContactSource</tt> represents a contact source that would
|
||||
* listen for message waiting notifications and would display them in the
|
||||
* history view of the contact list.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class NotificationContactSource
|
||||
implements MessageWaitingListener
|
||||
{
|
||||
/**
|
||||
* A mapping attaching to each <tt>NotificationGroup</tt> the
|
||||
* corresponding <tt>MessageType</tt>, for which notifications
|
||||
* are received.
|
||||
*/
|
||||
private final Hashtable<MessageType, NotificationGroup> groups
|
||||
= new Hashtable<MessageType, NotificationGroup>();
|
||||
|
||||
/**
|
||||
* Adds the received waiting message to the corresponding group and contact.
|
||||
* Also adds it the <tt>UINotificationManager</tt> that would take care of
|
||||
* notifying the user.
|
||||
*
|
||||
* @param evt the notification event.
|
||||
*/
|
||||
public void messageWaitingNotify(MessageWaitingEvent evt)
|
||||
{
|
||||
MessageType type = evt.getMessageType();
|
||||
|
||||
NotificationGroup group = groups.get(type);
|
||||
|
||||
if (group == null)
|
||||
{
|
||||
group = new NotificationGroup(type);
|
||||
groups.put(type, group);
|
||||
}
|
||||
|
||||
group.messageWaitingNotify(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <tt>Iterator</tt> over a list of all notification groups
|
||||
* contained in this source.
|
||||
*
|
||||
* @return an <tt>Iterator</tt> over a list of all notification groups
|
||||
* contained in this source
|
||||
*/
|
||||
public Iterator<? extends UIGroup> getNotificationGroups()
|
||||
{
|
||||
return groups.values().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <tt>Iterator</tt> over a list of all notification contacts
|
||||
* contained in the given group.
|
||||
*
|
||||
* @param group the group, which notification contacts we're looking for
|
||||
* @return an <tt>Iterator</tt> over a list of all notification contacts
|
||||
* contained in the given group
|
||||
*/
|
||||
public Iterator<? extends UIContact> getNotifications(UIGroup group)
|
||||
{
|
||||
if (!(group instanceof NotificationGroup))
|
||||
return null;
|
||||
|
||||
NotificationGroup notifGroup = (NotificationGroup) group;
|
||||
|
||||
return notifGroup.getNotifications();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,262 @@
|
||||
/*
|
||||
* 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.main.contactlist.notifsource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.service.protocol.OperationSetMessageWaiting.MessageType;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
|
||||
/**
|
||||
* The <tt>NotificationGroup</tt> represents a group of notification entries
|
||||
* shown in the contact list history view. It could represent the voice
|
||||
* messages,.emails, etc.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class NotificationGroup
|
||||
implements UIGroup
|
||||
{
|
||||
/**
|
||||
* The type of the notification message, identifying this group.
|
||||
*/
|
||||
private final MessageType type;
|
||||
|
||||
/**
|
||||
* The corresponding group node in the contact list component.
|
||||
*/
|
||||
private GroupNode groupNode;
|
||||
|
||||
/**
|
||||
* A mapping attaching to each <tt>NotificationContact</tt> the
|
||||
* corresponding <tt>ProtocolProviderService</tt>, for which notifications
|
||||
* are received.
|
||||
*/
|
||||
private final Hashtable<ProtocolProviderService, NotificationContact>
|
||||
contacts
|
||||
= new Hashtable<ProtocolProviderService, NotificationContact>();
|
||||
|
||||
/**
|
||||
* The group of UI notifications.
|
||||
*/
|
||||
private static UINotificationGroup uiNotificationGroup;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>NotificationGroup</tt> by specifying the
|
||||
* message type.
|
||||
*
|
||||
* @param type the type of messages that this group would contain
|
||||
*/
|
||||
public NotificationGroup(MessageType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptor of the group. This would be the underlying object
|
||||
* that should provide all other necessary information for the group.
|
||||
*
|
||||
* @return the descriptor of the group
|
||||
*/
|
||||
public Object getDescriptor()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The display name of the group. The display name is the name to be shown
|
||||
* in the contact list group row.
|
||||
*
|
||||
* @return the display name of the group
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
String displayName;
|
||||
if (type.equals(MessageType.VOICE))
|
||||
displayName = GuiActivator.getResources()
|
||||
.getI18NString("service.gui.VOICEMAIL_TITLE");
|
||||
else
|
||||
displayName = type.toString();
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of this group in its source. In other words this is
|
||||
* the descriptor index.
|
||||
*
|
||||
* @return the index of this group in its source
|
||||
*/
|
||||
public int getSourceIndex()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate that the parent group is the root group.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public UIGroup getParentGroup()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>false</tt> to indicate that this group is never collapsed.
|
||||
*
|
||||
* @return <tt>false</tt>
|
||||
*/
|
||||
public boolean isGroupCollapsed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count of online child contacts.
|
||||
*
|
||||
* @return the count of online child contacts
|
||||
*/
|
||||
public int countOnlineChildContacts()
|
||||
{
|
||||
return contacts.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the child contacts count.
|
||||
*
|
||||
* @return child contacts count
|
||||
*/
|
||||
public int countChildContacts()
|
||||
{
|
||||
return contacts.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of this group.
|
||||
*
|
||||
* @return the identifier of this group
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>GroupNode</tt> corresponding to this <tt>UIGroup</tt>.
|
||||
* The is the actual node used in the contact list component data model.
|
||||
*
|
||||
* @return the <tt>GroupNode</tt> corresponding to this <tt>UIGroup</tt>
|
||||
*/
|
||||
public GroupNode getGroupNode()
|
||||
{
|
||||
return groupNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>GroupNode</tt> corresponding to this <tt>UIGroup</tt>.
|
||||
*
|
||||
* @param groupNode the <tt>GroupNode</tt> to set. The is the actual
|
||||
* node used in the contact list component data model.
|
||||
*/
|
||||
public void setGroupNode(GroupNode groupNode)
|
||||
{
|
||||
this.groupNode = groupNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate that there's no right button menu provided for
|
||||
* this group.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <tt>Iterator</tt> over a list of all notification contacts
|
||||
* contained in this group.
|
||||
*
|
||||
* @return an <tt>Iterator</tt> over a list of all notification contacts
|
||||
* contained in this group
|
||||
*/
|
||||
public Iterator<? extends UIContact> getNotifications()
|
||||
{
|
||||
return contacts.values().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message type indicating the identity of this group.
|
||||
*
|
||||
* @return the message type corresponding to this group
|
||||
*/
|
||||
public MessageType getMessageType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates all necessary notification contacts coming from the given
|
||||
* <tt>MessageWaitingEvent</tt>.
|
||||
*
|
||||
* @param event the <tt>MessageWaitingEvent</tt> that notified us
|
||||
*/
|
||||
public void messageWaitingNotify(MessageWaitingEvent event)
|
||||
{
|
||||
ProtocolProviderService protocolProvider = event.getSourceProvider();
|
||||
|
||||
NotificationContact contact = contacts.get(protocolProvider);
|
||||
|
||||
TreeContactList contactList = GuiActivator.getContactList();
|
||||
|
||||
boolean isNew = false;
|
||||
if (contact == null)
|
||||
{
|
||||
contact = new NotificationContact(this, protocolProvider);
|
||||
contacts.put(protocolProvider, contact);
|
||||
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
contact.setMessageAccount(event.getAccount());
|
||||
contact.setUnreadMessageCount(event.getUnreadMessages());
|
||||
contact.setReadMessageCount(event.getReadMessages());
|
||||
|
||||
if (contactList.getCurrentFilter().isMatching(contact))
|
||||
{
|
||||
if (isNew)
|
||||
contactList.addContact(contact, this, true);
|
||||
else
|
||||
contactList.refreshContact(contact);
|
||||
}
|
||||
|
||||
if (contact.getUnreadMessageCount() > 0)
|
||||
{
|
||||
if (uiNotificationGroup == null)
|
||||
uiNotificationGroup
|
||||
= new UINotificationGroup(
|
||||
getDisplayName(),
|
||||
GuiActivator.getResources()
|
||||
.getI18NString("service.gui.VOICEMAIL_TOOLTIP"));
|
||||
|
||||
UINotificationManager.addNotification(
|
||||
new UINotification(
|
||||
contact.getDisplayName()
|
||||
+ " : " + contact.getDisplayDetails() ,
|
||||
new Date(),
|
||||
uiNotificationGroup));
|
||||
}
|
||||
}
|
||||
}
|
||||