浏览代码

Use config interfaces where possible.

Change-Id: Iaabedda2fa68c4e5562bb069dcdf15fa0c3beeea
Depends-On: I5f140e89bfb8c57804d0a500bbc9f5c18555b0e9
Reviewed-on: http://gerrit.dmdirc.com/2768
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 年前
父节点
当前提交
a335bf1208
共有 59 个文件被更改,包括 322 次插入276 次删除
  1. 5
    5
      src/com/dmdirc/ClientModule.java
  2. 4
    4
      src/com/dmdirc/FrameContainer.java
  3. 3
    3
      src/com/dmdirc/GlobalWindow.java
  4. 4
    4
      src/com/dmdirc/Main.java
  5. 2
    2
      src/com/dmdirc/MessageTarget.java
  6. 4
    4
      src/com/dmdirc/Server.java
  7. 1
    1
      src/com/dmdirc/ServerManager.java
  8. 4
    4
      src/com/dmdirc/WritableFrameContainer.java
  9. 3
    3
      src/com/dmdirc/actions/Action.java
  10. 4
    4
      src/com/dmdirc/actions/ActionManager.java
  11. 3
    3
      src/com/dmdirc/actions/ActionSubstitutor.java
  12. 2
    2
      src/com/dmdirc/commandparser/CommandManager.java
  13. 4
    5
      src/com/dmdirc/commandparser/PopupManager.java
  14. 1
    1
      src/com/dmdirc/commandparser/commands/global/NewServer.java
  15. 7
    7
      src/com/dmdirc/commandparser/commands/global/SetCommand.java
  16. 2
    2
      src/com/dmdirc/commandparser/parsers/CommandParser.java
  17. 2
    2
      src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java
  18. 2
    2
      src/com/dmdirc/commandparser/parsers/ServerCommandParser.java
  19. 3
    2
      src/com/dmdirc/config/CipherUtils.java
  20. 21
    21
      src/com/dmdirc/config/ConfigManager.java
  21. 42
    0
      src/com/dmdirc/config/ConfigProviderTargetComparator.java
  22. 0
    13
      src/com/dmdirc/config/ConfigSource.java
  23. 8
    8
      src/com/dmdirc/config/Identity.java
  24. 59
    41
      src/com/dmdirc/config/IdentityManager.java
  25. 3
    3
      src/com/dmdirc/config/prefs/PreferencesDialogModel.java
  26. 3
    3
      src/com/dmdirc/config/prefs/PreferencesManager.java
  27. 4
    5
      src/com/dmdirc/config/prefs/PreferencesSetting.java
  28. 3
    3
      src/com/dmdirc/config/validators/URLProtocolValidator.java
  29. 11
    2
      src/com/dmdirc/interfaces/config/AggregateConfigProvider.java
  30. 17
    38
      src/com/dmdirc/interfaces/config/IdentityController.java
  31. 3
    4
      src/com/dmdirc/interfaces/config/IdentityFactory.java
  32. 12
    0
      src/com/dmdirc/interfaces/config/ReadOnlyConfigProvider.java
  33. 3
    3
      src/com/dmdirc/logger/ErrorManager.java
  34. 1
    1
      src/com/dmdirc/logger/ProgramError.java
  35. 3
    3
      src/com/dmdirc/plugins/PluginInfo.java
  36. 1
    1
      src/com/dmdirc/plugins/PluginManager.java
  37. 4
    4
      src/com/dmdirc/tls/CertificateManager.java
  38. 3
    3
      src/com/dmdirc/ui/IconManager.java
  39. 4
    4
      src/com/dmdirc/ui/StatusMessage.java
  40. 3
    3
      src/com/dmdirc/ui/core/util/URLHandler.java
  41. 4
    4
      src/com/dmdirc/ui/input/TabCompleter.java
  42. 3
    3
      src/com/dmdirc/ui/messages/ColourManager.java
  43. 3
    4
      src/com/dmdirc/ui/messages/Formatter.java
  44. 6
    6
      src/com/dmdirc/ui/messages/IRCDocument.java
  45. 3
    3
      src/com/dmdirc/ui/messages/Styliser.java
  46. 2
    2
      src/com/dmdirc/ui/themes/Theme.java
  47. 1
    1
      src/com/dmdirc/ui/themes/ThemeManager.java
  48. 4
    4
      src/com/dmdirc/updater/UpdateChecker.java
  49. 3
    3
      src/com/dmdirc/updater/components/DefaultsComponent.java
  50. 3
    3
      src/com/dmdirc/updater/components/ModeAliasesComponent.java
  51. 2
    2
      src/com/dmdirc/updater/components/PluginComponent.java
  52. 2
    2
      src/com/dmdirc/updater/manager/ConfigComponentPolicy.java
  53. 1
    1
      src/com/dmdirc/updater/manager/DMDircUpdateManager.java
  54. 2
    2
      test/com/dmdirc/ServerTest.java
  55. 8
    8
      test/com/dmdirc/commandparser/commands/global/NewServerTest.java
  56. 1
    1
      test/com/dmdirc/config/CipherUtilsTest.java
  57. 3
    1
      test/com/dmdirc/config/ConfigManagerTest.java
  58. 1
    1
      test/com/dmdirc/harness/TestConfigSource.java
  59. 2
    2
      test/com/dmdirc/ui/messages/FormatterTest.java

+ 5
- 5
src/com/dmdirc/ClientModule.java 查看文件

@@ -32,16 +32,16 @@ import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
32 32
 import com.dmdirc.commandline.CommandLineParser;
33 33
 import com.dmdirc.commandparser.CommandManager;
34 34
 import com.dmdirc.commandparser.commands.CommandModule;
35
-import com.dmdirc.config.ConfigManager;
36 35
 import com.dmdirc.config.IdentityManager;
37 36
 import com.dmdirc.config.InvalidIdentityFileException;
38 37
 import com.dmdirc.config.prefs.PreferencesManager;
39 38
 import com.dmdirc.interfaces.ActionController;
40 39
 import com.dmdirc.interfaces.CommandController;
41
-import com.dmdirc.interfaces.config.IdentityController;
42
-import com.dmdirc.interfaces.config.IdentityFactory;
43 40
 import com.dmdirc.interfaces.LifecycleController;
44 41
 import com.dmdirc.interfaces.ServerFactory;
42
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
43
+import com.dmdirc.interfaces.config.IdentityController;
44
+import com.dmdirc.interfaces.config.IdentityFactory;
45 45
 import com.dmdirc.logger.ErrorLevel;
46 46
 import com.dmdirc.logger.Logger;
47 47
 import com.dmdirc.messages.MessageSinkManager;
@@ -107,7 +107,7 @@ public class ClientModule {
107 107
         }
108 108
 
109 109
         if (commandLineParser.getDisableReporting()) {
110
-            identityManager.getGlobalConfigIdentity()
110
+            identityManager.getUserSettings()
111 111
                     .setOption("temp", "noerrorreporting", true);
112 112
         }
113 113
 
@@ -517,7 +517,7 @@ public class ClientModule {
517 517
     private void checkBundledPlugins(
518 518
             final CorePluginExtractor corePluginExtractor,
519 519
             final PluginManager pm,
520
-            final ConfigManager config) {
520
+            final AggregateConfigProvider config) {
521 521
         for (PluginInfo plugin : pm.getPluginInfos()) {
522 522
             if (config.hasOptionString("bundledplugins_versions", plugin.getMetaData().getName())) {
523 523
                 final Version bundled = new Version(config.getOption("bundledplugins_versions",

+ 4
- 4
src/com/dmdirc/FrameContainer.java 查看文件

@@ -24,12 +24,12 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
-import com.dmdirc.config.ConfigManager;
28
-import com.dmdirc.interfaces.config.ConfigChangeListener;
29 27
 import com.dmdirc.interfaces.FrameCloseListener;
30 28
 import com.dmdirc.interfaces.FrameComponentChangeListener;
31 29
 import com.dmdirc.interfaces.FrameInfoListener;
32 30
 import com.dmdirc.interfaces.NotificationListener;
31
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
32
+import com.dmdirc.interfaces.config.ConfigChangeListener;
33 33
 import com.dmdirc.ui.Colour;
34 34
 import com.dmdirc.ui.IconManager;
35 35
 import com.dmdirc.ui.WindowManager;
@@ -91,7 +91,7 @@ public abstract class FrameContainer {
91 91
 
92 92
     /** The config manager for this container. */
93 93
     @Getter
94
-    private final ConfigManager configManager;
94
+    private final AggregateConfigProvider configManager;
95 95
 
96 96
     /** The IconChanger for this container. */
97 97
     private final IconChanger changer = new IconChanger();
@@ -124,7 +124,7 @@ public abstract class FrameContainer {
124 124
      */
125 125
     protected FrameContainer(
126 126
             final String icon, final String name,
127
-            final String title, final ConfigManager config,
127
+            final String title, final AggregateConfigProvider config,
128 128
             final Collection<String> components) {
129 129
         this.configManager = config;
130 130
         this.name = name;

+ 3
- 3
src/com/dmdirc/GlobalWindow.java 查看文件

@@ -27,8 +27,8 @@ import com.dmdirc.commandparser.CommandManager;
27 27
 import com.dmdirc.commandparser.CommandType;
28 28
 import com.dmdirc.commandparser.parsers.CommandParser;
29 29
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
30
-import com.dmdirc.config.ConfigManager;
31 30
 import com.dmdirc.config.IdentityManager;
31
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
32 32
 import com.dmdirc.interfaces.config.ConfigChangeListener;
33 33
 import com.dmdirc.ui.WindowManager;
34 34
 import com.dmdirc.ui.core.components.WindowComponent;
@@ -58,7 +58,7 @@ public class GlobalWindow extends WritableFrameContainer {
58 58
      * @param config The ConfigManager to retrieve settings from.
59 59
      * @param parser The command parser to use to parse input.
60 60
      */
61
-    public GlobalWindow(final ConfigManager config, final CommandParser parser) {
61
+    public GlobalWindow(final AggregateConfigProvider config, final CommandParser parser) {
62 62
         super("icon", "Global", "(Global)",
63 63
                 config, parser,
64 64
                 Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
@@ -129,7 +129,7 @@ public class GlobalWindow extends WritableFrameContainer {
129 129
      * general.showglobalwindow config setting.
130 130
      */
131 131
     protected static void updateWindowState() {
132
-        final ConfigManager configManager = IdentityManager.getIdentityManager()
132
+        final AggregateConfigProvider configManager = IdentityManager.getIdentityManager()
133 133
                 .getGlobalConfiguration();
134 134
 
135 135
         synchronized (GlobalWindow.class) {

+ 4
- 4
src/com/dmdirc/Main.java 查看文件

@@ -195,7 +195,7 @@ public class Main {
195 195
                 new WarningDialog(WarningDialog.NO_COMPAT_UIS_TITLE,
196 196
                         WarningDialog.NO_RECOV_UIS).displayBlocking();
197 197
             }
198
-            identityManager.getGlobalConfigIdentity().unsetOption("debug", "uiFixAttempted");
198
+            identityManager.getUserSettings().unsetOption("debug", "uiFixAttempted");
199 199
             System.exit(1);
200 200
         } else {
201 201
             // Try to extract the UIs again incase they changed between versions
@@ -210,7 +210,7 @@ public class Main {
210 210
             }
211 211
 
212 212
             // Allow the rebooted DMDirc to know that we have attempted restarting.
213
-            identityManager.getGlobalConfigIdentity().setOption("debug", "uiFixAttempted", "true");
213
+            identityManager.getUserSettings().setOption("debug", "uiFixAttempted", "true");
214 214
             // Tell the launcher to restart!
215 215
             System.exit(42);
216 216
         }
@@ -243,7 +243,7 @@ public class Main {
243 243
         } else {
244 244
             // The fix worked!
245 245
             if (identityManager.getGlobalConfiguration().hasOptionBool("debug", "uiFixAttempted")) {
246
-                identityManager.getGlobalConfigIdentity().unsetOption("debug", "uiFixAttempted");
246
+                identityManager.getUserSettings().unsetOption("debug", "uiFixAttempted");
247 247
             }
248 248
         }
249 249
     }
@@ -253,7 +253,7 @@ public class Main {
253 253
      */
254 254
     private void doFirstRun() {
255 255
         if (identityManager.getGlobalConfiguration().getOptionBool("general", "firstRun")) {
256
-            identityManager.getGlobalConfigIdentity().setOption("general", "firstRun", "false");
256
+            identityManager.getUserSettings().setOption("general", "firstRun", "false");
257 257
             for (UIController controller : CONTROLLERS) {
258 258
                 controller.showFirstRunWizard();
259 259
             }

+ 2
- 2
src/com/dmdirc/MessageTarget.java 查看文件

@@ -23,7 +23,7 @@
23 23
 package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.commandparser.parsers.CommandParser;
26
-import com.dmdirc.config.ConfigManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 
28 28
 import java.util.Collection;
29 29
 
@@ -45,7 +45,7 @@ public abstract class MessageTarget extends WritableFrameContainer {
45 45
      * @since 0.6.4
46 46
      */
47 47
     public MessageTarget(final String icon, final String name,
48
-            final String title, final ConfigManager config,
48
+            final String title, final AggregateConfigProvider config,
49 49
             final CommandParser parser, final Collection<String> components) {
50 50
         super(icon, name, title, config, parser, components);
51 51
     }

+ 4
- 4
src/com/dmdirc/Server.java 查看文件

@@ -27,14 +27,14 @@ import com.dmdirc.actions.CoreActionType;
27 27
 import com.dmdirc.actions.wrappers.AliasWrapper;
28 28
 import com.dmdirc.commandparser.CommandType;
29 29
 import com.dmdirc.commandparser.parsers.CommandParser;
30
-import com.dmdirc.config.ConfigManager;
31 30
 import com.dmdirc.interfaces.AwayStateListener;
32 31
 import com.dmdirc.interfaces.CommandController;
33
-import com.dmdirc.interfaces.config.ConfigChangeListener;
34 32
 import com.dmdirc.interfaces.Connection;
35
-import com.dmdirc.interfaces.config.IdentityFactory;
36 33
 import com.dmdirc.interfaces.InviteListener;
34
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
35
+import com.dmdirc.interfaces.config.ConfigChangeListener;
37 36
 import com.dmdirc.interfaces.config.ConfigProvider;
37
+import com.dmdirc.interfaces.config.IdentityFactory;
38 38
 import com.dmdirc.logger.ErrorLevel;
39 39
 import com.dmdirc.logger.Logger;
40 40
 import com.dmdirc.parser.common.ChannelJoinRequest;
@@ -210,7 +210,7 @@ public class Server extends WritableFrameContainer
210 210
      */
211 211
     public Server(
212 212
             final ServerManager manager,
213
-            final ConfigManager configManager,
213
+            final AggregateConfigProvider configManager,
214 214
             final CommandParser commandParser,
215 215
             final ParserFactory parserFactory,
216 216
             final WindowManager windowManager,

+ 1
- 1
src/com/dmdirc/ServerManager.java 查看文件

@@ -222,7 +222,7 @@ public class ServerManager implements ServerFactory {
222 222
      */
223 223
     public Server connectToAddress(final URI uri) {
224 224
         return connectToAddress(uri,
225
-                identityController.getIdentitiesByType("profile").get(0));
225
+                identityController.getProvidersByType("profile").get(0));
226 226
     }
227 227
 
228 228
     /**

+ 4
- 4
src/com/dmdirc/WritableFrameContainer.java 查看文件

@@ -24,8 +24,8 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.commandparser.parsers.CommandParser;
27
-import com.dmdirc.config.ConfigManager;
28 27
 import com.dmdirc.interfaces.actions.ActionType;
28
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 29
 import com.dmdirc.messages.MessageSinkManager;
30 30
 import com.dmdirc.parser.common.CompositionState;
31 31
 import com.dmdirc.ui.input.TabCompleter;
@@ -43,10 +43,10 @@ import java.util.List;
43 43
 public abstract class WritableFrameContainer extends FrameContainer {
44 44
 
45 45
     /** The name of the server notification target. */
46
-    protected static final String NOTIFICATION_SERVER = "server".intern();
46
+    protected static final String NOTIFICATION_SERVER = "server";
47 47
 
48 48
     /** The name of the channel notification target. */
49
-    protected static final String NOTIFICATION_CHANNEL = "channel".intern();
49
+    protected static final String NOTIFICATION_CHANNEL = "channel";
50 50
 
51 51
     /** The command parser used for commands in this container. */
52 52
     protected final CommandParser commandParser;
@@ -63,7 +63,7 @@ public abstract class WritableFrameContainer extends FrameContainer {
63 63
      * @since 0.6.4
64 64
      */
65 65
     public WritableFrameContainer(final String icon, final String name,
66
-            final String title, final ConfigManager config,
66
+            final String title, final AggregateConfigProvider config,
67 67
             final CommandParser parser, final Collection<String> components) {
68 68
         super(icon, name, title, config, components);
69 69
 

+ 3
- 3
src/com/dmdirc/actions/Action.java 查看文件

@@ -267,7 +267,7 @@ public class Action extends ActionModel implements ConfigChangeListener {
267 267
                         PreferencesType.valueOf(data.get("type")), "actions",
268 268
                         data.get("setting"), data.get("title"), data.get("tooltip"),
269 269
                         IdentityManager.getIdentityManager().getGlobalConfiguration(),
270
-                        IdentityManager.getIdentityManager().getGlobalConfigIdentity()));
270
+                        IdentityManager.getIdentityManager().getUserSettings()));
271 271
             }
272 272
         }
273 273
     }
@@ -592,10 +592,10 @@ public class Action extends ActionModel implements ConfigChangeListener {
592 592
      */
593 593
     public void setEnabled(final boolean enabled) {
594 594
         if (enabled) {
595
-            IdentityManager.getIdentityManager().getGlobalConfigIdentity()
595
+            IdentityManager.getIdentityManager().getUserSettings()
596 596
                     .unsetOption("disable_action", (group + "/" + name).replace(' ', '.'));
597 597
         } else {
598
-            IdentityManager.getIdentityManager().getGlobalConfigIdentity()
598
+            IdentityManager.getIdentityManager().getUserSettings()
599 599
                     .setOption("disable_action", (group + "/" + name).replace(' ', '.'), true);
600 600
         }
601 601
     }

+ 4
- 4
src/com/dmdirc/actions/ActionManager.java 查看文件

@@ -28,10 +28,10 @@ import com.dmdirc.actions.internal.WhoisNumericFormatter;
28 28
 import com.dmdirc.config.ConfigBinding;
29 29
 import com.dmdirc.interfaces.ActionController;
30 30
 import com.dmdirc.interfaces.ActionListener;
31
-import com.dmdirc.interfaces.config.IdentityController;
32 31
 import com.dmdirc.interfaces.actions.ActionComparison;
33 32
 import com.dmdirc.interfaces.actions.ActionComponent;
34 33
 import com.dmdirc.interfaces.actions.ActionType;
34
+import com.dmdirc.interfaces.config.IdentityController;
35 35
 import com.dmdirc.logger.ErrorLevel;
36 36
 import com.dmdirc.logger.Logger;
37 37
 import com.dmdirc.updater.UpdateChecker;
@@ -162,7 +162,7 @@ public class ActionManager implements ActionController {
162 162
             addGroup(wrapper);
163 163
         }
164 164
 
165
-        new WhoisNumericFormatter(identityManager.getGlobalAddonIdentity()).register();
165
+        new WhoisNumericFormatter(identityManager.getAddonSettings()).register();
166 166
 
167 167
         // Register a listener for the closing event, so we can save actions
168 168
         registerListener(new ActionListener() {
@@ -189,7 +189,7 @@ public class ActionManager implements ActionController {
189 189
     @Override
190 190
     public void registerSetting(final String name, final String value) {
191 191
         log.debug("Registering new action setting: {} = {}", name, value);
192
-        identityManager.getGlobalAddonIdentity().setOption("actions", name, value);
192
+        identityManager.getAddonSettings().setOption("actions", name, value);
193 193
     }
194 194
 
195 195
     /** {@inheritDoc} */
@@ -438,7 +438,7 @@ public class ActionManager implements ActionController {
438 438
      * @return The directory that should be used to store actions
439 439
      */
440 440
     public String getDirectory() {
441
-        return this.identityManager.getConfigDir() + "actions" + System.getProperty("file.separator");
441
+        return this.identityManager.getConfigurationDirectory() + "actions" + System.getProperty("file.separator");
442 442
     }
443 443
 
444 444
     /** {@inheritDoc} */

+ 3
- 3
src/com/dmdirc/actions/ActionSubstitutor.java 查看文件

@@ -27,11 +27,11 @@ import com.dmdirc.Precondition;
27 27
 import com.dmdirc.Server;
28 28
 import com.dmdirc.ServerState;
29 29
 import com.dmdirc.commandparser.CommandArguments;
30
-import com.dmdirc.config.ConfigManager;
31 30
 import com.dmdirc.config.IdentityManager;
32 31
 import com.dmdirc.interfaces.ActionController;
33 32
 import com.dmdirc.interfaces.actions.ActionComponent;
34 33
 import com.dmdirc.interfaces.actions.ActionType;
34
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
35 35
 import com.dmdirc.interfaces.ui.Window;
36 36
 
37 37
 import java.util.Arrays;
@@ -270,7 +270,7 @@ public class ActionSubstitutor {
270 270
             }
271 271
         }
272 272
 
273
-        final ConfigManager manager = getConfigManager(args);
273
+        final AggregateConfigProvider manager = getConfigManager(args);
274 274
 
275 275
         if (manager.hasOptionString("actions", substitution)) {
276 276
             return manager.getOption("actions", substitution);
@@ -328,7 +328,7 @@ public class ActionSubstitutor {
328 328
      * @return The best config manager to use for those arguments
329 329
      * @since 0.6.3m2
330 330
      */
331
-    protected ConfigManager getConfigManager(final Object ... args) {
331
+    protected AggregateConfigProvider getConfigManager(final Object ... args) {
332 332
         for (Object arg : args) {
333 333
             if (arg instanceof FrameContainer) {
334 334
                 return ((FrameContainer) arg).getConfigManager();

+ 2
- 2
src/com/dmdirc/commandparser/CommandManager.java 查看文件

@@ -28,8 +28,8 @@ import com.dmdirc.ServerManager;
28 28
 import com.dmdirc.commandparser.commands.Command;
29 29
 import com.dmdirc.commandparser.parsers.CommandParser;
30 30
 import com.dmdirc.config.ConfigBinding;
31
-import com.dmdirc.config.ConfigManager;
32 31
 import com.dmdirc.interfaces.CommandController;
32
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
33 33
 import com.dmdirc.ui.input.TabCompleter;
34 34
 import com.dmdirc.ui.input.TabCompletionType;
35 35
 import com.dmdirc.util.collections.MapList;
@@ -86,7 +86,7 @@ public class CommandManager implements CommandController {
86 86
      *
87 87
      * @param configManager The configuration manager to read settings from.
88 88
      */
89
-    public void initialise(final ConfigManager configManager) {
89
+    public void initialise(final AggregateConfigProvider configManager) {
90 90
         configManager.getBinder().bind(this, CommandManager.class);
91 91
     }
92 92
 

+ 4
- 5
src/com/dmdirc/commandparser/PopupManager.java 查看文件

@@ -24,8 +24,7 @@ package com.dmdirc.commandparser;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
-import com.dmdirc.config.ConfigManager;
28
-
27
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 28
 
30 29
 /**
31 30
  * The popup manager manages which commands should be present in popup menus.
@@ -47,7 +46,7 @@ public class PopupManager {
47 46
      * @param configManager The config manager to be used for the menu
48 47
      * @return The PopupMenu that should be displayed
49 48
      */
50
-    public static PopupMenu getMenu(final PopupType menuType, final ConfigManager configManager) {
49
+    public static PopupMenu getMenu(final PopupType menuType, final AggregateConfigProvider configManager) {
51 50
         final PopupMenu menu = getMenu(menuType.toString(), menuType, configManager);
52 51
 
53 52
         ActionManager.getActionManager().triggerEvent(
@@ -66,7 +65,7 @@ public class PopupManager {
66 65
      * @return The PopupMenu with the specified name
67 66
      */
68 67
     private static PopupMenu getMenu(final String menuName,
69
-            final PopupType type, final ConfigManager configManager) {
68
+            final PopupType type, final AggregateConfigProvider configManager) {
70 69
         final PopupMenu res = new PopupMenu();
71 70
 
72 71
         for (String item : configManager.getOptionList("popups", menuName)) {
@@ -89,7 +88,7 @@ public class PopupManager {
89 88
      * @return The corresponding PopupMenuItem
90 89
      */
91 90
     private static PopupMenuItem getItem(final String item,
92
-            final PopupType type, final ConfigManager configManager) {
91
+            final PopupType type, final AggregateConfigProvider configManager) {
93 92
         PopupMenuItem res;
94 93
 
95 94
         if ("-".equals(item)) {

+ 1
- 1
src/com/dmdirc/commandparser/commands/global/NewServer.java 查看文件

@@ -115,7 +115,7 @@ public class NewServer extends Command implements IntelligentCommand {
115 115
         }
116 116
 
117 117
         final Server server = serverFactory.createServer(address,
118
-                identityController.getIdentitiesByType("profile").get(0));
118
+                identityController.getProvidersByType("profile").get(0));
119 119
         server.connect();
120 120
     }
121 121
 

+ 7
- 7
src/com/dmdirc/commandparser/commands/global/SetCommand.java 查看文件

@@ -35,8 +35,8 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.commands.flags.CommandFlag;
36 36
 import com.dmdirc.commandparser.commands.flags.CommandFlagHandler;
37 37
 import com.dmdirc.commandparser.commands.flags.CommandFlagResult;
38
-import com.dmdirc.config.ConfigManager;
39 38
 import com.dmdirc.interfaces.CommandController;
39
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
40 40
 import com.dmdirc.interfaces.config.ConfigProvider;
41 41
 import com.dmdirc.interfaces.config.IdentityController;
42 42
 import com.dmdirc.interfaces.config.IdentityFactory;
@@ -110,8 +110,8 @@ public class SetCommand extends Command implements IntelligentCommand {
110 110
             return;
111 111
         }
112 112
 
113
-        ConfigProvider identity = identityController.getGlobalConfigIdentity();
114
-        ConfigManager manager = identityController.getGlobalConfiguration();
113
+        ConfigProvider identity = identityController.getUserSettings();
114
+        AggregateConfigProvider manager = identityController.getGlobalConfiguration();
115 115
 
116 116
         if (res.hasFlag(serverFlag)) {
117 117
             if (origin.getServer() == null) {
@@ -178,7 +178,7 @@ public class SetCommand extends Command implements IntelligentCommand {
178 178
      * @param manager The config manager to use to retrieve data
179 179
      */
180 180
     private void doDomainList(final FrameContainer origin, final boolean isSilent,
181
-            final ConfigManager manager) {
181
+            final AggregateConfigProvider manager) {
182 182
         final StringBuffer output = new StringBuffer(67);
183 183
 
184 184
         output.append("Valid domains (use ");
@@ -202,7 +202,7 @@ public class SetCommand extends Command implements IntelligentCommand {
202 202
      * @param domain The domain to be inspected
203 203
      */
204 204
     private void doOptionsList(final FrameContainer origin,
205
-            final boolean isSilent, final ConfigManager manager, final String domain) {
205
+            final boolean isSilent, final AggregateConfigProvider manager, final String domain) {
206 206
         final StringBuffer output = new StringBuffer(24);
207 207
 
208 208
         output.append("Options in domain '");
@@ -235,7 +235,7 @@ public class SetCommand extends Command implements IntelligentCommand {
235 235
      * @param option The name of the option
236 236
      */
237 237
     private void doShowOption(final FrameContainer origin,
238
-            final boolean isSilent, final ConfigManager manager,
238
+            final boolean isSilent, final AggregateConfigProvider manager,
239 239
             final String domain, final String option) {
240 240
         if (manager.hasOptionString(domain, option)) {
241 241
             sendLine(origin, isSilent, FORMAT_OUTPUT, "The current value of "
@@ -276,7 +276,7 @@ public class SetCommand extends Command implements IntelligentCommand {
276 276
      * @param data The data to be appended
277 277
      */
278 278
     private void doAppendOption(final FrameContainer origin,
279
-            final boolean isSilent, final ConfigProvider identity, final ConfigManager manager,
279
+            final boolean isSilent, final ConfigProvider identity, final AggregateConfigProvider manager,
280 280
             final String domain, final String option, final String data) {
281 281
         doSetOption(origin, isSilent, identity, domain, option,
282 282
                 (manager.hasOptionString(domain, option)

+ 2
- 2
src/com/dmdirc/commandparser/parsers/CommandParser.java 查看文件

@@ -35,7 +35,7 @@ import com.dmdirc.commandparser.commands.Command;
35 35
 import com.dmdirc.commandparser.commands.CommandOptions;
36 36
 import com.dmdirc.commandparser.commands.ExternalCommand;
37 37
 import com.dmdirc.commandparser.commands.PreviousCommand;
38
-import com.dmdirc.config.ConfigManager;
38
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
39 39
 import com.dmdirc.util.collections.RollingList;
40 40
 
41 41
 import java.io.Serializable;
@@ -73,7 +73,7 @@ public abstract class CommandParser implements Serializable {
73 73
     protected final CommandManager commandManager;
74 74
 
75 75
     /** Creates a new instance of CommandParser. */
76
-    protected CommandParser(final ConfigManager configManager,
76
+    protected CommandParser(final AggregateConfigProvider configManager,
77 77
             final CommandManager commandManager) {
78 78
         commands = new HashMap<>();
79 79
         history = new RollingList<>(configManager.getOptionInt("general", "commandhistory"));

+ 2
- 2
src/com/dmdirc/commandparser/parsers/GlobalCommandParser.java 查看文件

@@ -29,7 +29,7 @@ import com.dmdirc.commandparser.CommandManager;
29 29
 import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
32
-import com.dmdirc.config.ConfigManager;
32
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
33 33
 import com.dmdirc.logger.ErrorLevel;
34 34
 import com.dmdirc.logger.Logger;
35 35
 
@@ -51,7 +51,7 @@ public class GlobalCommandParser extends CommandParser {
51 51
      * @param configManager Config manager to read settings from
52 52
      * @param commandManager Command manager to load commands from
53 53
      */
54
-    public GlobalCommandParser(final ConfigManager configManager,
54
+    public GlobalCommandParser(final AggregateConfigProvider configManager,
55 55
             final CommandManager commandManager) {
56 56
         super(configManager, commandManager);
57 57
     }

+ 2
- 2
src/com/dmdirc/commandparser/parsers/ServerCommandParser.java 查看文件

@@ -31,7 +31,7 @@ import com.dmdirc.commandparser.CommandManager;
31 31
 import com.dmdirc.commandparser.CommandType;
32 32
 import com.dmdirc.commandparser.commands.Command;
33 33
 import com.dmdirc.commandparser.commands.context.ServerCommandContext;
34
-import com.dmdirc.config.ConfigManager;
34
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
35 35
 
36 36
 /**
37 37
  * A command parser used in the context of a server.
@@ -50,7 +50,7 @@ public class ServerCommandParser extends GlobalCommandParser {
50 50
      *
51 51
      * @param configManager Config manager to read settings from
52 52
      */
53
-    public ServerCommandParser(final ConfigManager configManager) {
53
+    public ServerCommandParser(final AggregateConfigProvider configManager) {
54 54
         super(configManager, CommandManager.getCommandManager());
55 55
     }
56 56
 

+ 3
- 2
src/com/dmdirc/config/CipherUtils.java 查看文件

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.config;
24 24
 
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
25 26
 import com.dmdirc.interfaces.config.IdentityController;
26 27
 import com.dmdirc.logger.ErrorLevel;
27 28
 import com.dmdirc.logger.Logger;
@@ -184,7 +185,7 @@ public abstract class CipherUtils {
184 185
      * @return true if auth was successful, false otherwise.
185 186
      */
186 187
     public boolean auth() {
187
-        final ConfigManager configManager = identityController.getGlobalConfiguration();
188
+        final AggregateConfigProvider configManager = identityController.getGlobalConfiguration();
188 189
 
189 190
         String passwordHash = null;
190 191
         String prompt = "Please enter your password";
@@ -200,7 +201,7 @@ public abstract class CipherUtils {
200 201
                 password = getPassword(prompt);
201 202
                 if (passwordHash == null) {
202 203
                     passwordHash = hash(password);
203
-                    identityController.getGlobalConfigIdentity()
204
+                    identityController.getUserSettings()
204 205
                             .setOption("encryption", "passwordHash", passwordHash);
205 206
                 }
206 207
                 if (!hash(password).equals(passwordHash)) {

+ 21
- 21
src/com/dmdirc/config/ConfigManager.java 查看文件

@@ -22,10 +22,10 @@
22 22
 
23 23
 package com.dmdirc.config;
24 24
 
25
-import com.dmdirc.interfaces.config.ConfigProviderListener;
26 25
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 26
 import com.dmdirc.interfaces.config.ConfigChangeListener;
28 27
 import com.dmdirc.interfaces.config.ConfigProvider;
28
+import com.dmdirc.interfaces.config.ConfigProviderListener;
29 29
 import com.dmdirc.util.collections.MapList;
30 30
 import com.dmdirc.util.validators.Validator;
31 31
 
@@ -56,7 +56,7 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
56 56
     private static final String VERSION_DOMAIN = "version";
57 57
 
58 58
     /** A list of sources for this config manager. */
59
-    private final List<Identity> sources;
59
+    private final List<ConfigProvider> sources;
60 60
 
61 61
     /** The listeners registered for this manager. */
62 62
     private final MapList<String, ConfigChangeListener> listeners = new MapList<>();
@@ -115,7 +115,7 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
115 115
         log.debug("Found {} source(s) for protocol: {}, ircd: {}, network: {}, server: {}, channel: {}",
116 116
                 new Object[] { sources.size(), protocol, ircd, network, server, chanName });
117 117
 
118
-        for (Identity identity : sources) {
118
+        for (ConfigProvider identity : sources) {
119 119
             log.trace("Found {}", identity);
120 120
             identity.addListener(this);
121 121
         }
@@ -131,11 +131,11 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
131 131
 
132 132
         if (VERSION_DOMAIN.equals(domain)) {
133 133
             return IdentityManager.getIdentityManager()
134
-                    .getGlobalVersionIdentity().getOption(domain, option, validator);
134
+                    .getVersionSettings().getOption(domain, option, validator);
135 135
         }
136 136
 
137 137
         synchronized (sources) {
138
-            for (Identity source : sources) {
138
+            for (ConfigProvider source : sources) {
139 139
                 if (source.hasOption(domain, option, validator)) {
140 140
                     return source.getOption(domain, option, validator);
141 141
                 }
@@ -147,17 +147,17 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
147 147
 
148 148
     /** {@inheritDoc} */
149 149
     @Override
150
-    protected boolean hasOption(final String domain, final String option,
150
+    public boolean hasOption(final String domain, final String option,
151 151
             final Validator<String> validator) {
152 152
         doStats(domain, option);
153 153
 
154 154
         if (VERSION_DOMAIN.equals(domain)) {
155 155
             return IdentityManager.getIdentityManager()
156
-                    .getGlobalVersionIdentity().hasOption(domain, option, validator);
156
+                    .getVersionSettings().hasOption(domain, option, validator);
157 157
         }
158 158
 
159 159
         synchronized (sources) {
160
-            for (Identity source : sources) {
160
+            for (ConfigProvider source : sources) {
161 161
                 if (source.hasOption(domain, option, validator)) {
162 162
                     return true;
163 163
                 }
@@ -172,7 +172,7 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
172 172
     public Map<String, String> getOptions(final String domain) {
173 173
         if (VERSION_DOMAIN.equals(domain)) {
174 174
             return IdentityManager.getIdentityManager()
175
-                    .getGlobalVersionIdentity().getOptions(domain);
175
+                    .getVersionSettings().getOptions(domain);
176 176
         }
177 177
 
178 178
         final Map<String, String> res = new HashMap<>();
@@ -191,7 +191,7 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
191 191
      *
192 192
      * @param identity The identity to be removed
193 193
      */
194
-    public void removeIdentity(final Identity identity) {
194
+    public void removeIdentity(final ConfigProvider identity) {
195 195
         if (!sources.contains(identity)) {
196 196
             return;
197 197
         }
@@ -226,14 +226,14 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
226 226
      * @param option The option to search for
227 227
      * @return The identity that defines that setting, or null on failure
228 228
      */
229
-    protected Identity getScope(final String domain, final String option) {
229
+    protected ConfigProvider getScope(final String domain, final String option) {
230 230
         if (VERSION_DOMAIN.equals(domain)) {
231 231
             return IdentityManager.getIdentityManager()
232
-                    .getGlobalVersionIdentity();
232
+                    .getVersionSettings();
233 233
         }
234 234
 
235 235
         synchronized (sources) {
236
-            for (Identity source : sources) {
236
+            for (ConfigProvider source : sources) {
237 237
                 if (source.hasOptionString(domain, option)) {
238 238
                     return source;
239 239
                 }
@@ -249,7 +249,7 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
249 249
      * @param identity The identity to test
250 250
      * @return True if the identity applies, false otherwise
251 251
      */
252
-    public boolean identityApplies(final Identity identity) {
252
+    public boolean identityApplies(final ConfigProvider identity) {
253 253
         String comp;
254 254
 
255 255
         switch (identity.getTarget().getType()) {
@@ -308,12 +308,12 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
308 308
      *
309 309
      * @param identity The identity to be checked
310 310
      */
311
-    public void checkIdentity(final Identity identity) {
311
+    public void checkIdentity(final ConfigProvider identity) {
312 312
         if (!sources.contains(identity) && identityApplies(identity)) {
313 313
             synchronized (sources) {
314 314
                 sources.add(identity);
315 315
                 identity.addListener(this);
316
-                Collections.sort(sources);
316
+                Collections.sort(sources, new ConfigProviderTargetComparator());
317 317
             }
318 318
 
319 319
             // Determine which settings will have changed
@@ -333,7 +333,7 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
333 333
         final Set<String> res = new HashSet<>();
334 334
 
335 335
         synchronized (sources) {
336
-            for (Identity source : sources) {
336
+            for (ConfigProvider source : sources) {
337 337
                 res.addAll(source.getDomains());
338 338
             }
339 339
         }
@@ -343,7 +343,7 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
343 343
 
344 344
     /** {@inheritDoc} */
345 345
     @Override
346
-    public List<Identity> getSources() {
346
+    public List<ConfigProvider> getSources() {
347 347
         return new ArrayList<>(sources);
348 348
     }
349 349
 
@@ -370,16 +370,16 @@ public class ConfigManager extends ConfigSource implements ConfigChangeListener,
370 370
         this.server = server;
371 371
         this.channel = channel + "@" + network;
372 372
 
373
-        for (Identity identity : new ArrayList<>(sources)) {
373
+        for (ConfigProvider identity : new ArrayList<>(sources)) {
374 374
             if (!identityApplies(identity)) {
375 375
                 log.debug("Removing identity that no longer applies: {}", identity);
376 376
                 removeIdentity(identity);
377 377
             }
378 378
         }
379 379
 
380
-        final List<Identity> newSources = IdentityManager.getIdentityManager()
380
+        final List<ConfigProvider> newSources = IdentityManager.getIdentityManager()
381 381
                 .getIdentitiesForManager(this);
382
-        for (Identity identity : newSources) {
382
+        for (ConfigProvider identity : newSources) {
383 383
             log.trace("Testing new identity: {}", identity);
384 384
             checkIdentity(identity);
385 385
         }

+ 42
- 0
src/com/dmdirc/config/ConfigProviderTargetComparator.java 查看文件

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2013 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.config;
24
+
25
+import com.dmdirc.interfaces.config.ConfigProvider;
26
+
27
+import java.util.Comparator;
28
+
29
+/**
30
+ * Compares {@link ConfigProvider}s by their targets.
31
+ *
32
+ * A collection sorted by this comparator will have the most specific (tightly scoped) providers
33
+ * first, and global (loosely scoped) last.
34
+ */
35
+public class ConfigProviderTargetComparator implements Comparator<ConfigProvider> {
36
+
37
+    /** {@inheritDoc} */
38
+    @Override
39
+    public int compare(final ConfigProvider t, final ConfigProvider t1) {
40
+        return t1.getTarget().compareTo(t.getTarget());
41
+    }
42
+}

+ 0
- 13
src/com/dmdirc/config/ConfigSource.java 查看文件

@@ -103,19 +103,6 @@ public abstract class ConfigSource implements ReadOnlyConfigProvider {
103 103
     public abstract String getOption(final String domain,
104 104
             final String option, final Validator<String> validator);
105 105
 
106
-    /**
107
-     * Determines if this source has a value for the specified option which
108
-     * matches the specified validator.
109
-     *
110
-     * @since 0.6.5
111
-     * @param domain The domain of the option
112
-     * @param option The name of the option
113
-     * @param validator The validator to use to check legal values
114
-     * @return True iff a matching option exists, false otherwise.
115
-     */
116
-    protected abstract boolean hasOption(final String domain,
117
-            final String option, final Validator<String> validator);
118
-
119 106
     /** {@inheritDoc} */
120 107
     @Override
121 108
     public boolean hasOptionString(final String domain, final String option) {

+ 8
- 8
src/com/dmdirc/config/Identity.java 查看文件

@@ -58,10 +58,10 @@ public class Identity extends ConfigSource implements Comparable<Identity>, Conf
58 58
     protected static final String ILLEGAL_CHARS = "[\\\\\"/:\\*\\?\"<>\\|]";
59 59
 
60 60
     /** The domain used for identity settings. */
61
-    private static final String DOMAIN = "identity".intern();
61
+    private static final String DOMAIN = "identity";
62 62
 
63 63
     /** The domain used for profile settings. */
64
-    private static final String PROFILE_DOMAIN = "profile".intern();
64
+    private static final String PROFILE_DOMAIN = "profile";
65 65
 
66 66
     /** The target for this identity. */
67 67
     protected final ConfigTarget myTarget;
@@ -299,7 +299,7 @@ public class Identity extends ConfigSource implements Comparable<Identity>, Conf
299 299
 
300 300
     /** {@inheritDoc} */
301 301
     @Override
302
-    protected boolean hasOption(final String domain, final String option,
302
+    public boolean hasOption(final String domain, final String option,
303 303
             final Validator<String> validator) {
304 304
         return file.isKeyDomain(domain)
305 305
                 && file.getKeyDomain(domain).containsKey(option)
@@ -449,10 +449,10 @@ public class Identity extends ConfigSource implements Comparable<Identity>, Conf
449 449
                 }
450 450
 
451 451
                 globalConfig.removeIdentity(this);
452
-                globalConfig.removeIdentity(IdentityManager.getIdentityManager().getGlobalVersionIdentity());
452
+                globalConfig.removeIdentity(IdentityManager.getIdentityManager().getVersionSettings());
453 453
 
454 454
                 if (log.isTraceEnabled()) {
455
-                    for (Identity source : globalConfig.getSources()) {
455
+                    for (ConfigProvider source : globalConfig.getSources()) {
456 456
                         log.trace("{}: source: {}",
457 457
                                 new Object[]{ getName(), source.getName() });
458 458
                     }
@@ -498,7 +498,7 @@ public class Identity extends ConfigSource implements Comparable<Identity>, Conf
498 498
             file.delete();
499 499
         }
500 500
 
501
-        IdentityManager.getIdentityManager().unregisterIdentity(this);
501
+        IdentityManager.getIdentityManager().removeConfigProvider(this);
502 502
     }
503 503
 
504 504
     /** {@inheritDoc} */
@@ -584,7 +584,7 @@ public class Identity extends ConfigSource implements Comparable<Identity>, Conf
584 584
         }
585 585
 
586 586
         final String fs = System.getProperty("file.separator");
587
-        final String location = IdentityManager.getIdentityManager().getConfigDir() + "identities" + fs;
587
+        final String location = IdentityManager.getIdentityManager().getConfigurationDirectory() + "identities" + fs;
588 588
         final String name = settings.get(DOMAIN).get("name").replaceAll(ILLEGAL_CHARS, "_");
589 589
 
590 590
         File file = new File(location + name);
@@ -603,7 +603,7 @@ public class Identity extends ConfigSource implements Comparable<Identity>, Conf
603 603
         configFile.write();
604 604
 
605 605
         final Identity identity = new Identity(file, false);
606
-        IdentityManager.getIdentityManager().registerIdentity(identity);
606
+        IdentityManager.getIdentityManager().addConfigProvider(identity);
607 607
 
608 608
         return identity;
609 609
     }

+ 59
- 41
src/com/dmdirc/config/IdentityManager.java 查看文件

@@ -22,8 +22,9 @@
22 22
 
23 23
 package com.dmdirc.config;
24 24
 
25
-import com.dmdirc.interfaces.config.ConfigProviderListener;
26 25
 import com.dmdirc.Precondition;
26
+import com.dmdirc.interfaces.config.ConfigProvider;
27
+import com.dmdirc.interfaces.config.ConfigProviderListener;
27 28
 import com.dmdirc.interfaces.config.IdentityController;
28 29
 import com.dmdirc.interfaces.config.IdentityFactory;
29 30
 import com.dmdirc.logger.ErrorLevel;
@@ -39,6 +40,7 @@ import java.io.File;
39 40
 import java.io.IOException;
40 41
 import java.util.ArrayList;
41 42
 import java.util.Collections;
43
+import java.util.Comparator;
42 44
 import java.util.HashMap;
43 45
 import java.util.LinkedHashSet;
44 46
 import java.util.List;
@@ -66,7 +68,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
66 68
      * Standard identities are inserted with a <code>null</code> key, custom
67 69
      * identities use their custom type as the key.
68 70
      */
69
-    private final MapList<String, Identity> identities = new MapList<>();
71
+    private final MapList<String, ConfigProvider> identities = new MapList<>();
70 72
 
71 73
     /**
72 74
      * The {@link IdentityListener}s that have registered with this manager.
@@ -99,12 +101,17 @@ public class IdentityManager implements IdentityFactory, IdentityController {
99 101
 
100 102
     /** {@inheritDoc} */
101 103
     @Override
102
-    public String getConfigDir() {
104
+    @Deprecated
105
+    public String getConfigurationDirectory() {
103 106
         return configDirectory;
104 107
     }
105 108
 
106
-    /** {@inheritDoc} */
107
-    @Override
109
+    /**
110
+     * Loads all identity files.
111
+     *
112
+     * @throws InvalidIdentityFileException If there is an error with the config
113
+     * file.
114
+     */
108 115
     public void initialise() throws InvalidIdentityFileException {
109 116
         identities.clear();
110 117
 
@@ -113,7 +120,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
113 120
         loadUserIdentities();
114 121
         loadConfig();
115 122
 
116
-        if (getIdentitiesByType("profile").isEmpty()) {
123
+        if (getProvidersByType("profile").isEmpty()) {
117 124
             try {
118 125
                 Identity.buildProfile("Default Profile");
119 126
             } catch (IOException ex) {
@@ -132,7 +139,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
132 139
         addonConfigFile.addDomain("identity", addonSettings);
133 140
 
134 141
         addonConfig = new Identity(addonConfigFile, target);
135
-        registerIdentity(addonConfig);
142
+        addConfigProvider(addonConfig);
136 143
 
137 144
         if (!getGlobalConfiguration().hasOptionString("identity", "defaultsversion")) {
138 145
             Logger.userError(ErrorLevel.FATAL, "Default settings "
@@ -143,7 +150,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
143 150
     /** Loads the default (built in) identities. */
144 151
     private void loadDefaults() {
145 152
         final String[] targets = {"default", "modealiases"};
146
-        final String dir = getIdentityDirectory();
153
+        final String dir = getUserSettingsDirectory();
147 154
 
148 155
         for (String target : targets) {
149 156
             final File file = new File(dir + target);
@@ -197,7 +204,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
197 204
         try {
198 205
             ResourceManager.getResourceManager().extractResource(
199 206
                     "com/dmdirc/config/defaults/default/formatter",
200
-                    getIdentityDirectory() + "default/", false);
207
+                    getUserSettingsDirectory() + "default/", false);
201 208
         } catch (IOException ex) {
202 209
             Logger.userError(ErrorLevel.MEDIUM, "Unable to extract default "
203 210
                     + "formatters: " + ex.getMessage());
@@ -214,7 +221,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
214 221
         try {
215 222
             ResourceManager.getResourceManager().extractResources(
216 223
                     "com/dmdirc/config/defaults/" + target,
217
-                    getIdentityDirectory() + target, false);
224
+                    getUserSettingsDirectory() + target, false);
218 225
         } catch (IOException ex) {
219 226
             Logger.userError(ErrorLevel.MEDIUM, "Unable to extract default "
220 227
                     + "identities: " + ex.getMessage());
@@ -223,14 +230,15 @@ public class IdentityManager implements IdentityFactory, IdentityController {
223 230
 
224 231
     /** {@inheritDoc} */
225 232
     @Override
226
-    public String getIdentityDirectory() {
233
+    @Deprecated
234
+    public String getUserSettingsDirectory() {
227 235
         return configDirectory + "identities" + System.getProperty("file.separator");
228 236
     }
229 237
 
230 238
     /** {@inheritDoc} */
231 239
     @Override
232 240
     public void loadUserIdentities() {
233
-        final File dir = new File(getIdentityDirectory());
241
+        final File dir = new File(getUserSettingsDirectory());
234 242
 
235 243
         if (!dir.exists()) {
236 244
             try {
@@ -280,8 +288,10 @@ public class IdentityManager implements IdentityFactory, IdentityController {
280 288
      */
281 289
     private void loadIdentity(final File file) {
282 290
         synchronized (identities) {
283
-            for (Identity identity : getAllIdentities()) {
284
-                if (identity.isFile(file)) {
291
+            for (ConfigProvider identity : getAllIdentities()) {
292
+                if ((identity instanceof Identity) && ((Identity) identity).isFile(file)) {
293
+                    // TODO: This manager should keep a list of files->identities instead of
294
+                    //       relying on the identities remembering.
285 295
                     try {
286 296
                         identity.reload();
287 297
                     } catch (IOException ex) {
@@ -298,7 +308,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
298 308
         }
299 309
 
300 310
         try {
301
-            registerIdentity(new Identity(file, false));
311
+            addConfigProvider(new Identity(file, false));
302 312
         } catch (InvalidIdentityFileException ex) {
303 313
             Logger.userError(ErrorLevel.MEDIUM,
304 314
                     "Invalid identity file: " + file.getAbsolutePath()
@@ -316,10 +326,10 @@ public class IdentityManager implements IdentityFactory, IdentityController {
316 326
      * @return A set of all known identities
317 327
      * @since 0.6.4
318 328
      */
319
-    private Set<Identity> getAllIdentities() {
320
-        final Set<Identity> res = new LinkedHashSet<>();
329
+    private Set<ConfigProvider> getAllIdentities() {
330
+        final Set<ConfigProvider> res = new LinkedHashSet<>();
321 331
 
322
-        for (Map.Entry<String, List<Identity>> entry : identities.entrySet()) {
332
+        for (Map.Entry<String, List<ConfigProvider>> entry : identities.entrySet()) {
323 333
             res.addAll(entry.getValue());
324 334
         }
325 335
 
@@ -335,7 +345,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
335 345
      * @return The group of the specified identity
336 346
      * @since 0.6.4
337 347
      */
338
-    private String getGroup(final Identity identity) {
348
+    private String getGroup(final ConfigProvider identity) {
339 349
         return identity.getTarget().getType() == ConfigTarget.TYPE.CUSTOM
340 350
                 ? identity.getTarget().getData() : null;
341 351
     }
@@ -345,7 +355,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
345 355
     public void loadVersionIdentity() {
346 356
         try {
347 357
             versionConfig = new Identity(IdentityManager.class.getResourceAsStream("/com/dmdirc/version.config"), false);
348
-            registerIdentity(versionConfig);
358
+            addConfigProvider(versionConfig);
349 359
         } catch (IOException | InvalidIdentityFileException ex) {
350 360
             Logger.appError(ErrorLevel.FATAL, "Unable to load version information", ex);
351 361
         }
@@ -367,7 +377,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
367 377
 
368 378
             config = new Identity(file, true);
369 379
             config.setOption("identity", "name", "Global config");
370
-            registerIdentity(config);
380
+            addConfigProvider(config);
371 381
         } catch (IOException ex) {
372 382
             Logger.userError(ErrorLevel.FATAL, "I/O error when loading global config: "
373 383
                     + ex.getMessage(), ex);
@@ -376,19 +386,19 @@ public class IdentityManager implements IdentityFactory, IdentityController {
376 386
 
377 387
     /** {@inheritDoc} */
378 388
     @Override
379
-    public Identity getGlobalConfigIdentity() {
389
+    public Identity getUserSettings() {
380 390
         return config;
381 391
     }
382 392
 
383 393
     /** {@inheritDoc} */
384 394
     @Override
385
-    public Identity getGlobalAddonIdentity() {
395
+    public Identity getAddonSettings() {
386 396
         return addonConfig;
387 397
     }
388 398
 
389 399
     /** {@inheritDoc} */
390 400
     @Override
391
-    public Identity getGlobalVersionIdentity() {
401
+    public Identity getVersionSettings() {
392 402
         return versionConfig;
393 403
     }
394 404
 
@@ -396,7 +406,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
396 406
     @Override
397 407
     public void saveAll() {
398 408
         synchronized (identities) {
399
-            for (Identity identity : getAllIdentities()) {
409
+            for (ConfigProvider identity : getAllIdentities()) {
400 410
                 identity.save();
401 411
             }
402 412
         }
@@ -404,13 +414,13 @@ public class IdentityManager implements IdentityFactory, IdentityController {
404 414
 
405 415
     /** {@inheritDoc} */
406 416
     @Override
407
-    public void registerIdentity(final Identity identity) {
417
+    public void addConfigProvider(final ConfigProvider identity) {
408 418
         Logger.assertTrue(identity != null);
409 419
 
410 420
         final String target = getGroup(identity);
411 421
 
412 422
         if (identities.containsValue(target, identity)) {
413
-            unregisterIdentity(identity);
423
+            removeConfigProvider(identity);
414 424
         }
415 425
 
416 426
         synchronized (identities) {
@@ -429,7 +439,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
429 439
 
430 440
     /** {@inheritDoc} */
431 441
     @Override
432
-    public void unregisterIdentity(final Identity identity) {
442
+    public void removeConfigProvider(final ConfigProvider identity) {
433 443
         Logger.assertTrue(identity != null);
434 444
 
435 445
         final String group = getGroup(identity);
@@ -471,24 +481,30 @@ public class IdentityManager implements IdentityFactory, IdentityController {
471 481
 
472 482
     /** {@inheritDoc} */
473 483
     @Override
474
-    public List<Identity> getIdentitiesByType(final String type) {
484
+    public List<ConfigProvider> getProvidersByType(final String type) {
475 485
         return Collections.unmodifiableList(identities.safeGet(type));
476 486
     }
477 487
 
478
-    /** {@inheritDoc} */
479
-    @Override
480
-    public List<Identity> getIdentitiesForManager(final ConfigManager manager) {
481
-        final List<Identity> sources = new ArrayList<>();
488
+    /**
489
+     * Retrieves a list of all config sources that should be applied to the
490
+     * specified config manager.
491
+     *
492
+     * @param manager The manager requesting sources
493
+     * @return A list of all matching config sources
494
+     */
495
+    public List<ConfigProvider> getIdentitiesForManager(final ConfigManager manager) {
496
+        final List<ConfigProvider> sources = new ArrayList<>();
482 497
 
483 498
         synchronized (identities) {
484
-            for (Identity identity : identities.safeGet(null)) {
499
+            for (ConfigProvider identity : identities.safeGet(null)) {
485 500
                 if (manager.identityApplies(identity)) {
486 501
                     sources.add(identity);
487 502
                 }
488 503
             }
489 504
         }
490 505
 
491
-        Collections.sort(sources);
506
+        // TODO: Expose this as a comparator other classes can use.
507
+        Collections.sort(sources, new ConfigProviderTargetComparator());
492 508
 
493 509
         return sources;
494 510
     }
@@ -505,7 +521,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
505 521
 
506 522
     /** {@inheritDoc} */
507 523
     @Override
508
-    public Identity createChannelConfig(final String network, final String channel) {
524
+    public ConfigProvider createChannelConfig(final String network, final String channel) {
509 525
         if (network == null || network.isEmpty()) {
510 526
             throw new IllegalArgumentException("getChannelConfig called "
511 527
                     + "with null or empty network\n\nNetwork: " + network);
@@ -519,7 +535,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
519 535
         final String myTarget = (channel + "@" + network).toLowerCase();
520 536
 
521 537
         synchronized (identities) {
522
-            for (Identity identity : identities.safeGet(null)) {
538
+            for (ConfigProvider identity : identities.safeGet(null)) {
523 539
                 if (identity.getTarget().getType() == ConfigTarget.TYPE.CHANNEL
524 540
                         && identity.getTarget().getData().equalsIgnoreCase(myTarget)) {
525 541
                     return identity;
@@ -541,7 +557,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
541 557
 
542 558
     /** {@inheritDoc} */
543 559
     @Override
544
-    public Identity createNetworkConfig(final String network) {
560
+    public ConfigProvider createNetworkConfig(final String network) {
545 561
         if (network == null || network.isEmpty()) {
546 562
             throw new IllegalArgumentException("getNetworkConfig called "
547 563
                     + "with null or empty network\n\nNetwork:" + network);
@@ -550,7 +566,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
550 566
         final String myTarget = network.toLowerCase();
551 567
 
552 568
         synchronized (identities) {
553
-            for (Identity identity : identities.safeGet(null)) {
569
+            for (ConfigProvider identity : identities.safeGet(null)) {
554 570
                 if (identity.getTarget().getType() == ConfigTarget.TYPE.NETWORK
555 571
                         && identity.getTarget().getData().equalsIgnoreCase(myTarget)) {
556 572
                     return identity;
@@ -572,7 +588,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
572 588
 
573 589
     /** {@inheritDoc} */
574 590
     @Override
575
-    public Identity createServerConfig(final String server) {
591
+    public ConfigProvider createServerConfig(final String server) {
576 592
         if (server == null || server.isEmpty()) {
577 593
             throw new IllegalArgumentException("getServerConfig called "
578 594
                     + "with null or empty server\n\nServer: " + server);
@@ -581,7 +597,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
581 597
         final String myTarget = server.toLowerCase();
582 598
 
583 599
         synchronized (identities) {
584
-            for (Identity identity : identities.safeGet(null)) {
600
+            for (ConfigProvider identity : identities.safeGet(null)) {
585 601
                 if (identity.getTarget().getType() == ConfigTarget.TYPE.SERVER
586 602
                         && identity.getTarget().getData().equalsIgnoreCase(myTarget)) {
587 603
                     return identity;
@@ -605,6 +621,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
605 621
      * Gets a singleton instance of the Identity Manager.
606 622
      *
607 623
      * @return A singleton instance of the IdentityManager.
624
+     * @deprecated Shouldn't use global state.
608 625
      */
609 626
     @Deprecated
610 627
     public static IdentityManager getIdentityManager() {
@@ -615,6 +632,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
615 632
      * Sets the singleton instance of the Identity Manager.
616 633
      *
617 634
      * @param identityManager The identity manager to use.
635
+     * @deprecated Shouldn't use global state.
618 636
      */
619 637
     @Deprecated
620 638
     public static void setIdentityManager(final IdentityManager identityManager) {

+ 3
- 3
src/com/dmdirc/config/prefs/PreferencesDialogModel.java 查看文件

@@ -24,7 +24,7 @@ package com.dmdirc.config.prefs;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
-import com.dmdirc.config.ConfigManager;
27
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
28 28
 import com.dmdirc.interfaces.config.ConfigProvider;
29 29
 import com.dmdirc.plugins.PluginManager;
30 30
 import com.dmdirc.plugins.Service;
@@ -59,7 +59,7 @@ public class PreferencesDialogModel {
59 59
     private final PreferencesInterface urlHandlerPanel;
60 60
     /** Config Manager to read settings from. */
61 61
     @Getter
62
-    private final ConfigManager configManager;
62
+    private final AggregateConfigProvider configManager;
63 63
     /** Identity to write settings to. */
64 64
     @Getter
65 65
     private final ConfigProvider identity;
@@ -84,7 +84,7 @@ public class PreferencesDialogModel {
84 84
             final PreferencesInterface themePanel,
85 85
             final PreferencesInterface updatesPanel,
86 86
             final PreferencesInterface urlHandlerPanel,
87
-            final ConfigManager configManager,
87
+            final AggregateConfigProvider configManager,
88 88
             final ConfigProvider identity,
89 89
             final ActionManager actionManager,
90 90
             final PluginManager pluginManager) {

+ 3
- 3
src/com/dmdirc/config/prefs/PreferencesManager.java 查看文件

@@ -24,8 +24,8 @@ package com.dmdirc.config.prefs;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
-import com.dmdirc.config.ConfigManager;
28 27
 import com.dmdirc.interfaces.ActionController;
28
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 29
 import com.dmdirc.interfaces.config.ConfigProvider;
30 30
 import com.dmdirc.util.validators.NumericalValidator;
31 31
 import com.dmdirc.util.validators.OptionalValidator;
@@ -54,7 +54,7 @@ public class PreferencesManager {
54 54
      * @param identity The identity to save settings to
55 55
      * @return A preferences category populated with channel settings
56 56
      */
57
-    public PreferencesCategory getServerSettings(final ConfigManager manager,
57
+    public PreferencesCategory getServerSettings(final AggregateConfigProvider manager,
58 58
             final ConfigProvider identity) {
59 59
         final PreferencesCategory category
60 60
                 = new PreferencesCategory("Server settings",
@@ -139,7 +139,7 @@ public class PreferencesManager {
139 139
      * @param identity The identity to save settings to
140 140
      * @return A preferences category populated with channel settings
141 141
      */
142
-    public PreferencesCategory getChannelSettings(final ConfigManager manager,
142
+    public PreferencesCategory getChannelSettings(final AggregateConfigProvider manager,
143 143
             final ConfigProvider identity) {
144 144
         final PreferencesCategory category
145 145
                 = new PreferencesCategory("Channel settings",

+ 4
- 5
src/com/dmdirc/config/prefs/PreferencesSetting.java 查看文件

@@ -22,8 +22,7 @@
22 22
 
23 23
 package com.dmdirc.config.prefs;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26
-import com.dmdirc.config.Identity;
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 26
 import com.dmdirc.interfaces.config.ConfigProvider;
28 27
 import com.dmdirc.util.validators.PermissiveValidator;
29 28
 import com.dmdirc.util.validators.Validator;
@@ -87,7 +86,7 @@ public class PreferencesSetting {
87 86
     public PreferencesSetting(final PreferencesType type,
88 87
             final Validator<String> validator, final String domain,
89 88
             final String option, final String title, final String helptext,
90
-            final ConfigManager configManager, final ConfigProvider identity) {
89
+            final AggregateConfigProvider configManager, final ConfigProvider identity) {
91 90
         if (PreferencesType.MULTICHOICE.equals(type)) {
92 91
             throw new IllegalArgumentException("Multi-choice preferences must "
93 92
                     + "have their options specified.");
@@ -120,7 +119,7 @@ public class PreferencesSetting {
120 119
      */
121 120
     public PreferencesSetting(final PreferencesType type, final String domain,
122 121
             final String option, final String title, final String helptext,
123
-            final ConfigManager configManager, final ConfigProvider identity) {
122
+            final AggregateConfigProvider configManager, final ConfigProvider identity) {
124 123
         if (PreferencesType.MULTICHOICE.equals(type)) {
125 124
             throw new IllegalArgumentException("Multi-choice preferences must "
126 125
                     + "have their options specified.");
@@ -153,7 +152,7 @@ public class PreferencesSetting {
153 152
     public PreferencesSetting(final String domain, final String option,
154 153
             final String title, final String helptext,
155 154
             final Map<String, String> options,
156
-            final ConfigManager configManager, final ConfigProvider identity) {
155
+            final AggregateConfigProvider configManager, final ConfigProvider identity) {
157 156
         this.type = PreferencesType.MULTICHOICE;
158 157
         this.comboOptions = new HashMap<>(options);
159 158
         this.validator = new PermissiveValidator<>();

+ 3
- 3
src/com/dmdirc/config/validators/URLProtocolValidator.java 查看文件

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.config.validators;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.config.IdentityManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.util.validators.ValidationResponse;
28 28
 import com.dmdirc.util.validators.Validator;
29 29
 
@@ -33,7 +33,7 @@ import com.dmdirc.util.validators.Validator;
33 33
 public class URLProtocolValidator implements Validator<String> {
34 34
 
35 35
     /** The global configuration to read settings from. */
36
-    private final ConfigManager globalConfig;
36
+    private final AggregateConfigProvider globalConfig;
37 37
 
38 38
     /**
39 39
      * Creates a {@link URLProtocolValidator} that will read from the given
@@ -41,7 +41,7 @@ public class URLProtocolValidator implements Validator<String> {
41 41
      *
42 42
      * @param globalConfig The config manager to read protocol info from.
43 43
      */
44
-    public URLProtocolValidator(final ConfigManager globalConfig) {
44
+    public URLProtocolValidator(final AggregateConfigProvider globalConfig) {
45 45
         this.globalConfig = globalConfig;
46 46
     }
47 47
 

+ 11
- 2
src/com/dmdirc/interfaces/config/AggregateConfigProvider.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.interfaces.config;
24 24
 
25
-import com.dmdirc.config.Identity;
25
+import com.dmdirc.config.ConfigBinder;
26 26
 
27 27
 import java.util.List;
28 28
 import java.util.Set;
@@ -64,7 +64,7 @@ public interface AggregateConfigProvider extends ReadOnlyConfigProvider {
64 64
      * Retrieves a list of sources for this config manager.
65 65
      * @return This config manager's sources.
66 66
      */
67
-    List<Identity> getSources();
67
+    List<ConfigProvider> getSources();
68 68
 
69 69
     /**
70 70
      * Removes the specified listener for all domains and options.
@@ -100,4 +100,13 @@ public interface AggregateConfigProvider extends ReadOnlyConfigProvider {
100 100
      */
101 101
     void migrate(String protocol, String ircd, String network, String server, String channel);
102 102
 
103
+    /**
104
+     * Gets a binder that may be used to bind methods or fields in a class to configuration
105
+     * values known by this provider. Bound values update automatically whenever the value in
106
+     * this provider changes.
107
+     *
108
+     * @return A config binder for use with this provider.
109
+     */
110
+    ConfigBinder getBinder();
111
+
103 112
 }

+ 17
- 38
src/com/dmdirc/interfaces/config/IdentityController.java 查看文件

@@ -22,11 +22,6 @@
22 22
 
23 23
 package com.dmdirc.interfaces.config;
24 24
 
25
-import com.dmdirc.Precondition;
26
-import com.dmdirc.config.ConfigManager;
27
-import com.dmdirc.config.Identity;
28
-import com.dmdirc.config.InvalidIdentityFileException;
29
-
30 25
 import java.util.List;
31 26
 
32 27
 /**
@@ -40,21 +35,21 @@ public interface IdentityController {
40 35
      *
41 36
      * @return The addons defaults identity
42 37
      */
43
-    Identity getGlobalAddonIdentity();
38
+    ConfigProvider getAddonSettings();
44 39
 
45 40
     /**
46 41
      * Retrieves the identity used for the global config.
47 42
      *
48 43
      * @return The global config identity
49 44
      */
50
-    Identity getGlobalConfigIdentity();
45
+    ConfigProvider getUserSettings();
51 46
 
52 47
     /**
53 48
      * Retrieves the global config manager.
54 49
      *
55 50
      * @return The global config manager
56 51
      */
57
-    ConfigManager getGlobalConfiguration();
52
+    AggregateConfigProvider getGlobalConfiguration();
58 53
 
59 54
     /**
60 55
      * Retrieves the identity bundled with the DMDirc client containing
@@ -63,7 +58,7 @@ public interface IdentityController {
63 58
      * @return The version identity
64 59
      * @since 0.6.3m2
65 60
      */
66
-    Identity getGlobalVersionIdentity();
61
+    ReadOnlyConfigProvider getVersionSettings();
67 62
 
68 63
     /**
69 64
      * Retrieves a list of identities that belong to the specified custom type.
@@ -72,38 +67,25 @@ public interface IdentityController {
72 67
      * @return A list of matching identities
73 68
      * @since 0.6.4
74 69
      */
75
-    List<Identity> getIdentitiesByType(final String type);
76
-
77
-    /**
78
-     * Retrieves a list of all config sources that should be applied to the
79
-     * specified config manager.
80
-     *
81
-     * @param manager The manager requesting sources
82
-     * @return A list of all matching config sources
83
-     */
84
-    List<Identity> getIdentitiesForManager(final ConfigManager manager);
70
+    List<ConfigProvider> getProvidersByType(String type);
85 71
 
86 72
     /**
87 73
      * Retrieves the directory used to store identities in.
88 74
      *
89 75
      * @return The identity directory path
76
+     * @deprecated Shouldn't be exposed through the controller.
90 77
      */
91
-    String getIdentityDirectory();
92
-
93
-    /**
94
-     * Loads all identity files.
95
-     *
96
-     * @throws InvalidIdentityFileException If there is an error with the config
97
-     * file.
98
-     */
99
-    void initialise() throws InvalidIdentityFileException;
78
+    @Deprecated
79
+    String getUserSettingsDirectory();
100 80
 
101 81
     /**
102 82
      * Get the config directory used by this identity controller.
103 83
      *
104 84
      * @return The config directory.
85
+     * @deprecated Shouldn't be exposed through the controller.
105 86
      */
106
-    String getConfigDir();
87
+    @Deprecated
88
+    String getConfigurationDirectory();
107 89
 
108 90
     /**
109 91
      * Loads user-defined identity files.
@@ -117,10 +99,10 @@ public interface IdentityController {
117 99
 
118 100
     /**
119 101
      * Adds the specific identity to this manager.
102
+     *
120 103
      * @param identity The identity to be added
121 104
      */
122
-    @Precondition(value = "The specified Identity is not null")
123
-    void registerIdentity(final Identity identity);
105
+    void addConfigProvider(ConfigProvider identity);
124 106
 
125 107
     /**
126 108
      * Adds a new identity listener which will be informed of all settings
@@ -129,8 +111,7 @@ public interface IdentityController {
129 111
      * @param listener The listener to be added
130 112
      * @since 0.6.4
131 113
      */
132
-    @Precondition(value = "The specified listener is not null")
133
-    void registerIdentityListener(final ConfigProviderListener listener);
114
+    void registerIdentityListener(ConfigProviderListener listener);
134 115
 
135 116
     /**
136 117
      * Adds a new identity listener which will be informed of all identities
@@ -140,15 +121,14 @@ public interface IdentityController {
140 121
      * @param listener The listener to be added
141 122
      * @since 0.6.4
142 123
      */
143
-    @Precondition(value = "The specified listener is not null")
144
-    void registerIdentityListener(final String type, final ConfigProviderListener listener);
124
+    void registerIdentityListener(String type, ConfigProviderListener listener);
145 125
 
146 126
     /**
147 127
      * Unregisters the given identity listener.
148 128
      *
149 129
      * @param listener The listener to be removed
150 130
      */
151
-    void unregisterIdentityListener(final ConfigProviderListener listener);
131
+    void unregisterIdentityListener(ConfigProviderListener listener);
152 132
 
153 133
     /**
154 134
      * Saves all modified identity files to disk.
@@ -159,7 +139,6 @@ public interface IdentityController {
159 139
      * Removes an identity from this manager.
160 140
      * @param identity The identity to be removed
161 141
      */
162
-    @Precondition(value = {"The specified Identity is not null", "The specified Identity has previously been added and not removed"})
163
-    void unregisterIdentity(final Identity identity);
142
+    void removeConfigProvider(ConfigProvider identity);
164 143
 
165 144
 }

+ 3
- 4
src/com/dmdirc/interfaces/config/IdentityFactory.java 查看文件

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.interfaces.config;
24 24
 
25 25
 import com.dmdirc.Precondition;
26
-import com.dmdirc.config.Identity;
27 26
 
28 27
 /**
29 28
  * Defines methods implemented by a factory which can create useful identities.
@@ -39,7 +38,7 @@ public interface IdentityFactory {
39 38
      * @return A config source for the channel
40 39
      */
41 40
     @Precondition(value = {"The specified network is non-null and not empty", "The specified channel is non-null and not empty"})
42
-    Identity createChannelConfig(final String network, final String channel);
41
+    ConfigProvider createChannelConfig(final String network, final String channel);
43 42
 
44 43
     /**
45 44
      * Retrieves the config for the specified network. The config is
@@ -49,7 +48,7 @@ public interface IdentityFactory {
49 48
      * @return A config source for the network
50 49
      */
51 50
     @Precondition(value = "The specified network is non-null and not empty")
52
-    Identity createNetworkConfig(final String network);
51
+    ConfigProvider createNetworkConfig(final String network);
53 52
 
54 53
     /**
55 54
      * Retrieves the config for the specified server. The config is
@@ -59,6 +58,6 @@ public interface IdentityFactory {
59 58
      * @return A config source for the server
60 59
      */
61 60
     @Precondition(value = "The specified server is non-null and not empty")
62
-    Identity createServerConfig(final String server);
61
+    ConfigProvider createServerConfig(final String server);
63 62
 
64 63
 }

+ 12
- 0
src/com/dmdirc/interfaces/config/ReadOnlyConfigProvider.java 查看文件

@@ -54,6 +54,18 @@ public interface ReadOnlyConfigProvider {
54 54
      */
55 55
     String getOption(String domain, String option, Validator<String> validator);
56 56
 
57
+    /**
58
+     * Determines if this source has a value for the specified option which
59
+     * matches the specified validator.
60
+     *
61
+     * @since 0.6.5
62
+     * @param domain The domain of the option
63
+     * @param option The name of the option
64
+     * @param validator The validator to use to check legal values
65
+     * @return True iff a matching option exists, false otherwise.
66
+     */
67
+    boolean hasOption(String domain, String option, Validator<String> validator);
68
+
57 69
     /**
58 70
      * Retrieves a boolean representation of the specified option.
59 71
      *

+ 3
- 3
src/com/dmdirc/logger/ErrorManager.java 查看文件

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.logger;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.config.IdentityManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.interfaces.config.ConfigChangeListener;
28 28
 import com.dmdirc.interfaces.config.IdentityController;
29 29
 import com.dmdirc.ui.FatalErrorDialog;
@@ -86,7 +86,7 @@ public class ErrorManager implements ConfigChangeListener {
86 86
      * @param controller The controller to use to read/write settings.
87 87
      */
88 88
     public void initialise(final IdentityController controller) {
89
-        final ConfigManager config = controller.getGlobalConfiguration();
89
+        final AggregateConfigProvider config = controller.getGlobalConfiguration();
90 90
 
91 91
         config.addChangeListener("general", "logerrors", this);
92 92
         config.addChangeListener("general", "submitErrors", this);
@@ -495,7 +495,7 @@ public class ErrorManager implements ConfigChangeListener {
495 495
 
496 496
     /** Updates the settings used by this error manager. */
497 497
     protected void updateSettings() {
498
-        final ConfigManager config = IdentityManager.getIdentityManager().getGlobalConfiguration();
498
+        final AggregateConfigProvider config = IdentityManager.getIdentityManager().getGlobalConfiguration();
499 499
 
500 500
         try {
501 501
             sendReports = config.getOptionBool("general", "submitErrors")

+ 1
- 1
src/com/dmdirc/logger/ProgramError.java 查看文件

@@ -271,7 +271,7 @@ public final class ProgramError implements Serializable {
271 271
         WRITING_SEM.acquireUninterruptibly();
272 272
 
273 273
         if (errorDir == null || !errorDir.exists()) {
274
-            errorDir = new File(IdentityManager.getIdentityManager().getConfigDir() + "errors");
274
+            errorDir = new File(IdentityManager.getIdentityManager().getConfigurationDirectory() + "errors");
275 275
             if (!errorDir.exists()) {
276 276
                 errorDir.mkdirs();
277 277
             }

+ 3
- 3
src/com/dmdirc/plugins/PluginInfo.java 查看文件

@@ -194,7 +194,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
194 194
      * Get the defaults, formatters and icons for this plugin.
195 195
      */
196 196
     private void getDefaults() {
197
-        final ConfigProvider defaults = IdentityManager.getIdentityManager().getGlobalAddonIdentity();
197
+        final ConfigProvider defaults = IdentityManager.getIdentityManager().getAddonSettings();
198 198
         final String domain = "plugin-" + metaData.getName();
199 199
 
200 200
         log.trace("{}: Using domain '{}'",
@@ -244,7 +244,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
244 244
                 synchronized (identities) {
245 245
                     try {
246 246
                         final Identity thisIdentity = new Identity(stream, false);
247
-                        IdentityManager.getIdentityManager().registerIdentity(thisIdentity);
247
+                        IdentityManager.getIdentityManager().addConfigProvider(thisIdentity);
248 248
                         identities.add(thisIdentity);
249 249
                     } catch (final InvalidIdentityFileException ex) {
250 250
                         Logger.userError(ErrorLevel.MEDIUM,
@@ -265,7 +265,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
265 265
     private void unloadIdentities() {
266 266
         synchronized (identities) {
267 267
             for (Identity identity : identities) {
268
-                IdentityManager.getIdentityManager().unregisterIdentity(identity);
268
+                IdentityManager.getIdentityManager().removeConfigProvider(identity);
269 269
             }
270 270
 
271 271
             identities.clear();

+ 1
- 1
src/com/dmdirc/plugins/PluginManager.java 查看文件

@@ -551,7 +551,7 @@ public class PluginManager implements ActionListener, ServiceManager {
551 551
             list.remove(path);
552 552
         }
553 553
 
554
-        identityController.getGlobalConfigIdentity().setOption("plugins", "autoload", list);
554
+        identityController.getUserSettings().setOption("plugins", "autoload", list);
555 555
     }
556 556
 
557 557
     /**

+ 4
- 4
src/com/dmdirc/tls/CertificateManager.java 查看文件

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.tls;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.config.IdentityManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.logger.ErrorLevel;
28 28
 import com.dmdirc.logger.Logger;
29 29
 import com.dmdirc.util.collections.ListenerList;
@@ -77,7 +77,7 @@ public class CertificateManager implements X509TrustManager {
77 77
     private final String serverName;
78 78
 
79 79
     /** The configuration manager to use for settings. */
80
-    private final ConfigManager config;
80
+    private final AggregateConfigProvider config;
81 81
 
82 82
     /** The set of CAs from the global cacert file. */
83 83
     private final Set<X509Certificate> globalTrustedCAs = new HashSet<X509Certificate>();
@@ -104,7 +104,7 @@ public class CertificateManager implements X509TrustManager {
104 104
      * @param serverName The name the user used to connect to the server
105 105
      * @param config The configuration manager to use
106 106
      */
107
-    public CertificateManager(final String serverName, final ConfigManager config) {
107
+    public CertificateManager(final String serverName, final AggregateConfigProvider config) {
108 108
         this.serverName = serverName;
109 109
         this.config = config;
110 110
         this.checkDate = config.getOptionBool("ssl", "checkdate");
@@ -365,7 +365,7 @@ public class CertificateManager implements X509TrustManager {
365 365
                     final List<String> list = new ArrayList<String>(config
366 366
                             .getOptionList("ssl", "trusted"));
367 367
                     list.add(Base64.encodeToString(chain[0].getSignature(), false));
368
-                    IdentityManager.getIdentityManager().getGlobalConfigIdentity()
368
+                    IdentityManager.getIdentityManager().getUserSettings()
369 369
                             .setOption("ssl", "trusted", list);
370 370
                     break;
371 371
                 case IGNORE_TEMPORARILY:

+ 3
- 3
src/com/dmdirc/ui/IconManager.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
26 26
 import com.dmdirc.interfaces.config.ConfigChangeListener;
27 27
 import com.dmdirc.util.URLBuilder;
28 28
 
@@ -51,7 +51,7 @@ public class IconManager implements ConfigChangeListener {
51 51
     /** A map of existing images. */
52 52
     private final Map<String, Image> images;
53 53
     /** Config manager to retrieve settings from. */
54
-    private final ConfigManager configManager;
54
+    private final AggregateConfigProvider configManager;
55 55
     /** URL builder to use for icons. */
56 56
     private final URLBuilder urlBuilder;
57 57
 
@@ -62,7 +62,7 @@ public class IconManager implements ConfigChangeListener {
62 62
      * @param urlBuilder URL builder to use for icons.
63 63
      */
64 64
     public IconManager(
65
-            final ConfigManager configManager,
65
+            final AggregateConfigProvider configManager,
66 66
             final URLBuilder urlBuilder) {
67 67
         this.configManager = configManager;
68 68
         this.urlBuilder = urlBuilder;

+ 4
- 4
src/com/dmdirc/ui/StatusMessage.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
26 26
 import com.dmdirc.interfaces.ui.StatusMessageNotifier;
27 27
 
28 28
 /**
@@ -39,7 +39,7 @@ public class StatusMessage {
39 39
     /** Timeout when initially displayed. */
40 40
     private final int timeout;
41 41
     /** Config manager to get default timeout from. */
42
-    private final ConfigManager configManager;
42
+    private final AggregateConfigProvider configManager;
43 43
 
44 44
     /**
45 45
      * Creates a new statusbar message.
@@ -52,7 +52,7 @@ public class StatusMessage {
52 52
      */
53 53
     public StatusMessage(final String iconType, final String message,
54 54
             final StatusMessageNotifier messageNotifier, final int timeout,
55
-            final ConfigManager configManager) {
55
+            final AggregateConfigProvider configManager) {
56 56
         this.iconType = iconType;
57 57
         this.message = message;
58 58
         this.messageNotifier = messageNotifier;
@@ -67,7 +67,7 @@ public class StatusMessage {
67 67
      * @param message Message to show
68 68
      * @param manager Config manager to get default timeout from
69 69
      */
70
-    public StatusMessage(final String message, final ConfigManager manager) {
70
+    public StatusMessage(final String message, final AggregateConfigProvider manager) {
71 71
         this(null, message, null, -1, manager);
72 72
     }
73 73
 

+ 3
- 3
src/com/dmdirc/ui/core/util/URLHandler.java 查看文件

@@ -23,7 +23,7 @@
23 23
 package com.dmdirc.ui.core.util;
24 24
 
25 25
 import com.dmdirc.ServerManager;
26
-import com.dmdirc.config.ConfigManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.interfaces.ui.UIController;
28 28
 import com.dmdirc.logger.ErrorLevel;
29 29
 import com.dmdirc.logger.Logger;
@@ -46,7 +46,7 @@ public class URLHandler {
46 46
     /** The UI Controller that owns this handler. */
47 47
     private final UIController controller;
48 48
     /** Config manager. */
49
-    private final ConfigManager config;
49
+    private final AggregateConfigProvider config;
50 50
     /** Server manager to use to connect to servers. */
51 51
     private final ServerManager serverManager;
52 52
     /** Status bar manager to use to show messages. */
@@ -61,7 +61,7 @@ public class URLHandler {
61 61
      */
62 62
     public URLHandler(
63 63
             final UIController controller,
64
-            final ConfigManager globalConfig,
64
+            final AggregateConfigProvider globalConfig,
65 65
             final ServerManager serverManager,
66 66
             final StatusBarManager statusBarManager) {
67 67
         this.controller = controller;

+ 4
- 4
src/com/dmdirc/ui/input/TabCompleter.java 查看文件

@@ -30,8 +30,8 @@ import com.dmdirc.commandparser.CommandType;
30 30
 import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.IntelligentCommand.IntelligentCommandContext;
33
-import com.dmdirc.config.ConfigManager;
34 33
 import com.dmdirc.config.IdentityManager;
34
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
35 35
 import com.dmdirc.util.collections.MapList;
36 36
 
37 37
 import java.util.Arrays;
@@ -56,7 +56,7 @@ public class TabCompleter {
56 56
     /**
57 57
      * The config manager to use for reading settings.
58 58
      */
59
-    private final ConfigManager configManager;
59
+    private final AggregateConfigProvider configManager;
60 60
 
61 61
     /**
62 62
      * The entries in this completer.
@@ -74,7 +74,7 @@ public class TabCompleter {
74 74
      *
75 75
      * @param configManager The manager to read config settings from.
76 76
      */
77
-    public TabCompleter(final ConfigManager configManager) {
77
+    public TabCompleter(final AggregateConfigProvider configManager) {
78 78
         this.parent = null;
79 79
         this.configManager = configManager;
80 80
     }
@@ -85,7 +85,7 @@ public class TabCompleter {
85 85
      * @param configManager The manager to read config settings from.
86 86
      * @param parent The parent tab completer to inherit completions from.
87 87
      */
88
-    public TabCompleter(final ConfigManager configManager, final TabCompleter parent) {
88
+    public TabCompleter(final AggregateConfigProvider configManager, final TabCompleter parent) {
89 89
         this.parent = parent;
90 90
         this.configManager = configManager;
91 91
     }

+ 3
- 3
src/com/dmdirc/ui/messages/ColourManager.java 查看文件

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.config.IdentityManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.interfaces.config.ConfigChangeListener;
28 28
 import com.dmdirc.logger.ErrorLevel;
29 29
 import com.dmdirc.logger.Logger;
@@ -55,7 +55,7 @@ public class ColourManager {
55 55
     private final Map<String, Colour> colourCache = new HashMap<>();
56 56
 
57 57
     /** Config manager to read settings from. */
58
-    private final ConfigManager configManager;
58
+    private final AggregateConfigProvider configManager;
59 59
 
60 60
     /** Actual colours we're using for the 16 IRC colours. */
61 61
     private Colour[] ircColours = DEFAULT_COLOURS.clone();
@@ -65,7 +65,7 @@ public class ColourManager {
65 65
      *
66 66
      * @param configManager The manager to read config settings from.
67 67
      */
68
-    public ColourManager(final ConfigManager configManager) {
68
+    public ColourManager(final AggregateConfigProvider configManager) {
69 69
         this.configManager = configManager;
70 70
 
71 71
         configManager.addChangeListener("colour", new ConfigChangeListener() {

+ 3
- 4
src/com/dmdirc/ui/messages/Formatter.java 查看文件

@@ -23,7 +23,7 @@
23 23
 package com.dmdirc.ui.messages;
24 24
 
25 25
 import com.dmdirc.Precondition;
26
-import com.dmdirc.config.ConfigManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.util.DateUtils;
28 28
 
29 29
 import java.util.HashMap;
@@ -40,8 +40,7 @@ public final class Formatter {
40 40
     /**
41 41
      * A cache of types needed by the various formatters.
42 42
      */
43
-    private static final Map<String, Character[]> TYPE_CACHE
44
-            = new HashMap<String, Character[]>();
43
+    private static final Map<String, Character[]> TYPE_CACHE = new HashMap<>();
45 44
 
46 45
     /**
47 46
      * Creates a new instance of Formatter.
@@ -60,7 +59,7 @@ public final class Formatter {
60 59
      * @return A formatted string
61 60
      */
62 61
     @Precondition("The specified message type is not null")
63
-    public static String formatMessage(final ConfigManager config, final String messageType,
62
+    public static String formatMessage(final AggregateConfigProvider config, final String messageType,
64 63
             final Object... arguments) {
65 64
         assert messageType != null;
66 65
 

+ 6
- 6
src/com/dmdirc/ui/messages/IRCDocument.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
26 26
 import com.dmdirc.interfaces.config.ConfigChangeListener;
27 27
 import com.dmdirc.util.collections.ListenerList;
28 28
 import com.dmdirc.util.collections.RollingList;
@@ -57,7 +57,7 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
57 57
     /** Cached attributed strings. */
58 58
     private final RollingList<AttributedString> cachedStrings;
59 59
     /** Config Manager for getting settings. */
60
-    private final ConfigManager configManager;
60
+    private final AggregateConfigProvider configManager;
61 61
     /** This document's styliser. */
62 62
     private final Styliser styliser;
63 63
     /** Font size. */
@@ -74,16 +74,16 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
74 74
      * @param styliser Styliser to style text
75 75
      * @since 0.6.3
76 76
      */
77
-    public IRCDocument(final ConfigManager configManager,
77
+    public IRCDocument(final AggregateConfigProvider configManager,
78 78
             final Styliser styliser) {
79 79
         this.configManager = configManager;
80 80
         this.styliser = styliser;
81 81
 
82
-        lines = new ArrayList<Line>();
82
+        lines = new ArrayList<>();
83 83
         listeners = new ListenerList();
84 84
 
85
-        cachedLines = new RollingList<Line>(50);
86
-        cachedStrings = new RollingList<AttributedString>(50);
85
+        cachedLines = new RollingList<>(50);
86
+        cachedStrings = new RollingList<>(50);
87 87
         frameBufferSize = configManager.getOptionInt("ui", "frameBufferSize", false);
88 88
 
89 89
         configManager.addChangeListener("ui", "textPaneFontSize", this);

+ 3
- 3
src/com/dmdirc/ui/messages/Styliser.java 查看文件

@@ -24,7 +24,7 @@ package com.dmdirc.ui.messages;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27
-import com.dmdirc.config.ConfigManager;
27
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
28 28
 import com.dmdirc.interfaces.config.ConfigChangeListener;
29 29
 import com.dmdirc.logger.ErrorLevel;
30 30
 import com.dmdirc.logger.Logger;
@@ -142,7 +142,7 @@ public class Styliser implements ConfigChangeListener {
142 142
     /** Server to get channel prefixes from, or null if not applicable. */
143 143
     private final Server server;
144 144
     /** Config manager to retrieve settings from. */
145
-    private final ConfigManager configManager;
145
+    private final AggregateConfigProvider configManager;
146 146
 
147 147
     /**
148 148
      * Creates a new instance of Styliser.
@@ -160,7 +160,7 @@ public class Styliser implements ConfigChangeListener {
160 160
      * @param configManager the {@link ConfigManager} to get settings from.
161 161
      * @since 0.6.3
162 162
      */
163
-    public Styliser(final Server server, final ConfigManager configManager) {
163
+    public Styliser(final Server server, final AggregateConfigProvider configManager) {
164 164
         this.server = server;
165 165
         this.configManager = configManager;
166 166
 

+ 2
- 2
src/com/dmdirc/ui/themes/Theme.java 查看文件

@@ -106,7 +106,7 @@ public class Theme implements Comparable<Theme> {
106 106
         if (stream != null) {
107 107
             try {
108 108
                 identity = new ThemeIdentity(stream, this);
109
-                identityController.registerIdentity(identity);
109
+                identityController.addConfigProvider(identity);
110 110
             } catch (InvalidIdentityFileException | IOException ex) {
111 111
                 Logger.userError(ErrorLevel.MEDIUM, "Error loading theme identity file: "
112 112
                         + ex.getMessage());
@@ -123,7 +123,7 @@ public class Theme implements Comparable<Theme> {
123 123
         }
124 124
 
125 125
         enabled = false;
126
-        identityController.unregisterIdentity(identity);
126
+        identityController.removeConfigProvider(identity);
127 127
     }
128 128
 
129 129
     /**

+ 1
- 1
src/com/dmdirc/ui/themes/ThemeManager.java 查看文件

@@ -163,7 +163,7 @@ public final class ThemeManager {
163 163
             enabled.remove(theme.getFileName());
164 164
         }
165 165
 
166
-        identityController.getGlobalConfigIdentity()
166
+        identityController.getUserSettings()
167 167
                 .setOption("themes", "enabled", enabled);
168 168
     }
169 169
 

+ 4
- 4
src/com/dmdirc/updater/UpdateChecker.java 查看文件

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.updater;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.config.IdentityManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.logger.ErrorLevel;
28 28
 import com.dmdirc.logger.Logger;
29 29
 import com.dmdirc.updater.manager.CachingUpdateManager;
@@ -64,10 +64,10 @@ public final class UpdateChecker implements Runnable {
64 64
             return;
65 65
         }
66 66
 
67
-        final ConfigManager config = IdentityManager.getIdentityManager().getGlobalConfiguration();
67
+        final AggregateConfigProvider config = IdentityManager.getIdentityManager().getGlobalConfiguration();
68 68
 
69 69
         if (!config.getOptionBool(DOMAIN, "enable")) {
70
-            IdentityManager.getIdentityManager().getGlobalConfigIdentity().setOption(DOMAIN,
70
+            IdentityManager.getIdentityManager().getUserSettings().setOption(DOMAIN,
71 71
                     "lastcheck", String.valueOf((int) (new Date().getTime() / 1000)));
72 72
 
73 73
             MUTEX.release();
@@ -79,7 +79,7 @@ public final class UpdateChecker implements Runnable {
79 79
 
80 80
         MUTEX.release();
81 81
 
82
-        IdentityManager.getIdentityManager().getGlobalConfigIdentity().setOption(DOMAIN,
82
+        IdentityManager.getIdentityManager().getUserSettings().setOption(DOMAIN,
83 83
                 "lastcheck", String.valueOf((int) (new Date().getTime() / 1000)));
84 84
 
85 85
         UpdateChecker.initTimer();

+ 3
- 3
src/com/dmdirc/updater/components/DefaultsComponent.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.updater.components;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
26 26
 import com.dmdirc.interfaces.config.IdentityController;
27 27
 import com.dmdirc.updater.UpdateComponent;
28 28
 import com.dmdirc.updater.Version;
@@ -72,7 +72,7 @@ public class DefaultsComponent implements UpdateComponent {
72 72
     /** {@inheritDoc} */
73 73
     @Override
74 74
     public Version getVersion() {
75
-        final ConfigManager globalConfig = identityController.getGlobalConfiguration();
75
+        final AggregateConfigProvider globalConfig = identityController.getGlobalConfiguration();
76 76
 
77 77
         if (globalConfig.hasOptionString("identity", "defaultsversion")) {
78 78
             return new Version(globalConfig.getOption("identity",
@@ -109,7 +109,7 @@ public class DefaultsComponent implements UpdateComponent {
109 109
     public boolean doInstall(final String path) throws IOException {
110 110
         final ZipResourceManager ziprm = ZipResourceManager.getInstance(path);
111 111
 
112
-        ziprm.extractResources("", identityController.getIdentityDirectory());
112
+        ziprm.extractResources("", identityController.getUserSettingsDirectory());
113 113
 
114 114
         identityController.loadUserIdentities();
115 115
 

+ 3
- 3
src/com/dmdirc/updater/components/ModeAliasesComponent.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.updater.components;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
26 26
 import com.dmdirc.interfaces.config.IdentityController;
27 27
 import com.dmdirc.updater.UpdateComponent;
28 28
 import com.dmdirc.updater.Version;
@@ -72,7 +72,7 @@ public class ModeAliasesComponent implements UpdateComponent {
72 72
     /** {@inheritDoc} */
73 73
     @Override
74 74
     public Version getVersion() {
75
-        final ConfigManager globalConfig = identityController.getGlobalConfiguration();
75
+        final AggregateConfigProvider globalConfig = identityController.getGlobalConfiguration();
76 76
 
77 77
         if (globalConfig.hasOptionString("identity", "modealiasversion")) {
78 78
             return new Version(globalConfig.getOption("identity",
@@ -109,7 +109,7 @@ public class ModeAliasesComponent implements UpdateComponent {
109 109
     public boolean doInstall(final String path) throws IOException {
110 110
         final ZipResourceManager ziprm = ZipResourceManager.getInstance(path);
111 111
 
112
-        ziprm.extractResources("", identityController.getIdentityDirectory());
112
+        ziprm.extractResources("", identityController.getUserSettingsDirectory());
113 113
 
114 114
         identityController.loadUserIdentities();
115 115
 

+ 2
- 2
src/com/dmdirc/updater/components/PluginComponent.java 查看文件

@@ -22,8 +22,8 @@
22 22
 
23 23
 package com.dmdirc.updater.components;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
26 25
 import com.dmdirc.config.IdentityManager;
26
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 27
 import com.dmdirc.plugins.PluginInfo;
28 28
 import com.dmdirc.updater.UpdateComponent;
29 29
 import com.dmdirc.updater.Version;
@@ -42,7 +42,7 @@ import lombok.RequiredArgsConstructor;
42 42
 public class PluginComponent implements UpdateComponent {
43 43
 
44 44
     /** The config to use. */
45
-    private static final ConfigManager CONFIG = IdentityManager.getIdentityManager().getGlobalConfiguration();
45
+    private static final AggregateConfigProvider CONFIG = IdentityManager.getIdentityManager().getGlobalConfiguration();
46 46
 
47 47
     /** The plugin this component is for. */
48 48
     private final PluginInfo plugin;

+ 2
- 2
src/com/dmdirc/updater/manager/ConfigComponentPolicy.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.updater.manager;
24 24
 
25
-import com.dmdirc.config.ConfigManager;
25
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
26 26
 import com.dmdirc.updater.UpdateComponent;
27 27
 
28 28
 import lombok.RequiredArgsConstructor;
@@ -35,7 +35,7 @@ import lombok.RequiredArgsConstructor;
35 35
 public class ConfigComponentPolicy implements UpdateComponentPolicy {
36 36
 
37 37
     /** The configuration manager to check. */
38
-    private final ConfigManager manager;
38
+    private final AggregateConfigProvider manager;
39 39
 
40 40
     /** {@inheritDoc} */
41 41
     @Override

+ 1
- 1
src/com/dmdirc/updater/manager/DMDircUpdateManager.java 查看文件

@@ -70,7 +70,7 @@ public class DMDircUpdateManager extends CachingUpdateManagerImpl {
70 70
         checkStrategy = new DMDircCheckStrategy(UpdateChannel.STABLE);
71 71
         identityController.getGlobalConfiguration().getBinder().bind(this, DMDircUpdateManager.class);
72 72
         addCheckStrategy(checkStrategy);
73
-        addRetrievalStrategy(new DownloadRetrievalStrategy(identityController.getConfigDir()));
73
+        addRetrievalStrategy(new DownloadRetrievalStrategy(identityController.getConfigurationDirectory()));
74 74
         addInstallationStrategy(new LegacyInstallationStrategy());
75 75
 
76 76
         for (UpdateComponent component : components) {

+ 2
- 2
test/com/dmdirc/ServerTest.java 查看文件

@@ -24,9 +24,9 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.actions.wrappers.AliasWrapper;
26 26
 import com.dmdirc.commandparser.parsers.CommandParser;
27
-import com.dmdirc.config.ConfigManager;
28 27
 import com.dmdirc.config.Identity;
29 28
 import com.dmdirc.interfaces.CommandController;
29
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
30 30
 import com.dmdirc.interfaces.config.IdentityFactory;
31 31
 import com.dmdirc.ui.WindowManager;
32 32
 
@@ -44,7 +44,7 @@ public class ServerTest {
44 44
 
45 45
     @Mock private ServerManager serverManager;
46 46
     @Mock private Identity profile;
47
-    @Mock private ConfigManager configManager;
47
+    @Mock private AggregateConfigProvider configManager;
48 48
     @Mock private CommandParser commandParser;
49 49
     @Mock private ParserFactory parserFactory;
50 50
     @Mock private IdentityFactory identityFactory;

+ 8
- 8
test/com/dmdirc/commandparser/commands/global/NewServerTest.java 查看文件

@@ -25,10 +25,10 @@ import com.dmdirc.FrameContainer;
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.commandparser.CommandArguments;
27 27
 import com.dmdirc.commandparser.commands.context.CommandContext;
28
-import com.dmdirc.config.Identity;
29 28
 import com.dmdirc.interfaces.CommandController;
30
-import com.dmdirc.interfaces.config.IdentityController;
31 29
 import com.dmdirc.interfaces.ServerFactory;
30
+import com.dmdirc.interfaces.config.ConfigProvider;
31
+import com.dmdirc.interfaces.config.IdentityController;
32 32
 import com.dmdirc.plugins.PluginManager;
33 33
 
34 34
 import java.net.URI;
@@ -48,7 +48,7 @@ public class NewServerTest {
48 48
 
49 49
     @Mock private CommandController controller;
50 50
     @Mock private IdentityController identityController;
51
-    @Mock private Identity identity;
51
+    @Mock private ConfigProvider identity;
52 52
     @Mock private FrameContainer container;
53 53
     @Mock private PluginManager pluginManager;
54 54
     @Mock private ServerFactory factory;
@@ -57,8 +57,8 @@ public class NewServerTest {
57 57
 
58 58
     @Before
59 59
     public void setup() {
60
-        when(factory.createServer(any(URI.class), any(Identity.class))).thenReturn(server);
61
-        when(identityController.getIdentitiesByType("profile")).thenReturn(Arrays.asList(new Identity[] { identity }));
60
+        when(factory.createServer(any(URI.class), any(ConfigProvider.class))).thenReturn(server);
61
+        when(identityController.getProvidersByType("profile")).thenReturn(Arrays.asList(new ConfigProvider[] { identity }));
62 62
         command = new NewServer(controller, factory, pluginManager, identityController);
63 63
     }
64 64
 
@@ -67,7 +67,7 @@ public class NewServerTest {
67 67
         command.execute(container, new CommandArguments(controller, "/foo irc.foo.com"),
68 68
                 new CommandContext(null, NewServer.INFO));
69 69
 
70
-        verify(factory).createServer(eq(new URI("irc://irc.foo.com:6667")), any(Identity.class));
70
+        verify(factory).createServer(eq(new URI("irc://irc.foo.com:6667")), any(ConfigProvider.class));
71 71
         verify(server).connect();
72 72
     }
73 73
 
@@ -76,7 +76,7 @@ public class NewServerTest {
76 76
         command.execute(container, new CommandArguments(controller, "/foo irc.foo.com:1234"),
77 77
                 new CommandContext(null, NewServer.INFO));
78 78
 
79
-        verify(factory).createServer(eq(new URI("irc://irc.foo.com:1234")), any(Identity.class));
79
+        verify(factory).createServer(eq(new URI("irc://irc.foo.com:1234")), any(ConfigProvider.class));
80 80
         verify(server).connect();
81 81
     }
82 82
 
@@ -85,7 +85,7 @@ public class NewServerTest {
85 85
         command.execute(container, new CommandArguments(controller, "/foo otheruri://foo.com:123/blah"),
86 86
                 new CommandContext(null, NewServer.INFO));
87 87
 
88
-        verify(factory).createServer(eq(new URI("otheruri://foo.com:123/blah")), any(Identity.class));
88
+        verify(factory).createServer(eq(new URI("otheruri://foo.com:123/blah")), any(ConfigProvider.class));
89 89
         verify(server).connect();
90 90
     }
91 91
 

+ 1
- 1
test/com/dmdirc/config/CipherUtilsTest.java 查看文件

@@ -45,7 +45,7 @@ public class CipherUtilsTest {
45 45
     @Before
46 46
     public void setup() {
47 47
         when(identityController.getGlobalConfiguration()).thenReturn(configManager);
48
-        when(identityController.getGlobalConfigIdentity()).thenReturn(identity);
48
+        when(identityController.getUserSettings()).thenReturn(identity);
49 49
     }
50 50
 
51 51
     @Test

+ 3
- 1
test/com/dmdirc/config/ConfigManagerTest.java 查看文件

@@ -22,9 +22,11 @@
22 22
 package com.dmdirc.config;
23 23
 
24 24
 import com.dmdirc.interfaces.config.ConfigChangeListener;
25
+import com.dmdirc.interfaces.config.ConfigProvider;
25 26
 import com.dmdirc.util.validators.PermissiveValidator;
26 27
 
27 28
 import java.util.Collections;
29
+
28 30
 import org.junit.Before;
29 31
 import org.junit.Test;
30 32
 import org.junit.runner.RunWith;
@@ -43,7 +45,7 @@ public class ConfigManagerTest {
43 45
     public void setup() {
44 46
         IdentityManager.setIdentityManager(identityManager);
45 47
         when(identityManager.getIdentitiesForManager(any(ConfigManager.class)))
46
-                .thenReturn(Collections.<Identity>emptyList());
48
+                .thenReturn(Collections.<ConfigProvider>emptyList());
47 49
     }
48 50
 
49 51
     @Test

+ 1
- 1
test/com/dmdirc/harness/TestConfigSource.java 查看文件

@@ -30,7 +30,7 @@ import java.util.Map;
30 30
 public class TestConfigSource extends ConfigSource {
31 31
 
32 32
     @Override
33
-    protected boolean hasOption(String domain, String option, Validator<String> validator) {
33
+    public boolean hasOption(String domain, String option, Validator<String> validator) {
34 34
         return Boolean.parseBoolean(domain);
35 35
     }
36 36
 

+ 2
- 2
test/com/dmdirc/ui/messages/FormatterTest.java 查看文件

@@ -22,9 +22,9 @@
22 22
 package com.dmdirc.ui.messages;
23 23
 
24 24
 import com.dmdirc.config.ConfigManager;
25
-import com.dmdirc.config.Identity;
26 25
 import com.dmdirc.config.IdentityManager;
27 26
 import com.dmdirc.harness.TestConfigManagerOptionToggle;
27
+import com.dmdirc.interfaces.config.ConfigProvider;
28 28
 
29 29
 import java.util.Collections;
30 30
 
@@ -49,7 +49,7 @@ public class FormatterTest {
49 49
     public void setup() {
50 50
         IdentityManager.setIdentityManager(identityManager);
51 51
         when(identityManager.getIdentitiesForManager(any(ConfigManager.class)))
52
-                .thenReturn(Collections.<Identity>emptyList());
52
+                .thenReturn(Collections.<ConfigProvider>emptyList());
53 53
 
54 54
         mcm = new TestConfigManagerOptionToggle();
55 55
     }

正在加载...
取消
保存