Sfoglia il codice sorgente

Core style/pmd fixes

git-svn-id: http://svn.dmdirc.com/trunk@3640 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 anni fa
parent
commit
34d37325d2

+ 23
- 11
src/com/dmdirc/Channel.java Vedi File

99
 
99
 
100
     /**
100
     /**
101
      * Creates a new instance of Channel.
101
      * Creates a new instance of Channel.
102
+     *
102
      * @param newServer The server object that this channel belongs to
103
      * @param newServer The server object that this channel belongs to
103
      * @param newChannelInfo The parser's channel object that corresponds to
104
      * @param newChannelInfo The parser's channel object that corresponds to
104
      * this channel
105
      * this channel
125
         icon = IconManager.getIconManager().getIcon("channel");
126
         icon = IconManager.getIconManager().getIcon("channel");
126
 
127
 
127
         tabCompleter = new TabCompleter(server.getTabCompleter());
128
         tabCompleter = new TabCompleter(server.getTabCompleter());
128
-        tabCompleter.addEntries(TabCompletionType.COMMAND, 
129
+        tabCompleter.addEntries(TabCompletionType.COMMAND,
129
                 CommandManager.getCommandNames(CommandType.TYPE_CHANNEL));
130
                 CommandManager.getCommandNames(CommandType.TYPE_CHANNEL));
130
         tabCompleter.addEntries(TabCompletionType.COMMAND,
131
         tabCompleter.addEntries(TabCompletionType.COMMAND,
131
                 CommandManager.getCommandNames(CommandType.TYPE_CHAT));
132
                 CommandManager.getCommandNames(CommandType.TYPE_CHAT));
236
 
237
 
237
     /**
238
     /**
238
      * Returns the server object that this channel belongs to.
239
      * Returns the server object that this channel belongs to.
240
+     *
239
      * @return The server object
241
      * @return The server object
240
      */
242
      */
241
     @Override
243
     @Override
244
     }
246
     }
245
 
247
 
246
     /**
248
     /**
247
-     * Returns the parser's ChannelInfo object that this object is associated with.
249
+     * Returns the parser's ChannelInfo object that this object is associated
250
+     * with.
251
+     *
248
      * @return The ChannelInfo object associated with this object
252
      * @return The ChannelInfo object associated with this object
249
      */
253
      */
250
     public ChannelInfo getChannelInfo() {
254
     public ChannelInfo getChannelInfo() {
252
     }
256
     }
253
 
257
 
254
     /**
258
     /**
255
-     * Sets this object's ChannelInfo reference to the one supplied. This only needs
256
-     * to be done if the channel window (and hence this channel object) has stayed
257
-     * open while the user has been out of the channel.
259
+     * Sets this object's ChannelInfo reference to the one supplied. This only
260
+     * needs to be done if the channel window (and hence this channel object)
261
+     * has stayed open while the user has been out of the channel.
262
+     *
258
      * @param newChannelInfo The new ChannelInfo object
263
      * @param newChannelInfo The new ChannelInfo object
259
      */
264
      */
260
     public void setChannelInfo(final ChannelInfo newChannelInfo) {
265
     public void setChannelInfo(final ChannelInfo newChannelInfo) {
264
 
269
 
265
     /**
270
     /**
266
      * Returns the internal window belonging to this object.
271
      * Returns the internal window belonging to this object.
272
+     *
267
      * @return This object's internal window
273
      * @return This object's internal window
268
      */
274
      */
269
     @Override
275
     @Override
273
 
279
 
274
     /**
280
     /**
275
      * Returns the tab completer for this channel.
281
      * Returns the tab completer for this channel.
282
+     *
276
      * @return This channel's tab completer
283
      * @return This channel's tab completer
277
      */
284
      */
278
     public TabCompleter getTabCompleter() {
285
     public TabCompleter getTabCompleter() {
296
     }
303
     }
297
 
304
 
298
     /**
305
     /**
299
-     * Updates the title of the channel window, and of the main window if appropriate.
306
+     * Updates the title of the channel window, and of the main window if
307
+     * appropriate.
300
      */
308
      */
301
     private void updateTitle() {
309
     private void updateTitle() {
302
         String temp = Styliser.stipControlCodes(channelInfo.getName());
310
         String temp = Styliser.stipControlCodes(channelInfo.getName());
309
     }
317
     }
310
 
318
 
311
     /**
319
     /**
312
-     * Joins the specified channel. This only makes sense if used after a call to
313
-     * part().
320
+     * Joins the specified channel. This only makes sense if used after a call
321
+     * to part().
314
      */
322
      */
315
     public void join() {
323
     public void join() {
316
         server.getParser().joinChannel(channelInfo.getName());
324
         server.getParser().joinChannel(channelInfo.getName());
323
     /**
331
     /**
324
      * Parts this channel with the specified message. Parting does NOT close the
332
      * Parts this channel with the specified message. Parting does NOT close the
325
      * channel window.
333
      * channel window.
334
+     *
326
      * @param reason The reason for parting the channel
335
      * @param reason The reason for parting the channel
327
      */
336
      */
328
     public void part(final String reason) {
337
     public void part(final String reason) {
410
     }
419
     }
411
 
420
 
412
     /**
421
     /**
413
-     * Replaces the list of known clients on this channel with the specified one.
422
+     * Replaces the list of known clients on this channel with the specified
423
+     * one.
414
      *
424
      *
415
      * @param clients The list of clients to use
425
      * @param clients The list of clients to use
416
      */
426
      */
445
     }
455
     }
446
 
456
 
447
     /**
457
     /**
448
-     * Returns a string containing the most important mode for the specified client.
458
+     * Returns a string containing the most important mode for the specified
459
+     * client.
449
      *
460
      *
450
      * @param channelClient The channel client to check.
461
      * @param channelClient The channel client to check.
451
      * @return A string containing the most important mode, or an empty string
462
      * @return A string containing the most important mode, or an empty string
501
     }
512
     }
502
 
513
 
503
     /**
514
     /**
504
-     * Returns a string[] containing the nickname/ident/host of a channel client.
515
+     * Returns a string[] containing the nickname/ident/host of a channel
516
+     * client.
505
      *
517
      *
506
      * @param client The channel client to check
518
      * @param client The channel client to check
507
      * @param showColours Whether or not to show colours
519
      * @param showColours Whether or not to show colours

+ 6
- 2
src/com/dmdirc/ChannelClientProperty.java Vedi File

24
 
24
 
25
 /**
25
 /**
26
  * Represents the properties that can be set on a channel client.
26
  * Represents the properties that can be set on a channel client.
27
+ *
27
  * @author chris
28
  * @author chris
28
  */
29
  */
29
 public enum ChannelClientProperty {
30
 public enum ChannelClientProperty {
30
-    
31
+
31
     /** Nicklist client foreground colour. */
32
     /** Nicklist client foreground colour. */
32
     NICKLIST_FOREGROUND,
33
     NICKLIST_FOREGROUND,
34
+    
33
     /** Nicklist client background colour. */
35
     /** Nicklist client background colour. */
34
     NICKLIST_BACKGROUND,
36
     NICKLIST_BACKGROUND,
37
+    
35
     /** Textpane client foreground colour. */
38
     /** Textpane client foreground colour. */
36
     TEXT_FOREGROUND,
39
     TEXT_FOREGROUND,
40
+    
37
     /** Textpane client background colour. */
41
     /** Textpane client background colour. */
38
     TEXT_BACKGROUND;
42
     TEXT_BACKGROUND;
39
-    
43
+
40
 }
44
 }

+ 10
- 10
src/com/dmdirc/ChannelEventHandler.java Vedi File

53
      */
53
      */
54
     public ChannelEventHandler(final Channel owner) {
54
     public ChannelEventHandler(final Channel owner) {
55
         super();
55
         super();
56
-        
56
+
57
         this.owner = owner;
57
         this.owner = owner;
58
     }
58
     }
59
 
59
 
107
 
107
 
108
     /** {@inheritDoc} */
108
     /** {@inheritDoc} */
109
     @Override
109
     @Override
110
-    public void onChannelTopic(final IRCParser tParser, final ChannelInfo cChannel,
111
-            final boolean bIsJoinTopic) {
110
+    public void onChannelTopic(final IRCParser tParser,
111
+            final ChannelInfo cChannel, final boolean bIsJoinTopic) {
112
         checkParser(tParser);
112
         checkParser(tParser);
113
 
113
 
114
         final Topic newTopic = new Topic(cChannel.getTopic(),
114
         final Topic newTopic = new Topic(cChannel.getTopic(),
201
             final ChannelClientInfo cChannelClient, final String sHost,
201
             final ChannelClientInfo cChannelClient, final String sHost,
202
             final String sModes) {
202
             final String sModes) {
203
         checkParser(tParser);
203
         checkParser(tParser);
204
-        
204
+
205
         if (sHost.isEmpty()) {
205
         if (sHost.isEmpty()) {
206
             owner.doNotification(sModes.length() <= 1 ? "channelNoModes"
206
             owner.doNotification(sModes.length() <= 1 ? "channelNoModes"
207
                     : "channelModeDiscovered", CoreActionType.CHANNEL_MODESDISCOVERED,
207
                     : "channelModeDiscovered", CoreActionType.CHANNEL_MODESDISCOVERED,
211
                     : "channelModeChanged", CoreActionType.CHANNEL_MODECHANGE,
211
                     : "channelModeChanged", CoreActionType.CHANNEL_MODECHANGE,
212
                     cChannelClient, sModes);
212
                     cChannelClient, sModes);
213
         }
213
         }
214
-        
214
+
215
         owner.refreshClients();
215
         owner.refreshClients();
216
     }
216
     }
217
 
217
 
221
             final ChannelInfo cChannel, final ChannelClientInfo cChangedClient,
221
             final ChannelInfo cChannel, final ChannelClientInfo cChangedClient,
222
             final ChannelClientInfo cSetByClient, final String sHost, final String sMode) {
222
             final ChannelClientInfo cSetByClient, final String sHost, final String sMode) {
223
         checkParser(tParser);
223
         checkParser(tParser);
224
-        
224
+
225
         if (owner.getConfigManager().getOptionBool("channel", "splitusermodes", false)) {
225
         if (owner.getConfigManager().getOptionBool("channel", "splitusermodes", false)) {
226
             String format = "channelSplitUserMode_" + sMode;
226
             String format = "channelSplitUserMode_" + sMode;
227
-            
227
+
228
             if (!owner.getConfigManager().hasOption("format", format)) {
228
             if (!owner.getConfigManager().hasOption("format", format)) {
229
                 format = "channelSplitUserMode_default";
229
                 format = "channelSplitUserMode_default";
230
             }
230
             }
231
- 
231
+
232
             owner.doNotification(format, CoreActionType.CHANNEL_USERMODECHANGE,
232
             owner.doNotification(format, CoreActionType.CHANNEL_USERMODECHANGE,
233
                     cSetByClient, cChangedClient, sMode);
233
                     cSetByClient, cChangedClient, sMode);
234
         }
234
         }
248
 
248
 
249
     /** {@inheritDoc} */
249
     /** {@inheritDoc} */
250
     @Override
250
     @Override
251
-    public void onAwayStateOther(final IRCParser tParser, final ClientInfo client,
252
-            final boolean state) {
251
+    public void onAwayStateOther(final IRCParser tParser,
252
+            final ClientInfo client, final boolean state) {
253
         checkParser(tParser);
253
         checkParser(tParser);
254
 
254
 
255
         final ChannelClientInfo channelClient = owner.getChannelInfo().getUser(client);
255
         final ChannelClientInfo channelClient = owner.getChannelInfo().getUser(client);

+ 8
- 8
src/com/dmdirc/CustomWindow.java Vedi File

29
 
29
 
30
 /**
30
 /**
31
  * A generic custom window implementation.
31
  * A generic custom window implementation.
32
- * 
32
+ *
33
  * @author chris
33
  * @author chris
34
  */
34
  */
35
 public class CustomWindow extends FrameContainer {
35
 public class CustomWindow extends FrameContainer {
48
 
48
 
49
     /**
49
     /**
50
      * Creates a new custom window as a child of the specified window.
50
      * Creates a new custom window as a child of the specified window.
51
-     * 
51
+     *
52
      * @param name The name of this custom window
52
      * @param name The name of this custom window
53
      * @param title The title of this custom window
53
      * @param title The title of this custom window
54
      * @param parent The parent of this custom window
54
      * @param parent The parent of this custom window
74
 
74
 
75
     /**
75
     /**
76
      * Creates a new custom window as a top-level window.
76
      * Creates a new custom window as a top-level window.
77
-     * 
77
+     *
78
      * @param name The name of this custom window
78
      * @param name The name of this custom window
79
      * @param title The parent of this custom window
79
      * @param title The parent of this custom window
80
      */
80
      */
112
     public void windowClosing() {
112
     public void windowClosing() {
113
         // 1: Make the window non-visible
113
         // 1: Make the window non-visible
114
         window.setVisible(false);
114
         window.setVisible(false);
115
-        
115
+
116
         // 2: Remove any callbacks or listeners
116
         // 2: Remove any callbacks or listeners
117
         // 3: Trigger any actions neccessary
117
         // 3: Trigger any actions neccessary
118
         // 4: Trigger action for the window closing
118
         // 4: Trigger action for the window closing
119
         // 5: Inform any parents that the window is closing
119
         // 5: Inform any parents that the window is closing
120
-        
120
+
121
         // 6: Remove the window from the window manager
121
         // 6: Remove the window from the window manager
122
         WindowManager.removeWindow(window);
122
         WindowManager.removeWindow(window);
123
-        
123
+
124
         // 7: Remove any references to the window and parents
124
         // 7: Remove any references to the window and parents
125
         window = null; // NOPMD
125
         window = null; // NOPMD
126
         parent = null; // NOPMD
126
         parent = null; // NOPMD
134
 
134
 
135
     /**
135
     /**
136
      * Retrieves this custom window's name.
136
      * Retrieves this custom window's name.
137
-     * 
137
+     *
138
      * @return This custom window's name
138
      * @return This custom window's name
139
      */
139
      */
140
     public String getName() {
140
     public String getName() {
143
 
143
 
144
     /**
144
     /**
145
      * Retrieves this custom window's title.
145
      * Retrieves this custom window's title.
146
-     * 
146
+     *
147
      * @return This custom window's title
147
      * @return This custom window's title
148
      */
148
      */
149
     public String getTitle() {
149
     public String getTitle() {

+ 18
- 24
src/com/dmdirc/FrameContainerComparator.java Vedi File

22
 
22
 
23
 package com.dmdirc;
23
 package com.dmdirc;
24
 
24
 
25
-
26
 import java.io.Serializable;
25
 import java.io.Serializable;
27
 import java.util.Comparator;
26
 import java.util.Comparator;
28
 
27
 
31
  */
30
  */
32
 public final class FrameContainerComparator implements Comparator<FrameContainer>,
31
 public final class FrameContainerComparator implements Comparator<FrameContainer>,
33
         Serializable {
32
         Serializable {
34
-    
33
+
35
     /**
34
     /**
36
      * A version number for this class. It should be changed whenever the class
35
      * A version number for this class. It should be changed whenever the class
37
      * structure is changed (or anything else that would prevent serialized
36
      * structure is changed (or anything else that would prevent serialized
38
      * objects being unserialized with the new class).
37
      * objects being unserialized with the new class).
39
      */
38
      */
40
     private static final long serialVersionUID = 1;
39
     private static final long serialVersionUID = 1;
41
-    
40
+
42
     /**
41
     /**
43
      * Creates a new instance of FrameContainerComparator.
42
      * Creates a new instance of FrameContainerComparator.
44
      */
43
      */
45
     public FrameContainerComparator() {
44
     public FrameContainerComparator() {
46
         super();
45
         super();
47
     }
46
     }
48
-    
47
+
49
     /**
48
     /**
50
      * Compares two frame containers names.
49
      * Compares two frame containers names.
51
      *
50
      *
52
      * @param item1 The first container to compare
51
      * @param item1 The first container to compare
53
      * @param item2 The second container to compare
52
      * @param item2 The second container to compare
54
-     *
55
      * @return -1 if item1 is before item2, 0 if they're equal,
53
      * @return -1 if item1 is before item2, 0 if they're equal,
56
      * +1 if item1 is after item2.
54
      * +1 if item1 is after item2.
57
      */
55
      */
71
             }
69
             }
72
         }
70
         }
73
     }
71
     }
74
-    
72
+
75
     /**
73
     /**
76
      * Compares frame container types and checks order preferences.
74
      * Compares frame container types and checks order preferences.
77
      *
75
      *
78
      * @param item1 The new container to be tested
76
      * @param item1 The new container to be tested
79
      * @param item2 The existing container to test against
77
      * @param item2 The existing container to test against
80
-     *
81
      * @return True iff the new container should be before the old container
78
      * @return True iff the new container should be before the old container
82
      */
79
      */
83
     private boolean sortBefore(final FrameContainer item1,
80
     private boolean sortBefore(final FrameContainer item1,
84
             final FrameContainer item2) {
81
             final FrameContainer item2) {
85
-        
82
+
86
         return getPosition(item1) < getPosition(item2);
83
         return getPosition(item1) < getPosition(item2);
87
     }
84
     }
88
-    
85
+
89
     /**
86
     /**
90
      * Compares frame container types and checks order preferences.
87
      * Compares frame container types and checks order preferences.
91
      *
88
      *
92
      * @param item1 The new container to be tested
89
      * @param item1 The new container to be tested
93
      * @param item2 The existing container to test against
90
      * @param item2 The existing container to test against
94
-     *
95
      * @return True iff the new container should be after the old container
91
      * @return True iff the new container should be after the old container
96
      */
92
      */
97
     private boolean sortAfter(final FrameContainer item1,
93
     private boolean sortAfter(final FrameContainer item1,
98
             final FrameContainer item2) {
94
             final FrameContainer item2) {
99
-        
100
         return getPosition(item1) > getPosition(item2);
95
         return getPosition(item1) > getPosition(item2);
101
     }
96
     }
102
-    
97
+
103
     /**
98
     /**
104
      * Returns an integer corresponding to the expected order of a frame
99
      * Returns an integer corresponding to the expected order of a frame
105
      * container.
100
      * container.
106
      *
101
      *
107
      * @param item The frame container to be tested
102
      * @param item The frame container to be tested
108
-     *
109
      * @return Position of the frame container
103
      * @return Position of the frame container
110
      */
104
      */
111
     private int getPosition(final FrameContainer item) {
105
     private int getPosition(final FrameContainer item) {
112
         if (item instanceof GlobalWindow) {
106
         if (item instanceof GlobalWindow) {
113
             return 0;
107
             return 0;
114
         } else if (item instanceof Server) {
108
         } else if (item instanceof Server) {
115
-	    return 1;
116
-	} else if (item instanceof Raw) {
117
-	    return 2;
118
-	} else if (item instanceof Channel) {
119
-	    return 3;
120
-	} else if (item instanceof Query) {
121
-	    return 4;
122
-	} else {
123
-	    return 5;
124
-	}
109
+            return 1;
110
+        } else if (item instanceof Raw) {
111
+            return 2;
112
+        } else if (item instanceof Channel) {
113
+            return 3;
114
+        } else if (item instanceof Query) {
115
+            return 4;
116
+        } else {
117
+            return 5;
118
+        }
125
     }
119
     }
126
-    
120
+
127
 }
121
 }

+ 21
- 21
src/com/dmdirc/GlobalWindow.java Vedi File

38
  * @author chris
38
  * @author chris
39
  */
39
  */
40
 public class GlobalWindow extends WritableFrameContainer {
40
 public class GlobalWindow extends WritableFrameContainer {
41
-    
41
+
42
     /** The window we're using. */
42
     /** The window we're using. */
43
     private final InputWindow window;
43
     private final InputWindow window;
44
-    
44
+
45
     /** Creates a new instance of GlobalWindow. */
45
     /** Creates a new instance of GlobalWindow. */
46
     public GlobalWindow() {
46
     public GlobalWindow() {
47
         super();
47
         super();
48
-        
48
+
49
         final TabCompleter tabCompleter = new TabCompleter();
49
         final TabCompleter tabCompleter = new TabCompleter();
50
         tabCompleter.addEntries(TabCompletionType.COMMAND,
50
         tabCompleter.addEntries(TabCompletionType.COMMAND,
51
                 CommandManager.getCommandNames(CommandType.TYPE_GLOBAL));
51
                 CommandManager.getCommandNames(CommandType.TYPE_GLOBAL));
52
-        
52
+
53
         window = Main.getUI().getInputWindow(this, GlobalCommandParser.getGlobalCommandParser());
53
         window = Main.getUI().getInputWindow(this, GlobalCommandParser.getGlobalCommandParser());
54
-        
54
+
55
         icon = IconManager.getIconManager().getIcon("icon");
55
         icon = IconManager.getIconManager().getIcon("icon");
56
-        
56
+
57
         window.setTitle("(Global)");
57
         window.setTitle("(Global)");
58
         window.getInputHandler().setTabCompleter(tabCompleter);
58
         window.getInputHandler().setTabCompleter(tabCompleter);
59
-        window.setFrameIcon(icon);        
60
-        
59
+        window.setFrameIcon(icon);
60
+
61
         WindowManager.addWindow(window);
61
         WindowManager.addWindow(window);
62
-        
62
+
63
         window.open();
63
         window.open();
64
     }
64
     }
65
 
65
 
66
     /** {@inheritDoc} */
66
     /** {@inheritDoc} */
67
-    @Override    
67
+    @Override
68
     public InputWindow getFrame() {
68
     public InputWindow getFrame() {
69
         return window;
69
         return window;
70
     }
70
     }
76
     }
76
     }
77
 
77
 
78
     /** {@inheritDoc} */
78
     /** {@inheritDoc} */
79
-    @Override    
79
+    @Override
80
     public void windowClosing() {
80
     public void windowClosing() {
81
         // 1: Make the window non-visible
81
         // 1: Make the window non-visible
82
         window.setVisible(false);
82
         window.setVisible(false);
83
-        
83
+
84
         // 2: Remove any callbacks or listeners
84
         // 2: Remove any callbacks or listeners
85
         // 3: Trigger any actions neccessary
85
         // 3: Trigger any actions neccessary
86
         // 4: Trigger action for the window closing
86
         // 4: Trigger action for the window closing
87
         // 5: Inform any parents that the window is closing
87
         // 5: Inform any parents that the window is closing
88
-        
88
+
89
         // 6: Remove the window from the window manager
89
         // 6: Remove the window from the window manager
90
         WindowManager.removeWindow(window);
90
         WindowManager.removeWindow(window);
91
-        
92
-        // 7: Remove any references to the window and parents        
91
+
92
+        // 7: Remove any references to the window and parents
93
     }
93
     }
94
 
94
 
95
     /** {@inheritDoc} */
95
     /** {@inheritDoc} */
96
-    @Override    
96
+    @Override
97
     public Server getServer() {
97
     public Server getServer() {
98
         return null;
98
         return null;
99
     }
99
     }
100
 
100
 
101
     /** {@inheritDoc} */
101
     /** {@inheritDoc} */
102
-    @Override    
102
+    @Override
103
     public void sendLine(final String line) {
103
     public void sendLine(final String line) {
104
-        GlobalCommandParser.getGlobalCommandParser().parseCommand(window, 
104
+        GlobalCommandParser.getGlobalCommandParser().parseCommand(window,
105
                 CommandManager.getCommandChar() + line);
105
                 CommandManager.getCommandChar() + line);
106
     }
106
     }
107
 
107
 
108
     /** {@inheritDoc} */
108
     /** {@inheritDoc} */
109
-    @Override    
109
+    @Override
110
     public int getMaxLineLength() {
110
     public int getMaxLineLength() {
111
         return 0;
111
         return 0;
112
     }
112
     }
113
-    
113
+
114
     /** {@inheritDoc} */
114
     /** {@inheritDoc} */
115
     @Override
115
     @Override
116
     public ConfigManager getConfigManager() {
116
     public ConfigManager getConfigManager() {
117
         return IdentityManager.getGlobalConfig();
117
         return IdentityManager.getGlobalConfig();
118
     }
118
     }
119
-    
119
+
120
 }
120
 }

+ 4
- 4
src/com/dmdirc/IconManager.java Vedi File

22
 
22
 
23
 package com.dmdirc;
23
 package com.dmdirc;
24
 
24
 
25
-import com.dmdirc.interfaces.ConfigChangeListener;
26
 import com.dmdirc.config.IdentityManager;
25
 import com.dmdirc.config.IdentityManager;
27
-
26
+import com.dmdirc.interfaces.ConfigChangeListener;
28
 import com.dmdirc.util.URLBuilder;
27
 import com.dmdirc.util.URLBuilder;
28
+
29
 import java.awt.Image;
29
 import java.awt.Image;
30
 import java.awt.Toolkit;
30
 import java.awt.Toolkit;
31
 import java.io.File;
31
 import java.io.File;
47
 public final class IconManager implements ConfigChangeListener {
47
 public final class IconManager implements ConfigChangeListener {
48
     
48
     
49
     /** Previously created IconManager instance. */
49
     /** Previously created IconManager instance. */
50
-    private static final IconManager me = new IconManager();
50
+    private static final IconManager ME = new IconManager();
51
         
51
         
52
     /** A map of existing icons. */
52
     /** A map of existing icons. */
53
     private final Map<String, Icon> icons;
53
     private final Map<String, Icon> icons;
69
      * @return Instance of IconManager
69
      * @return Instance of IconManager
70
      */
70
      */
71
     public static IconManager getIconManager() {
71
     public static IconManager getIconManager() {
72
-        return me;
72
+        return ME;
73
     }
73
     }
74
     
74
     
75
     /**
75
     /**

+ 29
- 29
src/com/dmdirc/IgnoreList.java Vedi File

30
 /**
30
 /**
31
  * Wraps around a RegexStringList to allow "simple" expressions to be used
31
  * Wraps around a RegexStringList to allow "simple" expressions to be used
32
  * instead of more complex regular expressions.
32
  * instead of more complex regular expressions.
33
- * 
33
+ *
34
  * @author chris
34
  * @author chris
35
  */
35
  */
36
 public class IgnoreList extends RegexStringList {
36
 public class IgnoreList extends RegexStringList {
37
-    
37
+
38
     /**
38
     /**
39
      * Creates a new instance of IgnoreList.
39
      * Creates a new instance of IgnoreList.
40
      */
40
      */
44
 
44
 
45
     /**
45
     /**
46
      * Creates a new instance of IgnoreList containing the specified items.
46
      * Creates a new instance of IgnoreList containing the specified items.
47
-     * 
47
+     *
48
      * @param items The items to be added
48
      * @param items The items to be added
49
      */
49
      */
50
     public IgnoreList(final List<String> items) {
50
     public IgnoreList(final List<String> items) {
51
         super(items);
51
         super(items);
52
     }
52
     }
53
-    
53
+
54
     /**
54
     /**
55
      * Adds the specified simple pattern to this ignore list.
55
      * Adds the specified simple pattern to this ignore list.
56
-     * 
56
+     *
57
      * @param pattern The simple pattern to be added
57
      * @param pattern The simple pattern to be added
58
      */
58
      */
59
     public void addSimple(final String pattern) {
59
     public void addSimple(final String pattern) {
60
         add(simpleToRegex(pattern));
60
         add(simpleToRegex(pattern));
61
     }
61
     }
62
-    
62
+
63
     /**
63
     /**
64
      * Determines if this list can be converted to a simple list.
64
      * Determines if this list can be converted to a simple list.
65
-     * 
65
+     *
66
      * @return True if this list can be converted, false otherwise.
66
      * @return True if this list can be converted, false otherwise.
67
      */
67
      */
68
     public boolean canConvert() {
68
     public boolean canConvert() {
69
         try {
69
         try {
70
             getSimpleList();
70
             getSimpleList();
71
             return true;
71
             return true;
72
-        } catch(UnsupportedOperationException ex) {
72
+        } catch (UnsupportedOperationException ex) {
73
             return false;
73
             return false;
74
         }
74
         }
75
     }
75
     }
76
-    
76
+
77
     /**
77
     /**
78
      * Retrieves a list of regular expressions in this ignore list.
78
      * Retrieves a list of regular expressions in this ignore list.
79
-     * 
79
+     *
80
      * @return All expressions in this ignore list
80
      * @return All expressions in this ignore list
81
      */
81
      */
82
     public List<String> getRegexList() {
82
     public List<String> getRegexList() {
83
         return new ArrayList<String>(ignoreInfo);
83
         return new ArrayList<String>(ignoreInfo);
84
     }
84
     }
85
-    
85
+
86
     /**
86
     /**
87
      * Retrieves a list of simple expressions in this ignore list.
87
      * Retrieves a list of simple expressions in this ignore list.
88
-     * 
88
+     *
89
      * @return All expressions in this ignore list, converted to simple expressions
89
      * @return All expressions in this ignore list, converted to simple expressions
90
      * @throws UnsupportedOperationException if an expression can't be converted
90
      * @throws UnsupportedOperationException if an expression can't be converted
91
      */
91
      */
92
     public List<String> getSimpleList() throws UnsupportedOperationException {
92
     public List<String> getSimpleList() throws UnsupportedOperationException {
93
         final List<String> res = new ArrayList<String>();
93
         final List<String> res = new ArrayList<String>();
94
-        
94
+
95
         for (String regex : ignoreInfo) {
95
         for (String regex : ignoreInfo) {
96
             res.add(regexToSimple(regex));
96
             res.add(regexToSimple(regex));
97
         }
97
         }
98
-        
98
+
99
         return res;
99
         return res;
100
     }
100
     }
101
-    
101
+
102
     /**
102
     /**
103
      * Converts a regular expression into a simple expression.
103
      * Converts a regular expression into a simple expression.
104
-     * 
104
+     *
105
      * @param regex The regular expression to be converted
105
      * @param regex The regular expression to be converted
106
      * @return A simple expression corresponding to the regex
106
      * @return A simple expression corresponding to the regex
107
      * @throws UnsupportedOperationException if the regex cannot be converted
107
      * @throws UnsupportedOperationException if the regex cannot be converted
111
         final StringBuilder res = new StringBuilder(regex.length());
111
         final StringBuilder res = new StringBuilder(regex.length());
112
         boolean escaped = false;
112
         boolean escaped = false;
113
         boolean inchar = false;
113
         boolean inchar = false;
114
-        
114
+
115
         for (char part : regex.toCharArray()) {
115
         for (char part : regex.toCharArray()) {
116
             if (inchar) {
116
             if (inchar) {
117
                 inchar = false;
117
                 inchar = false;
118
-                
118
+
119
                 if (part == '*') {
119
                 if (part == '*') {
120
                     res.append(part);
120
                     res.append(part);
121
                     continue;
121
                     continue;
123
                     res.append('?');
123
                     res.append('?');
124
                 }
124
                 }
125
             }
125
             }
126
-            
126
+
127
             if (escaped) {
127
             if (escaped) {
128
                 if (part == '?' || part == '*') {
128
                 if (part == '?' || part == '*') {
129
-                    throw new UnsupportedOperationException("Cannot convert to" +
130
-                            " simple expression: ? or * is escaped.");
129
+                    throw new UnsupportedOperationException("Cannot convert to"
130
+                            + " simple expression: ? or * is escaped.");
131
                 }
131
                 }
132
-                
132
+
133
                 res.append(part);
133
                 res.append(part);
134
                 escaped = false;
134
                 escaped = false;
135
             }  else if (part == '\\') {
135
             }  else if (part == '\\') {
146
                 res.append(part);
146
                 res.append(part);
147
             }
147
             }
148
         }
148
         }
149
-        
149
+
150
         if (escaped) {
150
         if (escaped) {
151
             throw new UnsupportedOperationException("Cannot convert to "
151
             throw new UnsupportedOperationException("Cannot convert to "
152
                     + "simple expression: trailing backslash");
152
                     + "simple expression: trailing backslash");
153
         } else if (inchar) {
153
         } else if (inchar) {
154
             res.append('?');
154
             res.append('?');
155
         }
155
         }
156
-        
156
+
157
         return res.toString();
157
         return res.toString();
158
     }
158
     }
159
-    
159
+
160
     /**
160
     /**
161
      * Converts a simple expression to a regular expression.
161
      * Converts a simple expression to a regular expression.
162
-     * 
162
+     *
163
      * @param regex The simple expression to be converted
163
      * @param regex The simple expression to be converted
164
      * @return A corresponding regular expression
164
      * @return A corresponding regular expression
165
      */
165
      */
166
     @SuppressWarnings("fallthrough")
166
     @SuppressWarnings("fallthrough")
167
     protected static String simpleToRegex(final String regex) {
167
     protected static String simpleToRegex(final String regex) {
168
         final StringBuilder res = new StringBuilder(regex.length());
168
         final StringBuilder res = new StringBuilder(regex.length());
169
-        
169
+
170
         for (char part : regex.toCharArray()) {
170
         for (char part : regex.toCharArray()) {
171
             switch (part) {
171
             switch (part) {
172
             case '.': case '^': case '$': case '[': case ']': case '\\':
172
             case '.': case '^': case '$': case '[': case ']': case '\\':
178
                 res.append('.');
178
                 res.append('.');
179
                 break;
179
                 break;
180
             case '*':
180
             case '*':
181
-                res.append('.');                
181
+                res.append('.');
182
             default:
182
             default:
183
                 res.append(part);
183
                 res.append(part);
184
                 break;
184
                 break;
185
             }
185
             }
186
         }
186
         }
187
-        
187
+
188
         return res.toString();
188
         return res.toString();
189
     }
189
     }
190
 
190
 

+ 35
- 35
src/com/dmdirc/Main.java Vedi File

46
  * @author chris
46
  * @author chris
47
  */
47
  */
48
 public final class Main {
48
 public final class Main {
49
-    
49
+
50
     /** Stores the current textual program version. */
50
     /** Stores the current textual program version. */
51
     public static final String VERSION = "SVN";
51
     public static final String VERSION = "SVN";
52
-    
52
+
53
     /** The SVN revision that this build was made from. */
53
     /** The SVN revision that this build was made from. */
54
     public static final int SVN_REVISION = 3628; // 3601;
54
     public static final int SVN_REVISION = 3628; // 3601;
55
-    
55
+
56
     /** Stores the update channel that this version came from, if any. */
56
     /** Stores the update channel that this version came from, if any. */
57
     public static final UpdateChannel UPDATE_CHANNEL = UpdateChannel.NONE;
57
     public static final UpdateChannel UPDATE_CHANNEL = UpdateChannel.NONE;
58
-    
58
+
59
     /** Feedback nag delay. */
59
     /** Feedback nag delay. */
60
     private static final int FEEDBACK_DELAY = 30 * 60 * 1000;
60
     private static final int FEEDBACK_DELAY = 30 * 60 * 1000;
61
-    
61
+
62
     /** The UI to use for the client. */
62
     /** The UI to use for the client. */
63
     private static UIController controller;
63
     private static UIController controller;
64
-    
64
+
65
     /** The config dir to use for the client. */
65
     /** The config dir to use for the client. */
66
     private static String configdir;
66
     private static String configdir;
67
-    
67
+
68
     /**
68
     /**
69
      * Prevents creation of main.
69
      * Prevents creation of main.
70
      */
70
      */
71
     private Main() {
71
     private Main() {
72
     }
72
     }
73
-    
73
+
74
     /**
74
     /**
75
      * Entry procedure.
75
      * Entry procedure.
76
      *
76
      *
78
      */
78
      */
79
     public static void main(final String[] args) {
79
     public static void main(final String[] args) {
80
         Thread.setDefaultUncaughtExceptionHandler(new DMDircExceptionHandler());
80
         Thread.setDefaultUncaughtExceptionHandler(new DMDircExceptionHandler());
81
-        
81
+
82
         final CommandLineParser clp = new CommandLineParser(args);
82
         final CommandLineParser clp = new CommandLineParser(args);
83
-        
83
+
84
         IdentityManager.load();
84
         IdentityManager.load();
85
-        
85
+
86
         clp.applySettings();
86
         clp.applySettings();
87
-        
87
+
88
         CommandManager.initCommands();
88
         CommandManager.initCommands();
89
-        
89
+
90
         getUI().initUISettings();
90
         getUI().initUISettings();
91
-        
91
+
92
         if (IdentityManager.getGlobalConfig().getOptionBool("general", "firstRun", true)) {
92
         if (IdentityManager.getGlobalConfig().getOptionBool("general", "firstRun", true)) {
93
             IdentityManager.getConfigIdentity().setOption("general", "firstRun", "false");
93
             IdentityManager.getConfigIdentity().setOption("general", "firstRun", "false");
94
             getUI().showFirstRunWizard();
94
             getUI().showFirstRunWizard();
104
             // @Deprecated - can be removed after 0.6 is released
104
             // @Deprecated - can be removed after 0.6 is released
105
             IdentityManager.getConfigIdentity().unsetOption("general", "addonrevision");
105
             IdentityManager.getConfigIdentity().unsetOption("general", "addonrevision");
106
             getUI().showMigrationWizard();
106
             getUI().showMigrationWizard();
107
-        }        
108
-        
107
+        }
108
+
109
         ActionManager.init();
109
         ActionManager.init();
110
-        
110
+
111
         PluginManager.getPluginManager();
111
         PluginManager.getPluginManager();
112
-        
112
+
113
         ActionManager.loadActions();
113
         ActionManager.loadActions();
114
-        
114
+
115
         new ThemeManager().loadDefaultTheme();
115
         new ThemeManager().loadDefaultTheme();
116
-        
116
+
117
         getUI().getMainWindow();
117
         getUI().getMainWindow();
118
-                
118
+
119
         ActionManager.processEvent(CoreActionType.CLIENT_OPENED, null);
119
         ActionManager.processEvent(CoreActionType.CLIENT_OPENED, null);
120
-        
120
+
121
         UpdateChecker.init();
121
         UpdateChecker.init();
122
-        
122
+
123
         clp.processArguments();
123
         clp.processArguments();
124
-        
124
+
125
         if (IdentityManager.getGlobalConfig().getOptionBool("general", "showglobalwindow", false)) {
125
         if (IdentityManager.getGlobalConfig().getOptionBool("general", "showglobalwindow", false)) {
126
             new GlobalWindow();
126
             new GlobalWindow();
127
         }
127
         }
128
-        
128
+
129
         Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
129
         Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
130
             public void run() {
130
             public void run() {
131
                 ActionManager.processEvent(CoreActionType.CLIENT_CLOSED, null);
131
                 ActionManager.processEvent(CoreActionType.CLIENT_CLOSED, null);
134
             }
134
             }
135
         }, "Shutdown thread"));
135
         }, "Shutdown thread"));
136
     }
136
     }
137
-    
137
+
138
     /**
138
     /**
139
      * Quits the client nicely, with the default closing message.
139
      * Quits the client nicely, with the default closing message.
140
      */
140
      */
141
     public static void quit() {
141
     public static void quit() {
142
         quit(IdentityManager.getGlobalConfig().getOption("general", "closemessage"));
142
         quit(IdentityManager.getGlobalConfig().getOption("general", "closemessage"));
143
     }
143
     }
144
-    
144
+
145
     /**
145
     /**
146
      * Quits the client nicely.
146
      * Quits the client nicely.
147
      *
147
      *
149
      */
149
      */
150
     public static void quit(final String reason) {
150
     public static void quit(final String reason) {
151
         ServerManager.getServerManager().disconnectAll(reason);
151
         ServerManager.getServerManager().disconnectAll(reason);
152
-        
152
+
153
         System.exit(0);
153
         System.exit(0);
154
     }
154
     }
155
-    
155
+
156
     /**
156
     /**
157
      * Retrieves the UI controller that's being used by the client.
157
      * Retrieves the UI controller that's being used by the client.
158
      *
158
      *
166
                 controller = new SwingController();
166
                 controller = new SwingController();
167
             }
167
             }
168
         }
168
         }
169
-        
169
+
170
         return controller;
170
         return controller;
171
     }
171
     }
172
-    
172
+
173
     /**
173
     /**
174
      * Sets the UI controller that should be used by this client.
174
      * Sets the UI controller that should be used by this client.
175
      *
175
      *
178
     public static void setUI(final UIController newController) {
178
     public static void setUI(final UIController newController) {
179
         controller = newController;
179
         controller = newController;
180
     }
180
     }
181
-    
181
+
182
     /**
182
     /**
183
      * Returns the application's config directory.
183
      * Returns the application's config directory.
184
      *
184
      *
200
                 configdir = System.getProperty("user.home") + fs + ".DMDirc" + fs;
200
                 configdir = System.getProperty("user.home") + fs + ".DMDirc" + fs;
201
             }
201
             }
202
         }
202
         }
203
-        
203
+
204
         return configdir;
204
         return configdir;
205
     }
205
     }
206
-    
206
+
207
     /**
207
     /**
208
      * Sets the config directory for this client.
208
      * Sets the config directory for this client.
209
      *
209
      *
212
     public static void setConfigDir(final String newdir) {
212
     public static void setConfigDir(final String newdir) {
213
         configdir = newdir;
213
         configdir = newdir;
214
     }
214
     }
215
-    
215
+
216
 }
216
 }

+ 4
- 4
src/com/dmdirc/MessageTarget.java Vedi File

25
 /**
25
 /**
26
  * Defines common methods for objects that you can send messages to (such as
26
  * Defines common methods for objects that you can send messages to (such as
27
  * channels and queries).
27
  * channels and queries).
28
- * 
28
+ *
29
  * @author Chris
29
  * @author Chris
30
  */
30
  */
31
 public abstract class MessageTarget extends WritableFrameContainer {
31
 public abstract class MessageTarget extends WritableFrameContainer {
32
-    
32
+
33
     /**
33
     /**
34
      * Sends the specified string as an action (CTCP) to the target that this
34
      * Sends the specified string as an action (CTCP) to the target that this
35
      * object represents.
35
      * object represents.
36
-     * 
36
+     *
37
      * @param action The action to send
37
      * @param action The action to send
38
-     */    
38
+     */
39
     public abstract void sendAction(final String action);
39
     public abstract void sendAction(final String action);
40
 
40
 
41
 }
41
 }

+ 5
- 4
src/com/dmdirc/Query.java Vedi File

301
     public void onQuit(final IRCParser tParser, final ClientInfo cClient,
301
     public void onQuit(final IRCParser tParser, final ClientInfo cClient,
302
             final String sReason) {
302
             final String sReason) {
303
         if (cClient.getNickname().equals(ClientInfo.parseHost(host))) {
303
         if (cClient.getNickname().equals(ClientInfo.parseHost(host))) {
304
-            final StringBuffer format = new StringBuffer(sReason.isEmpty() ?
305
-                "queryQuit" : "queryQuitReason");
304
+            final StringBuffer format = new StringBuffer(sReason.isEmpty()
305
+                ? "queryQuit" : "queryQuitReason");
306
 
306
 
307
             ActionManager.processEvent(CoreActionType.QUERY_QUIT, format, this, sReason);
307
             ActionManager.processEvent(CoreActionType.QUERY_QUIT, format, this, sReason);
308
 
308
 
394
     @Override
394
     @Override
395
     public ConfigManager getConfigManager() {
395
     public ConfigManager getConfigManager() {
396
         if (server == null) {
396
         if (server == null) {
397
-            Logger.appError(ErrorLevel.LOW, "Tried to retrieve config manager" +
398
-                    " from a query with no server", new IllegalStateException("My host: " + host));
397
+            Logger.appError(ErrorLevel.LOW, "Tried to retrieve config manager"
398
+                    + " from a query with no server",
399
+                    new IllegalStateException("My host: " + host));
399
             return IdentityManager.getGlobalConfig();
400
             return IdentityManager.getGlobalConfig();
400
         }
401
         }
401
 
402
 

+ 23
- 23
src/com/dmdirc/Raw.java Vedi File

41
  */
41
  */
42
 public final class Raw extends WritableFrameContainer implements IDataIn,
42
 public final class Raw extends WritableFrameContainer implements IDataIn,
43
         IDataOut, Serializable {
43
         IDataOut, Serializable {
44
-    
44
+
45
     /**
45
     /**
46
      * A version number for this class. It should be changed whenever the class
46
      * A version number for this class. It should be changed whenever the class
47
      * structure is changed (or anything else that would prevent serialized
47
      * structure is changed (or anything else that would prevent serialized
48
      * objects being unserialized with the new class).
48
      * objects being unserialized with the new class).
49
      */
49
      */
50
     private static final long serialVersionUID = 1;
50
     private static final long serialVersionUID = 1;
51
-    
51
+
52
     /** The server object that's being monitored. */
52
     /** The server object that's being monitored. */
53
     private Server server;
53
     private Server server;
54
-    
54
+
55
     /** An InputWindow used for displaying the raw data.*/
55
     /** An InputWindow used for displaying the raw data.*/
56
     private InputWindow window;
56
     private InputWindow window;
57
-    
57
+
58
     /**
58
     /**
59
      * Creates a new instance of Raw.
59
      * Creates a new instance of Raw.
60
      *
60
      *
62
      */
62
      */
63
     public Raw(final Server newServer) {
63
     public Raw(final Server newServer) {
64
         super();
64
         super();
65
-        
65
+
66
         this.server = newServer;
66
         this.server = newServer;
67
-        
67
+
68
         icon = IconManager.getIconManager().getIcon("raw");
68
         icon = IconManager.getIconManager().getIcon("raw");
69
-        
69
+
70
         window = Main.getUI().getInputWindow(this, newServer.getFrame().getCommandParser());
70
         window = Main.getUI().getInputWindow(this, newServer.getFrame().getCommandParser());
71
         WindowManager.addWindow(server.getFrame(), window);
71
         WindowManager.addWindow(server.getFrame(), window);
72
         window.setTitle("(Raw log)");
72
         window.setTitle("(Raw log)");
73
         window.getInputHandler().setTabCompleter(server.getTabCompleter());
73
         window.getInputHandler().setTabCompleter(server.getTabCompleter());
74
         window.setFrameIcon(icon);
74
         window.setFrameIcon(icon);
75
-        
75
+
76
         window.open();
76
         window.open();
77
     }
77
     }
78
-    
78
+
79
     /**
79
     /**
80
      * Registers the data callbacks for this raw window.
80
      * Registers the data callbacks for this raw window.
81
      */
81
      */
87
             Logger.appError(ErrorLevel.HIGH, "Unable to register raw callbacks", ex);
87
             Logger.appError(ErrorLevel.HIGH, "Unable to register raw callbacks", ex);
88
         }
88
         }
89
     }
89
     }
90
-    
90
+
91
     /** {@inheritDoc} */
91
     /** {@inheritDoc} */
92
     @Override
92
     @Override
93
     public void windowClosing() {
93
     public void windowClosing() {
94
         // 1: Make the window non-visible
94
         // 1: Make the window non-visible
95
         window.setVisible(false);
95
         window.setVisible(false);
96
-        
96
+
97
         // 2: Remove any callbacks or listeners
97
         // 2: Remove any callbacks or listeners
98
         if (server != null && server.getParser() != null) {
98
         if (server != null && server.getParser() != null) {
99
             server.getParser().getCallbackManager().delAllCallback(this);
99
             server.getParser().getCallbackManager().delAllCallback(this);
100
         }
100
         }
101
-        
101
+
102
         // 3: Trigger any actions neccessary
102
         // 3: Trigger any actions neccessary
103
         // 4: Trigger action for the window closing
103
         // 4: Trigger action for the window closing
104
-        
104
+
105
         // 5: Inform any parents that the window is closing
105
         // 5: Inform any parents that the window is closing
106
         server.delRaw();
106
         server.delRaw();
107
-        
107
+
108
         // 6: Remove the window from the window manager
108
         // 6: Remove the window from the window manager
109
         WindowManager.removeWindow(window);
109
         WindowManager.removeWindow(window);
110
-        
110
+
111
         // 7: Remove any references to the window and parents
111
         // 7: Remove any references to the window and parents
112
         window = null;
112
         window = null;
113
         server = null;
113
         server = null;
114
     }
114
     }
115
-    
115
+
116
     /** {@inheritDoc} */
116
     /** {@inheritDoc} */
117
     @Override
117
     @Override
118
     public InputWindow getFrame() {
118
     public InputWindow getFrame() {
119
         return window;
119
         return window;
120
     }
120
     }
121
-    
121
+
122
     /** {@inheritDoc} */
122
     /** {@inheritDoc} */
123
     @Override
123
     @Override
124
     public void onDataIn(final IRCParser tParser, final String sData) {
124
     public void onDataIn(final IRCParser tParser, final String sData) {
125
         addLine("rawIn", sData);
125
         addLine("rawIn", sData);
126
     }
126
     }
127
-    
127
+
128
     /** {@inheritDoc} */
128
     /** {@inheritDoc} */
129
     @Override
129
     @Override
130
     public void onDataOut(final IRCParser tParser, final String sData,
130
     public void onDataOut(final IRCParser tParser, final String sData,
131
             final boolean bFromParser) {
131
             final boolean bFromParser) {
132
         addLine("rawOut", sData);
132
         addLine("rawOut", sData);
133
     }
133
     }
134
-    
134
+
135
     /** {@inheritDoc} */
135
     /** {@inheritDoc} */
136
     @Override
136
     @Override
137
     public String toString() {
137
     public String toString() {
138
         return "Raw";
138
         return "Raw";
139
     }
139
     }
140
-    
140
+
141
     /** {@inheritDoc} */
141
     /** {@inheritDoc} */
142
     @Override
142
     @Override
143
     public Server getServer() {
143
     public Server getServer() {
144
         return server;
144
         return server;
145
     }
145
     }
146
-    
146
+
147
     /** {@inheritDoc} */
147
     /** {@inheritDoc} */
148
     @Override
148
     @Override
149
     public void sendLine(final String line) {
149
     public void sendLine(final String line) {
150
         server.sendLine(window.getTranscoder().encode(line));
150
         server.sendLine(window.getTranscoder().encode(line));
151
     }
151
     }
152
-    
152
+
153
     /** {@inheritDoc} */
153
     /** {@inheritDoc} */
154
     @Override
154
     @Override
155
     public int getMaxLineLength() {
155
     public int getMaxLineLength() {
161
     public ConfigManager getConfigManager() {
161
     public ConfigManager getConfigManager() {
162
         return server.getConfigManager();
162
         return server.getConfigManager();
163
     }
163
     }
164
-    
164
+
165
 }
165
 }

+ 73
- 73
src/com/dmdirc/Server.java Vedi File

113
     private ConfigManager configManager;
113
     private ConfigManager configManager;
114
 
114
 
115
     /** Our reason for being away, if any. */
115
     /** Our reason for being away, if any. */
116
-    private String awayMessage = null;
116
+    private String awayMessage;
117
 
117
 
118
     /** Our event handler. */
118
     /** Our event handler. */
119
     private final ServerEventHandler eventHandler = new ServerEventHandler(this);
119
     private final ServerEventHandler eventHandler = new ServerEventHandler(this);
120
 
120
 
121
     /** A list of outstanding invites. */
121
     /** A list of outstanding invites. */
122
     private final List<Invite> invites = new ArrayList<Invite>();
122
     private final List<Invite> invites = new ArrayList<Invite>();
123
-    
123
+
124
     /** Our ignore list. */
124
     /** Our ignore list. */
125
     private final IgnoreList ignoreList = new IgnoreList();
125
     private final IgnoreList ignoreList = new IgnoreList();
126
-    
126
+
127
     /** Our string convertor. */
127
     /** Our string convertor. */
128
     private IRCStringConverter converter = new IRCStringConverter();
128
     private IRCStringConverter converter = new IRCStringConverter();
129
 
129
 
216
     })
216
     })
217
     public void connect(final String server, final int port, final String password,
217
     public void connect(final String server, final int port, final String password,
218
             final boolean ssl, final Identity profile) {
218
             final boolean ssl, final Identity profile) {
219
-        assert(profile != null);
219
+        assert profile != null;
220
 
220
 
221
-        synchronized(myState) {
221
+        synchronized (myState) {
222
             switch (myState) {
222
             switch (myState) {
223
             case RECONNECT_WAIT:
223
             case RECONNECT_WAIT:
224
                 reconnectTimer.cancel();
224
                 reconnectTimer.cancel();
240
 
240
 
241
         ActionManager.processEvent(CoreActionType.SERVER_CONNECTING, null, this);
241
         ActionManager.processEvent(CoreActionType.SERVER_CONNECTING, null, this);
242
 
242
 
243
-        assert(parser == null || parser.getSocketState() != IRCParser.STATE_OPEN);
243
+        assert parser == null || parser.getSocketState() != IRCParser.STATE_OPEN;
244
 
244
 
245
         serverInfo = new ServerInfo(server, port, password);
245
         serverInfo = new ServerInfo(server, port, password);
246
         serverInfo.setSSL(ssl);
246
         serverInfo.setSSL(ssl);
283
      * @param reason The quit reason to send
283
      * @param reason The quit reason to send
284
      */
284
      */
285
     public void reconnect(final String reason) {
285
     public void reconnect(final String reason) {
286
-        synchronized(myState) {
286
+        synchronized (myState) {
287
             if (myState == ServerState.CLOSING) {
287
             if (myState == ServerState.CLOSING) {
288
                 return;
288
                 return;
289
             }
289
             }
300
     public void reconnect() {
300
     public void reconnect() {
301
         reconnect(configManager.getOption(DOMAIN_GENERAL, "reconnectmessage"));
301
         reconnect(configManager.getOption(DOMAIN_GENERAL, "reconnectmessage"));
302
     }
302
     }
303
-    
303
+
304
     /**
304
     /**
305
      * Disconnects from the server with the default quit message.
305
      * Disconnects from the server with the default quit message.
306
      */
306
      */
314
      * @param reason disconnect reason
314
      * @param reason disconnect reason
315
      */
315
      */
316
     public void disconnect(final String reason) {
316
     public void disconnect(final String reason) {
317
-        synchronized(myState) {
317
+        synchronized (myState) {
318
             switch (myState) {
318
             switch (myState) {
319
             case CLOSING:
319
             case CLOSING:
320
             case DISCONNECTED:
320
             case DISCONNECTED:
361
         reconnectTimer.schedule(new TimerTask() {
361
         reconnectTimer.schedule(new TimerTask() {
362
             @Override
362
             @Override
363
             public void run() {
363
             public void run() {
364
-                synchronized(myState) {
364
+                synchronized (myState) {
365
                     if (myState == ServerState.RECONNECT_WAIT) {
365
                     if (myState == ServerState.RECONNECT_WAIT) {
366
                         myState = ServerState.TRANSIENTLY_DISCONNECTED;
366
                         myState = ServerState.TRANSIENTLY_DISCONNECTED;
367
                         reconnect();
367
                         reconnect();
419
      */
419
      */
420
     public boolean hasQuery(final String host) {
420
     public boolean hasQuery(final String host) {
421
         final String nick = ClientInfo.parseHost(host);
421
         final String nick = ClientInfo.parseHost(host);
422
-        
422
+
423
         for (Query query : queries) {
423
         for (Query query : queries) {
424
             if (parser.equalsIgnoreCase(ClientInfo.parseHost(query.getHost()), nick)) {
424
             if (parser.equalsIgnoreCase(ClientInfo.parseHost(query.getHost()), nick)) {
425
                 return true;
425
                 return true;
426
             }
426
             }
427
         }
427
         }
428
-        
428
+
429
         return false;
429
         return false;
430
     }
430
     }
431
 
431
 
437
      */
437
      */
438
     public Query getQuery(final String host) {
438
     public Query getQuery(final String host) {
439
         final String nick = ClientInfo.parseHost(host);
439
         final String nick = ClientInfo.parseHost(host);
440
-        
440
+
441
         for (Query query : queries) {
441
         for (Query query : queries) {
442
             if (parser.equalsIgnoreCase(ClientInfo.parseHost(query.getHost()), nick)) {
442
             if (parser.equalsIgnoreCase(ClientInfo.parseHost(query.getHost()), nick)) {
443
                 return query;
443
                 return query;
444
             }
444
             }
445
         }
445
         }
446
-        
446
+
447
         throw new IllegalArgumentException("No such query: " + host);
447
         throw new IllegalArgumentException("No such query: " + host);
448
     }
448
     }
449
 
449
 
592
      */
592
      */
593
     private void updateIcon() {
593
     private void updateIcon() {
594
         icon = IconManager.getIconManager().getIcon(
594
         icon = IconManager.getIconManager().getIcon(
595
-                myState == ServerState.CONNECTED ?
596
-                    serverInfo.getSSL() ? "secure-server" : "server" : "server-disconnected");
595
+                myState == ServerState.CONNECTED
596
+                    ? serverInfo.getSSL() ? "secure-server" : "server" : "server-disconnected");
597
         if (window != null) {
597
         if (window != null) {
598
             window.setFrameIcon(icon);
598
             window.setFrameIcon(icon);
599
 
599
 
608
      */
608
      */
609
     @Precondition("The current profile is not null")
609
     @Precondition("The current profile is not null")
610
     private MyInfo getMyInfo() {
610
     private MyInfo getMyInfo() {
611
-        assert(profile != null);
611
+        assert profile != null;
612
 
612
 
613
         final MyInfo myInfo = new MyInfo();
613
         final MyInfo myInfo = new MyInfo();
614
         myInfo.setNickname(profile.getOption(DOMAIN_PROFILE, "nickname"));
614
         myInfo.setNickname(profile.getOption(DOMAIN_PROFILE, "nickname"));
660
     /** {@inheritDoc} */
660
     /** {@inheritDoc} */
661
     @Override
661
     @Override
662
     public void sendLine(final String line) {
662
     public void sendLine(final String line) {
663
-        synchronized(myState) {
663
+        synchronized (myState) {
664
             if (parser != null && myState == ServerState.CONNECTED) {
664
             if (parser != null && myState == ServerState.CONNECTED) {
665
                 parser.sendLine(window.getTranscoder().encode(line));
665
                 parser.sendLine(window.getTranscoder().encode(line));
666
             }
666
             }
823
     public void windowClosing() {
823
     public void windowClosing() {
824
         // 1: Make the window non-visible
824
         // 1: Make the window non-visible
825
         window.setVisible(false);
825
         window.setVisible(false);
826
-        
826
+
827
         // 2: Remove any callbacks or listeners
827
         // 2: Remove any callbacks or listeners
828
         eventHandler.unregisterCallbacks();
828
         eventHandler.unregisterCallbacks();
829
-        
829
+
830
         // 3: Trigger any actions neccessary
830
         // 3: Trigger any actions neccessary
831
         if (parser != null && parser.isReady()) {
831
         if (parser != null && parser.isReady()) {
832
             disconnect();
832
             disconnect();
833
         }
833
         }
834
-        
834
+
835
         myState = ServerState.CLOSING;
835
         myState = ServerState.CLOSING;
836
         closeChannels();
836
         closeChannels();
837
         closeQueries();
837
         closeQueries();
840
         if (raw != null) {
840
         if (raw != null) {
841
             raw.close();
841
             raw.close();
842
         }
842
         }
843
-        
844
-        
843
+
844
+
845
         // 4: Trigger action for the window closing
845
         // 4: Trigger action for the window closing
846
         // 5: Inform any parents that the window is closing
846
         // 5: Inform any parents that the window is closing
847
         ServerManager.getServerManager().unregisterServer(this);
847
         ServerManager.getServerManager().unregisterServer(this);
848
-        
848
+
849
         // 6: Remove the window from the window manager
849
         // 6: Remove the window from the window manager
850
         WindowManager.removeWindow(window);
850
         WindowManager.removeWindow(window);
851
-        
851
+
852
         // 7: Remove any references to the window and parents
852
         // 7: Remove any references to the window and parents
853
         window = null; //NOPMD
853
         window = null; //NOPMD
854
         parser = null; //NOPMD
854
         parser = null; //NOPMD
942
      * @return True if the channel name is valid, false otherwise
942
      * @return True if the channel name is valid, false otherwise
943
      */
943
      */
944
     public boolean isValidChannelName(final String channelName) {
944
     public boolean isValidChannelName(final String channelName) {
945
-        return hasChannel(channelName) ||
946
-                (parser != null && parser.isValidChannelName(channelName));
945
+        return hasChannel(channelName)
946
+                || (parser != null && parser.isValidChannelName(channelName));
947
     }
947
     }
948
 
948
 
949
     /**
949
     /**
979
             return super.processNotificationArg(arg, args);
979
             return super.processNotificationArg(arg, args);
980
         }
980
         }
981
     }
981
     }
982
-    
982
+
983
     /**
983
     /**
984
      * Retusnt the list of invites for this server.
984
      * Retusnt the list of invites for this server.
985
-     * 
985
+     *
986
      * @return Invite list
986
      * @return Invite list
987
      */
987
      */
988
     public List<Invite> getInvites() {
988
     public List<Invite> getInvites() {
1069
      */
1069
      */
1070
     public void onSocketClosed() {
1070
     public void onSocketClosed() {
1071
         handleNotification("socketClosed", getName());
1071
         handleNotification("socketClosed", getName());
1072
-        
1073
-        ActionManager.processEvent(CoreActionType.SERVER_DISCONNECTED, null, this);        
1074
 
1072
 
1075
-        synchronized(myState) {
1073
+        ActionManager.processEvent(CoreActionType.SERVER_DISCONNECTED, null, this);
1074
+
1075
+        synchronized (myState) {
1076
             if (myState == ServerState.CLOSING || myState == ServerState.DISCONNECTED) {
1076
             if (myState == ServerState.CLOSING || myState == ServerState.DISCONNECTED) {
1077
                 // This has been triggered via .disconect()
1077
                 // This has been triggered via .disconect()
1078
                 return;
1078
                 return;
1092
         if (configManager.getOptionBool(DOMAIN_GENERAL, "closequeriesondisconnect", false)) {
1092
         if (configManager.getOptionBool(DOMAIN_GENERAL, "closequeriesondisconnect", false)) {
1093
             closeQueries();
1093
             closeQueries();
1094
         }
1094
         }
1095
-        
1095
+
1096
         removeInvites();
1096
         removeInvites();
1097
 
1097
 
1098
         if (configManager.getOptionBool(DOMAIN_GENERAL, "reconnectondisconnect", false)) {
1098
         if (configManager.getOptionBool(DOMAIN_GENERAL, "reconnectondisconnect", false)) {
1107
      */
1107
      */
1108
     @Precondition("The current server state is CONNECTING")
1108
     @Precondition("The current server state is CONNECTING")
1109
     public void onConnectError(final ParserError errorInfo) {
1109
     public void onConnectError(final ParserError errorInfo) {
1110
-        synchronized(myState) {
1110
+        synchronized (myState) {
1111
             if (myState == ServerState.CLOSING) {
1111
             if (myState == ServerState.CLOSING) {
1112
                 // Do nothing
1112
                 // Do nothing
1113
                 return;
1113
                 return;
1114
             }
1114
             }
1115
-            
1116
-            assert(myState == ServerState.CONNECTING);
1115
+
1116
+            assert myState == ServerState.CONNECTING;
1117
             myState = ServerState.TRANSIENTLY_DISCONNECTED;
1117
             myState = ServerState.TRANSIENTLY_DISCONNECTED;
1118
         }
1118
         }
1119
 
1119
 
1160
         ActionManager.processEvent(CoreActionType.SERVER_NOPING, null, this,
1160
         ActionManager.processEvent(CoreActionType.SERVER_NOPING, null, this,
1161
                 Long.valueOf(parser.getPingTime(false)));
1161
                 Long.valueOf(parser.getPingTime(false)));
1162
 
1162
 
1163
-        if (parser.getPingTime(false) >=
1164
-                configManager.getOptionInt(DOMAIN_SERVER, "pingtimeout", 60000)) {
1163
+        if (parser.getPingTime(false)
1164
+                 >= configManager.getOptionInt(DOMAIN_SERVER, "pingtimeout", 60000)) {
1165
             handleNotification("stonedServer", getName());
1165
             handleNotification("stonedServer", getName());
1166
             reconnect();
1166
             reconnect();
1167
         }
1167
         }
1171
      * Called after the parser receives the 005 headers from the server.
1171
      * Called after the parser receives the 005 headers from the server.
1172
      */
1172
      */
1173
     public void onPost005() {
1173
     public void onPost005() {
1174
-        synchronized(myState) {
1174
+        synchronized (myState) {
1175
             myState = ServerState.CONNECTED;
1175
             myState = ServerState.CONNECTED;
1176
         }
1176
         }
1177
         updateIcon();
1177
         updateIcon();
1178
 
1178
 
1179
         configManager = new ConfigManager(parser.getIRCD(true), getNetwork(), getName());
1179
         configManager = new ConfigManager(parser.getIRCD(true), getNetwork(), getName());
1180
         updateIgnoreList();
1180
         updateIgnoreList();
1181
-        
1181
+
1182
         converter = parser.getIRCStringConverter();
1182
         converter = parser.getIRCStringConverter();
1183
 
1183
 
1184
         ActionManager.processEvent(CoreActionType.SERVER_CONNECTED, null, this);
1184
         ActionManager.processEvent(CoreActionType.SERVER_CONNECTED, null, this);
1195
 
1195
 
1196
         checkModeAliases();
1196
         checkModeAliases();
1197
     }
1197
     }
1198
-    
1198
+
1199
     /**
1199
     /**
1200
      * Checks that we have the neccessary mode aliases for this server.
1200
      * Checks that we have the neccessary mode aliases for this server.
1201
      */
1201
      */
1213
                 missingModes.append(mode);
1213
                 missingModes.append(mode);
1214
             }
1214
             }
1215
         }
1215
         }
1216
-        
1216
+
1217
         for (char mode : umodes.toCharArray()) {
1217
         for (char mode : umodes.toCharArray()) {
1218
             if (!configManager.hasOption(DOMAIN_SERVER, "umode" + mode)) {
1218
             if (!configManager.hasOption(DOMAIN_SERVER, "umode" + mode)) {
1219
                 missingUmodes.append(mode);
1219
                 missingUmodes.append(mode);
1220
             }
1220
             }
1221
         }
1221
         }
1222
-        
1222
+
1223
         if (missingModes.length() + missingUmodes.length() > 0) {
1223
         if (missingModes.length() + missingUmodes.length() > 0) {
1224
             final StringBuffer missing = new StringBuffer("Missing mode aliases: ");
1224
             final StringBuffer missing = new StringBuffer("Missing mode aliases: ");
1225
-            
1225
+
1226
             if (missingModes.length() > 0) {
1226
             if (missingModes.length() > 0) {
1227
                 missing.append("channel: +");
1227
                 missing.append("channel: +");
1228
                 missing.append(missingModes);
1228
                 missing.append(missingModes);
1229
             }
1229
             }
1230
-            
1230
+
1231
             if (missingUmodes.length() > 0) {
1231
             if (missingUmodes.length() > 0) {
1232
                 if (missingModes.length() > 0) {
1232
                 if (missingModes.length() > 0) {
1233
                     missing.append(' ');
1233
                     missing.append(' ');
1234
                 }
1234
                 }
1235
-                
1235
+
1236
                 missing.append("user: +");
1236
                 missing.append("user: +");
1237
                 missing.append(missingUmodes);
1237
                 missing.append(missingUmodes);
1238
             }
1238
             }
1239
-            
1239
+
1240
             Logger.appError(ErrorLevel.LOW, missing.toString() + " ["
1240
             Logger.appError(ErrorLevel.LOW, missing.toString() + " ["
1241
                     + getNetwork() + "]",
1241
                     + getNetwork() + "]",
1242
                     new Exception(missing.toString() + "\n" // NOPMD
1242
                     new Exception(missing.toString() + "\n" // NOPMD
1248
                     + "\n\n"));
1248
                     + "\n\n"));
1249
         }
1249
         }
1250
     }
1250
     }
1251
-   
1251
+
1252
     // ---------------------------------------------- IGNORE LIST HANDLING -----
1252
     // ---------------------------------------------- IGNORE LIST HANDLING -----
1253
-    
1253
+
1254
     /**
1254
     /**
1255
      * Retrieves this server's ignore list.
1255
      * Retrieves this server's ignore list.
1256
-     * 
1256
+     *
1257
      * @return This server's ignore list
1257
      * @return This server's ignore list
1258
      */
1258
      */
1259
     public IgnoreList getIgnoreList() {
1259
     public IgnoreList getIgnoreList() {
1260
         return ignoreList;
1260
         return ignoreList;
1261
     }
1261
     }
1262
-    
1262
+
1263
     /**
1263
     /**
1264
      * Updates this server's ignore list to use the entries stored in the
1264
      * Updates this server's ignore list to use the entries stored in the
1265
      * config manager.
1265
      * config manager.
1268
         ignoreList.clear();
1268
         ignoreList.clear();
1269
         ignoreList.addAll(configManager.getOptionList("network", "ignorelist"));
1269
         ignoreList.addAll(configManager.getOptionList("network", "ignorelist"));
1270
     }
1270
     }
1271
-    
1271
+
1272
     /**
1272
     /**
1273
      * Saves the contents of our ignore list to the network identity.
1273
      * Saves the contents of our ignore list to the network identity.
1274
      */
1274
      */
1275
     public void saveIgnoreList() {
1275
     public void saveIgnoreList() {
1276
         getNetworkIdentity().setOption("network", "ignorelist", ignoreList.getRegexList());
1276
         getNetworkIdentity().setOption("network", "ignorelist", ignoreList.getRegexList());
1277
-    }    
1278
-    
1277
+    }
1278
+
1279
     // ------------------------------------------------- IDENTITY WRAPPERS -----
1279
     // ------------------------------------------------- IDENTITY WRAPPERS -----
1280
-    
1280
+
1281
     /**
1281
     /**
1282
      * Retrieves the identity for this server.
1282
      * Retrieves the identity for this server.
1283
-     * 
1283
+     *
1284
      * @return This server's identity
1284
      * @return This server's identity
1285
      */
1285
      */
1286
     public Identity getServerIdentity() {
1286
     public Identity getServerIdentity() {
1289
 
1289
 
1290
     /**
1290
     /**
1291
      * Retrieves the identity for this server's network.
1291
      * Retrieves the identity for this server's network.
1292
-     * 
1292
+     *
1293
      * @return This server's network identity
1293
      * @return This server's network identity
1294
-     */    
1294
+     */
1295
     public Identity getNetworkIdentity() {
1295
     public Identity getNetworkIdentity() {
1296
         return IdentityManager.getNetworkConfig(getNetwork());
1296
         return IdentityManager.getNetworkConfig(getNetwork());
1297
     }
1297
     }
1322
      * @param invite The invite to be added
1322
      * @param invite The invite to be added
1323
      */
1323
      */
1324
     public void addInvite(final Invite invite) {
1324
     public void addInvite(final Invite invite) {
1325
-        synchronized(invites) {
1325
+        synchronized (invites) {
1326
             for (Invite oldInvite : new ArrayList<Invite>(invites)) {
1326
             for (Invite oldInvite : new ArrayList<Invite>(invites)) {
1327
                 if (oldInvite.getChannel().equals(invite.getChannel())) {
1327
                 if (oldInvite.getChannel().equals(invite.getChannel())) {
1328
                     removeInvite(oldInvite);
1328
                     removeInvite(oldInvite);
1336
             }
1336
             }
1337
         }
1337
         }
1338
     }
1338
     }
1339
-    
1339
+
1340
     /**
1340
     /**
1341
      * Removes all invites for the specified channel.
1341
      * Removes all invites for the specified channel.
1342
-     * 
1342
+     *
1343
      * @param channel The channel to remove invites for
1343
      * @param channel The channel to remove invites for
1344
      */
1344
      */
1345
     public void removeInvites(final String channel) {
1345
     public void removeInvites(final String channel) {
1349
             }
1349
             }
1350
         }
1350
         }
1351
     }
1351
     }
1352
-    
1352
+
1353
     /**
1353
     /**
1354
      * Removes all invites for all channels.
1354
      * Removes all invites for all channels.
1355
      */
1355
      */
1357
         for (Invite invite : new ArrayList<Invite>(invites)) {
1357
         for (Invite invite : new ArrayList<Invite>(invites)) {
1358
             removeInvite(invite);
1358
             removeInvite(invite);
1359
         }
1359
         }
1360
-    }    
1360
+    }
1361
 
1361
 
1362
     /**
1362
     /**
1363
      * Removes an invite from this server, and fires the appropriate listeners.
1363
      * Removes an invite from this server, and fires the appropriate listeners.
1365
      * @param invite The invite to be removed
1365
      * @param invite The invite to be removed
1366
      */
1366
      */
1367
     public void removeInvite(final Invite invite) {
1367
     public void removeInvite(final Invite invite) {
1368
-        synchronized(invites) {
1368
+        synchronized (invites) {
1369
             invites.remove(invite);
1369
             invites.remove(invite);
1370
 
1370
 
1371
             for (InviteListener listener : listeners.get(InviteListener.class)) {
1371
             for (InviteListener listener : listeners.get(InviteListener.class)) {
1373
             }
1373
             }
1374
         }
1374
         }
1375
     }
1375
     }
1376
-    
1376
+
1377
     // ----------------------------------------------- AWAY STATE HANDLING -----
1377
     // ----------------------------------------------- AWAY STATE HANDLING -----
1378
-    
1378
+
1379
     /**
1379
     /**
1380
      * Adds an away state lisener to this server.
1380
      * Adds an away state lisener to this server.
1381
-     * 
1381
+     *
1382
      * @param listener The listener to be added
1382
      * @param listener The listener to be added
1383
      */
1383
      */
1384
     public void addAwayStateListener(final AwayStateListener listener) {
1384
     public void addAwayStateListener(final AwayStateListener listener) {
1385
         listeners.add(AwayStateListener.class, listener);
1385
         listeners.add(AwayStateListener.class, listener);
1386
     }
1386
     }
1387
-    
1387
+
1388
     /**
1388
     /**
1389
      * Removes an away state lisener from this server.
1389
      * Removes an away state lisener from this server.
1390
-     * 
1390
+     *
1391
      * @param listener The listener to be removed
1391
      * @param listener The listener to be removed
1392
      */
1392
      */
1393
     public void removeAwayStateListener(final AwayStateListener listener) {
1393
     public void removeAwayStateListener(final AwayStateListener listener) {
1394
         listeners.remove(AwayStateListener.class, listener);
1394
         listeners.remove(AwayStateListener.class, listener);
1395
     }
1395
     }
1396
-    
1396
+
1397
     /**
1397
     /**
1398
      * Updates our away state and fires the relevant listeners.
1398
      * Updates our away state and fires the relevant listeners.
1399
-     * 
1399
+     *
1400
      * @param message The away message to use, or null if we're not away.
1400
      * @param message The away message to use, or null if we're not away.
1401
      */
1401
      */
1402
     public void updateAwayState(final String message) {
1402
     public void updateAwayState(final String message) {
1403
         awayMessage = message;
1403
         awayMessage = message;
1404
-        
1404
+
1405
         if (message == null) {
1405
         if (message == null) {
1406
             for (AwayStateListener listener : listeners.get(AwayStateListener.class)) {
1406
             for (AwayStateListener listener : listeners.get(AwayStateListener.class)) {
1407
                 listener.onBack();
1407
                 listener.onBack();
1409
         } else {
1409
         } else {
1410
             for (AwayStateListener listener : listeners.get(AwayStateListener.class)) {
1410
             for (AwayStateListener listener : listeners.get(AwayStateListener.class)) {
1411
                 listener.onAway(message);
1411
                 listener.onAway(message);
1412
-            }            
1412
+            }
1413
         }
1413
         }
1414
     }
1414
     }
1415
 
1415
 

+ 63
- 63
src/com/dmdirc/ServerEventHandler.java Vedi File

40
  * @author chris
40
  * @author chris
41
  */
41
  */
42
 public final class ServerEventHandler extends EventHandler
42
 public final class ServerEventHandler extends EventHandler
43
-        implements IChannelSelfJoin, IPrivateMessage, IPrivateAction, 
44
-        IErrorInfo, IPrivateCTCP, IPrivateCTCPReply, ISocketClosed, 
43
+        implements IChannelSelfJoin, IPrivateMessage, IPrivateAction,
44
+        IErrorInfo, IPrivateCTCP, IPrivateCTCPReply, ISocketClosed,
45
         IPrivateNotice, IMOTDStart, IMOTDLine, IMOTDEnd, INumeric, IPingFailed,
45
         IPrivateNotice, IMOTDStart, IMOTDLine, IMOTDEnd, INumeric, IPingFailed,
46
         IPingSuccess, IAwayState, IConnectError, INickInUse, IPost005,
46
         IPingSuccess, IAwayState, IConnectError, INickInUse, IPost005,
47
         INoticeAuth, IUnknownNotice, IUserModeChanged, IInvite, IWallop,
47
         INoticeAuth, IUnknownNotice, IUserModeChanged, IInvite, IWallop,
48
         IWalluser, IWallDesync, INickChanged, IServerError, IPingSent,
48
         IWalluser, IWallDesync, INickChanged, IServerError, IPingSent,
49
         IUserModeDiscovered {
49
         IUserModeDiscovered {
50
-    
50
+
51
     /** The server instance that owns this event handler. */
51
     /** The server instance that owns this event handler. */
52
     private final Server owner;
52
     private final Server owner;
53
-    
53
+
54
     /**
54
     /**
55
      * Creates a new instance of ServerEventHandler.
55
      * Creates a new instance of ServerEventHandler.
56
      *
56
      *
58
      */
58
      */
59
     public ServerEventHandler(final Server owner) {
59
     public ServerEventHandler(final Server owner) {
60
         super();
60
         super();
61
-        
61
+
62
         this.owner = owner;
62
         this.owner = owner;
63
     }
63
     }
64
-    
64
+
65
     /** {@inheritDoc} */
65
     /** {@inheritDoc} */
66
     @Override
66
     @Override
67
     protected void addCallback(final CallbackManager cbm, final String name)
67
     protected void addCallback(final CallbackManager cbm, final String name)
68
             throws CallbackNotFoundException {
68
             throws CallbackNotFoundException {
69
         cbm.addCallback(name, this);
69
         cbm.addCallback(name, this);
70
     }
70
     }
71
-    
71
+
72
     /** {@inheritDoc} */
72
     /** {@inheritDoc} */
73
     @Override
73
     @Override
74
     protected IRCParser getParser() {
74
     protected IRCParser getParser() {
75
         return owner.getParser();
75
         return owner.getParser();
76
     }
76
     }
77
-          
77
+
78
     /** {@inheritDoc} */
78
     /** {@inheritDoc} */
79
     @Override
79
     @Override
80
     public void onChannelSelfJoin(final IRCParser tParser, final ChannelInfo cChannel) {
80
     public void onChannelSelfJoin(final IRCParser tParser, final ChannelInfo cChannel) {
81
         checkParser(tParser);
81
         checkParser(tParser);
82
         owner.addChannel(cChannel);
82
         owner.addChannel(cChannel);
83
     }
83
     }
84
-    
84
+
85
     /** {@inheritDoc} */
85
     /** {@inheritDoc} */
86
     @Override
86
     @Override
87
     public void onPrivateMessage(final IRCParser tParser, final String sMessage,
87
     public void onPrivateMessage(final IRCParser tParser, final String sMessage,
89
         checkParser(tParser);
89
         checkParser(tParser);
90
         owner.addQuery(sHost);
90
         owner.addQuery(sHost);
91
     }
91
     }
92
-    
92
+
93
     /** {@inheritDoc} */
93
     /** {@inheritDoc} */
94
     @Override
94
     @Override
95
     public void onPrivateAction(final IRCParser tParser, final String sMessage,
95
     public void onPrivateAction(final IRCParser tParser, final String sMessage,
97
         checkParser(tParser);
97
         checkParser(tParser);
98
         owner.addQuery(sHost);
98
         owner.addQuery(sHost);
99
     }
99
     }
100
-    
100
+
101
     /** {@inheritDoc} */
101
     /** {@inheritDoc} */
102
     @Override
102
     @Override
103
     public void onErrorInfo(final IRCParser tParser, final ParserError errorInfo) {
103
     public void onErrorInfo(final IRCParser tParser, final ParserError errorInfo) {
104
         checkParser(tParser);
104
         checkParser(tParser);
105
-        
105
+
106
         final ErrorLevel errorLevel = ErrorLevel.UNKNOWN;
106
         final ErrorLevel errorLevel = ErrorLevel.UNKNOWN;
107
-        
107
+
108
         if (errorInfo.isException()) {
108
         if (errorInfo.isException()) {
109
-            Logger.appError(errorLevel, errorInfo.getData(), 
109
+            Logger.appError(errorLevel, errorInfo.getData(),
110
                     new Exception("Parser exception with line:\t"
110
                     new Exception("Parser exception with line:\t"
111
                     + errorInfo.getLastLine(), errorInfo.getException()));
111
                     + errorInfo.getLastLine(), errorInfo.getException()));
112
         } else {
112
         } else {
115
                     + errorInfo.getLastLine() + "\n\tServer:\t" + owner.getName() + "\n"));
115
                     + errorInfo.getLastLine() + "\n\tServer:\t" + owner.getName() + "\n"));
116
         }
116
         }
117
     }
117
     }
118
-    
118
+
119
     /** {@inheritDoc} */
119
     /** {@inheritDoc} */
120
     @Override
120
     @Override
121
     public void onPrivateCTCP(final IRCParser tParser, final String sType,
121
     public void onPrivateCTCP(final IRCParser tParser, final String sType,
123
         checkParser(tParser);
123
         checkParser(tParser);
124
 
124
 
125
         owner.doNotification("privateCTCP", CoreActionType.SERVER_CTCP,
125
         owner.doNotification("privateCTCP", CoreActionType.SERVER_CTCP,
126
-                tParser.getClientInfoOrFake(sHost), sType, sMessage);        
127
-        
126
+                tParser.getClientInfoOrFake(sHost), sType, sMessage);
127
+
128
         owner.sendCTCPReply(ClientInfo.parseHost(sHost), sType, sMessage);
128
         owner.sendCTCPReply(ClientInfo.parseHost(sHost), sType, sMessage);
129
     }
129
     }
130
-    
130
+
131
     /** {@inheritDoc} */
131
     /** {@inheritDoc} */
132
     @Override
132
     @Override
133
     public void onPrivateCTCPReply(final IRCParser tParser, final String sType,
133
     public void onPrivateCTCPReply(final IRCParser tParser, final String sType,
134
             final String sMessage, final String sHost) {
134
             final String sMessage, final String sHost) {
135
         checkParser(tParser);
135
         checkParser(tParser);
136
-        
136
+
137
         owner.doNotification("privateCTCPreply", CoreActionType.SERVER_CTCPR,
137
         owner.doNotification("privateCTCPreply", CoreActionType.SERVER_CTCPR,
138
                 tParser.getClientInfoOrFake(sHost), sType, sMessage);
138
                 tParser.getClientInfoOrFake(sHost), sType, sMessage);
139
     }
139
     }
140
-    
140
+
141
     /** {@inheritDoc} */
141
     /** {@inheritDoc} */
142
     @Override
142
     @Override
143
     public void onSocketClosed(final IRCParser tParser) {
143
     public void onSocketClosed(final IRCParser tParser) {
144
         checkParser(tParser);
144
         checkParser(tParser);
145
         owner.onSocketClosed();
145
         owner.onSocketClosed();
146
     }
146
     }
147
-    
147
+
148
     /** {@inheritDoc} */
148
     /** {@inheritDoc} */
149
     @Override
149
     @Override
150
     public void onPrivateNotice(final IRCParser tParser, final String sMessage,
150
     public void onPrivateNotice(final IRCParser tParser, final String sMessage,
151
             final String sHost) {
151
             final String sHost) {
152
         checkParser(tParser);
152
         checkParser(tParser);
153
-        
153
+
154
         owner.doNotification("privateNotice", CoreActionType.SERVER_NOTICE,
154
         owner.doNotification("privateNotice", CoreActionType.SERVER_NOTICE,
155
                 tParser.getClientInfoOrFake(sHost), sMessage);
155
                 tParser.getClientInfoOrFake(sHost), sMessage);
156
     }
156
     }
157
-    
157
+
158
     /** {@inheritDoc} */
158
     /** {@inheritDoc} */
159
     @Override
159
     @Override
160
     public void onMOTDStart(final IRCParser tParser, final String sData) {
160
     public void onMOTDStart(final IRCParser tParser, final String sData) {
161
         checkParser(tParser);
161
         checkParser(tParser);
162
-        
162
+
163
         owner.doNotification("motdStart", CoreActionType.SERVER_MOTDSTART, sData);
163
         owner.doNotification("motdStart", CoreActionType.SERVER_MOTDSTART, sData);
164
     }
164
     }
165
-    
165
+
166
     /** {@inheritDoc} */
166
     /** {@inheritDoc} */
167
     @Override
167
     @Override
168
     public void onMOTDLine(final IRCParser tParser, final String sData) {
168
     public void onMOTDLine(final IRCParser tParser, final String sData) {
169
         checkParser(tParser);
169
         checkParser(tParser);
170
-        
170
+
171
         owner.doNotification("motdLine", CoreActionType.SERVER_MOTDLINE, sData);
171
         owner.doNotification("motdLine", CoreActionType.SERVER_MOTDLINE, sData);
172
     }
172
     }
173
-    
173
+
174
     /** {@inheritDoc} */
174
     /** {@inheritDoc} */
175
     @Override
175
     @Override
176
     public void onMOTDEnd(final IRCParser tParser, final boolean noMOTD, final String sData) {
176
     public void onMOTDEnd(final IRCParser tParser, final boolean noMOTD, final String sData) {
177
         checkParser(tParser);
177
         checkParser(tParser);
178
-        
178
+
179
         owner.doNotification("motdEnd", CoreActionType.SERVER_MOTDEND, sData);
179
         owner.doNotification("motdEnd", CoreActionType.SERVER_MOTDEND, sData);
180
     }
180
     }
181
-    
181
+
182
     /** {@inheritDoc} */
182
     /** {@inheritDoc} */
183
     @Override
183
     @Override
184
     public void onNumeric(final IRCParser tParser, final int numeric,
184
     public void onNumeric(final IRCParser tParser, final int numeric,
186
         checkParser(tParser);
186
         checkParser(tParser);
187
         owner.onNumeric(numeric, token);
187
         owner.onNumeric(numeric, token);
188
     }
188
     }
189
-    
189
+
190
     /** {@inheritDoc} */
190
     /** {@inheritDoc} */
191
     @Override
191
     @Override
192
     public void onPingFailed(final IRCParser tParser) {
192
     public void onPingFailed(final IRCParser tParser) {
193
         checkParser(tParser);
193
         checkParser(tParser);
194
         owner.onPingFailed();
194
         owner.onPingFailed();
195
     }
195
     }
196
-    
196
+
197
     /** {@inheritDoc} */
197
     /** {@inheritDoc} */
198
     @Override
198
     @Override
199
     public void onPingSent(final IRCParser tParser) {
199
     public void onPingSent(final IRCParser tParser) {
200
         checkParser(tParser);
200
         checkParser(tParser);
201
-        
201
+
202
         ActionManager.processEvent(CoreActionType.SERVER_PINGSENT, null, owner);
202
         ActionManager.processEvent(CoreActionType.SERVER_PINGSENT, null, owner);
203
-    }    
204
-    
203
+    }
204
+
205
     /** {@inheritDoc} */
205
     /** {@inheritDoc} */
206
     @Override
206
     @Override
207
     public void onPingSuccess(final IRCParser tParser) {
207
     public void onPingSuccess(final IRCParser tParser) {
208
         checkParser(tParser);
208
         checkParser(tParser);
209
-        
209
+
210
         ActionManager.processEvent(CoreActionType.SERVER_GOTPING, null, owner,
210
         ActionManager.processEvent(CoreActionType.SERVER_GOTPING, null, owner,
211
                 Long.valueOf(tParser.getServerLag()));
211
                 Long.valueOf(tParser.getServerLag()));
212
     }
212
     }
213
-    
213
+
214
     /** {@inheritDoc} */
214
     /** {@inheritDoc} */
215
     @Override
215
     @Override
216
     public void onAwayState(final IRCParser tParser, final boolean currentState,
216
     public void onAwayState(final IRCParser tParser, final boolean currentState,
217
             final String reason) {
217
             final String reason) {
218
         checkParser(tParser);
218
         checkParser(tParser);
219
-        
219
+
220
         owner.updateAwayState(currentState ? reason : null);
220
         owner.updateAwayState(currentState ? reason : null);
221
-        
221
+
222
         if (currentState) {
222
         if (currentState) {
223
             owner.doNotification("away", CoreActionType.SERVER_AWAY, reason);
223
             owner.doNotification("away", CoreActionType.SERVER_AWAY, reason);
224
         } else {
224
         } else {
225
             owner.doNotification("back", CoreActionType.SERVER_BACK);
225
             owner.doNotification("back", CoreActionType.SERVER_BACK);
226
         }
226
         }
227
     }
227
     }
228
-    
228
+
229
     /** {@inheritDoc} */
229
     /** {@inheritDoc} */
230
     @Override
230
     @Override
231
     public void onConnectError(final IRCParser tParser, final ParserError errorInfo) {
231
     public void onConnectError(final IRCParser tParser, final ParserError errorInfo) {
232
         checkParser(tParser);
232
         checkParser(tParser);
233
         owner.onConnectError(errorInfo);
233
         owner.onConnectError(errorInfo);
234
     }
234
     }
235
-    
235
+
236
     /** {@inheritDoc} */
236
     /** {@inheritDoc} */
237
     @Override
237
     @Override
238
     public void onNickInUse(final IRCParser tParser, final String nickname) {
238
     public void onNickInUse(final IRCParser tParser, final String nickname) {
239
         owner.onNickInUse(nickname);
239
         owner.onNickInUse(nickname);
240
         checkParser(tParser);
240
         checkParser(tParser);
241
     }
241
     }
242
-    
242
+
243
     /** {@inheritDoc} */
243
     /** {@inheritDoc} */
244
     @Override
244
     @Override
245
     public void onPost005(final IRCParser tParser) {
245
     public void onPost005(final IRCParser tParser) {
246
         checkParser(tParser);
246
         checkParser(tParser);
247
         owner.onPost005();
247
         owner.onPost005();
248
     }
248
     }
249
-    
249
+
250
     /** {@inheritDoc} */
250
     /** {@inheritDoc} */
251
     @Override
251
     @Override
252
     public void onNoticeAuth(final IRCParser tParser, final String sData) {
252
     public void onNoticeAuth(final IRCParser tParser, final String sData) {
253
         checkParser(tParser);
253
         checkParser(tParser);
254
-        
254
+
255
         owner.doNotification("authNotice", CoreActionType.SERVER_AUTHNOTICE, sData);
255
         owner.doNotification("authNotice", CoreActionType.SERVER_AUTHNOTICE, sData);
256
     }
256
     }
257
-    
257
+
258
     /** {@inheritDoc} */
258
     /** {@inheritDoc} */
259
     @Override
259
     @Override
260
     public void onUnknownNotice(final IRCParser tParser, final String sMessage,
260
     public void onUnknownNotice(final IRCParser tParser, final String sMessage,
264
         owner.doNotification("unknownNotice", CoreActionType.SERVER_UNKNOWNNOTICE,
264
         owner.doNotification("unknownNotice", CoreActionType.SERVER_UNKNOWNNOTICE,
265
                 sHost, sTarget, sMessage);
265
                 sHost, sTarget, sMessage);
266
     }
266
     }
267
-    
267
+
268
     /** {@inheritDoc} */
268
     /** {@inheritDoc} */
269
     @Override
269
     @Override
270
     public void onUserModeChanged(final IRCParser tParser,
270
     public void onUserModeChanged(final IRCParser tParser,
271
             final ClientInfo cClient, final String sSetBy, final String sModes) {
271
             final ClientInfo cClient, final String sSetBy, final String sModes) {
272
         checkParser(tParser);
272
         checkParser(tParser);
273
-        
273
+
274
         owner.doNotification("userModeChanged", CoreActionType.SERVER_USERMODES,
274
         owner.doNotification("userModeChanged", CoreActionType.SERVER_USERMODES,
275
                 tParser.getClientInfoOrFake(sSetBy), sModes);
275
                 tParser.getClientInfoOrFake(sSetBy), sModes);
276
     }
276
     }
280
     public void onUserModeDiscovered(final IRCParser tParser, final ClientInfo cClient,
280
     public void onUserModeDiscovered(final IRCParser tParser, final ClientInfo cClient,
281
              final String sModes) {
281
              final String sModes) {
282
         checkParser(tParser);
282
         checkParser(tParser);
283
-        
283
+
284
         owner.doNotification("userModeDiscovered", CoreActionType.SERVER_USERMODES,
284
         owner.doNotification("userModeDiscovered", CoreActionType.SERVER_USERMODES,
285
-                cClient, sModes);        
285
+                cClient, sModes);
286
     }
286
     }
287
 
287
 
288
     /** {@inheritDoc} */
288
     /** {@inheritDoc} */
290
     public void onInvite(final IRCParser tParser, final String userHost,
290
     public void onInvite(final IRCParser tParser, final String userHost,
291
             final String channel) {
291
             final String channel) {
292
         checkParser(tParser);
292
         checkParser(tParser);
293
-        
293
+
294
         owner.addInvite(new Invite(owner, channel, userHost));
294
         owner.addInvite(new Invite(owner, channel, userHost));
295
         owner.doNotification("inviteReceived",
295
         owner.doNotification("inviteReceived",
296
-                CoreActionType.SERVER_INVITERECEIVED, 
296
+                CoreActionType.SERVER_INVITERECEIVED,
297
                 tParser.getClientInfoOrFake(userHost), channel);
297
                 tParser.getClientInfoOrFake(userHost), channel);
298
     }
298
     }
299
 
299
 
300
     /** {@inheritDoc} */
300
     /** {@inheritDoc} */
301
     @Override
301
     @Override
302
-    public void onWallop(final IRCParser tParser, final String sMessage, 
302
+    public void onWallop(final IRCParser tParser, final String sMessage,
303
             final String sHost) {
303
             final String sHost) {
304
         checkParser(tParser);
304
         checkParser(tParser);
305
-        
306
-        owner.doNotification("wallop", CoreActionType.SERVER_WALLOPS, 
305
+
306
+        owner.doNotification("wallop", CoreActionType.SERVER_WALLOPS,
307
                 tParser.getClientInfoOrFake(sHost), sMessage);
307
                 tParser.getClientInfoOrFake(sHost), sMessage);
308
-        
308
+
309
     }
309
     }
310
 
310
 
311
     /** {@inheritDoc} */
311
     /** {@inheritDoc} */
312
-    @Override    
313
-    public void onWalluser(final IRCParser tParser, final String sMessage, 
312
+    @Override
313
+    public void onWalluser(final IRCParser tParser, final String sMessage,
314
             final String sHost) {
314
             final String sHost) {
315
         checkParser(tParser);
315
         checkParser(tParser);
316
 
316
 
317
-        owner.doNotification("walluser", CoreActionType.SERVER_WALLUSERS, 
317
+        owner.doNotification("walluser", CoreActionType.SERVER_WALLUSERS,
318
                 tParser.getClientInfoOrFake(sHost), sMessage);
318
                 tParser.getClientInfoOrFake(sHost), sMessage);
319
     }
319
     }
320
 
320
 
321
     /** {@inheritDoc} */
321
     /** {@inheritDoc} */
322
-    @Override    
323
-    public void onWallDesync(final IRCParser tParser, final String sMessage, 
322
+    @Override
323
+    public void onWallDesync(final IRCParser tParser, final String sMessage,
324
             final String sHost) {
324
             final String sHost) {
325
         checkParser(tParser);
325
         checkParser(tParser);
326
-        
327
-        owner.doNotification("walldesync", CoreActionType.SERVER_WALLDESYNC, 
326
+
327
+        owner.doNotification("walldesync", CoreActionType.SERVER_WALLDESYNC,
328
                 tParser.getClientInfoOrFake(sHost), sMessage);
328
                 tParser.getClientInfoOrFake(sHost), sMessage);
329
     }
329
     }
330
 
330
 
333
     public void onNickChanged(final IRCParser tParser, final ClientInfo cClient,
333
     public void onNickChanged(final IRCParser tParser, final ClientInfo cClient,
334
             final String sOldNick) {
334
             final String sOldNick) {
335
         checkParser(tParser);
335
         checkParser(tParser);
336
-        
336
+
337
         if (cClient.equals(tParser.getMyself())) {
337
         if (cClient.equals(tParser.getMyself())) {
338
             owner.doNotification("selfNickChange", CoreActionType.SERVER_NICKCHANGE,
338
             owner.doNotification("selfNickChange", CoreActionType.SERVER_NICKCHANGE,
339
                     sOldNick, cClient.getNickname());
339
                     sOldNick, cClient.getNickname());
344
     @Override
344
     @Override
345
     public void onServerError(final IRCParser tParser, final String sMessage) {
345
     public void onServerError(final IRCParser tParser, final String sMessage) {
346
         checkParser(tParser);
346
         checkParser(tParser);
347
-        
347
+
348
         owner.doNotification("serverError", CoreActionType.SERVER_ERROR, sMessage);
348
         owner.doNotification("serverError", CoreActionType.SERVER_ERROR, sMessage);
349
     }
349
     }
350
 
350
 

+ 46
- 46
src/com/dmdirc/ServerManager.java Vedi File

31
 /**
31
 /**
32
  * The ServerManager maintains a list of all servers, and provides methods to
32
  * The ServerManager maintains a list of all servers, and provides methods to
33
  * search or iterate over them.
33
  * search or iterate over them.
34
- * 
34
+ *
35
  * @author chris
35
  * @author chris
36
  */
36
  */
37
 public final class ServerManager {
37
 public final class ServerManager {
38
-    
38
+
39
     /** Singleton instance of ServerManager. */
39
     /** Singleton instance of ServerManager. */
40
     private static ServerManager me;
40
     private static ServerManager me;
41
-    
41
+
42
     /** All servers that currently exist. */
42
     /** All servers that currently exist. */
43
     private final List<Server> servers = new ArrayList<Server>();
43
     private final List<Server> servers = new ArrayList<Server>();
44
-    
44
+
45
     /**
45
     /**
46
      * Creates a new instance of ServerManager.
46
      * Creates a new instance of ServerManager.
47
      */
47
      */
48
     private ServerManager() {
48
     private ServerManager() {
49
     }
49
     }
50
-    
50
+
51
     /**
51
     /**
52
      * Returns the singleton instance of ServerManager.
52
      * Returns the singleton instance of ServerManager.
53
-     * 
53
+     *
54
      * @return Instance of ServerManager
54
      * @return Instance of ServerManager
55
      */
55
      */
56
     public static synchronized ServerManager getServerManager() {
56
     public static synchronized ServerManager getServerManager() {
59
         }
59
         }
60
         return me;
60
         return me;
61
     }
61
     }
62
-    
62
+
63
     /**
63
     /**
64
      * Registers a new server with the manager.
64
      * Registers a new server with the manager.
65
-     * 
65
+     *
66
      * @param server The server to be registered
66
      * @param server The server to be registered
67
      */
67
      */
68
     public void registerServer(final Server server) {
68
     public void registerServer(final Server server) {
69
-        synchronized(servers) {
69
+        synchronized (servers) {
70
             servers.add(server);
70
             servers.add(server);
71
         }
71
         }
72
     }
72
     }
73
-    
73
+
74
     /**
74
     /**
75
      * Unregisters a server from the manager. The request is ignored if the
75
      * Unregisters a server from the manager. The request is ignored if the
76
      * ServerManager is in the process of closing all servers.
76
      * ServerManager is in the process of closing all servers.
77
-     * 
77
+     *
78
      * @param server The server to be unregistered
78
      * @param server The server to be unregistered
79
      */
79
      */
80
     public void unregisterServer(final Server server) {
80
     public void unregisterServer(final Server server) {
81
-        synchronized(servers) {
81
+        synchronized (servers) {
82
             servers.remove(server);
82
             servers.remove(server);
83
         }
83
         }
84
     }
84
     }
85
-    
85
+
86
     /**
86
     /**
87
      * Returns a list of all servers.
87
      * Returns a list of all servers.
88
-     * 
88
+     *
89
      * @return A list of all servers
89
      * @return A list of all servers
90
      */
90
      */
91
     public List<Server> getServers() {
91
     public List<Server> getServers() {
92
         return new ArrayList<Server>(servers);
92
         return new ArrayList<Server>(servers);
93
     }
93
     }
94
-    
94
+
95
     /**
95
     /**
96
      * Makes all servers disconnected with the specified quit message.
96
      * Makes all servers disconnected with the specified quit message.
97
-     * 
97
+     *
98
      * @param message The quit message to send to the IRC servers
98
      * @param message The quit message to send to the IRC servers
99
      */
99
      */
100
     public void disconnectAll(final String message) {
100
     public void disconnectAll(final String message) {
101
-        synchronized(servers) {
101
+        synchronized (servers) {
102
             for (Server server : servers) {
102
             for (Server server : servers) {
103
                 server.disconnect(message);
103
                 server.disconnect(message);
104
             }
104
             }
105
         }
105
         }
106
     }
106
     }
107
-    
107
+
108
     /**
108
     /**
109
      * Closes all servers with a default quit message.
109
      * Closes all servers with a default quit message.
110
      */
110
      */
111
     public void closeAll() {
111
     public void closeAll() {
112
-        synchronized(servers) {
112
+        synchronized (servers) {
113
             for (Server server : servers) {
113
             for (Server server : servers) {
114
                 server.disconnect();
114
                 server.disconnect();
115
                 server.close();
115
                 server.close();
116
             }
116
             }
117
         }
117
         }
118
     }
118
     }
119
-    
119
+
120
     /**
120
     /**
121
      * Closes all servers with the specified quit message.
121
      * Closes all servers with the specified quit message.
122
-     * 
122
+     *
123
      * @param message The quit message to send to the IRC servers
123
      * @param message The quit message to send to the IRC servers
124
      */
124
      */
125
     public void closeAll(final String message) {
125
     public void closeAll(final String message) {
126
-        synchronized(servers) {
126
+        synchronized (servers) {
127
             for (Server server : servers) {
127
             for (Server server : servers) {
128
                 server.disconnect(message);
128
                 server.disconnect(message);
129
                 server.close();
129
                 server.close();
130
             }
130
             }
131
         }
131
         }
132
     }
132
     }
133
-    
133
+
134
     /**
134
     /**
135
      * Returns the number of servers that are registered with the manager.
135
      * Returns the number of servers that are registered with the manager.
136
-     * 
136
+     *
137
      * @return number of registered servers
137
      * @return number of registered servers
138
      */
138
      */
139
     public int numServers() {
139
     public int numServers() {
140
         return servers.size();
140
         return servers.size();
141
     }
141
     }
142
-    
142
+
143
     /**
143
     /**
144
      * Returns the server instance that owns the specified internal frame.
144
      * Returns the server instance that owns the specified internal frame.
145
-     * 
145
+     *
146
      * @param active The internal frame to check
146
      * @param active The internal frame to check
147
      * @return The server associated with the internal frame
147
      * @return The server associated with the internal frame
148
      */
148
      */
149
     public Server getServerFromFrame(final Window active) {
149
     public Server getServerFromFrame(final Window active) {
150
-        synchronized(servers) {
150
+        synchronized (servers) {
151
             for (Server server : servers) {
151
             for (Server server : servers) {
152
                 if (server.ownsFrame(active)) {
152
                 if (server.ownsFrame(active)) {
153
                     return server;
153
                     return server;
154
                 }
154
                 }
155
             }
155
             }
156
         }
156
         }
157
-        
157
+
158
         return null;
158
         return null;
159
     }
159
     }
160
-    
160
+
161
     /**
161
     /**
162
      * Retrieves a list of servers connected to the specified network.
162
      * Retrieves a list of servers connected to the specified network.
163
-     * 
163
+     *
164
      * @param network The network to search for
164
      * @param network The network to search for
165
      * @return A list of servers connected to the network
165
      * @return A list of servers connected to the network
166
      */
166
      */
167
     public List<Server> getServersByNetwork(final String network) {
167
     public List<Server> getServersByNetwork(final String network) {
168
         final List<Server> res = new ArrayList<Server>();
168
         final List<Server> res = new ArrayList<Server>();
169
-        
170
-        synchronized(servers) {
169
+
170
+        synchronized (servers) {
171
             for (Server server : servers) {
171
             for (Server server : servers) {
172
                 if (server.getNetwork().equalsIgnoreCase(network)) {
172
                 if (server.getNetwork().equalsIgnoreCase(network)) {
173
                     res.add(server);
173
                     res.add(server);
174
                 }
174
                 }
175
             }
175
             }
176
         }
176
         }
177
-        
177
+
178
         return res;
178
         return res;
179
     }
179
     }
180
-    
180
+
181
     /**
181
     /**
182
      * Retrieves a list of servers connected to the specified address.
182
      * Retrieves a list of servers connected to the specified address.
183
-     * 
183
+     *
184
      * @param address The address to search for
184
      * @param address The address to search for
185
      * @return A list of servers connected to the network
185
      * @return A list of servers connected to the network
186
      */
186
      */
187
     public List<Server> getServersByAddress(final String address) {
187
     public List<Server> getServersByAddress(final String address) {
188
         final List<Server> res = new ArrayList<Server>();
188
         final List<Server> res = new ArrayList<Server>();
189
-        
190
-        synchronized(servers) {
189
+
190
+        synchronized (servers) {
191
             for (Server server : servers) {
191
             for (Server server : servers) {
192
                 if (server.getName().equalsIgnoreCase(address)) {
192
                 if (server.getName().equalsIgnoreCase(address)) {
193
                     res.add(server);
193
                     res.add(server);
194
                 }
194
                 }
195
             }
195
             }
196
         }
196
         }
197
-        
197
+
198
         return res;
198
         return res;
199
     }
199
     }
200
-    
200
+
201
     /**
201
     /**
202
      * Connects the user to Quakenet if neccessary and joins #DMDirc.
202
      * Connects the user to Quakenet if neccessary and joins #DMDirc.
203
      */
203
      */
204
     public void joinDevChat() {
204
     public void joinDevChat() {
205
         final List<Server> qnetServers = getServersByNetwork("Quakenet");
205
         final List<Server> qnetServers = getServersByNetwork("Quakenet");
206
-        
206
+
207
         Server connectedServer = null;
207
         Server connectedServer = null;
208
-        
208
+
209
         for (Server server : qnetServers) {
209
         for (Server server : qnetServers) {
210
             if (server.getState() == ServerState.CONNECTED) {
210
             if (server.getState() == ServerState.CONNECTED) {
211
                 connectedServer = server;
211
                 connectedServer = server;
212
-                
212
+
213
                 if (server.hasChannel("#DMDirc")) {
213
                 if (server.hasChannel("#DMDirc")) {
214
                     server.join("#DMDirc");
214
                     server.join("#DMDirc");
215
                     return;
215
                     return;
216
                 }
216
                 }
217
             }
217
             }
218
         }
218
         }
219
-        
219
+
220
         if (connectedServer == null) {
220
         if (connectedServer == null) {
221
             final List<String> channels = new ArrayList<String>();
221
             final List<String> channels = new ArrayList<String>();
222
                 channels.add("#DMDirc");
222
                 channels.add("#DMDirc");
223
-                
223
+
224
                 new Server("irc.quakenet.org", 6667, "", false,
224
                 new Server("irc.quakenet.org", 6667, "", false,
225
                         IdentityManager.getProfiles().get(0), channels);
225
                         IdentityManager.getProfiles().get(0), channels);
226
         } else {
226
         } else {
227
             connectedServer.join("#DMDirc");
227
             connectedServer.join("#DMDirc");
228
-        }        
228
+        }
229
     }
229
     }
230
-    
230
+
231
 }
231
 }

+ 15
- 11
src/com/dmdirc/Topic.java Vedi File

24
 
24
 
25
 /**
25
 /**
26
  * Stores information about a channel topic.
26
  * Stores information about a channel topic.
27
- * 
27
+ *
28
  * @author chris
28
  * @author chris
29
  */
29
  */
30
 public class Topic {
30
 public class Topic {
31
-    
32
-    /**  Topic. */
31
+
32
+    /** Topic. */
33
     private final String topic;
33
     private final String topic;
34
-    /**  Topic client. */
34
+    /** Topic client. */
35
     private final String client;
35
     private final String client;
36
-    /**  Topic time. */
36
+    /** Topic time. */
37
     private final long time;
37
     private final long time;
38
 
38
 
39
     /**
39
     /**
40
      * Creates a new topic.
40
      * Creates a new topic.
41
+     *
41
      * @param topic Topic
42
      * @param topic Topic
42
      * @param client Topic client
43
      * @param client Topic client
43
      * @param time Topic time
44
      * @param time Topic time
44
      */
45
      */
45
-    public Topic(String topic, String client, long time) {
46
+    public Topic(final String topic, final String client, final long time) {
46
         this.topic = topic;
47
         this.topic = topic;
47
         this.client = client;
48
         this.client = client;
48
         this.time = time;
49
         this.time = time;
49
     }
50
     }
50
 
51
 
51
-    /** 
52
+    /**
52
      * Returns the client who set the topic.
53
      * Returns the client who set the topic.
54
+     *
53
      * @return client host
55
      * @return client host
54
      */
56
      */
55
     public String getClient() {
57
     public String getClient() {
56
         return client;
58
         return client;
57
     }
59
     }
58
 
60
 
59
-    /** 
61
+    /**
60
      * Returns the time the topic was set.
62
      * Returns the time the topic was set.
63
+     *
61
      * @return topic time
64
      * @return topic time
62
      */
65
      */
63
     public long getTime() {
66
     public long getTime() {
64
         return time;
67
         return time;
65
     }
68
     }
66
 
69
 
67
-    /** 
70
+    /**
68
      * Returns the topic this object represents.
71
      * Returns the topic this object represents.
72
+     *
69
      * @return topic
73
      * @return topic
70
      */
74
      */
71
     public String getTopic() {
75
     public String getTopic() {
72
         return topic;
76
         return topic;
73
     }
77
     }
74
-    
78
+
75
     /** {@inheritDoc} */
79
     /** {@inheritDoc} */
76
     @Override
80
     @Override
77
     public String toString() {
81
     public String toString() {
78
         return topic;
82
         return topic;
79
     }
83
     }
80
-    
84
+
81
 }
85
 }

+ 1
- 1
src/com/dmdirc/WritableFrameContainer.java Vedi File

224
             containers.add(getServer());
224
             containers.add(getServer());
225
             containers.addAll(getServer().getChildren());
225
             containers.addAll(getServer().getChildren());
226
 
226
 
227
-            for (WritableFrameContainer container: containers) {
227
+            for (WritableFrameContainer container : containers) {
228
                 final long time
228
                 final long time
229
                         = container.getFrame().getCommandParser().getCommandTime(command);
229
                         = container.getFrame().getCommandParser().getCommandTime(command);
230
                 if (time > besttime) {
230
                 if (time > besttime) {

Loading…
Annulla
Salva