diff options
Diffstat (limited to 'client/trunk/src')
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/CloseServerSocketThread.java | 33 | ||||
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/DownloadItem/DeinitalizeModeThread.java | 8 | ||||
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/DownloadItem/DownloadItemMode.java | 14 | ||||
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/DownloadItem/ModeControl.java | 45 | ||||
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/DownloadItem/PullMode.java | 24 | ||||
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/DownloadItem/PushMode.java (renamed from client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java) | 97 | ||||
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/DownloadItem/UnknownDownloadItemModeException.java | 5 | ||||
-rw-r--r-- | client/trunk/src/com/fourisland/instadisc/InstaDiscView.java | 75 |
8 files changed, 187 insertions, 114 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/CloseServerSocketThread.java b/client/trunk/src/com/fourisland/instadisc/CloseServerSocketThread.java deleted file mode 100644 index cfe1820..0000000 --- a/client/trunk/src/com/fourisland/instadisc/CloseServerSocketThread.java +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* | ||
2 | * To change this template, choose Tools | Templates | ||
3 | * and open the template in the editor. | ||
4 | */ | ||
5 | |||
6 | package com.fourisland.instadisc; | ||
7 | |||
8 | import java.io.IOException; | ||
9 | import java.net.ServerSocket; | ||
10 | import java.util.logging.Level; | ||
11 | import java.util.logging.Logger; | ||
12 | |||
13 | /** | ||
14 | * | ||
15 | * @author hatkirby | ||
16 | */ | ||
17 | class CloseServerSocketThread implements Runnable { | ||
18 | |||
19 | ServerSocket svr; | ||
20 | |||
21 | public CloseServerSocketThread(ServerSocket svr) { | ||
22 | this.svr = svr; | ||
23 | } | ||
24 | |||
25 | public void run() { | ||
26 | try { | ||
27 | svr.close(); | ||
28 | } catch (IOException ex) { | ||
29 | Logger.getLogger(CloseServerSocketThread.class.getName()).log(Level.SEVERE, null, ex); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | } | ||
diff --git a/client/trunk/src/com/fourisland/instadisc/DownloadItem/DeinitalizeModeThread.java b/client/trunk/src/com/fourisland/instadisc/DownloadItem/DeinitalizeModeThread.java new file mode 100644 index 0000000..726b22e --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/DownloadItem/DeinitalizeModeThread.java | |||
@@ -0,0 +1,8 @@ | |||
1 | package com.fourisland.instadisc.DownloadItem; | ||
2 | |||
3 | public class DeinitalizeModeThread implements Runnable | ||
4 | { | ||
5 | public void run() { | ||
6 | ModeControl.INSTANCE.modeDeinitalize(); | ||
7 | } | ||
8 | } \ No newline at end of file | ||
diff --git a/client/trunk/src/com/fourisland/instadisc/DownloadItem/DownloadItemMode.java b/client/trunk/src/com/fourisland/instadisc/DownloadItem/DownloadItemMode.java new file mode 100644 index 0000000..157a62a --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/DownloadItem/DownloadItemMode.java | |||
@@ -0,0 +1,14 @@ | |||
1 | package com.fourisland.instadisc.DownloadItem; | ||
2 | |||
3 | import java.util.Timer; | ||
4 | |||
5 | public interface DownloadItemMode | ||
6 | { | ||
7 | public void modeInitalize(); | ||
8 | public void modeDeinitalize(); | ||
9 | |||
10 | public void requestRetained(); | ||
11 | |||
12 | public int setTimer(); | ||
13 | public void timerTick(); | ||
14 | } \ No newline at end of file | ||
diff --git a/client/trunk/src/com/fourisland/instadisc/DownloadItem/ModeControl.java b/client/trunk/src/com/fourisland/instadisc/DownloadItem/ModeControl.java new file mode 100644 index 0000000..3fcaa4b --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/DownloadItem/ModeControl.java | |||
@@ -0,0 +1,45 @@ | |||
1 | package com.fourisland.instadisc.DownloadItem; | ||
2 | |||
3 | import java.util.Timer; | ||
4 | |||
5 | public class ModeControl implements DownloadItemMode | ||
6 | { | ||
7 | public static final ModeControl INSTANCE = new ModeControl(); | ||
8 | private DownloadItemMode dim; | ||
9 | |||
10 | public void initalize(String dim) throws UnknownDownloadItemModeException | ||
11 | { | ||
12 | if (dim.equals("Push")) | ||
13 | { | ||
14 | this.dim = new PushMode(); | ||
15 | } else if (dim.equals("Pull")) | ||
16 | { | ||
17 | this.dim = new PullMode(); | ||
18 | } else { | ||
19 | throw new UnknownDownloadItemModeException(); | ||
20 | } | ||
21 | |||
22 | Runtime.getRuntime().addShutdownHook(new Thread(new DeinitalizeModeThread())); | ||
23 | } | ||
24 | |||
25 | public void modeInitalize() { | ||
26 | dim.modeInitalize(); | ||
27 | } | ||
28 | |||
29 | public void modeDeinitalize() { | ||
30 | dim.modeDeinitalize(); | ||
31 | } | ||
32 | |||
33 | public void requestRetained() | ||
34 | { | ||
35 | dim.requestRetained(); | ||
36 | } | ||
37 | |||
38 | public int setTimer() { | ||
39 | return dim.setTimer(); | ||
40 | } | ||
41 | |||
42 | public void timerTick() { | ||
43 | dim.timerTick(); | ||
44 | } | ||
45 | } \ No newline at end of file | ||
diff --git a/client/trunk/src/com/fourisland/instadisc/DownloadItem/PullMode.java b/client/trunk/src/com/fourisland/instadisc/DownloadItem/PullMode.java new file mode 100644 index 0000000..8e54542 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/DownloadItem/PullMode.java | |||
@@ -0,0 +1,24 @@ | |||
1 | package com.fourisland.instadisc.DownloadItem; | ||
2 | |||
3 | public class PullMode implements DownloadItemMode | ||
4 | { | ||
5 | public void modeInitalize() { | ||
6 | throw new UnsupportedOperationException("Not supported yet."); | ||
7 | } | ||
8 | |||
9 | public void modeDeinitalize() { | ||
10 | throw new UnsupportedOperationException("Not supported yet."); | ||
11 | } | ||
12 | |||
13 | public void requestRetained() { | ||
14 | throw new UnsupportedOperationException("Not supported yet."); | ||
15 | } | ||
16 | |||
17 | public int setTimer() { | ||
18 | throw new UnsupportedOperationException("Not supported yet."); | ||
19 | } | ||
20 | |||
21 | public void timerTick() { | ||
22 | throw new UnsupportedOperationException("Not supported yet."); | ||
23 | } | ||
24 | } \ No newline at end of file | ||
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java b/client/trunk/src/com/fourisland/instadisc/DownloadItem/PushMode.java index 05af63c..eb5ab5c 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java +++ b/client/trunk/src/com/fourisland/instadisc/DownloadItem/PushMode.java | |||
@@ -1,10 +1,8 @@ | |||
1 | /* | 1 | package com.fourisland.instadisc.DownloadItem; |
2 | * To change this template, choose Tools | Templates | ||
3 | * and open the template in the editor. | ||
4 | */ | ||
5 | package com.fourisland.instadisc; | ||
6 | 2 | ||
3 | import com.fourisland.instadisc.Database.Wrapper; | ||
7 | import com.fourisland.instadisc.Item.Item; | 4 | import com.fourisland.instadisc.Item.Item; |
5 | import com.fourisland.instadisc.XmlRpc; | ||
8 | import java.io.IOException; | 6 | import java.io.IOException; |
9 | import java.io.InputStream; | 7 | import java.io.InputStream; |
10 | import java.net.ServerSocket; | 8 | import java.net.ServerSocket; |
@@ -14,25 +12,48 @@ import java.util.HashMap; | |||
14 | import java.util.logging.Level; | 12 | import java.util.logging.Level; |
15 | import java.util.logging.Logger; | 13 | import java.util.logging.Logger; |
16 | 14 | ||
17 | /** | ||
18 | * | ||
19 | * @author hatkirby | ||
20 | */ | ||
21 | public class InstaDiscThread implements Runnable { | ||
22 | 15 | ||
23 | boolean cancelled = false; | 16 | public class PushMode implements DownloadItemMode |
24 | InstaDiscView idv; | 17 | { |
18 | InstaDiscThread idt; | ||
25 | 19 | ||
26 | public InstaDiscThread() | 20 | public void modeInitalize() |
27 | { | 21 | { |
28 | this.idv = null; | 22 | idt = new InstaDiscThread(); |
23 | new Thread(idt).start(); | ||
29 | } | 24 | } |
30 | 25 | ||
31 | public InstaDiscThread(InstaDiscView idv) | 26 | public void modeDeinitalize() |
32 | { | 27 | { |
33 | this.idv = idv; | 28 | idt.kill(); |
29 | } | ||
30 | |||
31 | public void requestRetained() { | ||
32 | XmlRpc xmlrpc = new XmlRpc("requestRetained"); | ||
33 | xmlrpc.execute(); | ||
34 | } | ||
35 | |||
36 | public int setTimer() { | ||
37 | int delay = (1000 * 60 * 60); | ||
38 | if (Wrapper.getConfig("ipCheckUnit").equals("day")) { | ||
39 | delay *= (24 * Integer.decode(Wrapper.getConfig("ipCheckValue"))); | ||
40 | } else if (Wrapper.getConfig("ipCheckUnit").equals("hour")) { | ||
41 | delay *= Integer.decode(Wrapper.getConfig("ipCheckValue")); | ||
42 | } | ||
43 | |||
44 | return delay; | ||
34 | } | 45 | } |
35 | 46 | ||
47 | public void timerTick() { | ||
48 | XmlRpc xmlrpc = new XmlRpc("checkRegistration"); | ||
49 | xmlrpc.execute(); | ||
50 | } | ||
51 | } | ||
52 | class InstaDiscThread implements Runnable { | ||
53 | |||
54 | boolean cancelled = false; | ||
55 | ServerSocket svr; | ||
56 | |||
36 | public void cancel() { | 57 | public void cancel() { |
37 | cancelled = true; | 58 | cancelled = true; |
38 | } | 59 | } |
@@ -40,16 +61,15 @@ public class InstaDiscThread implements Runnable { | |||
40 | public void run() { | 61 | public void run() { |
41 | try | 62 | try |
42 | { | 63 | { |
43 | ServerSocket svr = new ServerSocket(); | 64 | svr = new ServerSocket(); |
44 | java.net.InetSocketAddress addr = new java.net.InetSocketAddress(1204); | 65 | java.net.InetSocketAddress addr = new java.net.InetSocketAddress(1204); |
45 | svr.bind(addr); | 66 | svr.bind(addr); |
46 | Runtime.getRuntime().addShutdownHook(new Thread(new CloseServerSocketThread(svr))); | ||
47 | while (!cancelled) | 67 | while (!cancelled) |
48 | { | 68 | { |
49 | try | 69 | try |
50 | { | 70 | { |
51 | Socket s = svr.accept(); | 71 | Socket s = svr.accept(); |
52 | HandleItemThread hit = new HandleItemThread(s,idv); | 72 | HandleItemThread hit = new HandleItemThread(s); |
53 | Thread hitt = new Thread(hit); | 73 | Thread hitt = new Thread(hit); |
54 | hitt.start(); | 74 | hitt.start(); |
55 | } catch (SocketException ex) | 75 | } catch (SocketException ex) |
@@ -66,31 +86,31 @@ public class InstaDiscThread implements Runnable { | |||
66 | { | 86 | { |
67 | Logger.getLogger(InstaDiscThread.class.getName()).log(Level.SEVERE, null, ex); | 87 | Logger.getLogger(InstaDiscThread.class.getName()).log(Level.SEVERE, null, ex); |
68 | } | 88 | } |
69 | 89 | } | |
90 | |||
91 | public void kill() | ||
92 | { | ||
93 | try | ||
94 | { | ||
95 | svr.close(); | ||
96 | } catch (IOException ex) | ||
97 | { | ||
98 | Logger.getLogger(InstaDiscThread.class.getName()).log(Level.SEVERE, null, ex); | ||
99 | } | ||
70 | } | 100 | } |
71 | } | 101 | } |
72 | 102 | ||
73 | class HandleItemThread implements Runnable { | 103 | class HandleItemThread implements Runnable { |
74 | 104 | ||
75 | Socket s; | 105 | Socket s; |
76 | InstaDiscView idv; | ||
77 | 106 | ||
78 | public HandleItemThread(Socket s, InstaDiscView idv) { | 107 | public HandleItemThread(Socket s) { |
79 | this.s = s; | 108 | this.s = s; |
80 | this.idv = idv; | ||
81 | } | 109 | } |
82 | 110 | ||
83 | public void run() { | 111 | public void run() { |
84 | try | 112 | try |
85 | { | 113 | { |
86 | idv.startProgress(); | ||
87 | idv.doText("Downloading Item...."); | ||
88 | } catch (NullPointerException ex) | ||
89 | { | ||
90 | } | ||
91 | |||
92 | try | ||
93 | { | ||
94 | InputStream is = s.getInputStream(); | 114 | InputStream is = s.getInputStream(); |
95 | int buffer[] = new int[1000]; | 115 | int buffer[] = new int[1000]; |
96 | int rs = 0; | 116 | int rs = 0; |
@@ -107,13 +127,6 @@ class HandleItemThread implements Runnable { | |||
107 | buffer[i] = rs; | 127 | buffer[i] = rs; |
108 | } | 128 | } |
109 | 129 | ||
110 | try | ||
111 | { | ||
112 | idv.doProgress(buffer.length / (is.available()+1)); | ||
113 | } catch (NullPointerException ex) | ||
114 | { | ||
115 | } | ||
116 | |||
117 | i++; | 130 | i++; |
118 | } catch (SocketException ex) | 131 | } catch (SocketException ex) |
119 | { | 132 | { |
@@ -149,7 +162,6 @@ class HandleItemThread implements Runnable { | |||
149 | i++; | 162 | i++; |
150 | } | 163 | } |
151 | 164 | ||
152 | //Logger.getLogger(HandleItemThread.class.getName()).log(Level.INFO, headerMap.toString()); | ||
153 | try | 165 | try |
154 | { | 166 | { |
155 | s.close(); | 167 | s.close(); |
@@ -164,12 +176,5 @@ class HandleItemThread implements Runnable { | |||
164 | { | 176 | { |
165 | Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex); | 177 | Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex); |
166 | } | 178 | } |
167 | |||
168 | try | ||
169 | { | ||
170 | idv.doneProgress(); | ||
171 | } catch (NullPointerException ex) | ||
172 | { | ||
173 | } | ||
174 | } | 179 | } |
175 | } | 180 | } |
diff --git a/client/trunk/src/com/fourisland/instadisc/DownloadItem/UnknownDownloadItemModeException.java b/client/trunk/src/com/fourisland/instadisc/DownloadItem/UnknownDownloadItemModeException.java new file mode 100644 index 0000000..4fc7758 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/DownloadItem/UnknownDownloadItemModeException.java | |||
@@ -0,0 +1,5 @@ | |||
1 | package com.fourisland.instadisc.DownloadItem; | ||
2 | |||
3 | public class UnknownDownloadItemModeException extends Exception | ||
4 | { | ||
5 | } \ No newline at end of file | ||
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index 24364b4..99a7ab3 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java | |||
@@ -5,6 +5,8 @@ package com.fourisland.instadisc; | |||
5 | 5 | ||
6 | import com.fourisland.instadisc.Database.Item; | 6 | import com.fourisland.instadisc.Database.Item; |
7 | import com.fourisland.instadisc.Database.Wrapper; | 7 | import com.fourisland.instadisc.Database.Wrapper; |
8 | import com.fourisland.instadisc.DownloadItem.ModeControl; | ||
9 | import com.fourisland.instadisc.DownloadItem.UnknownDownloadItemModeException; | ||
8 | import com.fourisland.instadisc.Item.Categories.InstaDiscIcon; | 10 | import com.fourisland.instadisc.Item.Categories.InstaDiscIcon; |
9 | import java.awt.AWTException; | 11 | import java.awt.AWTException; |
10 | import java.awt.SystemTray; | 12 | import java.awt.SystemTray; |
@@ -35,13 +37,14 @@ public class InstaDiscView extends FrameView { | |||
35 | 37 | ||
36 | public InstaDiscView(SingleFrameApplication app) { | 38 | public InstaDiscView(SingleFrameApplication app) { |
37 | super(app); | 39 | super(app); |
38 | 40 | ||
39 | initComponents(); | 41 | initComponents(); |
40 | 42 | ||
41 | // status bar initialization - message timeout, idle icon and busy animation, etc | 43 | // status bar initialization - message timeout, idle icon and busy animation, etc |
42 | ResourceMap resourceMap = getResourceMap(); | 44 | ResourceMap resourceMap = getResourceMap(); |
43 | int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"); | 45 | int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"); |
44 | messageTimer = new Timer(messageTimeout, new ActionListener() { | 46 | messageTimer = new Timer(messageTimeout, new ActionListener() |
47 | { | ||
45 | 48 | ||
46 | public void actionPerformed(ActionEvent e) { | 49 | public void actionPerformed(ActionEvent e) { |
47 | statusMessageLabel.setText(""); | 50 | statusMessageLabel.setText(""); |
@@ -49,10 +52,12 @@ public class InstaDiscView extends FrameView { | |||
49 | }); | 52 | }); |
50 | messageTimer.setRepeats(false); | 53 | messageTimer.setRepeats(false); |
51 | int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate"); | 54 | int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate"); |
52 | for (int i = 0; i < busyIcons.length; i++) { | 55 | for (int i = 0; i < busyIcons.length; i++) |
56 | { | ||
53 | busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]"); | 57 | busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]"); |
54 | } | 58 | } |
55 | busyIconTimer = new Timer(busyAnimationRate, new ActionListener() { | 59 | busyIconTimer = new Timer(busyAnimationRate, new ActionListener() |
60 | { | ||
56 | 61 | ||
57 | public void actionPerformed(ActionEvent e) { | 62 | public void actionPerformed(ActionEvent e) { |
58 | busyIconIndex = (busyIconIndex + 1) % busyIcons.length; | 63 | busyIconIndex = (busyIconIndex + 1) % busyIcons.length; |
@@ -65,28 +70,34 @@ public class InstaDiscView extends FrameView { | |||
65 | 70 | ||
66 | // connecting action tasks to status bar via TaskMonitor | 71 | // connecting action tasks to status bar via TaskMonitor |
67 | TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()); | 72 | TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()); |
68 | taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() { | 73 | taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() |
74 | { | ||
69 | 75 | ||
70 | public void propertyChange(java.beans.PropertyChangeEvent evt) { | 76 | public void propertyChange(java.beans.PropertyChangeEvent evt) { |
71 | String propertyName = evt.getPropertyName(); | 77 | String propertyName = evt.getPropertyName(); |
72 | if ("started".equals(propertyName)) { | 78 | if ("started".equals(propertyName)) |
73 | if (!busyIconTimer.isRunning()) { | 79 | { |
80 | if (!busyIconTimer.isRunning()) | ||
81 | { | ||
74 | statusAnimationLabel.setIcon(busyIcons[0]); | 82 | statusAnimationLabel.setIcon(busyIcons[0]); |
75 | busyIconIndex = 0; | 83 | busyIconIndex = 0; |
76 | busyIconTimer.start(); | 84 | busyIconTimer.start(); |
77 | } | 85 | } |
78 | progressBar.setVisible(true); | 86 | progressBar.setVisible(true); |
79 | progressBar.setIndeterminate(true); | 87 | progressBar.setIndeterminate(true); |
80 | } else if ("done".equals(propertyName)) { | 88 | } else if ("done".equals(propertyName)) |
89 | { | ||
81 | busyIconTimer.stop(); | 90 | busyIconTimer.stop(); |
82 | statusAnimationLabel.setIcon(idleIcon); | 91 | statusAnimationLabel.setIcon(idleIcon); |
83 | progressBar.setVisible(false); | 92 | progressBar.setVisible(false); |
84 | progressBar.setValue(0); | 93 | progressBar.setValue(0); |
85 | } else if ("message".equals(propertyName)) { | 94 | } else if ("message".equals(propertyName)) |
95 | { | ||
86 | String text = (String) (evt.getNewValue()); | 96 | String text = (String) (evt.getNewValue()); |
87 | statusMessageLabel.setText((text == null) ? "" : text); | 97 | statusMessageLabel.setText((text == null) ? "" : text); |
88 | messageTimer.restart(); | 98 | messageTimer.restart(); |
89 | } else if ("progress".equals(propertyName)) { | 99 | } else if ("progress".equals(propertyName)) |
100 | { | ||
90 | int value = (Integer) (evt.getNewValue()); | 101 | int value = (Integer) (evt.getNewValue()); |
91 | progressBar.setVisible(true); | 102 | progressBar.setVisible(true); |
92 | progressBar.setIndeterminate(false); | 103 | progressBar.setIndeterminate(false); |
@@ -97,12 +108,15 @@ public class InstaDiscView extends FrameView { | |||
97 | 108 | ||
98 | this.getFrame().setIconImage(new ImageIcon(InstaDiscIcon.instadiscicon).getImage()); | 109 | this.getFrame().setIconImage(new ImageIcon(InstaDiscIcon.instadiscicon).getImage()); |
99 | 110 | ||
100 | if (SystemTray.isSupported()) { | 111 | if (SystemTray.isSupported()) |
101 | try { | 112 | { |
113 | try | ||
114 | { | ||
102 | TrayIcon ti = new TrayIcon(new ImageIcon(InstaDiscIcon.instadisciconmiddle).getImage(), "InstaDisc"); | 115 | TrayIcon ti = new TrayIcon(new ImageIcon(InstaDiscIcon.instadisciconmiddle).getImage(), "InstaDisc"); |
103 | SystemTray.getSystemTray().add(ti); | 116 | SystemTray.getSystemTray().add(ti); |
104 | InstaDiscApp.ti = ti; | 117 | InstaDiscApp.ti = ti; |
105 | } catch (AWTException ex) { | 118 | } catch (AWTException ex) |
119 | { | ||
106 | Logger.getLogger(InstaDiscView.class.getName()).log(Level.SEVERE, null, ex); | 120 | Logger.getLogger(InstaDiscView.class.getName()).log(Level.SEVERE, null, ex); |
107 | } | 121 | } |
108 | } | 122 | } |
@@ -110,12 +124,15 @@ public class InstaDiscView extends FrameView { | |||
110 | jList1.setCellRenderer(new IDItemListCellRenderer()); | 124 | jList1.setCellRenderer(new IDItemListCellRenderer()); |
111 | refreshItemPane(); | 125 | refreshItemPane(); |
112 | 126 | ||
113 | InstaDiscThread idt = new InstaDiscThread(this); | 127 | try |
114 | Thread idtt = new Thread(idt); | 128 | { |
115 | idtt.start(); | 129 | ModeControl.INSTANCE.initalize(Wrapper.getConfig("downloadItemMode")); |
116 | 130 | } catch (UnknownDownloadItemModeException ex) | |
117 | XmlRpc xmlrpc = new XmlRpc("requestRetained"); | 131 | { |
118 | xmlrpc.execute(); | 132 | Logger.getLogger(InstaDiscView.class.getName()).log(Level.SEVERE, null, ex); |
133 | } | ||
134 | ModeControl.INSTANCE.modeInitalize(); | ||
135 | ModeControl.INSTANCE.requestRetained(); | ||
119 | 136 | ||
120 | updateTimer(); | 137 | updateTimer(); |
121 | } | 138 | } |
@@ -396,8 +413,7 @@ public class InstaDiscView extends FrameView { | |||
396 | }//GEN-LAST:event_jMenuItem3ActionPerformed | 413 | }//GEN-LAST:event_jMenuItem3ActionPerformed |
397 | 414 | ||
398 | private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed | 415 | private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed |
399 | XmlRpc xmlrpc = new XmlRpc("requestRetained"); | 416 | ModeControl.INSTANCE.requestRetained(); |
400 | xmlrpc.execute(); | ||
401 | }//GEN-LAST:event_jMenuItem4ActionPerformed | 417 | }//GEN-LAST:event_jMenuItem4ActionPerformed |
402 | 418 | ||
403 | private void jList1ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jList1ComponentShown | 419 | private void jList1ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jList1ComponentShown |
@@ -504,31 +520,20 @@ public class InstaDiscView extends FrameView { | |||
504 | } | 520 | } |
505 | 521 | ||
506 | public void updateTimer() { | 522 | public void updateTimer() { |
507 | int delay = (1000 * 60 * 60); | ||
508 | |||
509 | try { | 523 | try { |
510 | ipCheckTimer.stop(); | 524 | ipCheckTimer.stop(); |
511 | } catch (NullPointerException ex) { | 525 | } catch (NullPointerException ex) { |
512 | |||
513 | } | ||
514 | |||
515 | if (Wrapper.getConfig("ipCheckUnit").equals("day")) { | ||
516 | delay *= (24 * Integer.decode(Wrapper.getConfig("ipCheckValue"))); | ||
517 | } else if (Wrapper.getConfig("ipCheckUnit").equals("hour")) { | ||
518 | delay *= Integer.decode(Wrapper.getConfig("ipCheckValue")); | ||
519 | } | 526 | } |
520 | 527 | ||
521 | ipCheckTimer = new Timer(delay, new ActionListener() { | 528 | ipCheckTimer = new Timer(ModeControl.INSTANCE.setTimer(), new ActionListener() { |
522 | public void actionPerformed(ActionEvent arg0) { | 529 | public void actionPerformed(ActionEvent arg0) { |
523 | XmlRpc xmlrpc = new XmlRpc("checkRegistration"); | 530 | ModeControl.INSTANCE.timerTick(); |
524 | xmlrpc.execute(); | ||
525 | } | 531 | } |
526 | }); | 532 | }); |
527 | 533 | ||
528 | ipCheckTimer.start(); | 534 | ipCheckTimer.start(); |
529 | 535 | ||
530 | XmlRpc xmlrpc = new XmlRpc("checkRegistration"); | 536 | ModeControl.INSTANCE.timerTick(); |
531 | xmlrpc.execute(); | ||
532 | } | 537 | } |
533 | 538 | ||
534 | public synchronized void startProgress() | 539 | public synchronized void startProgress() |