/soc/2012/michael/android: 8332020fe215: Added methods to set ac...

Michael Zangl michael at soc.pidgin.im
Sun Jul 29 08:20:08 EDT 2012


Changeset: 8332020fe2155e938f2767b7a35015a91abe56ff
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-29 14:12 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/8332020fe215

Description:

Added methods to set account settings (purple_account_clear_settings, purple_account_remove_setting, purple_account_set_int, purple_account_set_string, purple_account_set_bool).

diffstat:

 android/workspace/im.pidgin.libpurple/native/PurpleAccount.c                             |  92 +++++++++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccount.java |  38 ++++
 2 files changed, 129 insertions(+), 1 deletions(-)

diffs (157 lines):

diff --git a/android/workspace/im.pidgin.libpurple/native/PurpleAccount.c b/android/workspace/im.pidgin.libpurple/native/PurpleAccount.c
--- a/android/workspace/im.pidgin.libpurple/native/PurpleAccount.c
+++ b/android/workspace/im.pidgin.libpurple/native/PurpleAccount.c
@@ -166,7 +166,8 @@ Java_im_pidgin_libpurple_account_PurpleA
 	const char *alias_native;
 	PurpleBuddy *buddy;
 
-	g_log("jni", G_LOG_LEVEL_DEBUG, "bl: %p, root: %p", purple_get_blist(), purple_blist_get_root());
+	g_log("jni", G_LOG_LEVEL_DEBUG, "bl: %p, root: %p", purple_get_blist(),
+			purple_blist_get_root());
 
 	name_native = (*env)->GetStringUTFChars(env, name, NULL);
 	g_return_val_if_fail(name_native != NULL, 0);
@@ -195,6 +196,95 @@ Java_im_pidgin_libpurple_account_PurpleA
 
 /*
  * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    clearSettings_native
+ * Signature: ()V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_clearSettings_1native(
+		JNIEnv *env, jobject obj)
+{
+	PurpleAccount *account_native = getNativeAccount(env, obj);
+
+	purple_account_clear_settings(account_native);
+}
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    removeSetting_native
+ * Signature: (Ljava/lang/String;)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_removeSetting_1native(
+		JNIEnv *env, jobject obj, jstring setting)
+ {
+ 	PurpleAccount *account_native = getNativeAccount(env, obj);
+ 	const char* setting_native;
+
+	setting_native = (*env)->GetStringUTFChars(env, setting, NULL);
+	g_return_if_fail(setting_native != NULL);
+ 	purple_account_remove_setting(account_native, setting_native);
+	(*env)->ReleaseStringUTFChars(env, setting, setting_native);
+ }
+
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setInt_native
+ * Signature: (Ljava/lang/String;I)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setInt_1native(JNIEnv *env,
+		jobject obj, jstring setting, jint value)
+ {
+ 	PurpleAccount *account_native = getNativeAccount(env, obj);
+ 	const char* setting_native;
+
+	setting_native = (*env)->GetStringUTFChars(env, setting, NULL);
+	g_return_if_fail(setting_native != NULL);
+ 	purple_account_set_int(account_native, setting_native, value);
+	(*env)->ReleaseStringUTFChars(env, setting, setting_native);
+ }
+
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setString_native
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setString_1native(JNIEnv *env,
+		jobject obj, jstring setting, jstring value)
+ {
+ 	PurpleAccount *account_native = getNativeAccount(env, obj);
+ 	const char* setting_native;
+
+	setting_native = (*env)->GetStringUTFChars(env, setting, NULL);
+	g_return_if_fail(setting_native != NULL);
+	const char* value_native;
+	value_native = (*env)->GetStringUTFChars(env, value, NULL);
+	g_return_if_fail(value_native != NULL);
+
+ 	purple_account_set_string(account_native, setting_native, value_native);
+	(*env)->ReleaseStringUTFChars(env, setting, setting_native);
+	(*env)->ReleaseStringUTFChars(env, value, value_native);
+ }
+
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
+ * Method:    setBool_native
+ * Signature: (Ljava/lang/String;Z)V
+ */JNIEXPORT void JNICALL
+Java_im_pidgin_libpurple_account_PurpleAccount_setBool_1native(JNIEnv *env,
+		jobject obj, jstring setting, jboolean value)
+ {
+ 	PurpleAccount *account_native = getNativeAccount(env, obj);
+ 	const char* setting_native;
+
+	setting_native = (*env)->GetStringUTFChars(env, setting, NULL);
+	g_return_if_fail(setting_native != NULL);
+ 	purple_account_set_bool(account_native, setting_native, value);
+	(*env)->ReleaseStringUTFChars(env, setting, setting_native);
+ }
+
+/*
+ * Class:     im_pidgin_libpurple_account_PurpleAccount
  * Method:    newAccount_native
  * Signature: (Ljava/lang/String;Ljava/lang/String;)J
  */JNIEXPORT jlong JNICALL
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccount.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccount.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccount.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccount.java
@@ -224,6 +224,44 @@ public final class PurpleAccount extends
 
 	private native long newBuddy_native(String name, String alias);
 
+	public void clearSettings() {
+		clearSettings_native();
+	}
+
+	private native void clearSettings_native();
+
+	/**
+	 * Removes an account-specific setting by name. 
+	 * @param setting
+	 */
+	public void removeSetting(String setting) {
+		removeSetting_native(setting);
+	}
+
+	private native void removeSetting_native(String setting);
+
+	public void setInt(String setting, int value) {
+		setInt_native(setting, value);
+	}
+
+	private native void setInt_native(String setting, int value);
+	
+	public void setString(String setting, String value) {
+		setString_native(setting, value);
+	}
+
+	private native void setString_native(String setting, String value);
+	
+
+	public void setBool(String setting, boolean value) {
+		setBool_native(setting, value);
+	}
+
+	private native void setBool_native(String setting, boolean value);
+	
+	
+	
+	
 	/**
 	 * Creates a new purple account by calling purple_account_new.
 	 * <p>



More information about the Commits mailing list