0,0 → 1,127 |
/*************************************************************** |
* |
* Settings related Part of DUBwise |
* ( e.g. saving to / reading from RMS ) |
* |
* Author: Marcus -LiGi- Bueschleb |
* Mailto: LiGi @at@ LiGi DOTT de |
* |
***************************************************************/ |
|
import javax.microedition.rms.*; |
|
import java.io.*; |
|
public class DUBwiseSettings |
implements org.ligi.ufo.DUBwiseDefinitions |
{ |
// name/handle for the recordStore to memorize some stuff |
private final static String RECORD_STORE_NAME="DUBSETT_V2"; |
|
|
/* all settings hold here */ |
//holds id of actual skin |
public byte act_skin=SKINID_DARK; |
|
public String connection_name=""; |
public String connection_url=""; |
|
public boolean do_vibra=true; |
public boolean do_sound=true; |
public boolean fullscreen=false; |
public boolean do_scrollbg=false; |
|
|
//#if devicecontrol=="on" |
public boolean keep_lighton=false; |
//#endif |
|
int[] act_proxy_ip=default_ip; // { ip , ip , ip , ip , port } |
int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port } |
|
/* end of all settings hold here */ |
|
public DUBwiseSettings() |
{ |
try |
{ |
RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
|
if (recStore.getNumRecords()==1) |
{ |
ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
DataInputStream din = new DataInputStream( bin ); |
|
|
connection_url=din.readUTF(); |
connection_name=din.readUTF(); |
act_skin=din.readByte(); |
|
do_sound=din.readBoolean(); |
do_vibra=din.readBoolean(); |
do_scrollbg=din.readBoolean(); |
fullscreen=din.readBoolean(); |
//#if devicecontrol=="on" |
keep_lighton=din.readBoolean(); |
//#endif |
|
|
for ( int i=0;i<5;i++) |
{ |
act_proxy_ip[i]=din.readInt(); |
act_conn_ip[i]=din.readInt(); |
} |
|
} |
recStore.closeRecordStore(); |
} |
catch (Exception e) |
{ } |
|
} |
|
|
|
public void save() |
{ |
try |
{ |
RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
} |
catch (Exception e) |
{ } |
|
try { |
RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
|
ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
DataOutputStream dout = new DataOutputStream( bout ); |
|
dout.writeUTF(connection_url); |
dout.writeUTF(connection_name); |
dout.writeByte(act_skin); |
dout.writeBoolean(do_sound); |
dout.writeBoolean(do_vibra); |
dout.writeBoolean(do_scrollbg); |
dout.writeBoolean(fullscreen); |
//#if devicecontrol=="on" |
dout.writeBoolean(keep_lighton); |
//#endif |
|
for ( int i=0;i<5;i++) |
{ |
dout.writeInt(act_proxy_ip[i]); |
dout.writeInt(act_conn_ip[i]); |
} |
recStore.addRecord(bout.toByteArray(),0,bout.size()); |
|
recStore.closeRecordStore(); |
|
|
} |
catch (Exception e) |
{ } |
|
} |
|
} |