aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/icq
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/icq')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java142
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/OperationSetBasicInstantMessagingIcqImpl.java110
2 files changed, 18 insertions, 234 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java
index 993b26f..be3b69d 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java
@@ -1,8 +1,7 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.icq;
@@ -11,146 +10,27 @@ import net.java.sip.communicator.service.protocol.*;
/**
* A simple implementation of the <tt>Message</tt> interface. Right now the
* message only supports test contents and no binary data.
- *
+ *
* @author Emil Ivov
+ * @author Lubomir Marinov
*/
public class MessageIcqImpl
- implements Message
+ extends AbstractMessage
{
- /**
- * The content of this message.
- */
- private String textContent = null;
-
- /**
- * The content type of text. Right now only text content types (such as
- * text/plain or text/html) are supported.
- */
- private String contentType = null;
-
- /**
- * The encoding under which the contennt of this message is encoded.
- */
- private String contentEncoding = null;
-
- /**
- * An String uniquely identifying this Message.
- */
- private String messageUID = null;
-
- /**
- * The subject of the message if any (may remain null).
- */
- private String subject = null;
/**
* Creates an instance of this Message with the specified parameters.
- *
+ *
* @param content the text content of the message.
* @param contentType a MIME string indicating the content type of the
- * <tt>content</tt> String.
+ * <tt>content</tt> String.
* @param contentEncoding a MIME String indicating the content encoding of
- * the <tt>content</tt> String.
+ * the <tt>content</tt> String.
* @param subject the subject of the message or null for empty.
- * @param messageUID an UID in case we'd like to set our own or null for an
- * automatically generated one.
- */
- public MessageIcqImpl(String content,
- String contentType,
- String contentEncoding,
- String subject,
- String messageUID)
- {
- this.textContent = content;
- this.contentType = contentType;
- this.contentEncoding = contentEncoding;
- this.subject = subject;
-
- if(messageUID == null)
- {
- //generate the uid
- this.messageUID = String.valueOf(System.currentTimeMillis())
- + String.valueOf(hashCode());
- }
- else
- {
- this.messageUID = messageUID;
- }
- }
-
- /**
- * Returns the content of this message if representable in text form or
- * null if this message does not contain text data.
- *
- * @return a String containing the content of this message or null if
- * the message does not contain data representable in text form.
- */
- public String getContent()
- {
- return textContent;
- }
-
- /**
- * Returns the MIME type for the message content.
- *
- * @return a String containing the mime type of the message contant.
- */
- public String getContentType()
- {
- return contentType;
- }
-
- /**
- * Returns the MIME content encoding of this message.
- *
- * @return a String indicating the MIME encoding of this message.
- */
- public String getEncoding()
- {
- return contentEncoding;
- }
-
- /**
- * Returns a unique identifier of this message.
- *
- * @return a String that uniquely represents this message in the scope
- * of this protocol.
- */
- public String getMessageUID()
- {
- return messageUID;
- }
-
- /**
- * Get the raw/binary content of an instant message.
- *
- * @return a byte[] array containing message bytes.
- */
- public byte[] getRawData()
- {
- return getContent().getBytes();
- }
-
- /**
- * Returns the size of the content stored in this message.
- *
- * @return an int indicating the number of bytes that this message
- * contains.
- */
- public int getSize()
- {
- return getContent().length();
- }
-
- /**
- * Returns the subject of this message or null if the message contains no
- * subject.
- *
- * @return the subject of this message or null if the message contains
- * no subject.
*/
- public String getSubject()
+ public MessageIcqImpl(String content, String contentType,
+ String contentEncoding, String subject)
{
- return subject;
+ super(content, contentType, contentEncoding, subject);
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetBasicInstantMessagingIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetBasicInstantMessagingIcqImpl.java
index bbd7a79..6f8e003 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetBasicInstantMessagingIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetBasicInstantMessagingIcqImpl.java
@@ -29,15 +29,10 @@ import net.java.sip.communicator.service.protocol.icqconstants.*;
* @author Damian Minkov
*/
public class OperationSetBasicInstantMessagingIcqImpl
- implements OperationSetBasicInstantMessaging
+ extends AbstractOperationSetBasicInstantMessaging
{
private static final Logger logger =
Logger.getLogger(OperationSetBasicInstantMessagingIcqImpl.class);
-
- /**
- * A list of listeneres registered for message events.
- */
- private Vector messageListeners = new Vector();
/**
* The icq provider that created us.
@@ -131,67 +126,10 @@ public class OperationSetBasicInstantMessagingIcqImpl
icqProvider.addRegistrationStateChangeListener(providerRegListener);
}
- /**
- * Registeres a MessageListener with this operation set so that it gets
- * notifications of successful message delivery, failure or reception of
- * incoming messages..
- *
- * @param listener the <tt>MessageListener</tt> to register.
- */
- public void addMessageListener(MessageListener listener)
- {
- synchronized(messageListeners)
- {
- if(!messageListeners.contains(listener))
- this.messageListeners.add(listener);
- }
- }
-
- /**
- * Unregisteres <tt>listener</tt> so that it won't receive any further
- * notifications upon successful message delivery, failure or reception of
- * incoming messages..
- *
- * @param listener the <tt>MessageListener</tt> to unregister.
- */
- public void removeMessageListener(MessageListener listener)
- {
- synchronized(messageListeners)
- {
- this.messageListeners.remove(listener);
- }
- }
-
- /**
- * Create a Message instance for sending arbitrary MIME-encoding content.
- *
- * @param content content value
- * @param contentType the MIME-type for <tt>content</tt>
- * @param contentEncoding encoding used for <tt>content</tt>
- * @param subject a <tt>String</tt> subject or <tt>null</tt> for now subject.
- * @return the newly created message.
- */
- public Message createMessage(byte[] content, String contentType,
- String contentEncoding, String subject)
- {
- return new MessageIcqImpl( new String(content),
- contentType,
- contentEncoding,
- subject,
- null);
- }
-
- /**
- * Create a Message instance for sending a simple text messages with
- * default (text/plain) content type and encoding.
- *
- * @param messageText the string content of the message.
- * @return Message the newly created message
- */
- public Message createMessage(String messageText)
+ public Message createMessage(String content, String contentType,
+ String encoding, String subject)
{
- return new MessageIcqImpl(messageText, DEFAULT_MIME_TYPE
- , DEFAULT_MIME_ENCODING, null, null);
+ return new MessageIcqImpl(content, contentType, encoding, subject);
}
/**
@@ -467,41 +405,6 @@ public class OperationSetBasicInstantMessagingIcqImpl
}
}
-
-
- /**
- * Delivers the specified event to all registered message listeners.
- * @param evt the <tt>EventObject</tt> that we'd like delivered to all
- * registered message listerners.
- */
- private void fireMessageEvent(EventObject evt)
- {
- Iterator listeners = null;
- synchronized (messageListeners)
- {
- listeners = new ArrayList(messageListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- MessageListener listener
- = (MessageListener) listeners.next();
-
- if (evt instanceof MessageDeliveredEvent)
- {
- listener.messageDelivered( (MessageDeliveredEvent) evt);
- }
- else if (evt instanceof MessageReceivedEvent)
- {
- listener.messageReceived( (MessageReceivedEvent) evt);
- }
- else if (evt instanceof MessageDeliveryFailedEvent)
- {
- listener.messageDeliveryFailed(
- (MessageDeliveryFailedEvent) evt);
- }
- }
- }
/**
* The listener that would retrieve instant messaging events from oscar.jar.
*/
@@ -588,8 +491,9 @@ public class OperationSetBasicInstantMessagingIcqImpl
else
msgContent = msgBody;
- Message newMessage = createMessage(msgContent.getBytes(),
- HTML_MIME_TYPE, DEFAULT_MIME_ENCODING, null);
+ Message newMessage =
+ createMessage(msgContent, HTML_MIME_TYPE,
+ DEFAULT_MIME_ENCODING, null);
Contact sourceContact =
opSetPersPresence.findContactByID( conversation.getBuddy()