Kaynağa Gözat

Send a Topic discovery if we get an end of names before we get a topic. Fixes issue 3095

tags/0.6.3
Shane Mc Cormack 14 yıl önce
ebeveyn
işleme
d000e2734c

+ 19
- 0
src/com/dmdirc/parser/irc/IRCChannelInfo.java Dosyayı Görüntüle

@@ -60,6 +60,8 @@ public class IRCChannelInfo implements ChannelInfo {
60 60
     private String sTopicUser = "";
61 61
     /** Unixtimestamp representing time when the topic was set. */
62 62
     private long nTopicTime = 0;
63
+    /** Has this channel ever had a topic? */
64
+    private boolean hadTopic = false;
63 65
     
64 66
     /** Known boolean-modes for channel. */
65 67
     private long nModes;
@@ -191,7 +193,24 @@ public class IRCChannelInfo implements ChannelInfo {
191 193
             }
192 194
         }
193 195
     }
196
+
194 197
     
198
+    /**
199
+     * Has this channel ever had a topic? (even an empty one!)
200
+     * 
201
+     * @return True if a topic has ever been known for this channel.
202
+     */
203
+    public synchronized boolean hadTopic() {
204
+        return hadTopic;
205
+    }
206
+
207
+    /**
208
+     * Change the value of hadTopic to true.
209
+     */
210
+    public synchronized void setHadTopic() {
211
+        this.hadTopic = true;
212
+    }
213
+
195 214
     /**
196 215
      * Have we ever asked the server for this channels listmodes?
197 216
      *

+ 18
- 0
src/com/dmdirc/parser/irc/ProcessNames.java Dosyayı Görüntüle

@@ -24,6 +24,7 @@ package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.parser.interfaces.ChannelInfo;
26 26
 import com.dmdirc.parser.interfaces.callbacks.ChannelNamesListener;
27
+import com.dmdirc.parser.interfaces.callbacks.ChannelTopicListener;
27 28
 
28 29
 /**
29 30
  * Process a Names reply.
@@ -43,6 +44,10 @@ public class ProcessNames extends IRCProcessor {
43 44
             iChannel = getChannel(token[3]);
44 45
             if (iChannel == null) { return; }
45 46
             
47
+            if (!iChannel.hadTopic()) {
48
+                callChannelTopic(iChannel, true);
49
+            }
50
+
46 51
             iChannel.setAddingNames(false);
47 52
             callChannelGotNames(iChannel);
48 53
             
@@ -102,6 +107,19 @@ public class ProcessNames extends IRCProcessor {
102 107
         }
103 108
     }
104 109
     
110
+    /**
111
+     * Callback to all objects implementing the ChannelTopic Callback.
112
+     *
113
+     * @see IChannelTopic
114
+     * @param cChannel Channel that topic was set on
115
+     * @param bIsJoinTopic True when getting topic on join, false if set by user/server
116
+     * @return true if a method was called, false otherwise
117
+     */
118
+    protected boolean callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
119
+        ((IRCChannelInfo)cChannel).setHadTopic();
120
+        return getCallbackManager().getCallbackType(ChannelTopicListener.class).call(cChannel, bIsJoinTopic);
121
+    }
122
+
105 123
     /**
106 124
      * Callback to all objects implementing the ChannelGotNames Callback.
107 125
      *

+ 1
- 0
src/com/dmdirc/parser/irc/ProcessTopic.java Dosyayı Görüntüle

@@ -78,6 +78,7 @@ public class ProcessTopic extends IRCProcessor {
78 78
      * @return true if a method was called, false otherwise
79 79
      */
80 80
     protected boolean callChannelTopic(final ChannelInfo cChannel, final boolean bIsJoinTopic) {
81
+        ((IRCChannelInfo)cChannel).setHadTopic();
81 82
         return getCallbackManager().getCallbackType(ChannelTopicListener.class).call(cChannel, bIsJoinTopic);
82 83
     }
83 84
     

Loading…
İptal
Kaydet