Bläddra i källkod

Deprecation fixes

Sprinkle some annotations over the CommandManager
More fiddling with NB7.1 settings

Change-Id: I2a0b751798249d4cc3e527f6d2e5525d1936f0e1
Reviewed-on: http://gerrit.dmdirc.com/2278
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.6.7rc1
Chris Smith 12 år sedan
förälder
incheckning
d4507e0b3a
32 ändrade filer med 188 tillägg och 129 borttagningar
  1. 3
    1
      nbproject/project.properties
  2. 2
    1
      src/com/dmdirc/CustomWindow.java
  3. 6
    3
      src/com/dmdirc/GlobalWindow.java
  4. 6
    6
      src/com/dmdirc/Main.java
  5. 7
    6
      src/com/dmdirc/actions/Action.java
  6. 2
    2
      src/com/dmdirc/actions/ActionSubstitutor.java
  7. 4
    4
      src/com/dmdirc/commandline/CommandLineParser.java
  8. 60
    34
      src/com/dmdirc/commandparser/CommandManager.java
  9. 4
    4
      src/com/dmdirc/commandparser/commands/global/Set.java
  10. 3
    3
      src/com/dmdirc/commandparser/parsers/CommandParser.java
  11. 9
    8
      src/com/dmdirc/config/CipherUtils.java
  12. 4
    0
      src/com/dmdirc/config/ConfigBinder.java
  13. 2
    2
      src/com/dmdirc/config/IdentityManager.java
  14. 2
    1
      src/com/dmdirc/config/validators/URLProtocolValidator.java
  15. 2
    2
      src/com/dmdirc/logger/ErrorManager.java
  16. 2
    1
      src/com/dmdirc/logger/ProgramError.java
  17. 11
    5
      src/com/dmdirc/plugins/PluginManager.java
  18. 6
    4
      src/com/dmdirc/ui/FatalErrorDialog.java
  19. 4
    4
      src/com/dmdirc/ui/core/util/Info.java
  20. 7
    9
      src/com/dmdirc/ui/core/util/URLHandler.java
  21. 2
    2
      src/com/dmdirc/ui/input/TabCompleter.java
  22. 2
    2
      src/com/dmdirc/ui/input/TabCompleterResult.java
  23. 6
    3
      src/com/dmdirc/ui/messages/ColourManager.java
  24. 3
    2
      src/com/dmdirc/ui/themes/ThemeManager.java
  25. 8
    6
      src/com/dmdirc/updater/UpdateChecker.java
  26. 2
    2
      src/com/dmdirc/updater/components/ClientComponent.java
  27. 2
    1
      src/com/dmdirc/updater/components/DefaultsComponent.java
  28. 2
    1
      src/com/dmdirc/updater/components/ModeAliasesComponent.java
  29. 1
    1
      src/com/dmdirc/updater/components/PluginComponent.java
  30. 6
    6
      test/com/dmdirc/config/IdentityManagerTest.java
  31. 7
    2
      test/com/dmdirc/config/prefs/PreferencesSettingTest.java
  32. 1
    1
      test/com/dmdirc/harness/TestWritableFrameContainer.java

+ 3
- 1
nbproject/project.properties Visa fil

@@ -9,7 +9,9 @@ auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
9 9
 auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
10 10
 auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
11 11
 auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
12
-auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=com.dmdirc;java;javax;org;*
12
+auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.allowConvertToStarImport=false
13
+auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=com.dmdirc;java;javax;org;*;static *
14
+auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateStaticImports=true
13 15
 endorsed.classpath=
14 16
 javac.processorpath=\
15 17
     ${javac.classpath}

+ 2
- 1
src/com/dmdirc/CustomWindow.java Visa fil

@@ -55,7 +55,8 @@ public class CustomWindow extends FrameContainer {
55 55
      * @param title The parent of this custom window
56 56
      */
57 57
     public CustomWindow(final String name, final String title) {
58
-        super("custom", name, title, IdentityManager.getGlobalConfig(),
58
+        super("custom", name, title,
59
+                IdentityManager.getIdentityManager().getGlobalConfiguration(),
59 60
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier()));
60 61
 
61 62
         WindowManager.getWindowManager().addWindow(this);

+ 6
- 3
src/com/dmdirc/GlobalWindow.java Visa fil

@@ -48,7 +48,8 @@ public class GlobalWindow extends WritableFrameContainer {
48 48
 
49 49
     /** Creates a new instance of GlobalWindow. */
50 50
     public GlobalWindow() {
51
-        super("icon", "Global", "(Global)",IdentityManager.getGlobalConfig(),
51
+        super("icon", "Global", "(Global)",
52
+                IdentityManager.getIdentityManager().getGlobalConfiguration(),
52 53
                 GlobalCommandParser.getGlobalCommandParser(),
53 54
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
54 55
                 WindowComponent.INPUTFIELD.getIdentifier()));
@@ -106,7 +107,8 @@ public class GlobalWindow extends WritableFrameContainer {
106 107
      * Initialises the global window if it's enabled in the config.
107 108
      */
108 109
     public static void init() {
109
-        IdentityManager.getGlobalConfig().addChangeListener("general", "showglobalwindow",
110
+        IdentityManager.getIdentityManager().getGlobalConfiguration()
111
+                .addChangeListener("general", "showglobalwindow",
110 112
                 new ConfigChangeListener() {
111 113
 
112 114
             @Override
@@ -124,7 +126,8 @@ public class GlobalWindow extends WritableFrameContainer {
124 126
      */
125 127
     protected static void updateWindowState() {
126 128
         synchronized (GlobalWindow.class) {
127
-            if (IdentityManager.getGlobalConfig().getOptionBool("general", "showglobalwindow")) {
129
+            if (IdentityManager.getIdentityManager().getGlobalConfiguration()
130
+                    .getOptionBool("general", "showglobalwindow")) {
128 131
                 if (globalWindow == null) {
129 132
                     globalWindow = new GlobalWindow();
130 133
                 }

+ 6
- 6
src/com/dmdirc/Main.java Visa fil

@@ -121,7 +121,7 @@ public final class Main {
121 121
         MessageSinkManager.getManager().loadDefaultSinks();
122 122
 
123 123
         final PluginManager pm = PluginManager.getPluginManager();
124
-        checkBundledPlugins(pm, IdentityManager.getGlobalConfig());
124
+        checkBundledPlugins(pm, IdentityManager.getIdentityManager().getGlobalConfiguration());
125 125
 
126 126
         ThemeManager.loadThemes();
127 127
 
@@ -178,13 +178,13 @@ public final class Main {
178 178
      */
179 179
     private static void handleMissingUI() {
180 180
         // Check to see if we have already tried this
181
-        if (IdentityManager.getGlobalConfig().hasOptionBool("debug", "uiFixAttempted")) {
181
+        if (IdentityManager.getIdentityManager().getGlobalConfiguration().hasOptionBool("debug", "uiFixAttempted")) {
182 182
             System.out.println("DMDirc is unable to load any compatible UI plugins.");
183 183
             if (!GraphicsEnvironment.isHeadless()) {
184 184
                 new WarningDialog(WarningDialog.NO_COMPAT_UIS_TITLE,
185 185
                         WarningDialog.NO_RECOV_UIS).displayBlocking();
186 186
             }
187
-            IdentityManager.getConfigIdentity().unsetOption("debug", "uiFixAttempted");
187
+            IdentityManager.getIdentityManager().getGlobalConfigIdentity().unsetOption("debug", "uiFixAttempted");
188 188
             System.exit(1);
189 189
         } else {
190 190
             // Try to extract the UIs again incase they changed between versions
@@ -312,7 +312,7 @@ public final class Main {
312 312
             handleMissingUI();
313 313
         } else {
314 314
             // The fix worked!
315
-            if (IdentityManager.getGlobalConfig().hasOptionBool("debug", "uiFixAttempted")) {
315
+            if (IdentityManager.getIdentityManager().getGlobalConfiguration().hasOptionBool("debug", "uiFixAttempted")) {
316 316
                 IdentityManager.getConfigIdentity().unsetOption("debug", "uiFixAttempted");
317 317
             }
318 318
         }
@@ -322,7 +322,7 @@ public final class Main {
322 322
      * Executes the first run or migration wizards as required.
323 323
      */
324 324
     private static void doFirstRun() {
325
-        if (IdentityManager.getGlobalConfig().getOptionBool("general", "firstRun")) {
325
+        if (IdentityManager.getIdentityManager().getGlobalConfiguration().getOptionBool("general", "firstRun")) {
326 326
             IdentityManager.getConfigIdentity().setOption("general", "firstRun", "false");
327 327
             for (UIController controller : CONTROLLERS) {
328 328
                 controller.showFirstRunWizard();
@@ -355,7 +355,7 @@ public final class Main {
355 355
      *                  operating system when the client exits
356 356
      */
357 357
     public static void quit(final int exitCode) {
358
-        quit(IdentityManager.getGlobalConfig().getOption("general",
358
+        quit(IdentityManager.getIdentityManager().getGlobalConfiguration().getOption("general",
359 359
                 "closemessage"), exitCode);
360 360
     }
361 361
 

+ 7
- 6
src/com/dmdirc/actions/Action.java Visa fil

@@ -93,7 +93,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
93 93
             error(ActionErrorType.FILE, "I/O error when loading action: " + ex.getMessage());
94 94
         }
95 95
 
96
-        IdentityManager.getGlobalConfig().addChangeListener("disable_action",
96
+        IdentityManager.getIdentityManager().getGlobalConfiguration().addChangeListener("disable_action",
97 97
                 (group + "/" + name).replace(' ', '.'), this);
98 98
         checkDisabled();
99 99
     }
@@ -144,7 +144,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
144 144
 
145 145
         save();
146 146
 
147
-        IdentityManager.getGlobalConfig().addChangeListener("disable_action",
147
+        IdentityManager.getIdentityManager().getGlobalConfiguration().addChangeListener("disable_action",
148 148
                 (group + "/" + name).replace(' ', '.'), this);
149 149
         checkDisabled();
150 150
 
@@ -266,7 +266,8 @@ public class Action extends ActionModel implements ConfigChangeListener {
266 266
                 myGroup.getSettings().put(data.get("setting"), new PreferencesSetting(
267 267
                         PreferencesType.valueOf(data.get("type")), "actions",
268 268
                         data.get("setting"), data.get("title"), data.get("tooltip"),
269
-                        IdentityManager.getGlobalConfig(), IdentityManager.getConfigIdentity()));
269
+                        IdentityManager.getIdentityManager().getGlobalConfiguration(),
270
+                        IdentityManager.getConfigIdentity()));
270 271
             }
271 272
         }
272 273
     }
@@ -572,9 +573,9 @@ public class Action extends ActionModel implements ConfigChangeListener {
572 573
      */
573 574
     protected void checkDisabled() {
574 575
         final String key = (group + "/" + name).replace(' ', '.');
575
-        final boolean disabled = IdentityManager.getGlobalConfig()
576
-                .hasOptionBool("disable_action", key)
577
-                && IdentityManager.getGlobalConfig()
576
+        final boolean disabled = IdentityManager.getIdentityManager()
577
+                .getGlobalConfiguration().hasOptionBool("disable_action", key)
578
+                && IdentityManager.getIdentityManager().getGlobalConfiguration()
578 579
                 .getOptionBool("disable_action", key);
579 580
 
580 581
         if (disabled && status == ActionStatus.ACTIVE) {

+ 2
- 2
src/com/dmdirc/actions/ActionSubstitutor.java Visa fil

@@ -89,7 +89,7 @@ public class ActionSubstitutor {
89 89
      * @return A list of global variable names that will be substituted
90 90
      */
91 91
     public Set<String> getConfigSubstitutions() {
92
-        return IdentityManager.getGlobalConfig().getOptions("actions").keySet();
92
+        return IdentityManager.getIdentityManager().getGlobalConfiguration().getOptions("actions").keySet();
93 93
     }
94 94
 
95 95
     /**
@@ -322,7 +322,7 @@ public class ActionSubstitutor {
322 322
             }
323 323
         }
324 324
 
325
-        return IdentityManager.getGlobalConfig();
325
+        return IdentityManager.getIdentityManager().getGlobalConfiguration();
326 326
     }
327 327
 
328 328
     /**

+ 4
- 4
src/com/dmdirc/commandline/CommandLineParser.java Visa fil

@@ -302,10 +302,10 @@ public class CommandLineParser {
302 302
     private static void doVersion() {
303 303
         System.out.println("DMDirc - a cross-platform, open-source IRC client.");
304 304
         System.out.println();
305
-        System.out.println("        Version: "
306
-                + IdentityManager.getGlobalConfig().getOption("version", "version"));
307
-        System.out.println(" Update channel: "
308
-                + IdentityManager.getGlobalConfig().getOption("updater", "channel"));
305
+        System.out.println("        Version: " + IdentityManager.getIdentityManager()
306
+                .getGlobalConfiguration().getOption("version", "version"));
307
+        System.out.println(" Update channel: " + IdentityManager.getIdentityManager()
308
+                .getGlobalConfiguration().getOption("updater", "channel"));
309 309
         exit();
310 310
     }
311 311
 

+ 60
- 34
src/com/dmdirc/commandparser/CommandManager.java Visa fil

@@ -22,19 +22,58 @@
22 22
 
23 23
 package com.dmdirc.commandparser;
24 24
 
25
-import com.dmdirc.interfaces.CommandController;
26 25
 import com.dmdirc.BasicServerFactory;
27 26
 import com.dmdirc.Query;
28 27
 import com.dmdirc.Server;
29 28
 import com.dmdirc.ServerManager;
30 29
 import com.dmdirc.commandparser.commands.Command;
31
-import com.dmdirc.commandparser.commands.channel.*; //NOPMD
32
-import com.dmdirc.commandparser.commands.chat.*; //NOPMD
33
-import com.dmdirc.commandparser.commands.global.*; //NOPMD
34
-import com.dmdirc.commandparser.commands.server.*; //NOPMD
30
+import com.dmdirc.commandparser.commands.channel.Ban;
31
+import com.dmdirc.commandparser.commands.channel.Cycle;
32
+import com.dmdirc.commandparser.commands.channel.Invite;
33
+import com.dmdirc.commandparser.commands.channel.KickReason;
34
+import com.dmdirc.commandparser.commands.channel.Mode;
35
+import com.dmdirc.commandparser.commands.channel.Names;
36
+import com.dmdirc.commandparser.commands.channel.Part;
37
+import com.dmdirc.commandparser.commands.channel.SetNickColour;
38
+import com.dmdirc.commandparser.commands.channel.ShowTopic;
39
+import com.dmdirc.commandparser.commands.chat.Me;
40
+import com.dmdirc.commandparser.commands.global.AliasCommand;
41
+import com.dmdirc.commandparser.commands.global.AllServers;
42
+import com.dmdirc.commandparser.commands.global.Clear;
43
+import com.dmdirc.commandparser.commands.global.Echo;
44
+import com.dmdirc.commandparser.commands.global.Exit;
45
+import com.dmdirc.commandparser.commands.global.Help;
46
+import com.dmdirc.commandparser.commands.global.Ifplugin;
47
+import com.dmdirc.commandparser.commands.global.LoadPlugin;
48
+import com.dmdirc.commandparser.commands.global.NewServer;
49
+import com.dmdirc.commandparser.commands.global.Notify;
50
+import com.dmdirc.commandparser.commands.global.OpenWindow;
51
+import com.dmdirc.commandparser.commands.global.ReloadActions;
52
+import com.dmdirc.commandparser.commands.global.ReloadIdentities;
53
+import com.dmdirc.commandparser.commands.global.ReloadPlugin;
54
+import com.dmdirc.commandparser.commands.global.SaveConfig;
55
+import com.dmdirc.commandparser.commands.global.Set;
56
+import com.dmdirc.commandparser.commands.global.UnloadPlugin;
57
+import com.dmdirc.commandparser.commands.server.AllChannels;
58
+import com.dmdirc.commandparser.commands.server.Away;
59
+import com.dmdirc.commandparser.commands.server.Back;
60
+import com.dmdirc.commandparser.commands.server.ChangeServer;
61
+import com.dmdirc.commandparser.commands.server.Ctcp;
62
+import com.dmdirc.commandparser.commands.server.Disconnect;
63
+import com.dmdirc.commandparser.commands.server.Ignore;
64
+import com.dmdirc.commandparser.commands.server.JoinChannelCommand;
65
+import com.dmdirc.commandparser.commands.server.Message;
66
+import com.dmdirc.commandparser.commands.server.Nick;
67
+import com.dmdirc.commandparser.commands.server.Notice;
68
+import com.dmdirc.commandparser.commands.server.OpenQuery;
69
+import com.dmdirc.commandparser.commands.server.Raw;
70
+import com.dmdirc.commandparser.commands.server.RawServerCommand;
71
+import com.dmdirc.commandparser.commands.server.Reconnect;
72
+import com.dmdirc.commandparser.commands.server.Umode;
35 73
 import com.dmdirc.commandparser.parsers.CommandParser;
74
+import com.dmdirc.config.ConfigBinding;
36 75
 import com.dmdirc.config.IdentityManager;
37
-import com.dmdirc.interfaces.ConfigChangeListener;
76
+import com.dmdirc.interfaces.CommandController;
38 77
 import com.dmdirc.ui.input.TabCompleter;
39 78
 import com.dmdirc.ui.input.TabCompletionType;
40 79
 import com.dmdirc.util.collections.MapList;
@@ -44,10 +83,13 @@ import java.util.HashMap;
44 83
 import java.util.List;
45 84
 import java.util.Map;
46 85
 
86
+import lombok.Getter;
87
+
47 88
 /**
48 89
  * The command manager creates and manages a single instance of all commands,
49 90
  * and provides methods to load each group of commands into a parser instance.
50 91
  */
92
+@SuppressWarnings("PMD.UnusedPrivateField")
51 93
 public class CommandManager implements CommandController {
52 94
 
53 95
     /** A singleton instance of the command manager. */
@@ -62,23 +104,21 @@ public class CommandManager implements CommandController {
62 104
             = new MapList<CommandType, CommandParser>();
63 105
 
64 106
     /** The command char we're using. */
65
-    private char commandChar = IdentityManager.getGlobalConfig()
66
-            .getOptionChar("general", "commandchar");
107
+    @ConfigBinding(domain="general", key="commandchar")
108
+    @Getter
109
+    private char commandChar;
67 110
 
68 111
     /** The silence char we're using. */
69
-    private char silenceChar = IdentityManager.getGlobalConfig()
70
-            .getOptionChar("general", "silencechar");
71
-
72
-    /** {@inheritDoc} */
73
-    @Override
74
-    public char getCommandChar() {
75
-        return commandChar;
76
-    }
112
+    @ConfigBinding(domain="general", key="silencechar")
113
+    @Getter
114
+    private char silenceChar;
77 115
 
78
-    /** {@inheritDoc} */
79
-    @Override
80
-    public char getSilenceChar() {
81
-        return silenceChar;
116
+    /**
117
+     * Creates a new instance of the Command Manager.
118
+     */
119
+    public CommandManager() {
120
+        IdentityManager.getIdentityManager().getGlobalConfiguration()
121
+                .getBinder().bind(this, CommandManager.class);
82 122
     }
83 123
 
84 124
     /** {@inheritDoc} */
@@ -261,20 +301,6 @@ public class CommandManager implements CommandController {
261 301
         registerCommand(new ReloadPlugin(), ReloadPlugin.INFO);
262 302
         registerCommand(new SaveConfig(), SaveConfig.INFO);
263 303
         registerCommand(new Set(), Set.INFO);
264
-
265
-        // Set up a listener for config changes
266
-        final ConfigChangeListener listener = new ConfigChangeListener() {
267
-            @Override
268
-            public void configChanged(final String domain, final String key) {
269
-                commandChar = IdentityManager.getGlobalConfig()
270
-                        .getOptionChar("general", "commandchar");
271
-                silenceChar = IdentityManager.getGlobalConfig()
272
-                        .getOptionChar("general", "silencechar");
273
-            }
274
-        };
275
-
276
-        IdentityManager.getGlobalConfig().addChangeListener("general", "commandchar", listener);
277
-        IdentityManager.getGlobalConfig().addChangeListener("general", "silencechar", listener);
278 304
     }
279 305
 
280 306
     /** {@inheritDoc} */

+ 4
- 4
src/com/dmdirc/commandparser/commands/global/Set.java Visa fil

@@ -91,8 +91,8 @@ public class Set extends Command implements IntelligentCommand {
91 91
             return;
92 92
         }
93 93
 
94
-        Identity identity = IdentityManager.getConfigIdentity();
95
-        ConfigManager manager = IdentityManager.getGlobalConfig();
94
+        Identity identity = IdentityManager.getIdentityManager().getGlobalConfigIdentity();
95
+        ConfigManager manager = IdentityManager.getIdentityManager().getGlobalConfiguration();
96 96
 
97 97
         if (res.hasFlag(serverFlag)) {
98 98
             if (origin.getServer() == null) {
@@ -113,8 +113,8 @@ public class Set extends Command implements IntelligentCommand {
113 113
             }
114 114
 
115 115
             final Channel channel = ((ChannelCommandContext) context).getChannel();
116
-            identity = IdentityManager.getChannelConfig(origin.getServer().getNetwork(),
117
-                    channel.getName());
116
+            identity = IdentityManager.getIdentityManager().createChannelConfig(
117
+                    origin.getServer().getNetwork(), channel.getName());
118 118
             manager = channel.getConfigManager();
119 119
         }
120 120
 

+ 3
- 3
src/com/dmdirc/commandparser/parsers/CommandParser.java Visa fil

@@ -72,9 +72,9 @@ public abstract class CommandParser implements Serializable {
72 72
     /** Creates a new instance of CommandParser. */
73 73
     protected CommandParser() {
74 74
         commands = new HashMap<String, CommandInfoPair>();
75
-        history = new RollingList<PreviousCommand>(
76
-                IdentityManager.getGlobalConfig().getOptionInt("general",
77
-                    "commandhistory"));
75
+        history = new RollingList<PreviousCommand>(IdentityManager
76
+                .getIdentityManager().getGlobalConfiguration()
77
+                .getOptionInt("general", "commandhistory"));
78 78
         loadCommands();
79 79
     }
80 80
 

+ 9
- 8
src/com/dmdirc/config/CipherUtils.java Visa fil

@@ -194,24 +194,25 @@ public abstract class CipherUtils {
194 194
      * @return true if auth was successful, false otherwise.
195 195
      */
196 196
     public boolean auth() {
197
+        final ConfigManager configManager = IdentityManager.getIdentityManager()
198
+                .getGlobalConfiguration();
199
+
197 200
         String passwordHash = null;
198 201
         String prompt = "Please enter your password";
199 202
         int tries = 1;
200
-        if (IdentityManager.getGlobalConfig().hasOptionString("encryption", "password")) {
201
-            password = IdentityManager.getGlobalConfig().getOption("encryption", "password");
203
+        if (configManager.hasOptionString("encryption", "password")) {
204
+            password = configManager.getOption("encryption", "password");
202 205
         } else {
203
-            if (IdentityManager.getGlobalConfig().hasOptionString("encryption",
204
-                    "passwordHash")) {
205
-                passwordHash = IdentityManager.getGlobalConfig().getOption("encryption",
206
-                        "passwordHash");
206
+            if (configManager.hasOptionString("encryption", "passwordHash")) {
207
+                passwordHash = configManager.getOption("encryption", "passwordHash");
207 208
             }
208 209
 
209 210
             while ((password == null || password.isEmpty()) && tries < AUTH_TRIES) {
210 211
                 password = getPassword(prompt);
211 212
                 if (passwordHash == null) {
212 213
                     passwordHash = hash(password);
213
-                    IdentityManager.getConfigIdentity().setOption("encryption",
214
-                            "passwordHash", passwordHash);
214
+                    IdentityManager.getIdentityManager().getGlobalConfigIdentity()
215
+                            .setOption("encryption", "passwordHash", passwordHash);
215 216
                 }
216 217
                 if (!hash(password).equals(passwordHash)) {
217 218
                     prompt = "<html>Password mis-match<br>Please re-enter "

+ 4
- 0
src/com/dmdirc/config/ConfigBinder.java Visa fil

@@ -175,6 +175,10 @@ public class ConfigBinder {
175 175
             return manager.getOptionBool(binding.domain(), binding.key());
176 176
         }
177 177
 
178
+        if (targetClass.equals(Character.class) || targetClass.equals(Character.TYPE)) {
179
+            return manager.getOptionChar(binding.domain(), binding.key());
180
+        }
181
+
178 182
         return null;
179 183
     }
180 184
 

+ 2
- 2
src/com/dmdirc/config/IdentityManager.java Visa fil

@@ -180,9 +180,9 @@ public class IdentityManager implements IdentityFactory, IdentityController {
180 180
         // currently using, extract them.
181 181
         if (getGlobalConfiguration().hasOptionString("identity", "defaultsversion")
182 182
                 && getGlobalConfiguration().hasOptionString("updater", "bundleddefaultsversion")) {
183
-            final Version installedVersion = new Version(getGlobalConfig()
183
+            final Version installedVersion = new Version(getGlobalConfiguration()
184 184
                     .getOption("identity", "defaultsversion"));
185
-            final Version bundledVersion = new Version(getGlobalConfig()
185
+            final Version bundledVersion = new Version(getGlobalConfiguration()
186 186
                     .getOption("updater", "bundleddefaultsversion"));
187 187
 
188 188
             if (bundledVersion.compareTo(installedVersion) > 0) {

+ 2
- 1
src/com/dmdirc/config/validators/URLProtocolValidator.java Visa fil

@@ -36,7 +36,8 @@ public class URLProtocolValidator implements Validator<String> {
36 36
     public ValidationResponse validate(final String object) {
37 37
         if (object == null || object.isEmpty()) {
38 38
             return new ValidationResponse("Cannot be empty");
39
-        } else if (IdentityManager.getGlobalConfig().hasOptionString("protocol", object)) {
39
+        } else if (IdentityManager.getIdentityManager().getGlobalConfiguration()
40
+                .hasOptionString("protocol", object)) {
40 41
             return new ValidationResponse("Cannot already exist");
41 42
         } else {
42 43
             return new ValidationResponse();

+ 2
- 2
src/com/dmdirc/logger/ErrorManager.java Visa fil

@@ -78,7 +78,7 @@ public final class ErrorManager implements ConfigChangeListener {
78 78
         errors = new LinkedList<ProgramError>();
79 79
         nextErrorID = new AtomicLong();
80 80
 
81
-        final ConfigManager config = IdentityManager.getGlobalConfig();
81
+        final ConfigManager config = IdentityManager.getIdentityManager().getGlobalConfiguration();
82 82
 
83 83
         config.addChangeListener("general", "logerrors", this);
84 84
         config.addChangeListener("general", "submitErrors", this);
@@ -465,7 +465,7 @@ public final class ErrorManager implements ConfigChangeListener {
465 465
 
466 466
     /** Updates the settings used by this error manager. */
467 467
     protected void updateSettings() {
468
-        final ConfigManager config = IdentityManager.getGlobalConfig();
468
+        final ConfigManager config = IdentityManager.getIdentityManager().getGlobalConfiguration();
469 469
 
470 470
         try {
471 471
             sendReports = config.getOptionBool("general", "submitErrors")

+ 2
- 1
src/com/dmdirc/logger/ProgramError.java Visa fil

@@ -315,7 +315,8 @@ public final class ProgramError implements Serializable {
315 315
         }
316 316
         postData.put("message", getMessage());
317 317
         postData.put("trace", traceString);
318
-        postData.put("version", IdentityManager.getGlobalConfig().getOption("version", "version"));
318
+        postData.put("version", IdentityManager.getIdentityManager()
319
+                .getGlobalConfiguration().getOption("version", "version"));
319 320
 
320 321
         setReportStatus(ErrorReportStatus.SENDING);
321 322
 

+ 11
- 5
src/com/dmdirc/plugins/PluginManager.java Visa fil

@@ -185,7 +185,8 @@ public class PluginManager implements ActionListener, ServiceManager {
185 185
      * Autoloads plugins.
186 186
      */
187 187
     public void doAutoLoad() {
188
-        for (String plugin : IdentityManager.getGlobalConfig().getOptionList("plugins", "autoload")) {
188
+        for (String plugin : IdentityManager.getIdentityManager()
189
+                .getGlobalConfiguration().getOptionList("plugins", "autoload")) {
189 190
             plugin = plugin.trim();
190 191
             if (!plugin.isEmpty() && plugin.charAt(0) != '#' && getPluginInfo(plugin) != null) {
191 192
                 getPluginInfo(plugin).loadPlugin();
@@ -363,8 +364,11 @@ public class PluginManager implements ActionListener, ServiceManager {
363 364
     public String getFilesDirectory() {
364 365
         final String fs = System.getProperty("file.separator");
365 366
         String filesDir = myDir + "files" + fs;
366
-        if (IdentityManager.getGlobalConfig().hasOptionString("plugins", "filesdir")) {
367
-            final String fdopt = IdentityManager.getGlobalConfig().getOptionString("plugins", "filesdir");
367
+        if (IdentityManager.getIdentityManager().getGlobalConfiguration()
368
+                .hasOptionString("plugins", "filesdir")) {
369
+            final String fdopt = IdentityManager.getIdentityManager()
370
+                    .getGlobalConfiguration().getOptionString("plugins", "filesdir");
371
+
368 372
             if (fdopt != null && !fdopt.isEmpty() && new File(fdopt).exists()) {
369 373
                 filesDir = fdopt;
370 374
             }
@@ -512,7 +516,8 @@ public class PluginManager implements ActionListener, ServiceManager {
512 516
      * @param plugin to add/remove (Decided automatically based on isLoaded())
513 517
      */
514 518
     public void updateAutoLoad(final PluginInfo plugin) {
515
-        final List<String> list = IdentityManager.getGlobalConfig().getOptionList("plugins", "autoload");
519
+        final List<String> list = IdentityManager.getIdentityManager()
520
+                .getGlobalConfiguration().getOptionList("plugins", "autoload");
516 521
         final String path = plugin.getMetaData().getRelativeFilename();
517 522
 
518 523
         if (plugin.isLoaded() && !list.contains(path)) {
@@ -521,7 +526,8 @@ public class PluginManager implements ActionListener, ServiceManager {
521 526
             list.remove(path);
522 527
         }
523 528
 
524
-        IdentityManager.getConfigIdentity().setOption("plugins", "autoload", list);
529
+        IdentityManager.getIdentityManager().getGlobalConfigIdentity()
530
+                .setOption("plugins", "autoload", list);
525 531
     }
526 532
 
527 533
     /**

+ 6
- 4
src/com/dmdirc/ui/FatalErrorDialog.java Visa fil

@@ -135,8 +135,11 @@ public final class FatalErrorDialog extends JDialog implements ActionListener,
135 135
 
136 136
         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
137 137
         setTitle("DMDirc: Fatal Error");
138
-        setIconImage(new IconManager(IdentityManager.getGlobalConfig())
139
-                .getImage("icon"));
138
+
139
+        final IconManager iconManager = new IconManager(IdentityManager
140
+                .getIdentityManager().getGlobalConfiguration());
141
+
142
+        setIconImage(iconManager.getImage("icon"));
140 143
 
141 144
         infoLabel.setText("DMDirc has encountered a fatal error, and is "
142 145
                 + "not able to recover. \nThe application will now terminate.");
@@ -146,8 +149,7 @@ public final class FatalErrorDialog extends JDialog implements ActionListener,
146 149
         ((StyledDocument) messageLabel.getDocument()).setParagraphAttributes(0,
147 150
                 messageLabel.getText().length(), sas, false);
148 151
 
149
-        icon = new ImageIcon(new IconManager(IdentityManager.getGlobalConfig())
150
-                .getImage("error"));
152
+        icon = new ImageIcon(iconManager.getImage("error"));
151 153
 
152 154
         stacktraceField.setEditable(false);
153 155
 

+ 4
- 4
src/com/dmdirc/ui/core/util/Info.java Visa fil

@@ -43,10 +43,10 @@ public class Info {
43 43
      * @return DMDirc version string
44 44
      */
45 45
     public static String getDMDircVersion() {
46
-        return IdentityManager.getGlobalConfig().getOption("version", "version")
47
-                + " ("
48
-                + IdentityManager.getGlobalConfig().getOption("updater", "channel")
49
-                + ")";
46
+        return IdentityManager.getIdentityManager().getGlobalConfiguration()
47
+                .getOption("version", "version") + " ("
48
+                + IdentityManager.getIdentityManager().getGlobalConfiguration()
49
+                .getOption("updater", "channel") + ")";
50 50
     }
51 51
 
52 52
     /**

+ 7
- 9
src/com/dmdirc/ui/core/util/URLHandler.java Visa fil

@@ -25,11 +25,11 @@ package com.dmdirc.ui.core.util;
25 25
 import com.dmdirc.ServerManager;
26 26
 import com.dmdirc.config.ConfigManager;
27 27
 import com.dmdirc.config.IdentityManager;
28
+import com.dmdirc.interfaces.ui.UIController;
28 29
 import com.dmdirc.logger.ErrorLevel;
29 30
 import com.dmdirc.logger.Logger;
30 31
 import com.dmdirc.ui.StatusMessage;
31 32
 import com.dmdirc.ui.core.components.StatusBarManager;
32
-import com.dmdirc.interfaces.ui.UIController;
33 33
 import com.dmdirc.util.CommandUtils;
34 34
 
35 35
 import java.awt.Desktop;
@@ -58,7 +58,7 @@ public class URLHandler {
58 58
      */
59 59
     public URLHandler(final UIController controller) {
60 60
         this.controller = controller;
61
-        this.config = IdentityManager.getGlobalConfig();
61
+        this.config = IdentityManager.getIdentityManager().getGlobalConfiguration();
62 62
         this.desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
63 63
     }
64 64
 
@@ -137,12 +137,10 @@ public class URLHandler {
137 137
         final Date oldLaunch = lastLaunch;
138 138
         lastLaunch = new Date();
139 139
 
140
-        if (IdentityManager.getGlobalConfig().getOptionBool("browser",
141
-                "uselaunchdelay") && oldLaunch != null) {
140
+        if (config.getOptionBool("browser", "uselaunchdelay") && oldLaunch != null) {
142 141
             final Long diff = lastLaunch.getTime() - oldLaunch.getTime();
143 142
 
144
-            if (diff < IdentityManager.getGlobalConfig().getOptionInt("browser",
145
-                    "launchdelay")) {
143
+            if (diff < config.getOptionInt("browser", "launchdelay")) {
146 144
                 return;
147 145
             }
148 146
         }
@@ -157,19 +155,19 @@ public class URLHandler {
157 155
         if ("DMDIRC".equals(command)) {
158 156
             StatusBarManager.getStatusBarManager().setMessage(
159 157
                     new StatusMessage("Connecting to: " + uri.toString(),
160
-                    IdentityManager.getGlobalConfig()));
158
+                    config));
161 159
             ServerManager.getServerManager().connectToAddress(uri);
162 160
         } else if ("BROWSER".equals(command)) {
163 161
             StatusBarManager.getStatusBarManager().setMessage(
164 162
                     new StatusMessage("Opening: " + uri.toString(),
165
-                    IdentityManager.getGlobalConfig()));
163
+                    config));
166 164
             execBrowser(uri);
167 165
         } else if ("MAIL".equals(command)) {
168 166
             execMail(uri);
169 167
         } else {
170 168
             StatusBarManager.getStatusBarManager().setMessage(
171 169
                     new StatusMessage("Opening: " + uri.toString(),
172
-                    IdentityManager.getGlobalConfig()));
170
+                    config));
173 171
             execApp(substituteParams(uri, command));
174 172
         }
175 173
     }

+ 2
- 2
src/com/dmdirc/ui/input/TabCompleter.java Visa fil

@@ -83,9 +83,9 @@ public class TabCompleter {
83 83
         final MapList<TabCompletionType, String> targets
84 84
                 = new MapList<TabCompletionType, String>(entries);
85 85
 
86
-        final boolean caseSensitive = IdentityManager.getGlobalConfig()
86
+        final boolean caseSensitive = IdentityManager.getIdentityManager().getGlobalConfiguration()
87 87
                 .getOptionBool("tabcompletion", "casesensitive");
88
-        final boolean allowEmpty = IdentityManager.getGlobalConfig()
88
+        final boolean allowEmpty = IdentityManager.getIdentityManager().getGlobalConfiguration()
89 89
                 .getOptionBool("tabcompletion", "allowempty");
90 90
 
91 91
         if (partial.isEmpty() && !allowEmpty) {

+ 2
- 2
src/com/dmdirc/ui/input/TabCompleterResult.java Visa fil

@@ -99,8 +99,8 @@ public final class TabCompleterResult {
99 99
             return "";
100 100
         }
101 101
 
102
-        final boolean caseSensitive = IdentityManager.getGlobalConfig()
103
-                .getOptionBool("tabcompletion", "casesensitive");
102
+        final boolean caseSensitive = IdentityManager.getIdentityManager()
103
+                .getGlobalConfiguration().getOptionBool("tabcompletion", "casesensitive");
104 104
 
105 105
         String res = results.get(0);
106 106
         for (String entry : results) {

+ 6
- 3
src/com/dmdirc/ui/messages/ColourManager.java Visa fil

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
+import com.dmdirc.config.ConfigManager;
25 26
 import com.dmdirc.config.IdentityManager;
26 27
 import com.dmdirc.interfaces.ConfigChangeListener;
27 28
 import com.dmdirc.logger.ErrorLevel;
@@ -59,10 +60,12 @@ public final class ColourManager {
59 60
      * Initialises the IRC_COLOURS array.
60 61
      */
61 62
     private static void initColours() {
63
+        final ConfigManager configManager = IdentityManager.getIdentityManager()
64
+                .getGlobalConfiguration();
65
+
62 66
         for (int i = 0; i < 16; i++) {
63
-            if (IdentityManager.getGlobalConfig().hasOptionColour("colour", String.valueOf(i))) {
64
-                ircColours[i] = IdentityManager.getGlobalConfig()
65
-                        .getOptionColour("colour", String.valueOf(i));
67
+            if (configManager.hasOptionColour("colour", String.valueOf(i))) {
68
+                ircColours[i] = configManager.getOptionColour("colour", String.valueOf(i));
66 69
                 COLOUR_CACHE.remove(String.valueOf(i));
67 70
             } else if (!ircColours[i].equals(DEFAULT_COLOURS[i])) {
68 71
                 ircColours[i] = DEFAULT_COLOURS[i];

+ 3
- 2
src/com/dmdirc/ui/themes/ThemeManager.java Visa fil

@@ -44,7 +44,8 @@ public final class ThemeManager {
44 44
     private static final Map<String, Theme> THEMES = new HashMap<String, Theme>();
45 45
 
46 46
     static {
47
-        IdentityManager.getGlobalConfig().addChangeListener("themes", "enabled",
47
+        IdentityManager.getIdentityManager().getGlobalConfiguration()
48
+                .addChangeListener("themes", "enabled",
48 49
                 new ConfigChangeListener() {
49 50
             /** {@inheritDoc} */
50 51
             @Override
@@ -76,7 +77,7 @@ public final class ThemeManager {
76 77
             return;
77 78
         }
78 79
 
79
-        final List<String> enabled = IdentityManager.getGlobalConfig()
80
+        final List<String> enabled = IdentityManager.getIdentityManager().getGlobalConfiguration()
80 81
                 .getOptionList("themes", "enabled");
81 82
 
82 83
         synchronized (THEMES) {

+ 8
- 6
src/com/dmdirc/updater/UpdateChecker.java Visa fil

@@ -118,7 +118,7 @@ public final class UpdateChecker implements Runnable {
118 118
             return;
119 119
         }
120 120
 
121
-        final ConfigManager config = IdentityManager.getGlobalConfig();
121
+        final ConfigManager config = IdentityManager.getIdentityManager().getGlobalConfiguration();
122 122
 
123 123
         if (!config.getOptionBool(DOMAIN, "enable")
124 124
                 || status == STATE.UPDATING) {
@@ -265,7 +265,8 @@ public final class UpdateChecker implements Runnable {
265 265
      * frequency specified in the config.
266 266
      */
267 267
     public static void init() {
268
-        for (String update : IdentityManager.getGlobalConfig().getOptionList(DOMAIN, "updates")) {
268
+        for (String update : IdentityManager.getIdentityManager()
269
+                .getGlobalConfiguration().getOptionList(DOMAIN, "updates")) {
269 270
             checkLine(update);
270 271
         }
271 272
 
@@ -282,9 +283,9 @@ public final class UpdateChecker implements Runnable {
282 283
      * @since 0.6.5
283 284
      */
284 285
     protected static void initTimer() {
285
-        final int last = IdentityManager.getGlobalConfig()
286
+        final int last = IdentityManager.getIdentityManager().getGlobalConfiguration()
286 287
                 .getOptionInt(DOMAIN, "lastcheck");
287
-        final int freq = IdentityManager.getGlobalConfig()
288
+        final int freq = IdentityManager.getIdentityManager().getGlobalConfiguration()
288 289
                 .getOptionInt(DOMAIN, "frequency");
289 290
         final int timestamp = (int) (new Date().getTime() / 1000);
290 291
         int time = 0;
@@ -480,8 +481,9 @@ public final class UpdateChecker implements Runnable {
480 481
      * @return true iif the update component is enabled
481 482
      */
482 483
     public static boolean isEnabled(final UpdateComponent component) {
483
-        return !IdentityManager.getGlobalConfig().hasOptionBool(DOMAIN,
484
-                "enable-" + component.getName()) || IdentityManager.getGlobalConfig()
484
+        return !IdentityManager.getIdentityManager().getGlobalConfiguration()
485
+                .hasOptionBool(DOMAIN, "enable-" + component.getName())
486
+                || IdentityManager.getIdentityManager().getGlobalConfiguration()
485 487
                 .getOptionBool(DOMAIN, "enable-" + component.getName());
486 488
     }
487 489
 

+ 2
- 2
src/com/dmdirc/updater/components/ClientComponent.java Visa fil

@@ -98,8 +98,8 @@ public class ClientComponent implements UpdateComponent {
98 98
     /** {@inheritDoc} */
99 99
     @Override
100 100
     public String getFriendlyVersion() {
101
-        return IdentityManager.getGlobalConfig().getOption("version",
102
-                "version");
101
+        return IdentityManager.getIdentityManager().getGlobalConfiguration()
102
+                .getOption("version", "version");
103 103
     }
104 104
 
105 105
     /** {@inheritDoc} */

+ 2
- 1
src/com/dmdirc/updater/components/DefaultsComponent.java Visa fil

@@ -57,7 +57,8 @@ public class DefaultsComponent implements UpdateComponent {
57 57
     /** {@inheritDoc} */
58 58
     @Override
59 59
     public Version getVersion() {
60
-        final ConfigManager globalConfig = IdentityManager.getGlobalConfig();
60
+        final ConfigManager globalConfig = IdentityManager.getIdentityManager()
61
+                .getGlobalConfiguration();
61 62
 
62 63
         if (globalConfig.hasOptionString("identity", "defaultsversion")) {
63 64
             return new Version(globalConfig.getOption("identity",

+ 2
- 1
src/com/dmdirc/updater/components/ModeAliasesComponent.java Visa fil

@@ -57,7 +57,8 @@ public class ModeAliasesComponent implements UpdateComponent {
57 57
     /** {@inheritDoc} */
58 58
     @Override
59 59
     public Version getVersion() {
60
-        final ConfigManager globalConfig = IdentityManager.getGlobalConfig();
60
+        final ConfigManager globalConfig = IdentityManager.getIdentityManager()
61
+                .getGlobalConfiguration();
61 62
 
62 63
         if (globalConfig.hasOptionString("identity", "modealiasversion")) {
63 64
             return new Version(globalConfig.getOption("identity",

+ 1
- 1
src/com/dmdirc/updater/components/PluginComponent.java Visa fil

@@ -38,7 +38,7 @@ import java.io.File;
38 38
 public class PluginComponent implements UpdateComponent, FileComponent {
39 39
 
40 40
     /** The config to use. */
41
-    private static final ConfigManager CONFIG = IdentityManager.getGlobalConfig();
41
+    private static final ConfigManager CONFIG = IdentityManager.getIdentityManager().getGlobalConfiguration();
42 42
 
43 43
     /** The plugin this component is for. */
44 44
     private final PluginInfo plugin;

+ 6
- 6
test/com/dmdirc/config/IdentityManagerTest.java Visa fil

@@ -22,26 +22,26 @@
22 22
 
23 23
 package com.dmdirc.config;
24 24
 
25
+import static org.junit.Assert.assertTrue;
25 26
 import org.junit.Before;
26 27
 import org.junit.Test;
27
-import static org.junit.Assert.*;
28 28
 
29 29
 public class IdentityManagerTest {
30 30
 
31 31
     @Before
32
-    public void setUp() throws Exception {        
33
-        IdentityManager.load();
32
+    public void setUp() throws Exception {
33
+        IdentityManager.getIdentityManager().initialise();
34 34
     }
35 35
 
36 36
     @Test
37 37
     public void testGetGlobalConfig() {
38
-        final ConfigManager gcm = IdentityManager.getGlobalConfig();
39
-        
38
+        final ConfigManager gcm = IdentityManager.getIdentityManager().getGlobalConfiguration();
39
+
40 40
         for (Identity identity : gcm.getSources()) {
41 41
             assertTrue(identity.getTarget().getType() == ConfigTarget.TYPE.GLOBAL
42 42
                     || identity.getTarget().getType() == ConfigTarget.TYPE.GLOBALDEFAULT
43 43
                     || identity.getTarget().getType() == ConfigTarget.TYPE.THEME);
44 44
         }
45 45
     }
46
-    
46
+
47 47
 }

+ 7
- 2
test/com/dmdirc/config/prefs/PreferencesSettingTest.java Visa fil

@@ -26,10 +26,13 @@ import com.dmdirc.config.IdentityManager;
26 26
 import com.dmdirc.util.validators.NotEmptyValidator;
27 27
 import com.dmdirc.util.validators.PermissiveValidator;
28 28
 import com.dmdirc.util.validators.StringLengthValidator;
29
+
29 30
 import java.util.HashMap;
30 31
 import java.util.Map;
32
+
31 33
 import org.junit.BeforeClass;
32 34
 import org.junit.Test;
35
+
33 36
 import static org.junit.Assert.*;
34 37
 import static org.mockito.Mockito.*;
35 38
 
@@ -180,7 +183,8 @@ public class PreferencesSettingTest {
180 183
 
181 184
         final PreferencesSetting ps = new PreferencesSetting(PreferencesType.TEXT,
182 185
                 "unit-test", "ps", "title", "helptext",
183
-                IdentityManager.getGlobalConfig(), IdentityManager.getConfigIdentity());
186
+                IdentityManager.getIdentityManager().getGlobalConfiguration(),
187
+                IdentityManager.getConfigIdentity());
184 188
 
185 189
         assertFalse(ps.save());
186 190
         ps.setValue(null);
@@ -195,7 +199,8 @@ public class PreferencesSettingTest {
195 199
 
196 200
         final PreferencesSetting ps = new PreferencesSetting(PreferencesType.TEXT,
197 201
                 "unit-test", "ps", "title", "helptext",
198
-                IdentityManager.getGlobalConfig(), IdentityManager.getConfigIdentity());
202
+                IdentityManager.getIdentityManager().getGlobalConfiguration(),
203
+                IdentityManager.getConfigIdentity());
199 204
 
200 205
         assertFalse(ps.save());
201 206
         ps.setValue("def");

+ 1
- 1
test/com/dmdirc/harness/TestWritableFrameContainer.java Visa fil

@@ -45,7 +45,7 @@ public class TestWritableFrameContainer extends WritableFrameContainer {
45 45
     }
46 46
 
47 47
     public TestWritableFrameContainer(final int lineLength) {
48
-        this(lineLength, IdentityManager.getGlobalConfig());
48
+        this(lineLength, IdentityManager.getIdentityManager().getGlobalConfiguration());
49 49
     }
50 50
 
51 51
     @Override

Laddar…
Avbryt
Spara