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