[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/service/protocol/event/ChatRoomMessageReceivedEvent.java

emcho at dev.java.net emcho at dev.java.net
Mon May 14 13:38:49 CEST 2007


User: emcho   
Date: 2007-05-14 11:38:49+0000
Log:
 Added event types in order to allow distinguishing action and system messages.

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/service/protocol/event/
==================================================================================

File [changed]: ChatRoomMessageReceivedEvent.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/service/protocol/event/ChatRoomMessageReceivedEvent.java?r1=1.3&r2=1.4
Delta lines:  +63 -0
--------------------
--- ChatRoomMessageReceivedEvent.java	2007-04-27 15:43:46+0000	1.3
+++ ChatRoomMessageReceivedEvent.java	2007-05-14 11:38:46+0000	1.4
@@ -34,6 +34,35 @@
     private Message message = null;
 
     /**
+     * The type of message event that this instance represents.
+     */
+    private int eventType = -1;
+
+    /**
+     * An event type indicating that the message being received is a standard
+     * conversation message sent by another member of the chatroom to all
+     * current participants.
+     */
+    public static final int CONVERSATION_MESSAGE_RECEIVED = 1;
+
+    /**
+     * An event type indicating that the message being received is a special
+     * message that sent by either another member or the server itself,
+     * indicating that some kind of action (other than the delivery of a
+     * conversation message) has occurred. Action messages are widely used
+     * in IRC through the /action and /me commands
+     */
+    public static final int ACTION_MESSAGE_RECEIVED = 2;
+
+    /**
+     * An event type indicting that the message being received is a system
+     * message being sent by the server or a system administrator, possibly
+     * notifying us of something important such as ongoing maintenance
+     * activities or server downtime.
+     */
+    public static final int SYSTEM_MESSAGE_RECEIVED = 3;
+
+    /**
      * Creates a <tt>MessageReceivedEvent</tt> representing reception of the
      * <tt>source</tt> message received from the specified <tt>from</tt>
      * contact.
@@ -48,11 +77,33 @@
                                         Date timestamp,
                                         Message message)
     {
+        this(source, from, timestamp, message, CONVERSATION_MESSAGE_RECEIVED);
+    }
+
+    /**
+     * Creates a <tt>MessageReceivedEvent</tt> representing reception of the
+     * <tt>source</tt> message received from the specified <tt>from</tt>
+     * contact.
+     *
+     * @param source the <tt>ChatRoom</tt> for which the message is received.
+     * @param from the <tt>ChatRoomMember</tt> that has sent this message.
+     * @param timestamp the exact date when the event ocurred.
+     * @param message the received <tt>Message</tt>.
+     * @param eventType the type of message event that this instance represents
+     * (one of the XXX_MESSAGE_RECEIVED static fields).
+     */
+    public ChatRoomMessageReceivedEvent(ChatRoom        source,
+                                        ChatRoomMember  from,
+                                        Date            timestamp,
+                                        Message         message,
+                                        int             eventType)
+    {
         super(source);
 
         this.from = from;
         this.timestamp = timestamp;
         this.message = message;
+        this.eventType = eventType;
     }
 
     /**
@@ -93,4 +144,16 @@
     {
         return (ChatRoom) getSource();
     }
+
+    /**
+     * Returns the type of message event represented by this event instance.
+     * Message event types are generally one of the values of the
+     * XXX_MESSAGE_RECEIVED fields of this class.
+     * @return one of the values of the XXX_MESSAGE_RECEIVED fields of this
+     * class indicating the type of message received event received.
+     */
+    public int getEventType()
+    {
+        return eventType;
+    }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list