Subversion Repositories Projects

Rev

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