From ebbb046348ffe962ffc3b8576fd8be473b2b8e41 Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Thu, 23 Mar 2006 22:59:05 +0000 Subject: [PATCH] more work on implementing ordering contacts and A NEW EVENT scheme for the meta contact list service implemented support for instant messaging in icq (testing is still pending though) --- .../impl/protocol/icq/MessageIcqImpl.java | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java diff --git a/src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java new file mode 100644 index 000000000..ee6672922 --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/icq/MessageIcqImpl.java @@ -0,0 +1,147 @@ +/* + * 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.protocol.icq; + +import net.java.sip.communicator.service.protocol.*; + +/** + * A simple implementation of the Message interface. Right now the + * message only supports test contents and no binary data. + * + * @author Emil Ivov + */ +public class MessageIcqImpl + implements Message +{ + /** + * 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 + * content String. + * @param contentEncoding a MIME String indicating the content encoding of + * the content String. + * @param subject the subject of the message or null for empty. + */ + public MessageIcqImpl(String content, + String contentType, + String contentEncoding, + String subject) + { + this.textContent = content; + this.contentType = contentType; + this.contentEncoding = contentEncoding; + this.subject = subject; + + //generate the uid + this.messageUID = String.valueOf( System.currentTimeMillis()) + + String.valueOf(hashCode()); + + } + + /** + * 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() + { + return subject; + } +}