Source code: plugins/Messenger/MessengerPlugin.java
1 /*
2 This file is part of DeXter - Java Internet Communication Solution
3 Copyright (c) 2002 Tobias Riemer
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 package plugins.Messenger;
21
22 import java.util.HashMap;
23 import javax.swing.Icon;
24 import plugins.Messenger.event.*;
25
26 /** Defines the interface for all Plugins for Messenger. This interface
27 * provides methodes for:
28 * <ul>
29 * <li>Lifecylce Management
30 * <li>Sending/Receiving Messages
31 * </ul>
32 * <strong>Lifecylce Management</strong>
33 * A plugin is first created by a call to <i>Class.newInstance()</i>. <b>Be aware that
34 * every Plugin needs an empty Constructor!</b>. The <i>init</i> method is
35 * called to give the plugin a chance to initialze its inner state
36 * ie. generate key pairs for encryption plugins, load icons
37 * After <i>init</i> called a plugin can be activated and deactivated. There is
38 * no constraint that the activate methode is called on and activated of a plugin again. The
39 * same is true for deactivated Plugins. If PluginManager considers that a Plugin
40 * is not needed any more it calls the Plugins <i>destroy</i> methode.
41 * Implement your destroy method to clean up any resources that need some kind of
42 * special clean up treatment ie. close Sockets or Streams etc.
43 * <STRONG>Sending/Receiving Messages</STRONG>
44 * <I>processIncomingMessage</I> is called if the remote sender sends a message to
45 * the local client. Is never called if a Plugin is disabled!
46 * <I>processOutgoingMessage</I> is called if the user or another plugin
47 * wants to send a message to a remote client. Is never called if a Plugin is disabled!
48 *
49 *
50 * @author Christoph Walcher
51 * @see AbstractMessengerPlugin
52 */
53 public interface MessengerPlugin {
54
55 /**
56 * The init method is called after a new Plugin Instance is created. All code
57 * that is needed to create the initial state of the object should go here!
58 */
59 public void init(Conversation conversation);
60
61 /**
62 * Implement Destroy to get rid of any resources that require special destroy behaviour
63 */
64 public void destroy();
65
66
67 /**
68 * Return the name of the Plugin. The name will be displayed on configuration
69 * Panels, Chatframe Menus etc.
70 */
71 public String getName();
72
73 public Character getMnemonic();
74
75 public String getToolTip();
76 /**
77 * Return the icon of the Plugin. The icon will be displayed on configuration
78 * Panels, Chatframe Menus etc.
79 */
80 public javax.swing.ImageIcon getIcon();
81
82 /**
83 * Is called if the user decides to enable/disable a Plugin for a Conversation.
84 * This Method is called by the MessengerPluginProtocol
85 * @see MessengerPluginProtocol
86 */
87 public void setEnabled(boolean enabled, boolean remote);
88
89 /**
90 * Is called if the user decides to enable/disable a Plugin for a Conversation.
91 * This Method is called by the MessengerPluginProtocol
92 * @see MessengerPluginProtocol
93 */
94 public boolean isEnabled();
95
96
97 /**
98 * Is called by PluginManager to generate an new Instance of MessengerPlugin for
99 * every new PluginChain (PluginChains are constructed for Conversations)
100 * @see PluginManager
101 * @seee PluginChain
102 */
103 public Object clone();
104
105 /**
106 * Returns an instance of the used Protocol. Be sure to return the same instance on subsequent
107 * calls to this method!
108 */
109 public plugins.Messenger.MessengerPluginProtocol getProtocol();
110
111 public void addStateListener(StateListener listener);
112
113 public StateListener removeStateListener(StateListener listener);
114 }