/soc/2012/michael/android: db3467be4b67: Changed CALLBACK_START ...

Michael Zangl michael at soc.pidgin.im
Sat Jul 7 14:01:37 EDT 2012


Changeset: db3467be4b6761172e6bf0d279d204aa920f4d18
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-07 20:01 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/db3467be4b67

Description:

Changed CALLBACK_START makro to take a context pointer instead of a context object.

diffstat:

 android/workspace/im.pidgin.libpurple/native/ConversationManager.c  |   8 +-
 android/workspace/im.pidgin.libpurple/native/CoreManager.c          |   2 +-
 android/workspace/im.pidgin.libpurple/native/EventLoop.c            |   4 +-
 android/workspace/im.pidgin.libpurple/native/PurpleAccountManager.c |  16 ++--
 android/workspace/im.pidgin.libpurple/native/PurpleBlistManager.c   |  31 +++++----
 android/workspace/im.pidgin.libpurple/native/helpers.h              |   2 +-
 6 files changed, 33 insertions(+), 30 deletions(-)

diffs (233 lines):

diff --git a/android/workspace/im.pidgin.libpurple/native/ConversationManager.c b/android/workspace/im.pidgin.libpurple/native/ConversationManager.c
--- a/android/workspace/im.pidgin.libpurple/native/ConversationManager.c
+++ b/android/workspace/im.pidgin.libpurple/native/ConversationManager.c
@@ -48,7 +48,7 @@
 		jmethodID mid;
 		jlong conv_ptr;
 
-		CALLBACK_START_VOID(conversationManager);
+		CALLBACK_START_VOID(&conversationManager);
 
 		conv_ptr = pToLong(conv);
 
@@ -64,7 +64,7 @@
 		jmethodID mid;
 		jlong conv_ptr;
 
-		CALLBACK_START_VOID(conversationManager);
+		CALLBACK_START_VOID(&conversationManager);
 
 		conv_ptr = pToLong(conv);
 
@@ -82,7 +82,7 @@
 		jstring who_obj;
 		jstring message_obj;
 
-		CALLBACK_START_VOID(conversationManager);
+		CALLBACK_START_VOID(&conversationManager);
 
 		conv_ptr = pToLong(conv);
 		who_obj = (*env)->NewStringUTF(env, who);
@@ -106,7 +106,7 @@
 	jlong account_ptr;
 	jstring who_obj;
 
-	CALLBACK_START_VOID(conversationManager);
+	CALLBACK_START_VOID(&conversationManager);
 
 	account_ptr = pToLong(account);
 	who_obj = (*env)->NewStringUTF(env, who);
diff --git a/android/workspace/im.pidgin.libpurple/native/CoreManager.c b/android/workspace/im.pidgin.libpurple/native/CoreManager.c
--- a/android/workspace/im.pidgin.libpurple/native/CoreManager.c
+++ b/android/workspace/im.pidgin.libpurple/native/CoreManager.c
@@ -34,7 +34,7 @@
 
 	jmethodID mid;
 
-	CALLBACK_START_VOID(coreManagerInstance);
+	CALLBACK_START_VOID(&coreManagerInstance);
 
 	mid = getMethodIDCachedReferenced(env, coreManagerInstance.class,
 			&methodCache);
diff --git a/android/workspace/im.pidgin.libpurple/native/EventLoop.c b/android/workspace/im.pidgin.libpurple/native/EventLoop.c
--- a/android/workspace/im.pidgin.libpurple/native/EventLoop.c
+++ b/android/workspace/im.pidgin.libpurple/native/EventLoop.c
@@ -61,7 +61,7 @@
 	jlong data_ptr;
 	jint result = 0;
 
-	CALLBACK_START(eventloop, 0);
+	CALLBACK_START(&eventloop, 0);
 
 	function_ptr = pToLong(function);
 	data_ptr = pToLong(data);
@@ -83,7 +83,7 @@
 	jmethodID mid;
 	jboolean result = FALSE;
 
-	CALLBACK_START(eventloop, FALSE);
+	CALLBACK_START(&eventloop, FALSE);
 
 	mid = getMethodIDCachedReferenced(env, eventloop.class, &methodCache);
 	if (mid != NULL) {
diff --git a/android/workspace/im.pidgin.libpurple/native/PurpleAccountManager.c b/android/workspace/im.pidgin.libpurple/native/PurpleAccountManager.c
--- a/android/workspace/im.pidgin.libpurple/native/PurpleAccountManager.c
+++ b/android/workspace/im.pidgin.libpurple/native/PurpleAccountManager.c
@@ -112,7 +112,7 @@
 	jstring alias_obj;
 	jstring message_obj;
 
-	CALLBACK_START_VOID(accountList);
+	CALLBACK_START_VOID(&accountList);
 
 	account_ptr = pToLong(account);
 	remote_user_obj = (*env)->NewStringUTF(env, remote_user);
@@ -138,7 +138,7 @@
 	jlong account_ptr;
 	jlong status_ptr;
 
-	CALLBACK_START_VOID(accountList);
+	CALLBACK_START_VOID(&accountList);
 
 	account_ptr = pToLong(account);
 	status_ptr = pToLong(status);
@@ -164,7 +164,7 @@
 	jstring alias_obj;
 	jstring message_obj;
 
-	CALLBACK_START_VOID(accountList);
+	CALLBACK_START_VOID(&accountList);
 
 	account_ptr = pToLong(account);
 	remote_user_obj = (*env)->NewStringUTF(env, remote_user);
@@ -200,7 +200,7 @@
 	jlong user_data_ptr;
 	jlong result = 0;
 
-	CALLBACK_START(accountList, NULL);
+	CALLBACK_START(&accountList, NULL);
 
 	account_ptr = pToLong(account);
 	remote_user_obj = (*env)->NewStringUTF(env, remote_user);
@@ -231,7 +231,7 @@
 	jmethodID mid;
 	jlong ui_handle_ptr;
 
-	CALLBACK_START_VOID(accountList);
+	CALLBACK_START_VOID(&accountList);
 
 	ui_handle_ptr = pToLong(ui_handle);
 
@@ -249,7 +249,7 @@
 
 	jmethodID mid;
 
-	CALLBACK_START_VOID(accountList);
+	CALLBACK_START_VOID(&accountList);
 
 	mid = getMethodIDCachedReferenced(env, accountList.class, &methodCache);
 	if (mid != NULL) {
@@ -266,7 +266,7 @@
 
 	jmethodID mid;
 
-	CALLBACK_START_VOID(accountList);
+	CALLBACK_START_VOID(&accountList);
 
 	mid = getMethodIDCachedReferenced(env, accountList.class, &methodCache);
 	if (mid != NULL) {
@@ -282,7 +282,7 @@
 
 	jmethodID mid;
 
-	CALLBACK_START_VOID(accountList);
+	CALLBACK_START_VOID(&accountList);
 
 	mid = getMethodIDCachedReferenced(env, accountList.class, &methodCache);
 	if (mid != NULL) {
diff --git a/android/workspace/im.pidgin.libpurple/native/PurpleBlistManager.c b/android/workspace/im.pidgin.libpurple/native/PurpleBlistManager.c
--- a/android/workspace/im.pidgin.libpurple/native/PurpleBlistManager.c
+++ b/android/workspace/im.pidgin.libpurple/native/PurpleBlistManager.c
@@ -2,6 +2,13 @@
 #include "helpers.h"
 #include <libpurple/blist.h>
 
+static void*
+blist_get_handle()
+{
+	static int handle;
+	return &handle;
+}
+
 static void
 buddy_status_changed(PurpleBuddy* buddy, PurpleStatus* old, PurpleStatus* now,
 		JavaObjectReference *blist)
@@ -20,9 +27,9 @@
 	old_ptr = pToLong(old);
 	now_ptr = pToLong(now);
 
-	mid = getMethodIDCachedReferenced(env, blist.class, &methodCache);
+	mid = getMethodIDCachedReferenced(env, blist->class, &methodCache);
 	if (mid != NULL) {
-		(*env)->CallVoidMethod(env, blist.handlerObject, mid, buddy_ptr,
+		(*env)->CallVoidMethod(env, blist->handlerObject, mid, buddy_ptr,
 				old_ptr, now_ptr);
 	}
 }
@@ -41,9 +48,9 @@
 
 	buddy_ptr = pToLong(buddy);
 
-	mid = getMethodIDCachedReferenced(env, blist.class, &methodCache);
+	mid = getMethodIDCachedReferenced(env, blist->class, &methodCache);
 	if (mid != NULL) {
-		(*env)->CallVoidMethod(env, blist.handlerObject, mid, buddy_ptr,
+		(*env)->CallVoidMethod(env, blist->handlerObject, mid, buddy_ptr,
 				(jint) old, (jint) new);
 	}
 }
@@ -61,9 +68,9 @@
 
 	buddy_ptr = pToLong(buddy);
 
-	mid = getMethodIDCachedReferenced(env, blist.class, &methodCache);
+	mid = getMethodIDCachedReferenced(env, blist->class, &methodCache);
 	if (mid != NULL) {
-		(*env)->CallVoidMethod(env, blist.handlerObject, mid, buddy_ptr);
+		(*env)->CallVoidMethod(env, blist->handlerObject, mid, buddy_ptr);
 	}
 }
 /*
@@ -90,16 +97,12 @@
 	setJavaObject(blist, env, obj);
 
 	purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed",
-			finch_blist_get_handle(), PURPLE_CALLBACK(buddy_status_changed),
-			blist);
+			blist_get_handle(), PURPLE_CALLBACK(buddy_status_changed), blist);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-idle-changed",
-			finch_blist_get_handle(), PURPLE_CALLBACK(buddy_idle_changed),
-			blist);
+			blist_get_handle(), PURPLE_CALLBACK(buddy_idle_changed), blist);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on",
-			finch_blist_get_handle(), PURPLE_CALLBACK(buddy_signed_on_off),
-			blist);
+			blist_get_handle(), PURPLE_CALLBACK(buddy_signed_on_off), blist);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off",
-			finch_blist_get_handle(), PURPLE_CALLBACK(buddy_signed_on_off),
-			blist);
+			blist_get_handle(), PURPLE_CALLBACK(buddy_signed_on_off), blist);
 
 }
diff --git a/android/workspace/im.pidgin.libpurple/native/helpers.h b/android/workspace/im.pidgin.libpurple/native/helpers.h
--- a/android/workspace/im.pidgin.libpurple/native/helpers.h
+++ b/android/workspace/im.pidgin.libpurple/native/helpers.h
@@ -58,7 +58,7 @@
  */
 #define CALLBACK_START(context, failval) \
 		JNIEnv *env; \
-		if (context.jvm == NULL || context.handlerObject == NULL || (*context.jvm)->GetEnv(context.jvm, (void**)&env, JNI_VERSION_1_2) == JNI_EDETACHED) {\
+		if ((context)->jvm == NULL || (context)->handlerObject == NULL || (*(context)->jvm)->GetEnv((context)->jvm, (void**)&env, JNI_VERSION_1_2) == JNI_EDETACHED) {\
 			__android_log_print(ANDROID_LOG_DEBUG, "jni",\
 					"Error: No callback object registered or in wrong thread");\
 			return failval;\



More information about the Commits mailing list