]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/plugin/Plugin.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / plugin / Plugin.java
1 /*****************************************************/
2 /*          This java file is a part of the          */
3 /*                                                   */
4 /*           -  Plouf's Java IRC Client  -           */
5 /*                                                   */
6 /*   Copyright (C)  2002 - 2005 Philippe Detournay   */
7 /*                                                   */
8 /*         All contacts : theplouf@yahoo.com         */
9 /*                                                   */
10 /*  PJIRC is free software; you can redistribute     */
11 /*  it and/or modify it under the terms of the GNU   */
12 /*  General Public License as published by the       */
13 /*  Free Software Foundation; version 2 or later of  */
14 /*  the License.                                     */
15 /*                                                   */
16 /*  PJIRC is distributed in the hope that it will    */
17 /*  be useful, but WITHOUT ANY WARRANTY; without     */
18 /*  even the implied warranty of MERCHANTABILITY or  */
19 /*  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   */
20 /*  General Public License for more details.         */
21 /*                                                   */
22 /*  You should have received a copy of the GNU       */
23 /*  General Public License along with PJIRC; if      */
24 /*  not, write to the Free Software Foundation,      */
25 /*  Inc., 59 Temple Place, Suite 330, Boston,        */
26 /*  MA  02111-1307  USA                              */
27 /*                                                   */
28 /*****************************************************/
29
30 package irc.plugin;
31
32 import irc.IRCApplication;
33 import irc.IRCConfiguration;
34 import irc.Server;
35 import irc.Source;
36
37 /**
38  * The root class for all plugins.
39  */
40 public abstract class Plugin {
41
42         /**
43          * The global IRCConfiguration instance.
44          */
45         protected IRCConfiguration _ircConfiguration;
46         /**
47          * The running IRCApplication instance.
48          */
49         protected IRCApplication _ircApplication;
50
51         /**
52          * Create a new Plugin with the given IRCConfiguration instance.
53          * 
54          * @param ircConfiguration
55          *          the global IRCConfiguration instance.
56          */
57         public Plugin(IRCConfiguration ircConfiguration) {
58                 _ircConfiguration = ircConfiguration;
59         }
60
61         /**
62          * Set the running IRCApplication instance.
63          * 
64          * @param ircApplication
65          *          the running IRCApplication.
66          */
67         public void setIRCApplication(IRCApplication ircApplication) {
68                 _ircApplication = ircApplication;
69         }
70
71         /**
72          * Load the plugin.
73          */
74         public void load() {
75                 // default empty implementation...
76         }
77
78         /**
79          * Unload any ressources used by this plugin. This should be the last method
80          * call on the instance.
81          */
82         public void unload() {
83                 _ircConfiguration = null;
84                 _ircApplication = null;
85         }
86
87         /**
88          * Notify this plugin that a new source has been created.
89          * 
90          * @param source
91          *          the newly created source.
92          * @param bring
93          *          is true if the newly created source should gain immediate focus,
94          *          false is no particular action is to be taken.
95          */
96         public void sourceCreated(Source source, Boolean bring) {
97                 // default empty implementation...
98         }
99
100         /**
101          * Notify this plugin that an existing source has been removed. No further
102          * call should be performed on this source.
103          * 
104          * @param source
105          *          the removed source.
106          */
107         public void sourceRemoved(Source source) {
108                 // default empty implementation...
109         }
110
111         /**
112          * Notify this plugin that a new server has been created.
113          * 
114          * @param s
115          *          the newly created server.
116          */
117         public void serverCreated(Server s) {
118                 // default empty implementation...
119         }
120
121         /**
122          * Notify this plugin that an existing server has acheived connection to its
123          * remote host.
124          * 
125          * @param s
126          *          connected server.
127          */
128         public void serverConnected(Server s) {
129                 // default empty implementation...
130         }
131
132         /**
133          * Notify this plugin that an existing server has disconnected from its remote
134          * host.
135          * 
136          * @param s
137          *          disconnected server.
138          */
139         public void serverDisconnected(Server s) {
140                 // default empty implementation...
141         }
142
143         /**
144          * Notify this plugin that an existing server has been removed. No further
145          * call should be performed on this server.
146          * 
147          * @param s
148          *          server removed
149          */
150         public void serverRemoved(Server s) {
151                 // default empty implementation...
152         }
153
154         /**
155          * Notify this plugin that an external event has been triggered on it.
156          * 
157          * @param event
158          *          the event value.
159          */
160         public void externalEvent(Object event) {
161                 // default empty implementation...
162         }
163
164         /**
165          * Get the value from the name.
166          * 
167          * @param name
168          *          the value name.
169          * @return the plugin value for this name.
170          */
171         public Object getValue(Object name) {
172                 return null;
173         }
174
175 } // Plugin