Browse Source

Fix various dependencies.

Change-Id: I8a7de439f394086ec7c2a27fbef5c1ed6bc59dfe
Depends-On: I0d78fdc62431866377a06da819724a49e738b417
Reviewed-on: http://gerrit.dmdirc.com/2704
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 years ago
parent
commit
1a24895588

+ 1
- 1
src/com/dmdirc/ClientModule.java View File

68
 /**
68
 /**
69
  * Provides dependencies for the client.
69
  * Provides dependencies for the client.
70
  */
70
  */
71
-@Module(injects = Main.class, includes = CommandLineOptionsModule.class)
71
+@Module(injects = {Main.class, CommandLineParser.class}, includes = CommandLineOptionsModule.class)
72
 public class ClientModule {
72
 public class ClientModule {
73
 
73
 
74
     /**
74
     /**

+ 3
- 4
src/com/dmdirc/Main.java View File

25
 import com.dmdirc.interfaces.LifecycleController;
25
 import com.dmdirc.interfaces.LifecycleController;
26
 import com.dmdirc.actions.ActionManager;
26
 import com.dmdirc.actions.ActionManager;
27
 import com.dmdirc.actions.CoreActionType;
27
 import com.dmdirc.actions.CoreActionType;
28
-import com.dmdirc.commandline.CommandLineOptionsModule;
29
 import com.dmdirc.commandline.CommandLineParser;
28
 import com.dmdirc.commandline.CommandLineParser;
30
 import com.dmdirc.commandparser.CommandManager;
29
 import com.dmdirc.commandparser.CommandManager;
31
 import com.dmdirc.config.IdentityManager;
30
 import com.dmdirc.config.IdentityManager;
127
         Thread.setDefaultUncaughtExceptionHandler(new DMDircExceptionHandler());
126
         Thread.setDefaultUncaughtExceptionHandler(new DMDircExceptionHandler());
128
 
127
 
129
         try {
128
         try {
130
-            ObjectGraph graph = ObjectGraph.create(
131
-                    new ClientModule(),
132
-                    new CommandLineOptionsModule(new CommandLineParser(args)));
129
+            final ObjectGraph graph = ObjectGraph.create(new ClientModule());
130
+            final CommandLineParser parser = graph.get(CommandLineParser.class);
131
+            parser.parse(args);
133
             mainInstance = graph.get(Main.class);
132
             mainInstance = graph.get(Main.class);
134
             mainInstance.init();
133
             mainInstance.init();
135
         } catch (Throwable ex) {
134
         } catch (Throwable ex) {

+ 3
- 24
src/com/dmdirc/commandline/CommandLineOptionsModule.java View File

31
 /**
31
 /**
32
  * Provides options based on the command line.
32
  * Provides options based on the command line.
33
  */
33
  */
34
-@Module(library = true)
34
+@Module(library = true, complete = false)
35
 public class CommandLineOptionsModule {
35
 public class CommandLineOptionsModule {
36
 
36
 
37
     /**
37
     /**
57
         DirectoryType value();
57
         DirectoryType value();
58
     }
58
     }
59
 
59
 
60
-    /** The parser to use for command-line information. */
61
-    private final CommandLineParser parser;
62
-
63
-    /**
64
-     * Creates a new {@link CommandLineOptionsModule}.
65
-     *
66
-     * @param parser The parser to use for command-line information.
67
-     */
68
-    public CommandLineOptionsModule(final CommandLineParser parser) {
69
-        this.parser = parser;
70
-    }
71
-
72
-    /**
73
-     * Provides the command-line parser used for this instance.
74
-     *
75
-     * @return The command-line parser.
76
-     */
77
-    @Provides
78
-    public CommandLineParser getParser() {
79
-        return parser;
80
-    }
81
-
82
     /**
60
     /**
83
      * Provides the base directory that all DMDirc user data is stored in.
61
      * Provides the base directory that all DMDirc user data is stored in.
84
      *
62
      *
63
+     * @param parser The parser to get the user-supplied directory from.
85
      * @return The base directory.
64
      * @return The base directory.
86
      */
65
      */
87
     @Provides
66
     @Provides
88
     @Singleton
67
     @Singleton
89
     @Directory(DirectoryType.BASE)
68
     @Directory(DirectoryType.BASE)
90
-    public String getBaseDirectory() {
69
+    public String getBaseDirectory(final CommandLineParser parser) {
91
         if (parser.getConfigDirectory() == null) {
70
         if (parser.getConfigDirectory() == null) {
92
             return getDefaultBaseDirectory();
71
             return getDefaultBaseDirectory();
93
         } else {
72
         } else {

+ 18
- 3
src/com/dmdirc/commandline/CommandLineParser.java View File

22
 
22
 
23
 package com.dmdirc.commandline;
23
 package com.dmdirc.commandline;
24
 
24
 
25
-import com.dmdirc.Main;
26
 import com.dmdirc.ServerManager;
25
 import com.dmdirc.ServerManager;
27
 import com.dmdirc.commandparser.commands.global.NewServer;
26
 import com.dmdirc.commandparser.commands.global.NewServer;
28
 import com.dmdirc.config.IdentityManager;
27
 import com.dmdirc.config.IdentityManager;
37
 import java.util.ArrayList;
36
 import java.util.ArrayList;
38
 import java.util.List;
37
 import java.util.List;
39
 
38
 
39
+import javax.inject.Inject;
40
+import javax.inject.Provider;
41
+import javax.inject.Singleton;
42
+
40
 /**
43
 /**
41
  * Parses command line arguments for the client.
44
  * Parses command line arguments for the client.
42
  */
45
  */
46
+@Singleton
43
 public class CommandLineParser {
47
 public class CommandLineParser {
44
 
48
 
45
     /**
49
     /**
62
     /** A list of addresses to autoconnect to. */
66
     /** A list of addresses to autoconnect to. */
63
     private final List<URI> addresses = new ArrayList<>();
67
     private final List<URI> addresses = new ArrayList<>();
64
 
68
 
69
+    /** Provider to use to get server managers. */
70
+    private final Provider<ServerManager> serverManagerProvider;
71
+
65
     /** Whether to disable error reporting or not. */
72
     /** Whether to disable error reporting or not. */
66
     private boolean disablereporting;
73
     private boolean disablereporting;
67
 
74
 
76
 
83
 
77
     /**
84
     /**
78
      * Creates a new instance of CommandLineParser.
85
      * Creates a new instance of CommandLineParser.
86
+     */
87
+    @Inject
88
+    public CommandLineParser(final Provider<ServerManager> serverManagerProvider) {
89
+        this.serverManagerProvider = serverManagerProvider;
90
+    }
91
+
92
+    /**
93
+     * Parses the given arguments.
79
      *
94
      *
80
      * @param arguments The arguments to be parsed
95
      * @param arguments The arguments to be parsed
81
      */
96
      */
82
-    public CommandLineParser(final String ... arguments) {
97
+    public void parse(final String ... arguments) {
83
         boolean inArg = false;
98
         boolean inArg = false;
84
         char previousArg = '.';
99
         char previousArg = '.';
85
 
100
 
114
             }
129
             }
115
         }
130
         }
116
 
131
 
117
-        new RemoteServer(Main.mainInstance).bind();
132
+        new RemoteServer(serverManagerProvider).bind();
118
     }
133
     }
119
 
134
 
120
     /**
135
     /**

+ 10
- 10
src/com/dmdirc/commandline/RemoteServer.java View File

22
 
22
 
23
 package com.dmdirc.commandline;
23
 package com.dmdirc.commandline;
24
 
24
 
25
-import com.dmdirc.Main;
25
+import com.dmdirc.ServerManager;
26
 import com.dmdirc.logger.ErrorLevel;
26
 import com.dmdirc.logger.ErrorLevel;
27
 import com.dmdirc.logger.Logger;
27
 import com.dmdirc.logger.Logger;
28
 
28
 
34
 import java.rmi.server.UnicastRemoteObject;
34
 import java.rmi.server.UnicastRemoteObject;
35
 import java.util.List;
35
 import java.util.List;
36
 
36
 
37
+import javax.inject.Provider;
38
+
37
 /**
39
 /**
38
  * An RMI server that allows other clients to interact with DMDirc.
40
  * An RMI server that allows other clients to interact with DMDirc.
39
  */
41
  */
43
     private static final int MINPORT = 3634;
45
     private static final int MINPORT = 3634;
44
     /** The maximum port to use for RMI binding. */
46
     /** The maximum port to use for RMI binding. */
45
     private static final int MAXPORT = MINPORT + 5;
47
     private static final int MAXPORT = MINPORT + 5;
46
-    /** The interface we're exposing. */
47
-    private final Main main;
48
+    /** Provider for the server manager to use to connect. */
49
+    private final Provider<ServerManager> serverManager;
48
 
50
 
49
     /**
51
     /**
50
      * Crate a new RemoteServer.
52
      * Crate a new RemoteServer.
51
      *
53
      *
52
-     * @param main Main instance to use to do things.
54
+     * @param serverManager Provider of a server manager to use to connect.
53
      */
55
      */
54
-    public RemoteServer(final Main main) {
55
-        this.main = main;
56
+    public RemoteServer(final Provider<ServerManager> serverManager) {
57
+        this.serverManager = serverManager;
56
     }
58
     }
57
 
59
 
58
     /** {@inheritDoc} */
60
     /** {@inheritDoc} */
59
     @Override
61
     @Override
60
     public void connect(final List<URI> addresses) throws RemoteException {
62
     public void connect(final List<URI> addresses) throws RemoteException {
61
         for (URI address : addresses) {
63
         for (URI address : addresses) {
62
-            main.getServerManager().connectToAddress(address);
64
+            serverManager.get().connectToAddress(address);
63
         }
65
         }
64
     }
66
     }
65
 
67
 
106
                 } else {
108
                 } else {
107
                     return iface;
109
                     return iface;
108
                 }
110
                 }
109
-            } catch (RemoteException ex) {
110
-                continue;
111
-            } catch (NotBoundException ex) {
111
+            } catch (RemoteException | NotBoundException ex) {
112
                 continue;
112
                 continue;
113
             }
113
             }
114
         }
114
         }

+ 2
- 0
src/com/dmdirc/plugins/PluginInfo.java View File

26
 import com.dmdirc.ServerManager;
26
 import com.dmdirc.ServerManager;
27
 import com.dmdirc.actions.ActionManager;
27
 import com.dmdirc.actions.ActionManager;
28
 import com.dmdirc.actions.CoreActionType;
28
 import com.dmdirc.actions.CoreActionType;
29
+import com.dmdirc.actions.wrappers.PerformWrapper;
29
 import com.dmdirc.commandparser.CommandManager;
30
 import com.dmdirc.commandparser.CommandManager;
30
 import com.dmdirc.config.Identity;
31
 import com.dmdirc.config.Identity;
31
 import com.dmdirc.config.IdentityManager;
32
 import com.dmdirc.config.IdentityManager;
177
         injector.addParameter(WindowManager.class, WindowManager.getWindowManager());
178
         injector.addParameter(WindowManager.class, WindowManager.getWindowManager());
178
         injector.addParameter(StatusBarManager.getStatusBarManager());
179
         injector.addParameter(StatusBarManager.getStatusBarManager());
179
         injector.addParameter(PreferencesManager.class, PreferencesManager.getPreferencesManager());
180
         injector.addParameter(PreferencesManager.class, PreferencesManager.getPreferencesManager());
181
+        injector.addParameter(PerformWrapper.class, PerformWrapper.getPerformWrapper());
180
 
182
 
181
         return injector;
183
         return injector;
182
     }
184
     }

+ 17
- 7
src/com/dmdirc/ui/core/util/URLHandler.java View File

22
 
22
 
23
 package com.dmdirc.ui.core.util;
23
 package com.dmdirc.ui.core.util;
24
 
24
 
25
+import com.dmdirc.ServerManager;
25
 import com.dmdirc.config.ConfigManager;
26
 import com.dmdirc.config.ConfigManager;
26
-import com.dmdirc.config.IdentityManager;
27
 import com.dmdirc.interfaces.ui.UIController;
27
 import com.dmdirc.interfaces.ui.UIController;
28
 import com.dmdirc.logger.ErrorLevel;
28
 import com.dmdirc.logger.ErrorLevel;
29
 import com.dmdirc.logger.Logger;
29
 import com.dmdirc.logger.Logger;
47
     private final UIController controller;
47
     private final UIController controller;
48
     /** Config manager. */
48
     /** Config manager. */
49
     private final ConfigManager config;
49
     private final ConfigManager config;
50
+    /** Server manager to use to connect to servers. */
51
+    private final ServerManager serverManager;
52
+    /** Status bar manager to use to show messages. */
53
+    private final StatusBarManager statusBarManager;
50
     /** Desktop handler. */
54
     /** Desktop handler. */
51
     private final Desktop desktop;
55
     private final Desktop desktop;
52
 
56
 
55
      *
59
      *
56
      * @param controller The UI controller to show dialogs etc on
60
      * @param controller The UI controller to show dialogs etc on
57
      */
61
      */
58
-    public URLHandler(final UIController controller) {
62
+    public URLHandler(
63
+            final UIController controller,
64
+            final ConfigManager globalConfig,
65
+            final ServerManager serverManager,
66
+            final StatusBarManager statusBarManager) {
59
         this.controller = controller;
67
         this.controller = controller;
60
-        this.config = IdentityManager.getIdentityManager().getGlobalConfiguration();
68
+        this.config = globalConfig;
69
+        this.serverManager = serverManager;
70
+        this.statusBarManager = statusBarManager;
61
         this.desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
71
         this.desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
62
     }
72
     }
63
 
73
 
152
         final String command = config.getOption("protocol", uri.getScheme().toLowerCase());
162
         final String command = config.getOption("protocol", uri.getScheme().toLowerCase());
153
 
163
 
154
         if ("DMDIRC".equals(command)) {
164
         if ("DMDIRC".equals(command)) {
155
-            StatusBarManager.getStatusBarManager().setMessage(
165
+            statusBarManager.setMessage(
156
                     new StatusMessage("Connecting to: " + uri.toString(),
166
                     new StatusMessage("Connecting to: " + uri.toString(),
157
                     config));
167
                     config));
158
-            controller.getMain().getServerManager().connectToAddress(uri);
168
+            serverManager.connectToAddress(uri);
159
         } else if ("BROWSER".equals(command)) {
169
         } else if ("BROWSER".equals(command)) {
160
-            StatusBarManager.getStatusBarManager().setMessage(
170
+            statusBarManager.setMessage(
161
                     new StatusMessage("Opening: " + uri.toString(),
171
                     new StatusMessage("Opening: " + uri.toString(),
162
                     config));
172
                     config));
163
             execBrowser(uri);
173
             execBrowser(uri);
164
         } else if ("MAIL".equals(command)) {
174
         } else if ("MAIL".equals(command)) {
165
             execMail(uri);
175
             execMail(uri);
166
         } else {
176
         } else {
167
-            StatusBarManager.getStatusBarManager().setMessage(
177
+            statusBarManager.setMessage(
168
                     new StatusMessage("Opening: " + uri.toString(),
178
                     new StatusMessage("Opening: " + uri.toString(),
169
                     config));
179
                     config));
170
             execApp(substituteParams(uri, command));
180
             execApp(substituteParams(uri, command));

Loading…
Cancel
Save