Subversion Repositories Projects

Rev

Rev 290 | Rev 316 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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