0,0 → 1,340 |
/*********************************************************************** |
* |
* DUBwise == Digital UFO Broadcasting with intelligent service equipment |
* main MIDLet Source file |
* |
* Author: Marcus -LiGi- Bueschleb |
* Mailto: LiGi @at@ LiGi DOTT de |
* |
************************************************************************/ |
|
|
import javax.microedition.lcdui.*; |
import javax.microedition.midlet.*; |
|
public class DUBwiseInstaller |
extends MIDlet |
implements Runnable,CommandListener |
{ |
public Display display; |
public DUBwiseInstallerCanvas canvas; |
public boolean loaded=false; |
|
|
String browser_dest=""; |
|
protected void startApp() |
throws MIDletStateChangeException |
{ |
|
if (loaded)return; |
display = Display.getDisplay(this); |
canvas=new DUBwiseInstallerCanvas(this); |
|
// fire up canvas |
display.setCurrent(canvas); |
} |
|
|
public int[][] res_vals = { {480,640},{340,400},{240,320},{200,300},{176,220},{128,128} }; |
public String[] res_strings; |
|
public String[] feature_strings={"Bluetooth","Location API","File Connection","Device Control","Fullscreen","cldc11"}; |
|
public String[] sound_strings={"en_speedy","en_wav","de_tts","de_wav","de_64kbit_tts","wav","no_voice"}; |
public String[] firmware_strings={"all_firmwares","fc_mk3mag_firmwares","no_firmwares"}; |
|
public String[] installmethod_strings={"online Install","show Filename"};//,"email URL"}; |
|
public String[] installsrc_strings={"stable (latest tag)","Bleeding Edge (trunk)"}; |
public String[] installsrc_clean_strings={"tags","trunk"}; |
|
public int res_select=-1; |
public int sound_select=0; |
public int firmware_select=0; |
public int installsrc_select=0; |
|
|
public String installsrc_str() |
{ |
return installsrc_clean_strings[installsrc_select]; |
} |
|
public String cldc_str() |
{ |
if (canvas.cldc11) |
return "-CLDC11"; |
else |
return ""; |
} |
|
public String bt_str() |
{ |
if (canvas.bluetooth) |
return "-BluetoothAPI"; |
else |
return ""; |
} |
|
public String fileapi_str() |
{ |
if (canvas.fileapi) |
return "-FileAPI"; |
else |
return ""; |
} |
|
|
public String firmware_str() |
{ |
return firmware_strings[firmware_select]; |
} |
|
public String devicecontrol_str() |
{ |
if (canvas.devicecontrol) |
return "-DeviceControl"; |
else |
return ""; |
} |
|
public String sound_str() |
{ |
return sound_strings[sound_select]; |
} |
|
|
public String getURL() |
{ |
return download_url+installsrc_str()+"/"+getFileName(); |
} |
|
public String getFileName() |
{ |
return "DUBwise-"+res_str()+"-" + sound_str() + "-" + firmware_str() + cldc_str() + fileapi_str() + bt_str() + devicecontrol_str() +".jad"; |
} |
|
public boolean url_check() |
{ |
return (!InstallHelper.get_http_string(getURL()).equals("err")); |
} |
|
public String res_str() |
{ |
try |
{ |
return res_strings[res_select]; |
} |
catch(Exception e) |
{ |
return res_strings[0]; |
} |
} |
|
String helper_url=null; |
String download_url=null; |
|
boolean http_possible; |
|
public void run() |
{ |
|
helper_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/helper_url") ; |
|
http_possible=((!helper_url.equals("err"))); |
|
|
download_url=InstallHelper.get_http_string("http://mikrocontroller.cco-ev.de/mikrosvn/Projects/DUBwise/trunk/misc/download_url") ; |
|
if ((download_url==null) || (!download_url.startsWith("http"))) |
download_url=helper_url+"dl/"; |
|
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" ))); |
|
try |
{ |
Thread.sleep(500); |
platformRequest(getURL()); |
} |
catch ( Exception e) {} |
|
notifyDestroyed(); |
|
} |
|
|
public String description_str() |
{ |
return |
"Screenwidth:" + canvas.canvas_width + "\n" |
+"Screenheight:" + canvas.canvas_height + "\n" |
+"Screenwidth FS:" + canvas.canvas_full_width + "\n" |
+"Screenheight FS:" + canvas.canvas_full_height + "\n" |
+"CLDC1.1:" + canvas.cldc11 + "\n" |
+"JSR-82:" + canvas.bluetooth + "\n" |
+"JSR-179:" + canvas.locationprovider + "\n" |
+"FileConn:" + canvas.fileapi + "\n" |
+"DeviceControl:" + canvas.devicecontrol + "\n" |
+"comports:" + canvas.comports + "\n" |
+"Download URL:" + getURL() + "\n" |
+canvas.props; |
|
} |
|
ChoiceGroup res_choice; |
ChoiceGroup features_choice; |
ChoiceGroup sound_choice; |
ChoiceGroup installmethod_choice; |
ChoiceGroup installsrc_choice; |
|
public void quit() { |
|
try |
{ |
res_strings=new String[res_vals.length]; |
for (int i=0;i<res_vals.length;i++) |
{ |
if ((canvas.canvas_width>=res_vals[i][0])&&(res_select==-1)) |
res_select=i; |
res_strings[i]=res_vals[i][0]+"x"+res_vals[i][1]; |
} |
} |
catch(Exception e) |
{ |
res_strings=new String[0]; |
} |
|
if (res_select==-1) res_select=0; |
show_edit_form(); |
|
} |
|
|
public void show_edit_form() |
{ |
Form form = new Form("Install DUBwise"); |
|
installsrc_choice = new ChoiceGroup( |
"Install Source", |
Choice.EXCLUSIVE, |
installsrc_strings, |
null); |
|
installsrc_choice.setSelectedIndex(installsrc_select,true); |
form.append(installsrc_choice); |
|
installmethod_choice = new ChoiceGroup( |
"Install Method", |
Choice.EXCLUSIVE, |
installmethod_strings, |
null); |
|
form.append(installmethod_choice); |
|
res_choice = new ChoiceGroup( |
"Resolution (Real " +canvas.canvas_full_width + "x"+ canvas.canvas_full_height+")", |
Choice.EXCLUSIVE, |
res_strings, |
null); |
|
res_choice.setSelectedIndex(res_select,true); |
form.append(res_choice); |
|
features_choice = new ChoiceGroup( |
"Features ", |
Choice.MULTIPLE, |
feature_strings, |
null); |
|
|
features_choice.setSelectedIndex(0,canvas.bluetooth); |
features_choice.setSelectedIndex(1,canvas.locationprovider); |
features_choice.setSelectedIndex(2,canvas.fileapi); |
features_choice.setSelectedIndex(3,canvas.devicecontrol); |
features_choice.setSelectedIndex(4,canvas.fullscreen); |
features_choice.setSelectedIndex(5,canvas.cldc11); |
form.append(features_choice); |
|
sound_choice = new ChoiceGroup( |
"Sound ", |
Choice.EXCLUSIVE, |
sound_strings, |
null); |
|
sound_choice.setSelectedIndex(sound_select,true); |
form.append(sound_choice); |
|
form.addCommand(new Command("OK", Command.OK, 1)); |
form.addCommand(new Command("Exit", Command.EXIT, 2)); |
|
// set itself as the command listener |
form.setCommandListener(this); |
display.setCurrent(form); |
|
|
} |
|
public void show_url_form() |
{ |
|
Form url_form = new Form("FileName"); |
TextField txtField = new TextField( |
"FileName", getFileName() , 250, TextField.ANY); |
url_form.append(txtField); |
url_form.setCommandListener(this); |
url_form.addCommand(new Command("Back", Command.OK, 2)); |
display.setCurrent(url_form); |
} |
|
public void process_edit_form() |
{ |
res_select=res_choice.getSelectedIndex(); |
sound_select=sound_choice.getSelectedIndex(); |
installsrc_select= installsrc_choice.getSelectedIndex(); |
|
canvas.bluetooth= features_choice.isSelected(0); |
canvas.locationprovider=features_choice.isSelected(1); |
canvas.fileapi= features_choice.isSelected(2); |
canvas.devicecontrol= features_choice.isSelected(3); |
canvas.fullscreen= features_choice.isSelected(4); |
canvas.cldc11 = features_choice.isSelected(5); |
|
|
|
switch (installmethod_choice.getSelectedIndex()) |
{ |
case 0: |
// browser_dest= getURL(); |
new Thread(this).start(); |
break; |
|
case 1: |
show_url_form(); |
break; |
} |
|
|
} |
|
public void commandAction( Command com, Displayable dis) |
{ |
|
String label = com.getLabel(); |
|
if("Exit".equals(label)) |
notifyDestroyed(); |
else if("OK".equals(label)) |
process_edit_form(); |
else if("Back".equals(label)) |
show_edit_form(); |
} |
|
|
|
protected void pauseApp() {} // not needed right now |
protected void destroyApp(boolean arg0) { } |
|
|
|
|
} |