瀏覽代碼

Use GroupChatUser some more.

pull/289/head
Greg Holmes 9 年之前
父節點
當前提交
d88a183d9c

+ 13
- 9
src/com/dmdirc/Channel.java 查看文件

292
         setIcon("channel-inactive");
292
         setIcon("channel-inactive");
293
 
293
 
294
         getEventBus().publishAsync(new NickListClientsChangedEvent(this,
294
         getEventBus().publishAsync(new NickListClientsChangedEvent(this,
295
-                Collections.<ChannelClientInfo>emptyList()));
295
+                Collections.<GroupChatUser>emptyList()));
296
     }
296
     }
297
 
297
 
298
     @Override
298
     @Override
332
      *
332
      *
333
      * @param client The client to be added
333
      * @param client The client to be added
334
      */
334
      */
335
-    public void addClient(final ChannelClientInfo client) {
335
+    public void addClient(final GroupChatUser client) {
336
         getEventBus().publishAsync(new NickListClientAddedEvent(this, client));
336
         getEventBus().publishAsync(new NickListClientAddedEvent(this, client));
337
 
337
 
338
-        getTabCompleter().addEntry(TabCompletionType.CHANNEL_NICK,
339
-                client.getClient().getNickname());
338
+        getTabCompleter().addEntry(TabCompletionType.CHANNEL_NICK, client.getNickname());
340
     }
339
     }
341
 
340
 
342
     /**
341
     /**
344
      *
343
      *
345
      * @param client The client to be removed
344
      * @param client The client to be removed
346
      */
345
      */
347
-    public void removeClient(final ChannelClientInfo client) {
346
+    public void removeClient(final GroupChatUser client) {
348
         getEventBus().publishAsync(new NickListClientRemovedEvent(this, client));
347
         getEventBus().publishAsync(new NickListClientRemovedEvent(this, client));
349
 
348
 
350
         getTabCompleter().removeEntry(TabCompletionType.CHANNEL_NICK,
349
         getTabCompleter().removeEntry(TabCompletionType.CHANNEL_NICK,
351
-                client.getClient().getNickname());
350
+                client.getNickname());
352
 
351
 
353
-        if (client.getClient().equals(server.getParser().get().getLocalClient())) {
352
+        if (client.getUser().equals(server.getLocalUser())) {
354
             resetWindow();
353
             resetWindow();
355
         }
354
         }
356
     }
355
     }
360
      *
359
      *
361
      * @param clients The list of clients to use
360
      * @param clients The list of clients to use
362
      */
361
      */
363
-    public void setClients(final Collection<ChannelClientInfo> clients) {
362
+    public void setClients(final Collection<GroupChatUser> clients) {
364
         getEventBus().publishAsync(new NickListClientsChangedEvent(this, clients));
363
         getEventBus().publishAsync(new NickListClientsChangedEvent(this, clients));
365
 
364
 
366
         getTabCompleter().clear(TabCompletionType.CHANNEL_NICK);
365
         getTabCompleter().clear(TabCompletionType.CHANNEL_NICK);
367
 
366
 
368
         getTabCompleter().addEntries(TabCompletionType.CHANNEL_NICK,
367
         getTabCompleter().addEntries(TabCompletionType.CHANNEL_NICK,
369
-            clients.stream().map(c -> c.getClient().getNickname()).collect(Collectors.toList()));
368
+            clients.stream().map(GroupChatUser::getNickname).collect(Collectors.toList()));
370
     }
369
     }
371
 
370
 
372
     /**
371
     /**
549
         return groupChatUserFactory.getGroupChatUser(user, this);
548
         return groupChatUserFactory.getGroupChatUser(user, this);
550
     }
549
     }
551
 
550
 
551
+    public Collection<GroupChatUser> getUsers() {
552
+        return channelInfo.getChannelClients().stream().map(this::getUserFromClient)
553
+                .collect(Collectors.toList());
554
+    }
555
+
552
 }
556
 }

+ 11
- 8
src/com/dmdirc/ChannelEventHandler.java 查看文件

76
 
76
 
77
 import java.util.Date;
77
 import java.util.Date;
78
 import java.util.Optional;
78
 import java.util.Optional;
79
+import java.util.stream.Collectors;
79
 
80
 
80
 import javax.annotation.Nonnull;
81
 import javax.annotation.Nonnull;
81
 
82
 
148
     public void onChannelGotNames(final Parser parser, final Date date, final ChannelInfo channel) {
149
     public void onChannelGotNames(final Parser parser, final Date date, final ChannelInfo channel) {
149
         checkParser(parser);
150
         checkParser(parser);
150
 
151
 
151
-        owner.setClients(channel.getChannelClients());
152
+        owner.setClients(channel.getChannelClients().stream()
153
+                .map(owner::getUserFromClient)
154
+                .collect(Collectors.toList()));
152
         eventBus.publishAsync(new ChannelGotnamesEvent(owner));
155
         eventBus.publishAsync(new ChannelGotnamesEvent(owner));
153
     }
156
     }
154
 
157
 
192
         final Optional<Topic> currentTopic = owner.getCurrentTopic();
195
         final Optional<Topic> currentTopic = owner.getCurrentTopic();
193
         final boolean hasNewTopic = !Strings.isNullOrEmpty(channel.getTopic());
196
         final boolean hasNewTopic = !Strings.isNullOrEmpty(channel.getTopic());
194
         if (!isJoinTopic
197
         if (!isJoinTopic
195
-                || (!currentTopic.isPresent() && hasNewTopic)
196
-                || (currentTopic.isPresent() && !channel.getTopic().equals(
197
-                        owner.getCurrentTopic().get().getTopic()))) {
198
+                || !currentTopic.isPresent() && hasNewTopic
199
+                || currentTopic.isPresent() && !channel.getTopic().equals(
200
+                        owner.getCurrentTopic().get().getTopic())) {
198
             // Only add the topic if:
201
             // Only add the topic if:
199
             //  - It's being set while we're in the channel (rather than discovered on join), or
202
             //  - It's being set while we're in the channel (rather than discovered on join), or
200
             //  - We think the current topic is empty and are discovering a new one, or
203
             //  - We think the current topic is empty and are discovering a new one, or
211
         final ChannelJoinEvent event = new ChannelJoinEvent(owner, client);
214
         final ChannelJoinEvent event = new ChannelJoinEvent(owner, client);
212
         final String format = EventUtils.postDisplayable(eventBus, event, "channelJoin");
215
         final String format = EventUtils.postDisplayable(eventBus, event, "channelJoin");
213
         owner.doNotification(date, format, client);
216
         owner.doNotification(date, format, client);
214
-        owner.addClient(client);
217
+        owner.addClient(owner.getUserFromClient(client));
215
     }
218
     }
216
 
219
 
217
     @Override
220
     @Override
225
                 + (isMyself(client) ? "Self" : "") + "Part"
228
                 + (isMyself(client) ? "Self" : "") + "Part"
226
                 + (reason.isEmpty() ? "" : "Reason"));
229
                 + (reason.isEmpty() ? "" : "Reason"));
227
         owner.doNotification(date, format, client, reason);
230
         owner.doNotification(date, format, client, reason);
228
-        owner.removeClient(client);
231
+        owner.removeClient(owner.getUserFromClient(client));
229
     }
232
     }
230
 
233
 
231
     @Override
234
     @Override
238
         final String format = EventUtils.postDisplayable(eventBus, event,
241
         final String format = EventUtils.postDisplayable(eventBus, event,
239
                 "channelKick" + (reason.isEmpty() ? "" : "Reason"));
242
                 "channelKick" + (reason.isEmpty() ? "" : "Reason"));
240
         owner.doNotification(date, format, client, kickedClient, reason);
243
         owner.doNotification(date, format, client, kickedClient, reason);
241
-        owner.removeClient(kickedClient);
244
+        owner.removeClient(owner.getUserFromClient(kickedClient));
242
     }
245
     }
243
 
246
 
244
     @Override
247
     @Override
250
         final String format = EventUtils.postDisplayable(eventBus, event,
253
         final String format = EventUtils.postDisplayable(eventBus, event,
251
                 "channelQuit" + (reason.isEmpty() ? "" : "Reason"));
254
                 "channelQuit" + (reason.isEmpty() ? "" : "Reason"));
252
         owner.doNotification(date, format, client, reason);
255
         owner.doNotification(date, format, client, reason);
253
-        owner.removeClient(client);
256
+        owner.removeClient(owner.getUserFromClient(client));
254
     }
257
     }
255
 
258
 
256
     @Override
259
     @Override

+ 5
- 5
src/com/dmdirc/events/NickListClientAddedEvent.java 查看文件

23
 package com.dmdirc.events;
23
 package com.dmdirc.events;
24
 
24
 
25
 import com.dmdirc.Channel;
25
 import com.dmdirc.Channel;
26
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.interfaces.GroupChatUser;
27
 
27
 
28
 /**
28
 /**
29
  * Fired when a user is added to the list of users.
29
  * Fired when a user is added to the list of users.
30
  */
30
  */
31
 public class NickListClientAddedEvent extends NickListEvent {
31
 public class NickListClientAddedEvent extends NickListEvent {
32
 
32
 
33
-    private final ChannelClientInfo user;
33
+    private final GroupChatUser user;
34
 
34
 
35
     public NickListClientAddedEvent(final long timestamp, final Channel channel,
35
     public NickListClientAddedEvent(final long timestamp, final Channel channel,
36
-            final ChannelClientInfo user) {
36
+            final GroupChatUser user) {
37
         super(timestamp, channel);
37
         super(timestamp, channel);
38
         this.user = user;
38
         this.user = user;
39
     }
39
     }
40
 
40
 
41
-    public NickListClientAddedEvent(final Channel channel, final ChannelClientInfo user) {
41
+    public NickListClientAddedEvent(final Channel channel, final GroupChatUser user) {
42
         super(channel);
42
         super(channel);
43
         this.user = user;
43
         this.user = user;
44
     }
44
     }
45
 
45
 
46
-    public ChannelClientInfo getUser() {
46
+    public GroupChatUser getUser() {
47
         return user;
47
         return user;
48
     }
48
     }
49
 }
49
 }

+ 5
- 5
src/com/dmdirc/events/NickListClientRemovedEvent.java 查看文件

23
 package com.dmdirc.events;
23
 package com.dmdirc.events;
24
 
24
 
25
 import com.dmdirc.Channel;
25
 import com.dmdirc.Channel;
26
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.interfaces.GroupChatUser;
27
 
27
 
28
 /**
28
 /**
29
  * Fired when a user is removed from the list of users.
29
  * Fired when a user is removed from the list of users.
30
  */
30
  */
31
 public class NickListClientRemovedEvent extends NickListEvent {
31
 public class NickListClientRemovedEvent extends NickListEvent {
32
 
32
 
33
-    private final ChannelClientInfo user;
33
+    private final GroupChatUser user;
34
 
34
 
35
     public NickListClientRemovedEvent(final long timestamp, final Channel channel,
35
     public NickListClientRemovedEvent(final long timestamp, final Channel channel,
36
-            final ChannelClientInfo user) {
36
+            final GroupChatUser user) {
37
         super(timestamp, channel);
37
         super(timestamp, channel);
38
         this.user = user;
38
         this.user = user;
39
     }
39
     }
40
 
40
 
41
-    public NickListClientRemovedEvent(final Channel channel, final ChannelClientInfo user) {
41
+    public NickListClientRemovedEvent(final Channel channel, final GroupChatUser user) {
42
         super(channel);
42
         super(channel);
43
         this.user = user;
43
         this.user = user;
44
     }
44
     }
45
 
45
 
46
-    public ChannelClientInfo getUser() {
46
+    public GroupChatUser getUser() {
47
         return user;
47
         return user;
48
     }
48
     }
49
 }
49
 }

+ 5
- 5
src/com/dmdirc/events/NickListClientsChangedEvent.java 查看文件

23
 package com.dmdirc.events;
23
 package com.dmdirc.events;
24
 
24
 
25
 import com.dmdirc.Channel;
25
 import com.dmdirc.Channel;
26
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.interfaces.GroupChatUser;
27
 
27
 
28
 import com.google.common.collect.Lists;
28
 import com.google.common.collect.Lists;
29
 
29
 
35
  */
35
  */
36
 public class NickListClientsChangedEvent extends NickListEvent {
36
 public class NickListClientsChangedEvent extends NickListEvent {
37
 
37
 
38
-    private final Collection<ChannelClientInfo> users;
38
+    private final Collection<GroupChatUser> users;
39
 
39
 
40
     public NickListClientsChangedEvent(final long timestamp, final Channel channel,
40
     public NickListClientsChangedEvent(final long timestamp, final Channel channel,
41
-            final Iterable<ChannelClientInfo> users) {
41
+            final Iterable<GroupChatUser> users) {
42
         super(timestamp, channel);
42
         super(timestamp, channel);
43
         this.users = Lists.newArrayList(users);
43
         this.users = Lists.newArrayList(users);
44
     }
44
     }
45
 
45
 
46
     public NickListClientsChangedEvent(final Channel channel,
46
     public NickListClientsChangedEvent(final Channel channel,
47
-            final Iterable<ChannelClientInfo> users) {
47
+            final Iterable<GroupChatUser> users) {
48
         super(channel);
48
         super(channel);
49
         this.users = Lists.newArrayList(users);
49
         this.users = Lists.newArrayList(users);
50
     }
50
     }
51
 
51
 
52
-    public Collection<ChannelClientInfo> getUsers() {
52
+    public Collection<GroupChatUser> getUsers() {
53
         return Collections.unmodifiableCollection(users);
53
         return Collections.unmodifiableCollection(users);
54
     }
54
     }
55
 }
55
 }

Loading…
取消
儲存