Rev 211 | Rev 219 | 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 | |||
39 | |||
206 | ligi | 40 | //#if devicecontrol=="on" |
41 | public boolean keep_lighton=false; |
||
42 | //#endif |
||
43 | |||
44 | int[] act_proxy_ip=default_ip; // { ip , ip , ip , ip , port } |
||
45 | int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port } |
||
46 | |||
47 | /* end of all settings hold here */ |
||
48 | |||
49 | public DUBwiseSettings() |
||
50 | { |
||
51 | try |
||
52 | { |
||
53 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
||
54 | |||
55 | if (recStore.getNumRecords()==1) |
||
56 | { |
||
57 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
||
58 | DataInputStream din = new DataInputStream( bin ); |
||
59 | |||
60 | |||
61 | connection_url=din.readUTF(); |
||
62 | connection_name=din.readUTF(); |
||
63 | act_skin=din.readByte(); |
||
64 | |||
65 | do_sound=din.readBoolean(); |
||
66 | do_vibra=din.readBoolean(); |
||
67 | do_scrollbg=din.readBoolean(); |
||
68 | fullscreen=din.readBoolean(); |
||
69 | //#if devicecontrol=="on" |
||
70 | keep_lighton=din.readBoolean(); |
||
211 | ligi | 71 | //#else |
72 | din.readBoolean(); |
||
206 | ligi | 73 | //#endif |
74 | |||
75 | |||
211 | ligi | 76 | gps_format=din.readByte(); |
77 | speed_format=din.readByte(); |
||
78 | |||
214 | ligi | 79 | expert_mode=din.readBoolean(); |
211 | ligi | 80 | // reserve |
214 | ligi | 81 | |
211 | ligi | 82 | din.readBoolean(); |
83 | din.readBoolean(); |
||
84 | din.readByte(); |
||
85 | din.readByte(); |
||
86 | din.readByte(); |
||
87 | din.readUTF(); |
||
88 | din.readUTF(); |
||
89 | din.readUTF(); |
||
90 | |||
206 | ligi | 91 | for ( int i=0;i<5;i++) |
92 | { |
||
93 | act_proxy_ip[i]=din.readInt(); |
||
94 | act_conn_ip[i]=din.readInt(); |
||
95 | } |
||
96 | |||
97 | } |
||
98 | recStore.closeRecordStore(); |
||
99 | } |
||
100 | catch (Exception e) |
||
101 | { } |
||
102 | |||
103 | } |
||
104 | |||
105 | |||
106 | |||
107 | public void save() |
||
108 | { |
||
109 | try |
||
110 | { |
||
111 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
||
112 | } |
||
113 | catch (Exception e) |
||
114 | { } |
||
115 | |||
116 | try { |
||
117 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
||
118 | |||
119 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
||
120 | DataOutputStream dout = new DataOutputStream( bout ); |
||
121 | |||
122 | dout.writeUTF(connection_url); |
||
123 | dout.writeUTF(connection_name); |
||
124 | dout.writeByte(act_skin); |
||
125 | dout.writeBoolean(do_sound); |
||
126 | dout.writeBoolean(do_vibra); |
||
127 | dout.writeBoolean(do_scrollbg); |
||
128 | dout.writeBoolean(fullscreen); |
||
129 | //#if devicecontrol=="on" |
||
130 | dout.writeBoolean(keep_lighton); |
||
211 | ligi | 131 | //#else |
132 | dout.writeBoolean(false); |
||
206 | ligi | 133 | //#endif |
134 | |||
211 | ligi | 135 | dout.writeByte(gps_format); |
136 | dout.writeByte(speed_format); |
||
137 | |||
214 | ligi | 138 | dout.writeBoolean( expert_mode); |
211 | ligi | 139 | dout.writeBoolean(false); |
140 | dout.writeBoolean(false); |
||
141 | dout.writeByte(0); |
||
142 | dout.writeByte(0); |
||
143 | dout.writeByte(0); |
||
144 | dout.writeUTF(""); |
||
145 | dout.writeUTF(""); |
||
146 | dout.writeUTF(""); |
||
147 | |||
148 | |||
149 | |||
206 | ligi | 150 | for ( int i=0;i<5;i++) |
151 | { |
||
152 | dout.writeInt(act_proxy_ip[i]); |
||
153 | dout.writeInt(act_conn_ip[i]); |
||
154 | } |
||
155 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
||
156 | |||
157 | recStore.closeRecordStore(); |
||
158 | |||
159 | |||
160 | } |
||
161 | catch (Exception e) |
||
162 | { } |
||
163 | |||
164 | } |
||
165 | |||
166 | } |