12,39 → 12,35 |
import javax.microedition.lcdui.*; |
import javax.microedition.midlet.*; |
|
import javax.microedition.rms.*; |
|
|
public class DUBwiseInstaller |
extends MIDlet |
implements Runnable,CommandListener |
{ |
public Display display; |
public DUBwiseInstallerCanvas canvas; |
public boolean loaded=false; |
|
|
String browser_dest=""; |
public String[] installmethod_strings={"online Install","show Filename"};//,"email URL"}; |
public String[] installoption_strings={"default","full featured","minimal","custom","expert"}; |
|
public final static byte INSTALLOPTIONID_DEFAULT=0; |
public final static byte INSTALLOPTIONID_FULL=1; |
public final static byte INSTALLOPTIONID_MINIMAL=2; |
public final static byte INSTALLOPTIONID_CUSTOM=3; |
public final static byte INSTALLOPTIONID_EXPERT=4; |
|
public int[][] res_vals = { {480,640},{340,400},{240,320},{200,300},{176,220},{128,128} }; |
public String[] res_strings; |
public final static byte INSTALLMETHODID_ONLINE=0; |
public final static byte INSTALLMETHODID_SHOWURL=1; |
|
public String[] feature_strings={"Bluetooth","Location API","File Connection","Device Control","Fullscreen","cldc11"}; |
public Display display; |
public DUBwiseInstallerCanvas canvas; |
private DUBwiseProps props; |
|
public String[] sound_strings={"en_speedy","en_wav","de_tts","de_wav","de_64kbit_tts","wav","no_voice"}; |
public String[] firmware_strings={"No Firmwars","All Firmwares","FC&MK3MAF Firmwares"}; |
public String[] firmware_clean_strings={"no_firmwares","all_firmwares","fc_mk3mag_firmwares"}; |
public boolean app_running=false; // to prevent 2 instances |
|
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"}; |
String browser_dest=""; |
|
public int res_select=-1; |
public int sound_select=0; |
public int firmware_select=0; |
public int installsrc_select=0; |
|
|
String helper_url=null; |
String download_url=null; |
52,19 → 48,32 |
boolean http_possible; |
|
|
ChoiceGroup res_choice; |
ChoiceGroup features_choice; |
Form installoptions_form; |
Form install_form; |
|
|
ChoiceGroup installmethod_choice; |
ChoiceGroup installoption_choice; |
|
ChoiceGroup sound_choice; |
ChoiceGroup installmethod_choice; |
ChoiceGroup installsrc_choice; |
ChoiceGroup firmware_choice; |
|
ChoiceGroup optional_features_choice; |
|
|
Form expert_form; |
|
ChoiceGroup res_choice; |
ChoiceGroup device_features_choice; |
ChoiceGroup installsrc_choice; |
|
|
|
protected void startApp() |
throws MIDletStateChangeException |
{ |
|
if (loaded)return; |
if (app_running)return; |
display = Display.getDisplay(this); |
canvas=new DUBwiseInstallerCanvas(this); |
|
73,97 → 82,28 |
} |
|
|
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_clean_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(); |
return download_url+props.installsrc_str()+"/"+props.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")); |
return (InstallHelper.get_http_string(getURL()).startsWith("MIDlet-Jar-URL:")); |
} |
|
public String res_str() |
{ |
try |
{ |
return res_strings[res_select]; |
} |
catch(Exception e) |
{ |
return res_strings[0]; |
} |
} |
|
|
// fire up browser for online install |
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/installer_meta/dl_url") ; |
|
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" ))); |
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" ))); |
|
try |
{ |
172,180 → 112,211 |
} |
catch ( Exception e) {} |
|
notifyDestroyed(); |
notifyDestroyed(); //quit |
|
} |
|
|
public String description_str() |
{ |
|
int rms_avail=0; |
try { |
RecordStore recStore = RecordStore.openRecordStore("test", true ); |
rms_avail=recStore.getSizeAvailable(); |
} |
catch ( Exception e) {} |
System.gc(); |
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" |
+"SensorAPI:" + canvas.sensorapi + "\n" |
+"DeviceControl:" + canvas.devicecontrol + "\n" |
+"comports:" + canvas.comports + "\n" |
|
+"freeMemory:" + Runtime.getRuntime().freeMemory()+ "\n" |
+"totalMemory:" + Runtime.getRuntime().totalMemory()+ "\n" |
+"RMSAvail:" + rms_avail+ "\n" |
+"Download URL:" + getURL() + "\n" |
+canvas.props; |
|
} |
|
public void canvas_hw_detect_finish() |
{ |
|
props=new DUBwiseProps(); |
props.set_res_by_screensize(canvas.canvas_width,canvas.canvas_height); |
|
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]; |
} |
props.bluetooth=canvas.bluetooth; |
props.locationprovider=canvas.locationprovider; |
props.fileapi=canvas.fileapi; |
props.devicecontrol=canvas.devicecontrol; |
props.cldc11=canvas.cldc11; |
|
if (res_select==-1) res_select=0; |
show_edit_form(); |
|
} |
|
|
public void show_edit_form() |
{ |
Form form = new Form("Install DUBwise"); |
// create forms |
|
installsrc_choice = new ChoiceGroup( |
"Install Source", |
install_form = new Form("Install DUBwise"); |
installoptions_form=new Form("Install Options"); |
expert_form=new Form("Expert Settings"); |
|
|
// create widgets |
|
res_choice = new ChoiceGroup( |
"Resolution (Detected " +canvas.canvas_full_width + "x"+ canvas.canvas_full_height+")", |
Choice.EXCLUSIVE, |
installsrc_strings, |
props.res_strings, |
null); |
|
installsrc_choice.setSelectedIndex(installsrc_select,true); |
form.append(installsrc_choice); |
res_choice.setSelectedIndex(props.res_select,true); |
expert_form.append(res_choice); |
|
installmethod_choice = new ChoiceGroup( |
"Install Method", |
Choice.EXCLUSIVE, |
installmethod_strings, |
|
device_features_choice = new ChoiceGroup( |
"Features ", |
Choice.MULTIPLE, |
props.feature_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, |
device_features_choice.setSelectedIndex(0,props.bluetooth); |
device_features_choice.setSelectedIndex(1,props.locationprovider); |
device_features_choice.setSelectedIndex(2,props.fileapi); |
device_features_choice.setSelectedIndex(3,props.devicecontrol); |
device_features_choice.setSelectedIndex(4,props.cldc11); |
|
expert_form.append(device_features_choice); |
|
|
|
|
|
System.out.println("install build"); |
/* Install form */ |
|
|
|
|
|
|
optional_features_choice = new ChoiceGroup( |
"Optional Features ", |
Choice.MULTIPLE, |
props.optional_feature_strings, |
null); |
|
res_choice.setSelectedIndex(res_select,true); |
form.append(res_choice); |
|
|
features_choice = new ChoiceGroup( |
// |
|
installmethod_choice = new ChoiceGroup( |
"Install Method", |
Choice.EXCLUSIVE, |
installmethod_strings, |
null); |
|
|
|
installoption_choice = new ChoiceGroup ( |
"Install Options", |
Choice.EXCLUSIVE, |
installoption_strings, |
null); |
|
|
/* device_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); |
|
|
|
firmware_choice = new ChoiceGroup( |
"Firmwares:", |
Choice.EXCLUSIVE, |
firmware_strings, |
props.firmware_strings, |
null); |
|
firmware_choice.setSelectedIndex(firmware_select,true); |
form.append(firmware_choice); |
firmware_choice.setSelectedIndex(props.firmware_select,true); |
|
|
|
sound_choice = new ChoiceGroup( |
"Sound ", |
Choice.EXCLUSIVE, |
sound_strings, |
props.sound_strings, |
null); |
|
sound_choice.setSelectedIndex(sound_select,true); |
form.append(sound_choice); |
sound_choice.setSelectedIndex(props.sound_select,true); |
|
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); |
|
|
install_form.append(installmethod_choice); |
install_form.append(installoption_choice); |
|
installoptions_form.append(optional_features_choice); |
installoptions_form.append(firmware_choice); |
|
|
installoptions_form.append(sound_choice); |
|
|
expert_form.addCommand(new Command("OK", Command.OK, 1)); |
expert_form.addCommand(new Command("Back", Command.BACK, 2)); |
|
installoptions_form.addCommand(new Command("OK", Command.OK, 1)); |
installoptions_form.addCommand(new Command("Back", Command.BACK, 2)); |
|
|
install_form.addCommand(new Command("OK", Command.OK, 1)); |
install_form.addCommand(new Command("Exit", Command.EXIT, 2)); |
|
// set this class as the command listener |
installoptions_form.setCommandListener(this); |
install_form.setCommandListener(this); |
expert_form.setCommandListener(this); |
|
|
if (!canvas.bluetooth) |
{ |
|
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); |
|
myAlert.setTimeout(Alert.FOREVER); |
|
display.setCurrent( myAlert,install_form ); |
} |
else |
display.setCurrent( install_form ); |
} |
|
|
public void show_url_form() |
{ |
|
Form url_form = new Form("FileName"); |
TextField txtField = new TextField( |
"FileName", getFileName() , 250, TextField.ANY); |
"FileName", props.getFileName() , 250, TextField.ANY); |
url_form.append(txtField); |
url_form.setCommandListener(this); |
url_form.addCommand(new Command("Back", Command.OK, 2)); |
url_form.addCommand(new Command("Exit", Command.EXIT, 1)); |
url_form.addCommand(new Command("Back", Command.BACK, 2)); |
display.setCurrent(url_form); |
} |
|
public void process_edit_form() |
{ |
res_select=res_choice.getSelectedIndex(); |
firmware_select=firmware_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); |
// copy form to props |
props.res_select=res_choice.getSelectedIndex(); |
props.firmware_select=firmware_choice.getSelectedIndex(); |
props.sound_select=sound_choice.getSelectedIndex(); |
// installsrc_select= installsrc_choice.getSelectedIndex(); |
|
props.bluetooth= device_features_choice.isSelected(0); |
props.locationprovider=device_features_choice.isSelected(1); |
props.fileapi= device_features_choice.isSelected(2); |
props.devicecontrol= device_features_choice.isSelected(3); |
props.cldc11 = device_features_choice.isSelected(4); |
|
props.j2memaps = optional_features_choice.isSelected(0); |
|
switch (installmethod_choice.getSelectedIndex()) |
{ |
case 0: |
// browser_dest= getURL(); |
|
case INSTALLMETHODID_ONLINE: |
// online Install -> fire up browser |
new Thread(this).start(); |
break; |
|
case 1: |
case INSTALLMETHODID_SHOWURL: |
// show URL -> fire up browser |
show_url_form(); |
break; |
} |
353,21 → 324,92 |
|
} |
|
public void commandAction( Command com, Displayable dis) |
public void commandAction( Command cmd, Displayable dis) |
{ |
switch(cmd.getCommandType()) |
{ |
|
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(); |
case Command.BACK: |
if(dis==expert_form) |
display.setCurrent(installoptions_form); |
else |
switch(installoption_choice.getSelectedIndex()) |
{ |
case INSTALLOPTIONID_CUSTOM: |
display.setCurrent(installoptions_form); |
case INSTALLOPTIONID_EXPERT: |
display.setCurrent(expert_form); |
break; |
default: |
display.setCurrent(install_form); |
} |
|
break; |
|
|
case Command.EXIT: |
notifyDestroyed(); |
break; |
|
case Command.ITEM: |
display.setCurrent(expert_form); |
break; |
|
case Command.OK: |
if (dis==install_form) |
|
switch(installoption_choice.getSelectedIndex()) |
{ |
case INSTALLOPTIONID_DEFAULT: |
firmware_choice.setSelectedIndex(0,true); |
sound_choice.setSelectedIndex(1,true); |
|
|
|
process_edit_form(); |
break; |
case INSTALLOPTIONID_MINIMAL: |
firmware_choice.setSelectedIndex(0,true); |
sound_choice.setSelectedIndex(0,true); |
process_edit_form(); |
break; |
|
case INSTALLOPTIONID_FULL: |
firmware_choice.setSelectedIndex(1,true); |
sound_choice.setSelectedIndex(1,true); |
process_edit_form(); |
break; |
|
|
case INSTALLOPTIONID_CUSTOM: |
case INSTALLOPTIONID_EXPERT: |
display.setCurrent(installoptions_form); |
break; |
} |
else if (dis==installoptions_form) |
{ |
|
switch(installoption_choice.getSelectedIndex()) |
{ |
|
case INSTALLOPTIONID_CUSTOM: |
process_edit_form(); |
break; |
case INSTALLOPTIONID_EXPERT: |
display.setCurrent(expert_form); |
break; |
|
} |
|
} |
else if (dis==expert_form) |
process_edit_form(); |
break; |
} |
|
} |
|
|
|
protected void pauseApp() {} // not needed right now |
protected void destroyApp(boolean arg0) { } |
|