Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 279 → Rev 280

/DUBwise/trunk/j2me/installer/.ant-targets-build.xml
0,0 → 1,4
[echo]
build
builddirs
clean
/DUBwise/trunk/j2me/installer/bin/DUBwiseInstaller.jad
0,0 → 1,8
MIDlet-Jar-URL: DUBwiseInstaller.jar
MIDlet-Jar-Size: 6290
MIDlet-Name: DUBwiseInstaller
MIDlet-Vendor: LiGi
MIDlet-Version: 0.3
MIDlet-1: DUBwiseInstaller, i.png, DUBwiseInstaller
MIDletX-No-Command: true
MIDlet-Icon: i.png
/DUBwise/trunk/j2me/installer/bin/DUBwiseInstaller.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/DUBwise/trunk/j2me/installer/build.xml
0,0 → 1,76
<project name="DUBwiseInstaller" basedir=".">
<property name="wtk.home" value="/home/ligi/tools/WTK2.2/"/>
 
<property name="project_name" value="DUBwiseInstaller"/> <!-- jar filename -->
 
<property name="project_version" value="0.3"/>
 
<property name="res_dir" location="res"/>
<property name="build_dir" location="${basedir}/build/"/>
<property name="bin_dir" location="${basedir}/bin/"/>
 
<property name="lib_dir" location="${basedir}/lib/"/>
<property name="src_dir" location="${basedir}/src/"/>
 
<property name="basename" value="${project_name}"/>
 
 
<echo >
${build_dir}
${basename}
</echo>
<taskdef resource="antenna.properties" classpath="${lib_dir}/antenna.jar"/>
 
<property name="wtk.midp.version" value="2.0"/>
<property name="wtk.cldc.version" value="1.0"/>
 
<property name="wtk.midpapi" value="${lib_dir}/classes.zip"/>
<target name="build" depends="builddirs">
 
<wtkbuild destdir="${build_dir}/classes" srcdir="${src_dir}" target="1.1" preverify="false"/>
<wtkjad
jadfile="${bin_dir}/${basename}.jad"
jarfile="${bin_dir}/${basename}.jar"
update="false"
manifest="${build_dir}/MANIFEST.MF"
name="${project_name}"
vendor="LiGi"
version="${project_version}">
<attribute name="MIDletX-No-Command" value="true"/>
<attribute name="MIDlet-Icon" value="i.png"/>
<midlet name="${project_name}" class="${project_name}" icon="i.png" />
<!-- !!TODO!! Remove Icon JAD entry if no icon is there -->
</wtkjad>
<wtkpackage
jarfile="${bin_dir}/${basename}.jar"
jadfile="${bin_dir}/${basename}.jad"
basedir="${build_dir}/classes"
manifest="${build_dir}/MANIFEST.MF"
obfuscate="true"
preverify="true">
<fileset dir="${res_dir}/">
<include name="*"/>
</fileset>
</wtkpackage>
 
 
</target>
 
<target name="clean">
<delete dir="${build_dir}"/>
</target>
 
<target name="builddirs">
<delete dir="${build_dir}"/>
<mkdir dir="${build_dir}"/>
<mkdir dir="${build_dir}/classes"/>
<mkdir dir="${build_dir}/bin"/>
</target>
 
</project>
/DUBwise/trunk/j2me/installer/lib
0,0 → 1,0
link ../lib/
Property changes:
Added: svn:special
+*
\ No newline at end of property
/DUBwise/trunk/j2me/installer/src/DUBwiseInstaller.java
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) { }
 
 
 
}
/DUBwise/trunk/j2me/installer/src/DUBwiseInstallerCanvas.java
0,0 → 1,126
/***************************************************************
*
* Canvas of DUBwise Installer
*
* Author: Marcus -LiGi- Bueschleb
* Mailto: LiGi @at@ LiGi DOTT de
*
***************************************************************/
 
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
 
public class DUBwiseInstallerCanvas
extends Canvas
implements Runnable
{
 
// values to detect
int canvas_width=-1;
int canvas_height=-1;
 
int canvas_full_width=-1;
int canvas_full_height=-1;
boolean fullscreen=false;
boolean locationprovider;
boolean devicecontrol;
boolean bluetooth;
boolean cldc11;
boolean fileapi;
 
String comports;
String props;
// end values to detect
 
DUBwiseInstaller root;
 
public boolean try_class(String class_name)
{
try
{
Class.forName(class_name);
}
 
catch (Exception e)
{
return false;
}
return true;
}
public DUBwiseInstallerCanvas(DUBwiseInstaller _root)
 
{
root=_root;
new Thread(this).start();
}
 
 
public void run()
{
 
repaint();
serviceRepaints();
try
{
Thread.sleep(500);
}
catch (Exception e)
{}
 
locationprovider=try_class("javax.microedition.location.LocationProvider");;
devicecontrol=try_class("com.nokia.mid.ui.DeviceControl");
bluetooth=try_class("javax.bluetooth.DiscoveryAgent");
cldc11=try_class("java.lang.Math");
fileapi=try_class("javax.microedition.io.file.FileConnection");
comports=System.getProperty("microedition.commports")+"\n";
props="enc: " +System.getProperty("microedition.encoding")+"\n";
props+="platform: " +System.getProperty("microedition.platform")+"\n";
props+="locale: " +System.getProperty("microedition.locale")+"\n";
props+="config:" + System.getProperty("microedition.configuration")+"\n";
props+="profiles: " +System.getProperty("microedition.profiles")+"\n";
props+="hostname: " +System.getProperty("microedition.hostname")+"\n";
props+="loc-version: " +System.getProperty("microedition.location.version ")+"\n";
 
 
root.quit();
 
}
 
 
boolean fs_check=true;
 
public void paint(Graphics g)
{
 
if (fs_check) try
{
 
setFullScreenMode(false);
canvas_width=this.getWidth();
canvas_height=this.getHeight();
 
setFullScreenMode(true);
canvas_full_width=this.getWidth();
canvas_full_height=this.getHeight();
 
fullscreen=((canvas_full_width!=canvas_width)||(canvas_full_height!=canvas_height));
}
catch (Exception e)
{
canvas_width=this.getWidth();
canvas_height=this.getHeight();
canvas_full_width=this.getWidth();
canvas_full_height=this.getHeight();
 
}
 
fs_check=false;
g.setColor(0);
g.fillRect(0,0,canvas_full_width,canvas_full_height);
g.setColor(0x00BB00);
g.drawString("Detecting Hardware",0,0,Graphics.LEFT | Graphics.TOP);
 
}
}
/DUBwise/trunk/j2me/installer/src/InstallHelper.java
0,0 → 1,72
/***************************************************************
*
* Helper functions for DUBwise
*
* Author: Marcus -LiGi- Bueschleb
* Mailto: LiGi @at@ LiGi DOTT de
*
***************************************************************/
 
 
import java.io.*;
import javax.microedition.io.*;
 
public final class InstallHelper
{
public final static String get_http_string(String url)
{
try {
 
InputStream stream = null;
StringBuffer buff = new StringBuffer();
StreamConnection conn=null;
System.out.println("starting conn");
conn = (StreamConnection)Connector.open(url);
stream = conn.openInputStream();
int ch;
while((ch = stream.read()) != -1)
buff.append((char) ch);
if(stream != null)
stream.close();
if(conn != null)
conn.close();
return buff.toString();
}
catch ( Exception e)
{
return "err";
}
}
 
 
static public String urlEncode(String sUrl)
{
StringBuffer urlOK = new StringBuffer();
for(int i=0; i<sUrl.length(); i++)
{
char ch=sUrl.charAt(i);
switch(ch)
{
case '\n': urlOK.append("%0A"); break;
case '-': urlOK.append("%2D"); break;
case '<': urlOK.append("%3C"); break;
case '>': urlOK.append("%3E"); break;
case '/': urlOK.append("%2F"); break;
case ' ': urlOK.append("%20"); break;
case ':': urlOK.append("%3A"); break;
 
default: urlOK.append(ch); break;
}
}
return urlOK.toString();
}
}