Rev 214 | Rev 220 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
206 | ligi | 1 | /*************************************************************** |
2 | * |
||
3 | * Settings related Part of DUBwise |
||
4 | * ( e.g. saving to / reading from RMS ) |
||
5 | * |
||
6 | * Author: Marcus -LiGi- Bueschleb |
||
7 | * Mailto: LiGi @at@ LiGi DOTT de |
||
8 | * |
||
9 | ***************************************************************/ |
||
10 | |||
11 | import javax.microedition.rms.*; |
||
12 | |||
13 | import java.io.*; |
||
14 | |||
15 | public class DUBwiseSettings |
||
211 | ligi | 16 | implements org.ligi.ufo.DUBwiseDefinitions,DUBwiseUIDefinitions |
206 | ligi | 17 | { |
18 | // name/handle for the recordStore to memorize some stuff |
||
211 | ligi | 19 | private final static String RECORD_STORE_NAME="DUBSETT_V3"; |
206 | ligi | 20 | |
21 | /* all settings hold here */ |
||
22 | //holds id of actual skin |
||
23 | public byte act_skin=SKINID_DARK; |
||
24 | |||
25 | public String connection_name=""; |
||
26 | public String connection_url=""; |
||
27 | |||
28 | public boolean do_vibra=true; |
||
29 | public boolean do_sound=true; |
||
30 | public boolean fullscreen=false; |
||
31 | public boolean do_scrollbg=false; |
||
214 | ligi | 32 | public boolean expert_mode=false; |
206 | ligi | 33 | |
34 | |||
211 | ligi | 35 | public byte gps_format=GPS_FORMAT_DECIMAL; |
36 | public byte speed_format=SPEED_FORMAT_KMH; |
||
37 | |||
38 | |||
219 | ligi | 39 | public byte[] default_extern_control=default_extern_keycontrol ; |
211 | ligi | 40 | |
206 | ligi | 41 | //#if devicecontrol=="on" |
42 | public boolean keep_lighton=false; |
||
43 | //#endif |
||
44 | |||
45 | int[] act_proxy_ip=default_ip; // { ip , ip , ip , ip , port } |
||
46 | int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port } |
||
47 | |||
48 | /* end of all settings hold here */ |
||
49 | |||
50 | public DUBwiseSettings() |
||
51 | { |
||
52 | try |
||
53 | { |
||
54 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
||
55 | |||
56 | if (recStore.getNumRecords()==1) |
||
57 | { |
||
58 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
||
59 | DataInputStream din = new DataInputStream( bin ); |
||
60 | |||
61 | |||
62 | connection_url=din.readUTF(); |
||
63 | connection_name=din.readUTF(); |
||
64 | act_skin=din.readByte(); |
||
65 | |||
66 | do_sound=din.readBoolean(); |
||
67 | do_vibra=din.readBoolean(); |
||
68 | do_scrollbg=din.readBoolean(); |
||
69 | fullscreen=din.readBoolean(); |
||
70 | //#if devicecontrol=="on" |
||
71 | keep_lighton=din.readBoolean(); |
||
211 | ligi | 72 | //#else |
73 | din.readBoolean(); |
||
206 | ligi | 74 | //#endif |
75 | |||
76 | |||
211 | ligi | 77 | gps_format=din.readByte(); |
78 | speed_format=din.readByte(); |
||
79 | |||
214 | ligi | 80 | expert_mode=din.readBoolean(); |
211 | ligi | 81 | // reserve |
214 | ligi | 82 | |
211 | ligi | 83 | din.readBoolean(); |
84 | din.readBoolean(); |
||
85 | din.readByte(); |
||
86 | din.readByte(); |
||
87 | din.readByte(); |
||
88 | din.readUTF(); |
||
89 | din.readUTF(); |
||
90 | din.readUTF(); |
||
91 | |||
206 | ligi | 92 | for ( int i=0;i<5;i++) |
93 | { |
||
94 | act_proxy_ip[i]=din.readInt(); |
||
95 | act_conn_ip[i]=din.readInt(); |
||
96 | } |
||
97 | |||
98 | } |
||
99 | recStore.closeRecordStore(); |
||
100 | } |
||
101 | catch (Exception e) |
||
102 | { } |
||
103 | |||
104 | } |
||
105 | |||
106 | |||
107 | |||
108 | public void save() |
||
109 | { |
||
110 | try |
||
111 | { |
||
112 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
||
113 | } |
||
114 | catch (Exception e) |
||
115 | { } |
||
116 | |||
117 | try { |
||
118 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
||
119 | |||
120 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
||
121 | DataOutputStream dout = new DataOutputStream( bout ); |
||
122 | |||
123 | dout.writeUTF(connection_url); |
||
124 | dout.writeUTF(connection_name); |
||
125 | dout.writeByte(act_skin); |
||
126 | dout.writeBoolean(do_sound); |
||
127 | dout.writeBoolean(do_vibra); |
||
128 | dout.writeBoolean(do_scrollbg); |
||
129 | dout.writeBoolean(fullscreen); |
||
130 | //#if devicecontrol=="on" |
||
131 | dout.writeBoolean(keep_lighton); |
||
211 | ligi | 132 | //#else |
133 | dout.writeBoolean(false); |
||
206 | ligi | 134 | //#endif |
135 | |||
211 | ligi | 136 | dout.writeByte(gps_format); |
137 | dout.writeByte(speed_format); |
||
138 | |||
214 | ligi | 139 | dout.writeBoolean( expert_mode); |
211 | ligi | 140 | dout.writeBoolean(false); |
141 | dout.writeBoolean(false); |
||
142 | dout.writeByte(0); |
||
143 | dout.writeByte(0); |
||
144 | dout.writeByte(0); |
||
145 | dout.writeUTF(""); |
||
146 | dout.writeUTF(""); |
||
147 | dout.writeUTF(""); |
||
148 | |||
149 | |||
150 | |||
206 | ligi | 151 | for ( int i=0;i<5;i++) |
152 | { |
||
153 | dout.writeInt(act_proxy_ip[i]); |
||
154 | dout.writeInt(act_conn_ip[i]); |
||
155 | } |
||
156 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
||
157 | |||
158 | recStore.closeRecordStore(); |
||
159 | |||
160 | |||
161 | } |
||
162 | catch (Exception e) |
||
163 | { } |
||
164 | |||
165 | } |
||
166 | |||
167 | } |