Explorar el Código

Fix testcase for updatetest

Configfile work
Added topic history to Channel

git-svn-id: http://svn.dmdirc.com/trunk@2531 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Chris Smith hace 16 años
padre
commit
0b8cfa76a2

+ 19
- 0
src/com/dmdirc/Channel.java Ver fichero

@@ -59,6 +59,7 @@ import com.dmdirc.ui.messages.Styliser;
59 59
 import java.awt.Color;
60 60
 import java.io.Serializable;
61 61
 import java.util.ArrayList;
62
+import java.util.List;
62 63
 import java.util.Map;
63 64
 
64 65
 /**
@@ -106,6 +107,10 @@ public final class Channel extends MessageTarget implements
106 107
     /** The config manager for this channel. */
107 108
     private final ConfigManager configManager;
108 109
     
110
+    // TODO: Make this some kind of fixed-length buffer
111
+    /** A list of previous topics we've seen. */
112
+    private final List<Topic> topics = new ArrayList<Topic>();
113
+    
109 114
     /** Whether we're in this channel or not. */
110 115
     private boolean onChannel;
111 116
     
@@ -475,6 +480,10 @@ public final class Channel extends MessageTarget implements
475 480
             
476 481
             addLine(buff, modes, parts[0], parts[1], parts[2], cChannel, topic);
477 482
         }
483
+        
484
+        topics.add(new Topic(cChannel.getTopic(), 
485
+                cChannel.getTopicUser(), cChannel.getTopicTime()));
486
+        
478 487
         updateTitle();
479 488
     }
480 489
     
@@ -750,6 +759,16 @@ public final class Channel extends MessageTarget implements
750 759
         return res;
751 760
     }
752 761
     
762
+    /**
763
+     * Retrieve the topics that have been seen on this channel.
764
+     * 
765
+     * @return A list of topics that have been seen on this channel, including
766
+     * the current one.
767
+     */
768
+    public List<Topic> getTopics() {
769
+        return new ArrayList<Topic>(topics);
770
+    }
771
+    
753 772
     /**
754 773
      * Returns this channel's name.
755 774
      * 

+ 54
- 0
src/com/dmdirc/Topic.java Ver fichero

@@ -0,0 +1,54 @@
1
+/*
2
+ * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc;
24
+
25
+/**
26
+ * Stores information about a channel topic.
27
+ * 
28
+ * @author chris
29
+ */
30
+public class Topic {
31
+    
32
+    private final String topic;
33
+    private final String client;
34
+    private final long time;
35
+
36
+    public Topic(String topic, String client, long time) {
37
+        this.topic = topic;
38
+        this.client = client;
39
+        this.time = time;
40
+    }
41
+
42
+    public String getClient() {
43
+        return client;
44
+    }
45
+
46
+    public long getTime() {
47
+        return time;
48
+    }
49
+
50
+    public String getTopic() {
51
+        return topic;
52
+    }
53
+    
54
+}

+ 22
- 12
src/com/dmdirc/util/ConfigFile.java Ver fichero

@@ -67,16 +67,13 @@ public class ConfigFile {
67 67
 
68 68
                 domains.add(domain);
69 69
 
70
-                keydomain = "meta".equals(domain) || keydomains.containsKey(domain);
70
+                keydomain = keydomains.containsKey(domain)
71
+                        || flatdomains.containsValue("keysections", domain);
71 72
             } else if (domain != null && keydomain && (offset = tline.indexOf('=')) != -1) {
72 73
                 final String key = tline.substring(0, offset);
73 74
                 final String value = tline.substring(offset + 1);
74 75
 
75
-                if ("meta".equals(domain) && value.equals("key")) {
76
-                    keydomains.put(domain, new HashMap<String, String>());
77
-                } else if (!"meta".equals(domain)) {
78
-                    keydomains.get(domain).put(key, value);
79
-                }
76
+                keydomains.get(domain).put(key, value);
80 77
             } else if (domain != null && !keydomain) {
81 78
                 flatdomains.add(domain, tline);
82 79
             }
@@ -92,7 +89,7 @@ public class ConfigFile {
92 89
         writeMeta(lines);
93 90
 
94 91
         for (String domain : domains) {
95
-            if ("meta".equals(domain)) {
92
+            if ("keysections".equals(domain)) {
96 93
                 continue;
97 94
             }
98 95
 
@@ -116,16 +113,29 @@ public class ConfigFile {
116 113
 
117 114
     private void writeMeta(final List<String> lines) {
118 115
         lines.add("");
119
-        lines.add("# This section describes the format of the rest of the file.");
116
+        lines.add("# This section indicates which sections below take key/value");
117
+        lines.add("# pairs, rather than a simple list. It should be placed above");
118
+        lines.add("# any sections that take key/values.");
119
+        lines.add("keysections:");
120 120
 
121 121
         for (String domain : domains) {
122
-            if ("meta".equals(domain)) {
122
+            if ("keysections".equals(domain)) {
123 123
                 continue;
124 124
             } else if (keydomains.containsKey(domain)) {
125
-                lines.add("  " + domain + "=key");
126
-            } else {
127
-                lines.add("  " + domain + "=list");
125
+                lines.add("  " + domain);
128 126
             }
129 127
         }
130 128
     }
129
+    
130
+    public Map<String, String> getKeyDomain(final String domain) {
131
+        return keydomains.get(domain);
132
+    }
133
+    
134
+    public List<String> getListDomain(final String domain) {
135
+        return flatdomains.get(domain);
136
+    }
137
+    
138
+    public boolean hasDomain(final String domain) {
139
+        return keydomains.containsKey(domain) || flatdomains.containsKey(domain);
140
+    }
131 141
 }

+ 1
- 0
test/com/dmdirc/actions/ConditionTreeTest.java Ver fichero

@@ -45,6 +45,7 @@ public class ConditionTreeTest {
45 45
             {"!!1", "!!1"},
46 46
             {"1 & !(2 | (3 & !4))", "(1&!(2|(3&!4)))"},
47 47
             {"", ""},
48
+            {"((1|((2&!3)&(!4))|6)&7)|!8", "((((1|((2&!3)&!4))|6)&7)|!8)"},
48 49
         };
49 50
         
50 51
         for (String[] testCase : testCases) {

+ 2
- 7
test/com/dmdirc/updater/UpdateTest.java Ver fichero

@@ -28,7 +28,7 @@ import static org.junit.Assert.*;
28 28
 
29 29
 public class UpdateTest {
30 30
     
31
-    private final String subject = "outofdate component rversion lversion url";
31
+    private final String subject = "outofdate component channel date version url";
32 32
     
33 33
     private Update update;
34 34
 
@@ -42,14 +42,9 @@ public class UpdateTest {
42 42
         assertEquals("component", update.getComponent());
43 43
     }
44 44
 
45
-    @Test
46
-    public void testGetLocalVersion() {
47
-        //assertEquals("lversion", update.getLocalVersion());
48
-    }
49
-
50 45
     @Test
51 46
     public void testGetRemoteVersion() {
52
-        assertEquals("rversion", update.getRemoteVersion());
47
+        assertEquals("version", update.getRemoteVersion());
53 48
     }
54 49
 
55 50
     @Test

Loading…
Cancelar
Guardar