Selaa lähdekoodia

Initial commit of parser stuff.

tags/0.6.3
Shane Mc Cormack 15 vuotta sitten
commit
6c97cd0869
100 muutettua tiedostoa jossa 10232 lisäystä ja 0 poistoa
  1. 281
    0
      src/com/dmdirc/parser/common/CallbackManager.java
  2. 45
    0
      src/com/dmdirc/parser/common/CallbackNotFoundException.java
  3. 285
    0
      src/com/dmdirc/parser/common/CallbackObject.java
  4. 186
    0
      src/com/dmdirc/parser/common/CallbackObjectSpecific.java
  5. 93
    0
      src/com/dmdirc/parser/common/ChannelListModeItem.java
  6. 53
    0
      src/com/dmdirc/parser/common/DefaultStringConverter.java
  7. 303
    0
      src/com/dmdirc/parser/common/IgnoreList.java
  8. 159
    0
      src/com/dmdirc/parser/common/MyInfo.java
  9. 177
    0
      src/com/dmdirc/parser/common/ParserError.java
  10. 37
    0
      src/com/dmdirc/parser/common/QueuePriority.java
  11. 91
    0
      src/com/dmdirc/parser/interfaces/ChannelClientInfo.java
  12. 193
    0
      src/com/dmdirc/parser/interfaces/ChannelInfo.java
  13. 86
    0
      src/com/dmdirc/parser/interfaces/ClientInfo.java
  14. 40
    0
      src/com/dmdirc/parser/interfaces/FakableArgument.java
  15. 41
    0
      src/com/dmdirc/parser/interfaces/FakableSource.java
  16. 77
    0
      src/com/dmdirc/parser/interfaces/LocalClientInfo.java
  17. 398
    0
      src/com/dmdirc/parser/interfaces/Parser.java
  18. 52
    0
      src/com/dmdirc/parser/interfaces/SecureParser.java
  19. 38
    0
      src/com/dmdirc/parser/interfaces/SpecificCallback.java
  20. 59
    0
      src/com/dmdirc/parser/interfaces/StringConverter.java
  21. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/AuthNoticeListener.java
  22. 41
    0
      src/com/dmdirc/parser/interfaces/callbacks/AwayStateListener.java
  23. 28
    0
      src/com/dmdirc/parser/interfaces/callbacks/CallbackInterface.java
  24. 58
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelActionListener.java
  25. 57
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelCtcpListener.java
  26. 57
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelCtcpReplyListener.java
  27. 46
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelJoinListener.java
  28. 56
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelKickListener.java
  29. 44
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelListModeListener.java
  30. 56
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelMessageListener.java
  31. 56
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelModeChangeListener.java
  32. 59
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelModeMessageListener.java
  33. 59
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelModeNoticeListener.java
  34. 42
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelNamesListener.java
  35. 47
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelNickChangeListener.java
  36. 56
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelNonUserModeChangeListener.java
  37. 56
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelNoticeListener.java
  38. 45
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelOtherAwayStateListener.java
  39. 47
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelPartListener.java
  40. 47
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelQuitListener.java
  41. 42
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelSelfJoinListener.java
  42. 56
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelSingleModeChangeListener.java
  43. 45
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelTopicListener.java
  44. 56
    0
      src/com/dmdirc/parser/interfaces/callbacks/ChannelUserModeChangeListener.java
  45. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/ConnectErrorListener.java
  46. 39
    0
      src/com/dmdirc/parser/interfaces/callbacks/DataInListener.java
  47. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/DataOutListener.java
  48. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/DebugInfoListener.java
  49. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/ErrorInfoListener.java
  50. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/InviteListener.java
  51. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/MotdEndListener.java
  52. 39
    0
      src/com/dmdirc/parser/interfaces/callbacks/MotdLineListener.java
  53. 39
    0
      src/com/dmdirc/parser/interfaces/callbacks/MotdStartListener.java
  54. 42
    0
      src/com/dmdirc/parser/interfaces/callbacks/NetworkDetectedListener.java
  55. 43
    0
      src/com/dmdirc/parser/interfaces/callbacks/NickChangeListener.java
  56. 39
    0
      src/com/dmdirc/parser/interfaces/callbacks/NickInUseListener.java
  57. 40
    0
      src/com/dmdirc/parser/interfaces/callbacks/NumericListener.java
  58. 43
    0
      src/com/dmdirc/parser/interfaces/callbacks/OtherAwayStateListener.java
  59. 38
    0
      src/com/dmdirc/parser/interfaces/callbacks/PasswordRequiredListener.java
  60. 38
    0
      src/com/dmdirc/parser/interfaces/callbacks/PingFailureListener.java
  61. 38
    0
      src/com/dmdirc/parser/interfaces/callbacks/PingSentListener.java
  62. 38
    0
      src/com/dmdirc/parser/interfaces/callbacks/PingSuccessListener.java
  63. 38
    0
      src/com/dmdirc/parser/interfaces/callbacks/Post005Listener.java
  64. 46
    0
      src/com/dmdirc/parser/interfaces/callbacks/PrivateActionListener.java
  65. 47
    0
      src/com/dmdirc/parser/interfaces/callbacks/PrivateCtcpListener.java
  66. 47
    0
      src/com/dmdirc/parser/interfaces/callbacks/PrivateCtcpReplyListener.java
  67. 46
    0
      src/com/dmdirc/parser/interfaces/callbacks/PrivateMessageListener.java
  68. 46
    0
      src/com/dmdirc/parser/interfaces/callbacks/PrivateNoticeListener.java
  69. 43
    0
      src/com/dmdirc/parser/interfaces/callbacks/QuitListener.java
  70. 39
    0
      src/com/dmdirc/parser/interfaces/callbacks/ServerErrorListener.java
  71. 38
    0
      src/com/dmdirc/parser/interfaces/callbacks/ServerReadyListener.java
  72. 38
    0
      src/com/dmdirc/parser/interfaces/callbacks/SocketCloseListener.java
  73. 45
    0
      src/com/dmdirc/parser/interfaces/callbacks/UnknownActionListener.java
  74. 46
    0
      src/com/dmdirc/parser/interfaces/callbacks/UnknownCtcpListener.java
  75. 46
    0
      src/com/dmdirc/parser/interfaces/callbacks/UnknownCtcpReplyListener.java
  76. 45
    0
      src/com/dmdirc/parser/interfaces/callbacks/UnknownMessageListener.java
  77. 45
    0
      src/com/dmdirc/parser/interfaces/callbacks/UnknownNoticeListener.java
  78. 46
    0
      src/com/dmdirc/parser/interfaces/callbacks/UserModeChangeListener.java
  79. 44
    0
      src/com/dmdirc/parser/interfaces/callbacks/UserModeDiscoveryListener.java
  80. 44
    0
      src/com/dmdirc/parser/interfaces/callbacks/WallDesyncListener.java
  81. 44
    0
      src/com/dmdirc/parser/interfaces/callbacks/WallopListener.java
  82. 44
    0
      src/com/dmdirc/parser/interfaces/callbacks/WalluserListener.java
  83. 29
    0
      src/com/dmdirc/parser/interfaces/callbacks/package-info.java
  84. 130
    0
      src/com/dmdirc/parser/irc/IRCAuthenticator.java
  85. 55
    0
      src/com/dmdirc/parser/irc/IRCCallbackManager.java
  86. 65
    0
      src/com/dmdirc/parser/irc/IRCCallbackObject.java
  87. 71
    0
      src/com/dmdirc/parser/irc/IRCCallbackObjectSpecific.java
  88. 207
    0
      src/com/dmdirc/parser/irc/IRCChannelClientInfo.java
  89. 742
    0
      src/com/dmdirc/parser/irc/IRCChannelInfo.java
  90. 428
    0
      src/com/dmdirc/parser/irc/IRCClientInfo.java
  91. 2066
    0
      src/com/dmdirc/parser/irc/IRCParser.java
  92. 192
    0
      src/com/dmdirc/parser/irc/IRCProcessor.java
  93. 132
    0
      src/com/dmdirc/parser/irc/IRCStringConverter.java
  94. 167
    0
      src/com/dmdirc/parser/irc/Logging.java
  95. 55
    0
      src/com/dmdirc/parser/irc/PingTimer.java
  96. 101
    0
      src/com/dmdirc/parser/irc/Process001.java
  97. 159
    0
      src/com/dmdirc/parser/irc/Process004005.java
  98. 72
    0
      src/com/dmdirc/parser/irc/Process464.java
  99. 78
    0
      src/com/dmdirc/parser/irc/ProcessAway.java
  100. 0
    0
      src/com/dmdirc/parser/irc/ProcessInvite.java

+ 281
- 0
src/com/dmdirc/parser/common/CallbackManager.java Näytä tiedosto

@@ -0,0 +1,281 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+import com.dmdirc.parser.interfaces.callbacks.*;
28
+
29
+import java.util.Hashtable;
30
+import java.util.Map;
31
+
32
+/**
33
+ * IRC Parser Callback Manager.
34
+ * Manages adding/removing/calling callbacks.
35
+ *
36
+ * @param <T> The type of parser which this manager managers callbacks for
37
+ * @author            Shane Mc Cormack
38
+ */
39
+public abstract class CallbackManager<T extends Parser> {
40
+
41
+    protected static final Class[] CLASSES = {
42
+        AwayStateListener.class, OtherAwayStateListener.class,
43
+        ChannelOtherAwayStateListener.class, ChannelActionListener.class,
44
+        ChannelCtcpListener.class, ChannelCtcpReplyListener.class,
45
+        ChannelListModeListener.class, ChannelNamesListener.class,
46
+        ChannelJoinListener.class, ChannelKickListener.class,
47
+        ChannelMessageListener.class, ChannelModeChangeListener.class,
48
+        ChannelNickChangeListener.class, ChannelNonUserModeChangeListener.class,
49
+	ChannelModeMessageListener.class, ChannelModeNoticeListener.class,
50
+        ChannelNoticeListener.class, ChannelPartListener.class, ChannelQuitListener.class,
51
+        ChannelSelfJoinListener.class, ChannelSingleModeChangeListener.class,
52
+        ChannelTopicListener.class, ChannelUserModeChangeListener.class,
53
+        ConnectErrorListener.class, DataInListener.class, DataOutListener.class,
54
+        DebugInfoListener.class, ErrorInfoListener.class,
55
+        NetworkDetectedListener.class, InviteListener.class,
56
+        MotdEndListener.class, MotdLineListener.class, MotdStartListener.class,
57
+        NickChangeListener.class, NickInUseListener.class,
58
+        AuthNoticeListener.class, NumericListener.class,
59
+        PasswordRequiredListener.class, PingFailureListener.class,
60
+        PingSuccessListener.class, PingSentListener.class,
61
+        PrivateActionListener.class, PrivateCtcpListener.class,
62
+        PrivateCtcpReplyListener.class, PrivateMessageListener.class,
63
+        PrivateNoticeListener.class, Post005Listener.class, QuitListener.class,
64
+        ServerErrorListener.class, ServerReadyListener.class,
65
+        SocketCloseListener.class, UnknownActionListener.class,
66
+        UnknownCtcpListener.class, UnknownCtcpReplyListener.class,
67
+        UnknownMessageListener.class, UnknownNoticeListener.class,
68
+        UserModeChangeListener.class, UserModeDiscoveryListener.class,
69
+        WallDesyncListener.class, WallopListener.class, WalluserListener.class,
70
+    };
71
+    
72
+    /** Hashtable used to store the different types of callback known. */
73
+    private final Map<Class<? extends CallbackInterface>, CallbackObject> callbackHash
74
+            = new Hashtable<Class<? extends CallbackInterface>, CallbackObject>();
75
+
76
+    /**
77
+     * Constructor to create a CallbackManager.
78
+     *
79
+     * @param parser Parser that owns this callback manager.
80
+     */
81
+    public CallbackManager(final T parser) {
82
+        initialise(parser);
83
+    }
84
+
85
+    /**
86
+     * Initialises this callback manager.
87
+     *
88
+     * @param parser The parser associated with this CallbackManager
89
+     */
90
+    protected void initialise(T parser) {
91
+        for (Class<?> type : CLASSES) {
92
+            if (type.isAnnotationPresent(SpecificCallback.class)) {
93
+                addCallbackType(getSpecificCallbackObject(parser, type));
94
+            } else {
95
+                addCallbackType(getCallbackObject(parser, type));
96
+            }
97
+        }
98
+    }
99
+
100
+    /**
101
+     * Retrieves a relevant {@link CallbackObject} for the specified type.
102
+     *
103
+     * @param parser The parser that this manager belongs to
104
+     * @param type The type of callback to create an object for
105
+     * @return The relevant CallbackObject
106
+     */
107
+    protected abstract CallbackObject getCallbackObject(T parser, Class<?> type);
108
+
109
+    /**
110
+     * Retrieves a relevant {@link CallbackObjectSpecific} for the specified type.
111
+     *
112
+     * @param parser The parser that this manager belongs to
113
+     * @param type The type of callback to create an object for
114
+     * @return The relevant CallbackObject
115
+     */
116
+    protected abstract CallbackObjectSpecific getSpecificCallbackObject(T parser, Class<?> type);
117
+
118
+    /**
119
+     * Add new callback type.
120
+     *
121
+     * @param callback CallbackObject subclass for the callback.
122
+     * @return if adding succeeded or not.
123
+     */
124
+    public boolean addCallbackType(final CallbackObject callback) {
125
+        if (!callbackHash.containsKey(callback.getType())) {
126
+            callbackHash.put(callback.getType(), callback);
127
+            return true;
128
+        }
129
+
130
+        return false;
131
+    }
132
+
133
+    /**
134
+     * Remove a callback type.
135
+     *
136
+     * @param callback CallbackObject subclass to remove.
137
+     * @return if removal succeeded or not.
138
+     */
139
+    public boolean delCallbackType(final CallbackObject callback) {
140
+        if (callbackHash.containsKey(callback.getType())) {
141
+            callbackHash.remove(callback.getType());
142
+            return true;
143
+        }
144
+
145
+        return false;
146
+    }
147
+
148
+    /**
149
+     * Get reference to callback object.
150
+     *
151
+     * @param callback Name of type of callback object.
152
+     * @return CallbackObject returns the callback object for this type
153
+     */
154
+    public CallbackObject getCallbackType(final Class<? extends CallbackInterface> callback) {
155
+        if (!callbackHash.containsKey(callback)) {
156
+            throw new CallbackNotFoundException("Callback not found: " + callback.getName());
157
+        }
158
+
159
+        return callbackHash.get(callback);
160
+    }
161
+
162
+    /**
163
+     * Remove all callbacks associated with a specific object.
164
+     *
165
+     * @param o instance of ICallbackInterface to remove.
166
+     */
167
+    public void delAllCallback(final CallbackInterface o) {
168
+        for (CallbackObject cb : callbackHash.values()) {
169
+            if (cb != null) {
170
+                cb.del(o);
171
+            }
172
+        }
173
+    }
174
+
175
+    /**
176
+     * Add all callbacks.
177
+     *
178
+     * @param o instance of ICallbackInterface to add.
179
+     */
180
+    public void addAllCallback(final CallbackInterface o) {
181
+        for (CallbackObject cb : callbackHash.values()) {
182
+            if (cb != null) {
183
+                cb.add(o);
184
+            }
185
+        }
186
+    }
187
+
188
+    /**
189
+     * Add a callback.
190
+     * This method will throw a CallbackNotFoundException if the callback does not exist.
191
+     *
192
+     * @param <T> The type of callback
193
+     * @param callback Type of callback object
194
+     * @param o instance of ICallbackInterface to add.
195
+     * @throws CallbackNotFoundException If callback is not found.
196
+     * @throws NullPointerException If 'o' is null
197
+     */
198
+    public <T extends CallbackInterface> void addCallback(
199
+            final Class<T> callback, final T o) throws CallbackNotFoundException {
200
+        if (o == null) {
201
+            throw new NullPointerException("CallbackInterface is null");
202
+        }
203
+
204
+        final CallbackObject cb = getCallbackType(callback);
205
+
206
+        if (cb != null) {
207
+            cb.add(o);
208
+        }
209
+    }
210
+
211
+    /**
212
+     * Add a callback with a specific target.
213
+     * This method will throw a CallbackNotFoundException if the callback does not exist.
214
+     *
215
+     * @param <T> The type of callback
216
+     * @param callback Type of callback object.
217
+     * @param o instance of ICallbackInterface to add.
218
+     * @param target Parameter to specify that a callback should only fire for specific things
219
+     * @throws CallbackNotFoundException If callback is not found.
220
+     * @throws NullPointerException If 'o' is null
221
+     */
222
+    public <T extends CallbackInterface> void addCallback(
223
+            final Class<T> callback,
224
+            final T o, final String target) throws CallbackNotFoundException {
225
+        if (o == null) {
226
+            throw new NullPointerException("CallbackInterface is null");
227
+        }
228
+        
229
+        ((CallbackObjectSpecific) getCallbackType(callback)).add(o, target);
230
+    }
231
+
232
+    /**
233
+     * Add a callback without an exception.
234
+     * This should be used if a callback is not essential for execution (ie the DebugOut callback)
235
+     *
236
+     * @param <T> The type of callback object
237
+     * @param callback Type of callback object.
238
+     * @param o instance of ICallbackInterface to add.
239
+     * @return true/false if the callback was added or not.
240
+     */
241
+    public <T extends CallbackInterface> boolean addNonCriticalCallback(
242
+            final Class<T> callback, final T o) {
243
+        try {
244
+            addCallback(callback, o);
245
+            return true;
246
+        } catch (CallbackNotFoundException e) {
247
+            return false;
248
+        }
249
+    }
250
+
251
+    /**
252
+     * Add a callback with a specific target.
253
+     * This should be used if a callback is not essential for execution
254
+     *
255
+     * @param <T> The type of callback
256
+     * @param callback Type of callback object.
257
+     * @param o instance of ICallbackInterface to add.
258
+     * @param target Parameter to specify that a callback should only fire for specific things
259
+     * @return true/false if the callback was added or not.
260
+     */
261
+    public <T extends CallbackInterface> boolean addNonCriticalCallback(
262
+            final Class<T> callback, final T o, final String target) {
263
+        try {
264
+            addCallback(callback, o, target);
265
+            return true;
266
+        } catch (CallbackNotFoundException e) {
267
+            return false;
268
+        }
269
+    }
270
+
271
+    /**
272
+     * Remove a callback.
273
+     *
274
+     * @param callback Type of callback object.
275
+     * @param o instance of ICallbackInterface to remove.
276
+     */
277
+    public void delCallback(final Class<? extends CallbackInterface> callback,
278
+            final CallbackInterface o) {
279
+        getCallbackType(callback).del(o);
280
+    }
281
+}

+ 45
- 0
src/com/dmdirc/parser/common/CallbackNotFoundException.java Näytä tiedosto

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+/**
26
+ * IRC Parser Callback Exception.
27
+ *
28
+ * @author            Shane Mc Cormack
29
+ */
30
+public class CallbackNotFoundException extends RuntimeException {
31
+	/**
32
+	 * A version number for this class. It should be changed whenever the class
33
+	 * structure is changed (or anything else that would prevent serialized
34
+	 * objects being unserialized with the new class).
35
+	 */
36
+	private static final long serialVersionUID = 1;
37
+	
38
+	/**
39
+	 * Create a new CallbackNotFound Exception.
40
+	 *
41
+	 * @param message Reason for exception
42
+	 */
43
+	public CallbackNotFoundException(final String message) { super(message); }
44
+
45
+}

+ 285
- 0
src/com/dmdirc/parser/common/CallbackObject.java Näytä tiedosto

@@ -0,0 +1,285 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import com.dmdirc.parser.interfaces.FakableArgument;
26
+import com.dmdirc.parser.interfaces.FakableSource;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
29
+import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
30
+
31
+import java.lang.annotation.Annotation;
32
+import java.lang.reflect.Constructor;
33
+import java.lang.reflect.InvocationTargetException;
34
+import java.lang.reflect.Method;
35
+import java.util.ArrayList;
36
+import java.util.HashMap;
37
+import java.util.List;
38
+import java.util.Map;
39
+
40
+/**
41
+ * CallbackObject.
42
+ * Superclass for all callback types.
43
+ *
44
+ * @author            Shane Mc Cormack
45
+ */
46
+public abstract class CallbackObject {
47
+
48
+    /** The type of callback that this object is operating with. */
49
+    protected final Class<? extends CallbackInterface> type;
50
+
51
+    /** Arraylist for storing callback information related to the callback. */
52
+    protected final List<CallbackInterface> callbackInfo = new ArrayList<CallbackInterface>();
53
+
54
+    /** Reference to the Parser that owns this callback. */
55
+    protected Parser myParser;
56
+
57
+    /** Reference to the CallbackManager in charge of this callback. */
58
+    protected CallbackManager<?> myManager;
59
+
60
+    /**
61
+     * Create a new instance of the Callback Object.
62
+     *
63
+     * @param parser Parser That owns this callback
64
+     * @param manager CallbackManager that is in charge of this callback
65
+     * @param type The type of callback to use
66
+     * @since 0.6.3m1
67
+     */
68
+    public CallbackObject(final Parser parser, final CallbackManager<?> manager,
69
+            final Class<? extends CallbackInterface> type) {
70
+        this.myParser = parser;
71
+        this.myManager = manager;
72
+        this.type = type;
73
+    }
74
+
75
+    /**
76
+     * Add a callback pointer to the appropriate ArrayList.
77
+     *
78
+     * @param eMethod OBject to callback to.
79
+     */
80
+    protected final void addCallback(final CallbackInterface eMethod) {
81
+        if (!callbackInfo.contains(eMethod)) {
82
+            callbackInfo.add(eMethod);
83
+        }
84
+    }
85
+
86
+    /**
87
+     * Delete a callback pointer from the appropriate ArrayList.
88
+     *
89
+     * @param eMethod Object that was being called back to.
90
+     */
91
+    protected final void delCallback(final CallbackInterface eMethod) {
92
+        callbackInfo.remove(eMethod);
93
+    }
94
+
95
+    /**
96
+     * Call the OnErrorInfo callback.
97
+     *
98
+     * @param errorInfo ParserError object to pass as error.
99
+     * @return true if error call succeeded, false otherwise
100
+     */
101
+    protected final boolean callErrorInfo(final ParserError errorInfo) {
102
+        return myManager.getCallbackType(ErrorInfoListener.class).call(errorInfo);
103
+    }
104
+
105
+    /**
106
+     * Add a new callback.
107
+     *
108
+     * @param eMethod Object to callback to.
109
+     */
110
+    public void add(final CallbackInterface eMethod) {
111
+        addCallback(eMethod);
112
+    }
113
+
114
+    /**
115
+     * Remove a callback.
116
+     *
117
+     * @param eMethod Object to remove callback to.
118
+     */
119
+    public void del(final CallbackInterface eMethod) {
120
+        delCallback(eMethod);
121
+    }
122
+
123
+    /**
124
+     * Retrieves the type of callback that this callback object is for.
125
+     *
126
+     * @return This object's type
127
+     * @since 0.6.3m2
128
+     */
129
+    public Class<? extends CallbackInterface> getType() {
130
+        return type;
131
+    }
132
+
133
+    /**
134
+     * Actually calls this callback. The specified arguments must match those
135
+     * specified in the callback's interface, or an error will be raised.
136
+     *
137
+     * @param args The arguments to pass to the callback implementation
138
+     * @return True if a method was called, false otherwise
139
+     */
140
+    public boolean call(final Object... args) {
141
+        boolean bResult = false;
142
+
143
+        final Object[] newArgs = new Object[args.length + 1];
144
+        System.arraycopy(args, 0, newArgs, 1, args.length);
145
+        newArgs[0] = myParser;
146
+
147
+        createFakeArgs(newArgs);
148
+
149
+        for (CallbackInterface iface : new ArrayList<CallbackInterface>(callbackInfo)) {
150
+            try {
151
+                type.getMethods()[0].invoke(iface, newArgs);
152
+            } catch (Exception e) {
153
+                final ParserError ei = new ParserError(ParserError.ERROR_ERROR,
154
+                        "Exception in callback (" + e.getMessage() + ")",
155
+                        myParser.getLastLine());
156
+                ei.setException(e);
157
+                callErrorInfo(ei);
158
+            }
159
+            bResult = true;
160
+        }
161
+        return bResult;
162
+    }
163
+
164
+    /**
165
+     * Replaces all null entries in the specified array with fake values,
166
+     * if the corresponding parameter of this callback's type is marked with
167
+     * the {@link FakableArgument} annotation. The fake classes are constructed
168
+     * by using parameters designated {@link FakableSource}.
169
+     *
170
+     * @param args The arguments to be faked
171
+     */
172
+    protected void createFakeArgs(final Object[] args) {
173
+        int i = 0;
174
+
175
+        for (Annotation[] anns : type.getMethods()[0].getParameterAnnotations()) {
176
+            for (Annotation ann : anns) {
177
+                if (ann.annotationType().equals(FakableArgument.class) && args[i] == null) {
178
+                    args[i] = getFakeArg(args, type.getMethods()[0].getParameterTypes()[i]);
179
+                }
180
+            }
181
+
182
+            i++;
183
+        }
184
+    }
185
+
186
+    /**
187
+     * Tries to create fake argument of the specified target class, by using
188
+     * {@link FakableSource} denoted parameters from the specified arg array.
189
+     *
190
+     * If an argument is missing, the method attempts to create a fake instance
191
+     * by recursing into this method again. Note that this could cause an
192
+     * infinite recursion in cases of cyclic dependencies. If recursion fails,
193
+     * the constructor is skipped.
194
+     *
195
+     * If the created object has a <code>setFake(boolean)</code> method, it
196
+     * is automatically invoked with an argument of <code>true</code>.
197
+     *
198
+     * @param args The arguments array to use for sources
199
+     * @param target The class that should be constructed
200
+     * @return An instance of the target class, or null on failure
201
+     */
202
+    protected Object getFakeArg(final Object[] args, final Class<?> target) {
203
+        final Map<Class<?>, Object> sources = new HashMap<Class<?>, Object>();
204
+        int i = 0;
205
+
206
+        for (Annotation[] anns : type.getMethods()[0].getParameterAnnotations()) {
207
+            for (Annotation ann : anns) {
208
+                if (ann.annotationType().equals(FakableSource.class)) {
209
+                    Class<?> argType = type.getMethods()[0].getParameterTypes()[i];
210
+
211
+                    sources.put(argType, args[i]);
212
+                }
213
+            }
214
+
215
+            i++;
216
+        }
217
+
218
+        final Class<?> actualTarget = getImplementation(target);
219
+
220
+        for (Constructor<?> ctor : actualTarget.getConstructors()) {
221
+            Object[] params = new Object[ctor.getParameterTypes().length];
222
+
223
+            i = 0;
224
+            Object param;
225
+            boolean failed = false;
226
+
227
+            for (Class<?> needed : ctor.getParameterTypes()) {
228
+                boolean found = false;
229
+
230
+                for (Class<?> source : sources.keySet()) {
231
+                    if (source.isAssignableFrom(needed)) {
232
+                        params[i] = sources.get(source);
233
+                        found = true;
234
+                    }
235
+                }
236
+
237
+                if (!found && (param = getFakeArg(args, needed)) != null) {
238
+                    params[i] = param;
239
+                } else if (!found) {
240
+                    failed = true;
241
+                }
242
+
243
+                i++;
244
+            }
245
+
246
+            if (!failed) {
247
+                try {
248
+                    final Object instance = ctor.newInstance(params);
249
+
250
+                    for (Method method : actualTarget.getMethods()) {
251
+                        if (method.getName().equals("setFake")
252
+                                && method.getParameterTypes().length == 1
253
+                                && method.getParameterTypes()[0].equals(Boolean.TYPE)) {
254
+                            method.invoke(instance, true);
255
+                        }
256
+                    }
257
+
258
+                    return instance;
259
+                } catch (InstantiationException ex) {
260
+                    // Do nothing
261
+                } catch (IllegalAccessException ex) {
262
+                    // Do nothing
263
+                } catch (IllegalArgumentException ex) {
264
+                    // Do nothing
265
+                } catch (InvocationTargetException ex) {
266
+                    // Do nothing
267
+                }
268
+            }
269
+        }
270
+
271
+        return null;
272
+    }
273
+
274
+    /**
275
+     * Returns the concrete class which should be instansiated if this
276
+     * callback object desires an instance of the specified type. Generally,
277
+     * this will translate the common interfaces to specific parser-dependent
278
+     * implementations.
279
+     *
280
+     * @param type The type to be instansiated
281
+     * @return A concrete implementation of that type
282
+     */
283
+    protected abstract Class<?> getImplementation(Class<?> type);
284
+    
285
+}

+ 186
- 0
src/com/dmdirc/parser/common/CallbackObjectSpecific.java Näytä tiedosto

@@ -0,0 +1,186 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+package com.dmdirc.parser.common;
23
+
24
+import com.dmdirc.parser.interfaces.SpecificCallback;
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.ClientInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
29
+
30
+import java.util.ArrayList;
31
+import java.util.Hashtable;
32
+
33
+/**
34
+ * CallbackObjectSpecific.
35
+ * Superclass for all callback types that have a "specific" target.
36
+ *
37
+ * @author            Shane Mc Cormack
38
+ */
39
+public abstract class CallbackObjectSpecific extends CallbackObject {
40
+
41
+    /** Hashtable for storing specific information for callback. */
42
+    protected volatile Hashtable<CallbackInterface, String> specificData
43
+            = new Hashtable<CallbackInterface, String>();
44
+
45
+    /**
46
+     * Create a new instance of the Callback Object.
47
+     *
48
+     * @param parser Parser That owns this callback
49
+     * @param manager CallbackManager that is in charge of this callback
50
+     * @param type The type of callback to use
51
+     * @since 0.6.3m1
52
+     */
53
+    public CallbackObjectSpecific(final Parser parser, final CallbackManager<?> manager,
54
+            final Class<? extends CallbackInterface> type) {
55
+        super(parser, manager, type);
56
+    }
57
+
58
+    /**
59
+     * Used to check if a channel matches the specificData.
60
+     *
61
+     * @param eMethod Object that is being called back to
62
+     * @param cChannel ChannelInfo object for the channel to test
63
+     * @return true if channel given matches the specifics for the method given
64
+     */
65
+    protected boolean isValidChan(final CallbackInterface eMethod, final ChannelInfo cChannel) {
66
+        if (specificData.containsKey(eMethod)) {
67
+            if (!myParser.getStringConverter().equalsIgnoreCase(cChannel.getName(),
68
+                    specificData.get(eMethod))) {
69
+                return false;
70
+            }
71
+        }
72
+        return true;
73
+    }
74
+
75
+    /**
76
+     * Used to check if a hostname matches the specificData.
77
+     *
78
+     * @param eMethod Object that is being called back to
79
+     * @param sHost Hostname of user that sent the query
80
+     * @return true if host given matches the specifics for the method given
81
+     */
82
+    protected boolean isValidUser(final CallbackInterface eMethod, final String sHost) {
83
+        final String nickname = translateHostname(sHost);
84
+        if (specificData.containsKey(eMethod)) {
85
+            if (!myParser.getStringConverter().equalsIgnoreCase(nickname,
86
+                    specificData.get(eMethod))) {
87
+                return false;
88
+            }
89
+        }
90
+        return true;
91
+    }
92
+
93
+    /**
94
+     * Translates the specified hostname into the form which is used to
95
+     * register specific callbacks (e.g. nickname).
96
+     *
97
+     * @param hostname The hostname to be parsed
98
+     * @return The translated hostname
99
+     */
100
+    protected abstract String translateHostname(final String hostname);
101
+
102
+    // We override the default add method to make sure that any add with no
103
+    // specifics will have the specific data removed.
104
+    /**
105
+     * Add a new callback.
106
+     *
107
+     * @param eMethod Object to callback to.
108
+     */
109
+    @Override
110
+    public void add(final CallbackInterface eMethod) {
111
+        addCallback(eMethod);
112
+        if (specificData.containsKey(eMethod)) {
113
+            specificData.remove(eMethod);
114
+        }
115
+    }
116
+
117
+    /**
118
+     * Add a new callback with a specific target.
119
+     *
120
+     * @param eMethod Object to callback to.
121
+     * @param specificTarget Target that must match for callback to be called.
122
+     */
123
+    public void add(final CallbackInterface eMethod, final String specificTarget) {
124
+        add(eMethod);
125
+        if (!specificTarget.isEmpty()) {
126
+            specificData.put(eMethod, specificTarget);
127
+        }
128
+    }
129
+
130
+    /**
131
+     * Remove a callback.
132
+     *
133
+     * @param eMethod Object to remove callback to.
134
+     */
135
+    @Override
136
+    public void del(final CallbackInterface eMethod) {
137
+        delCallback(eMethod);
138
+        if (specificData.containsKey(eMethod)) {
139
+            specificData.remove(eMethod);
140
+        }
141
+    }
142
+
143
+    /**
144
+     * Actually calls this callback. The specified arguments must match those
145
+     * specified in the callback's interface, or an error will be raised.
146
+     *
147
+     * @param args The arguments to pass to the callback implementation
148
+     * @return True if a method was called, false otherwise
149
+     */
150
+    @Override
151
+    public boolean call(final Object... args) {
152
+        boolean bResult = false;
153
+
154
+        final Object[] newArgs = new Object[args.length + 1];
155
+        System.arraycopy(args, 0, newArgs, 1, args.length);
156
+        newArgs[0] = myParser;
157
+
158
+        createFakeArgs(newArgs);
159
+
160
+        for (CallbackInterface iface : new ArrayList<CallbackInterface>(callbackInfo)) {
161
+            if (type.isAnnotationPresent(SpecificCallback.class) &&
162
+                    ((args[0] instanceof ClientInfo
163
+                    && !isValidUser(iface, ((ClientInfo) args[0]).getHostname()))
164
+                    || (args[0] instanceof ChannelInfo
165
+                    && !isValidChan(iface, (ChannelInfo) args[0]))
166
+                    || (!(args[0] instanceof ClientInfo
167
+                    || args[0] instanceof ChannelInfo) &&
168
+                    args[args.length - 1] instanceof String
169
+                    && !isValidUser(iface, (String) args[args.length - 1])))) {
170
+                continue;
171
+            }
172
+
173
+            try {
174
+                type.getMethods()[0].invoke(iface, newArgs);
175
+            } catch (Exception e) {
176
+                final ParserError ei = new ParserError(ParserError.ERROR_ERROR,
177
+                        "Exception in callback (" + e.getMessage() + ")",
178
+                        myParser.getLastLine());
179
+                ei.setException(e);
180
+                callErrorInfo(ei);
181
+            }
182
+            bResult = true;
183
+        }
184
+        return bResult;
185
+    }
186
+}

+ 93
- 0
src/com/dmdirc/parser/common/ChannelListModeItem.java Näytä tiedosto

@@ -0,0 +1,93 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+/**
26
+ * Contains Channel List Mode information.
27
+ * 
28
+ * @author Shane Mc Cormack
29
+ * @author Chris Smith
30
+ * @see IRCParser
31
+ */
32
+public final class ChannelListModeItem {
33
+
34
+	/** The Item itself. */
35
+	private final String myItem;
36
+	
37
+	/** The Time the item was created. */
38
+	private final long myTime;
39
+	
40
+	/** The Person who created the item. */
41
+	private final String myOwner;
42
+	
43
+	/**
44
+	 * Create a new Item.
45
+	 *
46
+	 * @param item The item (ie: test!joe@user.com)
47
+	 * @param owner The owner (ie: Dataforce)
48
+	 * @param time The Time (ie: 1173389295)
49
+	 */
50
+	public ChannelListModeItem(final String item, final String owner, final long time) {
51
+		myItem = item;
52
+		myTime = time;
53
+
54
+		if (!owner.isEmpty() && owner.charAt(0) == ':') {
55
+			myOwner = owner.substring(1);
56
+		} else {
57
+			myOwner = owner;
58
+		}
59
+	}
60
+	
61
+	/**
62
+	 * Get The Item itself.
63
+	 *
64
+	 * @return The Item itself.
65
+	 */
66
+	public String getItem() { return myItem; }
67
+	
68
+	/**
69
+	 * Get The Person who created the item.
70
+	 *
71
+	 * @return The Person who created the item.
72
+	 */
73
+	public String getOwner() { return myOwner; }
74
+	
75
+	/**
76
+	 * Get The Time the item was created.
77
+	 *
78
+	 * @return The Time the item was created.
79
+	 */
80
+	public long getTime() { return myTime; }
81
+	
82
+	/**
83
+	* Returns a String representation of this object.
84
+	*
85
+	* @return String representation of this object
86
+	*/
87
+	@Override
88
+	public String toString() {
89
+		return getItem();
90
+	}
91
+
92
+}
93
+

+ 53
- 0
src/com/dmdirc/parser/common/DefaultStringConverter.java Näytä tiedosto

@@ -0,0 +1,53 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import com.dmdirc.parser.interfaces.StringConverter;
26
+
27
+/**
28
+ * A {@link StringConverter} that uses the system's default charset.
29
+ *
30
+ * @since 0.6.3m2
31
+ * @author chris
32
+ */
33
+public class DefaultStringConverter implements StringConverter {
34
+
35
+    /** {@inheritDoc} */
36
+    @Override
37
+    public String toLowerCase(String input) {
38
+        return input.toLowerCase();
39
+    }
40
+
41
+    /** {@inheritDoc} */
42
+    @Override
43
+    public String toUpperCase(String input) {
44
+        return input.toUpperCase();
45
+    }
46
+
47
+    /** {@inheritDoc} */
48
+    @Override
49
+    public boolean equalsIgnoreCase(String first, String second) {
50
+        return first.equalsIgnoreCase(second);
51
+    }
52
+
53
+}

+ 303
- 0
src/com/dmdirc/parser/common/IgnoreList.java Näytä tiedosto

@@ -0,0 +1,303 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+import java.util.ArrayList;
26
+import java.util.List;
27
+import java.util.regex.PatternSyntaxException;
28
+
29
+/**
30
+ * Parser Ignore list.
31
+ *
32
+ * @author Shane Mc Cormack
33
+ */
34
+public class IgnoreList {
35
+
36
+	/** Arraylist storing ignore patterns. */
37
+	protected final List<String> ignoreInfo = new ArrayList<String>();
38
+
39
+	/**
40
+	 * Creates a new instance of RegexStringList.
41
+	 */
42
+	public IgnoreList() {
43
+		// Do nothing
44
+	}
45
+
46
+	/**
47
+	 * Creates a new instance of RegexStringList, with the specified items.
48
+	 *
49
+	 * @param items Items to add to this RegexStringList
50
+	 */
51
+	public IgnoreList(final List<String> items) {
52
+		addAll(items);
53
+	}
54
+
55
+	/**
56
+	 * Add a new ignore pattern to the ignore list.
57
+	 *
58
+	 * @param pattern Regex syntax for the ignore (Pattern is matched case-insensitively as ^pattern$)
59
+	 */
60
+	public void add(final String pattern) {
61
+		for (String target : ignoreInfo) {
62
+			if (pattern.equalsIgnoreCase(target)) {
63
+				return;
64
+			}
65
+		}
66
+
67
+		ignoreInfo.add(pattern);
68
+	}
69
+
70
+	/**
71
+	 * Adds a set of patterns to the list.
72
+	 *
73
+	 * @param patterns A list of patterns to be added
74
+	 */
75
+	public void addAll(final List<String> patterns) {
76
+		for (String pattern : patterns) {
77
+			add(pattern);
78
+		}
79
+	}
80
+
81
+	/**
82
+	 * Delete an ignore from the list.
83
+	 *
84
+	 * @param position Position in the list to remove
85
+	 */
86
+	public void remove(final int position) {
87
+		if (position < this.count()) {
88
+			ignoreInfo.remove(position);
89
+		}
90
+	}
91
+
92
+	/**
93
+	 * Clear the ignore list.
94
+	 */
95
+	public void clear() {
96
+		ignoreInfo.clear();
97
+	}
98
+
99
+	/**
100
+	 * Check if a string matches any of the ignores in the list.
101
+	 *
102
+	 * @param check String to check (Patterns are matched case-insensitively as ^pattern$)
103
+	 * @return integer showing the position of the first match in the ignore list (-1 if none)
104
+	 * @throws PatternSyntaxException if one of the items in the list is an invalid regex
105
+	 */
106
+	public int matches(final String check) throws PatternSyntaxException {
107
+		for (int i = 0; i < this.count(); ++i) {
108
+			if (check.matches("(?i)"+this.get(i))) {
109
+				return i;
110
+			}
111
+		}
112
+		return -1;
113
+	}
114
+
115
+	/**
116
+	 * Check if a string matches a specific ignore in the list.
117
+	 *
118
+	 * @param position Position to check
119
+	 * @param check String to check (Patterns are matched case-insensitively as ^pattern$)
120
+	 * @return boolean true/false
121
+	 * @throws PatternSyntaxException if the item is an invalid regex
122
+	 */
123
+	public boolean matches(final int position, final String check) throws PatternSyntaxException {
124
+		if (position < this.count()) {
125
+			return check.matches("(?i)"+this.get(position));
126
+		} else {
127
+			return false;
128
+		}
129
+	}
130
+
131
+	/**
132
+	 * Get the ignore pattern in a given position in the list.
133
+	 *
134
+	 * @param position Position to check
135
+	 * @return String showing the pattern. ("" if position isn't valid)
136
+	 */
137
+	public String get(final int position) {
138
+		if (position < this.count()) {
139
+			return ignoreInfo.get(position);
140
+		} else {
141
+			return "";
142
+		}
143
+	}
144
+
145
+	/**
146
+	 * Change the ignore pattern in a given position in the list.
147
+	 *
148
+	 * @param position Position to change
149
+	 * @param pattern New pattern
150
+	 */
151
+	public void set(final int position, final String pattern) {
152
+		if (position < this.count()) {
153
+			ignoreInfo.set(position, pattern);
154
+		}
155
+	}
156
+
157
+	/**
158
+	 * Get the amount of ignores in the list.
159
+	 *
160
+	 * @return int showing the number of ignores
161
+	 */
162
+	public int count() {
163
+		return ignoreInfo.size();
164
+	}
165
+
166
+    /**
167
+     * Adds the specified simple pattern to this ignore list.
168
+     *
169
+     * @param pattern The simple pattern to be added
170
+     */
171
+    public void addSimple(final String pattern) {
172
+        add(simpleToRegex(pattern));
173
+    }
174
+
175
+    /**
176
+     * Determines if this list can be converted to a simple list.
177
+     *
178
+     * @return True if this list can be converted, false otherwise.
179
+     */
180
+    public boolean canConvert() {
181
+        try {
182
+            getSimpleList();
183
+            return true;
184
+        } catch (UnsupportedOperationException ex) {
185
+            return false;
186
+        }
187
+    }
188
+
189
+    /**
190
+     * Retrieves a list of regular expressions in this ignore list.
191
+     *
192
+     * @return All expressions in this ignore list
193
+     */
194
+    public List<String> getRegexList() {
195
+        return new ArrayList<String>(ignoreInfo);
196
+    }
197
+
198
+    /**
199
+     * Retrieves a list of simple expressions in this ignore list.
200
+     *
201
+     * @return All expressions in this ignore list, converted to simple expressions
202
+     * @throws UnsupportedOperationException if an expression can't be converted
203
+     */
204
+    public List<String> getSimpleList() throws UnsupportedOperationException {
205
+        final List<String> res = new ArrayList<String>();
206
+
207
+        for (String regex : ignoreInfo) {
208
+            res.add(regexToSimple(regex));
209
+        }
210
+
211
+        return res;
212
+    }
213
+
214
+    /**
215
+     * Converts a regular expression into a simple expression.
216
+     *
217
+     * @param regex The regular expression to be converted
218
+     * @return A simple expression corresponding to the regex
219
+     * @throws UnsupportedOperationException if the regex cannot be converted
220
+     */
221
+    protected static String regexToSimple(final String regex)
222
+            throws UnsupportedOperationException {
223
+        final StringBuilder res = new StringBuilder(regex.length());
224
+        boolean escaped = false;
225
+        boolean inchar = false;
226
+
227
+        for (char part : regex.toCharArray()) {
228
+            if (inchar) {
229
+                inchar = false;
230
+
231
+                if (part == '*') {
232
+                    res.append(part);
233
+                    continue;
234
+                } else {
235
+                    res.append('?');
236
+                }
237
+            }
238
+
239
+            if (escaped) {
240
+                if (part == '?' || part == '*') {
241
+                    throw new UnsupportedOperationException("Cannot convert to"
242
+                            + " simple expression: ? or * is escaped.");
243
+                }
244
+
245
+                res.append(part);
246
+                escaped = false;
247
+            }  else if (part == '\\') {
248
+                escaped = true;
249
+            } else if (part == '.') {
250
+                inchar = true;
251
+            } else if (part == '.' || part == '^' || part == '$' || part == '['
252
+                    || part == ']' || part == '\\' || part == '(' || part == ')'
253
+                    || part == '{' || part == '}' || part == '|' || part == '+'
254
+                    || part == '*' || part == '?') {
255
+                throw new UnsupportedOperationException("Cannot convert to"
256
+                        + " simple expression: unescaped special char: " + part);
257
+            } else {
258
+                res.append(part);
259
+            }
260
+        }
261
+
262
+        if (escaped) {
263
+            throw new UnsupportedOperationException("Cannot convert to "
264
+                    + "simple expression: trailing backslash");
265
+        } else if (inchar) {
266
+            res.append('?');
267
+        }
268
+
269
+        return res.toString();
270
+    }
271
+
272
+    /**
273
+     * Converts a simple expression to a regular expression.
274
+     *
275
+     * @param regex The simple expression to be converted
276
+     * @return A corresponding regular expression
277
+     */
278
+    @SuppressWarnings("fallthrough")
279
+    protected static String simpleToRegex(final String regex) {
280
+        final StringBuilder res = new StringBuilder(regex.length());
281
+
282
+        for (char part : regex.toCharArray()) {
283
+            switch (part) {
284
+            case '.': case '^': case '$': case '[': case ']': case '\\':
285
+            case '(': case ')': case '{': case '}': case '|': case '+':
286
+                res.append('\\');
287
+                res.append(part);
288
+                break;
289
+            case '?':
290
+                res.append('.');
291
+                break;
292
+            case '*':
293
+                res.append('.');
294
+            default:
295
+                res.append(part);
296
+                break;
297
+            }
298
+        }
299
+
300
+        return res.toString();
301
+    }
302
+
303
+}

+ 159
- 0
src/com/dmdirc/parser/common/MyInfo.java Näytä tiedosto

@@ -0,0 +1,159 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+/**
26
+ * Contains User information.
27
+ * 
28
+ * @author Shane Mc Cormack
29
+ * @author Chris Smith
30
+ * @see IRCParser
31
+ */
32
+public class MyInfo {
33
+    
34
+	/** Character to prepend to nickname if in use (Default "_"). */
35
+	private char prependChar = '_';	
36
+	/** Nickname to attempt to use on IRC. */
37
+	private String nickname;
38
+	/**
39
+	 * Alternative nickname to attempt to use on IRC.
40
+	 * If the first nickname is in use, and a NickInUse message is recieved before 001, we
41
+	 * will attempt to use this nickname instead.<br>
42
+	 * If this also fails, we will start prepending the prependChar character (_) to the main nickname
43
+	 */
44
+	private String altNickname;
45
+	/** Realname string to use */
46
+	private String realname;
47
+	/** Username to use, this doesn't matter when an ident server is running*/
48
+	private String username;
49
+	
50
+	/**
51
+	 * Create a new MyInfo object.
52
+	 */
53
+	public MyInfo() {
54
+		String result;
55
+		try {
56
+			result = System.getProperty("user.name");
57
+		} catch (SecurityException e) {
58
+			result = null;
59
+		}
60
+		if (result == null || result.isEmpty()) {
61
+			nickname = "IRCParser";
62
+			username = "IRCParser";
63
+			realname = "DMDIrc IRCParser";
64
+			altNickname = "IRC-Parser";
65
+		} else {
66
+			nickname = result;
67
+			username = nickname;
68
+			realname = nickname+" - DMDIrc";
69
+			altNickname = nickname+"-";
70
+		}
71
+	}
72
+	
73
+	/**
74
+	 * Set the Nickname.
75
+	 *
76
+	 * @param newValue Value to set to.
77
+	 */
78
+	public void setNickname(final String newValue) {
79
+		if (newValue != null && !newValue.isEmpty()) {
80
+			nickname = newValue;
81
+		}
82
+	}
83
+	
84
+	/**
85
+	 * Get the Nickname.
86
+	 *
87
+	 * @return Current Nickname
88
+	 */
89
+	public String getNickname() { return nickname; }
90
+	
91
+	/**
92
+	 * Set the Alternative Nickname.
93
+	 *
94
+	 * @param newValue Value to set to.
95
+	 */
96
+	public void setAltNickname(final String newValue) {
97
+		if (newValue != null && !newValue.isEmpty()) {
98
+			altNickname = newValue;
99
+		}
100
+	}
101
+	
102
+	/**
103
+	 * Get the Alternative Nickname.
104
+	 *
105
+	 * @return Current Nickname
106
+	 */
107
+	public String getAltNickname() { return altNickname; }
108
+	
109
+	/**
110
+	 * Set the Realname.
111
+	 *
112
+	 * @param newValue Value to set to.
113
+	 */
114
+	public void setRealname(final String newValue) {
115
+		if (newValue != null && !newValue.isEmpty()) {
116
+			realname = newValue;
117
+		}
118
+	}
119
+	
120
+	/**
121
+	 * Get the Realname.
122
+	 *
123
+	 * @return Current Realname
124
+	 */
125
+	public String getRealname() { return realname; }
126
+	
127
+	/**
128
+	 * Set the Username.
129
+	 *
130
+	 * @param newValue Value to set to.
131
+	 */
132
+	public void setUsername(final String newValue) {
133
+		if (newValue != null && !newValue.isEmpty()) {
134
+			username = newValue;
135
+		}
136
+	}
137
+	
138
+	/**
139
+	 * Get the Username.
140
+	 *
141
+	 * @return Current Username
142
+	 */
143
+	public String getUsername() { return username; }
144
+	
145
+	/**
146
+	 * Set the Prepend Character.
147
+	 *
148
+	 * @param newValue Value to set to.
149
+	 */
150
+	public void setPrependChar(final char newValue) { prependChar = newValue; }
151
+	
152
+	/**
153
+	 * Get the Prepend Character.
154
+	 *
155
+	 * @return Current Prepend Character
156
+	 */
157
+	public char getPrependChar() { return prependChar; }	
158
+
159
+}

+ 177
- 0
src/com/dmdirc/parser/common/ParserError.java Näytä tiedosto

@@ -0,0 +1,177 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+/**
26
+ * IRC Parser Error.
27
+ *
28
+ * @author Shane Mc Cormack
29
+ */
30
+public final class ParserError {
31
+	/** Error is potentially Fatal, Desync 99% Guaranteed! */
32
+	public static final int ERROR_FATAL = 1;
33
+	/** Error is not fatal, but is more severe than a warning. */
34
+	public static final int ERROR_ERROR = 2;
35
+	/** Error was an unexpected occurance, but shouldn't be anything to worry about. */
36
+	public static final int ERROR_WARNING = 4;
37
+	/** Error is a user-error rather than a server error. */
38
+	public static final int ERROR_USER = 8;
39
+	/** Error was an exception from elsewhere. */
40
+	public static final int ERROR_EXCEPTION = 16;
41
+	
42
+	/** Store the Error level. */
43
+	private int errorLevel;
44
+	/** Store the Error Information. */
45
+	private String errorData;
46
+	/** Store the Exception object. */
47
+	private Exception exceptionInfo;
48
+	
49
+	/** Last line of server input before this exception was triggered. */
50
+	private String lastLine = "";
51
+	
52
+	/**
53
+	 * Create a new Error.
54
+	 *
55
+	 * @param level Set the error level.
56
+	 * @param data String containing information about the error.
57
+	 * @param line The last line of data recieved from the server before this exception.
58
+	 */
59
+	public ParserError(final int level, final String data, final String line) {
60
+		errorData = data;
61
+		errorLevel = level;
62
+		lastLine = line;
63
+	}
64
+	
65
+	/**
66
+	 * Check if this error is considered Fatal.
67
+	 *
68
+	 * @return Returns true for a fatal error, false for a non-fatal error
69
+	 */
70
+	public boolean isFatal() {
71
+		return (errorLevel & ERROR_FATAL) == ERROR_FATAL;
72
+	}
73
+	
74
+	/**
75
+	 * Check if this error is considered an error (less severe than fatal, worse than warning).
76
+	 *
77
+	 * @return Returns true for an "Error" level error, else false.
78
+	 */
79
+	public boolean isError() {
80
+		return (errorLevel & ERROR_ERROR) == ERROR_ERROR;
81
+	}
82
+	
83
+	/**
84
+	 * Check if this error is considered a warning.
85
+	 *
86
+	 * @return Returns true for a warning, else false.
87
+	 */
88
+	public boolean isWarning() {
89
+		return (errorLevel & ERROR_WARNING) == ERROR_WARNING;
90
+	}
91
+	
92
+	/**
93
+	 * Check if this error is considered a user-error rather than a server error.
94
+	 * For DMDirc this will cause the error not to be reported to the developers
95
+	 *
96
+	 * @return Returns true for a user error, else false.
97
+	 */
98
+	public boolean isUserError() {
99
+		return (errorLevel & ERROR_USER) == ERROR_USER;
100
+	}
101
+	
102
+	/**
103
+	 * Check if this error was generated from an exception.
104
+	 *
105
+	 * @return Returns true if getException will return an exception.
106
+	 */
107
+	public boolean isException() {
108
+		return (errorLevel & ERROR_EXCEPTION) == ERROR_EXCEPTION;
109
+	}
110
+	
111
+	/**
112
+	 * Check if this error has a lastLine parameter.
113
+	 *
114
+	 * @return Returns true if getLastLine returns anything non null, non empty.
115
+	 */
116
+	public boolean hasLastLine() {
117
+		return (lastLine != null && !lastLine.isEmpty());
118
+	}
119
+	
120
+	/**
121
+	 * Set the Exception object.
122
+	 *
123
+	 * @param newException The exception object to store
124
+	 */
125
+	public void setException(final Exception newException) {
126
+		exceptionInfo = newException;
127
+		if (!this.isException()) {
128
+			this.errorLevel = this.errorLevel + ERROR_EXCEPTION;
129
+		}
130
+	}
131
+	
132
+	/**
133
+	 * Get the Exception object.
134
+	 *
135
+	 * @return Returns the exception object
136
+	 */
137
+	public Exception getException() {
138
+		return exceptionInfo;
139
+	}
140
+	
141
+	/**
142
+	 * Get the full ErrorLevel.
143
+	 *
144
+	 * @return Returns the error level
145
+	 */
146
+	public int getLevel() {
147
+		return errorLevel;
148
+	}
149
+	
150
+	/**
151
+	 * Get the Error information.
152
+	 *
153
+	 * @return Returns the error data
154
+	 */
155
+	public String getData() {
156
+		return errorData;
157
+	}
158
+	
159
+	/**
160
+	 * Add to the error information.
161
+	 *
162
+	 * @param data Information to add to the end of the existing Data
163
+	 */
164
+	public void appendData(final String data) {
165
+		errorData = errorData + '[' + data + ']';
166
+	}
167
+	
168
+	/**
169
+	 * Get the last line recieved from the server before this exception.
170
+	 *
171
+	 * @return Returns the error data
172
+	 */
173
+	public String getLastLine() {
174
+		return lastLine;
175
+	}	
176
+
177
+}

+ 37
- 0
src/com/dmdirc/parser/common/QueuePriority.java Näytä tiedosto

@@ -0,0 +1,37 @@
1
+/*
2
+ *  Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ * 
4
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ *  of this software and associated documentation files (the "Software"), to deal
6
+ *  in the Software without restriction, including without limitation the rights
7
+ *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ *  copies of the Software, and to permit persons to whom the Software is
9
+ *  furnished to do so, subject to the following conditions:
10
+ * 
11
+ *  The above copyright notice and this permission notice shall be included in
12
+ *  all copies or substantial portions of the Software.
13
+ * 
14
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ *  SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.common;
24
+
25
+/**
26
+ * Queue Priority.
27
+ *
28
+ * @author shane
29
+ */
30
+public enum QueuePriority {
31
+    /** Low priority. */
32
+    LOW,
33
+    /** Normal priority. */
34
+    NORMAL,
35
+    /** High Priority. */
36
+    HIGH;
37
+}

+ 91
- 0
src/com/dmdirc/parser/interfaces/ChannelClientInfo.java Näytä tiedosto

@@ -0,0 +1,91 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import java.util.Map;
26
+
27
+/**
28
+ * Describes a client that is present on a channel and provides methods to
29
+ * interact with it.
30
+ *
31
+ * @since 0.6.3m2
32
+ * @author chris
33
+ */
34
+public interface ChannelClientInfo extends Comparable<ChannelClientInfo> {
35
+
36
+    /**
37
+     * Retrieves the {@link ClientInfo} object which this object corresponds
38
+     * to.
39
+     * 
40
+     * @return The client info object which this object represents
41
+     */
42
+    ClientInfo getClient();
43
+
44
+    /**
45
+     * Retrieves the {@link ChannelInfo} object for the channel which this
46
+     * object is associated with.
47
+     *
48
+     * @return The corresponding ChannelInfo object
49
+     */
50
+    ChannelInfo getChannel();
51
+
52
+    /**
53
+     * Returns the most important mode that the client holds in its prefix
54
+     * form (e.g. @, +, etc).
55
+     *
56
+     * @return The most important mode the client holds, or an empty string
57
+     */
58
+    String getImportantModePrefix();
59
+
60
+    /**
61
+     * Returns the most important mode that the client holds in its textual
62
+     * form (e.g. o, v, etc)
63
+     *
64
+     * @return The most important mode the client holds, or an empty string
65
+     */
66
+    String getImportantMode();
67
+
68
+    /**
69
+     * Returns a list of all modes known to be held by the client, in their
70
+     * textual for (e.g. o, v, etc)
71
+     *
72
+     * @return All modes the client holds, or an empty string
73
+     */
74
+    String getAllModes();
75
+
76
+    /**
77
+     * Retrieves a {@link Map} which can be used to store arbitrary data
78
+     * about the channel client.
79
+     *
80
+     * @return A map used for storing arbitrary data
81
+     */
82
+    Map<Object, Object> getMap();
83
+
84
+    /**
85
+     * Kicks this client from the channel.
86
+     *
87
+     * @param message The kick message to use
88
+     */
89
+    void kick(String message);
90
+
91
+}

+ 193
- 0
src/com/dmdirc/parser/interfaces/ChannelInfo.java Näytä tiedosto

@@ -0,0 +1,193 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import com.dmdirc.parser.common.ChannelListModeItem;
26
+import java.util.Collection;
27
+
28
+/**
29
+ * Holds information about a channel and allows various operations to be
30
+ * performed on the channel.
31
+ *
32
+ * @since 0.6.3m2
33
+ * @author chris
34
+ */
35
+public interface ChannelInfo {
36
+
37
+    /**
38
+     * Returns the name of this channel.
39
+     *
40
+     * @return The name of this channel
41
+     */
42
+    String getName();
43
+
44
+    /**
45
+     * Changes the topic of this channel.
46
+     *
47
+     * @param topic This channel's new topic
48
+     */
49
+    void setTopic(String topic);
50
+
51
+    /**
52
+     * Retrieves the current topic or subject of this channel.
53
+     *
54
+     * @return This channel's topic
55
+     */
56
+    String getTopic();
57
+
58
+    /**
59
+     * Retrieves the time the current topic was set, as a unix timestamp.
60
+     *
61
+     * @return The time the current topic was set
62
+     */
63
+    long getTopicTime();
64
+
65
+    /**
66
+     * Retrieves a textual description of the person or entity that set the
67
+     * channel topic.
68
+     *
69
+     * @return The person that set the current topic
70
+     */
71
+    String getTopicSetter();
72
+
73
+    /**
74
+     * Retrieves a textual representation of the modes currently set on this
75
+     * channel. This includes boolean and parameter modes, but not list modes.
76
+     *
77
+     * @return The current channel modes
78
+     */
79
+    String getModes();
80
+
81
+    /**
82
+     * Retrieves the value of the specified mode if it's set.
83
+     *
84
+     * @param mode The mode to retrieve
85
+     * @return The value for the specified mode or an empty string if it's not set
86
+     */
87
+    String getMode(char mode);
88
+
89
+    /**
90
+     * Retrieves the known values for the specified list mode.
91
+     *
92
+     * @param mode The list mode to be retrieved
93
+     * @return A collection of known list mode items
94
+     */
95
+    Collection<ChannelListModeItem> getListMode(char mode);
96
+
97
+    /**
98
+     * Sends the specified message to this channel.
99
+     *
100
+     * @param message The message to be sent
101
+     */
102
+    void sendMessage(final String message);
103
+
104
+    /**
105
+     * Sends the specified action to this channel.
106
+     *
107
+     * @param action The action to be sent
108
+     */
109
+    void sendAction(String action);
110
+
111
+    /**
112
+     * Parts this channel with the specified reason.
113
+     *
114
+     * @param reason The reason for parting
115
+     */
116
+    void part(String reason);
117
+
118
+    /**
119
+     * Sends a WHO request to get details about people who are on the channel.
120
+     */
121
+    void sendWho();
122
+
123
+    /**
124
+     * Adjust the modes on this channel. This method should queue modes to be
125
+     * sent in one go, according to the configuration/behaviour of the backend
126
+     * system. If fewer modes are altered than the queue accepts, the
127
+     * flushModes() method must be called.
128
+     *
129
+     * @param add Whether to add or remove the specified mode
130
+     * @param mode Character The character representation of the mode to be changed
131
+     * @param parameter Optional parameter needed to make change
132
+     */
133
+    void alterMode(boolean add, final Character mode, String parameter);
134
+
135
+    /**
136
+     * Flushes any mode changes that have been queued by the
137
+     * {@link #alterMode(boolean, Character, String)} method.
138
+     */
139
+    void flushModes();
140
+
141
+    /**
142
+     * Retrieves a channel client information object corresponding to the
143
+     * specified client.
144
+     *
145
+     * @param client The client whose channel client info object is being requested
146
+     * @return A {@link ChannelClientInfo} object corresponding to the client
147
+     */
148
+    ChannelClientInfo getChannelClient(ClientInfo client);
149
+
150
+    /**
151
+     * Retrieves a channel client information object corresponding to the
152
+     * specified client.
153
+     *
154
+     * @param client The name or other textual representation of the client
155
+     * @return A {@link ChannelClientInfo} object corresponding to the client,
156
+     * or null if none was found
157
+     */
158
+    ChannelClientInfo getChannelClient(String client);
159
+
160
+    /**
161
+     * Retrieves a channel client information object corresponding to the
162
+     * specified client. If the client doesn't exist and the value of
163
+     * <code>create</code> is <code>true</code>, a new fake client is created.
164
+     *
165
+     * @param client The name or other textual representation of the client
166
+     * @param create Whether or not to create the client if it doesn't exist
167
+     * @return A {@link ChannelClientInfo} object corresponding to the client
168
+     */
169
+    ChannelClientInfo getChannelClient(String client, boolean create);
170
+
171
+    /**
172
+     * Retrieves a collection of all known clients that are present on the
173
+     * channel.
174
+     *
175
+     * @return A collection of known channel clients
176
+     */
177
+    Collection<ChannelClientInfo> getChannelClients();
178
+
179
+    /**
180
+     * Retrieves the number of clients known to exist in this channel.
181
+     *
182
+     * @return The number of clients known in this channel
183
+     */
184
+    int getChannelClientCount();
185
+
186
+    /**
187
+     * Retrieves the parser which created this ChannelInfo.
188
+     *
189
+     * @return This ChannelInfo's parser
190
+     */
191
+    Parser getParser();
192
+
193
+}

+ 86
- 0
src/com/dmdirc/parser/interfaces/ClientInfo.java Näytä tiedosto

@@ -0,0 +1,86 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import java.util.Map;
26
+
27
+/**
28
+ * Holds information about a client, and provides various methods for
29
+ * interacting with that client.
30
+ *
31
+ * @author chris
32
+ * @since 0.6.3m2
33
+ */
34
+public interface ClientInfo {
35
+
36
+    /**
37
+     * Retrieves the nickname or display name used by this client.
38
+     *
39
+     * @return This client's nickname
40
+     */
41
+    String getNickname();
42
+
43
+    /**
44
+     * Retrieves the username or ident used by this client.
45
+     *
46
+     * @return This client's username
47
+     */
48
+    String getUsername();
49
+
50
+    /**
51
+     * Retrieves the hostname that this client is connecting from.
52
+     *
53
+     * @return This client's hostname
54
+     */
55
+    String getHostname();
56
+
57
+    /**
58
+     * Retrieves the full/real name of the client.
59
+     *
60
+     * @return This client's real name
61
+     */
62
+    String getRealname();
63
+
64
+    /**
65
+     * Retrieves the number of channels that this client is known to be on.
66
+     *
67
+     * @return The number of channels the client is known to be on
68
+     */
69
+    int getChannelCount();
70
+
71
+    /**
72
+     * Retrieves a {@link Map} which can be used to store arbitrary data
73
+     * about the client.
74
+     *
75
+     * @return A map used for storing arbitrary data
76
+     */
77
+    Map<Object, Object> getMap();
78
+
79
+    /**
80
+     * Retrieves the parser which created this ClientInfo.
81
+     *
82
+     * @return This ClientInfo's parser
83
+     */
84
+    Parser getParser();
85
+    
86
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/FakableArgument.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import java.lang.annotation.ElementType;
26
+import java.lang.annotation.Retention;
27
+import java.lang.annotation.RetentionPolicy;
28
+import java.lang.annotation.Target;
29
+
30
+/**
31
+ * Indicates a specific argument may be faked.
32
+ *
33
+ * @since 0.6.3m1
34
+ * @author chris
35
+ */
36
+@Retention(RetentionPolicy.RUNTIME)
37
+@Target(ElementType.PARAMETER)
38
+public @interface FakableArgument {
39
+
40
+}

+ 41
- 0
src/com/dmdirc/parser/interfaces/FakableSource.java Näytä tiedosto

@@ -0,0 +1,41 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import java.lang.annotation.ElementType;
26
+import java.lang.annotation.Retention;
27
+import java.lang.annotation.RetentionPolicy;
28
+import java.lang.annotation.Target;
29
+
30
+/**
31
+ * Indicates that the specified argument is a source of data for fakable
32
+ * arguments.
33
+ *
34
+ * @since 0.6.3m1
35
+ * @author chris
36
+ */
37
+@Retention(RetentionPolicy.RUNTIME)
38
+@Target(ElementType.PARAMETER)
39
+public @interface FakableSource {
40
+
41
+}

+ 77
- 0
src/com/dmdirc/parser/interfaces/LocalClientInfo.java Näytä tiedosto

@@ -0,0 +1,77 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+/**
26
+ * A more specialised type of {@link ClientInfo} which represents a locally
27
+ * controlled client, and as such can be modified in various ways.
28
+ *
29
+ * @author chris
30
+ * @since 0.6.3m1
31
+ */
32
+public interface LocalClientInfo extends ClientInfo {
33
+
34
+    /**
35
+     * Sets this client's nickname to the specified value.
36
+     *
37
+     * @param name The new nickname to use
38
+     */
39
+    void setNickname(String name);
40
+
41
+    /**
42
+     * Retrieves the modes which are currently set on the local client.
43
+     *
44
+     * @return A string representation of the client's user modes
45
+     */
46
+    String getModes();
47
+
48
+    /**
49
+     * Marks the local client as being away.
50
+     *
51
+     * @param reason The reason for being away
52
+     */
53
+    void setAway(String reason);
54
+
55
+    /**
56
+     * Marks the local client as being back (not away).
57
+     */
58
+    void setBack();
59
+
60
+    /**
61
+     * Alters the user modes of the local client. This method will queue modes
62
+     * to be sent in one go, according to the behaviour/configuration of the
63
+     * backend system. If fewer modes are altered than the queue accepts,
64
+     * {@link #flushModes()} must be called.
65
+     *
66
+     * @param add Whether to add or remove the mode
67
+     * @param mode Character representation of the mode to be altered
68
+     */
69
+    public void alterMode(boolean add, Character mode);
70
+
71
+    /**
72
+     * Flushes any modes that have been queued by the
73
+     * {@link #alterMode(boolean, Character)} method.
74
+     */
75
+    public void flushModes();
76
+
77
+}

+ 398
- 0
src/com/dmdirc/parser/interfaces/Parser.java Näytä tiedosto

@@ -0,0 +1,398 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import com.dmdirc.parser.common.IgnoreList;
26
+import com.dmdirc.parser.common.CallbackManager;
27
+
28
+import com.dmdirc.parser.common.QueuePriority;
29
+import java.util.Collection;
30
+
31
+/**
32
+ * A parser connects to a back-end chat system and handles all communication
33
+ * with it.
34
+ *
35
+ * @since 0.6.3m2
36
+ * @author chris
37
+ */
38
+public interface Parser extends Runnable {
39
+
40
+    /**
41
+     * Disconnect from server. This method will quit and automatically close the
42
+     * socket without waiting for the server.
43
+     *
44
+     * @param message Reason for quitting.
45
+     */
46
+    void disconnect(String message);
47
+
48
+    /**
49
+     * Join a channel with no key.
50
+     *
51
+     * @param channel Name of channel to join
52
+     */
53
+    void joinChannel(String channel);
54
+
55
+    /**
56
+     * Joins a channel with the specified key.
57
+     *
58
+     * @param channel Name of channel to join
59
+     * @param key The key required to join the channel
60
+     */
61
+    void joinChannel(String channel, String key);
62
+
63
+    /**
64
+     * Retrieves a channel information object for the specified channel.
65
+     *
66
+     * @param channel Name of the channel to retrieve an information object for
67
+     * @return A corresponding channel info object
68
+     */
69
+    ChannelInfo getChannel(String channel);
70
+
71
+    /**
72
+     * Retrieves a collection of all known channels.
73
+     *
74
+     * @return A collection of known channels
75
+     */
76
+    Collection<? extends ChannelInfo> getChannels();
77
+
78
+    /**
79
+     * Set the IP address that this parser will bind to
80
+     *
81
+     * @param ip IP to bind to
82
+     */
83
+    void setBindIP(String ip);
84
+
85
+    /**
86
+     * Determines the maximimum length a message of the specified type may be.
87
+     *
88
+     * @param type Type of message (eg PRIVMSG)
89
+     * @param target Target of message (eg channel name)
90
+     * @return The maximum length of the message
91
+     */
92
+    int getMaxLength(String type, String target);
93
+
94
+    /**
95
+     * Determines the maximum length any message/raw command may be.
96
+     *
97
+     * @return The maximum length of a message
98
+     */
99
+    int getMaxLength();
100
+
101
+    /**
102
+     * Returns a {@link ClientInfo} object which represents the locally
103
+     * connected client.
104
+     *
105
+     * @return An info object for the local client
106
+     */
107
+    LocalClientInfo getLocalClient();
108
+
109
+    /**
110
+     * Retrieves a {@link ClientInfo} object which corresponds to the specified
111
+     * details. If the client wasn't previously known, it will be created.
112
+     *
113
+     * @param details The details of the client to look up
114
+     * @return A corresponding client info object
115
+     */
116
+    ClientInfo getClient(String details);
117
+
118
+    /**
119
+     * Sends a raw message directly to the backend system. The message will
120
+     * need to be of the appropriate format for whatever system is in use.
121
+     *
122
+     * @param message The message to be sent
123
+     */
124
+    void sendRawMessage(String message);
125
+
126
+    /**
127
+     * Sends a raw message directly to the backend system. The message will
128
+     * need to be of the appropriate format for whatever system is in use.
129
+     *
130
+     * @param message The message to be sent
131
+     * @param priority Priority of this line. (Priorities are advisory and not
132
+     *                 guaranteed to be enforced.
133
+     */
134
+    void sendRawMessage(String message, QueuePriority priority);
135
+
136
+    /**
137
+     * Retrieves an object that can be used to convert between upper- and lower-
138
+     * case strings in the relevant charset for the backend system.
139
+     *
140
+     * @return A string convertor for this parser
141
+     */
142
+    StringConverter getStringConverter();
143
+
144
+    /**
145
+     * Determines whether the specified channel name is valid or not for this
146
+     * parser.
147
+     *
148
+     * @param name The name of the channel to be tested
149
+     * @return True if the channel name is valid, false otherwise
150
+     */
151
+    boolean isValidChannelName(String name);
152
+
153
+    /**
154
+     * Retrieves the name of the server that this parser is connected to.
155
+     *
156
+     * @return This parser's server's name
157
+     */
158
+    String getServerName();
159
+
160
+    /**
161
+     * Retrieves the name of the network that this parser is connected to.
162
+     *
163
+     * @return This parser's network's name
164
+     */
165
+    String getNetworkName();
166
+
167
+    /**
168
+     * Retrieves a textual description of the software running on the server.
169
+     *
170
+     * @return This parser's server's software name
171
+     */
172
+    String getServerSoftware();
173
+
174
+    /**
175
+     * Retrieves the detected type of the software running on the server
176
+     *
177
+     * @return This parser's server's software type
178
+     */
179
+    String getServerSoftwareType();
180
+
181
+    /**
182
+     * Retrieves the maximum length for a topic that can be set by this parser.
183
+     *
184
+     * @return The maximum length (in bytes) of a topic
185
+     */
186
+    int getMaxTopicLength();
187
+
188
+    /**
189
+     * Retrieves an alphabetically-sorted list of boolean channel modes.
190
+     * Boolean channel modes may only be set or unset, and do not take any
191
+     * arguments.
192
+     *
193
+     * @return A string containing a list of channel mode characters
194
+     */
195
+    String getBooleanChannelModes();
196
+
197
+    /**
198
+     * Retrieves an alphabetically-sorted list of channel list modes.
199
+     * List channel modes may be set multiple times with different arguments,
200
+     * building up a "list" of values.
201
+     *
202
+     * @return A string containing a list of channel mode characters
203
+     */
204
+    String getListChannelModes();
205
+
206
+    /**
207
+     * Retrieves the maximum number of list modes of the specified type which
208
+     * may be set on a channel. Returns 0 or -1 if the limit wasn't specified,
209
+     * or couldn't be discovered, respectively.
210
+     *
211
+     * @param mode The list mode being requested
212
+     * @return The maximimum number of that mode which can be set
213
+     */
214
+    int getMaxListModes(char mode);
215
+
216
+    /**
217
+     * Determines if the specified channel mode is settable by users.
218
+     *
219
+     * @param mode The mode to be tested
220
+     * @return True if users may set the mode, false otherwise
221
+     */
222
+    boolean isUserSettable(final char mode);
223
+
224
+    /**
225
+     * Retrieves an alphabetically-sorted list of 'parameter' channel modes.
226
+     * Parameter channel modes may only be set or unset, and require a
227
+     * parameter to be specified when they are set (but not when unset).
228
+     *
229
+     * @return A string containing a list of channel mode characters
230
+     */
231
+    String getParameterChannelModes();
232
+
233
+    /**
234
+     * Retrieves an alphabetically-sorted list of 'double parameter' channel
235
+     * modes. Double parameter channel modes may only be set or unset, and
236
+     * require a parameter to be specified both when they are set and when
237
+     * they are unset.
238
+     *
239
+     * @return A string containing a list of channel mode characters
240
+     */
241
+    String getDoubleParameterChannelModes();
242
+
243
+    /**
244
+     * Retrieves a list of user modes in no particular order.
245
+     *
246
+     * @return A string containing a list of user mode characters
247
+     */
248
+    String getUserModes();
249
+
250
+    /**
251
+     * Retrieves a list of channel user modes, in descending priority order.
252
+     * 
253
+     * @return A string containing a list of channel user mode characters
254
+     */
255
+    String getChannelUserModes();
256
+    
257
+    /**
258
+     * Retrieves the object which is responsible for managing callbacks for
259
+     * this parser.
260
+     * 
261
+     * @return This parser's callback manager
262
+     */
263
+    CallbackManager<? extends Parser> getCallbackManager();
264
+
265
+    /**
266
+     * Retrieves the latency between the parser and the server in milliseconds.
267
+     *
268
+     * @return The current latency, in milliseconds
269
+     */
270
+    long getServerLatency();
271
+
272
+    /**
273
+     * Sends a CTCP of the specified type to the specified target.
274
+     *
275
+     * @param target The destination of the CTCP message
276
+     * @param type The type of CTCP to send
277
+     * @param message The content of the CTCP message
278
+     */
279
+    void sendCTCP(String target, String type, String message);
280
+
281
+    /**
282
+     * Sends a CTCP reply of the specified type to the specified target.
283
+     *
284
+     * @param target The destination of the CTCP reply
285
+     * @param type The type of CTCP to reply to
286
+     * @param message The content of the CTCP reply
287
+     */
288
+    void sendCTCPReply(String target, String type, String message);
289
+
290
+    /**
291
+     * Sends a message to the specified target.
292
+     *
293
+     * @param target The target to send the message to
294
+     * @param message The message to be sent
295
+     */
296
+    void sendMessage(String target, String message);
297
+
298
+    /**
299
+     * Sends a notice to the specified target.
300
+     *
301
+     * @param target The target to send the notice to
302
+     * @param message The message to be sent
303
+     */
304
+    void sendNotice(String target, String message);
305
+
306
+    /**
307
+     * Sends an action to the specified target.
308
+     *
309
+     * @param target The target to send the action to
310
+     * @param message The message to be sent
311
+     */
312
+    void sendAction(String target, String message);
313
+
314
+    /**
315
+     * Retrieves the last line/communication received from the server, for use
316
+     * in debugging purposes.
317
+     *
318
+     * @return The last line received
319
+     */
320
+    String getLastLine();
321
+
322
+    /**
323
+     * Sets the ignore list which should be used by this parser.
324
+     *
325
+     * @param ignoreList The new ignore list to be used by the parser
326
+     */
327
+    void setIgnoreList(IgnoreList ignoreList);
328
+
329
+    /**
330
+     * Retrieves the ignore list which is currently in use by this parser.
331
+     *
332
+     * @return This parser's ignore list
333
+     */
334
+    IgnoreList getIgnoreList();
335
+
336
+    /**
337
+     * Parses the specified hostmask into an array containing a nickname,
338
+     * username and hostname, in that order.
339
+     *
340
+     * @param hostmask The hostmask to be parsed
341
+     * @return An array containing the nickname, username and hostname
342
+     */
343
+    String[] parseHostmask(String hostmask);
344
+
345
+    /**
346
+     * Retrieves the local port number that this parser is using to communicate
347
+     * with the service.
348
+     *
349
+     * @return This parser's local port number
350
+     */
351
+    int getLocalPort();
352
+
353
+    /**
354
+     * Retrieves the amount of time elapsed since the last ping request was
355
+     * sent (or until the reply was received).
356
+     *
357
+     * @return The current ping time to the server
358
+     */
359
+    long getPingTime();
360
+
361
+    /**
362
+     * Sets the interval of the ping timer, in milliseconds. If the parser is
363
+     * waiting for a ping, it should fire a PingFailed event every time this
364
+     * interval is passed (or disconnect if no listeners are registered).
365
+     *
366
+     * @param newValue The new value for the ping timer interval
367
+     */
368
+    void setPingTimerInterval(long newValue);
369
+
370
+    /**
371
+     * Retrieves the length of the ping timer interval for this parser.
372
+     *
373
+     * @return This parser's ping timer interval
374
+     */
375
+    long getPingTimerInterval();
376
+
377
+    /**
378
+     * Sets how many ping timer intervals should pass before the parser sends
379
+     * a ping. That is, the time between pings on an idle connection will be
380
+     * <code>(ping timer interval) * (ping timer fraction)</code> millisecs.
381
+     *
382
+     * For example, setting the interval to 10,000 (10 seconds) and the fraction
383
+     * to 6 means that pings will be sent once every minute and if a reply is
384
+     * not received within 10 seconds, a ping failed event will be raised.
385
+     *
386
+     * @param newValue The new value of the ping timer fraction
387
+     */
388
+    void setPingTimerFraction(int newValue);
389
+
390
+    /**
391
+     * Retrieves the number of ping timer intervals that must pass before this
392
+     * parser sends a ping request.
393
+     *
394
+     * @return This parser's ping timer fraction
395
+     */
396
+    int getPingTimerFraction();
397
+
398
+}

+ 52
- 0
src/com/dmdirc/parser/interfaces/SecureParser.java Näytä tiedosto

@@ -0,0 +1,52 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import javax.net.ssl.KeyManager;
26
+import javax.net.ssl.TrustManager;
27
+
28
+/**
29
+ * A {@link SecureParser} is a specialised {@link Parser} that can connect
30
+ * to secure (SSL-enabled) backends.
31
+ *
32
+ * @since 0.6.3m2
33
+ * @author chris
34
+ */
35
+public interface SecureParser extends Parser {
36
+
37
+    /**
38
+     * Sets the trust managers which should be used to determine if a server
39
+     * certificate is trusted by the client.
40
+     *
41
+     * @param managers The new trust managers to use
42
+     */
43
+    void setTrustManagers(TrustManager[] managers);
44
+
45
+    /**
46
+     * Sets the key managers which should be used to supply client certificates.
47
+     *
48
+     * @param managers The new key managers to use
49
+     */
50
+    void setKeyManagers(KeyManager[] managers);
51
+
52
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/SpecificCallback.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+import java.lang.annotation.Retention;
26
+import java.lang.annotation.RetentionPolicy;
27
+
28
+/**
29
+ * Used to indicate that a callback interface can be called for specified
30
+ * objects (hosts/channels/etc).
31
+ *
32
+ * @since 0.6.3m1
33
+ * @author chris
34
+ */
35
+@Retention(RetentionPolicy.RUNTIME)
36
+public @interface SpecificCallback {
37
+
38
+}

+ 59
- 0
src/com/dmdirc/parser/interfaces/StringConverter.java Näytä tiedosto

@@ -0,0 +1,59 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces;
24
+
25
+/**
26
+ * Facilitates case conversion according to the charset/rules of the specific
27
+ * backend chat system.
28
+ *
29
+ * @since 0.6.3m2
30
+ * @author chris
31
+ */
32
+public interface StringConverter {
33
+
34
+    /**
35
+     * Get the lowercase version of a String.
36
+     *
37
+     * @param input String to convert to lowercase
38
+     * @return String converted to lowercase
39
+     */
40
+    String toLowerCase(String input);
41
+
42
+    /**
43
+     * Get the uppercase version of a String.
44
+     *
45
+     * @param input String to convert to uppercase
46
+     * @return String converted to uppercase
47
+     */
48
+    String toUpperCase(String input);
49
+
50
+    /**
51
+     * Check if the 2 strings are equal to each other ignoring case.
52
+     *
53
+     * @param first First string to check
54
+     * @param second Second string to check
55
+     * @return True if both strings are equal after being lowercased
56
+     */
57
+    boolean equalsIgnoreCase(String first, String second);
58
+
59
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/AuthNoticeListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used on every incomming line before 001.
29
+ */
30
+public interface AuthNoticeListener extends CallbackInterface {
31
+
32
+    /**
33
+	 * Called on every incomming line before 001.
34
+	 * 
35
+	 * @param tParser Reference to the parser object that made the callback.
36
+	 * @param sData Incomming Line.
37
+	 * @see com.dmdirc.parser.irc.ProcessNoticeAuth#callNoticeAuth
38
+	 */
39
+	void onNoticeAuth(Parser tParser, String sData);
40
+}

+ 41
- 0
src/com/dmdirc/parser/interfaces/callbacks/AwayStateListener.java Näytä tiedosto

@@ -0,0 +1,41 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when we go away, or come back.
29
+ */
30
+public interface AwayStateListener extends CallbackInterface {
31
+
32
+    /**
33
+	 * Called when we go away, or come back.
34
+	 *
35
+	 * @param tParser Reference to the parser object that made the callback.
36
+	 * @param currentState Set to true if we are now away, else false.
37
+	 * @param reason Best guess at away reason
38
+	 * @see com.dmdirc.parser.irc.ProcessAway#callAwayState
39
+	 */
40
+	void onAwayState(Parser tParser, boolean currentState, String reason);
41
+}

+ 28
- 0
src/com/dmdirc/parser/interfaces/callbacks/CallbackInterface.java Näytä tiedosto

@@ -0,0 +1,28 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+/**
26
+ * "SuperInterface" for all callbacks.
27
+ */
28
+public interface CallbackInterface { }

+ 58
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelActionListener.java Näytä tiedosto

@@ -0,0 +1,58 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person does an action in a channel.
34
+ * sHost is the hostname of the person sending the action. (Can be a server or a person)<br>
35
+ * cChannelClient is null if user is a server, or not on the channel.
36
+ */
37
+@SpecificCallback
38
+public interface ChannelActionListener extends CallbackInterface {
39
+
40
+    /**
41
+	 * Called when a person does an action in a channel.
42
+	 * sHost is the hostname of the person sending the action. (Can be a server or a person)<br>
43
+	 * cChannelClient is null if user is a server, or not on the channel.
44
+	 * 
45
+	 * @param tParser Reference to the parser object that made the callback.
46
+	 * @param cChannel Channel where the action was sent to
47
+	 * @param cChannelClient ChannelClient who sent the action (may be null if server)
48
+	 * @param sMessage action contents
49
+	 * @param sHost Hostname of sender (or servername)
50
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callChannelAction
51
+	 */
52
+	void onChannelAction(
53
+            @FakableSource Parser tParser,
54
+            @FakableSource ChannelInfo cChannel,
55
+            @FakableArgument ChannelClientInfo cChannelClient,
56
+            String sMessage,
57
+            @FakableSource String sHost);
58
+}

+ 57
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelCtcpListener.java Näytä tiedosto

@@ -0,0 +1,57 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person sends a CTCP to a channel.
34
+ * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
35
+ * cChannelClient is null if user is a server.
36
+ */
37
+@SpecificCallback
38
+public interface ChannelCtcpListener extends CallbackInterface {
39
+	/**
40
+	 * Called when a person sends a CTCP to a channel.
41
+	 * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
42
+	 * cChannelClient is null if user is a server.
43
+	 * 
44
+	 * @param tParser Reference to the parser object that made the callback.
45
+	 * @param cChannel Channel where CTCP was sent
46
+	 * @param cChannelClient ChannelClient who sent the message (may be null if server)
47
+	 * @param sType Type of CTCP (VERSION, TIME etc)
48
+	 * @param sMessage Additional contents
49
+	 * @param sHost Hostname of sender (or servername)
50
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callChannelCTCP
51
+	 */
52
+	void onChannelCTCP(@FakableSource Parser tParser,
53
+            @FakableSource ChannelInfo cChannel,
54
+            @FakableArgument ChannelClientInfo cChannelClient,
55
+            String sType, String sMessage,
56
+            @FakableSource String sHost);
57
+}

+ 57
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelCtcpReplyListener.java Näytä tiedosto

@@ -0,0 +1,57 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person sends a CTCPRReply to a channel.
34
+ * sHost is the hostname of the person sending the CTCPReply. (Can be a server or a person)<br>
35
+ * cChannelClient is null if user is a server.
36
+ */
37
+@SpecificCallback
38
+public interface ChannelCtcpReplyListener extends CallbackInterface {
39
+	/**
40
+	 * Called when a person sends a CTCPRReply to a channel.
41
+	 * sHost is the hostname of the person sending the CTCPReply. (Can be a server or a person)<br>
42
+	 * cChannelClient is null if user is a server.
43
+	 * 
44
+	 * @param tParser Reference to the parser object that made the callback.
45
+	 * @param cChannel Channel where CTCPReply was sent
46
+	 * @param cChannelClient ChannelClient who sent the message (may be null if server)
47
+	 * @param sType Type of CTCPRReply (VERSION, TIME etc)
48
+	 * @param sMessage Reply Contents
49
+	 * @param sHost Hostname of sender (or servername)
50
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callChannelCTCPReply
51
+	 */
52
+	void onChannelCTCPReply(@FakableSource Parser tParser,
53
+            @FakableSource ChannelInfo cChannel,
54
+            @FakableArgument ChannelClientInfo cChannelClient,
55
+            String sType, String sMessage,
56
+            @FakableSource String sHost);
57
+}

+ 46
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelJoinListener.java Näytä tiedosto

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.SpecificCallback;
29
+
30
+/** 
31
+ * Called When we, or another client joins a channel.
32
+ * This is called AFTER client has been added to channel as a ChannelClientInfo
33
+ */
34
+@SpecificCallback
35
+public interface ChannelJoinListener extends CallbackInterface {
36
+	/**
37
+	 * Called When another client joins a channel.
38
+	 * This is called AFTER client has been added to channel as a ChannelClientInfo
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param cChannel Channel Object
42
+	 * @param cChannelClient ChannelClient object for new person
43
+	 * @see com.dmdirc.parser.irc.ProcessJoin#callChannelJoin
44
+	 */
45
+	void onChannelJoin(Parser tParser, ChannelInfo cChannel, ChannelClientInfo cChannelClient);
46
+}

+ 56
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelKickListener.java Näytä tiedosto

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person is kicked.
34
+ * cKickedByClient can be null if kicked by a server. sKickedByHost is the hostname of the person/server doing the kicking.
35
+ */
36
+@SpecificCallback
37
+public interface ChannelKickListener extends CallbackInterface {
38
+	/**
39
+	 * Called when a person is kicked.
40
+	 * cKickedByClient can be null if kicked by a server. sKickedByHost is the hostname of the person/server doing the kicking.
41
+	 *
42
+	 * @param tParser Reference to the parser object that made the callback.
43
+	 * @param cChannel Channel where the kick took place
44
+	 * @param cKickedClient ChannelClient that got kicked
45
+	 * @param cKickedByClient ChannelClient that did the kicking (may be null if server)
46
+	 * @param sReason Reason for kick (may be "")
47
+	 * @param sKickedByHost Hostname of Kicker (or servername)
48
+	 * @see com.dmdirc.parser.irc.ProcessKick#callChannelKick
49
+	 */
50
+	void onChannelKick(@FakableSource Parser tParser,
51
+            @FakableSource ChannelInfo cChannel,
52
+            ChannelClientInfo cKickedClient,
53
+            @FakableArgument ChannelClientInfo cKickedByClient,
54
+            String sReason,
55
+            @FakableSource String sKickedByHost);
56
+}

+ 44
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelListModeListener.java Näytä tiedosto

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.SpecificCallback;
28
+
29
+/**
30
+ * Called when all requested ListModes have been sent.
31
+ * This is decided by ProcessListModes, and is called when an "end of list"
32
+ * reply is sent, and the listModeQueue is empty (or non-existant).
33
+ */
34
+@SpecificCallback
35
+public interface ChannelListModeListener extends CallbackInterface {
36
+	/**
37
+	 * Called when a ListModes reply is parsed.
38
+	 *
39
+	 * @param tParser Reference to the parser object that made the callback.
40
+	 * @param cChannel Channel which the ListModes reply is for
41
+	 * @see com.dmdirc.parser.irc.ProcessListModes#callChannelGotListModes
42
+	 */
43
+	void onChannelGotListModes(Parser tParser, ChannelInfo cChannel);
44
+}

+ 56
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelMessageListener.java Näytä tiedosto

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person sends a message to a channel.
34
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
35
+ * cChannelClient is null if user is a server, or not on the channel.
36
+ */
37
+@SpecificCallback
38
+public interface ChannelMessageListener extends CallbackInterface {
39
+	/**
40
+	 * Called when a person sends a message to a channel.
41
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
42
+	 * cChannelClient is null if user is a server, or not on the channel.
43
+	 *
44
+	 * @param tParser Reference to the parser object that made the callback.
45
+	 * @param cChannel Channel where the message was sent to
46
+	 * @param cChannelClient ChannelClient who sent the message (may be null if server)
47
+	 * @param sMessage Message contents
48
+	 * @param sHost Hostname of sender (or servername)
49
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callChannelMessage
50
+	 */
51
+	void onChannelMessage(@FakableSource Parser tParser,
52
+            @FakableSource ChannelInfo cChannel,
53
+            @FakableArgument ChannelClientInfo cChannelClient,
54
+            String sMessage,
55
+            @FakableSource String sHost);
56
+}

+ 56
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelModeChangeListener.java Näytä tiedosto

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/** 
33
+ * Called when the channel modes are changed or discovered.
34
+ * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
35
+ * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it
36
+ */
37
+@SpecificCallback
38
+public interface ChannelModeChangeListener extends CallbackInterface {
39
+	/**
40
+	 * Called when the channel modes are changed or discovered.
41
+	 * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
42
+	 * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it
43
+	 * 
44
+	 * @param tParser Reference to the parser object that made the callback.
45
+	 * @param cChannel Channel where modes were changed
46
+	 * @param cChannelClient Client chaning the modes (null if server)
47
+	 * @param sHost Host doing the mode changing (User host or server name)
48
+	 * @param sModes String showing the exact mode change parsed.
49
+	 * @see com.dmdirc.parser.irc.ProcessMode#callChannelModeChanged
50
+	 */
51
+	void onChannelModeChanged(@FakableSource Parser tParser,
52
+            @FakableSource ChannelInfo cChannel,
53
+            @FakableArgument ChannelClientInfo cChannelClient,
54
+            @FakableSource String sHost,
55
+            String sModes);
56
+}

+ 59
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelModeMessageListener.java Näytä tiedosto

@@ -0,0 +1,59 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person sends a Message to a channel with a mode prefix.
34
+ * (Examples @#Channel +#Channel)
35
+ * sHost is the hostname of the person sending the Message. (Can be a server or a person)<br>
36
+ * cChannelClient is null if user is a server, or not on the channel.
37
+ */
38
+@SpecificCallback
39
+public interface ChannelModeMessageListener extends CallbackInterface {
40
+	/**
41
+	 * Called when a person sends a Message to a channel.
42
+	 * sHost is the hostname of the person sending the Message. (Can be a server or a person)<br>
43
+	 * cChannelClient is null if user is a server, or not on the channel.
44
+	 * 
45
+	 * @param tParser Reference to the parser object that made the callback.
46
+         * @param prefix The mode prefix of the message
47
+	 * @param cChannel Channel where the Message was sent to
48
+	 * @param cChannelClient ChannelClient who sent the Message (may be null if server)
49
+	 * @param sMessage Message contents
50
+	 * @param sHost Hostname of sender (or servername)
51
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callChannelModeMessage
52
+	 */
53
+	void onChannelModeMessage(@FakableSource Parser tParser,
54
+            char prefix,
55
+            @FakableSource ChannelInfo cChannel,
56
+            @FakableArgument ChannelClientInfo cChannelClient,
57
+            String sMessage,
58
+            @FakableSource String sHost);
59
+}

+ 59
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelModeNoticeListener.java Näytä tiedosto

@@ -0,0 +1,59 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person sends a notice to a channel with a mode prefix.
34
+ * (Examples @#Channel +#Channel)
35
+ * sHost is the hostname of the person sending the notice. (Can be a server or a person)<br>
36
+ * cChannelClient is null if user is a server, or not on the channel.
37
+ */
38
+@SpecificCallback
39
+public interface ChannelModeNoticeListener extends CallbackInterface {
40
+	/**
41
+	 * Called when a person sends a notice to a channel.
42
+	 * sHost is the hostname of the person sending the notice. (Can be a server or a person)<br>
43
+	 * cChannelClient is null if user is a server, or not on the channel.
44
+	 * 
45
+	 * @param tParser Reference to the parser object that made the callback.
46
+         * @param prefix The mode prefix of the message
47
+	 * @param cChannel Channel where the notice was sent to
48
+	 * @param cChannelClient ChannelClient who sent the notice (may be null if server)
49
+	 * @param sMessage notice contents
50
+	 * @param sHost Hostname of sender (or servername)
51
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callChannelModeNotice
52
+	 */
53
+	void onChannelModeNotice(@FakableSource Parser tParser,
54
+            char prefix,
55
+            @FakableSource ChannelInfo cChannel,
56
+            @FakableArgument ChannelClientInfo cChannelClient,
57
+            String sMessage,
58
+            @FakableSource String sHost);
59
+}

+ 42
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelNamesListener.java Näytä tiedosto

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.SpecificCallback;
28
+
29
+/**
30
+ * Called when a names reply is parsed.
31
+ */
32
+@SpecificCallback
33
+public interface ChannelNamesListener extends CallbackInterface {
34
+	/**
35
+	 * Called when a names reply is parsed.
36
+	 *
37
+	 * @param tParser Reference to the parser object that made the callback.
38
+	 * @param cChannel Channel which the names reply is for
39
+	 * @see com.dmdirc.parser.irc.ProcessNames#callChannelGotNames
40
+	 */
41
+	void onChannelGotNames(Parser tParser, ChannelInfo cChannel);
42
+}

+ 47
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelNickChangeListener.java Näytä tiedosto

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.SpecificCallback;
29
+
30
+/** 
31
+ * Called when we or another user change nickname (Called once per channel the user is on).
32
+ * This is called after the nickname change has been done internally
33
+ */
34
+@SpecificCallback
35
+public interface ChannelNickChangeListener extends CallbackInterface {
36
+	/**
37
+	 * Called when we or another user change nickname (Called once per channel the user is on).
38
+	 * This is called after the nickname change has been done internally
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param cChannel One of the channels that the user is on
42
+	 * @param cChannelClient Client changing nickname
43
+	 * @param sOldNick Nickname before change
44
+	 * @see com.dmdirc.parser.irc.ProcessNick#callChannelNickChanged
45
+	 */
46
+	 void onChannelNickChanged(Parser tParser, ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sOldNick);
47
+}

+ 56
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelNonUserModeChangeListener.java Näytä tiedosto

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/** 
33
+ * Called when the channel modes are changed or discovered.
34
+ * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
35
+ * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it
36
+ */
37
+@SpecificCallback
38
+public interface ChannelNonUserModeChangeListener extends CallbackInterface {
39
+	/**
40
+	 * Called when the channel modes are changed or discovered.
41
+	 * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
42
+	 * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it
43
+	 * 
44
+	 * @param tParser Reference to the parser object that made the callback.
45
+	 * @param cChannel Channel where modes were changed
46
+	 * @param cChannelClient Client chaning the modes (null if server)
47
+	 * @param sHost Host doing the mode changing (User host or server name)
48
+	 * @param sModes String showing the exact mode change parsed. (Not including user modes)
49
+	 */
50
+	void onChannelNonUserModeChanged(@FakableSource Parser tParser,
51
+            @FakableSource ChannelInfo cChannel,
52
+            @FakableArgument ChannelClientInfo cChannelClient,
53
+            @FakableSource String sHost,
54
+            String sModes);
55
+}
56
+

+ 56
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelNoticeListener.java Näytä tiedosto

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/**
33
+ * Called when a person sends a notice to a channel.
34
+ * sHost is the hostname of the person sending the notice. (Can be a server or a person)<br>
35
+ * cChannelClient is null if user is a server, or not on the channel.
36
+ */
37
+@SpecificCallback
38
+public interface ChannelNoticeListener extends CallbackInterface {
39
+	/**
40
+	 * Called when a person sends a notice to a channel.
41
+	 * sHost is the hostname of the person sending the notice. (Can be a server or a person)<br>
42
+	 * cChannelClient is null if user is a server, or not on the channel.
43
+	 * 
44
+	 * @param tParser Reference to the parser object that made the callback.
45
+	 * @param cChannel Channel where the notice was sent to
46
+	 * @param cChannelClient ChannelClient who sent the notice (may be null if server)
47
+	 * @param sMessage notice contents
48
+	 * @param sHost Hostname of sender (or servername)
49
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callChannelNotice
50
+	 */
51
+	void onChannelNotice(@FakableSource Parser tParser,
52
+            @FakableSource ChannelInfo cChannel,
53
+            @FakableArgument ChannelClientInfo cChannelClient,
54
+            String sMessage,
55
+            @FakableSource String sHost);
56
+}

+ 45
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelOtherAwayStateListener.java Näytä tiedosto

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.SpecificCallback;
29
+
30
+/**
31
+ * Called when we go away, or come back.
32
+ */
33
+@SpecificCallback
34
+public interface ChannelOtherAwayStateListener extends CallbackInterface {
35
+	/**
36
+	 * Called when we go away, or come back.
37
+	 *
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param channel Channel this is for
40
+	 * @param channelClient Client this is for
41
+	 * @param state Away State (true if away, false if here)
42
+	 * @see com.dmdirc.parser.irc.ProcessAway#callChannelAwayStateOther
43
+	 */
44
+	void onChannelAwayStateOther(Parser tParser, ChannelInfo channel, ChannelClientInfo channelClient, boolean state);
45
+}

+ 47
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelPartListener.java Näytä tiedosto

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.SpecificCallback;
29
+
30
+/** 
31
+ * Called When we, or another client parts a channel.
32
+ * This is called BEFORE client has been removed from the channel.
33
+ */
34
+@SpecificCallback
35
+public interface ChannelPartListener extends CallbackInterface {
36
+	/**
37
+	 * Called When we, or another client parts a channel.
38
+	 * This is called BEFORE client has been removed from the channel.
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param cChannel Channel that the user parted
42
+	 * @param cChannelClient Client that parted
43
+	 * @param sReason Reason given for parting (May be "")
44
+	 * @see com.dmdirc.parser.irc.ProcessPart#callChannelPart
45
+	 */
46
+	void onChannelPart(Parser tParser, ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sReason);
47
+}

+ 47
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelQuitListener.java Näytä tiedosto

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.SpecificCallback;
29
+
30
+/** 
31
+ * Called When we, or another client quits IRC (Called once per channel the user was on).
32
+ * This is called BEFORE client has been removed from the channel.
33
+ */
34
+@SpecificCallback
35
+public interface ChannelQuitListener extends CallbackInterface {
36
+	/**
37
+	 * Called When we, or another client quits IRC (Called once per channel the user was on).
38
+	 * This is called BEFORE client has been removed from the channel.
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param cChannel Channel that user was on
42
+	 * @param cChannelClient User thats quitting
43
+	 * @param sReason Quit reason
44
+	 * @see com.dmdirc.parser.irc.ProcessQuit#callChannelQuit
45
+	 */
46
+	void onChannelQuit(Parser tParser, ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sReason);
47
+}

+ 42
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelSelfJoinListener.java Näytä tiedosto

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+
28
+/** 
29
+ * Called When we join a channel.
30
+ * We are NOT added as a channelclient until after the names reply
31
+ */
32
+public interface ChannelSelfJoinListener extends CallbackInterface {
33
+	/**
34
+	 * Called When we join a channel.
35
+	 * We are NOT added as a channelclient until after the names reply
36
+	 * 
37
+	 * @param tParser Reference to the parser object that made the callback.
38
+	 * @param cChannel Channel Object
39
+	 * @see com.dmdirc.parser.irc.ProcessJoin#callChannelSelfJoin
40
+	 */
41
+	void onChannelSelfJoin(Parser tParser, ChannelInfo cChannel);
42
+}

+ 56
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelSingleModeChangeListener.java Näytä tiedosto

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/** 
33
+ * Called when the channel modes are changed or discovered.
34
+ * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
35
+ * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it
36
+ */
37
+@SpecificCallback
38
+public interface ChannelSingleModeChangeListener extends CallbackInterface {
39
+	/**
40
+	 * Called when the channel modes are changed or discovered.
41
+	 * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
42
+	 * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it
43
+	 * 
44
+	 * @param tParser Reference to the parser object that made the callback.
45
+	 * @param cChannel Channel where modes were changed
46
+	 * @param cChannelClient Client chaning the modes (null if server)
47
+	 * @param sHost Host doing the mode changing (User host or server name)
48
+	 * @param sModes String parsed (ie "+m" or "+k moo"
49
+	 */
50
+	void onChannelSingleModeChanged(@FakableSource Parser tParser,
51
+            @FakableSource ChannelInfo cChannel,
52
+            @FakableArgument ChannelClientInfo cChannelClient,
53
+            @FakableSource String sHost,
54
+            String sModes);
55
+}
56
+

+ 45
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelTopicListener.java Näytä tiedosto

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.SpecificCallback;
28
+
29
+/** 
30
+ * Called when the topic is changed or discovered for the first time.
31
+ * bIsNewTopic is true if someone sets the topic, false if the topic is discovered on join
32
+ */
33
+@SpecificCallback
34
+public interface ChannelTopicListener extends CallbackInterface {
35
+	/**
36
+	 * Called when the topic is changed or discovered for the first time.
37
+	 * bIsNewTopic is true if someone sets the topic, false if the topic is discovered on join
38
+	 * 
39
+	 * @param tParser Reference to the parser object that made the callback.
40
+	 * @param cChannel Channel that topic was set on
41
+	 * @param bIsJoinTopic True when getting topic on join, false if set by user/server
42
+	 * @see com.dmdirc.parser.irc.ProcessTopic#callChannelTopic
43
+	 */
44
+	void onChannelTopic(Parser tParser, ChannelInfo cChannel, boolean bIsJoinTopic);
45
+}

+ 56
- 0
src/com/dmdirc/parser/interfaces/callbacks/ChannelUserModeChangeListener.java Näytä tiedosto

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.FakableArgument;
29
+import com.dmdirc.parser.interfaces.FakableSource;
30
+import com.dmdirc.parser.interfaces.SpecificCallback;
31
+
32
+/** 
33
+ * Called when a users channel mode is changed.
34
+ */
35
+@SpecificCallback
36
+public interface ChannelUserModeChangeListener extends CallbackInterface {
37
+	/**
38
+	 * Called when a users channel mode is changed.
39
+	 * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
40
+	 * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it
41
+	 * 
42
+	 * @param tParser Reference to the parser object that made the callback.
43
+	 * @param cChannel Channel where modes were changed
44
+	 * @param cChangedClient Client being changed
45
+	 * @param cSetByClient Client chaning the modes (null if server)
46
+	 * @param sHost Host doing the mode changing (User host or server name)
47
+	 * @param sMode String representing mode change (ie +o)
48
+	 * @see com.dmdirc.parser.irc.ProcessMode#callChannelUserModeChanged
49
+	 */
50
+	void onChannelUserModeChanged(@FakableSource Parser tParser,
51
+            @FakableSource ChannelInfo cChannel,
52
+            ChannelClientInfo cChangedClient,
53
+            @FakableArgument ChannelClientInfo cSetByClient,
54
+            @FakableSource String sHost,
55
+            String sMode);
56
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/ConnectErrorListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.common.ParserError;
27
+
28
+/**
29
+ * Called to give Error Information related to a connection attempt.
30
+ */
31
+public interface ConnectErrorListener extends CallbackInterface {
32
+	/**
33
+	 * Called to give Error Information related to a connection attempt.
34
+	 * 
35
+	 * @param tParser Reference to the parser object that made the callback.
36
+	 * @param errorInfo ParserError object representing the error.
37
+	 * @see com.dmdirc.parser.irc.IRCParser#callConnectError
38
+	 */
39
+	void onConnectError(Parser tParser, ParserError errorInfo);
40
+}

+ 39
- 0
src/com/dmdirc/parser/interfaces/callbacks/DataInListener.java Näytä tiedosto

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used on every incomming line BEFORE parsing.
29
+ */
30
+public interface DataInListener extends CallbackInterface {
31
+	/**
32
+	 * Called on every incomming line BEFORE parsing.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param sData Incomming Line.
36
+	 * @see com.dmdirc.parser.irc.IRCParser#callDataIn
37
+	 */
38
+	void onDataIn(Parser tParser, String sData);
39
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/DataOutListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called on every incomming line BEFORE being sent.
29
+ */
30
+public interface DataOutListener extends CallbackInterface {
31
+	/**
32
+	 * Called on every incomming line BEFORE being sent.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param sData Outgoing Data
36
+	 * @param bFromParser True if parser sent the data, false if sent using .sendLine
37
+	 * @see com.dmdirc.parser.irc.IRCParser#callDataOut
38
+	 */
39
+	void onDataOut(Parser tParser, String sData, boolean bFromParser);
40
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/DebugInfoListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used to give Debug Information.
29
+ */
30
+public interface DebugInfoListener extends CallbackInterface {
31
+	/**
32
+	 * This callback is used to provide occasional debug information from the parser.
33
+	 *
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param nLevel Debugging Level (ndInfo, ndSocket etc)
36
+	 * @param sData Debugging Information
37
+	 * @see com.dmdirc.parser.irc.IRCParser#callDebugInfo
38
+	 */
39
+	void onDebugInfo(Parser tParser, int nLevel, String sData);
40
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/ErrorInfoListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.common.ParserError;
27
+
28
+/**
29
+ * Called to give Error Information.
30
+ */
31
+public interface ErrorInfoListener extends CallbackInterface {
32
+	/**
33
+	 * Called to give Error Information.
34
+	 * 
35
+	 * @param tParser Reference to the parser object that made the callback.
36
+	 * @param errorInfo ParserError object representing the error.
37
+	 * @see com.dmdirc.parser.irc.IRCParser#callErrorInfo
38
+	 */
39
+	void onErrorInfo(Parser tParser, ParserError errorInfo);
40
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/InviteListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when we are invited to a channel.
29
+ */
30
+public interface InviteListener extends CallbackInterface {
31
+	/**
32
+	 * Called when we are invited to a channel.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param userHost Hostname of user who invited us
36
+	 * @param channel Channel we were invited to
37
+	 * @see com.dmdirc.parser.irc.ProcessInvite#callInvite
38
+	 */
39
+	void onInvite(Parser tParser, String userHost, String channel);
40
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/MotdEndListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when "End of MOTD" or "No MOTD" is received.
29
+ */
30
+public interface MotdEndListener extends CallbackInterface {
31
+	/**
32
+	 * Called when "End of MOTD" or "No MOTD".
33
+	 *
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param noMOTD Set to true if this was a "No MOTD Found" message rather than an "End of MOTD"
36
+	 * @param sData The contents of the line (incase of language changes or so)
37
+	 * @see com.dmdirc.parser.irc.ProcessMOTD#callMOTDEnd
38
+	 */
39
+	void onMOTDEnd(Parser tParser, boolean noMOTD, String sData);
40
+}

+ 39
- 0
src/com/dmdirc/parser/interfaces/callbacks/MotdLineListener.java Näytä tiedosto

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used to give MOTD Information.
29
+ */
30
+public interface MotdLineListener extends CallbackInterface {
31
+	/**
32
+	 * Called on every incomming line from the MOTD.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param sData Incomming Line.
36
+	 * @see com.dmdirc.parser.irc.ProcessMOTD#callMOTDLine
37
+	 */
38
+	void onMOTDLine(Parser tParser, String sData);
39
+}

+ 39
- 0
src/com/dmdirc/parser/interfaces/callbacks/MotdStartListener.java Näytä tiedosto

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used when the MOTD Starts.
29
+ */
30
+public interface MotdStartListener extends CallbackInterface {
31
+	/**
32
+	 * Called on MOTD Start.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param sData Incomming Line.
36
+	 * @see com.dmdirc.parser.irc.ProcessMOTD#callMOTDStart
37
+	 */
38
+	void onMOTDStart(Parser tParser, String sData);
39
+}

+ 42
- 0
src/com/dmdirc/parser/interfaces/callbacks/NetworkDetectedListener.java Näytä tiedosto

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used when the Network=blah 005 token is recieved.
29
+ */
30
+public interface NetworkDetectedListener extends CallbackInterface {
31
+	/**
32
+	 * Called when the Network=blah 005 token is recieved.
33
+	 * if NETWORK= is not sent in 005, this will not be called.
34
+	 * 
35
+	 * @param tParser Reference to the parser object that made the callback.
36
+	 * @param networkName The name of the network.
37
+	 * @param ircdVersion The version of the ircd.
38
+	 * @param ircdType The Guessed type of the ircd based on the name.
39
+	 * @see com.dmdirc.parser.irc.Process004005#callGotNetwork
40
+	 */
41
+	void onGotNetwork(Parser tParser, String networkName, String ircdVersion, String ircdType);
42
+}

+ 43
- 0
src/com/dmdirc/parser/interfaces/callbacks/NickChangeListener.java Näytä tiedosto

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+
28
+/**
29
+ * Called when we or another user change nickname.
30
+ * This is called after the nickname change has been done internally
31
+ */
32
+public interface NickChangeListener extends CallbackInterface {
33
+	/**
34
+	 * Called when we or another user change nickname.
35
+	 * This is called after the nickname change has been done internally
36
+	 * 
37
+	 * @param tParser Reference to the parser object that made the callback.
38
+	 * @param cClient Client changing nickname
39
+	 * @param sOldNick Nickname before change
40
+	 * @see com.dmdirc.parser.irc.ProcessNick#callNickChanged
41
+	 */
42
+	void onNickChanged(Parser tParser, ClientInfo cClient, String sOldNick);
43
+}

+ 39
- 0
src/com/dmdirc/parser/interfaces/callbacks/NickInUseListener.java Näytä tiedosto

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when requested nickname is in use.
29
+ */
30
+public interface NickInUseListener extends CallbackInterface {
31
+	/**
32
+	 * Called when requested nickname is in use.
33
+	 *
34
+	 * @param nickname Nickname that was wanted.
35
+	 * @param tParser Reference to the parser object that made the callback.
36
+	 * @see com.dmdirc.parser.irc.ProcessNickInUse#callNickInUse
37
+	 */
38
+	void onNickInUse(Parser tParser, String nickname);
39
+}

+ 40
- 0
src/com/dmdirc/parser/interfaces/callbacks/NumericListener.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used to give numeric Information.
29
+ */
30
+public interface NumericListener extends CallbackInterface {
31
+	/**
32
+	 * Called on every incomming line with a numerical type.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param numeric What numeric is this for
36
+	 * @param token IRC Tokenised line
37
+	 * @see com.dmdirc.parser.irc.ProcessingManager#callNumeric
38
+	 */
39
+	void onNumeric(Parser tParser, int numeric, String[] token);
40
+}

+ 43
- 0
src/com/dmdirc/parser/interfaces/callbacks/OtherAwayStateListener.java Näytä tiedosto

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.SpecificCallback;
28
+
29
+/**
30
+ * Called when we go away, or come back.
31
+ */
32
+@SpecificCallback
33
+public interface OtherAwayStateListener extends CallbackInterface {
34
+	/**
35
+	 * Called when we go away, or come back.
36
+	 *
37
+	 * @param tParser Reference to the parser object that made the callback.
38
+	 * @param client Client this is for
39
+	 * @param state Away State (true if away, false if here)
40
+	 * @see com.dmdirc.parser.irc.ProcessAway#callAwayStateOther
41
+	 */
42
+	void onAwayStateOther(Parser tParser, ClientInfo client, boolean state);
43
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/callbacks/PasswordRequiredListener.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used when a raw 464 is recieved.
29
+ */
30
+public interface PasswordRequiredListener extends CallbackInterface {
31
+	/**
32
+	 * Called when a raw 464 is recieved.
33
+	 *
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @see com.dmdirc.parser.irc.Process004005#callPasswordRequired
36
+	 */
37
+	void onPasswordRequired(Parser tParser);
38
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/callbacks/PingFailureListener.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a Ping Failed.
29
+ */
30
+public interface PingFailureListener extends CallbackInterface {
31
+	/**
32
+	 * Called when a ping failed.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @see IRCParser#callPingFailed
36
+	 */
37
+	void onPingFailed(Parser tParser);
38
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/callbacks/PingSentListener.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a Ping was Sent.
29
+ */
30
+public interface PingSentListener extends CallbackInterface {
31
+	/**
32
+	 * Called when a ping was Sent.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @see IRCParser#callPingSent
36
+	 */
37
+	void onPingSent(Parser tParser);
38
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/callbacks/PingSuccessListener.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a Ping was a Success.
29
+ */
30
+public interface PingSuccessListener extends CallbackInterface {
31
+	/**
32
+	 * Called when a ping was a Success.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @see IRCParser#callPingSuccess
36
+	 */
37
+	void onPingSuccess(Parser tParser);
38
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/callbacks/Post005Listener.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called after 001.
29
+ */
30
+public interface Post005Listener extends CallbackInterface {
31
+	/**
32
+	 * Called after 005.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @see com.dmdirc.parser.irc.Process001#callPost005
36
+	 */
37
+	void onPost005(Parser tParser);
38
+}

+ 46
- 0
src/com/dmdirc/parser/interfaces/callbacks/PrivateActionListener.java Näytä tiedosto

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when a person does an action to you (PM).
30
+ * sHost is the hostname of the person sending the action. (Can be a server or a person)<br>
31
+ * cClient is null if user is a server, or not on any common channel.
32
+ */
33
+@SpecificCallback
34
+public interface PrivateActionListener extends CallbackInterface {
35
+	/**
36
+	 * Called when a person does an action to you (PM).
37
+	 * sHost is the hostname of the person sending the action. (Can be a server or a person)<br>
38
+	 * cClient is null if user is a server, or not on any common channel.
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param sMessage action contents
42
+	 * @param sHost Hostname of sender (or servername)
43
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callPrivateAction
44
+	 */
45
+	void onPrivateAction(Parser tParser, String sMessage, String sHost);
46
+}

+ 47
- 0
src/com/dmdirc/parser/interfaces/callbacks/PrivateCtcpListener.java Näytä tiedosto

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when a person sends a CTCP to you directly.
30
+ * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
31
+ * cClient is null if user is a server, or not on any common channels.
32
+ */
33
+@SpecificCallback
34
+public interface PrivateCtcpListener extends CallbackInterface {
35
+	/**
36
+	 * Called when a person sends a CTCP to you directly.
37
+	 * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
38
+	 * cClient is null if user is a server, or not on any common channels.
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param sType Type of CTCP (VERSION, TIME etc)
42
+	 * @param sMessage Additional contents
43
+	 * @param sHost Hostname of sender (or servername)
44
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callPrivateCTCP
45
+	 */
46
+	void onPrivateCTCP(Parser tParser, String sType, String sMessage, String sHost);
47
+}

+ 47
- 0
src/com/dmdirc/parser/interfaces/callbacks/PrivateCtcpReplyListener.java Näytä tiedosto

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when a person sends a CTCPRReply to you directly.
30
+ * sHost is the hostname of the person sending the CTCPRReply. (Can be a server or a person)<br>
31
+ * cClient is null if user is a server, or not on any common channels.
32
+ */
33
+@SpecificCallback
34
+public interface PrivateCtcpReplyListener extends CallbackInterface {
35
+	/**
36
+	 * Called when a person sends a CTCPRReply to you directly.
37
+	 * sHost is the hostname of the person sending the CTCPRReply. (Can be a server or a person)<br>
38
+	 * cClient is null if user is a server, or not on any common channels.
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param sType Type of CTCPRReply (VERSION, TIME etc)
42
+	 * @param sMessage Reply Contents
43
+	 * @param sHost Hostname of sender (or servername)
44
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callPrivateCTCPReply
45
+	 */
46
+	void onPrivateCTCPReply(Parser tParser, String sType, String sMessage, String sHost);
47
+}

+ 46
- 0
src/com/dmdirc/parser/interfaces/callbacks/PrivateMessageListener.java Näytä tiedosto

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when a person sends a message to you directly (PM). 
30
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
31
+ * cClient is null if user is a server, or not on any common channel.
32
+ */
33
+@SpecificCallback
34
+public interface PrivateMessageListener extends CallbackInterface {
35
+	/**
36
+	 * Called when a person sends a message to you directly (PM). 
37
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
38
+	 * cClient is null if user is a server, or not on any common channel.
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param sMessage Message contents
42
+	 * @param sHost Hostname of sender (or servername)
43
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callPrivateMessage
44
+	 */
45
+	void onPrivateMessage(Parser tParser, String sMessage, String sHost);
46
+}

+ 46
- 0
src/com/dmdirc/parser/interfaces/callbacks/PrivateNoticeListener.java Näytä tiedosto

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when a person sends a notice to you.
30
+ * sHost is the hostname of the person sending the notice. (Can be a server or a person)<br>
31
+ * cClient is null if user is a server, or not on any common channel.
32
+ */
33
+@SpecificCallback
34
+public interface PrivateNoticeListener extends CallbackInterface {
35
+	/**
36
+	 * Called when a person sends a notice to you.
37
+	 * sHost is the hostname of the person sending the notice. (Can be a server or a person)<br>
38
+	 * cClient is null if user is a server, or not on any common channel.
39
+	 * 
40
+	 * @param tParser Reference to the parser object that made the callback.
41
+	 * @param sMessage Notice contents
42
+	 * @param sHost Hostname of sender (or servername)
43
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callPrivateNotice
44
+	 */
45
+	void onPrivateNotice(Parser tParser, String sMessage, String sHost);
46
+}

+ 43
- 0
src/com/dmdirc/parser/interfaces/callbacks/QuitListener.java Näytä tiedosto

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+
28
+/** 
29
+ * Called When we, or another client quits IRC (Called once in total).
30
+ * This is called BEFORE client has been removed from the channel.
31
+ */
32
+public interface QuitListener extends CallbackInterface {
33
+	/**
34
+	 * Called When we, or another client quits IRC (Called once in total).
35
+	 * This is called BEFORE client has been removed from the channel.
36
+	 *
37
+	 * @param tParser Reference to the parser object that made the callback.
38
+	 * @param cClient Client Quitting
39
+	 * @param sReason Reason for quitting (may be "")
40
+	 * @see com.dmdirc.parser.irc.ProcessQuit#callQuit
41
+	 */
42
+	void onQuit(Parser tParser, ClientInfo cClient, String sReason);
43
+}

+ 39
- 0
src/com/dmdirc/parser/interfaces/callbacks/ServerErrorListener.java Näytä tiedosto

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Interface Used to give ServerError.
29
+ */
30
+public interface ServerErrorListener extends CallbackInterface {
31
+	/**
32
+	 * This callback is used to give messages the server sends as an ERROR.
33
+	 *
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @param sMessage Error Information
36
+	 * @see com.dmdirc.parser.irc.IRCParser#callServerError
37
+	 */
38
+	void onServerError(Parser tParser, String sMessage);
39
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/callbacks/ServerReadyListener.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called after 001.
29
+ */
30
+public interface ServerReadyListener extends CallbackInterface {
31
+	/**
32
+	 * Called after 001.
33
+	 * 
34
+	 * @param tParser Reference to the parser object that made the callback.
35
+	 * @see com.dmdirc.parser.irc.Process001#callServerReady
36
+	 */
37
+	void onServerReady(Parser tParser);
38
+}

+ 38
- 0
src/com/dmdirc/parser/interfaces/callbacks/SocketCloseListener.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when the socket is closed.
29
+ */
30
+public interface SocketCloseListener extends CallbackInterface {
31
+
32
+    /**
33
+	 * Called when the socket is closed.
34
+	 * 
35
+	 * @param tParser Reference to the parser object that made the callback.
36
+	 */
37
+	void onSocketClosed(Parser tParser);
38
+}

+ 45
- 0
src/com/dmdirc/parser/interfaces/callbacks/UnknownActionListener.java Näytä tiedosto

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a person sends an action not aimed specifically at you or a channel (ie $*).
29
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
30
+ * cClient is null if user is a server, or not on any common channel.
31
+ */
32
+public interface UnknownActionListener extends CallbackInterface {
33
+	/**
34
+	 * Called when a person sends an action not aimed specifically at you or a channel (ie $*).
35
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
36
+	 * cClient is null if user is a server, or not on any common channel.
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sMessage Action contents
40
+	 * @param sTarget Actual target of action
41
+	 * @param sHost Hostname of sender (or servername)
42
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callUnknownAction
43
+	 */
44
+	void onUnknownAction(Parser tParser, String sMessage, String sTarget, String sHost);
45
+}

+ 46
- 0
src/com/dmdirc/parser/interfaces/callbacks/UnknownCtcpListener.java Näytä tiedosto

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a person sends a CTCP not aimed at you or a channel (ie $*).
29
+ * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
30
+ * cClient is null if user is a server, or not on any common channels.
31
+ */
32
+public interface UnknownCtcpListener extends CallbackInterface {
33
+	/**
34
+	 * Called when a person sends a CTCP not aimed at you or a channel (ie $*).
35
+	 * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
36
+	 * cClient is null if user is a server, or not on any common channels.
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sType Type of CTCP (VERSION, TIME etc)
40
+	 * @param sMessage Additional contents
41
+	 * @param sTarget Actual Target of CTCP
42
+	 * @param sHost Hostname of sender (or servername)
43
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callUnknownCTCP
44
+	 */
45
+	void onUnknownCTCP(Parser tParser, String sType, String sMessage, String sTarget, String sHost);
46
+}

+ 46
- 0
src/com/dmdirc/parser/interfaces/callbacks/UnknownCtcpReplyListener.java Näytä tiedosto

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a person sends a CTCP not aimed at you or a channel (ie $*).
29
+ * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
30
+ * cClient is null if user is a server, or not on any common channels.
31
+ */
32
+public interface UnknownCtcpReplyListener extends CallbackInterface {
33
+	/**
34
+	 * Called when a person sends a CTCP not aimed at you or a channel (ie $*).
35
+	 * sHost is the hostname of the person sending the CTCP. (Can be a server or a person)<br>
36
+	 * cClient is null if user is a server, or not on any common channels.
37
+	 *
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sType Type of CTCPRReply (VERSION, TIME etc)
40
+	 * @param sMessage Reply Contents
41
+	 * @param sTarget Actual Target of CTCPReply
42
+	 * @param sHost Hostname of sender (or servername)
43
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callUnknownCTCPReply
44
+	 */
45
+	void onUnknownCTCPReply(Parser tParser, String sType, String sMessage, String sTarget, String sHost);
46
+}

+ 45
- 0
src/com/dmdirc/parser/interfaces/callbacks/UnknownMessageListener.java Näytä tiedosto

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a person sends a message not aimed specifically at you or a channel (ie $*).
29
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
30
+ * cClient is null if user is a server, or not on any common channel.
31
+ */
32
+public interface UnknownMessageListener extends CallbackInterface {
33
+	/**
34
+	 * Called when a person sends a message not aimed specifically at you or a channel (ie $*).
35
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
36
+	 * cClient is null if user is a server, or not on any common channel.
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sMessage Message contents
40
+	 * @param sTarget Actual target of message
41
+	 * @param sHost Hostname of sender (or servername)
42
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callUnknownMessage
43
+	 */
44
+	void onUnknownMessage(Parser tParser, String sMessage, String sTarget, String sHost);
45
+}

+ 45
- 0
src/com/dmdirc/parser/interfaces/callbacks/UnknownNoticeListener.java Näytä tiedosto

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+
27
+/**
28
+ * Called when a person sends a notice not aimed specifically at you or a channel (ie $*).
29
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
30
+ * cClient is null if user is a server, or not on any common channel.
31
+ */
32
+public interface UnknownNoticeListener extends CallbackInterface {
33
+	/**
34
+	 * Called when a person sends a notice not aimed specifically at you or a channel (ie $*).
35
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
36
+	 * cClient is null if user is a server, or not on any common channel.
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sMessage Notice contents
40
+	 * @param sTarget Actual target of notice
41
+	 * @param sHost Hostname of sender (or servername)
42
+	 * @see com.dmdirc.parser.irc.ProcessMessage#callUnknownNotice
43
+	 */
44
+	void onUnknownNotice(Parser tParser, String sMessage, String sTarget, String sHost);
45
+}

+ 46
- 0
src/com/dmdirc/parser/interfaces/callbacks/UserModeChangeListener.java Näytä tiedosto

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+
28
+/** 
29
+ * Called when user modes are changed.
30
+ * cClient represents the user who's modes were changed (should ALWAYS be us)<br>
31
+ * sSetby is the host of the person who set the mode (usually us, may be an oper or server in some cases)
32
+ */
33
+public interface UserModeChangeListener extends CallbackInterface {
34
+	/**
35
+	 * Called when user modes are changed.
36
+	 * cClient represents the user who's modes were changed (should ALWAYS be us)<br>
37
+	 * sSetby is the host of the person who set the mode (usually us, may be an oper or server in some cases)
38
+	 * 
39
+	 * @param tParser Reference to the parser object that made the callback.
40
+	 * @param cClient Client that had the mode changed (almost always us)
41
+	 * @param sSetBy Host that set the mode (us or servername)
42
+	 * @param sModes The modes set.
43
+	 * @see com.dmdirc.parser.irc.ProcessMode#callUserModeChanged
44
+	 */
45
+	void onUserModeChanged(Parser tParser, ClientInfo cClient, String sSetBy, String sModes);
46
+}

+ 44
- 0
src/com/dmdirc/parser/interfaces/callbacks/UserModeDiscoveryListener.java Näytä tiedosto

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+
28
+/** 
29
+ * Called when user modes are Discovered.
30
+ * cClient represents the user who's modes were Discovered (should ALWAYS be us)<br>
31
+ * sSetby is the host of the person who set the mode (usually us, may be an oper or server in some cases)
32
+ */
33
+public interface UserModeDiscoveryListener extends CallbackInterface {
34
+	/**
35
+	 * Called when user modes are Discovered.
36
+	 * cClient represents the user who's modes were Discovered (should ALWAYS be us)
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param cClient Client that had the mode changed (almost always us)
40
+	 * @param sModes The modes set.
41
+	 * @see com.dmdirc.parser.irc.ProcessMode#callUserModeDiscovered
42
+	 */
43
+	void onUserModeDiscovered(Parser tParser, ClientInfo cClient, String sModes);
44
+}

+ 44
- 0
src/com/dmdirc/parser/interfaces/callbacks/WallDesyncListener.java Näytä tiedosto

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when a Desync message is recieved over wallops.
30
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
31
+ */
32
+@SpecificCallback
33
+public interface WallDesyncListener extends CallbackInterface {
34
+	/**
35
+	 * Called when a Desync message is recieved over wallops.
36
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sMessage Message contents
40
+	 * @param sHost Hostname of sender (or servername)
41
+	 * @see com.dmdirc.parser.irc.ProcessWallops#callWallDesync
42
+	 */
43
+	void onWallDesync(Parser tParser, String sMessage, String sHost);
44
+}

+ 44
- 0
src/com/dmdirc/parser/interfaces/callbacks/WallopListener.java Näytä tiedosto

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when an oper-only message is recieved over wallops.
30
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
31
+ */
32
+@SpecificCallback
33
+public interface WallopListener extends CallbackInterface {
34
+	/**
35
+	 * Called when an oper-only message is recieved over wallops.
36
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sMessage Message contents
40
+	 * @param sHost Hostname of sender (or servername)
41
+	 * @see com.dmdirc.parser.irc.ProcessWallops#callWallop
42
+	 */
43
+	void onWallop(Parser tParser, String sMessage, String sHost);
44
+}

+ 44
- 0
src/com/dmdirc/parser/interfaces/callbacks/WalluserListener.java Näytä tiedosto

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.interfaces.callbacks;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.SpecificCallback;
27
+
28
+/**
29
+ * Called when an all-users message is recieved over wallops.
30
+ * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
31
+ */
32
+@SpecificCallback
33
+public interface WalluserListener extends CallbackInterface {
34
+	/**
35
+	 * Called when an all-users message is recieved over wallops.
36
+	 * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
37
+	 * 
38
+	 * @param tParser Reference to the parser object that made the callback.
39
+	 * @param sMessage Message contents
40
+	 * @param sHost Hostname of sender (or servername)
41
+	 * @see com.dmdirc.parser.irc.ProcessWallops#callWalluser
42
+	 */
43
+	void onWalluser(Parser tParser, String sMessage, String sHost);
44
+}

+ 29
- 0
src/com/dmdirc/parser/interfaces/callbacks/package-info.java Näytä tiedosto

@@ -0,0 +1,29 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+/**
24
+ * Parser callback interfaces.  Classes wanting to use callbacks will be 
25
+ * required to implement the appropriate interface from this package.
26
+ *
27
+ * @since 0.6.3m2
28
+ */
29
+package com.dmdirc.parser.interfaces.callbacks;

+ 130
- 0
src/com/dmdirc/parser/irc/IRCAuthenticator.java Näytä tiedosto

@@ -0,0 +1,130 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import java.net.Authenticator;
26
+import java.net.PasswordAuthentication;
27
+
28
+import java.util.Map;
29
+import java.util.HashMap;
30
+
31
+/**
32
+ * Handles proxy authentication for the parser.
33
+ * 
34
+ * @author Shane Mc Cormack
35
+ * @see IRCParser
36
+ */
37
+public class IRCAuthenticator extends Authenticator {
38
+    /**
39
+     * A version number for this class. It should be changed whenever the class
40
+     * structure is changed (or anything else that would prevent serialized
41
+     * objects being unserialized with the new class).
42
+     */
43
+    private static final long serialVersionUID = 1;
44
+
45
+    /** Singleton instance of IRCAuthenticator. */
46
+    private static IRCAuthenticator me = null;
47
+    
48
+    /** List of authentication replies. */
49
+    private final Map<String,PasswordAuthentication> replies = new HashMap<String,PasswordAuthentication>();
50
+    
51
+    /**
52
+     * Create a new IRCAuthenticator.
53
+     *
54
+     * This creates an IRCAuthenticator and registers it as the default
55
+     * Authenticator.
56
+     */
57
+    private IRCAuthenticator() {
58
+/*        try {
59
+            final Field field = Authenticator.class.getDeclaredField("theAuthenticator");
60
+            field.setAccessible(true);
61
+            final Object authenticator = field.get(null);
62
+            if (authenticator instanceof Authenticator) {
63
+                oldAuthenticator = (Authenticator)authenticator;
64
+            }
65
+        } catch (NoSuchFieldException nsfe) {
66
+        } catch (IllegalAccessException iae) {
67
+        }*/
68
+        Authenticator.setDefault(this);
69
+    }
70
+    
71
+    /**
72
+     * Get the instance of IRCAuthenticator.
73
+     *
74
+     * @return The IRCAuthenticator instance.
75
+     */
76
+    public static synchronized IRCAuthenticator getIRCAuthenticator() {
77
+        if (me == null) {
78
+            me = new IRCAuthenticator();
79
+        }
80
+        return me;
81
+    }
82
+
83
+    /**
84
+     * Add a server to authenticate for.
85
+     *
86
+     * @param server ServerInfo object with proxy details.
87
+     */
88
+    public void addAuthentication(final ServerInfo server) {
89
+        addAuthentication(server.getProxyHost(), server.getProxyPort(), server.getProxyUser(), server.getProxyPass());
90
+    }
91
+
92
+    /**
93
+     * Add a host to authenticate for.
94
+     *
95
+     * @param host Hostname
96
+     * @param port Port
97
+     * @param username Username to return for authentication
98
+     * @param password Password to return for authentication
99
+     */
100
+    public void addAuthentication(final String host, final int port, final String username, final String password) {
101
+        if (username == null || password == null || username.isEmpty() || password.isEmpty()) {
102
+            return;
103
+        }
104
+        final PasswordAuthentication pass = new PasswordAuthentication(username, password.toCharArray());
105
+        final String fullhost = host.toLowerCase()+":"+port;
106
+        
107
+        if (replies.containsKey(fullhost)) {
108
+            replies.remove(fullhost);
109
+        }
110
+        
111
+        replies.put(fullhost, pass);
112
+    }
113
+    
114
+    /** {@inheritDoc} */
115
+    protected PasswordAuthentication getPasswordAuthentication() {
116
+        /*
117
+         * getRequestingHost: 85.234.138.2
118
+         * getRequestingPort: 1080
119
+         * getRequestingPrompt: SOCKS authentication
120
+         * getRequestingProtocol: SOCKS5
121
+         * getRequestingScheme: null
122
+         * getRequestingSite: /85.234.138.2
123
+         * getRequestingURL: null
124
+         * getRequestorType: SERVER
125
+         */
126
+
127
+        final String fullhost = getRequestingHost().toLowerCase()+":"+getRequestingPort();
128
+        return replies.get(fullhost);
129
+    }
130
+}

+ 55
- 0
src/com/dmdirc/parser/irc/IRCCallbackManager.java Näytä tiedosto

@@ -0,0 +1,55 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.common.CallbackObjectSpecific;
26
+import com.dmdirc.parser.common.CallbackObject;
27
+import com.dmdirc.parser.common.CallbackManager;
28
+import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
29
+
30
+/**
31
+ * Handles callbacks for the IRC Parser.
32
+ * 
33
+ * @author chris
34
+ */
35
+public class IRCCallbackManager extends CallbackManager<IRCParser> {
36
+
37
+    public IRCCallbackManager(final IRCParser parser) {
38
+        super(parser);
39
+    }
40
+
41
+    /** {@inheritDoc} */
42
+    @Override
43
+    protected CallbackObject getCallbackObject(final IRCParser parser, final Class<?> type) {
44
+        return new IRCCallbackObject(parser, this, type.asSubclass(CallbackInterface.class));
45
+    }
46
+
47
+    /** {@inheritDoc} */
48
+    @Override
49
+    protected CallbackObjectSpecific getSpecificCallbackObject(final IRCParser parser,
50
+            final Class<?> type) {
51
+        return new IRCCallbackObjectSpecific(parser, this,
52
+                type.asSubclass(CallbackInterface.class));
53
+    }
54
+
55
+}

+ 65
- 0
src/com/dmdirc/parser/irc/IRCCallbackObject.java Näytä tiedosto

@@ -0,0 +1,65 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.common.CallbackManager;
26
+import com.dmdirc.parser.common.CallbackObject;
27
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
28
+import com.dmdirc.parser.interfaces.ChannelInfo;
29
+import com.dmdirc.parser.interfaces.ClientInfo;
30
+import com.dmdirc.parser.interfaces.LocalClientInfo;
31
+import com.dmdirc.parser.interfaces.Parser;
32
+import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
33
+import java.util.HashMap;
34
+import java.util.Map;
35
+
36
+/**
37
+ * A callback object for the IRC parser.
38
+ *
39
+ * @since 0.6.3m2
40
+ * @author chris
41
+ */
42
+public class IRCCallbackObject extends CallbackObject {
43
+
44
+    /** A map of interfaces to the classes which should be instansiated for them. */
45
+    protected static Map<Class<?>, Class<?>> IMPL_MAP = new HashMap<Class<?>, Class<?>>();
46
+
47
+    static {
48
+        IMPL_MAP.put(ChannelClientInfo.class, IRCChannelClientInfo.class);
49
+        IMPL_MAP.put(ChannelInfo.class, IRCChannelInfo.class);
50
+        IMPL_MAP.put(ClientInfo.class, IRCClientInfo.class);
51
+        IMPL_MAP.put(LocalClientInfo.class, IRCClientInfo.class);
52
+    }
53
+
54
+    public IRCCallbackObject(Parser parser, CallbackManager<?> manager,
55
+            Class<? extends CallbackInterface> type) {
56
+        super(parser, manager, type);
57
+    }
58
+
59
+    /** {@inheritDoc} */
60
+    @Override
61
+    protected Class<?> getImplementation(Class<?> type) {
62
+        return IMPL_MAP.containsKey(type) ? IMPL_MAP.get(type) : type;
63
+    }
64
+
65
+}

+ 71
- 0
src/com/dmdirc/parser/irc/IRCCallbackObjectSpecific.java Näytä tiedosto

@@ -0,0 +1,71 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.common.CallbackManager;
26
+import com.dmdirc.parser.common.CallbackObjectSpecific;
27
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
28
+import com.dmdirc.parser.interfaces.ChannelInfo;
29
+import com.dmdirc.parser.interfaces.ClientInfo;
30
+import com.dmdirc.parser.interfaces.LocalClientInfo;
31
+import com.dmdirc.parser.interfaces.Parser;
32
+import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
33
+import java.util.HashMap;
34
+import java.util.Map;
35
+
36
+/**
37
+ * A specific callback object for use with the IRC Parser
38
+ *
39
+ * @since 0.6.3m2
40
+ * @author chris
41
+ */
42
+public class IRCCallbackObjectSpecific extends CallbackObjectSpecific {
43
+
44
+    /** A map of interfaces to the classes which should be instansiated for them. */
45
+    protected static Map<Class<?>, Class<?>> IMPL_MAP = new HashMap<Class<?>, Class<?>>();
46
+
47
+    static {
48
+        IMPL_MAP.put(ChannelClientInfo.class, IRCChannelClientInfo.class);
49
+        IMPL_MAP.put(ChannelInfo.class, IRCChannelInfo.class);
50
+        IMPL_MAP.put(ClientInfo.class, IRCClientInfo.class);
51
+        IMPL_MAP.put(LocalClientInfo.class, IRCClientInfo.class);
52
+    }
53
+
54
+    public IRCCallbackObjectSpecific(final Parser parser,
55
+            final CallbackManager<?> manager, final Class<? extends CallbackInterface> type) {
56
+        super(parser, manager, type);
57
+    }
58
+
59
+    /** {@inheritDoc} */
60
+    @Override
61
+    protected String translateHostname(final String hostname) {
62
+        return IRCClientInfo.parseHost(hostname);
63
+    }
64
+
65
+    /** {@inheritDoc} */
66
+    @Override
67
+    protected Class<?> getImplementation(Class<?> type) {
68
+        return IMPL_MAP.containsKey(type) ? IMPL_MAP.get(type) : type;
69
+    }
70
+
71
+}

+ 207
- 0
src/com/dmdirc/parser/irc/IRCChannelClientInfo.java Näytä tiedosto

@@ -0,0 +1,207 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import java.util.HashMap;
28
+import java.util.Map;
29
+
30
+/**
31
+ * Contains information about a client on a channel.
32
+ * 
33
+ * @author Shane Mc Cormack
34
+ * @author Chris Smith
35
+ * @see IRCParser
36
+ */
37
+public class IRCChannelClientInfo implements ChannelClientInfo {
38
+    
39
+    /** Reference to ClientInfo object this represents. */
40
+    private final IRCClientInfo cClient;
41
+    /** Integer representation of the channel modes assocated with this user. */
42
+    private long nModes;
43
+    /** Reference to the parser object that owns this channelclient, Used for modes. */
44
+    private final IRCParser myParser;
45
+    /** Reference to the channel object that owns this channelclient. */
46
+    private final ChannelInfo myChannel;
47
+    /** A Map to allow applications to attach misc data to this object */
48
+    private Map<Object, Object> myMap;
49
+    
50
+    /**
51
+     * Create a ChannelClient instance of a CLient.
52
+     *
53
+     * @param tParser Refernce to parser that owns this channelclient (used for modes)
54
+     * @param client Client that this channelclient represents
55
+     * @param channel Channel that owns this channelclient
56
+     */    
57
+    public IRCChannelClientInfo(final IRCParser tParser, final IRCClientInfo client, final ChannelInfo channel) {
58
+        myMap = new HashMap<Object, Object>();
59
+        myParser = tParser;
60
+        cClient = client;
61
+        myChannel = channel;
62
+        cClient.addChannelClientInfo(this);
63
+    }
64
+    
65
+    /**
66
+     * Set the Map object attatched to this object.
67
+     *
68
+     * @param newMap New Map to attatch.
69
+     * @see #getMap
70
+     */
71
+    public void setMap(final Map<Object, Object> newMap) {
72
+        myMap = newMap;
73
+    }
74
+    
75
+    /** {@inheritDoc} */
76
+        @Override
77
+    public Map<Object, Object> getMap() { return myMap; }
78
+    
79
+    /** {@inheritDoc} */
80
+        @Override
81
+    public IRCClientInfo getClient() { return cClient; }
82
+
83
+    /** {@inheritDoc} */
84
+        @Override
85
+    public ChannelInfo getChannel() { return myChannel; }
86
+    /**
87
+     * Get the nickname of the client object represented by this channelclient.
88
+     *
89
+     * @return Nickname of the Client object represented by this channelclient
90
+     */    
91
+    public String getNickname() { return cClient.getNickname(); }    
92
+    
93
+    /**
94
+     * Set the modes this client has (Prefix modes).
95
+     *
96
+     * @param nNewMode integer representing the modes this client has.
97
+     */
98
+    public void setChanMode(final long nNewMode) { nModes = nNewMode; }
99
+    /**
100
+     * Get the modes this client has (Prefix modes).
101
+     *
102
+     * @return integer representing the modes this client has.
103
+     */
104
+    public long getChanMode() { return nModes; }
105
+    
106
+    /**
107
+     * Get the modes this client has (Prefix modes) as a string.
108
+     * Returns all known modes that the client has.
109
+     * getChanModeStr(false).charAt(0) can be used to get the highest mode (o)
110
+     * getChanModeStr(true).charAt(0) can be used to get the highest prefix (@)
111
+     *
112
+     * @param bPrefix if this is true, prefixes will be returned (@+) not modes (ov)
113
+     * @return String representing the modes this client has.
114
+     */
115
+    public String getChanModeStr(final boolean bPrefix) {
116
+        StringBuilder sModes = new StringBuilder();
117
+        long nTemp = 0;
118
+        final long nCurrentModes = this.getChanMode();
119
+
120
+        for (long i = myParser.nextKeyPrefix; i > 0; i = i / 2) {
121
+            if ((nCurrentModes & i) == i) {
122
+                for (char cTemp : myParser.prefixModes.keySet()) {
123
+                    nTemp = myParser.prefixModes.get(cTemp);
124
+                    if (nTemp == i) {
125
+                        if (bPrefix) { cTemp = myParser.prefixMap.get(cTemp); }
126
+                        sModes = sModes.append(cTemp);
127
+                        break;
128
+                    }
129
+                }
130
+            }
131
+        }
132
+        
133
+        return sModes.toString();
134
+    }
135
+
136
+    /** {@inheritDoc} */
137
+    @Override
138
+    public String getAllModes() {
139
+        return getChanModeStr(false);
140
+    }
141
+
142
+    /**
143
+     * Get the value of the most important mode this client has (Prefix modes).
144
+     * A higher value, is a more important mode, 0 = no modes.
145
+     *
146
+     * @return integer representing the value of the most important mode.
147
+     */
148
+    public long getImportantModeValue() {
149
+        for (long i = myParser.nextKeyPrefix; i > 0; i = i / 2) {
150
+            if ((nModes & i) == i) { return i; }
151
+        }
152
+        return 0;
153
+    }
154
+    
155
+    /** {@inheritDoc} */
156
+        @Override
157
+    public String getImportantMode() {
158
+        String sModes = this.getChanModeStr(false);
159
+        if (!sModes.isEmpty()) { sModes = "" + sModes.charAt(0); }
160
+        return sModes;
161
+    }
162
+    
163
+    /** {@inheritDoc} */
164
+        @Override
165
+    public String getImportantModePrefix() {
166
+        String sModes = this.getChanModeStr(true);
167
+        if (!sModes.isEmpty()) { sModes = "" + sModes.charAt(0); }
168
+        return sModes;
169
+    }
170
+    
171
+
172
+    /**
173
+     * Get the String Value of ChannelClientInfo (ie @Nickname).
174
+     *
175
+     * @return String Value of user (inc prefix) (ie @Nickname)
176
+     */
177
+    @Override
178
+    public String toString() { 
179
+        return this.getImportantModePrefix() + this.getNickname();
180
+    }    
181
+    
182
+    /** {@inheritDoc} */
183
+        @Override
184
+    public void kick(final String sReason) {
185
+        myParser.sendString("KICK " + myChannel + " " + this.getNickname() + (sReason.isEmpty() ? sReason : " :" + sReason));
186
+    }
187
+    
188
+    /**
189
+     * Get the "Complete" String Value of ChannelClientInfo (ie @+Nickname).
190
+     *
191
+     * @return String Value of user (inc prefix) (ie @+Nickname)
192
+     */
193
+    public String toFullString() { return this.getChanModeStr(true) + this.getNickname(); }
194
+
195
+        /** {@inheritDoc} */
196
+        @Override
197
+        public int compareTo(final ChannelClientInfo arg0) {
198
+            if (arg0 instanceof IRCChannelClientInfo) {
199
+                final IRCChannelClientInfo other = (IRCChannelClientInfo) arg0;
200
+                return (int) (getImportantModeValue() - other.getImportantModeValue());
201
+            }
202
+
203
+            return 0;
204
+        }
205
+
206
+}
207
+

+ 742
- 0
src/com/dmdirc/parser/irc/IRCChannelInfo.java Näytä tiedosto

@@ -0,0 +1,742 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.common.ChannelListModeItem;
26
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
27
+import com.dmdirc.parser.interfaces.ChannelInfo;
28
+import com.dmdirc.parser.interfaces.ClientInfo;
29
+import com.dmdirc.parser.interfaces.Parser;
30
+import com.dmdirc.parser.common.QueuePriority;
31
+import java.util.ArrayList;
32
+import java.util.Collection;
33
+import java.util.Hashtable;
34
+import java.util.HashMap;
35
+import java.util.LinkedList;
36
+import java.util.List;
37
+import java.util.Map;
38
+import java.util.Queue;
39
+
40
+/**
41
+ * Contains Channel information.
42
+ * 
43
+ * @author Shane Mc Cormack
44
+ * @author Chris Smith
45
+ * @see IRCParser
46
+ */
47
+public class IRCChannelInfo implements ChannelInfo {
48
+    /**
49
+     * Boolean repreenting the status of names requests.
50
+     * When this is false, any new names reply will cause current known channelclients to be removed.
51
+     */
52
+    private boolean bAddingNames = true;
53
+    
54
+    /** Unixtimestamp representing time when the channel was created. */
55
+    private long nCreateTime = 0;
56
+    
57
+    /** Current known topic in the channel. */
58
+    private String sTopic = "";
59
+    /** Last known user to set the topic (Full host where possible). */
60
+    private String sTopicUser = "";
61
+    /** Unixtimestamp representing time when the topic was set. */
62
+    private long nTopicTime = 0;
63
+    
64
+    /** Known boolean-modes for channel. */
65
+    private long nModes;
66
+    /** Reference to the parser object that owns this channel, Used for modes. */
67
+    private final IRCParser myParser; // Reference to parser object that owns this channel. Used for Modes
68
+    
69
+    /** Channel Name. */
70
+    private final String sName;
71
+    
72
+    /** Hashtable containing references to ChannelClients. */
73
+    private final Map<String, IRCChannelClientInfo> hChannelUserList = new Hashtable<String, IRCChannelClientInfo>();
74
+    /** Hashtable storing values for modes set in the channel that use parameters. */
75
+    private final Map<Character, String> hParamModes = new Hashtable<Character, String>();
76
+    /** Hashtable storing list modes. */
77
+    private final Map<Character, ArrayList<ChannelListModeItem>> hListModes = new Hashtable<Character, ArrayList<ChannelListModeItem>>();
78
+    /**
79
+     * LinkedList storing status of mode adding.
80
+     * if an item is in this list for a mode, we are expecting new items for the list
81
+     */
82
+    private final List<Character> lAddingModes = new LinkedList<Character>();
83
+    /** Modes waiting to be sent to the server. */
84
+    private final List<String> lModeQueue = new LinkedList<String>();
85
+    /** A Map to allow applications to attach misc data to this object */
86
+    private Map myMap;
87
+    
88
+    /** Queue of requested list modes */
89
+    private final Queue<Character> listModeQueue = new LinkedList<Character>();
90
+    /** Listmode Queue Time */
91
+    private long listModeQueueTime = System.currentTimeMillis();
92
+    /** Have we asked the server for the list modes for this channel yet? */
93
+    private boolean askedForListModes = false;
94
+    /** Has OnChannelGotListModes ever been called for this channel? */
95
+    private boolean hasGotListModes = false;
96
+
97
+    /**
98
+     * Create a new channel object.
99
+     *
100
+     * @param tParser Refernce to parser that owns this channelclient (used for modes)     
101
+     * @param name Channel name.
102
+     */
103
+    public IRCChannelInfo(final IRCParser tParser, final String name) {
104
+        myMap = new HashMap<Object, Object>();
105
+        myParser = tParser;
106
+        sName = name;
107
+    }
108
+    
109
+    /**
110
+     * Get the listModeQueue.
111
+     *
112
+     * @return The listModeQueue
113
+     */
114
+    public Queue<Character> getListModeQueue() {
115
+        Queue<Character> result = listModeQueue;
116
+        final long now = System.currentTimeMillis();
117
+        // Incase of breakage, if getListModeQueue() was last called greater than
118
+        // 60 seconds ago, we reset the list.
119
+        if (now-(30*1000) > listModeQueueTime) {
120
+            result = new LinkedList<Character>();
121
+            myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "Resetting LMQ");
122
+        }
123
+        listModeQueueTime = now;
124
+        return result;
125
+    }
126
+    
127
+    /**
128
+     * Ask the server for all the list modes for this channel.
129
+     */
130
+    public void requestListModes() {
131
+        final IRCChannelClientInfo me = getChannelClient(myParser.getLocalClient());
132
+                
133
+        if (me == null) {
134
+            // In a normal situation of non bouncer-brokenness this won't happen
135
+            return;
136
+        }
137
+        
138
+        askedForListModes = true;
139
+        
140
+        final String thisIRCD = myParser.getIRCD(true).toLowerCase();
141
+        final boolean isFreenode = (thisIRCD.equals("hyperion") || thisIRCD.equals("dancer"));
142
+        final boolean isUnreal = thisIRCD.equals("unreal");
143
+        final boolean isStarChat = thisIRCD.equals("starchat");
144
+        final boolean isHybrid = thisIRCD.equals("hybrid") || thisIRCD.equals("oftc-hybrid");
145
+        final boolean isCharybdis = thisIRCD.equals("charybdis");
146
+        
147
+        // We are considered opped if we have a mode higher than voice (or if we have any modes if voice doesn't exist)
148
+        long voiceValue = 0;
149
+        if (myParser.prefixModes.get('v') != null) { voiceValue = myParser.prefixModes.get('v');}
150
+        final boolean isOpped = me.getImportantModeValue() > voiceValue;
151
+        
152
+        int modecount = 1;
153
+        if (!isUnreal && myParser.h005Info.containsKey("MODES")) {
154
+            try {
155
+                modecount = Integer.parseInt(myParser.h005Info.get("MODES"));
156
+            } catch (NumberFormatException e) { /* use default modecount */}
157
+        }
158
+        
159
+        // Support for potential future decent mode listing in the protocol
160
+        //
161
+        // See my proposal: http://shane.dmdirc.com/listmodes.php
162
+        // Add listmode handler
163
+        final boolean supportLISTMODE = myParser.h005Info.containsKey("LISTMODE");
164
+        
165
+        String listmodes = "";
166
+        int i = 0;
167
+        for (Character cTemp : myParser.chanModesOther.keySet()) {
168
+            final int nTemp = myParser.chanModesOther.get(cTemp);
169
+            if (nTemp == IRCParser.MODE_LIST) {
170
+                if ((isFreenode || isHybrid || isCharybdis) && (cTemp == 'e' || cTemp == 'I') && !isOpped) {
171
+                    // IRCD doesn't allow non-ops to ask for these modes.
172
+                    continue;
173
+                } else if (isStarChat && cTemp == 'H') {
174
+                    // IRCD Denies the mode exists
175
+                    continue;
176
+                }
177
+                i++;
178
+                listmodes = listmodes + cTemp;
179
+                if (i >= modecount && !supportLISTMODE) {
180
+                    myParser.sendString("MODE "+getName()+" "+listmodes, QueuePriority.LOW);
181
+                    i = 0;
182
+                    listmodes = "";
183
+                }
184
+            }
185
+        }
186
+        if (i > 0) {
187
+            if (supportLISTMODE) {
188
+                myParser.sendString("LISTMODE "+getName()+" "+listmodes, QueuePriority.LOW);
189
+            } else {
190
+                myParser.sendString("MODE "+getName()+" "+listmodes, QueuePriority.LOW);
191
+            }
192
+        }
193
+    }
194
+    
195
+    /**
196
+     * Have we ever asked the server for this channels listmodes?
197
+     *
198
+     * @return True if requestListModes() has ever been used, else false
199
+     */
200
+    public boolean hasAskedForListModes() {
201
+        return askedForListModes;
202
+    }
203
+    
204
+    /**
205
+     * Returns true if OnChannelGotListModes ever been called for this channel.
206
+     *
207
+     * @return True if OnChannelGotListModes ever been called for this channel.
208
+     */
209
+    public boolean hasGotListModes() {
210
+        return hasGotListModes;
211
+    }
212
+    
213
+    /**
214
+     * Set if OnChannelGotListModes ever been called for this channel.
215
+     *
216
+     * @param newValue new value for if OnChannelGotListModes ever been called for this channel.
217
+     */
218
+    protected void setHasGotListModes(final boolean newValue) {
219
+        hasGotListModes = newValue;
220
+    }
221
+    
222
+    /**
223
+     * Set the Map object attatched to this object.
224
+     *
225
+     * @param newMap New Map to attatch.
226
+     */
227
+    public void setMap(final Map newMap) {
228
+        myMap = newMap;
229
+    }
230
+    
231
+    /**
232
+     * Get the Map object attatched to this object.
233
+     *
234
+     * @return Map to attatched to this.
235
+     */
236
+    public Map getMap() {
237
+        return myMap;
238
+    }
239
+    
240
+    /**
241
+     * Set if we are getting a names request or not.
242
+     *
243
+     * @param newValue if false, any new names reply will cause current known channelclients to be removed.
244
+     */
245
+    public void setAddingNames(final boolean newValue) { bAddingNames = newValue; }
246
+    
247
+    /**
248
+     * Get if we are getting a names request or not.
249
+     *
250
+     * @return if false, any new names reply will cause current known channelclients to be removed.
251
+     */
252
+    public boolean isAddingNames() { return bAddingNames; }
253
+    
254
+    /** {@inheritDoc} */
255
+        @Override
256
+    public String getName() { return sName; }
257
+
258
+        /** {@inheritDoc} */
259
+        @Override
260
+    public int getChannelClientCount() { return hChannelUserList.size(); }
261
+    
262
+    /** {@inheritDoc} */
263
+        @Override
264
+    public Collection<ChannelClientInfo> getChannelClients() {
265
+        return new ArrayList<ChannelClientInfo>(hChannelUserList.values());
266
+    }
267
+    
268
+    /**
269
+     * Empty the channel (Remove all known channelclients).
270
+     */
271
+    protected void emptyChannel() {
272
+        IRCClientInfo cTemp = null;
273
+        for (IRCChannelClientInfo client : hChannelUserList.values()) {
274
+            cTemp = client.getClient();
275
+            cTemp.delChannelClientInfo(client);
276
+            if (cTemp != myParser.getLocalClient() && !cTemp.checkVisibility()) {
277
+                myParser.removeClient(cTemp);
278
+            }
279
+        }
280
+        hChannelUserList.clear();
281
+    }
282
+
283
+    /** {@inheritDoc} */
284
+        @Override
285
+    public IRCChannelClientInfo getChannelClient(final String sWho) {
286
+        return getChannelClient(sWho, false);
287
+    }
288
+    
289
+    /** {@inheritDoc} */
290
+        @Override
291
+    public IRCChannelClientInfo getChannelClient(final String sWho, final boolean createFake) {
292
+        final String who = myParser.getStringConverter().toLowerCase(IRCClientInfo.parseHost(sWho));
293
+        if (hChannelUserList.containsKey(who)) {
294
+            return hChannelUserList.get(who);
295
+        }
296
+        if (createFake) {
297
+            return new IRCChannelClientInfo(myParser, (new IRCClientInfo(myParser, sWho)).setFake(true), this);
298
+        } else {
299
+            return null;
300
+        }
301
+    }
302
+    
303
+    /** {@inheritDoc} */
304
+        @Override
305
+    public IRCChannelClientInfo getChannelClient(final ClientInfo cWho) {
306
+        for (IRCChannelClientInfo client : hChannelUserList.values()) {
307
+            if (client.getClient() == cWho) {
308
+                return client;
309
+            }
310
+        }
311
+        return null;
312
+    }
313
+    
314
+    /**
315
+     * Get the ChannelClientInfo object associated with a ClientInfo object.
316
+     *
317
+     * @param cClient Client object to be added to channel
318
+     * @return ChannelClientInfo object added, or an existing object if already known on channel
319
+     */
320
+    protected IRCChannelClientInfo addClient(final IRCClientInfo cClient) {
321
+        IRCChannelClientInfo cTemp = getChannelClient(cClient);
322
+        if (cTemp == null) { 
323
+            cTemp = new IRCChannelClientInfo(myParser, cClient, this);
324
+            hChannelUserList.put(myParser.getStringConverter().toLowerCase(cTemp.getClient().getNickname()), cTemp);
325
+        }
326
+        return cTemp;
327
+    }
328
+    
329
+    /**
330
+     * Remove ChannelClientInfo object associated with a ClientInfo object.
331
+     *
332
+     * @param cClient Client object to be removed from channel
333
+     */    
334
+    protected void delClient(final IRCClientInfo cClient) {
335
+        IRCChannelClientInfo cTemp = getChannelClient(cClient);
336
+        if (cTemp != null) {
337
+            final IRCClientInfo clTemp = cTemp.getClient();
338
+            clTemp.delChannelClientInfo(cTemp);
339
+            if (clTemp != myParser.getLocalClient() && !clTemp.checkVisibility()) {
340
+                myParser.removeClient(clTemp);
341
+            }
342
+            hChannelUserList.remove(myParser.getStringConverter().toLowerCase(cTemp.getClient().getNickname()));
343
+        }
344
+    }    
345
+    
346
+    /**
347
+     * Rename a channelClient.
348
+     *
349
+     * @param oldNickname Nickname client used to be known as
350
+     * @param cChannelClient ChannelClient object with updated client object
351
+     */    
352
+    protected void renameClient(final String oldNickname, final IRCChannelClientInfo cChannelClient) {
353
+        if (hChannelUserList.containsKey(oldNickname)) {
354
+            final IRCChannelClientInfo cTemp = hChannelUserList.get(oldNickname);
355
+            if (cTemp == cChannelClient) {
356
+                // Remove the old key
357
+                hChannelUserList.remove(oldNickname);
358
+                // Add with the new key. (getNickname will return the new name not the
359
+                // old one)
360
+                hChannelUserList.put(myParser.getStringConverter().toLowerCase(cTemp.getClient().getNickname()), cTemp);
361
+            }
362
+        }
363
+    }
364
+    
365
+    /**
366
+     * Set the create time.
367
+     *
368
+     * @param nNewTime New unixtimestamp time for the channel creation (Seconds since epoch, not milliseconds)
369
+     */
370
+    protected void setCreateTime(final long nNewTime) { nCreateTime = nNewTime; }
371
+    /**
372
+     * Get the Create time.
373
+     *
374
+     * @return Unixtimestamp time for the channel creation (Seconds since epoch, not milliseconds)
375
+     */
376
+    public long getCreateTime() { return nCreateTime; }    
377
+    
378
+    /**
379
+     * Set the topic time.
380
+     *
381
+     * @param nNewTime New unixtimestamp time for the topic (Seconds since epoch, not milliseconds)
382
+     */
383
+    protected void setTopicTime(final long nNewTime) { nTopicTime = nNewTime; }
384
+
385
+        /** {@inheritDoc} */
386
+        @Override
387
+    public long getTopicTime() { return nTopicTime; }    
388
+    
389
+    /**
390
+     * Set the topic.
391
+     *
392
+     * @param sNewTopic New contents of topic
393
+     */    
394
+    protected void setInternalTopic(final String sNewTopic) { sTopic = sNewTopic; }
395
+    
396
+        /** {@inheritDoc} */
397
+        @Override
398
+    public String getTopic() { return sTopic; }    
399
+
400
+    /**
401
+     * Set the topic creator.
402
+     *
403
+     * @param sNewUser New user who set the topic (nickname if gotten on connect, full host if seen by parser)
404
+     */    
405
+    protected void setTopicUser(final String sNewUser) { sTopicUser = sNewUser; }
406
+    
407
+        /** {@inheritDoc} */
408
+        @Override
409
+    public String getTopicSetter() { return sTopicUser; }
410
+    
411
+    /**
412
+     * Set the channel modes (as an integer).
413
+     *
414
+     * @param nNewMode new long representing channel modes. (Boolean only)
415
+     */    
416
+    protected void setMode(final long nNewMode) { nModes = nNewMode; }
417
+    /**
418
+     * Get the channel modes (as an integer).
419
+     *
420
+     * @return long representing channel modes. (Boolean only)
421
+     */    
422
+    public long getMode() { return nModes; }    
423
+    
424
+    /** {@inheritDoc} */
425
+        @Override
426
+    public String getModes() {
427
+        final StringBuilder sModes = new StringBuilder("+");
428
+        final StringBuilder sModeParams = new StringBuilder();
429
+        String sTemp = "";
430
+        long nTemp = 0;
431
+        final long nChanModes = this.getMode();
432
+        for (char cTemp : myParser.chanModesBool.keySet()) {
433
+            nTemp = myParser.chanModesBool.get(cTemp);
434
+            if ((nChanModes & nTemp) == nTemp) { sModes.append(cTemp); }
435
+        }
436
+        for (char cTemp : hParamModes.keySet()) {
437
+            sTemp = hParamModes.get(cTemp);
438
+            if (!sTemp.isEmpty()) {
439
+                sModes.append(cTemp);
440
+                sModeParams.append(" ").append(this.getMode(cTemp));
441
+             }
442
+        }
443
+        
444
+        return sModes.append(sModeParams).toString();
445
+    }    
446
+    
447
+    /**
448
+     * Set a channel mode that requires a parameter.
449
+     *
450
+     * @param cMode Character representing mode
451
+     * @param sValue String repreenting value (if "" mode is unset)
452
+     */    
453
+    protected void setModeParam(final Character cMode, final String sValue) { 
454
+        if (sValue.isEmpty()) {
455
+            if (hParamModes.containsKey(cMode)) {
456
+                hParamModes.remove(cMode);
457
+            }
458
+        } else {
459
+            hParamModes.put(cMode, sValue);
460
+        }
461
+    }
462
+        
463
+    /** {@inheritDoc} */
464
+        @Override
465
+    public String getMode(final char cMode) {
466
+        if (hParamModes.containsKey(cMode)) { 
467
+            return hParamModes.get(cMode); 
468
+        }
469
+        return "";
470
+    }
471
+    
472
+    /**
473
+     * Add/Remove a value to a channel list.
474
+     *
475
+     * @param givenMode Character representing mode
476
+     * @param givenItem ChannelListModeItem representing the item
477
+     * @param bAdd Add or remove the value. (true for add, false for remove)
478
+     */
479
+    protected void setListModeParam(final Character givenMode, final ChannelListModeItem givenItem, final boolean bAdd) { 
480
+        Character cMode = givenMode;
481
+        ChannelListModeItem newItem = givenItem;
482
+        if (!myParser.chanModesOther.containsKey(cMode) || myParser.chanModesOther.get(cMode) != IRCParser.MODE_LIST) { return; }
483
+        
484
+        // Hyperion sucks.
485
+        if (cMode == 'b' || cMode == 'q') {
486
+            final String thisIRCD = myParser.getIRCD(true).toLowerCase();
487
+            if ((thisIRCD.equals("hyperion") || thisIRCD.equals("dancer"))) {
488
+                if (cMode == 'b' && givenItem.getItem().charAt(0) == '%') {
489
+                    cMode = 'q';
490
+                } else if (cMode == 'q' && givenItem.getItem().charAt(0) != '%') {
491
+                    cMode = 'b';
492
+                }
493
+                if (givenItem.getItem().charAt(0) == '%') {
494
+                    newItem = new ChannelListModeItem(givenItem.getItem().substring(1), givenItem.getOwner(), givenItem.getTime());
495
+                }
496
+            }
497
+        }
498
+        
499
+        if (!hListModes.containsKey(cMode)) { 
500
+            hListModes.put(cMode, new ArrayList<ChannelListModeItem>());    
501
+        }
502
+        final ArrayList<ChannelListModeItem> lModes = hListModes.get(cMode);
503
+        for (int i = 0; i < lModes.size(); i++) {
504
+            if (myParser.getStringConverter().equalsIgnoreCase(lModes.get(i).getItem(), newItem.getItem())) {
505
+                if (bAdd) { return; }
506
+                else { 
507
+                    lModes.remove(i);
508
+                    break;
509
+                }
510
+            }
511
+        }
512
+        if (bAdd) { lModes.add(newItem); }
513
+    }
514
+    
515
+    /** {@inheritDoc} */
516
+        @Override
517
+    public Collection<ChannelListModeItem> getListMode(final char cMode) {
518
+        if (!myParser.chanModesOther.containsKey(cMode) || myParser.chanModesOther.get(cMode) != IRCParser.MODE_LIST) { return null; }
519
+        
520
+        if (!hListModes.containsKey(cMode)) { 
521
+            hListModes.put(cMode, new ArrayList<ChannelListModeItem>());
522
+        }
523
+        return hListModes.get(cMode);
524
+    }
525
+    
526
+    /**
527
+     * Get the "adding state" of a list mode.
528
+     * 
529
+     * @param cMode Character representing mode 
530
+     * @return false if we are not expecting a 367 etc, else true.
531
+     */
532
+    public boolean getAddState(final Character cMode) { 
533
+        synchronized (lAddingModes) {
534
+            return lAddingModes.contains(cMode);
535
+        }
536
+    }
537
+    
538
+    /**
539
+     * Get the "adding state" of a list mode.
540
+     * 
541
+     * @param cMode Character representing mode
542
+     * @param newState change the value returned by getAddState
543
+     */
544
+    protected void setAddState(final Character cMode, final boolean newState) { 
545
+        synchronized (lAddingModes) {
546
+            if (newState) {
547
+                lAddingModes.add(cMode);
548
+            } else {
549
+                if (lAddingModes.contains(cMode)) { lAddingModes.remove(cMode); }
550
+            }
551
+        }
552
+    }
553
+    
554
+    /**
555
+     * Reset the "adding state" of *all* list modes.
556
+     */
557
+    protected void resetAddState() {
558
+        synchronized (lAddingModes) {
559
+            lAddingModes.clear();
560
+        }
561
+    }
562
+    
563
+    /** {@inheritDoc} */
564
+        @Override
565
+    public void alterMode(final boolean positive, final Character mode, final String parameter) { 
566
+        int modecount = 1;
567
+        int modeint = 0;
568
+        String modestr = "";
569
+        if (myParser.h005Info.containsKey("MODES")) {
570
+            try {
571
+                modecount = Integer.parseInt(myParser.h005Info.get("MODES")); 
572
+            } catch (NumberFormatException e) { 
573
+                modecount = 1; 
574
+            }
575
+        }
576
+        if (!myParser.isUserSettable(mode)) { return; }
577
+
578
+        modestr = ((positive) ? "+" : "-") + mode;
579
+        if (myParser.chanModesBool.containsKey(mode)) {
580
+            final String teststr = ((positive) ? "-" : "+") + mode;
581
+            if (lModeQueue.contains(teststr)) {
582
+                lModeQueue.remove(teststr);
583
+                return;
584
+            } else if (lModeQueue.contains(modestr)) {
585
+                return;
586
+            }
587
+        } else {
588
+            // May need a param
589
+            if (myParser.prefixModes.containsKey(mode)) {
590
+                modestr = modestr + " " + parameter;
591
+            } else {
592
+                modeint = myParser.chanModesOther.get(mode);
593
+                if ((modeint & IRCParser.MODE_LIST) == IRCParser.MODE_LIST) {
594
+                    modestr = modestr + " " + parameter;
595
+                } else if (!positive && ((modeint & IRCParser.MODE_UNSET) == IRCParser.MODE_UNSET)) {
596
+                    modestr = modestr + " " + parameter;
597
+                } else if (positive && ((modeint & IRCParser.MODE_SET) == IRCParser.MODE_SET)) {
598
+                    // Does mode require a param to unset aswell?
599
+                    // We might need to queue an unset first
600
+                    if (((modeint & IRCParser.MODE_UNSET) == IRCParser.MODE_UNSET)) {
601
+                        final String existingParam = getMode(mode);
602
+                        if (!existingParam.isEmpty()) {
603
+                            final String reverseModeStr = "-" + mode + " " + existingParam;
604
+                            
605
+                            myParser.callDebugInfo(IRCParser.DEBUG_INFO, "Queueing mode: %s", reverseModeStr);
606
+                            lModeQueue.add(reverseModeStr);
607
+                            if (lModeQueue.size() == modecount) { flushModes(); }
608
+                        }
609
+                    }
610
+                    modestr = modestr + " " + parameter;
611
+                }
612
+            }
613
+        }
614
+        myParser.callDebugInfo(IRCParser.DEBUG_INFO, "Queueing mode: %s", modestr);
615
+        lModeQueue.add(modestr);
616
+        if (lModeQueue.size() == modecount) { flushModes(); }
617
+    }
618
+    
619
+    /** {@inheritDoc} */
620
+        @Override
621
+    public void flushModes() {
622
+        if (lModeQueue.isEmpty()) { return; }
623
+        final StringBuilder positivemode = new StringBuilder();
624
+        final StringBuilder positiveparam = new StringBuilder();
625
+        final StringBuilder negativemode = new StringBuilder();
626
+        final StringBuilder negativeparam = new StringBuilder();
627
+        final StringBuilder sendModeStr = new StringBuilder();
628
+        String modestr;
629
+        String[] modeparam;
630
+        boolean positive;
631
+        for (int i = 0; i < lModeQueue.size(); ++i) {
632
+            modeparam = lModeQueue.get(i).split(" ");
633
+            modestr = modeparam[0];
634
+            positive = modestr.charAt(0) == '+';
635
+            if (positive) {
636
+                positivemode.append(modestr.charAt(1));
637
+                if (modeparam.length > 1) { positiveparam.append(" ").append(modeparam[1]); }
638
+            } else {
639
+                negativemode.append(modestr.charAt(1));
640
+                if (modeparam.length > 1) { negativeparam.append(" ").append(modeparam[1]); }
641
+            }
642
+        }
643
+        if (negativemode.length() > 0) { sendModeStr.append("-").append(negativemode); }
644
+        if (positivemode.length() > 0) { sendModeStr.append("+").append(positivemode); }
645
+        if (negativeparam.length() > 0) { sendModeStr.append(negativeparam); }
646
+        if (positiveparam.length() > 0) { sendModeStr.append(positiveparam); }
647
+        myParser.callDebugInfo(IRCParser.DEBUG_INFO, "Sending mode: %s", sendModeStr.toString());
648
+        myParser.sendRawMessage("MODE " + sName + " " + sendModeStr.toString());
649
+        clearModeQueue();
650
+    }
651
+    
652
+    /**
653
+     * This function will clear the mode queue (WITHOUT Sending).
654
+     */
655
+    public void clearModeQueue() { 
656
+        lModeQueue.clear();
657
+    }
658
+    
659
+    /** {@inheritDoc} */
660
+        @Override
661
+    public void sendMessage(final String message) {
662
+        if (message.isEmpty()) { return; }
663
+        
664
+        myParser.sendString("PRIVMSG " + sName + " :" + message);
665
+    }
666
+    
667
+    /**
668
+     * Send a notice message to a target.
669
+     *
670
+     * @param sMessage Message to send
671
+     */
672
+    public void sendNotice(final String sMessage) { 
673
+        if (sMessage.isEmpty()) { return; }
674
+        
675
+        myParser.sendString("NOTICE " + sName + " :" + sMessage);    
676
+    }
677
+
678
+    /** {@inheritDoc} */
679
+        @Override
680
+    public void sendAction(final String action) {
681
+        if (action.isEmpty()) { return; }
682
+        sendCTCP("ACTION", action);
683
+    }
684
+    
685
+    /**
686
+     * Send a CTCP to a target.
687
+     *
688
+     * @param sType Type of CTCP
689
+     * @param sMessage Optional Additional Parameters
690
+     */
691
+    public void sendCTCP(final String sType, String sMessage) { 
692
+        if (sType.isEmpty()) { return; }
693
+        final char char1 = (char) 1;
694
+        if (!sMessage.isEmpty()) { sMessage = " " + sMessage; }
695
+        sendMessage(char1 + sType.toUpperCase() + sMessage + char1);
696
+    }
697
+    
698
+    /**
699
+     * Send a CTCPReply to a target.
700
+     *
701
+     * @param sType Type of CTCP
702
+     * @param sMessage Optional Additional Parameters
703
+     */
704
+    public void sendCTCPReply(final String sType, String sMessage) { 
705
+        if (sType.isEmpty()) { return; }
706
+        final char char1 = (char) 1;
707
+        if (!sMessage.isEmpty()) { sMessage = " " + sMessage; }
708
+        sendNotice(char1 + sType.toUpperCase() + sMessage + char1);    
709
+    }
710
+    
711
+    /**
712
+     * Get a string representation of the Channel.
713
+     *
714
+     * @return String representation of the Channel.
715
+     */
716
+    @Override
717
+    public String toString() { return sName; }
718
+    
719
+    /** {@inheritDoc} */
720
+        @Override
721
+    public Parser getParser() { return myParser; }
722
+
723
+        /** {@inheritDoc} */
724
+        @Override
725
+        public void part(final String reason) {
726
+            myParser.partChannel(sName, reason);
727
+        }
728
+
729
+    /** {@inheritDoc} */
730
+    @Override
731
+    public void setTopic(final String topic) {
732
+        myParser.sendRawMessage("TOPIC " + sName + " :" + topic);
733
+    }
734
+
735
+    /** {@inheritDoc} */
736
+    @Override
737
+    public void sendWho() {
738
+        myParser.sendRawMessage("WHO " + sName);
739
+    }
740
+
741
+}
742
+

+ 428
- 0
src/com/dmdirc/parser/irc/IRCClientInfo.java Näytä tiedosto

@@ -0,0 +1,428 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.LocalClientInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import java.util.ArrayList;
29
+import java.util.List;
30
+import java.util.LinkedList;
31
+import java.util.Hashtable;
32
+import java.util.HashMap;
33
+import java.util.Map;
34
+
35
+/**
36
+ * Contains information about known users.
37
+ * 
38
+ * @author Shane Mc Cormack
39
+ * @author Chris Smith
40
+ * @see IRCParser
41
+ */
42
+public class IRCClientInfo implements LocalClientInfo {
43
+    /** Known nickname of client. */
44
+    private String sNickname = "";
45
+    /** Known ident of client. */
46
+    private String sIdent = "";    
47
+    /** Known host of client. */
48
+    private String sHost = "";
49
+    /** Known user modes of client. */
50
+    private long nModes;
51
+    /** Known Away Reason of client. */
52
+    private String myAwayReason = "";
53
+    /** Known RealName of client. */
54
+    private String sRealName = "";
55
+    /** Known away state for client. */
56
+    private boolean bIsAway;
57
+    /** Is this a fake client created just for a callback? */
58
+    private boolean bIsFake;
59
+    /** Reference to the parser object that owns this channel, Used for modes. */
60
+    private final IRCParser myParser;
61
+    /** A Map to allow applications to attach misc data to this object */
62
+    private Map<Object, Object> myMap;
63
+    /** List of ChannelClientInfos that point to this */
64
+    private final Map<String, IRCChannelClientInfo> myChannelClientInfos = new Hashtable<String, IRCChannelClientInfo>();
65
+    /** Modes waiting to be sent to the server. */
66
+    private final List<String> lModeQueue = new LinkedList<String>();
67
+
68
+    /**
69
+     * Create a new client object from a hostmask.
70
+     *
71
+      * @param tParser Refernce to parser that owns this channelclient (used for modes)
72
+     * @param sHostmask Hostmask parsed by parseHost to get nickname
73
+     * @see ClientInfo#parseHost
74
+     */
75
+    public IRCClientInfo(final IRCParser tParser, final String sHostmask) {
76
+        myMap = new HashMap<Object, Object>();
77
+        setUserBits(sHostmask, true);
78
+        myParser = tParser;
79
+    }
80
+
81
+    /**
82
+     * Set the Map object attatched to this object.
83
+     *
84
+     * @param newMap New Map to attatch.
85
+     */
86
+    public void setMap(final Map<Object, Object> newMap) {
87
+        myMap = newMap;
88
+    }
89
+    
90
+    /** {@inheritDoc} */
91
+        @Override
92
+    public Map<Object, Object> getMap() {
93
+            return myMap;
94
+    }
95
+
96
+    /**
97
+     * Check if this is a fake client.
98
+     *
99
+     * @return True if this is a fake client, else false
100
+     */
101
+    public boolean isFake() { return bIsFake; }
102
+    /**
103
+     * Check if this client is actually a server.
104
+     *
105
+     * @return True if this client is actually a server.
106
+     */
107
+    public boolean isServer() { return !(sNickname.indexOf(':') == -1); }
108
+    /**
109
+     * Set if this is a fake client.
110
+     * This returns "this" and thus can be used in the construction line.
111
+     *
112
+     * @param newValue new value for isFake - True if this is a fake client, else false
113
+     * @return this Object
114
+     */
115
+    public IRCClientInfo setFake(final boolean newValue) { bIsFake = newValue; return this; }
116
+
117
+    /**
118
+     * Get a nickname of a user from a hostmask.
119
+     * Hostmask must match (?:)nick(?!ident)(?@host)
120
+     *
121
+     * @param sWho Hostname to parse
122
+     * @return nickname of user
123
+     */
124
+    public static String parseHost(final String sWho) {
125
+        // Get the nickname from the string.
126
+        return parseHostFull(sWho)[0];
127
+    }
128
+    
129
+    /**
130
+     * Get a nick ident and host of a user from a hostmask.
131
+     * Hostmask must match (?:)nick(?!ident)(?@host)
132
+     *
133
+     * @param sWho Hostname to parse
134
+     * @return Array containing details. (result[0] -> Nick | result[1] -> Ident | result[2] -> Host)
135
+     */
136
+    public static String[] parseHostFull(String sWho) {
137
+        String[] sTemp = null;
138
+        final String[] result = new String[3];
139
+        if (!sWho.isEmpty() && sWho.charAt(0) == ':') { sWho = sWho.substring(1); }
140
+        sTemp = sWho.split("@", 2);
141
+        if (sTemp.length == 1) { result[2] = ""; } else { result[2] = sTemp[1]; }
142
+        sTemp = sTemp[0].split("!", 2);
143
+        if (sTemp.length == 1) { result[1] = ""; } else { result[1] = sTemp[1]; }
144
+        result[0] = sTemp[0];
145
+        
146
+        return result;
147
+    }
148
+
149
+    /**
150
+     * Set the nick/ident/host of this client.
151
+     *
152
+     * @param sHostmask takes a host (?:)nick(?!ident)(?@host) and sets nick/host/ident variables
153
+     * @param bUpdateNick if this is false, only host/ident will be updated.
154
+     */    
155
+    public void setUserBits(final String sHostmask, final boolean bUpdateNick) {
156
+        setUserBits(sHostmask, bUpdateNick, false);
157
+    }
158
+    
159
+    /**
160
+     * Set the nick/ident/host of this client.
161
+     *
162
+     * @param sHostmask takes a host (?:)nick(?!ident)(?@host) and sets nick/host/ident variables
163
+     * @param bUpdateNick if this is false, only host/ident will be updated.
164
+     * @param allowBlank if this is true, ident/host will be set even if
165
+     *                   parseHostFull returns empty values for them
166
+     */    
167
+    public void setUserBits(final String sHostmask, final boolean bUpdateNick, final boolean allowBlank) {
168
+        final String[] sTemp = parseHostFull(sHostmask);
169
+        if (!sTemp[2].isEmpty() || allowBlank) { sHost = sTemp[2]; }
170
+        if (!sTemp[1].isEmpty() || allowBlank) { sIdent = sTemp[1]; }
171
+        if (bUpdateNick) { sNickname = sTemp[0]; }
172
+    }
173
+    
174
+    /**
175
+     * Get a string representation of the user.
176
+     *
177
+     * @return String representation of the user.
178
+     */
179
+    @Override
180
+    public String toString() { return sNickname + "!" + sIdent + "@" + sHost; }
181
+    
182
+    /** {@inheritDoc} */
183
+    @Override
184
+    public String getNickname() {
185
+        // If this is the localClient then do what we are supposed to do, and ask
186
+        // the parser using parser.getNickname() like was used prior to the
187
+        // great-parser-breaking (aka abstraction) of 09.
188
+        if (this.equals(myParser.getLocalClient())) {
189
+            return myParser.getMyNickname();
190
+        } else {
191
+            return sNickname;
192
+        }
193
+    }
194
+    
195
+    /** {@inheritDoc} */
196
+    public String getRealNickname() { return sNickname; }
197
+    
198
+    /** {@inheritDoc} */
199
+    @Override
200
+    public String getUsername() { return sIdent; }
201
+    
202
+    /** {@inheritDoc} */
203
+  @Override
204
+    public String getHostname() { return sHost; }
205
+    
206
+    /**
207
+     * Set the away state of a user.
208
+     * Automatically sets away reason to "" if set to false
209
+     *
210
+     * @param bNewState Boolean representing state. true = away, false = here
211
+     */    
212
+    protected void setAwayState(final boolean bNewState) {
213
+        bIsAway = bNewState;
214
+        if (!bIsAway) { myAwayReason = ""; }
215
+    }
216
+    
217
+    /**
218
+     * Get the away state of a user.
219
+     *
220
+     * @return Boolean representing state. true = away, false = here
221
+     */    
222
+    public boolean getAwayState() { return bIsAway; }
223
+    
224
+    /**
225
+     * Get the Away Reason for this user.
226
+     *
227
+     * @return Known away reason for user.
228
+     */
229
+    public String getAwayReason() { return myAwayReason; }
230
+    
231
+    /**
232
+     * Set the Away Reason for this user.
233
+     * Automatically set to "" if awaystate is set to false
234
+     *
235
+     * @param newValue new away reason for user.
236
+     */
237
+    protected void setAwayReason(final String newValue) { myAwayReason = newValue; }
238
+    
239
+    /** {@inheritDoc} */
240
+        @Override
241
+    public String getRealname() { return sRealName; }
242
+    
243
+    /**
244
+     * Set the RealName for this user.
245
+     *
246
+     * @param newValue new RealName for user.
247
+     */
248
+    protected void setRealName(final String newValue) { sRealName = newValue; }
249
+    
250
+    /**
251
+     * Set the user modes (as an integer).
252
+     *
253
+     * @param nNewMode new long representing channel modes. (Boolean only)
254
+     */    
255
+    protected void setUserMode(final long nNewMode) { nModes = nNewMode; }
256
+    
257
+    /**
258
+     * Get the user modes (as an integer).
259
+     *
260
+     * @return long representing channel modes. (Boolean only)
261
+     */    
262
+    public long getUserMode() { return nModes; }    
263
+    
264
+    /** {@inheritDoc} */
265
+        @Override
266
+    public String getModes() {
267
+        final StringBuilder sModes = new StringBuilder("+");
268
+        long nTemp = 0;
269
+        final long nChanModes = this.getUserMode();
270
+        
271
+        for (char cTemp : myParser.userModes.keySet()) {
272
+            nTemp = myParser.userModes.get(cTemp);
273
+            if ((nChanModes & nTemp) == nTemp) { sModes.append(cTemp); }
274
+        }
275
+        
276
+        return sModes.toString();
277
+    }
278
+    
279
+    /**
280
+     * Is this client an oper?
281
+     * This is a guess currently based on user-modes and thus only works on the
282
+     * parsers own client.
283
+     *
284
+     * @return True/False if this client appears to be an oper
285
+     */
286
+    public boolean isOper() {
287
+        final String modestr = getModes();
288
+        return (modestr.indexOf('o') > -1) || (modestr.indexOf('O') > -1);
289
+    }
290
+    
291
+    /**
292
+     * Add a ChannelClientInfo as a known reference to this client.
293
+     *
294
+     * @param cci ChannelClientInfo to add as a known reference
295
+     */    
296
+    public void addChannelClientInfo(final IRCChannelClientInfo cci) {
297
+        final String key = myParser.getStringConverter().toLowerCase(cci.getChannel().getName());
298
+        if (!myChannelClientInfos.containsKey(key)) {
299
+            myChannelClientInfos.put(key, cci);
300
+        }
301
+    }
302
+    
303
+    /**
304
+     * Remove a ChannelClientInfo as a known reference to this client.
305
+     *
306
+     * @param cci ChannelClientInfo to remove as a known reference
307
+     */    
308
+    public void delChannelClientInfo(final IRCChannelClientInfo cci) {
309
+        final String key = myParser.getStringConverter().toLowerCase(cci.getChannel().getName());
310
+        if (myChannelClientInfos.containsKey(key)) {
311
+            myChannelClientInfos.remove(key);
312
+        }
313
+    }
314
+    
315
+    /**
316
+     * Check to see if a client is still known on any of the channels we are on.
317
+     *
318
+     * @return Boolean to see if client is still visable.
319
+     */
320
+    public boolean checkVisibility() {
321
+        return !myChannelClientInfos.isEmpty();
322
+    }
323
+    
324
+    /** {@inheritDoc} */
325
+        @Override
326
+    public int getChannelCount() {
327
+        return myChannelClientInfos.size();
328
+    }
329
+    
330
+    /**
331
+     * Get a list of channelClients that point to this object.
332
+     *
333
+     * @return int with the count of known channels
334
+     */    
335
+    public List<IRCChannelClientInfo> getChannelClients() {
336
+        final List<IRCChannelClientInfo> result = new ArrayList<IRCChannelClientInfo>();
337
+        for (IRCChannelClientInfo cci : myChannelClientInfos.values()) {
338
+            result.add(cci);
339
+        }
340
+        return result;
341
+    }
342
+    
343
+    /** {@inheritDoc} */
344
+        @Override
345
+    public void alterMode(final boolean add, final Character mode) {
346
+        if (isFake()) { return; }
347
+        int modecount = 1;
348
+        String modestr = "";
349
+        if (myParser.h005Info.containsKey("MODES")) {
350
+            try { 
351
+                modecount = Integer.parseInt(myParser.h005Info.get("MODES")); 
352
+            } catch (NumberFormatException e) { 
353
+                modecount = 1;
354
+            }
355
+        }
356
+        modestr = ((add) ? "+" : "-") + mode;
357
+        if (!myParser.userModes.containsKey(mode)) { return; }
358
+        final String teststr = ((add) ? "-" : "+") + mode;
359
+        if (lModeQueue.contains(teststr)) {
360
+            lModeQueue.remove(teststr);
361
+            return;
362
+        } else if (lModeQueue.contains(modestr)) {
363
+            return;
364
+        }
365
+        myParser.callDebugInfo(IRCParser.DEBUG_INFO, "Queueing user mode: %s", modestr);
366
+        lModeQueue.add(modestr);
367
+        if (lModeQueue.size() == modecount) { flushModes(); }
368
+    }
369
+    
370
+    /** {@inheritDoc} */
371
+        @Override
372
+    public void flushModes() {
373
+        if (lModeQueue.isEmpty()) { return; }
374
+        final StringBuilder positivemode = new StringBuilder();
375
+        final StringBuilder negativemode = new StringBuilder();
376
+        final StringBuilder sendModeStr = new StringBuilder();
377
+        String modestr;
378
+        boolean positive;
379
+        for (int i = 0; i < lModeQueue.size(); ++i) {
380
+            modestr = lModeQueue.get(i);
381
+            positive = modestr.charAt(0) == '+';
382
+            if (positive) {
383
+                positivemode.append(modestr.charAt(1));
384
+            } else {
385
+                negativemode.append(modestr.charAt(1));
386
+            }
387
+        }
388
+        if (negativemode.length() > 0) { sendModeStr.append("-").append(negativemode); }
389
+        if (positivemode.length() > 0) { sendModeStr.append("+").append(positivemode); }
390
+        myParser.callDebugInfo(IRCParser.DEBUG_INFO, "Sending mode: %s", sendModeStr.toString());
391
+        myParser.sendRawMessage("MODE " + sNickname + " " + sendModeStr.toString());
392
+        clearModeQueue();
393
+    }
394
+    
395
+    /**
396
+     * This function will clear the mode queue (WITHOUT Sending).
397
+     */
398
+    public void clearModeQueue() { 
399
+        lModeQueue.clear();
400
+    }
401
+    
402
+    /** {@inheritDoc} */
403
+        @Override
404
+    public Parser getParser() { return myParser; }
405
+
406
+        /** {@inheritDoc} */
407
+        @Override
408
+        public void setNickname(final String name) {
409
+            if (myParser.getLocalClient().equals(this)) {
410
+                myParser.setNickname(name);
411
+            } else {
412
+                throw new UnsupportedOperationException("Cannot call setNickname on non-local client");
413
+            }
414
+        }
415
+
416
+    /** {@inheritDoc} */
417
+    @Override
418
+    public void setAway(String reason) {
419
+        myParser.sendRawMessage("AWAY :" + reason);
420
+    }
421
+
422
+    /** {@inheritDoc} */
423
+    @Override
424
+    public void setBack() {
425
+        myParser.sendRawMessage("AWAY");
426
+    }
427
+
428
+}

+ 2066
- 0
src/com/dmdirc/parser/irc/IRCParser.java
File diff suppressed because it is too large
Näytä tiedosto


+ 192
- 0
src/com/dmdirc/parser/irc/IRCProcessor.java Näytä tiedosto

@@ -0,0 +1,192 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.common.ParserError;
26
+import com.dmdirc.parser.common.CallbackManager;
27
+import com.dmdirc.parser.common.QueuePriority;
28
+
29
+/**
30
+ * IRCProcessor.
31
+ * Superclass for all IRCProcessor types.
32
+ *
33
+ * @author Shane Mc Cormack
34
+ */
35
+abstract class IRCProcessor {
36
+    /** Reference to the IRCParser that owns this IRCProcessor. */
37
+    protected IRCParser myParser;
38
+    
39
+    /** Reference to the Processing in charge of this IRCProcessor. */
40
+    protected ProcessingManager myManager;
41
+
42
+    // Some functions from the main parser are useful, and having to use myParser.functionName
43
+    // is annoying, so we also implement them here (calling them again using myParser)
44
+    /**
45
+     * Create a new instance of the IRCProcessor Object.
46
+     *
47
+     * @param parser IRCParser That owns this IRCProcessor
48
+     * @param manager ProcessingManager that is in charge of this IRCProcessor
49
+     */
50
+    protected IRCProcessor(final IRCParser parser, final ProcessingManager manager) {
51
+        this.myParser = parser;
52
+        this.myManager = manager;
53
+    }
54
+
55
+    /**
56
+     * Callback to all objects implementing the IErrorInfo Interface.
57
+     *
58
+     * @see com.dmdirc.parser.irc.callbacks.interfaces.IErrorInfo
59
+     * @param errorInfo ParserError object representing the error.
60
+     * @return true if a method was called, false otherwise
61
+     */
62
+    protected final boolean callErrorInfo(final ParserError errorInfo) {
63
+        return myParser.callErrorInfo(errorInfo);
64
+    }
65
+    
66
+    /**
67
+     * Callback to all objects implementing the DebugInfo Callback.
68
+     *
69
+     * @see com.dmdirc.parser.irc.callbacks.interfaces.IDebugInfo
70
+     * @param level Debugging Level (DEBUG_INFO, ndSocket etc)
71
+     * @param data Debugging Information
72
+     * @param args Formatting String Options
73
+     * @return true if a method was called, false otherwise
74
+     */
75
+    protected final boolean callDebugInfo(final int level, final String data, final Object... args) {
76
+        return myParser.callDebugInfo(level, String.format(data, args));
77
+    }
78
+    
79
+    /**
80
+     * Callback to all objects implementing the DebugInfo Callback.
81
+     *
82
+     * @see com.dmdirc.parser.irc.callbacks.interfaces.IDebugInfo
83
+     * @param level Debugging Level (DEBUG_INFO, ndSocket etc)
84
+     * @param data Debugging Information
85
+     * @return true if a method was called, false otherwise
86
+     */
87
+    protected final boolean callDebugInfo(final int level, final String data) {
88
+        return myParser.callDebugInfo(level, data);
89
+    }
90
+    
91
+    /**
92
+     * Check if a channel name is valid .
93
+     *
94
+     * @param sChannelName Channel name to test
95
+     * @return true if name is valid on the current connection, false otherwise. (Always false before noMOTD/MOTDEnd)
96
+     */
97
+    protected final boolean isValidChannelName(final String sChannelName) {
98
+        return myParser.isValidChannelName(sChannelName);
99
+    }
100
+    
101
+    /**
102
+     * Get the ClientInfo object for a person.
103
+     *
104
+     * @param sWho Who can be any valid identifier for a client as long as it contains a nickname (?:)nick(?!ident)(?@host)
105
+     * @return ClientInfo Object for the client, or null
106
+     */
107
+    protected final IRCClientInfo getClientInfo(final String sWho) {
108
+        return myParser.isKnownClient(sWho) ? myParser.getClient(sWho) : null;
109
+    }
110
+    
111
+    /**
112
+     * Get the ChannelInfo object for a channel.
113
+     *
114
+     * @param name This is the name of the channel.
115
+     * @return ChannelInfo Object for the channel, or null
116
+     */
117
+    protected final IRCChannelInfo getChannel(final String name) {
118
+        return myParser.getChannel(name);
119
+    }
120
+    
121
+    /**
122
+     * Get a reference to the CallbackManager.
123
+     *
124
+     * @return Reference to the CallbackManager
125
+     */
126
+    protected final CallbackManager<?> getCallbackManager() {
127
+        return myParser.getCallbackManager();
128
+    }
129
+    
130
+    /**
131
+     * Send a line to the server and add proper line ending.
132
+     *
133
+     * @param line Line to send (\r\n termination is added automatically)
134
+     */
135
+    protected final void sendString(final String line) {
136
+        myParser.sendString(line);
137
+    }
138
+
139
+    /**
140
+     * Send a line to the server and add proper line ending.
141
+     *
142
+     * @param line Line to send (\r\n termination is added automatically)
143
+     * @param priority Priority of this line.
144
+     */
145
+    protected final void sendString(final String line, final QueuePriority priority) {
146
+        myParser.sendString(line, priority);
147
+    }
148
+    
149
+    /**
150
+     * Process a Line.
151
+     *
152
+     * @param sParam Type of line to process ("005", "PRIVMSG" etc)
153
+     * @param token IRCTokenised line to process
154
+     */
155
+    public abstract void process(final String sParam, final String[] token);
156
+    
157
+    /**
158
+     * What does this IRCProcessor handle.
159
+     *
160
+     * @return String[] with the names of the tokens we handle.
161
+     */
162
+    public abstract String[] handles();
163
+    
164
+    /** 
165
+     * Get the name for this Processor.
166
+     * @return the name of this processor
167
+     */
168
+    public final String getName() {
169
+        final Package thisPackage = this.getClass().getPackage();
170
+        int packageLength = 0;
171
+        if (thisPackage != null) {
172
+            packageLength = thisPackage.getName().length() + 1;
173
+        }
174
+        return this.getClass().getName().substring(packageLength);
175
+    }
176
+    
177
+    /** 
178
+     * Get the name for this Processor in lowercase.
179
+     * @return lower case name of this processor
180
+     */
181
+    public final String getLowerName() {
182
+        return this.getName().toLowerCase();
183
+    }
184
+    
185
+    /** 
186
+     * Get the name for this Processor.
187
+     * @return the name of this processor
188
+     */
189
+        @Override
190
+    public final String toString() { return this.getName(); }
191
+    
192
+}

+ 132
- 0
src/com/dmdirc/parser/irc/IRCStringConverter.java Näytä tiedosto

@@ -0,0 +1,132 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.interfaces.StringConverter;
26
+
27
+/**
28
+ * IRC String Converter.
29
+ *
30
+ * @author Shane Mc Cormack
31
+ */
32
+public class IRCStringConverter implements StringConverter {
33
+    
34
+    /** Characters to use when converting tolowercase. */
35
+    private final char[] lowercase;
36
+    /** Characters to use when converting touppercase. */
37
+    private final char[] uppercase;
38
+    /** limit */
39
+    private final byte limit;
40
+
41
+    /**
42
+     * Create a new IRCStringConverter with rfc1459 encoding.
43
+     */
44
+    public IRCStringConverter() {
45
+        this((byte)4);
46
+    }
47
+    
48
+    /**
49
+     * Create a new IRCStringConverter.
50
+     * @param limit Number of post-alphabetical characters to convert
51
+     *              0 = ascii encoding
52
+     *              3 = strict-rfc1459 encoding
53
+     *              4 = rfc1459 encoding
54
+     */
55
+    public IRCStringConverter(final byte limit) {
56
+        // If limit is out side the boundries, use rfc1459
57
+        if (limit > 4 || limit < 0 ) { this.limit = (byte)4; }
58
+        else { this.limit = limit; }
59
+        
60
+        lowercase = new char[127];
61
+        uppercase = new char[127];
62
+        // Normal Chars
63
+        for (char i = 0; i < lowercase.length; ++i) {
64
+            lowercase[i] = i;
65
+            uppercase[i] = i;
66
+        }
67
+
68
+        // Replace the uppercase chars with lowercase
69
+        for (char i = 65; i <= (90 + this.limit); ++i) {
70
+            lowercase[i] = (char)(i + 32);
71
+            uppercase[i + 32] = i;
72
+        }
73
+    }
74
+
75
+    /**
76
+     * Get last used chararray limit.
77
+     *
78
+     * @return last used chararray limit
79
+     */
80
+    protected int getLimit() { return limit; }
81
+    
82
+    /** {@inheritDoc} */
83
+        @Override
84
+    public String toLowerCase(final String input) {
85
+        final char[] result = input.toCharArray();
86
+        for (int i = 0; i < input.length(); ++i) {
87
+            if (result[i] >= 0 && result[i] < lowercase.length) {
88
+                result[i] = lowercase[result[i]];
89
+            } else {
90
+                result[i] = result[i];
91
+            }
92
+        }
93
+        return new String(result);
94
+    }
95
+
96
+    /** {@inheritDoc} */
97
+        @Override
98
+    public String toUpperCase(final String input) {
99
+        final char[] result = input.toCharArray();
100
+        for (int i = 0; i < input.length(); ++i) {
101
+            if (result[i] >= 0 && result[i] < uppercase.length) {
102
+                result[i] = uppercase[result[i]];
103
+            } else {
104
+                result[i] = result[i];
105
+            }
106
+        }
107
+        return new String(result);
108
+    }
109
+
110
+    /** {@inheritDoc} */
111
+        @Override
112
+    public boolean equalsIgnoreCase(final String first, final String second) {
113
+        if (first == null && second == null) { return true; }
114
+        if (first == null || second == null) { return false; }
115
+        boolean result = (first.length() == second.length());
116
+        if (result) {
117
+            final char[] firstChar = first.toCharArray();
118
+            final char[] secondChar = second.toCharArray();
119
+            for (int i = 0; i < first.length(); ++i) {
120
+                if (firstChar[i] < lowercase.length && secondChar[i] < lowercase.length) {
121
+                    result = (lowercase[firstChar[i]] == lowercase[secondChar[i]]);
122
+                } else {
123
+                    result = firstChar[i] == secondChar[i];
124
+                }
125
+                if (!result) { break; }
126
+            }
127
+        }
128
+
129
+        return result;
130
+    }
131
+
132
+}

+ 167
- 0
src/com/dmdirc/parser/irc/Logging.java Näytä tiedosto

@@ -0,0 +1,167 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import java.lang.reflect.Method;
26
+import java.lang.reflect.InvocationTargetException;
27
+
28
+/**
29
+ * Logging using log4j if available.
30
+ */
31
+public class Logging {
32
+    /** Available Log Levels */
33
+    public enum LogLevel {
34
+        TRACE("trace", "isTraceEnabled"),
35
+        DEBUG("debug", "isDebugEnabled"),
36
+        INFO("info", "isInfoEnabled"),
37
+        WARN("warn", "isWarnEnabled"),
38
+        ERROR("error", "isErrorEnabled"),
39
+        FATAL("fatal", "isFatalEnabled");
40
+        
41
+        /** Method name */
42
+        private final String methodName;
43
+        
44
+        /** Check Method name */
45
+        private final String checkMethodName;
46
+        
47
+        /**
48
+         * Create a new LogLevel
49
+         *
50
+         * @param methodName Name of method in log4j to log to
51
+         * @param checkMethodName Name of method in log4j to sue to check logging
52
+         */
53
+        private LogLevel(final String methodName, final String checkMethodName) {
54
+            this.methodName = methodName;
55
+            this.checkMethodName = checkMethodName;
56
+        }
57
+        
58
+        /**
59
+         * Get the Name of method in log4j to log to
60
+         *
61
+         * @return Name of method in log4j to log to
62
+         */
63
+        public String getMethodName() { return methodName; }
64
+        
65
+        /**
66
+         * Get the Name of the check method in log4j
67
+         *
68
+         * @return Name of check method in log4j
69
+         */
70
+        public String getCheckMethodName() { return checkMethodName; }
71
+    };
72
+    
73
+    /** Singleton Instance of Logging. */
74
+    private static Logging me;
75
+    
76
+    /** Is log4j available. */
77
+    private final boolean isAvailable;
78
+    
79
+    /** "Log" object if available. */
80
+    private Object log = null;
81
+    
82
+    /**
83
+     * Get an instance of Logging.
84
+     *
85
+     * @return The instance of Logging
86
+     */
87
+    public static Logging getLogging() {
88
+        if (me == null) { me = new Logging(); }
89
+        return me;
90
+    }
91
+    
92
+    /** Create a new Logging. */
93
+    @SuppressWarnings("unchecked")
94
+    private Logging() {
95
+        boolean classExists = false;
96
+        try {
97
+            Class factory = null;
98
+            // Check for classes
99
+            Class.forName("org.apache.commons.logging.Log");
100
+            factory = Class.forName("org.apache.commons.logging.LogFactory");
101
+        
102
+            classExists = (factory != null);
103
+            if (classExists) {
104
+                final Method getLog = factory.getMethod("getLog", new Class[]{Class.class});
105
+                log = getLog.invoke(null, this.getClass());
106
+            }
107
+        } catch (ClassNotFoundException cnfe) {
108
+        } catch (NoSuchMethodException nsme) {
109
+        } catch (IllegalAccessException iae) {
110
+        } catch (InvocationTargetException ite) {
111
+        }
112
+        
113
+        isAvailable = (classExists && log != null);
114
+    }
115
+    
116
+    /**
117
+     * Check is a log level is available.
118
+     *
119
+     * @param level Level to check
120
+     */
121
+    public boolean levelEnabled(final LogLevel level) {
122
+        if (isAvailable) {
123
+            try {
124
+                final Method check = log.getClass().getMethod(level.getCheckMethodName(), new Class[0]);
125
+                return (Boolean)check.invoke(log, new Object[0]);
126
+            } catch (NoSuchMethodException nsme) {
127
+            } catch (IllegalAccessException iae) {
128
+            } catch (InvocationTargetException ite) {
129
+            }
130
+        }
131
+        
132
+        return false;
133
+    }
134
+    
135
+    /**
136
+     * Log a message if log4j is available.
137
+     *
138
+     * @param level Level to log at
139
+     * @param message Message to log
140
+     */
141
+    public void log(final LogLevel level, final String message) {
142
+        log(level, message, null);
143
+    }
144
+    
145
+    /**
146
+     * Log a message if log4j is available.
147
+     *
148
+     * @param level Level to log at
149
+     * @param message Message to log
150
+     * @param throwable Throwable to log alongside message
151
+     */
152
+    public void log(final LogLevel level, final String message, final Throwable throwable) {
153
+        if (!isAvailable) { return; }
154
+        try {
155
+            if (throwable == null) {
156
+                final Method method = log.getClass().getMethod(level.getMethodName(), new Class[]{String.class});
157
+                method.invoke(log, new Object[]{message});
158
+            } else {
159
+                final Method method = log.getClass().getMethod(level.getMethodName(), new Class[]{String.class, Throwable.class});
160
+                method.invoke(log, new Object[]{message, throwable});
161
+            }
162
+        } catch (NoSuchMethodException nsme) {
163
+        } catch (IllegalAccessException iae) {
164
+        } catch (InvocationTargetException ite) {
165
+        }
166
+    }
167
+}

+ 55
- 0
src/com/dmdirc/parser/irc/PingTimer.java Näytä tiedosto

@@ -0,0 +1,55 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import java.util.TimerTask;
26
+import java.util.Timer;
27
+
28
+/**
29
+ * Used by the parser to ping the server at a set interval to check that the
30
+ * server is still alive.
31
+ *
32
+ * @author Shane Mc Cormack
33
+ */
34
+public class PingTimer extends TimerTask {
35
+    /** Owning Parser. */
36
+    final IRCParser myOwner;
37
+    /** The Timer that owns this task */
38
+    final Timer myTimer;
39
+    
40
+    /**
41
+     * Create the PingTimer.
42
+     *
43
+     * @param control IRCParser that owns this TimerTask.
44
+     * @param timer Timer that owns this TimerTask.
45
+     */
46
+    public PingTimer(final IRCParser control, final Timer timer) {
47
+        myOwner = control;
48
+        myTimer = timer;
49
+    }
50
+    
51
+    /** Timer has been executed. */
52
+    public void run() {
53
+        myOwner.pingTimerTask(myTimer);
54
+    }
55
+}

+ 101
- 0
src/com/dmdirc/parser/irc/Process001.java Näytä tiedosto

@@ -0,0 +1,101 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.common.ParserError;
26
+import com.dmdirc.parser.interfaces.callbacks.ServerReadyListener;
27
+
28
+/**
29
+ * Process a 001 message.
30
+ */
31
+public class Process001 extends IRCProcessor {
32
+    /**
33
+     * Process a 001 message.
34
+     *
35
+     * @param sParam Type of line to process ("001")
36
+     * @param token IRCTokenised line to process
37
+     */
38
+    @Override
39
+    public void process(final String sParam, final String[] token) {
40
+        myParser.got001 = true;
41
+        // << :demon1.uk.quakenet.org 001 Java-Test :Welcome to the QuakeNet IRC Network, Java-Test
42
+        myParser.serverName = token[0].substring(1,token[0].length());
43
+        final String sNick = token[2];
44
+                
45
+        // myself will be fake if we havn't recieved a 001 yet
46
+        if (myParser.getLocalClient().isFake()) {
47
+            // Update stored information
48
+            myParser.getLocalClient().setUserBits(sNick, true, true);
49
+            myParser.getLocalClient().setFake(false);
50
+            myParser.addClient(myParser.getLocalClient());
51
+        } else {
52
+            // Another 001? if nicknames change then we need to update the hashtable
53
+            if (!myParser.getLocalClient().getNickname().equalsIgnoreCase(sNick)) {
54
+                // Nick changed, remove old me
55
+                myParser.forceRemoveClient(myParser.getLocalClient());
56
+                /// Update stored information
57
+                myParser.getLocalClient().setUserBits(sNick, true, true);
58
+                // Check that we don't already know someone by this name
59
+                if (getClientInfo(myParser.getLocalClient().getNickname()) == null) {
60
+                    // And add to list
61
+                    myParser.addClient(myParser.getLocalClient());
62
+                } else {
63
+                    // Someone else already know? this is bad!
64
+                    myParser.callErrorInfo(new ParserError(ParserError.ERROR_FATAL, "001 overwrites existing client?", myParser.getLastLine()));
65
+                }
66
+            }
67
+        }
68
+        
69
+        callServerReady();
70
+        myParser.startPingTimer();
71
+    }
72
+    
73
+    /**
74
+     * Callback to all objects implementing the ServerReady Callback.
75
+     *
76
+     * @see IServerReady
77
+     * @return true if a method was called, false otherwise
78
+     */    
79
+    protected boolean callServerReady() {
80
+        return getCallbackManager().getCallbackType(ServerReadyListener.class).call();
81
+    }
82
+    
83
+    /**
84
+     * What does this IRCProcessor handle.
85
+     *
86
+     * @return String[] with the names of the tokens we handle.
87
+     */
88
+    @Override
89
+    public String[] handles() {
90
+        return new String[]{"001"};
91
+    } 
92
+    
93
+    /**
94
+     * Create a new instance of the IRCProcessor Object.
95
+     *
96
+     * @param parser IRCParser That owns this IRCProcessor
97
+     * @param manager ProcessingManager that is in charge of this IRCProcessor
98
+     */
99
+    protected Process001 (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
100
+
101
+}

+ 159
- 0
src/com/dmdirc/parser/irc/Process004005.java Näytä tiedosto

@@ -0,0 +1,159 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.common.ParserError;
26
+import com.dmdirc.parser.interfaces.callbacks.NetworkDetectedListener;
27
+import java.util.regex.Pattern;
28
+import java.util.regex.Matcher;
29
+
30
+/**
31
+ * Process ISUPPORT lines.
32
+ */
33
+public class Process004005 extends IRCProcessor {
34
+    /**
35
+     * Process ISUPPORT lines.
36
+     *
37
+     * @param sParam Type of line to process ("005", "004")
38
+     * @param token IRCTokenised line to process
39
+     */
40
+    @Override
41
+    public void process(final String sParam, final String[] token) {
42
+        if (sParam.equals("002")) {
43
+            final Pattern pattern = Pattern.compile("running(?: version)? (.*)$");
44
+            final Matcher matcher = pattern.matcher(myParser.getLastLine());
45
+            if (matcher.find()) {
46
+                myParser.h005Info.put("002IRCD", matcher.group(1));
47
+            }
48
+        } else if (sParam.equals("003")) {
49
+            myParser.h005Info.put("003IRCD",token[token.length-1]);
50
+        } else if (sParam.equals("004")) {
51
+            // 004
52
+            if (token.length > 4) {
53
+                myParser.h005Info.put("004IRCD",token[4]);
54
+                myParser.h005Info.put("USERMODES",token[5]);
55
+                myParser.h005Info.put("USERCHANMODES",token[6]);
56
+                if (token.length > 7) { myParser.h005Info.put("USERCHANPARAMMODES",token[7]); } // INSPIRCD includes an extra param
57
+            } else {
58
+                final String[] bits = token[3].split(" ");
59
+                myParser.h005Info.put("004IRCD",bits[1]);
60
+                myParser.h005Info.put("USERMODES",bits[2]);
61
+                myParser.h005Info.put("USERCHANMODES",bits[3]);
62
+                if (token.length > 4) { myParser.h005Info.put("USERCHANPARAMMODES",bits[4]); } // INSPIRCD includes an extra param
63
+            }
64
+            myParser.parseUserModes();
65
+        } else if (sParam.equals("005")) {
66
+            // 005
67
+            for (int i = 3; i < token.length ; i++) {
68
+                String[] Bits = token[i].split("=",2);
69
+                final boolean isNegation = (Bits[0].charAt(0) == '-');
70
+                final String sKey = (isNegation) ? Bits[0].substring(1).toUpperCase() : Bits[0].toUpperCase();
71
+                final String sValue = (Bits.length == 2) ? Bits[1] : "";
72
+                callDebugInfo(IRCParser.DEBUG_INFO, "%s => %s",sKey,sValue);
73
+                if (isNegation) {
74
+                    myParser.h005Info.remove(sKey);
75
+                } else {
76
+                    myParser.h005Info.put(sKey,sValue);
77
+                }
78
+                if (sKey.equals("NETWORK") && !isNegation) {
79
+                    myParser.networkName = sValue;
80
+                    callGotNetwork();
81
+                } else if (sKey.equals("CASEMAPPING") && !isNegation) {
82
+                    byte limit = (byte)4;
83
+                    if (sValue.equalsIgnoreCase("strict-rfc1459")) {
84
+                        limit = (byte)3;
85
+                    } else if (sValue.equalsIgnoreCase("ascii")) {
86
+                        limit = (byte)0;
87
+                    } else if (!sValue.equalsIgnoreCase("rfc1459")) {
88
+                        myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Unknown casemapping: '"+sValue+"' - assuming rfc1459", myParser.getLastLine()));
89
+                    }
90
+                    final boolean limitChanged = (myParser.getStringConverter().getLimit() != limit);
91
+                    myParser.updateCharArrays(limit);
92
+                    if (limitChanged && myParser.knownClients() == 1) {
93
+                        // This means that the casemapping is not rfc1459
94
+                        // We have only added ourselves so far (from 001)
95
+                        // We can fix the hashtable easily.
96
+                        myParser.removeClient(myParser.getLocalClient());
97
+                        myParser.addClient(myParser.getLocalClient());
98
+                    }
99
+                } else if (sKey.equals("CHANTYPES")) {
100
+                    myParser.parseChanPrefix();
101
+                } else if (sKey.equals("PREFIX")) {
102
+                    myParser.parsePrefixModes();
103
+                } else if (sKey.equals("CHANMODES")) {
104
+                    myParser.parseChanModes();
105
+                } else if (sKey.equals("NAMESX") || sKey.equals("UHNAMES")) {
106
+                    myParser.sendString("PROTOCTL "+sKey);
107
+                } else if (sKey.equals("LISTMODE")) {
108
+                    // Support for potential future decent mode listing in the protocol
109
+                    // 
110
+                    // See my proposal: http://shanemcc.co.uk/irc/#listmode
111
+                    // Add listmode handler
112
+                    String[] handles = new String[2];
113
+                    handles[0] = sValue; // List mode item
114
+                    final String endValue = ""+(Integer.parseInt(sValue) + 1);
115
+                    myParser.h005Info.put("LISTMODEEND", endValue);
116
+                    handles[1] = endValue; // List mode end
117
+                    // Add listmode handlers
118
+                    try {
119
+                        myParser.getProcessingManager().addProcessor(handles, myParser.getProcessingManager().getProcessor("__LISTMODE__"));
120
+                    } catch (ProcessorNotFoundException e) { }
121
+                }
122
+            }
123
+        }
124
+    }
125
+    
126
+    /**
127
+     * What does this IRCProcessor handle.
128
+     *
129
+     * @return String[] with the names of the tokens we handle.
130
+     */
131
+    @Override
132
+    public String[] handles() {
133
+        return new String[]{"002", "003", "004", "005"};
134
+    } 
135
+    
136
+    /**
137
+     * Callback to all objects implementing the GotNetwork Callback.
138
+     * This takes no params of its own, but works them out itself.
139
+     *
140
+     * @see IGotNetwork
141
+     * @return true if a method was called, false otherwise
142
+     */
143
+    protected boolean callGotNetwork() {
144
+        final String networkName = myParser.networkName;
145
+        final String ircdVersion = myParser.getIRCD(false);
146
+        final String ircdType = myParser.getIRCD(true);
147
+        
148
+        return getCallbackManager().getCallbackType(NetworkDetectedListener.class).call(networkName, ircdVersion, ircdType);
149
+    }
150
+    
151
+    /**
152
+     * Create a new instance of the IRCProcessor Object.
153
+     *
154
+     * @param parser IRCParser That owns this IRCProcessor
155
+     * @param manager ProcessingManager that is in charge of this IRCProcessor
156
+     */
157
+    protected Process004005 (final IRCParser parser, final ProcessingManager manager) { super(parser, manager); }
158
+
159
+}

+ 72
- 0
src/com/dmdirc/parser/irc/Process464.java Näytä tiedosto

@@ -0,0 +1,72 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.interfaces.callbacks.PasswordRequiredListener;
26
+
27
+/**
28
+ * Process a 464 message.
29
+ */
30
+public class Process464 extends IRCProcessor {
31
+    /**
32
+     * Process a 464 message.
33
+     *
34
+     * @param sParam Type of line to process ("464")
35
+     * @param token IRCTokenised line to process
36
+     */
37
+    @Override
38
+    public void process(String sParam, String[] token) {
39
+        callPasswordRequired();
40
+//        ParserError ei = new ParserError(ParserError.ERROR_ERROR, "Password Required");
41
+//        callErrorInfo(ei);
42
+    }
43
+    
44
+    /**
45
+     * What does this IRCProcessor handle.
46
+     *
47
+     * @return String[] with the names of the tokens we handle.
48
+     */
49
+    @Override
50
+    public String[] handles() {
51
+        return new String[]{"464"};
52
+    } 
53
+    
54
+    /**
55
+     * Callback to all objects implementing the PasswordRequired Callback.
56
+     *
57
+     * @see IPasswordRequired
58
+     * @return true if a method was called, false otherwise
59
+     */
60
+    protected boolean callPasswordRequired() {
61
+        return getCallbackManager().getCallbackType(PasswordRequiredListener.class).call();
62
+    }
63
+    
64
+    /**
65
+     * Create a new instance of the IRCProcessor Object.
66
+     *
67
+     * @param parser IRCParser That owns this IRCProcessor
68
+     * @param manager ProcessingManager that is in charge of this IRCProcessor
69
+     */
70
+    protected Process464 (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
71
+
72
+}

+ 78
- 0
src/com/dmdirc/parser/irc/ProcessAway.java Näytä tiedosto

@@ -0,0 +1,78 @@
1
+/*
2
+ * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import com.dmdirc.parser.interfaces.callbacks.AwayStateListener;
26
+
27
+/**
28
+ * Process an Away/Back message.
29
+ */
30
+public class ProcessAway extends IRCProcessor {
31
+    /**
32
+     * Process an Away/Back message.
33
+     *
34
+     * @param sParam Type of line to process ("305", "306")
35
+     * @param token IRCTokenised line to process
36
+     */
37
+    @Override
38
+    public void process(String sParam, String[] token) {
39
+        if (sParam.equals("301")) {
40
+            IRCClientInfo iClient = getClientInfo(token[3]);
41
+            if (iClient != null) { iClient.setAwayReason(token[token.length-1]); }
42
+        } else {
43
+            myParser.getLocalClient().setAwayState(sParam.equals("306"));
44
+            callAwayState(myParser.getLocalClient().getAwayState(), myParser.getLocalClient().getAwayReason());
45
+        }
46
+    }
47
+    
48
+    /**
49
+     * Callback to all objects implementing the onAwayState Callback.
50
+     *
51
+     * @see IAwayState
52
+     * @param currentState Set to true if we are now away, else false.
53
+     * @param reason Best guess at away reason
54
+     * @return true if a method was called, false otherwise
55
+     */
56
+    protected boolean callAwayState(boolean currentState, String reason) {
57
+        return myParser.getCallbackManager().getCallbackType(AwayStateListener.class).call(currentState, reason);
58
+    }
59
+    
60
+    /**
61
+     * What does this IRCProcessor handle.
62
+     *
63
+     * @return String[] with the names of the tokens we handle.
64
+     */
65
+    @Override
66
+    public String[] handles() {
67
+        return new String[]{"301", "305", "306"};
68
+    } 
69
+    
70
+    /**
71
+     * Create a new instance of the IRCProcessor Object.
72
+     *
73
+     * @param parser IRCParser That owns this IRCProcessor
74
+     * @param manager ProcessingManager that is in charge of this IRCProcessor
75
+     */
76
+    protected ProcessAway (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
77
+
78
+}

+ 0
- 0
src/com/dmdirc/parser/irc/ProcessInvite.java Näytä tiedosto


Some files were not shown because too many files changed in this diff

Loading…
Peruuta
Tallenna