--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationListener.java Mon Aug 20 15:17:18 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationListener.java Mon Aug 20 15:33:50 2012 +0200
@@ -1,8 +1,28 @@
package im.pidgin.libpurple.conversation;
+ * This interface allows you to listen to conversations public interface ConversationListener {
- void messageReceived(PurpleConversation purpleConversation, PurpleMessage message);
+ * Called when a message was received on a conversation. + * @param purpleConversation + * The conversation with that message. + * The message that was received. + void messageReceived(PurpleConversation purpleConversation, + PurpleMessage message); + * Called when the typing state of the buddy we are talking with changed. + * @param purpleConversation + * The conversation in which the buddy changed the typing state. void updateTypingState(PurpleConversation purpleConversation);
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationManager.java Mon Aug 20 15:17:18 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationManager.java Mon Aug 20 15:33:50 2012 +0200
@@ -9,10 +9,22 @@
import java.util.Hashtable;
+ * This is the main conversation manager. It handles conversation object + * creation and destruction and event handling. This class is not accessible in public class ConversationManager extends AbstractPurpleManaged implements
- PeerGenerator<PurpleConversation> {
+ PeerGenerator<PurpleConversation> { - private final Hashtable<Long, PurpleConversation> conversations = new Hashtable<Long, PurpleConversation>();
+ * A hashtable of conversations that we know of. TODO: We can use ui_data + private final Hashtable<Long, PurpleConversation> conversations = + new Hashtable<Long, PurpleConversation>(); public ConversationManager(CoreManager manager) {
@@ -27,34 +39,58 @@
private native void register_native();
+ * Starts a new conversation with a buddy. + * The buddy to start a conversation with. public PurpleConversation newConversation(PurpleBuddy buddy) {
- PurpleConversation conversation = PurpleConversation.newConversation(
+ PurpleConversation conversation = + PurpleConversation.newConversation(buddy, getManager()); conversations.put(conversation.getNativePointer(), conversation);
- protected void createConversation(long conv) {
- //PurpleConversation conversation = getPeer(conv);
- //conversations.put(conversation.getNativePointer(), conversation);
+ * Called on a conversation created event. + * The conversation that was created. + protected void createConversation(long conv) { + // PurpleConversation conversation = getPeer(conv); + // conversations.put(conversation.getNativePointer(), conversation); - protected void destroyConversation(long conv) {
+ * Called when a conversation was destroyed. + * The conversation that was destroyed. + protected void destroyConversation(long conv) { PurpleConversation conversation = getPeer(conv);
+ conversation.nativeObjectFreed(); conversations.remove(conversation.getNativePointer());
conversation.nativeObjectFreed();
- protected void writeIm(long conv, String who, String message, int flags, long mtime) {
+ /* signal / ui ops callbacks */ + protected void writeIm(long conv, String who, String message, int flags, Date time = new Date(mtime);
PurpleConversation conversation = getPeer(conv);
- conversation.notifyMessageReceived(new PurpleMessage(who, message, flags, time));
+ conversation.notifyMessageReceived(new PurpleMessage(who, message, protected void updateBuddyTyping(long accountPointer, String who) {
- PurpleAccount account = getManager().getAccountList().getPeer(
+ PurpleAccount account = + getManager().getAccountList().getPeer(accountPointer); PurpleConversation conversation = findImWithAccount(who, account);
if (conversation == null) {
@@ -64,7 +100,7 @@
private PurpleConversation findImWithAccount(String who,
- PurpleAccount account) {
+ PurpleAccount account) { long account_native = findImWithAccount_native(who, account);
if (account_native == 0) {
@@ -74,7 +110,7 @@
private native long findImWithAccount_native(String who,
- PurpleAccount account);
+ PurpleAccount account); public PurpleConversation getPeer(long pointer) {
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleConversation.java Mon Aug 20 15:17:18 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleConversation.java Mon Aug 20 15:33:50 2012 +0200
@@ -6,29 +6,63 @@
import java.util.LinkedList;
+ * This is a conversation with some buddy. Currently, this only represents an IM public class PurpleConversation extends PeeredPurpleManaged {
+ * Creates a new conversation. + * The buddy to conversate with. + * @return A new conversation that was just created. protected static PurpleConversation newConversation(PurpleBuddy buddy,
long nativePointer = newConversation_native(buddy);
return new PurpleConversation(nativePointer, manager);
private static native long newConversation_native(PurpleBuddy buddy);
- private final LinkedList<ConversationListener> conversationListeners = new LinkedList<ConversationListener>();
+ * This is a list of listeners that listen to this conversation. + private final LinkedList<ConversationListener> conversationListeners = + new LinkedList<ConversationListener>(); + * The mutex to synchronize the conversation listeners. private final Object conversationListenerMutex = new Object();
private PurpleConversation(long nativePointer, CoreManager manager) {
super(nativePointer, manager);
+ * Adds a listener to this conversation. public void addConversationListener(ConversationListener l) {
synchronized (conversationListenerMutex) {
conversationListeners.add(l);
+ * Removes a listener from this conversation if it was previously added. + * The listener to remove. public void removeConversationListener(ConversationListener l) {
synchronized (conversationListenerMutex) {
conversationListeners.remove(l);
@@ -51,6 +85,13 @@
+ * Enables or disables logging for this conversation. + * <code>true</code> if logging should be enabled, or + * <code>false</code> otherwise. public synchronized void setLogging(boolean logging) {
setLogging_native(logging);
@@ -58,6 +99,12 @@
private native void setLogging_native(boolean logging);
+ * Returns whether or not logging is enabled for this conversation. + * @return <code>true</code> if logging is enabled, or <code>false</code> public synchronized boolean isLogging() {
return isLogging_native();
@@ -65,6 +112,12 @@
private native boolean isLogging_native();
+ * Sends a message to the buddy in this conversation. public synchronized void send(String message) {
@@ -81,7 +134,12 @@
protected synchronized void nativeObjectFreed() {
super.nativeObjectFreed();
+ * Gets the typing state of the opponent. + * @return true if the other buddy is typing. TODO: Change this to an enum. public synchronized boolean getTypingState() {
return getTypingState_native();
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleMessage.java Mon Aug 20 15:17:18 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleMessage.java Mon Aug 20 15:33:50 2012 +0200
@@ -4,6 +4,11 @@
+ * This is a message that was sent on a conversation. public class PurpleMessage {
private final String who;
@@ -11,33 +16,66 @@
- public PurpleMessage(String who, String message, int flags, Date time) {
+ * Creates a new message object. + protected PurpleMessage(String who, String message, int flags, Date time) {
+ * Gets the user that wrote this message. + * @return The writer of the message
+ * Gets the time the message was sent. + * @return That time as {@link Date} object. + * Gets the content of the message. public String getMessage() {
+ * Checks whether the message was sent by us. + * @return <code>true</code> if and only if the message was sent by us. public boolean isSend() {
return (flags & ConversationConstants.PURPLE_MESSAGE_SEND) != 0;
+ * Checks whether the message was an incoming message + * @return <code>true</code> if and only if the message was received. public boolean isReceived() {
return (flags & ConversationConstants.PURPLE_MESSAGE_RECV) != 0;
public boolean isSystem() {
return (flags & ConversationConstants.PURPLE_MESSAGE_SYSTEM) != 0;