|
@@ -22,7 +22,6 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.updater;
|
24
|
24
|
|
25
|
|
-import com.dmdirc.config.IdentityManager;
|
26
|
25
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
27
|
26
|
import com.dmdirc.interfaces.config.IdentityController;
|
28
|
27
|
import com.dmdirc.logger.ErrorLevel;
|
|
@@ -50,19 +49,11 @@ public final class UpdateChecker implements Runnable {
|
50
|
49
|
/** Our timer. */
|
51
|
50
|
private static Timer timer = new Timer("Update Checker Timer");
|
52
|
51
|
|
53
|
|
- /** The update manager to use. */
|
54
|
|
- private static CachingUpdateManager manager;
|
55
|
|
-
|
56
|
52
|
/** The update manager to use. */
|
57
|
53
|
private final CachingUpdateManager updateManager;
|
58
|
54
|
/** The controller to use to read and write settings. */
|
59
|
55
|
private final IdentityController identityController;
|
60
|
56
|
|
61
|
|
- @Deprecated
|
62
|
|
- public UpdateChecker() {
|
63
|
|
- this(manager, IdentityManager.getIdentityManager());
|
64
|
|
- }
|
65
|
|
-
|
66
|
57
|
/**
|
67
|
58
|
* Creates a new instance of {@link UpdateChecker}.
|
68
|
59
|
*
|
|
@@ -91,18 +82,18 @@ public final class UpdateChecker implements Runnable {
|
91
|
82
|
"lastcheck", String.valueOf((int) (new Date().getTime() / 1000)));
|
92
|
83
|
|
93
|
84
|
MUTEX.release();
|
94
|
|
- initTimer(updateManager, identityController);
|
|
85
|
+ init(updateManager, identityController);
|
95
|
86
|
return;
|
96
|
87
|
}
|
97
|
88
|
|
98
|
|
- manager.checkForUpdates();
|
|
89
|
+ updateManager.checkForUpdates();
|
99
|
90
|
|
100
|
91
|
MUTEX.release();
|
101
|
92
|
|
102
|
93
|
identityController.getUserSettings().setOption(DOMAIN,
|
103
|
94
|
"lastcheck", String.valueOf((int) (new Date().getTime() / 1000)));
|
104
|
95
|
|
105
|
|
- initTimer(updateManager, identityController);
|
|
96
|
+ init(updateManager, identityController);
|
106
|
97
|
|
107
|
98
|
if (config.getOptionBool(DOMAIN, "autoupdate")) {
|
108
|
99
|
for (UpdateComponent component : updateManager.getComponents()) {
|
|
@@ -129,23 +120,9 @@ public final class UpdateChecker implements Runnable {
|
129
|
120
|
public static void init(
|
130
|
121
|
final CachingUpdateManager manager,
|
131
|
122
|
final IdentityController controller) {
|
132
|
|
- UpdateChecker.manager = manager;
|
133
|
|
- initTimer(manager, controller);
|
134
|
|
- }
|
135
|
|
-
|
136
|
|
- /**
|
137
|
|
- * Initialises the timer to check for updates.
|
138
|
|
- *
|
139
|
|
- * @param updateManager The manager to use when checking for updates.
|
140
|
|
- * @param identityController The controller to use to retrieve and update settings.
|
141
|
|
- * @since 0.6.5
|
142
|
|
- */
|
143
|
|
- protected static void initTimer(
|
144
|
|
- final CachingUpdateManager updateManager,
|
145
|
|
- final IdentityController identityController) {
|
146
|
|
- final int last = identityController.getGlobalConfiguration()
|
|
123
|
+ final int last = controller.getGlobalConfiguration()
|
147
|
124
|
.getOptionInt(DOMAIN, "lastcheck");
|
148
|
|
- final int freq = identityController.getGlobalConfiguration()
|
|
125
|
+ final int freq = controller.getGlobalConfiguration()
|
149
|
126
|
.getOptionInt(DOMAIN, "frequency");
|
150
|
127
|
final int timestamp = (int) (new Date().getTime() / 1000);
|
151
|
128
|
int time = 0;
|
|
@@ -167,19 +144,11 @@ public final class UpdateChecker implements Runnable {
|
167
|
144
|
/** {@inheritDoc} */
|
168
|
145
|
@Override
|
169
|
146
|
public void run() {
|
170
|
|
- checkNow(updateManager, identityController);
|
|
147
|
+ checkNow(manager, controller);
|
171
|
148
|
}
|
172
|
149
|
}, time * 1000);
|
173
|
150
|
}
|
174
|
151
|
|
175
|
|
- /**
|
176
|
|
- * Checks for updates now.
|
177
|
|
- */
|
178
|
|
- @Deprecated
|
179
|
|
- public static void checkNow() {
|
180
|
|
- checkNow(manager, IdentityManager.getIdentityManager(), "Update Checker thread");
|
181
|
|
- }
|
182
|
|
-
|
183
|
152
|
/**
|
184
|
153
|
* Checks for updates now.
|
185
|
154
|
*
|
|
@@ -189,7 +158,7 @@ public final class UpdateChecker implements Runnable {
|
189
|
158
|
public static void checkNow(
|
190
|
159
|
final CachingUpdateManager updateManager,
|
191
|
160
|
final IdentityController identityController) {
|
192
|
|
- checkNow(manager, identityController, "Update Checker thread");
|
|
161
|
+ checkNow(updateManager, identityController, "Update Checker thread");
|
193
|
162
|
}
|
194
|
163
|
|
195
|
164
|
/**
|