mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Replaced InvitationManager with a generic ReferenceManager for Android.
This commit is contained in:
30
briar-api/src/net/sf/briar/api/android/ReferenceManager.java
Normal file
30
briar-api/src/net/sf/briar/api/android/ReferenceManager.java
Normal 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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user