Rev 280 | Rev 289 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 280 | Rev 285 | ||
---|---|---|---|
1 | /*********************************************************************** |
1 | /*********************************************************************** |
2 | * |
2 | * |
3 | * DUBwise == Digital UFO Broadcasting with intelligent service equipment |
3 | * DUBwise == Digital UFO Broadcasting with intelligent service equipment |
4 | * main MIDLet Source file |
4 | * main MIDLet Source file |
5 | * |
5 | * |
6 | * Author: Marcus -LiGi- Bueschleb |
6 | * Author: Marcus -LiGi- Bueschleb |
7 | * Mailto: LiGi @at@ LiGi DOTT de |
7 | * Mailto: LiGi @at@ LiGi DOTT de |
8 | * |
8 | * |
9 | ************************************************************************/ |
9 | ************************************************************************/ |
10 | 10 | ||
11 | 11 | ||
12 | import javax.microedition.lcdui.*; |
12 | import javax.microedition.lcdui.*; |
13 | import javax.microedition.midlet.*; |
13 | import javax.microedition.midlet.*; |
14 | 14 | ||
15 | public class DUBwiseInstaller |
15 | public class DUBwiseInstaller |
16 | extends MIDlet |
16 | extends MIDlet |
17 | implements Runnable,CommandListener |
17 | implements Runnable,CommandListener |
18 | { |
18 | { |
19 | public Display display; |
19 | public Display display; |
20 | public DUBwiseInstallerCanvas canvas; |
20 | public DUBwiseInstallerCanvas canvas; |
21 | public boolean loaded=false; |
21 | public boolean loaded=false; |
22 | 22 | ||
23 | 23 | ||
24 | String browser_dest=""; |
24 | String browser_dest=""; |
25 | - | ||
26 | protected void startApp() |
- | |
27 | throws MIDletStateChangeException |
- | |
28 | { |
- | |
29 | - | ||
30 | if (loaded)return; |
- | |
31 | display = Display.getDisplay(this); |
- | |
32 | canvas=new DUBwiseInstallerCanvas(this); |
- | |
33 | - | ||
34 | // fire up canvas |
- | |
35 | display.setCurrent(canvas); |
- | |
36 | } |
- | |
37 | 25 | ||
38 | 26 | ||
39 | public int[][] res_vals = { {480,640},{340,400},{240,320},{200,300},{176,220},{128,128} }; |
27 | public int[][] res_vals = { {480,640},{340,400},{240,320},{200,300},{176,220},{128,128} }; |
40 | public String[] res_strings; |
28 | public String[] res_strings; |
41 | 29 | ||
42 | public String[] feature_strings={"Bluetooth","Location API","File Connection","Device Control","Fullscreen","cldc11"}; |
30 | public String[] feature_strings={"Bluetooth","Location API","File Connection","Device Control","Fullscreen","cldc11"}; |
43 | 31 | ||
44 | public String[] sound_strings={"en_speedy","en_wav","de_tts","de_wav","de_64kbit_tts","wav","no_voice"}; |
32 | public String[] sound_strings={"en_speedy","en_wav","de_tts","de_wav","de_64kbit_tts","wav","no_voice"}; |
- | 33 | public String[] firmware_strings={"No Firmwars","All Firmwares","FC&MK3MAF Firmwares"}; |
|
45 | public String[] firmware_strings={"all_firmwares","fc_mk3mag_firmwares","no_firmwares"}; |
34 | public String[] firmware_clean_strings={"no_firmwares","all_firmwares","fc_mk3mag_firmwares"}; |
46 | 35 | ||
47 | public String[] installmethod_strings={"online Install","show Filename"};//,"email URL"}; |
36 | public String[] installmethod_strings={"online Install","show Filename"};//,"email URL"}; |
48 | 37 | ||
49 | public String[] installsrc_strings={"stable (latest tag)","Bleeding Edge (trunk)"}; |
38 | public String[] installsrc_strings={"stable (latest tag)","Bleeding Edge (trunk)"}; |
50 | public String[] installsrc_clean_strings={"tags","trunk"}; |
39 | public String[] installsrc_clean_strings={"tags","trunk"}; |
51 | 40 | ||
52 | public int res_select=-1; |
41 | public int res_select=-1; |
53 | public int sound_select=0; |
42 | public int sound_select=0; |
54 | public int firmware_select=0; |
43 | public int firmware_select=0; |
55 | public int installsrc_select=0; |
44 | public int installsrc_select=0; |
56 | 45 | ||
- | 46 | ||
- | 47 | String helper_url=null; |
|
- | 48 | String download_url=null; |
|
- | 49 | ||
- | 50 | boolean http_possible; |
|
- | 51 | ||
- | 52 | ||
- | 53 | ChoiceGroup res_choice; |
|
- | 54 | ChoiceGroup features_choice; |
|
- | 55 | ChoiceGroup sound_choice; |
|
- | 56 | ChoiceGroup installmethod_choice; |
|
- | 57 | ChoiceGroup installsrc_choice; |
|
- | 58 | ChoiceGroup firmware_choice; |
|
- | 59 | ||
- | 60 | ||
- | 61 | protected void startApp() |
|
- | 62 | throws MIDletStateChangeException |
|
- | 63 | { |
|
- | 64 | ||
- | 65 | if (loaded)return; |
|
- | 66 | display = Display.getDisplay(this); |
|
- | 67 | canvas=new DUBwiseInstallerCanvas(this); |
|
- | 68 | ||
- | 69 | // fire up canvas |
|
- | 70 | display.setCurrent(canvas); |
|
- | 71 | } |
|
- | 72 | ||
57 | 73 | ||
58 | public String installsrc_str() |
74 | public String installsrc_str() |
59 | { |
75 | { |
60 | return installsrc_clean_strings[installsrc_select]; |
76 | return installsrc_clean_strings[installsrc_select]; |
61 | } |
77 | } |
62 | 78 | ||
63 | public String cldc_str() |
79 | public String cldc_str() |
64 | { |
80 | { |
65 | if (canvas.cldc11) |
81 | if (canvas.cldc11) |
66 | return "-CLDC11"; |
82 | return "-CLDC11"; |
67 | else |
83 | else |
68 | return ""; |
84 | return ""; |
69 | } |
85 | } |
70 | 86 | ||
71 | public String bt_str() |
87 | public String bt_str() |
72 | { |
88 | { |
73 | if (canvas.bluetooth) |
89 | if (canvas.bluetooth) |
74 | return "-BluetoothAPI"; |
90 | return "-BluetoothAPI"; |
75 | else |
91 | else |
76 | return ""; |
92 | return ""; |
77 | } |
93 | } |
78 | 94 | ||
79 | public String fileapi_str() |
95 | public String fileapi_str() |
80 | { |
96 | { |
81 | if (canvas.fileapi) |
97 | if (canvas.fileapi) |
82 | return "-FileAPI"; |
98 | return "-FileAPI"; |
83 | else |
99 | else |
84 | return ""; |
100 | return ""; |
85 | } |
101 | } |
86 | 102 | ||
87 | 103 | ||
88 | public String firmware_str() |
104 | public String firmware_str() |
89 | { |
105 | { |
90 | return firmware_strings[firmware_select]; |
106 | return firmware_clean_strings[firmware_select]; |
91 | } |
107 | } |
92 | 108 | ||
93 | public String devicecontrol_str() |
109 | public String devicecontrol_str() |
94 | { |
110 | { |
95 | if (canvas.devicecontrol) |
111 | if (canvas.devicecontrol) |
96 | return "-DeviceControl"; |
112 | return "-DeviceControl"; |
97 | else |
113 | else |
98 | return ""; |
114 | return ""; |
99 | } |
115 | } |
100 | 116 | ||
101 | public String sound_str() |
117 | public String sound_str() |
102 | { |
118 | { |
103 | return sound_strings[sound_select]; |
119 | return sound_strings[sound_select]; |
104 | } |
120 | } |
105 | 121 | ||
106 | 122 | ||
107 | public String getURL() |
123 | public String getURL() |
108 | { |
124 | { |
109 | return download_url+installsrc_str()+"/"+getFileName(); |
125 | return download_url+installsrc_str()+"/"+getFileName(); |
110 | } |
126 | } |
111 | 127 | ||
112 | public String getFileName() |
128 | public String getFileName() |
113 | { |
129 | { |
114 | return "DUBwise-"+res_str()+"-" + sound_str() + "-" + firmware_str() + cldc_str() + fileapi_str() + bt_str() + devicecontrol_str() +".jad"; |
130 | return "DUBwise-"+res_str()+"-" + sound_str() + "-" + firmware_str() + cldc_str() + fileapi_str() + bt_str() + devicecontrol_str() +".jad"; |
115 | } |
131 | } |
116 | 132 | ||
117 | public boolean url_check() |
133 | public boolean url_check() |
118 | { |
134 | { |
119 | return (!InstallHelper.get_http_string(getURL()).equals("err")); |
135 | return (!InstallHelper.get_http_string(getURL()).equals("err")); |
120 | } |
136 | } |
121 | 137 | ||
122 | public String res_str() |
138 | public String res_str() |
123 | { |
139 | { |
124 | try |
140 | try |
125 | { |
141 | { |
126 | return res_strings[res_select]; |
142 | return res_strings[res_select]; |
127 | } |
143 | } |
128 | catch(Exception e) |
144 | catch(Exception e) |
129 | { |
145 | { |
130 | return res_strings[0]; |
146 | return res_strings[0]; |
131 | } |
147 | } |
132 | } |
148 | } |
133 | - | ||
134 | String helper_url=null; |
- | |
135 | String download_url=null; |
- | |
136 | - | ||
137 | boolean http_possible; |
149 | |
138 | 150 | ||
139 | public void run() |
151 | public void run() |
140 | { |
152 | { |
141 | 153 | ||
142 | helper_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/helper_url") ; |
154 | helper_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/helper_url") ; |
143 | 155 | ||
144 | http_possible=((!helper_url.equals("err"))); |
156 | http_possible=((!helper_url.equals("err"))); |
145 | 157 | ||
146 | 158 | ||
147 | download_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/download_url") ; |
159 | download_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/download_url") ; |
148 | 160 | ||
149 | if ((download_url==null) || (!download_url.startsWith("http"))) |
161 | if ((download_url==null) || (!download_url.startsWith("http"))) |
150 | download_url=helper_url+"dl/"; |
162 | download_url=helper_url+"dl/"; |
151 | 163 | ||
152 | if (http_possible) System.out.println(InstallHelper.get_http_string(helper_url+"mail?subject=DUBwiseInstall&text="+InstallHelper.urlEncode( description_str() + "\nDownload OK:" + url_check()+"\n" ))); |
164 | if (http_possible) System.out.println(InstallHelper.get_http_string(helper_url+"mail?subject=DUBwiseInstall&text="+InstallHelper.urlEncode( description_str() + "\nDownload OK:" + url_check()+"\n" ))); |
153 | 165 | ||
154 | try |
166 | try |
155 | { |
167 | { |
156 | Thread.sleep(500); |
168 | Thread.sleep(500); |
157 | platformRequest(getURL()); |
169 | platformRequest(getURL()); |
158 | } |
170 | } |
159 | catch ( Exception e) {} |
171 | catch ( Exception e) {} |
160 | 172 | ||
161 | notifyDestroyed(); |
173 | notifyDestroyed(); |
162 | 174 | ||
163 | } |
175 | } |
164 | 176 | ||
165 | 177 | ||
166 | public String description_str() |
178 | public String description_str() |
167 | { |
179 | { |
168 | return |
180 | return |
169 | "Screenwidth:" + canvas.canvas_width + "\n" |
181 | "Screenwidth:" + canvas.canvas_width + "\n" |
170 | +"Screenheight:" + canvas.canvas_height + "\n" |
182 | +"Screenheight:" + canvas.canvas_height + "\n" |
171 | +"Screenwidth FS:" + canvas.canvas_full_width + "\n" |
183 | +"Screenwidth FS:" + canvas.canvas_full_width + "\n" |
172 | +"Screenheight FS:" + canvas.canvas_full_height + "\n" |
184 | +"Screenheight FS:" + canvas.canvas_full_height + "\n" |
173 | +"CLDC1.1:" + canvas.cldc11 + "\n" |
185 | +"CLDC1.1:" + canvas.cldc11 + "\n" |
174 | +"JSR-82:" + canvas.bluetooth + "\n" |
186 | +"JSR-82:" + canvas.bluetooth + "\n" |
175 | +"JSR-179:" + canvas.locationprovider + "\n" |
187 | +"JSR-179:" + canvas.locationprovider + "\n" |
176 | +"FileConn:" + canvas.fileapi + "\n" |
188 | +"FileConn:" + canvas.fileapi + "\n" |
177 | +"DeviceControl:" + canvas.devicecontrol + "\n" |
189 | +"DeviceControl:" + canvas.devicecontrol + "\n" |
178 | +"comports:" + canvas.comports + "\n" |
190 | +"comports:" + canvas.comports + "\n" |
179 | +"Download URL:" + getURL() + "\n" |
191 | +"Download URL:" + getURL() + "\n" |
180 | +canvas.props; |
192 | +canvas.props; |
181 | 193 | ||
182 | } |
194 | } |
183 | - | ||
184 | ChoiceGroup res_choice; |
- | |
185 | ChoiceGroup features_choice; |
- | |
186 | ChoiceGroup sound_choice; |
- | |
187 | ChoiceGroup installmethod_choice; |
- | |
- | 195 | ||
188 | ChoiceGroup installsrc_choice; |
196 | |
189 | 197 | ||
190 | public void quit() { |
198 | public void quit() { |
191 | 199 | ||
192 | try |
200 | try |
193 | { |
201 | { |
194 | res_strings=new String[res_vals.length]; |
202 | res_strings=new String[res_vals.length]; |
195 | for (int i=0;i<res_vals.length;i++) |
203 | for (int i=0;i<res_vals.length;i++) |
196 | { |
204 | { |
197 | if ((canvas.canvas_width>=res_vals[i][0])&&(res_select==-1)) |
205 | if ((canvas.canvas_width>=res_vals[i][0])&&(res_select==-1)) |
198 | res_select=i; |
206 | res_select=i; |
199 | res_strings[i]=res_vals[i][0]+"x"+res_vals[i][1]; |
207 | res_strings[i]=res_vals[i][0]+"x"+res_vals[i][1]; |
200 | } |
208 | } |
201 | } |
209 | } |
202 | catch(Exception e) |
210 | catch(Exception e) |
203 | { |
211 | { |
204 | res_strings=new String[0]; |
212 | res_strings=new String[0]; |
205 | } |
213 | } |
206 | 214 | ||
207 | if (res_select==-1) res_select=0; |
215 | if (res_select==-1) res_select=0; |
208 | show_edit_form(); |
216 | show_edit_form(); |
209 | 217 | ||
210 | } |
218 | } |
211 | 219 | ||
212 | 220 | ||
213 | public void show_edit_form() |
221 | public void show_edit_form() |
214 | { |
222 | { |
215 | Form form = new Form("Install DUBwise"); |
223 | Form form = new Form("Install DUBwise"); |
216 | 224 | ||
217 | installsrc_choice = new ChoiceGroup( |
225 | installsrc_choice = new ChoiceGroup( |
218 | "Install Source", |
226 | "Install Source", |
219 | Choice.EXCLUSIVE, |
227 | Choice.EXCLUSIVE, |
220 | installsrc_strings, |
228 | installsrc_strings, |
221 | null); |
229 | null); |
222 | 230 | ||
223 | installsrc_choice.setSelectedIndex(installsrc_select,true); |
231 | installsrc_choice.setSelectedIndex(installsrc_select,true); |
224 | form.append(installsrc_choice); |
232 | form.append(installsrc_choice); |
225 | 233 | ||
226 | installmethod_choice = new ChoiceGroup( |
234 | installmethod_choice = new ChoiceGroup( |
227 | "Install Method", |
235 | "Install Method", |
228 | Choice.EXCLUSIVE, |
236 | Choice.EXCLUSIVE, |
229 | installmethod_strings, |
237 | installmethod_strings, |
230 | null); |
238 | null); |
231 | 239 | ||
232 | form.append(installmethod_choice); |
240 | form.append(installmethod_choice); |
233 | 241 | ||
234 | res_choice = new ChoiceGroup( |
242 | res_choice = new ChoiceGroup( |
235 | "Resolution (Real " +canvas.canvas_full_width + "x"+ canvas.canvas_full_height+")", |
243 | "Resolution (Real " +canvas.canvas_full_width + "x"+ canvas.canvas_full_height+")", |
236 | Choice.EXCLUSIVE, |
244 | Choice.EXCLUSIVE, |
237 | res_strings, |
245 | res_strings, |
238 | null); |
246 | null); |
239 | 247 | ||
240 | res_choice.setSelectedIndex(res_select,true); |
248 | res_choice.setSelectedIndex(res_select,true); |
241 | form.append(res_choice); |
249 | form.append(res_choice); |
- | 250 | ||
242 | 251 | ||
243 | features_choice = new ChoiceGroup( |
252 | features_choice = new ChoiceGroup( |
244 | "Features ", |
253 | "Features ", |
245 | Choice.MULTIPLE, |
254 | Choice.MULTIPLE, |
246 | feature_strings, |
255 | feature_strings, |
247 | null); |
256 | null); |
248 | 257 | ||
249 | 258 | ||
250 | features_choice.setSelectedIndex(0,canvas.bluetooth); |
259 | features_choice.setSelectedIndex(0,canvas.bluetooth); |
251 | features_choice.setSelectedIndex(1,canvas.locationprovider); |
260 | features_choice.setSelectedIndex(1,canvas.locationprovider); |
252 | features_choice.setSelectedIndex(2,canvas.fileapi); |
261 | features_choice.setSelectedIndex(2,canvas.fileapi); |
253 | features_choice.setSelectedIndex(3,canvas.devicecontrol); |
262 | features_choice.setSelectedIndex(3,canvas.devicecontrol); |
254 | features_choice.setSelectedIndex(4,canvas.fullscreen); |
263 | features_choice.setSelectedIndex(4,canvas.fullscreen); |
255 | features_choice.setSelectedIndex(5,canvas.cldc11); |
264 | features_choice.setSelectedIndex(5,canvas.cldc11); |
256 | form.append(features_choice); |
265 | form.append(features_choice); |
- | 266 | ||
- | 267 | ||
- | 268 | ||
- | 269 | firmware_choice = new ChoiceGroup( |
|
- | 270 | "Firmwares:", |
|
- | 271 | Choice.EXCLUSIVE, |
|
- | 272 | firmware_strings, |
|
- | 273 | null); |
|
- | 274 | ||
- | 275 | firmware_choice.setSelectedIndex(firmware_select,true); |
|
- | 276 | form.append(firmware_choice); |
|
- | 277 | ||
257 | 278 | ||
258 | sound_choice = new ChoiceGroup( |
279 | sound_choice = new ChoiceGroup( |
259 | "Sound ", |
280 | "Sound ", |
260 | Choice.EXCLUSIVE, |
281 | Choice.EXCLUSIVE, |
261 | sound_strings, |
282 | sound_strings, |
262 | null); |
283 | null); |
263 | 284 | ||
264 | sound_choice.setSelectedIndex(sound_select,true); |
285 | sound_choice.setSelectedIndex(sound_select,true); |
265 | form.append(sound_choice); |
286 | form.append(sound_choice); |
266 | 287 | ||
267 | form.addCommand(new Command("OK", Command.OK, 1)); |
288 | form.addCommand(new Command("OK", Command.OK, 1)); |
268 | form.addCommand(new Command("Exit", Command.EXIT, 2)); |
289 | form.addCommand(new Command("Exit", Command.EXIT, 2)); |
269 | 290 | ||
270 | // set itself as the command listener |
291 | // set itself as the command listener |
271 | form.setCommandListener(this); |
292 | form.setCommandListener(this); |
272 | display.setCurrent(form); |
293 | display.setCurrent(form); |
273 | 294 | ||
274 | 295 | ||
275 | } |
296 | } |
276 | 297 | ||
277 | public void show_url_form() |
298 | public void show_url_form() |
278 | { |
299 | { |
279 | 300 | ||
280 | Form url_form = new Form("FileName"); |
301 | Form url_form = new Form("FileName"); |
281 | TextField txtField = new TextField( |
302 | TextField txtField = new TextField( |
282 | "FileName", getFileName() , 250, TextField.ANY); |
303 | "FileName", getFileName() , 250, TextField.ANY); |
283 | url_form.append(txtField); |
304 | url_form.append(txtField); |
284 | url_form.setCommandListener(this); |
305 | url_form.setCommandListener(this); |
285 | url_form.addCommand(new Command("Back", Command.OK, 2)); |
306 | url_form.addCommand(new Command("Back", Command.OK, 2)); |
286 | display.setCurrent(url_form); |
307 | display.setCurrent(url_form); |
287 | } |
308 | } |
288 | 309 | ||
289 | public void process_edit_form() |
310 | public void process_edit_form() |
290 | { |
311 | { |
291 | res_select=res_choice.getSelectedIndex(); |
312 | res_select=res_choice.getSelectedIndex(); |
- | 313 | firmware_select=firmware_choice.getSelectedIndex(); |
|
292 | sound_select=sound_choice.getSelectedIndex(); |
314 | sound_select=sound_choice.getSelectedIndex(); |
293 | installsrc_select= installsrc_choice.getSelectedIndex(); |
315 | installsrc_select= installsrc_choice.getSelectedIndex(); |
294 | 316 | ||
295 | canvas.bluetooth= features_choice.isSelected(0); |
317 | canvas.bluetooth= features_choice.isSelected(0); |
296 | canvas.locationprovider=features_choice.isSelected(1); |
318 | canvas.locationprovider=features_choice.isSelected(1); |
297 | canvas.fileapi= features_choice.isSelected(2); |
319 | canvas.fileapi= features_choice.isSelected(2); |
298 | canvas.devicecontrol= features_choice.isSelected(3); |
320 | canvas.devicecontrol= features_choice.isSelected(3); |
299 | canvas.fullscreen= features_choice.isSelected(4); |
321 | canvas.fullscreen= features_choice.isSelected(4); |
300 | canvas.cldc11 = features_choice.isSelected(5); |
322 | canvas.cldc11 = features_choice.isSelected(5); |
301 | 323 | ||
302 | 324 | ||
303 | 325 | ||
304 | switch (installmethod_choice.getSelectedIndex()) |
326 | switch (installmethod_choice.getSelectedIndex()) |
305 | { |
327 | { |
306 | case 0: |
328 | case 0: |
307 | // browser_dest= getURL(); |
329 | // browser_dest= getURL(); |
308 | new Thread(this).start(); |
330 | new Thread(this).start(); |
309 | break; |
331 | break; |
310 | 332 | ||
311 | case 1: |
333 | case 1: |
312 | show_url_form(); |
334 | show_url_form(); |
313 | break; |
335 | break; |
314 | } |
336 | } |
315 | 337 | ||
316 | 338 | ||
317 | } |
339 | } |
318 | 340 | ||
319 | public void commandAction( Command com, Displayable dis) |
341 | public void commandAction( Command com, Displayable dis) |
320 | { |
342 | { |
321 | 343 | ||
322 | String label = com.getLabel(); |
344 | String label = com.getLabel(); |
323 | 345 | ||
324 | if("Exit".equals(label)) |
346 | if("Exit".equals(label)) |
325 | notifyDestroyed(); |
347 | notifyDestroyed(); |
326 | else if("OK".equals(label)) |
348 | else if("OK".equals(label)) |
327 | process_edit_form(); |
349 | process_edit_form(); |
328 | else if("Back".equals(label)) |
350 | else if("Back".equals(label)) |
329 | show_edit_form(); |
351 | show_edit_form(); |
330 | } |
352 | } |
331 | 353 | ||
332 | 354 | ||
333 | 355 | ||
334 | protected void pauseApp() {} // not needed right now |
356 | protected void pauseApp() {} // not needed right now |
335 | protected void destroyApp(boolean arg0) { } |
357 | protected void destroyApp(boolean arg0) { } |
336 | 358 | ||
337 | 359 | ||
338 | 360 | ||
339 | 361 | ||
340 | } |
362 | } |
341 | 363 |