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