Browse Source

Fix dcc and relaybot plugins after recent change to parser callbacks.

Change-Id: Ieff2782b780f37d794ae0fc935cb9b4e6b989535
Reviewed-on: http://gerrit.dmdirc.com/1214
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4
Shane Mc Cormack 14 years ago
parent
commit
da96af41ff

+ 2
- 1
src/com/dmdirc/addons/dcc/DCCTransferWindow.java View File

38
 import java.awt.event.ActionListener;
38
 import java.awt.event.ActionListener;
39
 import java.io.File;
39
 import java.io.File;
40
 import java.io.IOException;
40
 import java.io.IOException;
41
+import java.util.Date;
41
 
42
 
42
 import javax.swing.JButton;
43
 import javax.swing.JButton;
43
 import javax.swing.JLabel;
44
 import javax.swing.JLabel;
158
 
159
 
159
     /** {@inheritDoc} */
160
     /** {@inheritDoc} */
160
     @Override
161
     @Override
161
-    public void onSocketClosed(final Parser tParser) {
162
+    public void onSocketClosed(final Parser tParser, final Date date) {
162
         // Remove our reference to the parser (and its reference to us)
163
         // Remove our reference to the parser (and its reference to us)
163
         parser.getCallbackManager().delAllCallback(this);
164
         parser.getCallbackManager().delAllCallback(this);
164
         parser = null;
165
         parser = null;

+ 2
- 1
src/com/dmdirc/addons/relaybot/RelayBotPlugin.java View File

36
 import com.dmdirc.parser.interfaces.Parser;
36
 import com.dmdirc.parser.interfaces.Parser;
37
 import com.dmdirc.parser.irc.IRCParser;
37
 import com.dmdirc.parser.irc.IRCParser;
38
 import java.util.ArrayList;
38
 import java.util.ArrayList;
39
+import java.util.Date;
39
 import java.util.HashMap;
40
 import java.util.HashMap;
40
 import java.util.Map;
41
 import java.util.Map;
41
 
42
 
88
         for (Server server : ServerManager.getServerManager().getServers()) {
89
         for (Server server : ServerManager.getServerManager().getServers()) {
89
             final Parser parser = server.getParser();
90
             final Parser parser = server.getParser();
90
             if (parser instanceof IRCParser && parser.getCallbackManager() instanceof RelayCallbackManager) {
91
             if (parser instanceof IRCParser && parser.getCallbackManager() instanceof RelayCallbackManager) {
91
-                ((RelayCallbackManager) parser.getCallbackManager()).onSocketClosed(parser);
92
+                ((RelayCallbackManager) parser.getCallbackManager()).onSocketClosed(parser, new Date());
92
             }
93
             }
93
         }
94
         }
94
 
95
 

+ 3
- 2
src/com/dmdirc/addons/relaybot/RelayCallbackManager.java View File

27
 import com.dmdirc.parser.common.CallbackManager;
27
 import com.dmdirc.parser.common.CallbackManager;
28
 import com.dmdirc.parser.common.CallbackNotFoundException;
28
 import com.dmdirc.parser.common.CallbackNotFoundException;
29
 import com.dmdirc.parser.common.CallbackObject;
29
 import com.dmdirc.parser.common.CallbackObject;
30
-import com.dmdirc.parser.common.CallbackObjectSpecific;
31
 import com.dmdirc.parser.interfaces.Parser;
30
 import com.dmdirc.parser.interfaces.Parser;
32
 import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
31
 import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
33
 import com.dmdirc.parser.interfaces.callbacks.ChannelMessageListener;
32
 import com.dmdirc.parser.interfaces.callbacks.ChannelMessageListener;
35
 import com.dmdirc.parser.irc.IRCParser;
34
 import com.dmdirc.parser.irc.IRCParser;
36
 import com.dmdirc.parser.interfaces.callbacks.SocketCloseListener;
35
 import com.dmdirc.parser.interfaces.callbacks.SocketCloseListener;
37
 import java.lang.reflect.Field;
36
 import java.lang.reflect.Field;
37
+import java.util.Date;
38
 import java.util.Map;
38
 import java.util.Map;
39
 
39
 
40
 /**
40
 /**
174
      *
174
      *
175
      * @param parser
175
      * @param parser
176
      */
176
      */
177
-    public void onSocketClosed(final Parser parser) {
177
+    @Override
178
+    public void onSocketClosed(final Parser parser, final Date date) {
178
         if (parser.getCallbackManager() instanceof RelayCallbackManager) {
179
         if (parser.getCallbackManager() instanceof RelayCallbackManager) {
179
             setCallbackManager((IRCParser)parser, originalCBM);
180
             setCallbackManager((IRCParser)parser, originalCBM);
180
         }
181
         }

+ 17
- 16
src/com/dmdirc/addons/relaybot/RelayChannelHandler.java View File

38
 import com.dmdirc.ui.messages.Styliser;
38
 import com.dmdirc.ui.messages.Styliser;
39
 import java.lang.reflect.Field;
39
 import java.lang.reflect.Field;
40
 import java.lang.reflect.Method;
40
 import java.lang.reflect.Method;
41
+import java.util.Date;
41
 import java.util.HashMap;
42
 import java.util.HashMap;
42
 import java.util.Map;
43
 import java.util.Map;
43
 
44
 
105
      * @param sendJoinIfNew
106
      * @param sendJoinIfNew
106
      * @return Requested ChannelClient Info.
107
      * @return Requested ChannelClient Info.
107
      */
108
      */
108
-    private IRCChannelClientInfo getChannelClient(final ChannelInfo channel, final String nick, final boolean sendJoinIfNew) {
109
+    private IRCChannelClientInfo getChannelClient(final ChannelInfo channel, final Date date, final String nick, final boolean sendJoinIfNew) {
109
         final Parser parser = channel.getParser();
110
         final Parser parser = channel.getParser();
110
         final String storeName = parser.getStringConverter().toLowerCase(nick);
111
         final String storeName = parser.getStringConverter().toLowerCase(nick);
111
         synchronized (channelClients) {
112
         synchronized (channelClients) {
116
 
117
 
117
                 channelClients.put(storeName, newChannelClient);
118
                 channelClients.put(storeName, newChannelClient);
118
                 if (sendJoinIfNew && !client.isServer()) {
119
                 if (sendJoinIfNew && !client.isServer()) {
119
-                    coreChannelHandler.onChannelJoin(parser, channel, newChannelClient);
120
+                    coreChannelHandler.onChannelJoin(parser, date, channel, newChannelClient);
120
                     // The nickcolour plugin colours the nicknames on join
121
                     // The nickcolour plugin colours the nicknames on join
121
                     // and uses nickname@server when colouring rather than
122
                     // and uses nickname@server when colouring rather than
122
                     // the setting the user wanted, we can recolour here to
123
                     // the setting the user wanted, we can recolour here to
226
      * @param host Host of client
227
      * @param host Host of client
227
      */
228
      */
228
     @Override
229
     @Override
229
-    public void onChannelMessage(final Parser parser, final ChannelInfo channel, final ChannelClientInfo channelClient, final String message, final String host) {
230
+    public void onChannelMessage(final Parser parser, final Date date, final ChannelInfo channel, final ChannelClientInfo channelClient, final String message, final String host) {
230
         final String channelName = parser.getStringConverter().toLowerCase(channel.getName());
231
         final String channelName = parser.getStringConverter().toLowerCase(channel.getName());
231
         String botName;
232
         String botName;
232
         try {
233
         try {
245
 
246
 
246
             if (initial.charAt(0) == '+') {
247
             if (initial.charAt(0) == '+') {
247
                 // Channel Message
248
                 // Channel Message
248
-                final IRCChannelClientInfo newChannelClient = getChannelClient(channel, bits[0].substring(2, bits[0].length() - 1), joinNew);
249
+                final IRCChannelClientInfo newChannelClient = getChannelClient(channel, date, bits[0].substring(2, bits[0].length() - 1), joinNew);
249
 
250
 
250
-                coreChannelHandler.onChannelMessage(parser, channel, newChannelClient, bits[1], host);
251
+                coreChannelHandler.onChannelMessage(parser, date, channel, newChannelClient, bits[1], host);
251
                 return;
252
                 return;
252
             } else if (initial.equalsIgnoreCase("***")) {
253
             } else if (initial.equalsIgnoreCase("***")) {
253
                 // Some kind of state-changing action
254
                 // Some kind of state-changing action
254
                 final String[] newBits = bits[1].split(" ");
255
                 final String[] newBits = bits[1].split(" ");
255
 
256
 
256
                 if (newBits.length > 2) {
257
                 if (newBits.length > 2) {
257
-                    final IRCChannelClientInfo newChannelClient = getChannelClient(channel, newBits[0], joinNew);
258
+                    final IRCChannelClientInfo newChannelClient = getChannelClient(channel, date, newBits[0], joinNew);
258
 
259
 
259
                     if (newBits[2].equalsIgnoreCase("joined")) {
260
                     if (newBits[2].equalsIgnoreCase("joined")) {
260
                         // User joined a relayed channel.
261
                         // User joined a relayed channel.
262
                             // If auto join on discover isn't enabled, we will
263
                             // If auto join on discover isn't enabled, we will
263
                             // need to send this join, else it will already
264
                             // need to send this join, else it will already
264
                             // have been sent.
265
                             // have been sent.
265
-                            coreChannelHandler.onChannelJoin(parser, channel, newChannelClient);
266
+                            coreChannelHandler.onChannelJoin(parser, date, channel, newChannelClient);
266
                             // And recolour to combat the nickcolour plugin
267
                             // And recolour to combat the nickcolour plugin
267
                             // changing the colour on join.
268
                             // changing the colour on join.
268
                             colourClient(newChannelClient);
269
                             colourClient(newChannelClient);
273
                         String reason = (newBits.length > 4) ? mergeBits(newBits, 4, newBits.length - 1, " ") : "()";
274
                         String reason = (newBits.length > 4) ? mergeBits(newBits, 4, newBits.length - 1, " ") : "()";
274
                         reason = reason.substring(1, reason.length() - 1);
275
                         reason = reason.substring(1, reason.length() - 1);
275
 
276
 
276
-                        coreChannelHandler.onChannelPart(parser, channel, newChannelClient, reason);
277
+                        coreChannelHandler.onChannelPart(parser, date, channel, newChannelClient, reason);
277
                         removeChannelClient(channel, newBits[0]);
278
                         removeChannelClient(channel, newBits[0]);
278
                         return;
279
                         return;
279
                     } else if (newBits[2].equalsIgnoreCase("quit")) {
280
                     } else if (newBits[2].equalsIgnoreCase("quit")) {
281
                         String reason = (newBits.length > 4) ? mergeBits(newBits, 4, newBits.length - 1, " ") : "()";
282
                         String reason = (newBits.length > 4) ? mergeBits(newBits, 4, newBits.length - 1, " ") : "()";
282
                         reason = reason.substring(1, reason.length() - 1);
283
                         reason = reason.substring(1, reason.length() - 1);
283
 
284
 
284
-                        coreChannelHandler.onChannelQuit(parser, channel, newChannelClient, reason);
285
+                        coreChannelHandler.onChannelQuit(parser, date, channel, newChannelClient, reason);
285
                         removeChannelClient(channel, newBits[0]);
286
                         removeChannelClient(channel, newBits[0]);
286
                         return;
287
                         return;
287
                     } else if (newBits[2].equalsIgnoreCase("kicked")) {
288
                     } else if (newBits[2].equalsIgnoreCase("kicked")) {
289
                         String reason = (newBits.length > 7) ? mergeBits(newBits, 7, newBits.length - 1, " ") : "()";
290
                         String reason = (newBits.length > 7) ? mergeBits(newBits, 7, newBits.length - 1, " ") : "()";
290
                         reason = reason.substring(1, reason.length() - 1);
291
                         reason = reason.substring(1, reason.length() - 1);
291
 
292
 
292
-                        final IRCChannelClientInfo kickingChannelClient = (newBits.length > 6) ? getChannelClient(channel, newBits[6], joinNew) : null;
293
+                        final IRCChannelClientInfo kickingChannelClient = (newBits.length > 6) ? getChannelClient(channel, date, newBits[6], joinNew) : null;
293
 
294
 
294
-                        coreChannelHandler.onChannelKick(parser, channel, newChannelClient, kickingChannelClient, reason, "");
295
+                        coreChannelHandler.onChannelKick(parser, date, channel, newChannelClient, kickingChannelClient, reason, "");
295
                         removeChannelClient(channel, newBits[0]);
296
                         removeChannelClient(channel, newBits[0]);
296
                         return;
297
                         return;
297
                     } else if (newBits[2].equalsIgnoreCase("now")) {
298
                     } else if (newBits[2].equalsIgnoreCase("now")) {
299
                         if (newBits.length > 3) {
300
                         if (newBits.length > 3) {
300
                             renameChannelClient(newChannelClient, newBits[3]);
301
                             renameChannelClient(newChannelClient, newBits[3]);
301
 
302
 
302
-                            coreChannelHandler.onChannelNickChanged(parser, channel, newChannelClient, newBits[0]);
303
+                            coreChannelHandler.onChannelNickChanged(parser, date, channel, newChannelClient, newBits[0]);
303
                             return;
304
                             return;
304
                         }
305
                         }
305
                     }
306
                     }
308
                 // Channel Action
309
                 // Channel Action
309
                 final String[] newBits = bits[1].split(" ", 2);
310
                 final String[] newBits = bits[1].split(" ", 2);
310
 
311
 
311
-                final IRCChannelClientInfo newChannelClient = getChannelClient(channel, newBits[0], joinNew);
312
+                final IRCChannelClientInfo newChannelClient = getChannelClient(channel, date, newBits[0], joinNew);
312
 
313
 
313
-                coreChannelHandler.onChannelAction(parser, channel, newChannelClient, newBits[1], "");
314
+                coreChannelHandler.onChannelAction(parser, date, channel, newChannelClient, newBits[1], "");
314
                 return;
315
                 return;
315
             }
316
             }
316
         }
317
         }
317
 
318
 
318
         // Pass it on unchanged.
319
         // Pass it on unchanged.
319
-        coreChannelHandler.onChannelMessage(parser, channel, channelClient, message, host);
320
+        coreChannelHandler.onChannelMessage(parser, date, channel, channelClient, message, host);
320
     }
321
     }
321
 
322
 
322
     /**
323
     /**
344
      * This will cause all remote clients to vanish from the nicklist.
345
      * This will cause all remote clients to vanish from the nicklist.
345
      */
346
      */
346
     public void updateNames() {
347
     public void updateNames() {
347
-        coreChannelHandler.onChannelGotNames(myChannel.getServer().getParser(), myChannel.getChannelInfo());
348
+        coreChannelHandler.onChannelGotNames(myChannel.getServer().getParser(), new Date(), myChannel.getChannelInfo());
348
     }
349
     }
349
 }
350
 }

Loading…
Cancel
Save