--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/AbstractPurpleManaged.java Mon Aug 20 16:02:15 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/AbstractPurpleManaged.java Mon Aug 20 16:14:06 2012 +0200
@@ -1,21 +1,25 @@
package im.pidgin.libpurple.core;
* Objects that use this class belong to a purple instance, which is referenced
-public class AbstractPurpleManaged implements PurpleManaged {
+public class AbstractPurpleManaged { private final CoreManager manager;
+ * Creates a new object that is managed by libpurple. public AbstractPurpleManaged(CoreManager manager) {
protected CoreManager getManager() {
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java Mon Aug 20 16:02:15 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java Mon Aug 20 16:14:06 2012 +0200
@@ -16,32 +16,50 @@
* This is the core purple manager, that provides access to all functionality.
* It also implements the core UI ops.
public class CoreManager {
+ * The purple account list. private final PurpleAccountManager accountList = new PurpleAccountManager(
+ * The purple event loop. private final EventLoop eventloop = new EventLoop(this);
+ * The thread to run all purple tasks on. private final PurpleThread purpleThread = new PurpleThread();
- private final PurplePluginList pluginManager = new PurplePluginManager(this);
+ * The plugin manager we are using. + private final PurplePluginList pluginManager = + new PurplePluginManager(this); + * The blist manager we use. private final PurpleBlistManager blist = new PurpleBlistManager(this);
- private final ConversationManager conversationManager = new ConversationManager(
+ * The conversation manager we use. + private final ConversationManager conversationManager = + new ConversationManager(this); * Initializes libpurple by setting all the ui ops and calling
public boolean startCore(String uiName, File baseDirectory) {
@@ -50,6 +68,11 @@
private native boolean startCore_native(String uiName, String baseDirectory);
+ * Gets the event loop to use. public EventLoop getEventloop() {
@@ -68,22 +91,42 @@
new RequestUiOps().register();
+ * Gets the thread to run all purple tasks on. public PurpleThread getThread() {
+ * Gets the account list manager. + * @return The account list. public PurpleAccountManager getAccountList() {
+ * Gets the plugin manager. + * @return The plugin manager. public PurplePluginList getPluginManager() {
+ * Gets the blist manager. + * @return The blist manager. public PurpleBlistManager getBlist() {
+ * Gets the conversation manager. + * @return The conversation manager. public ConversationManager getConversationManager() {
return conversationManager;
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java Mon Aug 20 16:02:15 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java Mon Aug 20 16:14:06 2012 +0200
@@ -9,17 +9,26 @@
* This is the eventloop implementation that is used to schedule libpruple
* events on the purple thread.
public class EventLoop extends AbstractPurpleManaged {
- Timer eventTimer = new Timer("Event queue timer");
+ private final Timer eventTimer = new Timer("Event queue timer"); private final Object scheduledTimersMutex = new Object();
- private final Hashtable<Integer, EventloopTask> scheduledTimers = new Hashtable<Integer, EventloopTask>();
+ * A list of tasks that are currently scheduled and might be aborted. + private final Hashtable<Integer, EventloopTask> scheduledTimers = + new Hashtable<Integer, EventloopTask>(); + * A steadily increasing counter to create unique timeout ids. private int timeoutCounter = 0;
public EventLoop(CoreManager manager) {
@@ -47,16 +56,12 @@
* Should create a callback timer with an interval measured in milliseconds.
* The supplied function should be called every interval seconds until it
- * returns FALSE, after which it should not be called again.
- * Analogous to g_timeout_add in glib.
- * Note: On Win32, this function may be called from a thread other than the
- * libpurple thread. You should make sure to detect this situation and to
- * only call "function" from the libpurple thread.
+ * returns FALSE, after which it should not be called again. Analogous to + * g_timeout_add in glib. Note: On Win32, this function may be called from a + * thread other than the libpurple thread. You should make sure to detect + * this situation and to only call "function" from the libpurple thread. * the interval in milliseconds between calls to function.
@@ -71,10 +76,10 @@
System.out.println("Adding eventloop task " + key
- + " to be scheduled every " + interval + " milliseconds.");
- EventloopTask task = new EventloopTask(
- new EventloopFunctionExecutor(key, function, data),
- getManager().getThread());
+ + " to be scheduled every " + interval + " milliseconds."); + new EventloopTask(new EventloopFunctionExecutor(key, + function, data), getManager().getThread()); @@ -87,7 +92,6 @@
* an identifier for a timeout, as returned by timeout_add.
* @return TRUE if the timeout identified by handle was found and removed.
@@ -109,9 +113,8 @@
* This is a {@link WaitableRunnable} that executes the given function.
private class EventloopFunctionExecutor extends AbstractWaitableRunnable {
private final long function;
@@ -147,10 +150,13 @@
private native boolean exeucte_native(long function, long data);
+ /* UI ops callbacks and runners */ public void ioInvoke(long function, long data, int fd, int cond) {
- getManager().getThread().scheduleAndWaitForUninterruptable(new IoInvokeRunner(function, data, fd, cond));
+ getManager().getThread().scheduleAndWaitForUninterruptable( + new IoInvokeRunner(function, data, fd, cond));
private static class IoInvokeRunner extends AbstractWaitableRunnable {
private final long function;
@@ -169,8 +175,8 @@
ioInvoke_native(function, data, fd, cond);
- private native void ioInvoke_native(long function2, long data2, int fd2,
+ private native void ioInvoke_native(long function2, long data2, --- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventloopTask.java Mon Aug 20 16:02:15 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventloopTask.java Mon Aug 20 16:14:06 2012 +0200
@@ -7,13 +7,18 @@
* This is a special task for the eventloop.
public class EventloopTask extends TimerTask {
+ * The runnable we need to run. private final WaitableRunnable runnable;
+ * The thread we need to run it on. private final PurpleThread thread;
public EventloopTask(WaitableRunnable runnable, PurpleThread thread) {
@@ -32,7 +37,7 @@
System.err.println("Unexpected interupt exception"
- + " during an EventloopTask executioon.");
+ + " during an EventloopTask executioon."); --- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PeeredPurpleManaged.java Mon Aug 20 16:02:15 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PeeredPurpleManaged.java Mon Aug 20 16:14:06 2012 +0200
@@ -3,22 +3,25 @@
import im.pidgin.libpurple.peering.Peered;
* Objects that use this class belong to a purple instance, which is referenced
-public class PeeredPurpleManaged extends Peered implements PurpleManaged {
+public class PeeredPurpleManaged extends Peered { private final CoreManager manager;
public PeeredPurpleManaged(long nativePointer, CoreManager manager) {
+ * Gets the manager that is used to construct this object. + * @return The core manager. protected CoreManager getManager() {
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java Mon Aug 20 16:02:15 2012 +0200
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java Mon Aug 20 16:14:06 2012 +0200
@@ -14,18 +14,18 @@
* There can only be one instance per process.
public class PurpleInstance {
private static Object instanceActiveMutex = new Object();
private static boolean instanceActive = false;
private final CoreManager coreManager = new CoreManager();
* Creates a new instance and loads libpurple. This might take some time.
@@ -33,7 +33,7 @@
PurpleLibraryLoader.load();
File pluginDirectory = new File(baseDirectory, "plugins");
if (!pluginDirectory.exists()) {
pluginDirectory.mkdirs();
@@ -42,29 +42,51 @@
if (!coreManager.startCore(uiName, baseDirectory)) {
throw new PurpleRuntimeException(
- "Initialization of the libpurple core failed.");
+ "Initialization of the libpurple core failed."); + * Sets the debug enabled flag. + * <code>true</code> to enable debugging. public void setDebugEnabled(boolean enabled) {
setDebugEnabled_native(enabled);
private native void setDebugEnabled_native(boolean enabled);
+ * Adds a directory to search for plugins. public void addPluginSearchpath(File directory) {
addPluginSearchpath_native(directory.getAbsolutePath());
private native void addPluginSearchpath_native(String absolutePath);
+ * Creates a new purple instance. + * The base directory (like <code>.libpurple</code>). + * @return The purple instance. + * @throws IllegalStateException + * if there is already a libpurple instance. public static PurpleInstance createInstance(String uiName,
synchronized (instanceActiveMutex) {
throw new IllegalStateException(
- "There is already a libpurple running");
+ "There is already a libpurple running"); @@ -74,7 +96,7 @@
* Gets the current version of libpurple.
* @return The version as version String.
public String getVersion() {
@@ -82,15 +104,30 @@
private native String getVersion_native();
+ * Gets the account list. + * @return The account list. public PurpleAccountList getAccountList() {
return coreManager.getAccountList();
+ * Gets the plugin list. + * @return The plugin list. public PurplePluginList getPluginList() {
return coreManager.getPluginManager();
+ * @return The buddy list. public PurpleBlist getBlist() {
return coreManager.getBlist();