soc.2012.android: 3e86308d: Added account UI ops and listeners.

michael at soc.pidgin.im michael at soc.pidgin.im
Sat Jun 9 06:57:11 EDT 2012


----------------------------------------------------------------------
Revision: 3e86308d7f711600e74e7345df84b0175eed799c
Parent:   1100e87ce49857c1c2601822db719e5dde0d0d0a
Author:   michael at soc.pidgin.im
Date:     06/09/12 06:50:47
Branch:   im.pidgin.soc.2012.android
URL: http://d.pidgin.im/viewmtn/revision/info/3e86308d7f711600e74e7345df84b0175eed799c

Changelog: 

Added account UI ops and listeners.

Changes against parent 1100e87ce49857c1c2601822db719e5dde0d0d0a

  added    android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/AccountListenerList.java
  added    android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountListenable.java
  added    android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountManager.java
  patched  android/workspace/im.pidgin.libpurple/loadlibs.ant
  patched  android/workspace/im.pidgin.libpurple/native/build.ant
  patched  android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountList.java
  patched  android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java
  patched  android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java

-------------- next part --------------
============================================================
--- android/workspace/im.pidgin.libpurple/native/build.ant	6af6e45c33846f9b16eb943400e023ba02c985a9
+++ android/workspace/im.pidgin.libpurple/native/build.ant	2ca9d96aa846c9e8628b541fec59569513f92576
@@ -33,7 +33,7 @@
          - - - - - - - - - - - - - - - - - -->
 	<target name="headers.create">
 		<javah classdefinition="im.pidgin.libpurple.account.PurpleAccount" to="${javah.out}" />
-		<javah classdefinition="im.pidgin.libpurple.account.PurpleAccountList" to="${javah.out}" />
+		<javah classdefinition="im.pidgin.libpurple.account.PurpleAccountManager" to="${javah.out}" />
 		<javah classdefinition="im.pidgin.libpurple.account.PurpleStatus" to="${javah.out}" />
 
 		<javah classdefinition="im.pidgin.libpurple.blist.PurpleBlist" to="${javah.out}" />
============================================================
--- android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountList.java	23fb321f72557480beb368200afc2f281505f0f7
+++ android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountList.java	3540cf4b647e44504399df67b8d2b04010222800
@@ -1,10 +1,31 @@ package im.pidgin.libpurple.account;
 package im.pidgin.libpurple.account;
 
 /**
- * This class provides access to the account list of libpurple.
+ * THis is an account list that is part of a purple instance.
+ * <p>
+ * It can be used to access accounts, create new accounts, delete accounts and
+ * listen to account list changes.
+ * <p>
+ * If you add Account listeners to this object, they will listen to all accounts.
+ * 
  * @author michaelz
- *
+ * 
  */
-public final class PurpleAccountList {
+public interface PurpleAccountList extends PurpleAccountListenable {
+	/**
+	 * Adds a {@link PurpleAccountListListener} to the account list.
+	 * 
+	 * @param listener
+	 *            The listener.
+	 */
+	public void addAccountListener(PurpleAccountListListener listener);
 
+	/**
+	 * Removes a previously added {@link PurpleAccountListListener} from the
+	 * account list. Does nothing if the listener was not added.
+	 * 
+	 * @param listener
+	 *            The listener.
+	 */
+	public void removeAccountListener(PurpleAccountListListener listener);
 }
============================================================
--- android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java	c8fa4f197de0c1910799e8d4d5fc8c540acd9b3a
+++ android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/CoreManager.java	af2780980367f21c1f77375cba4170316aa3f8e0
@@ -1,6 +1,6 @@ package im.pidgin.libpurple.core;
 package im.pidgin.libpurple.core;
 
-import im.pidgin.libpurple.account.PurpleAccountList;
+import im.pidgin.libpurple.account.PurpleAccountManager;
 
 /**
  * This is the core purple manager, that provides access to all functionality.
@@ -10,9 +10,9 @@ public class CoreManager{
  * 
  */
 public class CoreManager{
-	private final PurpleAccountList accountList = new PurpleAccountList();
+	private final PurpleAccountManager accountList = new PurpleAccountManager(this);
 	
-	private final EventLoop eventloop = new EventLoop();
+	private final EventLoop eventloop = new EventLoop(this);
 	
 	/**
 	 * Initializes libpurple by setting all the ui ops and calling
============================================================
--- android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java	97b3555c7822b801f3d8a3450f9b6a6f5b1127ea
+++ android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/EventLoop.java	24b9a8da3645d52deb82a68c30c575764aa9eb20
@@ -7,8 +7,10 @@ package im.pidgin.libpurple.core;
  * @author michaelz
  * 
  */
-public class EventLoop {
-	public EventLoop() {
+public class EventLoop extends AbstractPurpleManaged {
+
+	public EventLoop(CoreManager manager) {
+		super(manager);
 	}
 
 	private native void init_native();
============================================================
--- android/workspace/im.pidgin.libpurple/loadlibs.ant	dc0c53eb5473cb00de5c88661f4c4d1b9b3ea54a
+++ android/workspace/im.pidgin.libpurple/loadlibs.ant	1b37e4b71fe277085ed22d16e8c8e242808a30a2
@@ -17,7 +17,7 @@
           macrodef: libpurple.loadlibs          
          = = = = = = = = = = = = = = = = = -->
 	<macrodef name="libpurple.loadlibs" description="copys the librarys to your android project.">
-		<attribute name="outproject" default=""/>
+		<attribute name="outproject" default="" />
 		<sequential>
 			<dirname file="${ant.file.libpurple.loadlibs}" property="libpurple.projectroot" />
 			<property name="libpurple.deploy" location="${libpurple.projectroot}/deploy" />
@@ -26,7 +26,6 @@
 			<property name="libpurple.outlibdir" location="${libpurple.outproject}/libs/armeabi" />
 			<mkdir dir="${libpurple.outlibdir}" />
 
-			<echo>${libpurple.deploy}</echo>
 			<!-- do the copy -->
 			<copy todir="${libpurple.outlibdir}">
 				<fileset dir="${libpurple.deploy}">
============================================================
--- /dev/null	
+++ android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/AccountListenerList.java	b9ce75a895b3aecf52a68ac1a8a0bdfe9141c6ae
@@ -0,0 +1,23 @@
+package im.pidgin.libpurple.account;
+
+import java.util.LinkedList;
+
+/**
+ * This class holds a list of account listeners that can be notified.
+ * @author michaelz
+ *
+ */
+class AccountListenerList implements PurpleAccountListenable {
+	private final LinkedList<PurpleAccountListener> listeners = new LinkedList<PurpleAccountListener>();
+
+	@Override
+	public void addAccountListener(PurpleAccountListener listener) {
+		listeners.add(listener);
+	}
+	
+	@Override
+	public void removeAccountListener(PurpleAccountListener listener) {
+		listeners.remove(listener);
+	}
+}
+
============================================================
--- /dev/null	
+++ android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountListenable.java	d779aec00f17d1d17ea99d116ea58e75a1fb1add
@@ -0,0 +1,20 @@
+package im.pidgin.libpurple.account;
+
+interface PurpleAccountListenable {
+
+	/**
+	 * Adds a listener that listens to account changes
+	 * 
+	 * @param listener
+	 *            The listener
+	 */
+	public abstract void addAccountListener(PurpleAccountListener listener);
+
+	/**
+	 * Removes a listener that listens to account changes.
+	 * 
+	 * @param listener
+	 */
+	public abstract void removeAccountListener(PurpleAccountListener listener);
+
+}
\ No newline at end of file
============================================================
--- /dev/null	
+++ android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/account/PurpleAccountManager.java	7d68f39e36abb2ddbc4d7e00b9ae6ee7755b8f3a
@@ -0,0 +1,86 @@
+package im.pidgin.libpurple.account;
+
+import im.pidgin.libpurple.core.AbstractPurpleManaged;
+import im.pidgin.libpurple.core.CoreManager;
+
+import java.util.LinkedList;
+
+/**
+ * This class provides access to the account list of libpurple.
+ * <p>
+ * It also implements the account UI ops.
+ * 
+ * @author michaelz
+ * 
+ */
+public final class PurpleAccountManager extends AbstractPurpleManaged implements
+		PurpleAccountList {
+
+	private final LinkedList<PurpleAccountListListener> listeners = new LinkedList<PurpleAccountListListener>();
+
+	private final AccountListenerList accountListeners = new AccountListenerList();
+
+	public PurpleAccountManager(CoreManager manager) {
+		super(manager);
+	}
+
+	/**
+	 * Registers this account list to libpurple.
+	 */
+	public void register() {
+		register_native();
+	}
+
+	private native void register_native();
+
+	/**
+	 * A buddy who is already on this account's buddy list added this account to
+	 * their buddy list.
+	 * 
+	 * @param account
+	 * @param remoteUser
+	 * @param id
+	 * @param alias
+	 * @param message
+	 */
+	private void notifyAdded(long account, String remoteUser, String id,
+			String alias, String message) {
+
+	}
+
+	private void statusChanged(long account, long status) {
+	}
+
+	public void requestAdd(long account, String remoteUser, String id,
+			String alias, String message) {
+	}
+
+	public long requestAuthorize(long account, String remoteUser, String id,
+			String alias, String message, boolean onList, long authorizeCb,
+			long denyCb, long userData) {
+		return 0;
+	}
+
+	public void closeAccountRequest(long uiHandle) {
+	}
+
+	@Override
+	public void addAccountListener(PurpleAccountListListener listener) {
+		listeners.add(listener);
+	}
+
+	@Override
+	public void removeAccountListener(PurpleAccountListListener listener) {
+		listeners.remove(listener);
+	}
+
+	@Override
+	public void addAccountListener(PurpleAccountListener listener) {
+		accountListeners.addAccountListener(listener);
+	}
+
+	@Override
+	public void removeAccountListener(PurpleAccountListener listener) {
+		accountListeners.removeAccountListener(listener);
+	}
+}


More information about the Commits mailing list