/soc/2012/michael/android: e0ee0749df86: Commented the core classes

Michael Zangl michael at soc.pidgin.im
Mon Aug 20 10:15:53 EDT 2012


Changeset: e0ee0749df864109ed8f9c45edc93eee62076ac0
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-08-20 16:14 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/e0ee0749df86

Description:

Commented the core classes

diffstat:

 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/AbstractPurpleManaged.java |  16 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java           |  63 ++++++++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java             |  56 ++++---
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventloopTask.java         |  11 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PeeredPurpleManaged.java   |  15 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/PurpleInstance.java        |  61 +++++++-
 6 files changed, 160 insertions(+), 62 deletions(-)

diffs (truncated from 473 to 300 lines):

diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/AbstractPurpleManaged.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/AbstractPurpleManaged.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/AbstractPurpleManaged.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/AbstractPurpleManaged.java
@@ -1,21 +1,25 @@
 package im.pidgin.libpurple.core;
 
 /**
- * 
  * Objects that use this class belong to a purple instance, which is referenced
  * by the main manager.
- * 
+ *
  * @author michaelz
- * 
  */
-public class AbstractPurpleManaged implements PurpleManaged {
-	
+public class AbstractPurpleManaged {
+
 	private final CoreManager manager;
 
+	/**
+	 * Creates a new object that is managed by libpurple.
+	 *
+	 * @param manager
+	 *            The manager to use.
+	 */
 	public AbstractPurpleManaged(CoreManager manager) {
 		this.manager = manager;
 	}
-	
+
 	protected CoreManager getManager() {
 		return manager;
 	}
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
@@ -16,32 +16,50 @@ import java.io.File;
  * This is the core purple manager, that provides access to all functionality.
  * <p>
  * It also implements the core UI ops.
- * 
- * @author michaelz
- * 
+ *
+ * @author michael
  */
 public class CoreManager {
+	/**
+	 * The purple account list.
+	 */
 	private final PurpleAccountManager accountList = new PurpleAccountManager(
-			this);
+	        this);
 
+	/**
+	 * 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(
-			this);
+	/**
+	 * The conversation manager we use.
+	 */
+	private final ConversationManager conversationManager =
+	        new ConversationManager(this);
 
 	/**
 	 * Initializes libpurple by setting all the ui ops and calling
 	 * purple_core_init().
-	 * 
+	 *
 	 * @param uiName
 	 *            The name of the UI.
-	 * @param baseDirectory 
+	 * @param baseDirectory
 	 */
 	public boolean startCore(String uiName, File baseDirectory) {
 		eventloop.register();
@@ -50,6 +68,11 @@ public class CoreManager {
 
 	private native boolean startCore_native(String uiName, String baseDirectory);
 
+	/**
+	 * Gets the event loop to use.
+	 *
+	 * @return The loop.
+	 */
 	public EventLoop getEventloop() {
 		return eventloop;
 	}
@@ -68,22 +91,42 @@ public class CoreManager {
 		new RequestUiOps().register();
 	}
 
+	/**
+	 * Gets the thread to run all purple tasks on.
+	 * @return The thread.
+	 */
 	public PurpleThread getThread() {
 		return purpleThread;
 	}
 
+	/**
+	 * Gets the account list manager.
+	 * @return The account list.
+	 */
 	public PurpleAccountManager getAccountList() {
 		return accountList;
 	}
 
+	/**
+	 * Gets the plugin manager.
+	 * @return The plugin manager.
+	 */
 	public PurplePluginList getPluginManager() {
 		return pluginManager;
 	}
 
+	/**
+	 * Gets the blist manager.
+	 * @return The blist manager.
+	 */
 	public PurpleBlistManager getBlist() {
 		return blist;
 	}
-	
+
+	/**
+	 * Gets the conversation manager.
+	 * @return The conversation manager.
+	 */
 	public ConversationManager getConversationManager() {
 		return conversationManager;
 	}
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java
@@ -9,17 +9,26 @@ import java.util.Timer;
 /**
  * This is the eventloop implementation that is used to schedule libpruple
  * events on the purple thread.
- * 
+ *
  * @author michaelz
- * 
  */
 public class EventLoop extends AbstractPurpleManaged {
 
-	Timer eventTimer = new Timer("Event queue timer");
+	/**
+	 * The main event 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 @@ public class EventLoop extends AbstractP
 
 	/**
 	 * 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.
+	 *
 	 * @param interval
 	 *            the interval in milliseconds between calls to function.
 	 * @param function
@@ -71,10 +76,10 @@ public class EventLoop extends AbstractP
 			key = timeoutCounter;
 
 			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.");
+			EventloopTask task =
+			        new EventloopTask(new EventloopFunctionExecutor(key,
+			                function, data), getManager().getThread());
 			if (interval <= 0) {
 				interval = 1;
 			}
@@ -87,7 +92,6 @@ public class EventLoop extends AbstractP
 	}
 
 	/**
-	 * 
 	 * @param handle
 	 *            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 @@ public class EventLoop extends AbstractP
 
 	/**
 	 * This is a {@link WaitableRunnable} that executes the given function.
-	 * 
+	 *
 	 * @author michaelz
-	 * 
 	 */
 	private class EventloopFunctionExecutor extends AbstractWaitableRunnable {
 		private final long function;
@@ -147,10 +150,13 @@ public class EventLoop extends AbstractP
 
 	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;
 		private final long data;
@@ -169,8 +175,8 @@ public class EventLoop extends AbstractP
 			ioInvoke_native(function, data, fd, cond);
 		}
 
-		private native void ioInvoke_native(long function2, long data2, int fd2,
-				int cond2);
-		
+		private native void ioInvoke_native(long function2, long data2,
+		        int fd2, int cond2);
+
 	}
 }
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventloopTask.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventloopTask.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventloopTask.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventloopTask.java
@@ -7,13 +7,18 @@ import java.util.TimerTask;
 
 /**
  * This is a special task for the eventloop.
- * 
+ *
  * @author michaelz
- * 
  */
 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 @@ public class EventloopTask extends Timer
 			 * interrupted.
 			 */
 			System.err.println("Unexpected interupt exception"



More information about the Commits mailing list