Rev 222 | Rev 233 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 222 | Rev 229 | ||
---|---|---|---|
1 | /*************************************************************** |
1 | /*************************************************************** |
2 | * |
2 | * |
3 | * Settings related Part of DUBwise |
3 | * Settings related Part of DUBwise |
4 | * ( e.g. saving to / reading from RMS ) |
4 | * ( e.g. saving to / reading from RMS ) |
5 | * |
5 | * |
6 | * Author: Marcus -LiGi- Bueschleb |
6 | * Author: Marcus -LiGi- Bueschleb |
7 | * Mailto: LiGi @at@ LiGi DOTT de |
7 | * Mailto: LiGi @at@ LiGi DOTT de |
8 | * |
8 | * |
9 | ***************************************************************/ |
9 | ***************************************************************/ |
10 | 10 | ||
11 | import javax.microedition.rms.*; |
11 | import javax.microedition.rms.*; |
12 | 12 | ||
13 | import java.io.*; |
13 | import java.io.*; |
14 | 14 | ||
15 | public class DUBwiseSettings |
15 | public class DUBwiseSettings |
16 | extends org.ligi.ufo.ParamsClass |
16 | extends org.ligi.ufo.ParamsClass |
17 | implements org.ligi.ufo.DUBwiseDefinitions,DUBwiseUIDefinitions |
17 | implements org.ligi.ufo.DUBwiseDefinitions,DUBwiseUIDefinitions |
18 | { |
18 | { |
19 | // name/handle for the recordStore to memorize some stuff |
19 | // name/handle for the recordStore to memorize some stuff |
20 | private final static String RECORD_STORE_NAME="DUBSETT_V4"; |
20 | private final static String RECORD_STORE_NAME="DUBSETT_V4"; |
21 | 21 | ||
22 | /* all settings hold here */ |
22 | /* all settings hold here */ |
23 | //holds id of actual skin |
23 | //holds id of actual skin |
24 | public byte act_skin=SKINID_DARK; |
24 | public byte act_skin=SKINID_DARK; |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | public int key_back; |
28 | public int key_back; |
29 | public int key_fullscreen; |
29 | public int key_fullscreen; |
30 | public int key_clear; |
30 | public int key_clear; |
- | 31 | ||
- | 32 | public int voice_delay; |
|
- | 33 | public int voice_volume; |
|
- | 34 | ||
- | 35 | ||
31 | 36 | ||
32 | public int remote_cam_stick; |
37 | public int remote_cam_stick; |
33 | 38 | ||
34 | public String connection_name=""; |
39 | public String connection_name=""; |
35 | public String connection_url=""; |
40 | public String connection_url=""; |
36 | 41 | ||
37 | public boolean do_vibra=true; |
42 | public boolean do_vibra=true; |
38 | public boolean do_sound=true; |
43 | public boolean do_sound=true; |
39 | public boolean fullscreen=false; |
44 | public boolean fullscreen=false; |
40 | public boolean do_scrollbg=false; |
45 | public boolean do_scrollbg=false; |
41 | public boolean expert_mode=false; |
46 | public boolean expert_mode=false; |
- | 47 | ||
- | 48 | public boolean reload_settings=false; |
|
- | 49 | ||
- | 50 | ||
- | 51 | public boolean graph_legend; |
|
- | 52 | public boolean graph_scale; |
|
42 | 53 | ||
43 | //#if devicecontrol=="on" |
54 | //#if devicecontrol=="on" |
44 | public boolean keep_lighton=false; |
55 | public boolean keep_lighton=false; |
45 | //#endif |
56 | //#endif |
46 | 57 | ||
47 | int[] act_proxy_ip=default_ip; // { ip , ip , ip , ip , port } |
58 | int[] act_proxy_ip=default_ip; // { ip , ip , ip , ip , port } |
48 | int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port } |
59 | int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port } |
49 | 60 | ||
50 | 61 | ||
51 | public byte gps_format=GPS_FORMAT_DECIMAL; |
62 | public byte gps_format=GPS_FORMAT_DECIMAL; |
52 | public byte speed_format=SPEED_FORMAT_KMH; |
63 | public byte speed_format=SPEED_FORMAT_KMH; |
53 | 64 | ||
54 | 65 | ||
55 | int[] settings_field; |
66 | int[] settings_field; |
56 | 67 | ||
57 | public int get_field_from_act(int pos) { return settings_field[pos];} |
68 | public int get_field_from_act(int pos) { return settings_field[pos];} |
58 | public void set_field_from_act(int pos,int val){ |
69 | public void set_field_from_act(int pos,int val){ |
59 | 70 | ||
60 | settings_field[pos]=val; |
71 | settings_field[pos]=val; |
61 | field2setting(pos,val); |
72 | field2setting(pos,val); |
62 | } |
73 | } |
63 | 74 | ||
64 | public void toggle_fullscreen() |
75 | public void toggle_fullscreen() |
65 | { |
76 | { |
66 | // fullscreen=!fullscreen; |
77 | // fullscreen=!fullscreen; |
67 | set_field_from_act(1,settings_field[1]^1); |
78 | set_field_from_act(1,settings_field[1]^1); |
68 | // if (fullscreen)canvas.setFullScreenMode(true); |
79 | // if (fullscreen)canvas.setFullScreenMode(true); |
69 | } |
80 | } |
70 | 81 | ||
71 | public final static int SETTINGS_POS_SKIN=0; |
82 | public final static int SETTINGS_POS_SKIN=0; |
72 | public final static int SETTINGS_POS_BITFIELD1=1; |
83 | public final static int SETTINGS_POS_BITFIELD1=1; |
73 | public final static int SETTINGS_POS_GPS_FORMAT=2; |
84 | public final static int SETTINGS_POS_GPS_FORMAT=2; |
74 | public final static int SETTINGS_POS_SPEED_FORMAT=3; |
85 | public final static int SETTINGS_POS_SPEED_FORMAT=3; |
75 | public final static int SETTINGS_POS_EXTERN_NICK=4; |
86 | public final static int SETTINGS_POS_EXTERN_NICK=4; |
76 | public final static int SETTINGS_POS_EXTERN_ROLL=5; |
87 | public final static int SETTINGS_POS_EXTERN_ROLL=5; |
77 | public final static int SETTINGS_POS_EXTERN_GIER=6; |
88 | public final static int SETTINGS_POS_EXTERN_GIER=6; |
78 | public final static int SETTINGS_POS_EXTERN_GAS=7; |
89 | public final static int SETTINGS_POS_EXTERN_GAS=7; |
79 | public final static int SETTINGS_POS_EXTERN_HIGHT=8; |
90 | public final static int SETTINGS_POS_EXTERN_HIGHT=8; |
80 | public final static int SETTINGS_POS_KEY_BACK=9; |
91 | public final static int SETTINGS_POS_KEY_BACK=9; |
81 | public final static int SETTINGS_POS_KEY_FULL=10; |
92 | public final static int SETTINGS_POS_KEY_FULL=10; |
82 | public final static int SETTINGS_POS_KEY_CLEAR=11; |
93 | public final static int SETTINGS_POS_KEY_CLEAR=11; |
- | 94 | public final static int SETTINGS_POS_VOICEVOLUME=12; |
|
- | 95 | public final static int SETTINGS_POS_VOICEDELAY=13; |
|
- | 96 | public final static int SETTINGS_POS_BITFIELD2=14; |
|
83 | 97 | ||
84 | 98 | ||
85 | public void field2setting(int pos,int val) |
99 | public void field2setting(int pos,int val) |
86 | { |
100 | { |
87 | 101 | ||
88 | if (pos==SETTINGS_POS_SKIN) |
102 | if (pos==SETTINGS_POS_SKIN) |
89 | { |
103 | { |
90 | act_skin=(byte)val; |
104 | act_skin=(byte)val; |
91 | canvas.load_skin_images(); |
105 | canvas.load_skin_images(); |
92 | } |
106 | } |
93 | 107 | ||
94 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&1)==1)&&(!fullscreen)) |
108 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&1)==1)&&(!fullscreen)) |
95 | { |
109 | { |
96 | fullscreen=true; |
110 | fullscreen=true; |
97 | canvas.setFullScreenMode(fullscreen); |
111 | canvas.setFullScreenMode(fullscreen); |
98 | } |
112 | } |
99 | 113 | ||
100 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&1)==0)&&(fullscreen)) |
114 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&1)==0)&&(fullscreen)) |
101 | { |
115 | { |
102 | fullscreen=false; |
116 | fullscreen=false; |
103 | canvas.setFullScreenMode(fullscreen); |
117 | canvas.setFullScreenMode(fullscreen); |
104 | } |
118 | } |
105 | 119 | ||
106 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&2)==2)&&(!do_scrollbg)) |
120 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&2)==2)&&(!do_scrollbg)) |
107 | { |
121 | { |
108 | do_scrollbg=true; |
122 | do_scrollbg=true; |
109 | canvas.load_skin_images(); |
123 | canvas.load_skin_images(); |
110 | } |
124 | } |
111 | 125 | ||
112 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&2)==0)&&(do_scrollbg)) |
126 | if ((pos==SETTINGS_POS_BITFIELD1)&&((val&2)==0)&&(do_scrollbg)) |
113 | { |
127 | { |
114 | do_scrollbg=false; |
128 | do_scrollbg=false; |
115 | canvas.load_skin_images(); |
129 | canvas.load_skin_images(); |
116 | } |
130 | } |
- | 131 | ||
117 | 132 | ||
118 | if (pos==SETTINGS_POS_BITFIELD1) |
133 | if (pos==SETTINGS_POS_BITFIELD1) |
119 | do_sound=((val&4)!=0); |
134 | do_sound=((val&4)!=0); |
120 | 135 | ||
121 | if (pos==SETTINGS_POS_BITFIELD1) |
136 | if (pos==SETTINGS_POS_BITFIELD1) |
122 | do_vibra=((val&8)!=0); |
137 | do_vibra=((val&8)!=0); |
123 | 138 | ||
124 | if (pos==SETTINGS_POS_BITFIELD1) |
139 | if (pos==SETTINGS_POS_BITFIELD1) |
125 | expert_mode=((val&16)!=0); |
140 | expert_mode=((val&16)!=0); |
126 | 141 | ||
127 | if (pos==SETTINGS_POS_BITFIELD1) |
142 | if (pos==SETTINGS_POS_BITFIELD1) |
128 | keep_lighton=((val&32)!=0); |
143 | keep_lighton=((val&32)!=0); |
- | 144 | ||
- | 145 | if (pos==SETTINGS_POS_BITFIELD1) |
|
- | 146 | graph_legend=((val&64)!=0); |
|
- | 147 | ||
- | 148 | if (pos==SETTINGS_POS_BITFIELD1) |
|
- | 149 | graph_scale=((val&128)!=0); |
|
- | 150 | ||
- | 151 | ||
129 | 152 | ||
130 | if (pos==SETTINGS_POS_GPS_FORMAT) |
153 | if (pos==SETTINGS_POS_GPS_FORMAT) |
131 | gps_format=(byte)val; |
154 | gps_format=(byte)val; |
132 | 155 | ||
133 | if (pos==SETTINGS_POS_SPEED_FORMAT) |
156 | if (pos==SETTINGS_POS_SPEED_FORMAT) |
134 | speed_format=(byte)val; |
157 | speed_format=(byte)val; |
135 | 158 | ||
136 | if (pos==SETTINGS_POS_EXTERN_NICK) |
159 | if (pos==SETTINGS_POS_EXTERN_NICK) |
137 | default_extern_control[EXTERN_CONTROL_NICK]=(byte)val; |
160 | default_extern_control[EXTERN_CONTROL_NICK]=(byte)val; |
138 | 161 | ||
139 | if (pos==SETTINGS_POS_EXTERN_ROLL) |
162 | if (pos==SETTINGS_POS_EXTERN_ROLL) |
140 | default_extern_control[EXTERN_CONTROL_ROLL]=(byte)val; |
163 | default_extern_control[EXTERN_CONTROL_ROLL]=(byte)val; |
141 | 164 | ||
142 | if (pos==SETTINGS_POS_EXTERN_GIER) |
165 | if (pos==SETTINGS_POS_EXTERN_GIER) |
143 | default_extern_control[EXTERN_CONTROL_GIER]=(byte)val; |
166 | default_extern_control[EXTERN_CONTROL_GIER]=(byte)val; |
144 | 167 | ||
145 | if (pos==SETTINGS_POS_EXTERN_GAS) |
168 | if (pos==SETTINGS_POS_EXTERN_GAS) |
146 | default_extern_control[EXTERN_CONTROL_GAS]=(byte)val; |
169 | default_extern_control[EXTERN_CONTROL_GAS]=(byte)val; |
147 | 170 | ||
148 | if (pos==SETTINGS_POS_EXTERN_HIGHT) |
171 | if (pos==SETTINGS_POS_EXTERN_HIGHT) |
149 | default_extern_control[EXTERN_CONTROL_HIGHT]=(byte)val; |
172 | default_extern_control[EXTERN_CONTROL_HIGHT]=(byte)val; |
150 | 173 | ||
151 | 174 | ||
152 | if (pos==SETTINGS_POS_KEY_BACK) |
175 | if (pos==SETTINGS_POS_KEY_BACK) |
153 | key_back=val; |
176 | key_back=val; |
154 | 177 | ||
155 | if (pos==SETTINGS_POS_KEY_FULL) |
178 | if (pos==SETTINGS_POS_KEY_FULL) |
156 | key_fullscreen=val; |
179 | key_fullscreen=val; |
157 | 180 | ||
158 | if (pos==SETTINGS_POS_KEY_CLEAR) |
181 | if (pos==SETTINGS_POS_KEY_CLEAR) |
159 | key_clear=val; |
182 | key_clear=val; |
160 | 183 | ||
161 | if (pos==12) |
184 | if (pos==12) |
162 | remote_cam_stick=val; |
185 | remote_cam_stick=val; |
- | 186 | ||
- | 187 | ||
- | 188 | if(pos==SETTINGS_POS_VOICEVOLUME) |
|
- | 189 | { |
|
- | 190 | voice_volume=val; |
|
- | 191 | //#if voice_mode!="no_voice" |
|
- | 192 | canvas.status_voice.volume=voice_volume; |
|
- | 193 | ||
- | 194 | //#endif |
|
- | 195 | } |
|
- | 196 | if(pos==SETTINGS_POS_VOICEDELAY) |
|
- | 197 | { |
|
- | 198 | voice_delay=val; |
|
- | 199 | //#if voice_mode!="no_voice" |
|
- | 200 | canvas.status_voice.delay=voice_delay; |
|
- | 201 | ||
- | 202 | //#endif |
|
- | 203 | } |
|
- | 204 | ||
- | 205 | if (pos==SETTINGS_POS_BITFIELD2) |
|
- | 206 | do_sound=((val&1)!=0); // TODO: FIXME - extra var |
|
- | 207 | ||
- | 208 | if (pos==SETTINGS_POS_BITFIELD2) |
|
- | 209 | reload_settings=((val&2)!=0); |
|
163 | } |
210 | } |
164 | 211 | ||
165 | 212 | ||
166 | public byte[] default_extern_control;//=default_extern_keycontrol ; |
213 | public byte[] default_extern_control;//=default_extern_keycontrol ; |
167 | 214 | ||
168 | 215 | ||
169 | /* end of all settings hold here */ |
216 | /* end of all settings hold here */ |
170 | 217 | ||
171 | public String[] _tab_names={"User Interface","GPS","Keycontrol","Special Keys","Other" }; |
218 | public String[] _tab_names={"User Interface","GPS","Keycontrol","Special Keys","Graph","Voice","Other" }; |
172 | 219 | ||
173 | public String[][] _field_names={ { "Skin","Fullscreen","Scroll Background" |
220 | public String[][] _field_names={ { "Skin","Fullscreen","Scroll Background" |
174 | //#if devicecontrol=="on" |
221 | //#if devicecontrol=="on" |
175 | ,"Permanent Light" |
222 | ,"Permanent Light" |
176 | //#endif |
223 | //#endif |
177 | } , {"GPS Format","Speed Format"},{"Nick","Roll","Gier","Gas Increase","Height Increase"},{"Back","Fullscreen","Clear"},{"Sound","Vibra","Remote Cam Stick","Expert-Mode"} }; |
224 | } , {"GPS Format","Speed Format"},{"Nick","Roll","Gier","Gas Increase","Height Increase"},{"Back to Main-Menu","Fullscreen","Clear"},{"Legend","Scale-Grid"},{"Volts Output","Delay in Seconds","Volume"},{"Sound","Vibra","Remote Cam Stick","Always Reload Params","Expert-Mode"} }; |
178 | 225 | ||
179 | public String[][] _choice_strings={ { "Dark","Light" } , {"km/h","mp/h","cm/s"},{"decimal","min sec"}} ; |
226 | public String[][] _choice_strings={ { "Dark","Light" } , {"km/h","mp/h","cm/s"},{"decimal","min sec"}} ; |
180 | public int[][] _field_positions={ {SETTINGS_POS_SKIN,8,9 |
227 | public int[][] _field_positions={ {SETTINGS_POS_SKIN,8,9 |
181 | //#if devicecontrol=="on" |
228 | //#if devicecontrol=="on" |
182 | ,13 |
229 | ,13 |
183 | //#endif |
230 | //#endif |
184 | } , {2,3} , {4,5,6,7,8} , {9,10,11}, {10,11,12,12}}; |
231 | } , {2,3} , {4,5,6,7,8} , {9,10,11},{SETTINGS_POS_BITFIELD1*8 +6,SETTINGS_POS_BITFIELD1*8 +7} ,{SETTINGS_POS_BITFIELD2+0,SETTINGS_POS_VOICEDELAY,SETTINGS_POS_VOICEVOLUME }, {10,11,12,SETTINGS_POS_BITFIELD2+1,12}}; |
185 | public int[][] _field_types={ {PARAMTYPE_CHOICE+0,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH |
232 | public int[][] _field_types={ {PARAMTYPE_CHOICE+0,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH |
186 | //#if devicecontrol=="on" |
233 | //#if devicecontrol=="on" |
187 | ,PARAMTYPE_BITSWITCH |
234 | ,PARAMTYPE_BITSWITCH |
188 | //#endif |
235 | //#endif |
189 | } , {PARAMTYPE_CHOICE+1,PARAMTYPE_CHOICE+2} , {PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}, {PARAMTYPE_KEY,PARAMTYPE_KEY,PARAMTYPE_KEY} , {PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_STICK,PARAMTYPE_BITSWITCH}}; |
236 | } , {PARAMTYPE_CHOICE+1,PARAMTYPE_CHOICE+2} , {PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE,PARAMTYPE_BYTE}, {PARAMTYPE_KEY,PARAMTYPE_KEY,PARAMTYPE_KEY} , {PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH}, {PARAMTYPE_BITSWITCH,PARAMTYPE_BYTE,PARAMTYPE_BYTE}, {PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH,PARAMTYPE_STICK,PARAMTYPE_BITSWITCH,PARAMTYPE_BITSWITCH}}; |
190 | DUBwiseCanvas canvas; |
237 | DUBwiseCanvas canvas; |
- | 238 | ||
191 | 239 | ||
192 | 240 | ||
193 | public final static int SETTINGS_FIELD_LENGTH=42; |
241 | public final static int SETTINGS_FIELD_LENGTH=42; |
194 | public DUBwiseSettings(DUBwiseCanvas _canvas) |
242 | public DUBwiseSettings(DUBwiseCanvas _canvas) |
195 | { |
243 | { |
196 | canvas= _canvas; |
244 | canvas= _canvas; |
197 | settings_field=new int[SETTINGS_FIELD_LENGTH]; |
245 | settings_field=new int[SETTINGS_FIELD_LENGTH]; |
198 | default_extern_control=new byte[11]; |
246 | default_extern_control=new byte[11]; |
199 | // set defaults |
247 | // set defaults |
200 | settings_field[4]=42; // nick |
248 | settings_field[4]=42; // nick |
201 | settings_field[5]=42; // roll |
249 | settings_field[5]=42; // roll |
202 | settings_field[6]=42; // gier |
250 | settings_field[6]=42; // gier |
203 | settings_field[7]=1; // fas |
251 | settings_field[7]=1; // fas |
204 | settings_field[8]=1; // hight |
252 | settings_field[8]=1; // hight |
205 | 253 | ||
206 | 254 | ||
207 | settings_field[9]=-4242; // no key |
255 | settings_field[9]=-4242; // no key |
208 | settings_field[10]=-4242; // no key |
256 | settings_field[10]=-4242; // no key |
209 | settings_field[11]=-4242; // no key |
257 | settings_field[11]=-4242; // no key |
210 | 258 | ||
211 | } |
259 | } |
212 | 260 | ||
213 | public void load() |
261 | public void load() |
214 | { |
262 | { |
215 | 263 | ||
216 | tab_names=_tab_names; |
264 | tab_names=_tab_names; |
217 | field_names=_field_names; |
265 | field_names=_field_names; |
218 | field_positions=_field_positions; |
266 | field_positions=_field_positions; |
219 | field_types=_field_types; |
267 | field_types=_field_types; |
220 | choice_strings=_choice_strings; |
268 | choice_strings=_choice_strings; |
221 | try |
269 | try |
222 | { |
270 | { |
223 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
271 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
224 | 272 | ||
225 | if (recStore.getNumRecords()==1) |
273 | if (recStore.getNumRecords()==1) |
226 | { |
274 | { |
227 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
275 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
228 | DataInputStream din = new DataInputStream( bin ); |
276 | DataInputStream din = new DataInputStream( bin ); |
229 | 277 | ||
230 | 278 | ||
231 | connection_url=din.readUTF(); |
279 | connection_url=din.readUTF(); |
232 | connection_name=din.readUTF(); |
280 | connection_name=din.readUTF(); |
233 | // reserve utf's |
281 | // reserve utf's |
234 | din.readUTF(); |
282 | din.readUTF(); |
235 | din.readUTF(); |
283 | din.readUTF(); |
236 | din.readUTF(); |
284 | din.readUTF(); |
237 | 285 | ||
238 | 286 | ||
239 | 287 | ||
240 | for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++) |
288 | for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++) |
241 | settings_field[i]=din.readInt(); |
289 | settings_field[i]=din.readInt(); |
242 | 290 | ||
243 | for ( int i=0;i<5;i++) |
291 | for ( int i=0;i<5;i++) |
244 | 292 | ||
245 | { |
293 | { |
246 | act_proxy_ip[i]=din.readInt(); |
294 | act_proxy_ip[i]=din.readInt(); |
247 | act_conn_ip[i]=din.readInt(); |
295 | act_conn_ip[i]=din.readInt(); |
248 | } |
296 | } |
249 | 297 | ||
250 | } |
298 | } |
251 | recStore.closeRecordStore(); |
299 | recStore.closeRecordStore(); |
252 | } |
300 | } |
253 | catch (Exception e) |
301 | catch (Exception e) |
254 | { } |
302 | { } |
255 | 303 | ||
256 | 304 | ||
257 | for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++) |
305 | for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++) |
258 | field2setting(i,settings_field[i]); |
306 | field2setting(i,settings_field[i]); |
259 | 307 | ||
260 | } |
308 | } |
261 | 309 | ||
262 | 310 | ||
263 | public void save() |
311 | public void save() |
264 | { |
312 | { |
265 | try |
313 | try |
266 | { |
314 | { |
267 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
315 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
268 | } |
316 | } |
269 | catch (Exception e) |
317 | catch (Exception e) |
270 | { } |
318 | { } |
271 | 319 | ||
272 | try { |
320 | try { |
273 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
321 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
274 | 322 | ||
275 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
323 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
276 | DataOutputStream dout = new DataOutputStream( bout ); |
324 | DataOutputStream dout = new DataOutputStream( bout ); |
277 | 325 | ||
278 | dout.writeUTF(connection_url); |
326 | dout.writeUTF(connection_url); |
279 | dout.writeUTF(connection_name); |
327 | dout.writeUTF(connection_name); |
280 | 328 | ||
281 | dout.writeUTF(""); |
329 | dout.writeUTF(""); |
282 | dout.writeUTF(""); |
330 | dout.writeUTF(""); |
283 | dout.writeUTF(""); |
331 | dout.writeUTF(""); |
284 | 332 | ||
285 | 333 | ||
286 | for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++) |
334 | for ( int i=0;i<SETTINGS_FIELD_LENGTH;i++) |
287 | dout.writeInt(settings_field[i]); |
335 | dout.writeInt(settings_field[i]); |
288 | for ( int i=0;i<5;i++) |
336 | for ( int i=0;i<5;i++) |
289 | { |
337 | { |
290 | dout.writeInt(act_proxy_ip[i]); |
338 | dout.writeInt(act_proxy_ip[i]); |
291 | dout.writeInt(act_conn_ip[i]); |
339 | dout.writeInt(act_conn_ip[i]); |
292 | } |
340 | } |
293 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
341 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
294 | 342 | ||
295 | recStore.closeRecordStore(); |
343 | recStore.closeRecordStore(); |
296 | 344 | ||
297 | 345 | ||
298 | } |
346 | } |
299 | catch (Exception e) |
347 | catch (Exception e) |
300 | { } |
348 | { } |
301 | 349 | ||
302 | } |
350 | } |
303 | 351 | ||
304 | } |
352 | } |
305 | 353 |