Browse Source

Remove all usages of getCallbackType.

All callbacks are now done through getCallback, which offers
type safety (gasp!) and is potentially extensible in the future
(wow!).

This means that nothing can depend on callbacks existing, so
there are two functional changes:

 - the parser will no longer disconnect automatically on failed
   pings; users have to listen for the event and handle it
   themselves;

 - the parser will no longer attempt to automatically use alt
   nicknames or create new nicknames on connection; users have to
   listen for the event and implement the logic themselves

Both of these were really weird anyway, as adding a listener (even
for debugging purposes) disabled the built-in behaviour.
pull/41/head
Chris Smith 9 years ago
parent
commit
d25b195470
24 changed files with 130 additions and 165 deletions
  1. 1
    1
      common/src/com/dmdirc/parser/common/CallbackManager.java
  2. 2
    3
      common/src/com/dmdirc/parser/common/CallbackObject.java
  3. 0
    52
      common/src/com/dmdirc/parser/common/MyInfo.java
  4. 4
    13
      irc/src/com/dmdirc/parser/irc/IRCParser.java
  5. 4
    4
      irc/src/com/dmdirc/parser/irc/ProcessingManager.java
  6. 2
    2
      irc/src/com/dmdirc/parser/irc/processors/Process004005.java
  7. 2
    1
      irc/src/com/dmdirc/parser/irc/processors/Process464.java
  8. 2
    1
      irc/src/com/dmdirc/parser/irc/processors/ProcessAway.java
  9. 2
    1
      irc/src/com/dmdirc/parser/irc/processors/ProcessInvite.java
  10. 4
    2
      irc/src/com/dmdirc/parser/irc/processors/ProcessJoin.java
  11. 3
    1
      irc/src/com/dmdirc/parser/irc/processors/ProcessKick.java
  12. 2
    1
      irc/src/com/dmdirc/parser/irc/processors/ProcessListModes.java
  13. 6
    3
      irc/src/com/dmdirc/parser/irc/processors/ProcessMOTD.java
  14. 39
    19
      irc/src/com/dmdirc/parser/irc/processors/ProcessMessage.java
  15. 24
    23
      irc/src/com/dmdirc/parser/irc/processors/ProcessMode.java
  16. 4
    2
      irc/src/com/dmdirc/parser/irc/processors/ProcessNames.java
  17. 4
    2
      irc/src/com/dmdirc/parser/irc/processors/ProcessNick.java
  18. 4
    23
      irc/src/com/dmdirc/parser/irc/processors/ProcessNickInUse.java
  19. 2
    1
      irc/src/com/dmdirc/parser/irc/processors/ProcessNoticeAuth.java
  20. 2
    1
      irc/src/com/dmdirc/parser/irc/processors/ProcessPart.java
  21. 4
    2
      irc/src/com/dmdirc/parser/irc/processors/ProcessQuit.java
  22. 2
    1
      irc/src/com/dmdirc/parser/irc/processors/ProcessTopic.java
  23. 5
    3
      irc/src/com/dmdirc/parser/irc/processors/ProcessWallops.java
  24. 6
    3
      irc/src/com/dmdirc/parser/irc/processors/ProcessWho.java

+ 1
- 1
common/src/com/dmdirc/parser/common/CallbackManager.java View File

@@ -200,7 +200,7 @@ public class CallbackManager {
200 200
      * @param callback Name of type of callback object.
201 201
      * @return CallbackObject returns the callback object for this type
202 202
      */
203
-    public CallbackObject getCallbackType(final Class<? extends CallbackInterface> callback) {
203
+    private CallbackObject getCallbackType(final Class<? extends CallbackInterface> callback) {
204 204
         if (!callbackHash.containsKey(callback)) {
205 205
             throw new CallbackNotFoundException("Callback not found: " + callback.getName()
206 206
                     + "\n\nMy class: " + getClass().getName()

+ 2
- 3
common/src/com/dmdirc/parser/common/CallbackObject.java View File

@@ -101,10 +101,9 @@ public class CallbackObject {
101 101
      * Call the OnErrorInfo callback.
102 102
      *
103 103
      * @param errorInfo ParserError object to pass as error.
104
-     * @return true if error call succeeded, false otherwise
105 104
      */
106
-    protected final boolean callErrorInfo(final ParserError errorInfo) {
107
-        return myManager.getCallbackType(ErrorInfoListener.class).call(errorInfo);
105
+    protected final void callErrorInfo(final ParserError errorInfo) {
106
+        myManager.getCallback(ErrorInfoListener.class).onErrorInfo(null, null, errorInfo);
108 107
     }
109 108
 
110 109
     /**

+ 0
- 52
common/src/com/dmdirc/parser/common/MyInfo.java View File

@@ -31,21 +31,9 @@ import com.dmdirc.parser.interfaces.Parser;
31 31
  */
32 32
 public class MyInfo {
33 33
 
34
-    /** Character to prepend to nickname if in use (Default "_"). */
35
-    private char prependChar = '_';
36
-
37 34
     /** Nickname to attempt to use on IRC. */
38 35
     private String nickname;
39 36
 
40
-    /**
41
-     * Alternative nickname to attempt to use on IRC. If the first nickname is
42
-     * in use, and a NickInUse message is recieved before 001, we will attempt
43
-     * to use this nickname instead.<br>
44
-     * If this also fails, we will start prepending the prependChar character
45
-     * (_) to the main nickname
46
-     */
47
-    private String altNickname;
48
-
49 37
     /** Realname string to use. */
50 38
     private String realname;
51 39
 
@@ -66,12 +54,10 @@ public class MyInfo {
66 54
             nickname = "IRCParser";
67 55
             username = "IRCParser";
68 56
             realname = "DMDIrc IRCParser";
69
-            altNickname = "IRC-Parser";
70 57
         } else {
71 58
             nickname = result;
72 59
             username = nickname;
73 60
             realname = nickname + " - DMDIrc";
74
-            altNickname = nickname + '-';
75 61
         }
76 62
     }
77 63
 
@@ -95,26 +81,6 @@ public class MyInfo {
95 81
         return nickname;
96 82
     }
97 83
 
98
-    /**
99
-     * Set the Alternative Nickname.
100
-     *
101
-     * @param newValue Value to set to.
102
-     */
103
-    public void setAltNickname(final String newValue) {
104
-        if (newValue != null && !newValue.isEmpty()) {
105
-            altNickname = newValue;
106
-        }
107
-    }
108
-
109
-    /**
110
-     * Get the Alternative Nickname.
111
-     *
112
-     * @return Current Nickname
113
-     */
114
-    public String getAltNickname() {
115
-        return altNickname;
116
-    }
117
-
118 84
     /**
119 85
      * Set the Realname.
120 86
      *
@@ -155,22 +121,4 @@ public class MyInfo {
155 121
         return username;
156 122
     }
157 123
 
158
-    /**
159
-     * Set the Prepend Character.
160
-     *
161
-     * @param newValue Value to set to.
162
-     */
163
-    public void setPrependChar(final char newValue) {
164
-        prependChar = newValue;
165
-    }
166
-
167
-    /**
168
-     * Get the Prepend Character.
169
-     *
170
-     * @return Current Prepend Character
171
-     */
172
-    public char getPrependChar() {
173
-        return prependChar;
174
-    }
175
-
176 124
 }

+ 4
- 13
irc/src/com/dmdirc/parser/irc/IRCParser.java View File

@@ -617,10 +617,9 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
617 617
      * Callback to all objects implementing the PingFailed Callback.
618 618
      *
619 619
      * @see PingFailureListener
620
-     * @return True if any callback was called, false otherwise.
621 620
      */
622
-    protected boolean callPingFailed() {
623
-        return getCallbackManager().getCallbackType(PingFailureListener.class).call();
621
+    protected void callPingFailed() {
622
+        getCallbackManager().getCallback(PingFailureListener.class).onPingFailed(null, null);
624 623
     }
625 624
 
626 625
     /**
@@ -1920,17 +1919,9 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
1920 1919
 
1921 1920
             return;
1922 1921
         }
1923
-        if (getPingNeeded()) {
1924
-            if (!callPingFailed()) {
1925
-                pingTimerSem.acquireUninterruptibly();
1926
-
1927
-                if (pingTimer != null && pingTimer.equals(timer)) {
1928
-                    pingTimer.cancel();
1929
-                }
1930
-                pingTimerSem.release();
1931 1922
 
1932
-                disconnect("Server not responding.");
1933
-            }
1923
+        if (getPingNeeded()) {
1924
+            callPingFailed();
1934 1925
         } else {
1935 1926
             --pingCountDown;
1936 1927
             if (pingCountDown < 1) {

+ 4
- 4
irc/src/com/dmdirc/parser/irc/ProcessingManager.java View File

@@ -267,12 +267,12 @@ public class ProcessingManager {
267 267
     /**
268 268
      * Callback to all objects implementing the onNumeric Callback.
269 269
      *
270
-     * @see com.dmdirc.parser.interfaces.callbacks.NumericListener
270
+     * @see NumericListener
271 271
      * @param numeric What numeric is this for
272 272
      * @param token IRC Tokenised line
273
-     * @return true if a method was called, false otherwise
274 273
      */
275
-    protected boolean callNumeric(final int numeric, final String... token) {
276
-        return parser.getCallbackManager().getCallbackType(NumericListener.class).call(numeric, token);
274
+    protected void callNumeric(final int numeric, final String... token) {
275
+        parser.getCallbackManager().getCallback(NumericListener.class)
276
+                .onNumeric(null, null, numeric, token);
277 277
     }
278 278
 }

+ 2
- 2
irc/src/com/dmdirc/parser/irc/processors/Process004005.java View File

@@ -94,8 +94,8 @@ public class Process004005 extends IRCProcessor {
94 94
         final String ircdVersion = parser.getServerSoftware();
95 95
         final String ircdType = parser.getServerSoftwareType();
96 96
 
97
-        getCallbackManager().getCallbackType(NetworkDetectedListener.class)
98
-                .call(networkName, ircdVersion, ircdType);
97
+        getCallbackManager().getCallback(NetworkDetectedListener.class)
98
+                .onGotNetwork(null, null, networkName, ircdVersion, ircdType);
99 99
     }
100 100
 
101 101
     /**

+ 2
- 1
irc/src/com/dmdirc/parser/irc/processors/Process464.java View File

@@ -68,6 +68,7 @@ public class Process464 extends IRCProcessor {
68 68
      * @see PasswordRequiredListener
69 69
      */
70 70
     protected void callPasswordRequired() {
71
-        getCallbackManager().getCallbackType(PasswordRequiredListener.class).call();
71
+        getCallbackManager().getCallback(PasswordRequiredListener.class)
72
+                .onPasswordRequired(null, null);
72 73
     }
73 74
 }

+ 2
- 1
irc/src/com/dmdirc/parser/irc/processors/ProcessAway.java View File

@@ -90,7 +90,8 @@ public class ProcessAway extends IRCProcessor {
90 90
      */
91 91
     protected void callAwayState(final AwayState oldState, final AwayState currentState,
92 92
             final String reason) {
93
-        getCallbackManager().getCallbackType(AwayStateListener.class).call(oldState, currentState, reason);
93
+        getCallbackManager().getCallback(AwayStateListener.class)
94
+                .onAwayState(null, null, oldState, currentState, reason);
94 95
     }
95 96
 
96 97
     /**

+ 2
- 1
irc/src/com/dmdirc/parser/irc/processors/ProcessInvite.java View File

@@ -63,7 +63,8 @@ public class ProcessInvite extends IRCProcessor {
63 63
      * @param channel The name of the channel we were invited to
64 64
      */
65 65
     protected void callInvite(final String userHost, final String channel) {
66
-        getCallbackManager().getCallbackType(InviteListener.class).call(userHost, channel);
66
+        getCallbackManager().getCallback(InviteListener.class)
67
+                .onInvite(null, null, userHost, channel);
67 68
     }
68 69
 
69 70
     /**

+ 4
- 2
irc/src/com/dmdirc/parser/irc/processors/ProcessJoin.java View File

@@ -182,7 +182,8 @@ public class ProcessJoin extends IRCProcessor {
182 182
      */
183 183
     protected void callChannelJoin(final ChannelInfo cChannel,
184 184
             final ChannelClientInfo cChannelClient) {
185
-        getCallbackManager().getCallbackType(ChannelJoinListener.class).call(cChannel, cChannelClient);
185
+        getCallbackManager().getCallback(ChannelJoinListener.class)
186
+                .onChannelJoin(null, null, cChannel, cChannelClient);
186 187
     }
187 188
 
188 189
     /**
@@ -192,7 +193,8 @@ public class ProcessJoin extends IRCProcessor {
192 193
      * @param cChannel Channel Object
193 194
      */
194 195
     protected void callChannelSelfJoin(final ChannelInfo cChannel) {
195
-        getCallbackManager().getCallbackType(ChannelSelfJoinListener.class).call(cChannel);
196
+        getCallbackManager().getCallback(ChannelSelfJoinListener.class)
197
+                .onChannelSelfJoin(null, null, cChannel);
196 198
     }
197 199
 
198 200
     /**

+ 3
- 1
irc/src/com/dmdirc/parser/irc/processors/ProcessKick.java View File

@@ -120,7 +120,9 @@ public class ProcessKick extends IRCProcessor {
120 120
     protected void callChannelKick(final ChannelInfo cChannel,
121 121
             final ChannelClientInfo cKickedClient, final ChannelClientInfo cKickedByClient,
122 122
             final String sReason, final String sKickedByHost) {
123
-        getCallbackManager().getCallbackType(ChannelKickListener.class).call(cChannel, cKickedClient, cKickedByClient, sReason, sKickedByHost);
123
+        getCallbackManager().getCallback(ChannelKickListener.class)
124
+                .onChannelKick(null, null, cChannel, cKickedClient, cKickedByClient, sReason,
125
+                        sKickedByHost);
124 126
     }
125 127
 
126 128
     /**

+ 2
- 1
irc/src/com/dmdirc/parser/irc/processors/ProcessListModes.java View File

@@ -294,6 +294,7 @@ public class ProcessListModes extends IRCProcessor {
294 294
      * @param mode the mode that we got list modes for.
295 295
      */
296 296
     protected void callChannelGotListModes(final ChannelInfo cChannel, final char mode) {
297
-        getCallbackManager().getCallbackType(ChannelListModeListener.class).call(cChannel, mode);
297
+        getCallbackManager().getCallback(ChannelListModeListener.class)
298
+                .onChannelGotListModes(null, null, cChannel, mode);
298 299
     }
299 300
 }

+ 6
- 3
irc/src/com/dmdirc/parser/irc/processors/ProcessMOTD.java View File

@@ -72,7 +72,8 @@ public class ProcessMOTD extends IRCProcessor {
72 72
      * @see MotdEndListener
73 73
      */
74 74
     protected void callMOTDEnd(final boolean noMOTD, final String data) {
75
-        getCallbackManager().getCallbackType(MotdEndListener.class).call(noMOTD, data);
75
+        getCallbackManager().getCallback(MotdEndListener.class)
76
+                .onMOTDEnd(null, null, noMOTD, data);
76 77
     }
77 78
 
78 79
     /**
@@ -82,7 +83,8 @@ public class ProcessMOTD extends IRCProcessor {
82 83
      * @param data Incomming Line.
83 84
      */
84 85
     protected void callMOTDLine(final String data) {
85
-        getCallbackManager().getCallbackType(MotdLineListener.class).call(data);
86
+        getCallbackManager().getCallback(MotdLineListener.class)
87
+                .onMOTDLine(null, null, data);
86 88
     }
87 89
 
88 90
     /**
@@ -92,7 +94,8 @@ public class ProcessMOTD extends IRCProcessor {
92 94
      * @param data Incomming Line.
93 95
      */
94 96
     protected void callMOTDStart(final String data) {
95
-        getCallbackManager().getCallbackType(MotdStartListener.class).call(data);
97
+        getCallbackManager().getCallback(MotdStartListener.class)
98
+                .onMOTDStart(null, null, data);
96 99
     }
97 100
 
98 101
     /**

+ 39
- 19
irc/src/com/dmdirc/parser/irc/processors/ProcessMessage.java View File

@@ -302,7 +302,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
302 302
      */
303 303
     protected void callChannelAction(final Date date, final ChannelInfo cChannel,
304 304
             final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
305
-        getCallbackManager().getCallbackType(ChannelActionListener.class).call(date, cChannel, cChannelClient, sMessage, sHost);
305
+        getCallbackManager().getCallback(ChannelActionListener.class)
306
+                .onChannelAction(null, date, cChannel, cChannelClient, sMessage, sHost);
306 307
     }
307 308
 
308 309
     /**
@@ -319,7 +320,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
319 320
     protected void callChannelCTCP(final Date date, final ChannelInfo cChannel,
320 321
             final ChannelClientInfo cChannelClient, final String sType, final String sMessage,
321 322
             final String sHost) {
322
-        getCallbackManager().getCallbackType(ChannelCtcpListener.class).call(date, cChannel, cChannelClient, sType, sMessage, sHost);
323
+        getCallbackManager().getCallback(ChannelCtcpListener.class)
324
+                .onChannelCTCP(null, date, cChannel, cChannelClient, sType, sMessage, sHost);
323 325
     }
324 326
 
325 327
     /**
@@ -336,7 +338,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
336 338
     protected void callChannelCTCPReply(final Date date, final ChannelInfo cChannel,
337 339
             final ChannelClientInfo cChannelClient, final String sType, final String sMessage,
338 340
             final String sHost) {
339
-        getCallbackManager().getCallbackType(ChannelCtcpReplyListener.class).call(date, cChannel, cChannelClient, sType, sMessage, sHost);
341
+        getCallbackManager().getCallback(ChannelCtcpReplyListener.class)
342
+                .onChannelCTCPReply(null, date, cChannel, cChannelClient, sType, sMessage, sHost);
340 343
     }
341 344
 
342 345
     /**
@@ -351,7 +354,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
351 354
      */
352 355
     protected void callChannelMessage(final Date date, final ChannelInfo cChannel,
353 356
             final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
354
-        getCallbackManager().getCallbackType(ChannelMessageListener.class).call(date, cChannel, cChannelClient, sMessage, sHost);
357
+        getCallbackManager().getCallback(ChannelMessageListener.class)
358
+                .onChannelMessage(null, date, cChannel, cChannelClient, sMessage, sHost);
355 359
     }
356 360
 
357 361
     /**
@@ -366,7 +370,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
366 370
      */
367 371
     protected void callChannelNotice(final Date date, final ChannelInfo cChannel,
368 372
             final ChannelClientInfo cChannelClient, final String sMessage, final String sHost) {
369
-        getCallbackManager().getCallbackType(ChannelNoticeListener.class).call(date, cChannel, cChannelClient, sMessage, sHost);
373
+        getCallbackManager().getCallback(ChannelNoticeListener.class)
374
+                .onChannelNotice(null, date, cChannel, cChannelClient, sMessage, sHost);
370 375
     }
371 376
 
372 377
     /**
@@ -383,7 +388,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
383 388
     protected void callChannelModeNotice(final Date date, final char prefix,
384 389
             final ChannelInfo cChannel, final ChannelClientInfo cChannelClient,
385 390
             final String sMessage, final String sHost) {
386
-        getCallbackManager().getCallbackType(ChannelModeNoticeListener.class).call(date, cChannel, prefix, cChannelClient, sMessage, sHost);
391
+        getCallbackManager().getCallback(ChannelModeNoticeListener.class)
392
+                .onChannelModeNotice(null, date, cChannel, prefix, cChannelClient, sMessage, sHost);
387 393
     }
388 394
 
389 395
     /**
@@ -400,7 +406,9 @@ public class ProcessMessage extends TimestampedIRCProcessor {
400 406
     protected void callChannelModeMessage(final Date date, final char prefix,
401 407
             final ChannelInfo cChannel, final ChannelClientInfo cChannelClient,
402 408
             final String sMessage, final String sHost) {
403
-        getCallbackManager().getCallbackType(ChannelModeMessageListener.class).call(date, cChannel, prefix, cChannelClient, sMessage, sHost);
409
+        getCallbackManager().getCallback(ChannelModeMessageListener.class)
410
+                .onChannelModeMessage(null, date, cChannel, prefix, cChannelClient, sMessage,
411
+                        sHost);
404 412
     }
405 413
 
406 414
     /**
@@ -412,7 +420,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
412 420
      * @param sHost Hostname of sender (or servername)
413 421
      */
414 422
     protected void callPrivateAction(final Date date, final String sMessage, final String sHost) {
415
-        getCallbackManager().getCallbackType(PrivateActionListener.class).call(date, sMessage, sHost);
423
+        getCallbackManager().getCallback(PrivateActionListener.class)
424
+                .onPrivateAction(null, date, sMessage, sHost);
416 425
     }
417 426
 
418 427
     /**
@@ -426,7 +435,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
426 435
      */
427 436
     protected void callPrivateCTCP(final Date date, final String sType, final String sMessage,
428 437
             final String sHost) {
429
-        getCallbackManager().getCallbackType(PrivateCtcpListener.class).call(date, sType, sMessage, sHost);
438
+        getCallbackManager().getCallback(PrivateCtcpListener.class)
439
+                .onPrivateCTCP(null, date, sType, sMessage, sHost);
430 440
     }
431 441
 
432 442
     /**
@@ -440,7 +450,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
440 450
      */
441 451
     protected void callPrivateCTCPReply(final Date date, final String sType, final String sMessage,
442 452
             final String sHost) {
443
-        getCallbackManager().getCallbackType(PrivateCtcpReplyListener.class).call(date, sType, sMessage, sHost);
453
+        getCallbackManager().getCallback(PrivateCtcpReplyListener.class)
454
+                .onPrivateCTCPReply(null, date, sType, sMessage, sHost);
444 455
     }
445 456
 
446 457
     /**
@@ -452,7 +463,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
452 463
      * @param sHost Hostname of sender (or servername)
453 464
      */
454 465
     protected void callPrivateMessage(final Date date, final String sMessage, final String sHost) {
455
-        getCallbackManager().getCallbackType(PrivateMessageListener.class).call(date, sMessage, sHost);
466
+        getCallbackManager().getCallback(PrivateMessageListener.class)
467
+                .onPrivateMessage(null, date, sMessage, sHost);
456 468
     }
457 469
 
458 470
     /**
@@ -464,7 +476,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
464 476
      * @param sHost Hostname of sender (or servername)
465 477
      */
466 478
     protected void callPrivateNotice(final Date date, final String sMessage, final String sHost) {
467
-        getCallbackManager().getCallbackType(PrivateNoticeListener.class).call(date, sMessage, sHost);
479
+        getCallbackManager().getCallback(PrivateNoticeListener.class)
480
+                .onPrivateNotice(null, date, sMessage, sHost);
468 481
     }
469 482
 
470 483
     /**
@@ -476,7 +489,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
476 489
      * @param sHost Hostname of sender (or servername)
477 490
      */
478 491
     protected void callServerNotice(final Date date, final String sMessage, final String sHost) {
479
-        getCallbackManager().getCallbackType(ServerNoticeListener.class).call(date, sMessage, sHost);
492
+        getCallbackManager().getCallback(ServerNoticeListener.class)
493
+                .onServerNotice(null, date, sMessage, sHost);
480 494
     }
481 495
 
482 496
     /**
@@ -490,7 +504,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
490 504
      */
491 505
     protected void callUnknownAction(final Date date, final String sMessage, final String sTarget,
492 506
             final String sHost) {
493
-        getCallbackManager().getCallbackType(UnknownActionListener.class).call(date, sMessage, sTarget, sHost);
507
+        getCallbackManager().getCallback(UnknownActionListener.class)
508
+                .onUnknownAction(null, date, sMessage, sTarget, sHost);
494 509
     }
495 510
 
496 511
     /**
@@ -505,7 +520,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
505 520
      */
506 521
     protected void callUnknownCTCP(final Date date, final String sType, final String sMessage,
507 522
             final String sTarget, final String sHost) {
508
-        getCallbackManager().getCallbackType(UnknownCtcpListener.class).call(date, sType, sMessage, sTarget, sHost);
523
+        getCallbackManager().getCallback(UnknownCtcpListener.class)
524
+                .onUnknownCTCP(null, date, sType, sMessage, sTarget, sHost);
509 525
     }
510 526
 
511 527
     /**
@@ -520,7 +536,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
520 536
      */
521 537
     protected void callUnknownCTCPReply(final Date date, final String sType, final String sMessage,
522 538
             final String sTarget, final String sHost) {
523
-        getCallbackManager().getCallbackType(UnknownCtcpReplyListener.class).call(date, sType, sMessage, sTarget, sHost);
539
+        getCallbackManager().getCallback(UnknownCtcpReplyListener.class)
540
+                .onUnknownCTCPReply(null, date, sType, sMessage, sTarget, sHost);
524 541
     }
525 542
 
526 543
     /**
@@ -534,7 +551,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
534 551
      */
535 552
     protected void callUnknownMessage(final Date date, final String sMessage, final String sTarget,
536 553
             final String sHost) {
537
-        getCallbackManager().getCallbackType(UnknownMessageListener.class).call(date, sMessage, sTarget, sHost);
554
+        getCallbackManager().getCallback(UnknownMessageListener.class)
555
+                .onUnknownMessage(null, date, sMessage, sTarget, sHost);
538 556
     }
539 557
 
540 558
     /**
@@ -548,7 +566,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
548 566
      */
549 567
     protected void callUnknownNotice(final Date date, final String sMessage, final String sTarget,
550 568
             final String sHost) {
551
-        getCallbackManager().getCallbackType(UnknownNoticeListener.class).call(date, sMessage, sTarget, sHost);
569
+        getCallbackManager().getCallback(UnknownNoticeListener.class)
570
+                .onUnknownNotice(null, date, sMessage, sTarget, sHost);
552 571
     }
553 572
 
554 573
     /**
@@ -562,7 +581,8 @@ public class ProcessMessage extends TimestampedIRCProcessor {
562 581
      */
563 582
     protected void callUnknownServerNotice(final Date date, final String sMessage,
564 583
             final String sTarget, final String sHost) {
565
-        getCallbackManager().getCallbackType(UnknownServerNoticeListener.class).call(date, sMessage, sTarget, sHost);
584
+        getCallbackManager().getCallback(UnknownServerNoticeListener.class)
585
+                .onUnknownServerNotice(null, date, sMessage, sTarget, sHost);
566 586
     }
567 587
 
568 588
     /**

+ 24
- 23
irc/src/com/dmdirc/parser/irc/processors/ProcessMode.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.parser.irc.processors;
24 24
 
25
-import com.dmdirc.parser.common.CallbackObject;
26 25
 import com.dmdirc.parser.common.ChannelListModeItem;
27 26
 import com.dmdirc.parser.common.ParserError;
28 27
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
@@ -128,14 +127,6 @@ public class ProcessMode extends IRCProcessor {
128 127
     public void processChanMode(final String sParam, final String[] token, final String[] sModestr, final String sChannelName) {
129 128
         final StringBuilder sFullModeStr = new StringBuilder();
130 129
 
131
-        CallbackObject cbSingle = null;
132
-        CallbackObject cbNonUser = null;
133
-
134
-        if (!"324".equals(sParam)) {
135
-            cbSingle = getCallbackManager().getCallbackType(ChannelSingleModeChangeListener.class);
136
-            cbNonUser = getCallbackManager().getCallbackType(ChannelNonUserModeChangeListener.class);
137
-        }
138
-
139 130
         final IRCChannelInfo iChannel = getChannel(sChannelName);
140 131
         if (iChannel == null) {
141 132
             return;
@@ -236,8 +227,10 @@ public class ProcessMode extends IRCProcessor {
236 227
                         final long nTemp = Calendar.getInstance().getTimeInMillis() / 1000;
237 228
                         iChannel.setListModeParam(cMode, new ChannelListModeItem(sModeParam, token[0], nTemp), bPositive);
238 229
                         callDebugInfo(IRCParser.DEBUG_INFO, "List Mode: %c [%s] {Positive: %b}", cMode, sModeParam, bPositive);
239
-                        if (cbSingle != null) {
240
-                            cbSingle.call(iChannel, setterCCI, token[0], cPositive + cMode + " " + sModeParam);
230
+                        if (!"324".equals(sParam)) {
231
+                            getCallbackManager().getCallback(ChannelSingleModeChangeListener.class)
232
+                                    .onChannelSingleModeChanged(null, null, iChannel, setterCCI,
233
+                                            token[0], cPositive + cMode + " " + sModeParam);
241 234
                         }
242 235
                     } else {
243 236
                         // Mode with a parameter
@@ -247,8 +240,10 @@ public class ProcessMode extends IRCProcessor {
247 240
                             sNonUserModeStrParams.append(' ').append(sModeParam);
248 241
                             callDebugInfo(IRCParser.DEBUG_INFO, "Set Mode: %c [%s] {Positive: %b}", cMode, sModeParam, bPositive);
249 242
                             iChannel.setModeParam(cMode, sModeParam);
250
-                            if (cbSingle != null) {
251
-                                cbSingle.call(iChannel, setterCCI, token[0], cPositive + cMode + " " + sModeParam);
243
+                            if (!"324".equals(sParam)) {
244
+                                getCallbackManager().getCallback(ChannelSingleModeChangeListener.class)
245
+                                        .onChannelSingleModeChanged(null, null, iChannel, setterCCI,
246
+                                            token[0], cPositive + cMode + " " + sModeParam);
252 247
                             }
253 248
                         } else {
254 249
                             // -Mode - parameter isn't always needed, we need to check
@@ -260,8 +255,10 @@ public class ProcessMode extends IRCProcessor {
260 255
                             }
261 256
                             callDebugInfo(IRCParser.DEBUG_INFO, "Unset Mode: %c [%s] {Positive: %b}", cMode, sModeParam, bPositive);
262 257
                             iChannel.setModeParam(cMode, "");
263
-                            if (cbSingle != null) {
264
-                                cbSingle.call(iChannel, setterCCI, token[0], trim(cPositive + cMode + " " + sModeParam));
258
+                            if (!"324".equals(sParam)) {
259
+                                getCallbackManager().getCallback(ChannelSingleModeChangeListener.class)
260
+                                        .onChannelSingleModeChanged(null, null, iChannel, setterCCI,
261
+                                            token[0], trim(cPositive + cMode + " " + sModeParam));
265 262
                             }
266 263
                         }
267 264
                     }
@@ -279,10 +276,9 @@ public class ProcessMode extends IRCProcessor {
279 276
             callChannelModeChanged(iChannel, null, "", sFullModeStr.toString().trim());
280 277
         } else {
281 278
             callChannelModeChanged(iChannel, setterCCI, token[0], sFullModeStr.toString().trim());
282
-        }
283
-        if (cbNonUser != null) {
284
-            cbNonUser.call(iChannel, setterCCI, token[0],
285
-                    trim(sNonUserModeStr.toString() + sNonUserModeStrParams));
279
+            getCallbackManager().getCallback(ChannelNonUserModeChangeListener.class)
280
+                    .onChannelNonUserModeChanged(null, null, iChannel, setterCCI, token[0],
281
+                            trim(sNonUserModeStr.toString() + sNonUserModeStrParams));
286 282
         }
287 283
     }
288 284
 
@@ -349,7 +345,8 @@ public class ProcessMode extends IRCProcessor {
349 345
      */
350 346
     protected void callChannelModeChanged(final ChannelInfo cChannel,
351 347
             final ChannelClientInfo cChannelClient, final String sHost, final String sModes) {
352
-        getCallbackManager().getCallbackType(ChannelModeChangeListener.class).call(cChannel, cChannelClient, sHost, sModes);
348
+        getCallbackManager().getCallback(ChannelModeChangeListener.class)
349
+                .onChannelModeChanged(null, null, cChannel, cChannelClient, sHost, sModes);
353 350
     }
354 351
 
355 352
     /**
@@ -365,7 +362,9 @@ public class ProcessMode extends IRCProcessor {
365 362
     protected void callChannelUserModeChanged(final ChannelInfo cChannel,
366 363
             final ChannelClientInfo cChangedClient, final ChannelClientInfo cSetByClient,
367 364
             final String sHost, final String sMode) {
368
-        getCallbackManager().getCallbackType(ChannelUserModeChangeListener.class).call(cChannel, cChangedClient, cSetByClient, sHost, sMode);
365
+        getCallbackManager().getCallback(ChannelUserModeChangeListener.class)
366
+                .onChannelUserModeChanged(null, null, cChannel, cChangedClient, cSetByClient,
367
+                        sHost, sMode);
369 368
     }
370 369
 
371 370
     /**
@@ -378,7 +377,8 @@ public class ProcessMode extends IRCProcessor {
378 377
      */
379 378
     protected void callUserModeChanged(final ClientInfo cClient, final String sSetby,
380 379
             final String sModes) {
381
-        getCallbackManager().getCallbackType(UserModeChangeListener.class).call(cClient, sSetby, sModes);
380
+        getCallbackManager().getCallback(UserModeChangeListener.class)
381
+                .onUserModeChanged(null, null, cClient, sSetby, sModes);
382 382
     }
383 383
 
384 384
     /**
@@ -389,7 +389,8 @@ public class ProcessMode extends IRCProcessor {
389 389
      * @param sModes The modes set.
390 390
      */
391 391
     protected void callUserModeDiscovered(final ClientInfo cClient, final String sModes) {
392
-        getCallbackManager().getCallbackType(UserModeDiscoveryListener.class).call(cClient, sModes);
392
+        getCallbackManager().getCallback(UserModeDiscoveryListener.class)
393
+                .onUserModeDiscovered(null, null, cClient, sModes);
393 394
     }
394 395
 
395 396
     /**

+ 4
- 2
irc/src/com/dmdirc/parser/irc/processors/ProcessNames.java View File

@@ -145,7 +145,8 @@ public class ProcessNames extends IRCProcessor {
145 145
      */
146 146
     protected void callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
147 147
         ((IRCChannelInfo) cChannel).setHadTopic();
148
-        getCallbackManager().getCallbackType(ChannelTopicListener.class).call(cChannel, bIsJoinTopic);
148
+        getCallbackManager().getCallback(ChannelTopicListener.class)
149
+                .onChannelTopic(null, null, cChannel, bIsJoinTopic);
149 150
     }
150 151
 
151 152
     /**
@@ -155,7 +156,8 @@ public class ProcessNames extends IRCProcessor {
155 156
      * @param cChannel Channel which the names reply is for
156 157
      */
157 158
     protected void callChannelGotNames(final ChannelInfo cChannel) {
158
-        getCallbackManager().getCallbackType(ChannelNamesListener.class).call(cChannel);
159
+        getCallbackManager().getCallback(ChannelNamesListener.class)
160
+                .onChannelGotNames(null, null, cChannel);
159 161
     }
160 162
 
161 163
     /**

+ 4
- 2
irc/src/com/dmdirc/parser/irc/processors/ProcessNick.java View File

@@ -107,7 +107,8 @@ public class ProcessNick extends IRCProcessor {
107 107
      */
108 108
     protected void callChannelNickChanged(final ChannelInfo cChannel,
109 109
             final ChannelClientInfo cChannelClient, final String sOldNick) {
110
-        getCallbackManager().getCallbackType(ChannelNickChangeListener.class).call(cChannel, cChannelClient, sOldNick);
110
+        getCallbackManager().getCallback(ChannelNickChangeListener.class)
111
+                .onChannelNickChanged(null, null, cChannel, cChannelClient, sOldNick);
111 112
     }
112 113
 
113 114
     /**
@@ -118,7 +119,8 @@ public class ProcessNick extends IRCProcessor {
118 119
      * @param sOldNick Nickname before change
119 120
      */
120 121
     protected void callNickChanged(final ClientInfo cClient, final String sOldNick) {
121
-        getCallbackManager().getCallbackType(NickChangeListener.class).call(cClient, sOldNick);
122
+        getCallbackManager().getCallback(NickChangeListener.class)
123
+                .onNickChanged(null, null, cClient, sOldNick);
122 124
     }
123 125
 
124 126
     /**

+ 4
- 23
irc/src/com/dmdirc/parser/irc/processors/ProcessNickInUse.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.parser.irc.processors;
24 24
 
25
-import com.dmdirc.parser.common.MyInfo;
26 25
 import com.dmdirc.parser.interfaces.callbacks.NickInUseListener;
27 26
 import com.dmdirc.parser.irc.IRCParser;
28 27
 import com.dmdirc.parser.irc.ProcessingManager;
@@ -62,25 +61,7 @@ public class ProcessNickInUse extends IRCProcessor {
62 61
      */
63 62
     @Override
64 63
     public void process(final String sParam, final String... token) {
65
-        if (!callNickInUse(token[3])) {
66
-            // Manually handle nick in use.
67
-            callDebugInfo(IRCParser.DEBUG_INFO, "No Nick in use Handler.");
68
-            if (!parser.got001) {
69
-                callDebugInfo(IRCParser.DEBUG_INFO, "Using inbuilt handler");
70
-                // If this is before 001 we will try and get a nickname, else we will leave the nick as-is
71
-                final MyInfo myInfo = parser.getMyInfo();
72
-                if (parser.triedAlt) {
73
-                    final String magicAltNick = myInfo.getPrependChar() + myInfo.getNickname();
74
-                    if (parser.getStringConverter().equalsIgnoreCase(parser.thinkNickname, myInfo.getAltNickname()) && !myInfo.getAltNickname().equalsIgnoreCase(magicAltNick)) {
75
-                        parser.thinkNickname = myInfo.getNickname();
76
-                    }
77
-                    parser.getLocalClient().setNickname(myInfo.getPrependChar() + parser.thinkNickname);
78
-                } else {
79
-                    parser.getLocalClient().setNickname(parser.getMyInfo().getAltNickname());
80
-                    parser.triedAlt = true;
81
-                }
82
-            }
83
-        }
64
+        callNickInUse(token[3]);
84 65
     }
85 66
 
86 67
     /**
@@ -88,10 +69,10 @@ public class ProcessNickInUse extends IRCProcessor {
88 69
      *
89 70
      * @param nickname Nickname that was wanted.
90 71
      * @see NickInUseListener
91
-     * @return true if a method was called, false otherwise
92 72
      */
93
-    protected boolean callNickInUse(final String nickname) {
94
-        return getCallbackManager().getCallbackType(NickInUseListener.class).call(nickname);
73
+    protected void callNickInUse(final String nickname) {
74
+        getCallbackManager().getCallback(NickInUseListener.class)
75
+                .onNickInUse(null, null, nickname);
95 76
     }
96 77
 
97 78
     /**

+ 2
- 1
irc/src/com/dmdirc/parser/irc/processors/ProcessNoticeAuth.java View File

@@ -59,7 +59,8 @@ public class ProcessNoticeAuth extends IRCProcessor {
59 59
      * @param data Incomming Line.
60 60
      */
61 61
     protected void callNoticeAuth(final String data) {
62
-        getCallbackManager().getCallbackType(AuthNoticeListener.class).call(data);
62
+        getCallbackManager().getCallback(AuthNoticeListener.class)
63
+                .onNoticeAuth(null, null, data);
63 64
     }
64 65
 
65 66
     /**

+ 2
- 1
irc/src/com/dmdirc/parser/irc/processors/ProcessPart.java View File

@@ -112,7 +112,8 @@ public class ProcessPart extends IRCProcessor {
112 112
      */
113 113
     protected void callChannelPart(final ChannelInfo cChannel,
114 114
             final ChannelClientInfo cChannelClient, final String sReason) {
115
-        getCallbackManager().getCallbackType(ChannelPartListener.class).call(cChannel, cChannelClient, sReason);
115
+        getCallbackManager().getCallback(ChannelPartListener.class)
116
+                .onChannelPart(null, null, cChannel, cChannelClient, sReason);
116 117
     }
117 118
 
118 119
     /**

+ 4
- 2
irc/src/com/dmdirc/parser/irc/processors/ProcessQuit.java View File

@@ -120,7 +120,8 @@ public class ProcessQuit extends IRCProcessor {
120 120
      */
121 121
     protected void callChannelQuit(final ChannelInfo cChannel,
122 122
             final ChannelClientInfo cChannelClient, final String sReason) {
123
-        getCallbackManager().getCallbackType(ChannelQuitListener.class).call(cChannel, cChannelClient, sReason);
123
+        getCallbackManager().getCallback(ChannelQuitListener.class)
124
+                .onChannelQuit(null, null, cChannel, cChannelClient, sReason);
124 125
     }
125 126
 
126 127
     /**
@@ -131,7 +132,8 @@ public class ProcessQuit extends IRCProcessor {
131 132
      * @param sReason Reason for quitting (may be "")
132 133
      */
133 134
     protected void callQuit(final ClientInfo cClient, final String sReason) {
134
-        getCallbackManager().getCallbackType(QuitListener.class).call(cClient, sReason);
135
+        getCallbackManager().getCallback(QuitListener.class)
136
+                .onQuit(null, null, cClient, sReason);
135 137
     }
136 138
 
137 139
     /**

+ 2
- 1
irc/src/com/dmdirc/parser/irc/processors/ProcessTopic.java View File

@@ -102,7 +102,8 @@ public class ProcessTopic extends IRCProcessor {
102 102
      */
103 103
     protected void callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
104 104
         ((IRCChannelInfo) cChannel).setHadTopic();
105
-        getCallbackManager().getCallbackType(ChannelTopicListener.class).call(cChannel, bIsJoinTopic);
105
+        getCallbackManager().getCallback(ChannelTopicListener.class)
106
+                .onChannelTopic(null, null, cChannel, bIsJoinTopic);
106 107
     }
107 108
 
108 109
     /**

+ 5
- 3
irc/src/com/dmdirc/parser/irc/processors/ProcessWallops.java View File

@@ -82,7 +82,7 @@ public class ProcessWallops extends IRCProcessor {
82 82
      * @param host Host of the user who sent the wallop
83 83
      */
84 84
     protected void callWallop(final String message, final String host) {
85
-        getCallbackManager().getCallbackType(WallopListener.class).call(message, host);
85
+        getCallbackManager().getCallback(WallopListener.class).onWallop(null, null, message, host);
86 86
     }
87 87
 
88 88
     /**
@@ -93,7 +93,8 @@ public class ProcessWallops extends IRCProcessor {
93 93
      * @param host Host of the user who sent the walluser
94 94
      */
95 95
     protected void callWalluser(final String message, final String host) {
96
-        getCallbackManager().getCallbackType(WalluserListener.class).call(message, host);
96
+        getCallbackManager().getCallback(WalluserListener.class)
97
+                .onWalluser(null, null, message, host);
97 98
     }
98 99
 
99 100
     /**
@@ -104,7 +105,8 @@ public class ProcessWallops extends IRCProcessor {
104 105
      * @param host Host of the user who sent the WallDesync
105 106
      */
106 107
     protected void callWallDesync(final String message, final String host) {
107
-        getCallbackManager().getCallbackType(WallDesyncListener.class).call(message, host);
108
+        getCallbackManager().getCallback(WallDesyncListener.class)
109
+                .onWallDesync(null, null, message, host);
108 110
     }
109 111
 
110 112
     /**

+ 6
- 3
irc/src/com/dmdirc/parser/irc/processors/ProcessWho.java View File

@@ -106,7 +106,8 @@ public class ProcessWho extends IRCProcessor {
106 106
      */
107 107
     protected void callAwayState(final AwayState oldState, final AwayState currentState,
108 108
             final String reason) {
109
-        getCallbackManager().getCallbackType(AwayStateListener.class).call(oldState, currentState, reason);
109
+        getCallbackManager().getCallback(AwayStateListener.class)
110
+                .onAwayState(null, null, oldState, currentState, reason);
110 111
     }
111 112
 
112 113
     /**
@@ -119,7 +120,8 @@ public class ProcessWho extends IRCProcessor {
119 120
      */
120 121
     protected void callAwayStateOther(final ClientInfo client, final AwayState oldState,
121 122
             final AwayState state) {
122
-        getCallbackManager().getCallbackType(OtherAwayStateListener.class).call(client, oldState, state);
123
+        getCallbackManager().getCallback(OtherAwayStateListener.class)
124
+                .onAwayStateOther(null, null, client, oldState, state);
123 125
     }
124 126
 
125 127
     /**
@@ -133,7 +135,8 @@ public class ProcessWho extends IRCProcessor {
133 135
      */
134 136
     protected void callChannelAwayStateOther(final ChannelInfo channel,
135 137
             final ChannelClientInfo channelClient, final AwayState oldState, final AwayState state) {
136
-        getCallbackManager().getCallbackType(ChannelOtherAwayStateListener.class).call(channel, channelClient, oldState, state);
138
+        getCallbackManager().getCallback(ChannelOtherAwayStateListener.class)
139
+                .onChannelAwayStateOther(null, null, channel, channelClient, oldState, state);
137 140
     }
138 141
 
139 142
     /**

Loading…
Cancel
Save