|
All server based plugins that are created for use with the P2P Application Framework must implement this interface. These methods are called by the framework to find out information about the plugin, as well as to inform the plugin of external events (for example, the arrival of a message intended for the plugin).
It is not necessarily the case that all methods will be used, this will be dependent on the operation of the plugin. For example, if your plugin does not perform file transfers then the methods DownloadLocation() and UploadLocation() will not be relevant. In such cases then the method should just return null (if anything).
| Method Summary | |
void |
ActivatePlugin(java.util.Vector resources)
|
void |
ActivatePluginPreferences()
|
void |
ChangeOfPeerStatus(java.lang.String id,
java.lang.String status)
|
void |
FileTransferSuccess(java.lang.Boolean sucsess,
java.lang.String filename,
java.lang.String source)
|
java.util.Vector |
GetAvailableResources()
|
int[] |
GetMediaInterested()
|
java.lang.String |
GetPluginAuthor()
|
java.lang.String |
GetPluginDescription()
|
java.awt.Image |
GetPluginIcon()
|
int |
GetPluginID()
|
java.lang.String |
GetPluginName()
|
java.lang.String |
IncomingLocation()
|
void |
KillPlugin()
|
void |
MessageArrived(java.util.HashMap messageparts)
|
java.lang.String |
OutgoingLocation()
|
void |
SearchResults(java.util.Vector results)
|
void |
StatusChange(java.lang.String status)
|
| Method Detail |
public int GetPluginID()
Returns the ID for this plugin.
An ID for your plugin should be requested from the Administrator of the P2P
Application Framework.
public java.lang.String GetPluginName()
Returns the name of the plugin.
This is what is displayed to the user of the framework and so it should not be
too long.
public java.lang.String GetPluginDescription()
Returns a brief description of the plugin.
Currently the description is not used within the framework.
public java.lang.String GetPluginAuthor()
Returns the plugins author's name.
Currently this information is not used within the frameork.
public java.awt.Image GetPluginIcon()
Returns the icon used to represent the plugin within the framework.
public int[] GetMediaInterested()
This method is called by the framework so it can determine which MediaTypes the plugin is interested in.
Returns an int array that contains the ID's of all the MediaTypes this plugin
is interested in (and potentially deals with)
A list of the currently registered MediaTypes can be found here :
Should your plugin make use of a new MediaType then you should first register it
with the Administrator of the P2P Application Framework.
public java.util.Vector GetContactInterested()
This method is called by the framework so it can determine whether the plugin should have an entry on the Pop-up menu that appears over the Contact List.
Returns a Vector that contains String values representing the menu items that
will appear on the Pop-up menu.
For example, for the FileSharingPlugin this method contains the code:
Vector v = new Vector();
v.add("Browse user's files");
v.add("Send file");
return v;
This code will add the two strings to the pop-up menu.
When the menu item is selected, the framework calls ActivatePlugin (below) and passes the String as a parameter.
public void ActivatePlugin(java.lang.Integer id,
java.lang.String action,
UserObject participant)
This method is called by the framework as a result of a user selecting a menu item from the pop-up menu that appears over the Contact List.
id - refers to the ID of the plugins. Essentially this can be used to
confirm that the correct plugin has been called
action - refers to the String displayed in the menu item. For example
"Browse user's files" or "Send file".
participant - refers to the user which this action refers to. ie, over
whom on the contact list the pop-up menu was brought up. Information about this
user is captured within an instance of UserObject.
public void ActivatePlugin(UserObject participant)
This method is called by the framework as a result of a user indicating that they wish to utilise the plugin with the provided user (for example, to launch a chat plugin that involves the specified target user)
participant - the target user. Information about this user is captured within an instance of UserObject
public void ActivatePlugin(java.util.Vector resources)
This method is called by the framework as a result of a user indicating that they wish to utilise the plugin with the provided resources (for example, download the specified files with the FileSharingPlugin).
resources - a Vector of resources. Each resource is represented by an instance of ResourceObject
public void ActivatePluginPreferences()
This method is called by the framework as a result of a user indicating they wish to access/edit the plugins preferences. This is achieved whenever the user clicks on the respective plugins icon within the plugins panel (bottom of the main framework window).
With some plugins this might be the only way to activate the plugin (for example, as with the Noughts and Crosses plugin).
public void StatusChange(java.lang.String status)
This method is called by the framework whenever the user of the framework changes their status (for example, changes from on-line to off-line). All plugins are informed of this change in case they need to react to it.
status - a String representing the current status of the user (for example, "Off-Line").
public void ChangeOfPeerStatus(java.lang.String id,
java.lang.String status)
This method is called by the framework whenever a user that is on the Contact List changes status. All plugins are informed of this change in case they need to react to it.
id - the unique id of the user that has changed state
status - a String representing the current status of that user (for
example, "Off-Line")
public void KillPlugin()
This method is called by the framework to inform the plugin that it should shut down. When this is called plugins should make sure they stop their current operations and store critical data if needs be. This method will typically be called when a user deactivates a plugin, or when they are quitting the framework.
public java.util.Vector GetAvailableResources()
This method is called by the framework so it can establish what resources the plugin is making available to the rest of the network. The plugin should return a Vector of ResourceTemplate objects, where each ResourceTemplate represents one resource (for example, an MP3 file).
The ClientFramework provides a method (CreateResourceTemplate) that can be used to construct ResourceTemplates.
ResourceTemplates are converted to ResourceObjects by the ClientFramework before being made available to the rest of the network. Essentially the ResourceTemplates capture some information that will make up a ResourceObject, the rest is provided by the ClientFramework itself.
public void MessageArrived(java.util.HashMap messageparts)
This method is called by the framework whenever it receives a new message for the particular plugin.
messageparts - the returned message is represented by a HashMap. HashMap.get() methods can be used to access the contents of the message.
public java.lang.String OutgoingLocation()
This method is called by the framework when it needs to know where files the plugin is making available are being stored. Typically this will be a directory within the plugin directory to ensure platform/machine independence. The plugin should return the full path to this location.
public java.lang.String IncomingLocation()
This method is called by the framework when it needs to know where files the plugin is downloading should be stored. Typically this will be a directory within the plugin directory to ensure platform/machine independence. The plugin should return the full path to this location.
public void FileTransferSuccess(java.lang.Boolean success,
java.lang.String filename,
java.lang.String source)
This method is called by the framework to inform the plugin of the results of a file transfer operation. The framework will call this method whether the transfer was a success or a failure.
success - a Booleam value that represents whether the transfer was a
success or failure
filename - a String value that represents the filename of the file that
was transferred
source - a String value that represents whether this peer was the
"Server" or "Client" during the operation
public void SearchResults(java.util.Vector results)
This method is called by the framework containing the results of a resource search that has been performed on the network. It should be noted that the framework provides its own means for allowing the user to search the network. However in some cases it might be necessary for a plugin to do a resource search without the user's knowledge (for example, a computational plugin that performs a search to see what computational resources exist on the network so it can send out workpackages). In which case this method is called when the search (initiated by ClientFramework.ResourceSearch() ) has been completed.
results - a Vector containing the results of the search. Each result is represented by an instance of ResultObject.
|