Browse Source

Add timestamps to some events that should have them. Fixes DMDirc/DMDirc#795

pull/148/head
Shane Mc Cormack 7 years ago
parent
commit
4f3e74dbff

+ 12
- 8
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessJoin.java View File

@@ -36,6 +36,7 @@ import com.dmdirc.parser.irc.IRCParser;
36 36
 import com.dmdirc.parser.irc.ModeManager;
37 37
 import com.dmdirc.parser.irc.PrefixModeManager;
38 38
 import com.dmdirc.parser.irc.ProcessorNotFoundException;
39
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
39 40
 import com.dmdirc.parser.irc.events.IRCDataOutEvent;
40 41
 import net.engio.mbassy.listener.Handler;
41 42
 
@@ -50,7 +51,7 @@ import javax.inject.Named;
50 51
 /**
51 52
  * Process a channel join.
52 53
  */
53
-public class ProcessJoin extends IRCProcessor {
54
+public class ProcessJoin extends TimestampedIRCProcessor {
54 55
 
55 56
     /** The manager to use to access prefix modes. */
56 57
     private final PrefixModeManager prefixModeManager;
@@ -84,11 +85,12 @@ public class ProcessJoin extends IRCProcessor {
84 85
     /**
85 86
      * Process a channel join.
86 87
      *
88
+     * @param date The LocalDateTime that this event occurred at.
87 89
      * @param sParam Type of line to process ("JOIN")
88 90
      * @param token IRCTokenised line to process
89 91
      */
90 92
     @Override
91
-    public void process(final String sParam, final String... token) {
93
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
92 94
         callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: %s | %s", sParam, Arrays.toString(token));
93 95
 
94 96
         if ("329".equals(sParam)) {
@@ -162,7 +164,7 @@ public class ProcessJoin extends IRCProcessor {
162 164
                     // joined.
163 165
                     callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Adding client to channel.");
164 166
                     final IRCChannelClientInfo iChannelClient = iChannel.addClient(iClient);
165
-                    callChannelJoin(iChannel, iChannelClient);
167
+                    callChannelJoin(date, iChannel, iChannelClient);
166 168
                     callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Added client to channel.");
167 169
                     return;
168 170
                 } else {
@@ -189,7 +191,7 @@ public class ProcessJoin extends IRCProcessor {
189 191
                 pendingJoins.clear();
190 192
             }
191 193
 
192
-            callChannelSelfJoin(iChannel);
194
+            callChannelSelfJoin(date, iChannel);
193 195
         } else {
194 196
             // Some kind of failed to join, pop the pending join queues.
195 197
             final PendingJoin pendingJoin = pendingJoins.poll();
@@ -239,23 +241,25 @@ public class ProcessJoin extends IRCProcessor {
239 241
     /**
240 242
      * Callback to all objects implementing the ChannelJoin Callback.
241 243
      *
244
+     * @param date The LocalDateTime that this event occurred at.
242 245
      * @param cChannel Channel Object
243 246
      * @param cChannelClient ChannelClient object for new person
244 247
      */
245
-    protected void callChannelJoin(final ChannelInfo cChannel,
248
+    protected void callChannelJoin(final LocalDateTime date, final ChannelInfo cChannel,
246 249
             final ChannelClientInfo cChannelClient) {
247 250
         getCallbackManager().publish(
248
-                new ChannelJoinEvent(parser, LocalDateTime.now(), cChannel, cChannelClient));
251
+                new ChannelJoinEvent(parser, date, cChannel, cChannelClient));
249 252
     }
250 253
 
251 254
     /**
252 255
      * Callback to all objects implementing the ChannelSelfJoin Callback.
253 256
      *
257
+     * @param date The LocalDateTime that this event occurred at.
254 258
      * @param cChannel Channel Object
255 259
      */
256
-    protected void callChannelSelfJoin(final ChannelInfo cChannel) {
260
+    protected void callChannelSelfJoin(final LocalDateTime date, final ChannelInfo cChannel) {
257 261
         getCallbackManager().publish(new ChannelSelfJoinEvent(
258
-                parser, LocalDateTime.now(), cChannel));
262
+                parser, date, cChannel));
259 263
     }
260 264
 
261 265
 

+ 9
- 6
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessKick.java View File

@@ -30,6 +30,7 @@ import com.dmdirc.parser.irc.IRCChannelClientInfo;
30 30
 import com.dmdirc.parser.irc.IRCChannelInfo;
31 31
 import com.dmdirc.parser.irc.IRCClientInfo;
32 32
 import com.dmdirc.parser.irc.IRCParser;
33
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
33 34
 
34 35
 import java.time.LocalDateTime;
35 36
 import java.util.Arrays;
@@ -39,7 +40,7 @@ import javax.inject.Inject;
39 40
 /**
40 41
  * Process a channel kick.
41 42
  */
42
-public class ProcessKick extends IRCProcessor {
43
+public class ProcessKick extends TimestampedIRCProcessor {
43 44
 
44 45
     /**
45 46
      * Create a new instance of the IRCProcessor Object.
@@ -54,11 +55,12 @@ public class ProcessKick extends IRCProcessor {
54 55
     /**
55 56
      * Process a channel kick.
56 57
      *
58
+     * @param date The LocalDateTime that this event occurred at.
57 59
      * @param sParam Type of line to process ("KICK")
58 60
      * @param token IRCTokenised line to process
59 61
      */
60 62
     @Override
61
-    public void process(final String sParam, final String... token) {
63
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
62 64
         callDebugInfo(IRCParser.DEBUG_INFO, "processKick: %s | %s", sParam, Arrays.toString(token));
63 65
 
64 66
         final IRCClientInfo iClient = getClientInfo(token[3]);
@@ -93,14 +95,14 @@ public class ProcessKick extends IRCProcessor {
93 95
             final IRCChannelClientInfo iChannelKicker = iChannel.getChannelClient(token[0], true);
94 96
             if (parser.getRemoveAfterCallback()) {
95 97
                 callDebugInfo(IRCParser.DEBUG_INFO, "processKick: calling kick before. {%s | %s | %s | %s | %s}", iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
96
-                callChannelKick(iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
98
+                callChannelKick(date, iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
97 99
             }
98 100
             callDebugInfo(IRCParser.DEBUG_INFO, "processKick: removing client from channel { %s | %s }", iChannel, iClient);
99 101
             iChannel.delClient(iClient);
100 102
             callDebugInfo(IRCParser.DEBUG_INFO, "processKick: removed client from channel { %s | %s }", iChannel, iClient);
101 103
             if (!parser.getRemoveAfterCallback()) {
102 104
                 callDebugInfo(IRCParser.DEBUG_INFO, "processKick: calling kick after. {%s | %s | %s | %s | %s}", iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
103
-                callChannelKick(iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
105
+                callChannelKick(date, iChannel, iChannelClient, iChannelKicker, sReason, token[0]);
104 106
             }
105 107
             if (iClient == parser.getLocalClient()) {
106 108
                 iChannel.emptyChannel();
@@ -112,17 +114,18 @@ public class ProcessKick extends IRCProcessor {
112 114
     /**
113 115
      * Callback to all objects implementing the ChannelKick Callback.
114 116
      *
117
+     * @param date The LocalDateTime that this event occurred at.
115 118
      * @param cChannel Channel where the kick took place
116 119
      * @param cKickedClient ChannelClient that got kicked
117 120
      * @param cKickedByClient ChannelClient that did the kicking
118 121
      * @param sReason Reason for kick (may be "")
119 122
      * @param sKickedByHost Hostname of Kicker (or servername)
120 123
      */
121
-    protected void callChannelKick(final ChannelInfo cChannel,
124
+    protected void callChannelKick(final LocalDateTime date, final ChannelInfo cChannel,
122 125
             final ChannelClientInfo cKickedClient, final ChannelClientInfo cKickedByClient,
123 126
             final String sReason, final String sKickedByHost) {
124 127
         getCallbackManager().publish(
125
-                new ChannelKickEvent(parser, LocalDateTime.now(), cChannel, cKickedClient,
128
+                new ChannelKickEvent(parser, date, cChannel, cKickedClient,
126 129
                         cKickedByClient, sReason, sKickedByHost));
127 130
     }
128 131
 

+ 9
- 6
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessListModes.java View File

@@ -29,6 +29,7 @@ import com.dmdirc.parser.irc.IRCChannelInfo;
29 29
 import com.dmdirc.parser.irc.IRCParser;
30 30
 import com.dmdirc.parser.irc.ServerType;
31 31
 import com.dmdirc.parser.irc.ServerTypeGroup;
32
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
32 33
 
33 34
 import java.time.LocalDateTime;
34 35
 import java.util.Arrays;
@@ -40,7 +41,7 @@ import javax.inject.Inject;
40 41
 /**
41 42
  * Process a List Modes.
42 43
  */
43
-public class ProcessListModes extends IRCProcessor {
44
+public class ProcessListModes extends TimestampedIRCProcessor {
44 45
 
45 46
     /**
46 47
      * Create a new instance of the IRCProcessor Object.
@@ -66,11 +67,12 @@ public class ProcessListModes extends IRCProcessor {
66 67
     /**
67 68
      * Process a ListModes.
68 69
      *
70
+     * @param date The LocalDateTime that this event occurred at.
69 71
      * @param sParam Type of line to process
70 72
      * @param token IRCTokenised line to process
71 73
      */
72 74
     @Override
73
-    public void process(final String sParam, final String... token) {
75
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
74 76
         final IRCChannelInfo channel = getChannel(token[3]);
75 77
         final ServerType serverType = parser.getServerType();
76 78
         if (channel == null) {
@@ -271,9 +273,9 @@ public class ProcessListModes extends IRCProcessor {
271 273
                             .stream()
272 274
                             .filter(thisMode -> parser.chanModesOther
273 275
                                     .get(thisMode) == IRCParser.MODE_LIST)
274
-                            .forEach(thisMode -> callChannelGotListModes(channel, thisMode));
276
+                            .forEach(thisMode -> callChannelGotListModes(date, channel, thisMode));
275 277
                 } else {
276
-                    callChannelGotListModes(channel, mode);
278
+                    callChannelGotListModes(date, channel, mode);
277 279
                 }
278 280
             }
279 281
         }
@@ -282,11 +284,12 @@ public class ProcessListModes extends IRCProcessor {
282 284
     /**
283 285
      * Callback to all objects implementing the ChannelGotListModes Callback.
284 286
      *
287
+     * @param date The LocalDateTime that this event occurred at.
285 288
      * @param cChannel Channel which the ListModes reply is for
286 289
      * @param mode the mode that we got list modes for.
287 290
      */
288
-    protected void callChannelGotListModes(final ChannelInfo cChannel, final char mode) {
289
-        getCallbackManager().publish(new ChannelListModeEvent(parser, LocalDateTime.now(), cChannel,
291
+    protected void callChannelGotListModes(final LocalDateTime date, final ChannelInfo cChannel, final char mode) {
292
+        getCallbackManager().publish(new ChannelListModeEvent(parser, date, cChannel,
290 293
                 mode));
291 294
     }
292 295
 }

+ 1
- 0
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMessage.java View File

@@ -90,6 +90,7 @@ public class ProcessMessage extends TimestampedIRCProcessor {
90 90
      * Actions are handled here aswell separately from CTCPs.<br>
91 91
      * Each type has 5 Calls, making 15 callbacks handled here.
92 92
      *
93
+     * @param date The LocalDateTime that this event occurred at.
93 94
      * @param sParam Type of line to process ("NOTICE", "PRIVMSG")
94 95
      * @param token IRCTokenised line to process
95 96
      */

+ 28
- 20
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMode.java View File

@@ -39,6 +39,7 @@ import com.dmdirc.parser.irc.IRCClientInfo;
39 39
 import com.dmdirc.parser.irc.IRCParser;
40 40
 import com.dmdirc.parser.irc.ModeManager;
41 41
 import com.dmdirc.parser.irc.PrefixModeManager;
42
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
42 43
 
43 44
 import java.time.LocalDateTime;
44 45
 import java.util.Calendar;
@@ -49,7 +50,7 @@ import javax.inject.Named;
49 50
 /**
50 51
  * Process a Mode line.
51 52
  */
52
-public class ProcessMode extends IRCProcessor {
53
+public class ProcessMode extends TimestampedIRCProcessor {
53 54
 
54 55
     /** The manager to use to access prefix modes. */
55 56
     private final PrefixModeManager prefixModeManager;
@@ -79,11 +80,12 @@ public class ProcessMode extends IRCProcessor {
79 80
     /**
80 81
      * Process a Mode Line.
81 82
      *
83
+     * @param date The LocalDateTime that this event occurred at.
82 84
      * @param sParam Type of line to process ("MODE", "324")
83 85
      * @param token IRCTokenised line to process
84 86
      */
85 87
     @Override
86
-    public void process(final String sParam, final String... token) {
88
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
87 89
         final String[] sModestr;
88 90
         final String sChannelName;
89 91
         switch (sParam) {
@@ -93,7 +95,7 @@ public class ProcessMode extends IRCProcessor {
93 95
                 System.arraycopy(token, 4, sModestr, 0, token.length - 4);
94 96
                 break;
95 97
             case "221":
96
-                processUserMode(sParam, token, new String[]{token[token.length - 1]}, true);
98
+                processUserMode(date, sParam, token, new String[]{token[token.length - 1]}, true);
97 99
                 return;
98 100
             default:
99 101
                 sChannelName = token[2];
@@ -103,9 +105,9 @@ public class ProcessMode extends IRCProcessor {
103 105
         }
104 106
 
105 107
         if (isValidChannelName(sChannelName)) {
106
-            processChanMode(sParam, token, sModestr, sChannelName);
108
+            processChanMode(date, sParam, token, sModestr, sChannelName);
107 109
         } else {
108
-            processUserMode(sParam, token, sModestr, false);
110
+            processUserMode(date, sParam, token, sModestr, false);
109 111
         }
110 112
     }
111 113
 
@@ -122,12 +124,13 @@ public class ProcessMode extends IRCProcessor {
122 124
     /**
123 125
      * Process Chan modes.
124 126
      *
127
+     * @param date The LocalDateTime that this event occurred at.
125 128
      * @param sParam String representation of parameter to parse
126 129
      * @param token IRCTokenised Array of the incomming line
127 130
      * @param sModestr The modes and params
128 131
      * @param sChannelName Channel these modes are for
129 132
      */
130
-    public void processChanMode(final String sParam, final String[] token, final String[] sModestr, final String sChannelName) {
133
+    public void processChanMode(final LocalDateTime date, final String sParam, final String[] token, final String[] sModestr, final String sChannelName) {
131 134
         final StringBuilder sFullModeStr = new StringBuilder();
132 135
 
133 136
         final IRCChannelInfo iChannel = getChannel(sChannelName);
@@ -197,7 +200,7 @@ public class ProcessMode extends IRCProcessor {
197 200
                     } else {
198 201
                         iChannelClientInfo.removeMode(cMode);
199 202
                     }
200
-                    callChannelUserModeChanged(iChannel, iChannelClientInfo, setterCCI, token[0],
203
+                    callChannelUserModeChanged(date, iChannel, iChannelClientInfo, setterCCI, token[0],
201 204
                             (bPositive ? "+" : "-") + cMode);
202 205
                     continue;
203 206
                 } else {
@@ -283,9 +286,9 @@ public class ProcessMode extends IRCProcessor {
283 286
 
284 287
         iChannel.setMode(nCurrent);
285 288
         if ("324".equals(sParam)) {
286
-            callChannelModeChanged(iChannel, setterCCI, "", sFullModeStr.toString().trim());
289
+            callChannelModeChanged(date, iChannel, setterCCI, "", sFullModeStr.toString().trim());
287 290
         } else {
288
-            callChannelModeChanged(iChannel, setterCCI, token[0], sFullModeStr.toString().trim());
291
+            callChannelModeChanged(date, iChannel, setterCCI, token[0], sFullModeStr.toString().trim());
289 292
             getCallbackManager().publish(
290 293
                     new ChannelNonUserModeChangeEvent(parser, LocalDateTime.now(), iChannel,
291 294
                             setterCCI, token[0],
@@ -296,11 +299,12 @@ public class ProcessMode extends IRCProcessor {
296 299
     /**
297 300
      * Process user modes.
298 301
      *
302
+     * @param date The LocalDateTime that this event occurred at.
299 303
      * @param sParam String representation of parameter to parse
300 304
      * @param token IRCTokenised Array of the incomming line
301 305
      * @param clearOldModes Clear old modes before applying these modes (used by 221)
302 306
      */
303
-    private void processUserMode(final String sParam, final String[] token, final String[] sModestr,
307
+    private void processUserMode(final LocalDateTime date, final String sParam, final String[] token, final String[] sModestr,
304 308
             final boolean clearOldModes) {
305 309
         final IRCClientInfo iClient = getClientInfo(token[2]);
306 310
 
@@ -340,66 +344,70 @@ public class ProcessMode extends IRCProcessor {
340 344
 
341 345
         iClient.setUserMode(nCurrent);
342 346
         if ("221".equals(sParam)) {
343
-            callUserModeDiscovered(iClient, sModestr[0]);
347
+            callUserModeDiscovered(date, iClient, sModestr[0]);
344 348
         } else {
345
-            callUserModeChanged(iClient, token[0], sModestr[0]);
349
+            callUserModeChanged(date, iClient, token[0], sModestr[0]);
346 350
         }
347 351
     }
348 352
 
349 353
     /**
350 354
      * Callback to all objects implementing the ChannelModeChanged Callback.
351 355
      *
356
+     * @param date The LocalDateTime that this event occurred at.
352 357
      * @param cChannel Channel where modes were changed
353 358
      * @param cChannelClient Client chaning the modes (null if server)
354 359
      * @param sHost Host doing the mode changing (User host or server name)
355 360
      * @param sModes Exact String parsed
356 361
      */
357
-    protected void callChannelModeChanged(final ChannelInfo cChannel,
362
+    protected void callChannelModeChanged(final LocalDateTime date, final ChannelInfo cChannel,
358 363
             final ChannelClientInfo cChannelClient, final String sHost, final String sModes) {
359 364
         getCallbackManager().publish(
360
-                new ChannelModeChangeEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
365
+                new ChannelModeChangeEvent(parser, date, cChannel, cChannelClient,
361 366
                         sHost, sModes));
362 367
     }
363 368
 
364 369
     /**
365 370
      * Callback to all objects implementing the ChannelUserModeChanged Callback.
366 371
      *
372
+     * @param date The LocalDateTime that this event occurred at.
367 373
      * @param cChannel Channel where modes were changed
368 374
      * @param cChangedClient Client being changed
369 375
      * @param cSetByClient Client chaning the modes (null if server)
370 376
      * @param sHost Host doing the mode changing (User host or server name)
371 377
      * @param sMode String representing mode change (ie +o)
372 378
      */
373
-    protected void callChannelUserModeChanged(final ChannelInfo cChannel,
379
+    protected void callChannelUserModeChanged(final LocalDateTime date, final ChannelInfo cChannel,
374 380
             final ChannelClientInfo cChangedClient, final ChannelClientInfo cSetByClient,
375 381
             final String sHost, final String sMode) {
376 382
         getCallbackManager().publish(
377
-                new ChannelUserModeChangeEvent(parser, LocalDateTime.now(), cChannel,
383
+                new ChannelUserModeChangeEvent(parser, date, cChannel,
378 384
                         cChangedClient, cSetByClient, sHost, sMode));
379 385
     }
380 386
 
381 387
     /**
382 388
      * Callback to all objects implementing the UserModeChanged Callback.
383 389
      *
390
+     * @param date The LocalDateTime that this event occurred at.
384 391
      * @param cClient Client that had the mode changed (almost always us)
385 392
      * @param sSetby Host that set the mode (us or servername)
386 393
      * @param sModes The modes set.
387 394
      */
388
-    protected void callUserModeChanged(final ClientInfo cClient, final String sSetby,
395
+    protected void callUserModeChanged(final LocalDateTime date, final ClientInfo cClient, final String sSetby,
389 396
             final String sModes) {
390 397
         getCallbackManager().publish(
391
-                new UserModeChangeEvent(parser, LocalDateTime.now(), cClient, sSetby, sModes));
398
+                new UserModeChangeEvent(parser, date, cClient, sSetby, sModes));
392 399
     }
393 400
 
394 401
     /**
395 402
      * Callback to all objects implementing the UserModeDiscovered Callback.
396 403
      *
404
+     * @param date The LocalDateTime that this event occurred at.
397 405
      * @param cClient Client that had the mode changed (almost always us)
398 406
      * @param sModes The modes set.
399 407
      */
400
-    protected void callUserModeDiscovered(final ClientInfo cClient, final String sModes) {
408
+    protected void callUserModeDiscovered(final LocalDateTime date, final ClientInfo cClient, final String sModes) {
401 409
         getCallbackManager().publish(
402
-                new UserModeDiscoveryEvent(parser, LocalDateTime.now(), cClient, sModes));
410
+                new UserModeDiscoveryEvent(parser, date, cClient, sModes));
403 411
     }
404 412
 
405 413
 }

+ 12
- 8
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessNick.java View File

@@ -32,6 +32,7 @@ import com.dmdirc.parser.irc.IRCChannelClientInfo;
32 32
 import com.dmdirc.parser.irc.IRCChannelInfo;
33 33
 import com.dmdirc.parser.irc.IRCClientInfo;
34 34
 import com.dmdirc.parser.irc.IRCParser;
35
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
35 36
 
36 37
 import java.time.LocalDateTime;
37 38
 
@@ -40,7 +41,7 @@ import javax.inject.Inject;
40 41
 /**
41 42
  * Process a Nick change.
42 43
  */
43
-public class ProcessNick extends IRCProcessor {
44
+public class ProcessNick extends TimestampedIRCProcessor {
44 45
 
45 46
     /**
46 47
      * Create a new instance of the IRCProcessor Object.
@@ -55,11 +56,12 @@ public class ProcessNick extends IRCProcessor {
55 56
     /**
56 57
      * Process a Nick change.
57 58
      *
59
+     * @param date The LocalDateTime that this event occurred at.
58 60
      * @param sParam Type of line to process ("NICK")
59 61
      * @param token IRCTokenised line to process
60 62
      */
61 63
     @Override
62
-    public void process(final String sParam, final String... token) {
64
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
63 65
 
64 66
         final IRCClientInfo iClient = getClientInfo(token[0]);
65 67
         if (iClient == null) {
@@ -92,36 +94,38 @@ public class ProcessNick extends IRCProcessor {
92 94
                     if (!isSameNick) {
93 95
                         iChannel.renameClient(oldNickname, iChannelClient);
94 96
                     }
95
-                    callChannelNickChanged(iChannel, iChannelClient, IRCClientInfo.parseHost(token[0]));
97
+                    callChannelNickChanged(date, iChannel, iChannelClient, IRCClientInfo.parseHost(token[0]));
96 98
                 }
97 99
             }
98 100
 
99
-            callNickChanged(iClient, IRCClientInfo.parseHost(token[0]));
101
+            callNickChanged(date, iClient, IRCClientInfo.parseHost(token[0]));
100 102
         }
101 103
     }
102 104
 
103 105
     /**
104 106
      * Callback to all objects implementing the ChannelNickChanged Callback.
105 107
      *
108
+     * @param date The LocalDateTime that this event occurred at.
106 109
      * @param cChannel One of the channels that the user is on
107 110
      * @param cChannelClient Client changing nickname
108 111
      * @param sOldNick Nickname before change
109 112
      */
110
-    protected void callChannelNickChanged(final ChannelInfo cChannel,
113
+    protected void callChannelNickChanged(final LocalDateTime date, final ChannelInfo cChannel,
111 114
             final ChannelClientInfo cChannelClient, final String sOldNick) {
112 115
         getCallbackManager().publish(
113
-                new ChannelNickChangeEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
116
+                new ChannelNickChangeEvent(parser, date, cChannel, cChannelClient,
114 117
                         sOldNick));
115 118
     }
116 119
 
117 120
     /**
118 121
      * Callback to all objects implementing the NickChanged Callback.
119 122
      *
123
+     * @param date The LocalDateTime that this event occurred at.
120 124
      * @param cClient Client changing nickname
121 125
      * @param sOldNick Nickname before change
122 126
      */
123
-    protected void callNickChanged(final ClientInfo cClient, final String sOldNick) {
124
-        getCallbackManager().publish(new NickChangeEvent(parser, LocalDateTime.now(), cClient,
127
+    protected void callNickChanged(final LocalDateTime date, final ClientInfo cClient, final String sOldNick) {
128
+        getCallbackManager().publish(new NickChangeEvent(parser, date, cClient,
125 129
                 sOldNick));
126 130
     }
127 131
 

+ 9
- 6
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessPart.java View File

@@ -30,6 +30,7 @@ import com.dmdirc.parser.irc.IRCChannelClientInfo;
30 30
 import com.dmdirc.parser.irc.IRCChannelInfo;
31 31
 import com.dmdirc.parser.irc.IRCClientInfo;
32 32
 import com.dmdirc.parser.irc.IRCParser;
33
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
33 34
 
34 35
 import java.time.LocalDateTime;
35 36
 
@@ -38,7 +39,7 @@ import javax.inject.Inject;
38 39
 /**
39 40
  * Process a channel part.
40 41
  */
41
-public class ProcessPart extends IRCProcessor {
42
+public class ProcessPart extends TimestampedIRCProcessor {
42 43
 
43 44
     /**
44 45
      * Create a new instance of the IRCProcessor Object.
@@ -53,11 +54,12 @@ public class ProcessPart extends IRCProcessor {
53 54
     /**
54 55
      * Process a channel part.
55 56
      *
57
+     * @param date The LocalDateTime that this event occurred at.
56 58
      * @param sParam Type of line to process ("PART")
57 59
      * @param token IRCTokenised line to process
58 60
      */
59 61
     @Override
60
-    public void process(final String sParam, final String... token) {
62
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
61 63
         // :nick!ident@host PART #Channel
62 64
         // :nick!ident@host PART #Channel :reason
63 65
         if (token.length < 3) {
@@ -91,12 +93,12 @@ public class ProcessPart extends IRCProcessor {
91 93
                 return;
92 94
             }
93 95
             if (parser.getRemoveAfterCallback()) {
94
-                callChannelPart(iChannel, iChannelClient, sReason);
96
+                callChannelPart(date, iChannel, iChannelClient, sReason);
95 97
             }
96 98
             callDebugInfo(IRCParser.DEBUG_INFO, "Removing %s from %s", iClient.getNickname(), iChannel.getName());
97 99
             iChannel.delClient(iClient);
98 100
             if (!parser.getRemoveAfterCallback()) {
99
-                callChannelPart(iChannel, iChannelClient, sReason);
101
+                callChannelPart(date, iChannel, iChannelClient, sReason);
100 102
             }
101 103
             if (iClient == parser.getLocalClient()) {
102 104
                 iChannel.emptyChannel();
@@ -108,14 +110,15 @@ public class ProcessPart extends IRCProcessor {
108 110
     /**
109 111
      * Callback to all objects implementing the ChannelPart Callback.
110 112
      *
113
+     * @param date The LocalDateTime that this event occurred at.
111 114
      * @param cChannel Channel that the user parted
112 115
      * @param cChannelClient Client that parted
113 116
      * @param sReason Reason given for parting (May be "")
114 117
      */
115
-    protected void callChannelPart(final ChannelInfo cChannel,
118
+    protected void callChannelPart(final LocalDateTime date, final ChannelInfo cChannel,
116 119
             final ChannelClientInfo cChannelClient, final String sReason) {
117 120
         getCallbackManager().publish(
118
-                new ChannelPartEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
121
+                new ChannelPartEvent(parser, date, cChannel, cChannelClient,
119 122
                         sReason));
120 123
     }
121 124
 

+ 13
- 9
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessQuit.java View File

@@ -31,6 +31,7 @@ import com.dmdirc.parser.irc.IRCChannelClientInfo;
31 31
 import com.dmdirc.parser.irc.IRCChannelInfo;
32 32
 import com.dmdirc.parser.irc.IRCClientInfo;
33 33
 import com.dmdirc.parser.irc.IRCParser;
34
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
34 35
 
35 36
 import java.time.LocalDateTime;
36 37
 import java.util.ArrayList;
@@ -40,7 +41,7 @@ import javax.inject.Inject;
40 41
 /**
41 42
  * Process a Quit message.
42 43
  */
43
-public class ProcessQuit extends IRCProcessor {
44
+public class ProcessQuit extends TimestampedIRCProcessor {
44 45
 
45 46
     /**
46 47
      * Create a new instance of the IRCProcessor Object.
@@ -55,11 +56,12 @@ public class ProcessQuit extends IRCProcessor {
55 56
     /**
56 57
      * Process a Quit message.
57 58
      *
59
+     * @param date The LocalDateTime that this event occurred at.
58 60
      * @param sParam Type of line to process ("QUIT")
59 61
      * @param token IRCTokenised line to process
60 62
      */
61 63
     @Override
62
-    public void process(final String sParam, final String... token) {
64
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
63 65
         // :nick!ident@host QUIT
64 66
         // :nick!ident@host QUIT :reason
65 67
         if (token.length < 2) {
@@ -85,7 +87,7 @@ public class ProcessQuit extends IRCProcessor {
85 87
             final IRCChannelClientInfo iChannelClient = iChannel.getChannelClient(iClient);
86 88
             if (iChannelClient != null) {
87 89
                 if (parser.getRemoveAfterCallback()) {
88
-                    callChannelQuit(iChannel, iChannelClient, sReason);
90
+                    callChannelQuit(date, iChannel, iChannelClient, sReason);
89 91
                 }
90 92
                 if (iClient == parser.getLocalClient()) {
91 93
                     iChannel.emptyChannel();
@@ -94,13 +96,13 @@ public class ProcessQuit extends IRCProcessor {
94 96
                     iChannel.delClient(iClient);
95 97
                 }
96 98
                 if (!parser.getRemoveAfterCallback()) {
97
-                    callChannelQuit(iChannel, iChannelClient, sReason);
99
+                    callChannelQuit(date, iChannel, iChannelClient, sReason);
98 100
                 }
99 101
             }
100 102
         }
101 103
 
102 104
         if (parser.getRemoveAfterCallback()) {
103
-            callQuit(iClient, sReason);
105
+            callQuit(date, iClient, sReason);
104 106
         }
105 107
         if (iClient == parser.getLocalClient()) {
106 108
             parser.clearClients();
@@ -108,18 +110,19 @@ public class ProcessQuit extends IRCProcessor {
108 110
             parser.removeClient(iClient);
109 111
         }
110 112
         if (!parser.getRemoveAfterCallback()) {
111
-            callQuit(iClient, sReason);
113
+            callQuit(date, iClient, sReason);
112 114
         }
113 115
     }
114 116
 
115 117
     /**
116 118
      * Callback to all objects implementing the ChannelQuit Callback.
117 119
      *
120
+     * @param date The LocalDateTime that this event occurred at.
118 121
      * @param cChannel Channel that user was on
119 122
      * @param cChannelClient User thats quitting
120 123
      * @param sReason Quit reason
121 124
      */
122
-    protected void callChannelQuit(final ChannelInfo cChannel,
125
+    protected void callChannelQuit(final LocalDateTime date, final ChannelInfo cChannel,
123 126
             final ChannelClientInfo cChannelClient, final String sReason) {
124 127
         getCallbackManager().publish(
125 128
                 new ChannelQuitEvent(parser, LocalDateTime.now(), cChannel, cChannelClient,
@@ -129,11 +132,12 @@ public class ProcessQuit extends IRCProcessor {
129 132
     /**
130 133
      * Callback to all objects implementing the Quit Callback.
131 134
      *
135
+     * @param date The LocalDateTime that this event occurred at.
132 136
      * @param cClient Client Quitting
133 137
      * @param sReason Reason for quitting (may be "")
134 138
      */
135
-    protected void callQuit(final ClientInfo cClient, final String sReason) {
136
-        getCallbackManager().publish(new QuitEvent(parser, LocalDateTime.now(), cClient, sReason));
139
+    protected void callQuit(final LocalDateTime date, final ClientInfo cClient, final String sReason) {
140
+        getCallbackManager().publish(new QuitEvent(parser, date, cClient, sReason));
137 141
     }
138 142
 
139 143
 }

+ 9
- 6
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessTopic.java View File

@@ -27,6 +27,7 @@ import com.dmdirc.parser.interfaces.ChannelInfo;
27 27
 import com.dmdirc.parser.irc.IRCChannelInfo;
28 28
 import com.dmdirc.parser.irc.IRCClientInfo;
29 29
 import com.dmdirc.parser.irc.IRCParser;
30
+import com.dmdirc.parser.irc.TimestampedIRCProcessor;
30 31
 
31 32
 import java.time.LocalDateTime;
32 33
 
@@ -35,7 +36,7 @@ import javax.inject.Inject;
35 36
 /**
36 37
  * Process a topic change.
37 38
  */
38
-public class ProcessTopic extends IRCProcessor {
39
+public class ProcessTopic extends TimestampedIRCProcessor {
39 40
 
40 41
     /**
41 42
      * Create a new instance of the IRCProcessor Object.
@@ -50,11 +51,12 @@ public class ProcessTopic extends IRCProcessor {
50 51
     /**
51 52
      * Process a topic change.
52 53
      *
54
+     * @param date The LocalDateTime that this event occurred at.
53 55
      * @param sParam Type of line to process ("TOPIC", "332", "333")
54 56
      * @param token IRCTokenised line to process
55 57
      */
56 58
     @Override
57
-    public void process(final String sParam, final String... token) {
59
+    public void process(final LocalDateTime date, final String sParam, final String... token) {
58 60
         final IRCChannelInfo iChannel;
59 61
         switch (sParam) {
60 62
             case "332":
@@ -75,7 +77,7 @@ public class ProcessTopic extends IRCProcessor {
75 77
                             iChannel.setTopicTime(Long.parseLong(token[5]));
76 78
                         }
77 79
                     }
78
-                    callChannelTopic(iChannel, true);
80
+                    callChannelTopic(date, iChannel, true);
79 81
                 }   break;
80 82
             default:
81 83
                 if (IRCParser.ALWAYS_UPDATECLIENT) {
@@ -91,7 +93,7 @@ public class ProcessTopic extends IRCProcessor {
91 93
                 iChannel.setTopicTime(System.currentTimeMillis() / 1000);
92 94
                 iChannel.setTopicUser(token[0].charAt(0) == ':' ? token[0].substring(1) : token[0]);
93 95
                 iChannel.setInternalTopic(token[token.length - 1]);
94
-                callChannelTopic(iChannel, false);
96
+                callChannelTopic(date, iChannel, false);
95 97
                 break;
96 98
         }
97 99
     }
@@ -99,13 +101,14 @@ public class ProcessTopic extends IRCProcessor {
99 101
     /**
100 102
      * Callback to all objects implementing the ChannelTopic Callback.
101 103
      *
104
+     * @param date The LocalDateTime that this event occurred at.
102 105
      * @param cChannel Channel that topic was set on
103 106
      * @param bIsJoinTopic True when getting topic on join, false if set by user/server
104 107
      */
105
-    protected void callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
108
+    protected void callChannelTopic(final LocalDateTime date, final ChannelInfo cChannel, final boolean bIsJoinTopic) {
106 109
         ((IRCChannelInfo) cChannel).setHadTopic();
107 110
         getCallbackManager().publish(
108
-                new ChannelTopicEvent(parser, LocalDateTime.now(), cChannel, bIsJoinTopic));
111
+                new ChannelTopicEvent(parser, date, cChannel, bIsJoinTopic));
109 112
     }
110 113
 
111 114
 }

Loading…
Cancel
Save