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