diff options
author | Yana Stamcheva <yana@jitsi.org> | 2012-08-13 09:56:31 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2012-08-13 09:56:31 +0000 |
commit | 8992d147b79b0311f1211d0e1a9d7222ce0a9486 (patch) | |
tree | 78688cbbba1ca95044e6dfee2c7d9e587d894f86 /src/net/java/sip/communicator/service | |
parent | 3301f2a10dd2999f830629bdc73b50fff0e40a59 (diff) | |
download | jitsi-8992d147b79b0311f1211d0e1a9d7222ce0a9486.zip jitsi-8992d147b79b0311f1211d0e1a9d7222ce0a9486.tar.gz jitsi-8992d147b79b0311f1211d0e1a9d7222ce0a9486.tar.bz2 |
A new custom contact action service allowing to represent more actions for a contact entry in the contact list.
Diffstat (limited to 'src/net/java/sip/communicator/service')
5 files changed, 238 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/service/customcontactactions/ContactAction.java b/src/net/java/sip/communicator/service/customcontactactions/ContactAction.java new file mode 100644 index 0000000..c4df97e --- /dev/null +++ b/src/net/java/sip/communicator/service/customcontactactions/ContactAction.java @@ -0,0 +1,49 @@ +/* + * 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.service.customcontactactions; + +import net.java.sip.communicator.service.protocol.*; + +/** + * A custom contact action, used to define an action that can be represented in + * the contact list entry in the user interface. + * + * @author Damian Minkov + * @author Yana Stamcheva + */ +public interface ContactAction<T> +{ + /** + * Invoked when an action occurs. + * + * @param actionSource the source of the action + */ + public void actionPerformed(T actionSource) + throws OperationFailedException; + + /** + * The icon used by the UI to visualise this action. + * @return the button icon. + */ + public byte[] getIcon(); + + /** + * The icon used by the UI to visualise this action. + * @return the button icon. + */ + public byte[] getPressedIcon(); + + /** + * Indicates if this action is visible for the given <tt>actionSource</tt>. + * + * @param actionSource the action source for which we're verifying the + * action. + * @return <tt>true</tt> if the action should be visible for the given + * <tt>actionSource</tt>, <tt>false</tt> - otherwise + */ + public boolean isVisible(T actionSource); +}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java b/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java new file mode 100644 index 0000000..3aaf0ba --- /dev/null +++ b/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java @@ -0,0 +1,32 @@ +/* + * 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.service.customcontactactions; + +import java.util.*; + +/** + * The <tt>CustomContactActionsService</tt> can be used to define a set of + * custom actions for a contact list entry. + * + * @author Damian Minkov + */ +public interface CustomContactActionsService<T> +{ + /** + * Returns the template class that this service has been initialized with + * + * @return the template class + */ + public Class<T> getContactSourceClass(); + + /** + * Returns all custom actions defined by this service. + * + * @return an iterator over a list of <tt>ContactAction</tt>s + */ + public Iterator<ContactAction<T>> getCustomContactActions(); +} diff --git a/src/net/java/sip/communicator/service/customcontactactions/customcontactactions.manifest.mf b/src/net/java/sip/communicator/service/customcontactactions/customcontactactions.manifest.mf new file mode 100644 index 0000000..c00ebba --- /dev/null +++ b/src/net/java/sip/communicator/service/customcontactactions/customcontactactions.manifest.mf @@ -0,0 +1,7 @@ +Bundle-Name: Custom Contact Actions +Bundle-Description: Custom Contact Actions +Bundle-Vendor: jitsi.org +Bundle-Version: 0.0.1 +System-Bundle: yes +Import-Package: net.java.sip.communicator.service.protocol +Export-Package: net.java.sip.communicator.service.customcontactactions
\ No newline at end of file diff --git a/src/net/java/sip/communicator/service/protocol/NotificationMessage.java b/src/net/java/sip/communicator/service/protocol/NotificationMessage.java new file mode 100644 index 0000000..6078f82 --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/NotificationMessage.java @@ -0,0 +1,103 @@ +/* + * 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.service.protocol; + +/** + * A notification message that is used to deliver notifications for an waiting + * server message. + * + * @see MessageWaitingListener, MessageWaitingEvent + * + * @author Yana Stamcheva + */ +public class NotificationMessage +{ + /** + * The contact from which the message is coming. + */ + private final String fromContact; + + /** + * The name of the group of messages to which this message belongs, + * if there's any. + */ + private final String messageGroup; + + /** + * Additional details related to the message. + */ + private final String messageDetails; + + /** + * The text of the message. + */ + private final String messageText; + + /** + * Creates an instance of <tt>NotificationMessage</tt> by specifying the + * name of the contact from which the message is, the message group, any + * additional details and the message actual text. + * + * @param fromContact the contact from which the message is coming + * @param messageGroup the name of the group of messages to which this + * message belongs + * @param messageDetails additional details related to the message + * @param messageText the text of the message + */ + public NotificationMessage( String fromContact, + String messageGroup, + String messageDetails, + String messageText) + { + this.fromContact = fromContact; + this.messageGroup = messageGroup; + this.messageDetails = messageDetails; + this.messageText = messageText; + } + + /** + * Returns the contact from which the message is coming + * + * @return the contact from which the message is coming + */ + public String getFromContact() + { + return fromContact; + } + + /** + * Returns the name of the group of messages to which this + * message belongs. + * + * @return the name of the group of messages to which this + * message belongs + */ + public String getMessageGroup() + { + return messageGroup; + } + + /** + * Returns the additional details related to the message + * + * @return the additional details related to the message + */ + public String getMessageDetails() + { + return messageDetails; + } + + /** + * Returns the text of the message + * + * @return the text of the message + */ + public String getMessageText() + { + return messageText; + } +} diff --git a/src/net/java/sip/communicator/service/protocol/event/MessageWaitingEvent.java b/src/net/java/sip/communicator/service/protocol/event/MessageWaitingEvent.java index b705cec..6ba8fd5 100644 --- a/src/net/java/sip/communicator/service/protocol/event/MessageWaitingEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/MessageWaitingEvent.java @@ -56,6 +56,11 @@ public class MessageWaitingEvent private OperationSetMessageWaiting.MessageType messageType; /** + * The list of notification messages concerned by this event. + */ + private List<NotificationMessage> messageList; + + /** * Constructs the Event with the given source, typically the provider and * number of messages. * @@ -76,6 +81,39 @@ public class MessageWaitingEvent int unreadUrgentMessages, int readUrgentMessages) { + this( source, + messageType, + account, + unreadMessages, + readMessages, + unreadUrgentMessages, + readUrgentMessages, + null); + } + + /** + * Constructs the Event with the given source, typically the provider and + * number of messages. + * + * @param messageType the message type for this event. + * @param source the protocol provider from which this event is coming. + * @param account the account URI we can use to reach the messages. + * @param unreadMessages the unread messages. + * @param readMessages the read messages. + * @param unreadUrgentMessages the unread urgent messages. + * @param readUrgentMessages the read urgent messages. + * @param messages the list of messages that this event is about. + */ + public MessageWaitingEvent( + ProtocolProviderService source, + OperationSetMessageWaiting.MessageType messageType, + String account, + int unreadMessages, + int readMessages, + int unreadUrgentMessages, + int readUrgentMessages, + List<NotificationMessage> messages) + { super(source); this.messageType = messageType; @@ -84,6 +122,7 @@ public class MessageWaitingEvent this.readMessages = readMessages; this.unreadUrgentMessages = unreadUrgentMessages; this.readUrgentMessages = readUrgentMessages; + this.messageList = messages; } /** @@ -150,4 +189,12 @@ public class MessageWaitingEvent { return messageType; } + + public Iterator<NotificationMessage> getMessages() + { + if (messageList != null) + return messageList.iterator(); + + return null; + } } |