소스 검색

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

pull/148/head
Shane Mc Cormack 7 년 전
부모
커밋
4f3e74dbff

+ 12
- 8
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessJoin.java 파일 보기

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

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

+ 9
- 6
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessListModes.java 파일 보기

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

+ 1
- 0
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMessage.java 파일 보기

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

+ 28
- 20
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMode.java 파일 보기

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

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

+ 9
- 6
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessPart.java 파일 보기

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

+ 13
- 9
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessQuit.java 파일 보기

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

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