/soc/2012/michael/android: 4a1e90ac063e: Implemented native meth...
Michael Zangl
michael at soc.pidgin.im
Sat Jul 7 03:34:26 EDT 2012
Changeset: 4a1e90ac063e6d64e4707f8c6969a334010cffd4
Author: Michael Zangl <michael at soc.pidgin.im>
Date: 2012-07-01 22:23 +0200
Branch: soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/4a1e90ac063e
Description:
Implemented native methods needed for Blist nodes.
diffstat:
android/workspace/im.pidgin.libpurple/native/CoreManager.c | 24 +++-
android/workspace/im.pidgin.libpurple/native/PurpleBlistGroup.c | 21 +++
android/workspace/im.pidgin.libpurple/native/PurpleBlistNode.c | 60 ++++++++++
android/workspace/im.pidgin.libpurple/native/build.ant | 1 +
android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/blist/PurpleBlistNode.java | 12 +-
5 files changed, 110 insertions(+), 8 deletions(-)
diffs (181 lines):
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
@@ -24,6 +24,14 @@
JavaObjectReference coreManagerInstance;
+/* protocol init functions */
+extern gboolean purple_init_jabber_plugin(void);
+extern gboolean purple_init_msn_plugin(void);
+extern gboolean purple_init_aim_plugin(void);
+extern gboolean purple_init_icq_plugin(void);
+extern gboolean purple_init_yahoo_plugin(void);
+
+
/**
* Called on a ui init event from the core.
*/
@@ -54,9 +62,17 @@
jboolean success;
const char* uiNameNative;
- __android_log_print(ANDROID_LOG_WARN, "jni", "starting");
setJavaObject(&coreManagerInstance, env, obj);
+ /* plugins init */
+ __android_log_print(ANDROID_LOG_WARN, "jni", "loading plugins");
+ purple_init_jabber_plugin();
+ purple_init_msn_plugin();
+ purple_init_aim_plugin();
+ purple_init_icq_plugin();
+ purple_init_yahoo_plugin();
+
+ __android_log_print(ANDROID_LOG_WARN, "jni", "starting core");
purple_core_set_ui_ops(&coreUiOps);
purple_eventloop_set_ui_ops(getEventloopUiOps());
@@ -67,9 +83,13 @@
(*env)->ReleaseStringUTFChars(env, uiName, uiNameNative);
if (success) {
+ __android_log_print(ANDROID_LOG_INFO, "jni", "loading blist");
purple_set_blist(purple_blist_new());
purple_blist_load();
- purple_plugins_load_saved("/plugins/loaded");
+ //purple_plugins_load_saved("/plugins/loaded");
+ purple_plugin_load(purple_plugins_find_with_id("aim"));
+ purple_plugin_load(purple_plugins_find_with_id("msn"));
+ purple_plugin_load(purple_plugins_find_with_id("icq"));
purple_pounces_load();
}
diff --git a/android/workspace/im.pidgin.libpurple/native/PurpleBlistGroup.c b/android/workspace/im.pidgin.libpurple/native/PurpleBlistGroup.c
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple/native/PurpleBlistGroup.c
@@ -0,0 +1,21 @@
+#include "PurpleBlistGroup.h"
+#include "helpers.h"
+#include <libpurple/blist.h>
+
+static PurpleBlistNode *
+getNativeGroup(JNIEnv *env, jobject obj)
+{
+ return (PurpleBlistNode*) getNativePointer(env, obj);
+}
+
+/*
+ * Class: im_pidgin_libpurple_blist_PurpleBlistGroup
+ * Method: getName_native
+ * Signature: ()Ljava/lang/String;
+ */JNIEXPORT jstring JNICALL
+Java_im_pidgin_libpurple_blist_PurpleBlistGroup_getName_1native(JNIEnv *env,
+ jobject obj)
+{
+ const char* name = purple_group_get_name(getNativeGroup(env, obj));
+ return (*env)->NewStringUTF(env, name);
+}
diff --git a/android/workspace/im.pidgin.libpurple/native/PurpleBlistNode.c b/android/workspace/im.pidgin.libpurple/native/PurpleBlistNode.c
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple/native/PurpleBlistNode.c
@@ -0,0 +1,60 @@
+#include "PurpleBlistNode.h"
+#include "helpers.h"
+#include <libpurple/blist.h>
+
+static PurpleBlistNode *
+getNativeNode(JNIEnv *env, jobject obj)
+{
+ return (PurpleBlistNode*) getNativePointer(env, obj);
+}
+
+/*
+ * Class: im_pidgin_libpurple_blist_PurpleBlistNode
+ * Method: getTypeFor_native
+ * Signature: (J)I
+ */JNIEXPORT jint JNICALL
+Java_im_pidgin_libpurple_blist_PurpleBlistNode_getTypeFor_1native(JNIEnv *env,
+ jclass class, jlong node)
+{
+ return purple_blist_node_get_type((PurpleBlistNode*) longToP(node));
+}
+/*
+ * Class: im_pidgin_libpurple_blist_PurpleBlistNode
+ * Method: getNext_native
+ * Signature: ()J
+ */JNIEXPORT jlong JNICALL
+Java_im_pidgin_libpurple_blist_PurpleBlistNode_getNextSibling_1native(
+ JNIEnv *env, jobject obj)
+{
+ return purple_blist_node_get_sibling_next(getNativeNode(env, obj));
+}
+/*
+ * Class: im_pidgin_libpurple_blist_PurpleBlistNode
+ * Method: getPrevious_native
+ * Signature: ()J
+ */JNIEXPORT jlong JNICALL
+Java_im_pidgin_libpurple_blist_PurpleBlistNode_getPreviousSibling_1native(
+ JNIEnv *env, jobject obj)
+{
+ return purple_blist_node_get_sibling_prev(getNativeNode(env, obj));
+}
+/*
+ * Class: im_pidgin_libpurple_blist_PurpleBlistNode
+ * Method: getParent_native
+ * Signature: ()J
+ */JNIEXPORT jlong JNICALL
+Java_im_pidgin_libpurple_blist_PurpleBlistNode_getParent_1native(JNIEnv *env,
+ jobject obj)
+{
+ return purple_blist_node_get_parent(getNativeNode(env, obj));
+}
+/*
+ * Class: im_pidgin_libpurple_blist_PurpleBlistNode
+ * Method: getFirstChild_native
+ * Signature: ()J
+ */JNIEXPORT jlong JNICALL
+Java_im_pidgin_libpurple_blist_PurpleBlistNode_getFirstChild_1native(
+ JNIEnv *env, jobject obj)
+{
+ return purple_blist_node_get_first_child(getNativeNode(env, obj));
+}
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
@@ -37,6 +37,7 @@
<javah classdefinition="im.pidgin.libpurple.account.PurpleStatus" to="${javah.out}" />
<javah classdefinition="im.pidgin.libpurple.blist.PurpleBlist" to="${javah.out}" />
+ <javah classdefinition="im.pidgin.libpurple.blist.PurpleBlistGroup" to="${javah.out}" />
<javah classdefinition="im.pidgin.libpurple.blist.PurpleBlistNode" to="${javah.out}" />
<javah classdefinition="im.pidgin.libpurple.blist.PurpleContact" to="${javah.out}" />
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/blist/PurpleBlistNode.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/blist/PurpleBlistNode.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/blist/PurpleBlistNode.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/blist/PurpleBlistNode.java
@@ -40,17 +40,17 @@
return constructNode(nativePointer, getManager());
}
- public PurpleBlistNode getNext() {
- return getNode(getNext_native());
+ public PurpleBlistNode getNextSibling() {
+ return getNode(getSiblingNext_native());
}
- private native long getNext_native();
+ private native long getSiblingNext_native();
- public PurpleBlistNode getPrevious() {
- return getNode(getPrevious_native());
+ public PurpleBlistNode getSiblingPrevious() {
+ return getNode(getSiblingPrevious_native());
}
- private native long getPrevious_native();
+ private native long getSiblingPrevious_native();
public PurpleBlistNode getParent() {
return getNode(getParent_native());
More information about the Commits
mailing list