Replaced InvitationManager with a generic ReferenceManager for Android.

This commit is contained in:
akwizgran
2013-02-14 13:04:51 +00:00
parent 4307d516a6
commit d1fedaed57
11 changed files with 191 additions and 108 deletions

View File

@@ -0,0 +1,30 @@
package net.sf.briar.api.android;
/**
* Manages mappings between object references and serialisable handles. This
* enables references to be passed between Android UI objects that belong to
* the same process but can only communicate via serialisation.
* <p>
* This interface is designed to be accessed from the UI thread, so
* implementations may not be thread-safe.
*/
public interface ReferenceManager {
/**
* Returns the object with the given handle, or null if no mapping exists
* for the handle.
*/
<T> T getReference(long handle, Class<T> c);
/**
* Creates a mapping between the given reference and a handle, and returns
* the handle.
*/
<T> long putReference(T reference, Class<T> c);
/**
* Removes and returns the object with the given handle, or returns null
* if no mapping exists for the handle.
*/
<T> T removeReference(long handle, Class<T> c);
}

View File

@@ -1,22 +0,0 @@
package net.sf.briar.api.invitation;
/** Creates and manages tasks for exchanging invitations with remote peers. */
public interface InvitationManager {
/** Creates a task using the given invitation codes. */
InvitationTask createTask(int localCode, int remoteCode);
/**
* Returns the previously created task with the given handle, unless the
* task has subsequently removed itself.
*/
InvitationTask getTask(int handle);
/** Called by tasks to add themselves to the manager when they start. */
void putTask(int handle, InvitationTask task);
/**
* Called by tasks to remove themselves from the manager when they finish.
*/
void removeTask(int handle);
}

View File

@@ -3,9 +3,6 @@ package net.sf.briar.api.invitation;
/** A task for exchanging invitations with a remote peer. */
public interface InvitationTask {
/** Returns the task's unique handle. */
int getHandle();
/**
* Adds a listener to be informed of state changes and returns the
* task's current state.

View File

@@ -0,0 +1,8 @@
package net.sf.briar.api.invitation;
/** Creates tasks for exchanging invitations with remote peers. */
public interface InvitationTaskFactory {
/** Creates a task using the given invitation codes. */
InvitationTask createTask(int localCode, int remoteCode);
}