/soc/2012/michael/android: 6668b6b9537d: wrapped received messag...

Michael Zangl michael at soc.pidgin.im
Wed Aug 15 06:14:15 EDT 2012


Changeset: 6668b6b9537dc888db0a1a0c9444497e80c6e223
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-08-11 12:01 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/6668b6b9537d

Description:

wrapped received messages in an object to simplify handling.

diffstat:

 android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java |   6 ++--
 android/workspace/im.pidgin.libpurple/native/build.ant                                                                 |  12 ++++++++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationListener.java                   |   2 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationManager.java                    |   5 +++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleConversation.java                     |   2 +-
 5 files changed, 19 insertions(+), 8 deletions(-)

diffs (107 lines):

diff --git a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java
--- a/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java
+++ b/android/workspace/im.pidgin.libpurple.testclient/src/im/pidgin/libpurple/testclient/conversation/ConversationView.java
@@ -3,6 +3,7 @@ package im.pidgin.libpurple.testclient.c
 import im.pidgin.libpurple.buddy.PurpleBuddy;
 import im.pidgin.libpurple.conversation.ConversationListener;
 import im.pidgin.libpurple.conversation.PurpleConversation;
+import im.pidgin.libpurple.conversation.PurpleMessage;
 import im.pidgin.libpurple.testclient.R;
 import im.pidgin.libpurple.testclient.core.TestClientView;
 import im.pidgin.libpurple.testclient.core.ViewController;
@@ -65,12 +66,11 @@ public class ConversationView implements
 	}
 
 	@Override
-	public void messageReceived(PurpleConversation purpleConversation,
-			final String message) {
+	public void messageReceived(PurpleConversation conv, final PurpleMessage message) {
 		viewController.runOnUiThread(new Runnable() {
 			@Override
 			public void run() {
-				messages.append("\n" + message);
+				messages.append("\n" + message.getWho() + ": " + message.getMessage());
 			}
 		});
 	}
diff --git a/android/workspace/im.pidgin.libpurple/native/build.ant b/android/workspace/im.pidgin.libpurple/native/build.ant
--- a/android/workspace/im.pidgin.libpurple/native/build.ant
+++ b/android/workspace/im.pidgin.libpurple/native/build.ant
@@ -86,7 +86,7 @@
 		<extractconstants input="${pidgin.base}/libpurple/dnssrv.h" output="${libpurple.constants.outdir}/DnsSrvConstants.java" package="${libpurple.constants.package}">
 			<enum name="PurpleDnsType" />
 		</extractconstants>
-		
+
 		<extractconstants input="${pidgin.base}/libpurple/plugin.h" output="${libpurple.constants.outdir}/PluginConstants.java" package="${libpurple.constants.package}">
 			<enum name="PurplePluginType" />
 		</extractconstants>
@@ -100,12 +100,20 @@
 		<extractconstants input="${pidgin.base}/libpurple/blist.h" output="${libpurple.constants.outdir}/BlistConstants.java" package="${libpurple.constants.package}">
 			<enum name="PurpleBlistNodeType" />
 		</extractconstants>
-		
+
 		<extractconstants input="${pidgin.base}/libpurple/request.h" output="${libpurple.constants.outdir}/RequestConstants.java" package="${libpurple.constants.package}">
 			<enum name="PurpleRequestType" />
 			<enum name="PurpleRequestFieldType" />
 		</extractconstants>
 
+		<extractconstants input="${pidgin.base}/libpurple/conversation.h" output="${libpurple.constants.outdir}/ConversationConstants.java" package="${libpurple.constants.package}">
+			<enum name="PurpleConversationType" />
+			<enum name="PurpleMessageFlags" />
+			<enum name="PurpleConvChatBuddyFlags" />
+			<enum name="PurpleTypingState" />
+			<enum name="PurpleConvUpdateType" />
+		</extractconstants>
+
 	</target>
 
 </project>
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationListener.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationListener.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationListener.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationListener.java
@@ -2,7 +2,7 @@ package im.pidgin.libpurple.conversation
 
 public interface ConversationListener {
 
-	void messageReceived(PurpleConversation purpleConversation, String message);
+	void messageReceived(PurpleConversation purpleConversation, PurpleMessage message);
 
 	void updateTypingState(PurpleConversation purpleConversation);
 }
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationManager.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationManager.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationManager.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/ConversationManager.java
@@ -6,6 +6,7 @@ import im.pidgin.libpurple.core.Abstract
 import im.pidgin.libpurple.core.CoreManager;
 import im.pidgin.libpurple.peering.PeerGenerator;
 
+import java.util.Date;
 import java.util.Hashtable;
 
 public class ConversationManager extends AbstractPurpleManaged implements
@@ -45,8 +46,10 @@ public class ConversationManager extends
 	}
 	
 	protected void writeIm(long conv, String who, String message, int flags, long mtime) { 
+		
+		Date time = new Date(mtime);
 		PurpleConversation conversation = getPeer(conv);
-		conversation.notifyMessageReceived(message);
+		conversation.notifyMessageReceived(new PurpleMessage(who, message, flags, time));
 	}
 
 	protected void updateBuddyTyping(long accountPointer, String who) {
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleConversation.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleConversation.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleConversation.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/conversation/PurpleConversation.java
@@ -35,7 +35,7 @@ public class PurpleConversation extends 
 		}
 	}
 
-	protected void notifyMessageReceived(String message) {
+	protected void notifyMessageReceived(PurpleMessage message) {
 		synchronized (conversationListenerMutex) {
 			for (ConversationListener l : conversationListeners) {
 				l.messageReceived(this, message);



More information about the Commits mailing list