/soc/2012/michael/android: ce200a6accfa: Fixed user directory ha...

Michael Zangl michael at soc.pidgin.im
Wed Jul 18 06:29:28 EDT 2012


Changeset: ce200a6accfaf062002bdb92b09dc622dcaa71a3
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-18 12:26 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/ce200a6accfa

Description:

Fixed user directory handling in core.

diffstat:

 android/workspace/im.pidgin.libpurple/.project                                                  |   4 +-
 android/workspace/im.pidgin.libpurple/native/CoreManager.c                                      |  18 ++++++---
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountManager.java |   7 +++
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java             |   9 +++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java          |   2 +-
 5 files changed, 27 insertions(+), 13 deletions(-)

diffs (120 lines):

diff --git a/android/workspace/im.pidgin.libpurple/.project b/android/workspace/im.pidgin.libpurple/.project
--- a/android/workspace/im.pidgin.libpurple/.project
+++ b/android/workspace/im.pidgin.libpurple/.project
@@ -34,7 +34,7 @@
 				</dictionary>
 				<dictionary>
 					<key>org.eclipse.cdt.make.core.buildArguments</key>
-					<value>-j</value>
+					<value></value>
 				</dictionary>
 				<dictionary>
 					<key>org.eclipse.cdt.make.core.buildCommand</key>
@@ -42,7 +42,7 @@
 				</dictionary>
 				<dictionary>
 					<key>org.eclipse.cdt.make.core.buildLocation</key>
-					<value>${workspace_loc:/im.pidgin.libpurple/Android}</value>
+					<value>${workspace_loc:/im.pidgin.libpurple/X86}</value>
 				</dictionary>
 				<dictionary>
 					<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
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
@@ -48,25 +48,29 @@
  * Signature: (Ljava/lang/String;)Z
  */JNIEXPORT jboolean JNICALL
 Java_im_pidgin_libpurple_core_CoreManager_startCore_1native(JNIEnv *env,
-		jobject obj, jstring uiName)
+		jobject obj, jstring ui_name, jstring user_dir)
 {
 	jboolean success;
-	const char* uiNameNative;
+	const char* user_dir_native;
+	const char* ui_name_native;
 
 	setJavaObject(&coreManagerInstance, env, obj);
 
 	/* plugins init */
 	g_log("jni", G_LOG_LEVEL_INFO, "starting core");
-	__android_log_print(ANDROID_LOG_WARN, "jni", "loading plugins");
+	user_dir_native = (*env)->GetStringUTFChars(env, user_dir, NULL);
+	g_return_val_if_fail(user_dir_native != NULL, JNI_FALSE);
+	purple_util_set_user_dir(user_dir_native);
+	(*env)->ReleaseStringUTFChars(env, user_dir, user_dir_native);
 
 	purple_core_set_ui_ops(&coreUiOps);
 	purple_eventloop_set_ui_ops(getEventloopUiOps());
 
-	uiNameNative = (*env)->GetStringUTFChars(env, uiName, NULL);
-	g_return_val_if_fail(uiNameNative != NULL, JNI_FALSE);
+	ui_name_native = (*env)->GetStringUTFChars(env, ui_name, NULL);
+	g_return_val_if_fail(ui_name_native != NULL, JNI_FALSE);
 
-	success = purple_core_init(uiNameNative) ? JNI_TRUE : JNI_FALSE;
-	(*env)->ReleaseStringUTFChars(env, uiName, uiNameNative);
+	success = purple_core_init(ui_name_native) ? JNI_TRUE : JNI_FALSE;
+	(*env)->ReleaseStringUTFChars(env, ui_name, ui_name_native);
 
 	if (success) {
 		g_log("jni", G_LOG_LEVEL_INFO, "loading blist");
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountManager.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountManager.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountManager.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountManager.java
@@ -165,6 +165,13 @@
 	@Override
 	public PurpleAccount addAccount(final String username,
 			final PurpleProtocolPlugin protocol) {
+		if (username == null) {
+			throw new IllegalArgumentException("username is null");
+		}
+		if (protocol == null) {
+			throw new IllegalArgumentException("protocol is null");
+		}
+		
 		AddAccountExecutor runnable = new AddAccountExecutor(protocol, username);
 		getManager().getThread().scheduleAndWaitForUninterruptable(runnable);
 		return runnable.account;
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java
@@ -7,6 +7,8 @@
 import im.pidgin.libpurple.plugin.PurplePluginList;
 import im.pidgin.libpurple.plugin.PurplePluginManager;
 
+import java.io.File;
+
 /**
  * This is the core purple manager, that provides access to all functionality.
  * <p>
@@ -36,13 +38,14 @@
 	 * 
 	 * @param uiName
 	 *            The name of the UI.
+	 * @param baseDirectory 
 	 */
-	public boolean startCore(String uiName) {
+	public boolean startCore(String uiName, File baseDirectory) {
 		eventloop.register();
-		return startCore_native(uiName);
+		return startCore_native(uiName, baseDirectory.getAbsolutePath());
 	}
 
-	private native boolean startCore_native(String uiName);
+	private native boolean startCore_native(String uiName, String baseDirectory);
 
 	public EventLoop getEventloop() {
 		return eventloop;
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java
@@ -40,7 +40,7 @@
 		}
 		addPluginSearchpath(pluginDirectory);
 
-		if (!coreManager.startCore(uiName)) {
+		if (!coreManager.startCore(uiName, baseDirectory)) {
 			throw new PurpleRuntimeException(
 					"Initialization of the libpurple core failed.");
 		}



More information about the Commits mailing list