|
@@ -28,6 +28,7 @@ import com.dmdirc.commandparser.CommandManager;
|
28
|
28
|
import com.dmdirc.commandparser.CommandType;
|
29
|
29
|
import com.dmdirc.config.ConfigManager;
|
30
|
30
|
import com.dmdirc.interfaces.ConfigChangeListener;
|
|
31
|
+import com.dmdirc.interfaces.TopicChangeListener;
|
31
|
32
|
import com.dmdirc.parser.interfaces.ChannelClientInfo;
|
32
|
33
|
import com.dmdirc.parser.interfaces.ChannelInfo;
|
33
|
34
|
import com.dmdirc.parser.interfaces.ClientInfo;
|
|
@@ -461,39 +462,6 @@ public class Channel extends MessageTarget implements ConfigChangeListener,
|
461
|
462
|
}
|
462
|
463
|
}
|
463
|
464
|
|
464
|
|
- /**
|
465
|
|
- * Adds the specified topic to this channel's topic list.
|
466
|
|
- *
|
467
|
|
- * @param topic The topic to be added.
|
468
|
|
- */
|
469
|
|
- public void addTopic(final Topic topic) {
|
470
|
|
- topics.add(topic);
|
471
|
|
- updateTitle();
|
472
|
|
- }
|
473
|
|
-
|
474
|
|
- /**
|
475
|
|
- * Retrieve the topics that have been seen on this channel.
|
476
|
|
- *
|
477
|
|
- * @return A list of topics that have been seen on this channel, including
|
478
|
|
- * the current one.
|
479
|
|
- */
|
480
|
|
- public List<Topic> getTopics() {
|
481
|
|
- return topics.getList();
|
482
|
|
- }
|
483
|
|
-
|
484
|
|
- /**
|
485
|
|
- * Returns the current topic for this channel.
|
486
|
|
- *
|
487
|
|
- * @return Current channel topic
|
488
|
|
- */
|
489
|
|
- public Topic getCurrentTopic() {
|
490
|
|
- if (channelInfo.getTopic().isEmpty()) {
|
491
|
|
- return null;
|
492
|
|
- }
|
493
|
|
- return new Topic(channelInfo.getTopic(), channelInfo.getTopicSetter(),
|
494
|
|
- channelInfo.getTopicTime());
|
495
|
|
- }
|
496
|
|
-
|
497
|
465
|
/** {@inheritDoc} */
|
498
|
466
|
@Override
|
499
|
467
|
public void configChanged(final String domain, final String key) {
|
|
@@ -592,6 +560,71 @@ public class Channel extends MessageTarget implements ConfigChangeListener,
|
592
|
560
|
messageArgs.add(channelInfo.getName());
|
593
|
561
|
}
|
594
|
562
|
|
|
563
|
+ // ---------------------------------------------------- TOPIC HANDLING -----
|
|
564
|
+
|
|
565
|
+ /**
|
|
566
|
+ * Adds the specified topic to this channel's topic list.
|
|
567
|
+ *
|
|
568
|
+ * @param topic The topic to be added.
|
|
569
|
+ */
|
|
570
|
+ public void addTopic(final Topic topic) {
|
|
571
|
+ topics.add(topic);
|
|
572
|
+ updateTitle();
|
|
573
|
+
|
|
574
|
+ synchronized (listeners) {
|
|
575
|
+ for (TopicChangeListener listener : listeners.get(TopicChangeListener.class)) {
|
|
576
|
+ listener.topicChanged(this, topic);
|
|
577
|
+ }
|
|
578
|
+ }
|
|
579
|
+ }
|
|
580
|
+
|
|
581
|
+ /**
|
|
582
|
+ * Retrieve the topics that have been seen on this channel.
|
|
583
|
+ *
|
|
584
|
+ * @return A list of topics that have been seen on this channel, including
|
|
585
|
+ * the current one.
|
|
586
|
+ */
|
|
587
|
+ public List<Topic> getTopics() {
|
|
588
|
+ return topics.getList();
|
|
589
|
+ }
|
|
590
|
+
|
|
591
|
+ /**
|
|
592
|
+ * Returns the current topic for this channel.
|
|
593
|
+ *
|
|
594
|
+ * @return Current channel topic
|
|
595
|
+ */
|
|
596
|
+ public Topic getCurrentTopic() {
|
|
597
|
+ if (channelInfo.getTopic().isEmpty()) {
|
|
598
|
+ return null;
|
|
599
|
+ }
|
|
600
|
+ return new Topic(channelInfo.getTopic(), channelInfo.getTopicSetter(),
|
|
601
|
+ channelInfo.getTopicTime());
|
|
602
|
+ }
|
|
603
|
+
|
|
604
|
+ /**
|
|
605
|
+ * Adds a new topic change listener to this channel.
|
|
606
|
+ *
|
|
607
|
+ * @param listener The listener to be added
|
|
608
|
+ * @since 0.6.3
|
|
609
|
+ */
|
|
610
|
+ public void addTopicChangeListener(final TopicChangeListener listener) {
|
|
611
|
+ synchronized (listeners) {
|
|
612
|
+ listeners.add(TopicChangeListener.class, listener);
|
|
613
|
+ }
|
|
614
|
+ }
|
|
615
|
+
|
|
616
|
+ /**
|
|
617
|
+ * Removes an existing topic change listener from this channel.
|
|
618
|
+ *
|
|
619
|
+ * @param listener The listener to be removed
|
|
620
|
+ * @since 0.6.3
|
|
621
|
+ */
|
|
622
|
+ public void removeTopicChangeListener(final TopicChangeListener listener) {
|
|
623
|
+ synchronized (listeners) {
|
|
624
|
+ listeners.remove(TopicChangeListener.class, listener);
|
|
625
|
+ }
|
|
626
|
+ }
|
|
627
|
+
|
595
|
628
|
// ------------------------------------------ PARSER METHOD DELEGATION -----
|
596
|
629
|
|
597
|
630
|
/**
|
|
@@ -603,4 +636,14 @@ public class Channel extends MessageTarget implements ConfigChangeListener,
|
603
|
636
|
public void setTopic(final String topic) {
|
604
|
637
|
channelInfo.setTopic(topic);
|
605
|
638
|
}
|
|
639
|
+
|
|
640
|
+ /**
|
|
641
|
+ * Retrieves the maximum length that a topic on this channel can be.
|
|
642
|
+ *
|
|
643
|
+ * @return The maximum length that this channel's topic may be
|
|
644
|
+ * @since 0.6.3
|
|
645
|
+ */
|
|
646
|
+ public int getMaxTopicLength() {
|
|
647
|
+ return server.getParser().getMaxTopicLength();
|
|
648
|
+ }
|
606
|
649
|
}
|