Rev 214 |
Rev 220 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/***************************************************************
*
* 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,DUBwiseUIDefinitions
{
// name/handle for the recordStore to memorize some stuff
private final static String RECORD_STORE_NAME=
"DUBSETT_V3";
/* 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;
public boolean expert_mode=
false;
public byte gps_format=GPS_FORMAT_DECIMAL
;
public byte speed_format=SPEED_FORMAT_KMH
;
public byte[] default_extern_control=default_extern_keycontrol
;
//#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();
//#else
din.
readBoolean();
//#endif
gps_format=din.
readByte();
speed_format=din.
readByte();
expert_mode=din.
readBoolean();
// reserve
din.
readBoolean();
din.
readBoolean();
din.
readByte();
din.
readByte();
din.
readByte();
din.
readUTF();
din.
readUTF();
din.
readUTF();
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
);
//#else
dout.
writeBoolean(false);
//#endif
dout.
writeByte(gps_format
);
dout.
writeByte(speed_format
);
dout.
writeBoolean( expert_mode
);
dout.
writeBoolean(false);
dout.
writeBoolean(false);
dout.
writeByte(0);
dout.
writeByte(0);
dout.
writeByte(0);
dout.
writeUTF("");
dout.
writeUTF("");
dout.
writeUTF("");
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
)
{ }
}
}