Subversion Repositories Projects

Rev

Rev 316 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 316 Rev 531
Line 10... Line 10...
10
 
10
 
11
 
11
 
Line 12... Line -...
12
import javax.microedition.lcdui.*;
-
 
-
 
12
import javax.microedition.lcdui.*;
Line 13... Line 13...
13
import javax.microedition.midlet.*;
13
import javax.microedition.midlet.*;
14
 
14
 
15
import javax.microedition.rms.*;
15
 
16
 
16
 
-
 
17
public class DUBwiseInstaller
-
 
18
    extends MIDlet
-
 
19
    implements Runnable,CommandListener
-
 
20
{
-
 
21
 
-
 
22
 
-
 
23
    public String[] installmethod_strings={"online Install","show Filename"};//,"email URL"};
-
 
24
    public String[] installoption_strings={"default","full featured","minimal","custom","expert"};
-
 
25
 
-
 
26
    public final static byte INSTALLOPTIONID_DEFAULT=0;
-
 
27
    public final static byte INSTALLOPTIONID_FULL=1;
-
 
28
    public final static byte INSTALLOPTIONID_MINIMAL=2;
-
 
29
    public final static byte INSTALLOPTIONID_CUSTOM=3;
-
 
30
    public final static byte INSTALLOPTIONID_EXPERT=4;
17
public class DUBwiseInstaller
31
 
18
    extends MIDlet
32
    public final static byte INSTALLMETHODID_ONLINE=0;
19
    implements Runnable,CommandListener
33
    public final static byte INSTALLMETHODID_SHOWURL=1;
-
 
34
 
-
 
35
    public Display display;
Line 20... Line 36...
20
{
36
    public  DUBwiseInstallerCanvas canvas;
Line 21... Line 37...
21
    public Display display;
37
    private DUBwiseProps props;
22
    public  DUBwiseInstallerCanvas canvas;
38
 
Line 23... Line 39...
23
    public boolean loaded=false;
39
    public boolean app_running=false;  // to prevent 2 instances
Line 24... Line -...
24
 
-
 
25
 
-
 
26
    String browser_dest="";
-
 
Line 27... Line 40...
27
 
40
 
-
 
41
 
Line 28... Line -...
28
 
-
 
29
    public int[][] res_vals = { {480,640},{340,400},{240,320},{200,300},{176,220},{128,128} };
-
 
Line 30... Line -...
30
    public String[] res_strings;
-
 
31
 
-
 
32
    public String[] feature_strings={"Bluetooth","Location API","File Connection","Device Control","Fullscreen","cldc11"};
42
    String browser_dest="";
33
 
43
 
Line -... Line 44...
-
 
44
 
-
 
45
    String helper_url=null;
Line 34... Line -...
34
    public String[] sound_strings={"en_speedy","en_wav","de_tts","de_wav","de_64kbit_tts","wav","no_voice"};
-
 
35
    public String[] firmware_strings={"No Firmwars","All Firmwares","FC&MK3MAF Firmwares"};
46
    String download_url=null;
Line 36... Line -...
36
    public String[] firmware_clean_strings={"no_firmwares","all_firmwares","fc_mk3mag_firmwares"};
-
 
Line -... Line 47...
-
 
47
 
Line 37... Line 48...
37
 
48
    boolean http_possible;
38
    public String[] installmethod_strings={"online Install","show Filename"};//,"email URL"};
49
 
39
 
-
 
40
    public String[] installsrc_strings={"stable (latest tag)","Bleeding Edge (trunk)"};
-
 
41
    public String[] installsrc_clean_strings={"tags","trunk"};
50
 
42
 
-
 
-
 
51
    Form installoptions_form;
Line 43... Line 52...
43
    public int res_select=-1;
52
    Form install_form;
44
    public int sound_select=0;
53
 
45
    public int firmware_select=0;
54
 
Line 46... Line 55...
46
    public int installsrc_select=0;
55
    ChoiceGroup installmethod_choice;
47
   
56
    ChoiceGroup installoption_choice;
48
 
57
 
Line 49... Line 58...
49
    String helper_url=null;
58
    ChoiceGroup sound_choice;
50
    String download_url=null;
59
    ChoiceGroup firmware_choice;
51
 
60
 
Line 52... Line -...
52
    boolean http_possible;
-
 
53
 
-
 
54
 
-
 
55
    ChoiceGroup res_choice;
-
 
Line 56... Line -...
56
    ChoiceGroup features_choice;
-
 
57
    ChoiceGroup sound_choice;
-
 
58
    ChoiceGroup installmethod_choice;
-
 
59
    ChoiceGroup installsrc_choice;
-
 
60
    ChoiceGroup firmware_choice;
-
 
61
 
-
 
62
 
-
 
Line 63... Line 61...
63
    protected void startApp()
61
    ChoiceGroup optional_features_choice;
64
        throws MIDletStateChangeException
62
 
65
    {
-
 
66
 
63
 
67
       if (loaded)return;
-
 
68
       display  = Display.getDisplay(this);
-
 
69
       canvas=new  DUBwiseInstallerCanvas(this);
64
    Form expert_form;
Line 70... Line 65...
70
 
65
 
71
       // fire up canvas
66
    ChoiceGroup res_choice;
72
       display.setCurrent(canvas);
-
 
73
    }
67
    ChoiceGroup device_features_choice;
74
 
-
 
75
 
-
 
76
    public String installsrc_str()
68
    ChoiceGroup installsrc_choice;
-
 
69
 
-
 
70
 
-
 
71
 
-
 
72
    protected void startApp()
-
 
73
        throws MIDletStateChangeException
-
 
74
    {
Line -... Line 75...
-
 
75
 
-
 
76
       if (app_running)return;
Line 77... Line -...
77
    {
-
 
78
        return installsrc_clean_strings[installsrc_select];
-
 
79
    }
77
       display  = Display.getDisplay(this);
80
 
-
 
Line 81... Line 78...
81
    public String cldc_str()
78
       canvas=new  DUBwiseInstallerCanvas(this);
82
    {
79
 
83
        if (canvas.cldc11)
80
       // fire up canvas
84
             return "-CLDC11";
81
       display.setCurrent(canvas);
85
        else
-
 
86
             return "";
-
 
87
    }
82
    }
-
 
83
 
-
 
84
 
-
 
85
 
Line 88... Line -...
88
 
-
 
89
    public String bt_str()
-
 
90
    {
-
 
91
        if (canvas.bluetooth)
86
 
Line 92... Line -...
92
             return "-BluetoothAPI";
-
 
93
        else
-
 
94
             return "";
-
 
95
    }
-
 
Line 96... Line -...
96
 
-
 
97
    public String fileapi_str()
-
 
98
    {
-
 
99
        if (canvas.fileapi)
-
 
Line 100... Line -...
100
             return "-FileAPI";
-
 
101
        else
-
 
102
             return "";
-
 
103
    }
-
 
Line 104... Line -...
104
 
-
 
105
 
-
 
106
    public String firmware_str()
87
    public String getURL()
107
    {
-
 
108
        return firmware_clean_strings[firmware_select];
88
    {
109
    }
-
 
110
 
-
 
111
    public String devicecontrol_str()
89
            return download_url+props.installsrc_str()+"/"+props.getFileName();
112
    {
-
 
113
        if (canvas.devicecontrol)
-
 
114
             return "-DeviceControl";
-
 
Line -... Line 90...
-
 
90
    }
-
 
91
 
Line 115... Line -...
115
        else
-
 
116
             return "";
-
 
Line -... Line 92...
-
 
92
    public boolean url_check()
117
    }
93
    {
-
 
94
        return (InstallHelper.get_http_string(getURL()).startsWith("MIDlet-Jar-URL:"));
-
 
95
    }
-
 
96
    // fire up browser for online install
Line 118... Line -...
118
 
-
 
Line 119... Line 97...
119
    public String sound_str()
97
    public void run()
Line -... Line 98...
-
 
98
    {
120
    {
99
        helper_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/helper_url") ;
121
        return sound_strings[sound_select];
100
        http_possible=((!helper_url.equals("err")));
Line 122... Line -...
122
    }
-
 
Line 123... Line -...
123
 
-
 
124
 
-
 
125
    public String getURL()
101
        download_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/installer_meta/dl_url") ;
126
    {
-
 
127
            return download_url+installsrc_str()+"/"+getFileName();
-
 
128
    }
-
 
Line -... Line 102...
-
 
102
       
-
 
103
        if ((download_url==null) || (!download_url.startsWith("http")))
-
 
104
            download_url=helper_url+"dl/";
129
 
105
 
-
 
106
        if (http_possible) System.out.println(InstallHelper.get_http_string(helper_url+"mail?subject=DUBwiseInstall&text="+InstallHelper.urlEncode( "Installer Version: 0.8 \nDownload URL:" + getURL() + "\nDownload OK:" + url_check()+ "\nInstall Options:" + installoption_strings[installoption_choice.getSelectedIndex()] + "\n\n------Device Infos---\n" + canvas.description_str() +"\n"  )));
Line -... Line 107...
-
 
107
 
130
    public String getFileName()
108
        try
Line -... Line 109...
-
 
109
            {
-
 
110
                Thread.sleep(500);
-
 
111
                platformRequest(getURL());
131
    {
112
            }
132
        return "DUBwise-"+res_str()+"-" + sound_str() + "-"  + firmware_str() + cldc_str() + fileapi_str() + bt_str() + devicecontrol_str() +".jad";
113
        catch ( Exception e) {}
Line 133... Line -...
133
    }
-
 
134
 
-
 
135
    public boolean url_check()
-
 
136
    {
-
 
137
        return (!InstallHelper.get_http_string(getURL()).equals("err"));
-
 
138
    }
-
 
139
 
-
 
140
    public String res_str()
-
 
141
    {
-
 
142
        try
-
 
143
            {
-
 
144
                return  res_strings[res_select];
-
 
145
            }
-
 
146
        catch(Exception e)
-
 
147
            {
-
 
148
                return  res_strings[0];
-
 
149
            }
-
 
150
    }
-
 
151
 
-
 
152
 
-
 
153
    public void run()
-
 
154
    {
-
 
155
 
-
 
156
        helper_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/helper_url") ;
-
 
157
 
-
 
Line 158... Line -...
158
        http_possible=((!helper_url.equals("err")));
-
 
-
 
114
       
-
 
115
        notifyDestroyed(); //quit
-
 
116
 
-
 
117
    }
-
 
118
   
Line -... Line 119...
-
 
119
 
Line 159... Line -...
159
 
-
 
Line 160... Line -...
160
       
-
 
161
        download_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/download_url") ;
-
 
162
       
-
 
163
        if ((download_url==null) || (!download_url.startsWith("http")))
-
 
164
            download_url=helper_url+"dl/";
-
 
165
 
-
 
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" )));
-
 
167
 
-
 
168
        try
-
 
169
            {
-
 
170
                Thread.sleep(500);
-
 
171
                platformRequest(getURL());
-
 
172
            }
-
 
173
        catch ( Exception e) {}
-
 
Line 174... Line -...
174
       
-
 
175
        notifyDestroyed();
-
 
Line -... Line 120...
-
 
120
 
176
 
121
 
Line 177... Line -...
177
    }
-
 
178
   
-
 
179
 
-
 
Line -... Line 122...
-
 
122
 
-
 
123
 
-
 
124
    public void canvas_hw_detect_finish()
180
    public String description_str()
125
    {
181
    {
126
 
182
 
127
        props=new DUBwiseProps();
183
        int rms_avail=0;
128
        props.set_res_by_screensize(canvas.canvas_width,canvas.canvas_height);
184
        try {
129
 
Line 185... Line -...
185
            RecordStore recStore = RecordStore.openRecordStore("test", true );
-
 
-
 
130
 
-
 
131
        props.bluetooth=canvas.bluetooth;
186
            rms_avail=recStore.getSizeAvailable();
132
        props.locationprovider=canvas.locationprovider;
Line 187... Line 133...
187
            }
133
        props.fileapi=canvas.fileapi;
188
        catch ( Exception e) {}
134
        props.devicecontrol=canvas.devicecontrol;
189
        System.gc();
135
        props.cldc11=canvas.cldc11;
190
        return
136
 
191
            "Screenwidth:" + canvas.canvas_width + "\n"
137
 
Line 192... Line -...
192
            +"Screenheight:" + canvas.canvas_height + "\n"
-
 
Line -... Line 138...
-
 
138
 
193
            +"Screenwidth FS:" + canvas.canvas_full_width + "\n"
139
        // create forms
194
            +"Screenheight FS:" + canvas.canvas_full_height + "\n"
140
 
195
            +"CLDC1.1:" + canvas.cldc11 + "\n"
141
        install_form = new Form("Install DUBwise");
196
            +"JSR-82:" + canvas.bluetooth + "\n"
142
        installoptions_form=new Form("Install Options");
197
            +"JSR-179:" + canvas.locationprovider + "\n"
143
        expert_form=new Form("Expert Settings");
Line 198... Line -...
198
            +"FileConn:" + canvas.fileapi + "\n"
-
 
199
            +"SensorAPI:" + canvas.sensorapi + "\n"
-
 
Line 200... Line -...
200
            +"DeviceControl:" + canvas.devicecontrol + "\n"
-
 
201
            +"comports:" + canvas.comports + "\n"
144
 
202
 
145
 
203
            +"freeMemory:" + Runtime.getRuntime().freeMemory()+ "\n"
146
        // create widgets
204
            +"totalMemory:" + Runtime.getRuntime().totalMemory()+ "\n"
147
 
205
            +"RMSAvail:" +  rms_avail+ "\n"
148
        res_choice = new ChoiceGroup(
Line 206... Line 149...
206
            +"Download URL:" + getURL() + "\n"
149
                                     "Resolution (Detected " +canvas.canvas_full_width + "x"+ canvas.canvas_full_height+")",
207
            +canvas.props;
-
 
208
 
-
 
209
    }
-
 
210
 
-
 
211
 
-
 
212
 
-
 
213
    public void quit() {
-
 
214
 
-
 
Line 215... Line 150...
215
        try
150
                        Choice.EXCLUSIVE,
216
            {
151
                        props.res_strings,
217
                res_strings=new String[res_vals.length];
152
                        null);
218
                for (int i=0;i<res_vals.length;i++)
153
 
219
                    {
154
        res_choice.setSelectedIndex(props.res_select,true);
Line 220... Line 155...
220
                        if ((canvas.canvas_width>=res_vals[i][0])&&(res_select==-1))
155
        expert_form.append(res_choice);
221
                            res_select=i;
-
 
-
 
156
 
Line 222... Line 157...
222
                        res_strings[i]=res_vals[i][0]+"x"+res_vals[i][1];
157
 
223
                    }
158
        device_features_choice = new ChoiceGroup(
224
            }
159
                                                 "Features ",
225
        catch(Exception e)
160
                        Choice.MULTIPLE,
226
            {
161
                        props.feature_strings,
Line 227... Line 162...
227
                res_strings=new String[0];
162
                        null);
-
 
163
 
-
 
164
 
-
 
165
        device_features_choice.setSelectedIndex(0,props.bluetooth);
-
 
166
        device_features_choice.setSelectedIndex(1,props.locationprovider);
-
 
167
        device_features_choice.setSelectedIndex(2,props.fileapi);
-
 
168
        device_features_choice.setSelectedIndex(3,props.devicecontrol);
-
 
169
        device_features_choice.setSelectedIndex(4,props.cldc11);
-
 
170
 
-
 
171
        expert_form.append(device_features_choice);
-
 
172
 
-
 
173
 
228
            }
174
 
-
 
175
 
-
 
176
 
-
 
177
        System.out.println("install build");
-
 
178
        /* Install form */
Line 229... Line 179...
229
 
179
 
230
        if (res_select==-1) res_select=0;
180
 
Line 231... Line -...
231
        show_edit_form();
-
 
232
       
-
 
233
    }
-
 
Line -... Line 181...
-
 
181
 
-
 
182
 
Line -... Line 183...
-
 
183
 
-
 
184
 
-
 
185
        optional_features_choice = new ChoiceGroup(
-
 
186
                                                 "Optional Features ",
-
 
187
                        Choice.MULTIPLE,
-
 
188
                        props.optional_feature_strings,
-
 
189
                        null);
-
 
190
 
-
 
191
 
-
 
192
 
-
 
193
        //
-
 
194
 
-
 
195
        installmethod_choice = new ChoiceGroup(
-
 
196
                                               "Install Method",
-
 
197
                                               Choice.EXCLUSIVE,
-
 
198
                                               installmethod_strings,
-
 
199
                                               null);
234
 
200
 
Line -... Line 201...
-
 
201
 
235
 
202
 
236
   public void show_edit_form()
203
        installoption_choice = new ChoiceGroup (
Line 237... Line 204...
237
    {
204
                                                "Install Options",
238
        Form form = new Form("Install DUBwise");
205
                                                Choice.EXCLUSIVE,
239
 
206
                                                installoption_strings,
240
        installsrc_choice = new ChoiceGroup(
207
                                                null);
241
                                            "Install Source",
208
 
-
 
209
 
242
                        Choice.EXCLUSIVE,
210
        /*      device_features_choice = new ChoiceGroup(
243
                        installsrc_strings,
211
                                                 "Features ",
244
                        null);
212
                        Choice.MULTIPLE,
Line 245... Line 213...
245
 
213
                        feature_strings,
246
        installsrc_choice.setSelectedIndex(installsrc_select,true);
214
                        null);
247
        form.append(installsrc_choice);
-
 
248
 
-
 
249
        installmethod_choice = new ChoiceGroup(
-
 
250
                                                 "Install Method",
-
 
251
                        Choice.EXCLUSIVE,
-
 
252
                        installmethod_strings,
-
 
253
                        null);
-
 
254
 
-
 
255
        form.append(installmethod_choice);
-
 
256
 
-
 
257
        res_choice = new ChoiceGroup(
-
 
Line -... Line 215...
-
 
215
 
-
 
216
        */
-
 
217
 
-
 
218
 
-
 
219
        firmware_choice = new ChoiceGroup(
-
 
220
                                     "Firmwares:",
-
 
221
                        Choice.EXCLUSIVE,
-
 
222
                        props.firmware_strings,
-
 
223
                        null);
-
 
224
 
-
 
225
        firmware_choice.setSelectedIndex(props.firmware_select,true);
Line -... Line 226...
-
 
226
 
Line 258... Line 227...
258
                                     "Resolution (Real " +canvas.canvas_full_width + "x"+ canvas.canvas_full_height+")",
227
 
259
                        Choice.EXCLUSIVE,
228
 
-
 
229
        sound_choice = new ChoiceGroup(
260
                        res_strings,
230
                                                 "Sound ",
261
                        null);
231
                        Choice.EXCLUSIVE,
262
 
232
                        props.sound_strings,
263
        res_choice.setSelectedIndex(res_select,true);
233
                        null);
Line 264... Line 234...
264
        form.append(res_choice);
234
 
-
 
235
        sound_choice.setSelectedIndex(props.sound_select,true);
265
 
236
 
266
 
237
 
267
        features_choice = new ChoiceGroup(
238
 
Line 268... Line 239...
268
                                                 "Features ",
239
 
Line 269... Line 240...
269
                        Choice.MULTIPLE,
240
        install_form.append(installmethod_choice);
-
 
241
        install_form.append(installoption_choice);
-
 
242
 
270
                        feature_strings,
243
        installoptions_form.append(optional_features_choice);
Line 271... Line 244...
271
                        null);
244
        installoptions_form.append(firmware_choice);
-
 
245
 
-
 
246
 
-
 
247
        installoptions_form.append(sound_choice);
-
 
248
 
-
 
249
 
-
 
250
        expert_form.addCommand(new Command("OK", Command.OK, 1));
-
 
251
        expert_form.addCommand(new Command("Back", Command.BACK, 2));
-
 
252
 
-
 
253
        installoptions_form.addCommand(new Command("OK", Command.OK, 1));
-
 
254
        installoptions_form.addCommand(new Command("Back", Command.BACK, 2));
-
 
255
 
-
 
256
 
-
 
257
        install_form.addCommand(new Command("OK", Command.OK, 1));
Line -... Line 258...
-
 
258
        install_form.addCommand(new Command("Exit", Command.EXIT, 2));
-
 
259
 
-
 
260
        // set this class as the command listener
272
 
261
        installoptions_form.setCommandListener(this);
273
 
262
        install_form.setCommandListener(this);
-
 
263
        expert_form.setCommandListener(this);
-
 
264
 
-
 
265
 
-
 
266
        if (!canvas.bluetooth)
-
 
267
            {
-
 
268
               
-
 
269
                Alert myAlert = new Alert("Warning", "The Bluetooth API (JSR-82) on your Phone was not found. Without this API DUBwise is not very usefull for most users ( You can only connect via TCP/IP or Serial port ). \n If you have a Windows Mobile Phone this issue can be solved by using DUBwise with a diffrent JRE ( PhoneME or J9 ).\n There is Information in the Internet to show you how to do that - just use your preferred search engine.", null, AlertType.ERROR);
274
        features_choice.setSelectedIndex(0,canvas.bluetooth);
270
 
-
 
271
                myAlert.setTimeout(Alert.FOREVER);
-
 
272
               
-
 
273
                display.setCurrent( myAlert,install_form );
-
 
274
            }
-
 
275
        else
-
 
276
            display.setCurrent( install_form );
-
 
277
    }
-
 
278
 
-
 
279
 
-
 
280
    public void show_url_form()
-
 
281
    {
-
 
282
 
-
 
283
        Form url_form = new Form("FileName");
-
 
284
        TextField txtField = new TextField(
275
        features_choice.setSelectedIndex(1,canvas.locationprovider);
285
                                 "FileName", props.getFileName() , 250, TextField.ANY);
-
 
286
        url_form.append(txtField);
-
 
287
        url_form.setCommandListener(this);
-
 
288
        url_form.addCommand(new Command("Exit", Command.EXIT, 1));
-
 
289
        url_form.addCommand(new Command("Back", Command.BACK, 2));
-
 
290
        display.setCurrent(url_form);
-
 
291
    }
-
 
292
 
-
 
293
    public void process_edit_form()
-
 
294
    {
-
 
295
 
-
 
296
        // copy form to props
-
 
297
        props.res_select=res_choice.getSelectedIndex();
-
 
298
        props.firmware_select=firmware_choice.getSelectedIndex();
-
 
299
        props.sound_select=sound_choice.getSelectedIndex();
-
 
300
        //      installsrc_select=      installsrc_choice.getSelectedIndex();
-
 
301
 
-
 
302
        props.bluetooth=        device_features_choice.isSelected(0);
-
 
303
        props.locationprovider=device_features_choice.isSelected(1);
-
 
304
        props.fileapi=          device_features_choice.isSelected(2);
-
 
305
        props.devicecontrol=    device_features_choice.isSelected(3);
-
 
306
        props.cldc11      =     device_features_choice.isSelected(4);
-
 
307
 
-
 
308
        props.j2memaps = optional_features_choice.isSelected(0);
-
 
309
 
-
 
310
        switch (installmethod_choice.getSelectedIndex())
-
 
311
            {
-
 
312
               
-
 
313
            case INSTALLMETHODID_ONLINE:
-
 
314
                // online Install -> fire up browser    
-
 
315
                new Thread(this).start();
276
        features_choice.setSelectedIndex(2,canvas.fileapi);
316
                break;
277
        features_choice.setSelectedIndex(3,canvas.devicecontrol);
317
 
-
 
318
            case INSTALLMETHODID_SHOWURL:
278
        features_choice.setSelectedIndex(4,canvas.fullscreen);
319
                // show URL -> fire up browser  
Line -... Line 320...
-
 
320
                show_url_form();
Line 279... Line 321...
279
        features_choice.setSelectedIndex(5,canvas.cldc11);
321
                break;
280
        form.append(features_choice);
322
            }