Rev 206 | Rev 214 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 206 | Rev 211 | ||
---|---|---|---|
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 | implements org.ligi.ufo.DUBwiseDefinitions |
16 | implements org.ligi.ufo.DUBwiseDefinitions,DUBwiseUIDefinitions |
17 | { |
17 | { |
18 | // name/handle for the recordStore to memorize some stuff |
18 | // name/handle for the recordStore to memorize some stuff |
19 | private final static String RECORD_STORE_NAME="DUBSETT_V2"; |
19 | private final static String RECORD_STORE_NAME="DUBSETT_V3"; |
20 | - | ||
21 | 20 | ||
22 | /* all settings hold here */ |
21 | /* all settings hold here */ |
23 | //holds id of actual skin |
22 | //holds id of actual skin |
24 | public byte act_skin=SKINID_DARK; |
23 | public byte act_skin=SKINID_DARK; |
25 | 24 | ||
26 | public String connection_name=""; |
25 | public String connection_name=""; |
27 | public String connection_url=""; |
26 | public String connection_url=""; |
28 | 27 | ||
29 | public boolean do_vibra=true; |
28 | public boolean do_vibra=true; |
30 | public boolean do_sound=true; |
29 | public boolean do_sound=true; |
31 | public boolean fullscreen=false; |
30 | public boolean fullscreen=false; |
32 | public boolean do_scrollbg=false; |
31 | public boolean do_scrollbg=false; |
33 | 32 | ||
- | 33 | ||
- | 34 | public byte gps_format=GPS_FORMAT_DECIMAL; |
|
- | 35 | public byte speed_format=SPEED_FORMAT_KMH; |
|
- | 36 | ||
- | 37 | ||
34 | 38 | ||
35 | //#if devicecontrol=="on" |
39 | //#if devicecontrol=="on" |
36 | public boolean keep_lighton=false; |
40 | public boolean keep_lighton=false; |
37 | //#endif |
41 | //#endif |
38 | 42 | ||
39 | int[] act_proxy_ip=default_ip; // { ip , ip , ip , ip , port } |
43 | int[] act_proxy_ip=default_ip; // { ip , ip , ip , ip , port } |
40 | int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port } |
44 | int[] act_conn_ip=default_ip; // { ip , ip , ip , ip , port } |
41 | 45 | ||
42 | /* end of all settings hold here */ |
46 | /* end of all settings hold here */ |
43 | 47 | ||
44 | public DUBwiseSettings() |
48 | public DUBwiseSettings() |
45 | { |
49 | { |
46 | try |
50 | try |
47 | { |
51 | { |
48 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
52 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME , true ); |
49 | 53 | ||
50 | if (recStore.getNumRecords()==1) |
54 | if (recStore.getNumRecords()==1) |
51 | { |
55 | { |
52 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
56 | ByteArrayInputStream bin = new ByteArrayInputStream(recStore.getRecord(1)); |
53 | DataInputStream din = new DataInputStream( bin ); |
57 | DataInputStream din = new DataInputStream( bin ); |
54 | 58 | ||
55 | 59 | ||
56 | connection_url=din.readUTF(); |
60 | connection_url=din.readUTF(); |
57 | connection_name=din.readUTF(); |
61 | connection_name=din.readUTF(); |
58 | act_skin=din.readByte(); |
62 | act_skin=din.readByte(); |
59 | 63 | ||
60 | do_sound=din.readBoolean(); |
64 | do_sound=din.readBoolean(); |
61 | do_vibra=din.readBoolean(); |
65 | do_vibra=din.readBoolean(); |
62 | do_scrollbg=din.readBoolean(); |
66 | do_scrollbg=din.readBoolean(); |
63 | fullscreen=din.readBoolean(); |
67 | fullscreen=din.readBoolean(); |
64 | //#if devicecontrol=="on" |
68 | //#if devicecontrol=="on" |
65 | keep_lighton=din.readBoolean(); |
69 | keep_lighton=din.readBoolean(); |
- | 70 | //#else |
|
- | 71 | din.readBoolean(); |
|
66 | //#endif |
72 | //#endif |
67 | 73 | ||
- | 74 | ||
- | 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(); |
|
68 | 88 | ||
69 | for ( int i=0;i<5;i++) |
89 | for ( int i=0;i<5;i++) |
70 | { |
90 | { |
71 | act_proxy_ip[i]=din.readInt(); |
91 | act_proxy_ip[i]=din.readInt(); |
72 | act_conn_ip[i]=din.readInt(); |
92 | act_conn_ip[i]=din.readInt(); |
73 | } |
93 | } |
74 | 94 | ||
75 | } |
95 | } |
76 | recStore.closeRecordStore(); |
96 | recStore.closeRecordStore(); |
77 | } |
97 | } |
78 | catch (Exception e) |
98 | catch (Exception e) |
79 | { } |
99 | { } |
80 | 100 | ||
81 | } |
101 | } |
82 | 102 | ||
83 | 103 | ||
84 | 104 | ||
85 | public void save() |
105 | public void save() |
86 | { |
106 | { |
87 | try |
107 | try |
88 | { |
108 | { |
89 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
109 | RecordStore.deleteRecordStore(RECORD_STORE_NAME); |
90 | } |
110 | } |
91 | catch (Exception e) |
111 | catch (Exception e) |
92 | { } |
112 | { } |
93 | 113 | ||
94 | try { |
114 | try { |
95 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
115 | RecordStore recStore = RecordStore.openRecordStore(RECORD_STORE_NAME, true ); |
96 | 116 | ||
97 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
117 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); |
98 | DataOutputStream dout = new DataOutputStream( bout ); |
118 | DataOutputStream dout = new DataOutputStream( bout ); |
99 | 119 | ||
100 | dout.writeUTF(connection_url); |
120 | dout.writeUTF(connection_url); |
101 | dout.writeUTF(connection_name); |
121 | dout.writeUTF(connection_name); |
102 | dout.writeByte(act_skin); |
122 | dout.writeByte(act_skin); |
103 | dout.writeBoolean(do_sound); |
123 | dout.writeBoolean(do_sound); |
104 | dout.writeBoolean(do_vibra); |
124 | dout.writeBoolean(do_vibra); |
105 | dout.writeBoolean(do_scrollbg); |
125 | dout.writeBoolean(do_scrollbg); |
106 | dout.writeBoolean(fullscreen); |
126 | dout.writeBoolean(fullscreen); |
107 | //#if devicecontrol=="on" |
127 | //#if devicecontrol=="on" |
108 | dout.writeBoolean(keep_lighton); |
128 | dout.writeBoolean(keep_lighton); |
- | 129 | //#else |
|
- | 130 | dout.writeBoolean(false); |
|
109 | //#endif |
131 | //#endif |
- | 132 | ||
- | 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 | ||
110 | 147 | ||
111 | for ( int i=0;i<5;i++) |
148 | for ( int i=0;i<5;i++) |
112 | { |
149 | { |
113 | dout.writeInt(act_proxy_ip[i]); |
150 | dout.writeInt(act_proxy_ip[i]); |
114 | dout.writeInt(act_conn_ip[i]); |
151 | dout.writeInt(act_conn_ip[i]); |
115 | } |
152 | } |
116 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
153 | recStore.addRecord(bout.toByteArray(),0,bout.size()); |
117 | 154 | ||
118 | recStore.closeRecordStore(); |
155 | recStore.closeRecordStore(); |
119 | 156 | ||
120 | 157 | ||
121 | } |
158 | } |
122 | catch (Exception e) |
159 | catch (Exception e) |
123 | { } |
160 | { } |
124 | 161 | ||
125 | } |
162 | } |
126 | 163 | ||
127 | } |
164 | } |
128 | 165 |