/soc/2012/michael/android: 0b9b9d638ef2: Added basic plugin gett...

Michael Zangl michael at soc.pidgin.im
Sat Jul 7 03:34:14 EDT 2012


Changeset: 0b9b9d638ef2bcec8829332c74268d02bd30c682
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-06-23 16:24 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/0b9b9d638ef2

Description:

Added basic plugin getters and the plugin manager class.

diffstat:

 android/workspace/im.pidgin.libpurple/native/PurpleAccount.c                                   |  171 ++++++++++
 android/workspace/im.pidgin.libpurple/native/PurplePlugin.c                                    |   90 +++++
 android/workspace/im.pidgin.libpurple/native/PurplePluginManager.c                             |   44 ++
 android/workspace/im.pidgin.libpurple/native/build.ant                                         |    1 +
 android/workspace/im.pidgin.libpurple/native/generateheaders.ant                               |    3 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccount.java       |   35 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java            |    7 +
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/plugin/PurplePlugin.java         |   79 ++++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/plugin/PurplePluginManager.java  |   83 ++++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/plugin/PurpleProtocolPlugin.java |    6 +
 10 files changed, 500 insertions(+), 19 deletions(-)

diffs (truncated from 640 to 300 lines):

diff --git a/android/workspace/im.pidgin.libpurple/native/PurpleAccount.c b/android/workspace/im.pidgin.libpurple/native/PurpleAccount.c
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple/native/PurpleAccount.c
@@ -0,0 +1,171 @@
+#include "PurpleAccount.h"
+#include "helpers.h"
+#include <libpurple/account.h>
+
+static PurpleAccount *
+getNativeAccount(JNIEnv *env, jobject obj)
+{
+	return (PurpleAccount *) getNativePointer(env, obj);
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    getProtocol_native
+ * Signature: ()J
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_account_PurpleAccount_getProtocol_1native
+  (JNIEnv *env,
+			jobject obj) {
+	 return (*env)->NewStringUTF(env, purple_account_get_protocol_id(getNativeAccount(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    getUsername_native
+ * Signature: ()Ljava/lang/String;
+ */JNIEXPORT jstring JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_getUsername_1native(JNIEnv *env,
+		jobject obj)
+ {
+	 return (*env)->NewStringUTF(env, purple_account_get_username(getNativeAccount(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setUsername_native
+ * Signature: (Ljava/lang/String;)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setUsername_1native(JNIEnv *env,
+		jobject obj, jstring username) {
+	 const char* username_native;
+	username_native = (*env)->GetStringUTFChars(env, username, NULL);
+	g_return_if_fail(username_native != NULL);
+	purple_account_set_alias(getNativeAccount(env, obj), username_native);
+	(*env)->ReleaseStringUTFChars(env, username, username_native);
+ }
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    getAlias_native
+ * Signature: ()Ljava/lang/String;
+ */JNIEXPORT jstring JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_getAlias_1native(JNIEnv *env,
+		jobject obj) {
+	 return (*env)->NewStringUTF(env, purple_account_get_alias(getNativeAccount(env, obj)));
+ }
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setAlias_native
+ * Signature: (Ljava/lang/String;)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setAlias_1native(JNIEnv *env,
+		jobject obj, jstring alias) {
+	 const char* alias_native;
+	alias_native = (*env)->GetStringUTFChars(env, alias, NULL);
+	g_return_if_fail(alias_native != NULL);
+	purple_account_set_alias(getNativeAccount(env, obj), alias_native);
+	(*env)->ReleaseStringUTFChars(env, alias, alias_native);
+ }
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    getPassword_native
+ * Signature: ()Ljava/lang/String;
+ */JNIEXPORT jstring JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_getPassword_1native(JNIEnv *env,
+		jobject obj) {
+	return (*env)->NewStringUTF(env, purple_account_get_password(getNativeAccount(env, obj)));
+ }
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setPassword_native
+ * Signature: (Ljava/lang/String;)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setPassword_1native(JNIEnv *env,
+		jobject obj, jstring password)
+{
+	const char* password_native;
+	if (password != NULL) {
+		password_native = (*env)->GetStringUTFChars(env, password, NULL);
+		g_return_if_fail(password != NULL);
+	} else {
+		password_native = NULL;
+	}
+
+	purple_account_set_password(getNativeAccount(env, obj), password_native);
+
+	if (password_native != NULL) {
+		(*env)->ReleaseStringUTFChars(env, password, password_native);
+	}
+}
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    getRememberPassword_native
+ * Signature: ()Z
+ */JNIEXPORT jboolean JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_getRememberPassword_1native(
+		JNIEnv *env, jobject obj)
+{
+	return purple_account_get_remember_password(getNativeAccount(env, obj)) ?
+			JNI_TRUE : JNI_FALSE;
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setRememberPassword_native
+ * Signature: (Z)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setRememberPassword_1native(
+		JNIEnv *env, jobject obj, jboolean remember)
+{
+	purple_account_set_remember_password(getNativeAccount(env, obj), remember);
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    isEnabled_native
+ * Signature: ()Z
+ */JNIEXPORT jboolean JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_isEnabled_1native(JNIEnv *env,
+		jobject obj)
+{
+	return purple_account_get_enabled(getNativeAccount(env, obj), ANDROID_UI) ?
+			JNI_TRUE : JNI_FALSE;
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setEnabled_native
+ * Signature: (Z)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setEnabled_1native(JNIEnv *env,
+		jobject obj, jboolean enabled)
+{
+	purple_account_set_enabled(getNativeAccount(env, obj), ANDROID_UI, enabled);
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    newAccount_native
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */JNIEXPORT jlong JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_newAccount_1native(JNIEnv *env,
+		jclass cls, jstring username, jstring protocolId)
+{
+	const char* username_native;
+	const char* protocolId_native;
+	PurpleAccount *account = NULL;
+
+	username_native = (*env)->GetStringUTFChars(env, username, NULL);
+	protocolId_native = (*env)->GetStringUTFChars(env, protocolId, NULL);
+
+	if (username_native != NULL && protocolId_native != NULL) {
+		account = purple_account_new(username_native, protocolId_native);
+	}
+
+	(*env)->ReleaseStringUTFChars(env, username, username_native);
+	(*env)->ReleaseStringUTFChars(env, protocolId, protocolId_native);
+	return pToLong(account);
+
+}
diff --git a/android/workspace/im.pidgin.libpurple/native/PurplePlugin.c b/android/workspace/im.pidgin.libpurple/native/PurplePlugin.c
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple/native/PurplePlugin.c
@@ -0,0 +1,90 @@
+#include "PurplePlugin.h"
+#include "helpers.h"
+#include <glib.h>
+#include <libpurple/plugin.h>
+
+static PurplePlugin *
+getNativePlugin(JNIEnv *env, jobject obj)
+{
+	return (PurplePlugin *) getNativePointer(env, obj);
+}
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getType_native
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getType_1native
+  (JNIEnv *env, jclass class, jlong ptr) {
+	PurplePlugin *plugin = (PurplePlugin *) longToP(ptr);
+	return purple_plugin_get_type(plugin);
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getId_native
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getId_1native
+  (JNIEnv *env, jobject obj) {
+	return (*env)->NewStringUTF(env, purple_plugin_get_id(getNativePlugin(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getName_native
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getName_1native
+  (JNIEnv *env, jobject obj) {
+	return (*env)->NewStringUTF(env, purple_plugin_get_name(getNativePlugin(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getVersion_native
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getVersion_1native
+  (JNIEnv *env, jobject obj) {
+	return (*env)->NewStringUTF(env, purple_plugin_get_version(getNativePlugin(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getSummary_native
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getSummary_1native
+  (JNIEnv *env, jobject obj) {
+	return (*env)->NewStringUTF(env, purple_plugin_get_summary(getNativePlugin(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getDescription_native
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getDescription_1native
+  (JNIEnv *env, jobject obj) {
+	return (*env)->NewStringUTF(env, purple_plugin_get_description(getNativePlugin(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getAuthor_native
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getAuthor_1native
+  (JNIEnv *env, jobject obj) {
+	return (*env)->NewStringUTF(env, purple_plugin_get_author(getNativePlugin(env, obj)));
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePlugin
+ * Method:    getHomepage_native
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_im_pidgin_libpurple_plugin_PurplePlugin_getHomepage_1native
+  (JNIEnv *env, jobject obj) {
+	return (*env)->NewStringUTF(env, purple_plugin_get_homepage(getNativePlugin(env, obj)));
+}
diff --git a/android/workspace/im.pidgin.libpurple/native/PurplePluginManager.c b/android/workspace/im.pidgin.libpurple/native/PurplePluginManager.c
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple/native/PurplePluginManager.c
@@ -0,0 +1,44 @@
+#include "PurplePluginManager.h"
+#include "helpers.h"
+#include <glib.h>
+#include <libpurple/plugin.h>
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePluginManager
+ * Method:    getProtocolPlugins_native
+ * Signature: ()J
+ */JNIEXPORT jlong JNICALL
+Java_im_pidgin_libpurple_plugin_PurplePluginManager_getProtocolPlugins_1native(
+		JNIEnv *env, jobject obj)
+{
+	 return pToLong(purple_plugins_get_protocols());
+}
+
+/*
+ * Class:     im_pidgin_libpurple_plugin_PurplePluginManager
+ * Method:    getPlugins_native
+ * Signature: ()J
+ */JNIEXPORT jlong JNICALL
+Java_im_pidgin_libpurple_plugin_PurplePluginManager_getPlugins_1native(
+		JNIEnv *env, jobject obj)
+{



More information about the Commits mailing list