|
@@ -29,8 +29,10 @@ import com.dmdirc.addons.debug.DebugCommand;
|
29
|
29
|
import com.dmdirc.commandparser.CommandArguments;
|
30
|
30
|
import com.dmdirc.commandparser.commands.context.CommandContext;
|
31
|
31
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
|
32
|
+import com.dmdirc.interfaces.config.IdentityController;
|
32
|
33
|
import com.dmdirc.ui.messages.Styliser;
|
33
|
34
|
import com.dmdirc.updater.UpdateChecker;
|
|
35
|
+import com.dmdirc.updater.manager.CachingUpdateManager;
|
34
|
36
|
|
35
|
37
|
import javax.inject.Inject;
|
36
|
38
|
import javax.inject.Provider;
|
|
@@ -42,20 +44,30 @@ public class ForceUpdate extends DebugCommand {
|
42
|
44
|
|
43
|
45
|
/** The global configuration used to check if updates are enabled. */
|
44
|
46
|
private final AggregateConfigProvider globalConfig;
|
|
47
|
+ /** The controller to use to read/write settings for the updater. */
|
|
48
|
+ private final IdentityController identityController;
|
|
49
|
+ /** The update manager to use when forcing an update. */
|
|
50
|
+ private final CachingUpdateManager updateManager;
|
45
|
51
|
|
46
|
52
|
/**
|
47
|
53
|
* Creates a new instance of the command.
|
48
|
54
|
*
|
49
|
55
|
* @param commandProvider The provider to use to access the main debug command.
|
50
|
56
|
* @param globalConfig The global config to use to check if updates are enabled.
|
|
57
|
+ * @param identityController The controller to use to read/write settings for the updater.
|
|
58
|
+ * @param updateManager The update manager to use when forcing an update.
|
51
|
59
|
*/
|
52
|
60
|
@Inject
|
53
|
61
|
public ForceUpdate(
|
54
|
62
|
final Provider<Debug> commandProvider,
|
55
|
|
- @GlobalConfig final AggregateConfigProvider globalConfig) {
|
|
63
|
+ @GlobalConfig final AggregateConfigProvider globalConfig,
|
|
64
|
+ final IdentityController identityController,
|
|
65
|
+ final CachingUpdateManager updateManager) {
|
56
|
66
|
super(commandProvider);
|
57
|
67
|
|
58
|
68
|
this.globalConfig = globalConfig;
|
|
69
|
+ this.identityController = identityController;
|
|
70
|
+ this.updateManager = updateManager;
|
59
|
71
|
}
|
60
|
72
|
|
61
|
73
|
/** {@inheritDoc} */
|
|
@@ -74,8 +86,8 @@ public class ForceUpdate extends DebugCommand {
|
74
|
86
|
@Override
|
75
|
87
|
public void execute(final FrameContainer origin,
|
76
|
88
|
final CommandArguments args, final CommandContext context) {
|
77
|
|
- if (globalConfig.getOptionBool("updater","enable")) {
|
78
|
|
- new Thread(new UpdateChecker(), "Forced update checker").start();
|
|
89
|
+ if (globalConfig.getOptionBool("updater", "enable")) {
|
|
90
|
+ UpdateChecker.checkNow(updateManager, identityController, "Forced update checker");
|
79
|
91
|
} else {
|
80
|
92
|
sendLine(origin, args.isSilent(), FORMAT_ERROR, "Update checking is "
|
81
|
93
|
+ "currenty disabled. You can enable it by typing:");
|