View Javadoc

1   /* ***** BEGIN LICENSE BLOCK *****
2    * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3    *
4    * The contents of this file are subject to the Mozilla Public License Version
5    * 1.1 (the "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    * http://www.mozilla.org/MPL/
8    *
9    * Software distributed under the License is distributed on an "AS IS" basis,
10   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11   * for the specific language governing rights and limitations under the
12   * License.
13   *
14   * The Original Code is "SMS Library for the Java platform".
15   *
16   * The Initial Developer of the Original Code is Markus Eriksson.
17   * Portions created by the Initial Developer are Copyright (C) 2002
18   * the Initial Developer. All Rights Reserved.
19   *
20   * Contributor(s):
21   *
22   * Alternatively, the contents of this file may be used under the terms of
23   * either the GNU General Public License Version 2 or later (the "GPL"), or
24   * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25   * in which case the provisions of the GPL or the LGPL are applicable instead
26   * of those above. If you wish to allow use of your version of this file only
27   * under the terms of either the GPL or the LGPL, and not to allow others to
28   * use your version of this file under the terms of the MPL, indicate your
29   * decision by deleting the provisions above and replace them with the notice
30   * and other provisions required by the GPL or the LGPL. If you do not delete
31   * the provisions above, a recipient may use your version of this file under
32   * the terms of any one of the MPL, the GPL or the LGPL.
33   *
34   * ***** END LICENSE BLOCK ***** */
35  package org.marre.wap.nokia;
36  
37  import java.io.IOException;
38  import java.io.OutputStream;
39  import java.util.Iterator;
40  import java.util.LinkedList;
41  import java.util.List;
42  
43  import org.marre.wap.wbxml.WbxmlDocument;
44  import org.marre.wap.wbxml.WbxmlWriter;
45  import org.marre.xml.XmlWriter;
46  
47  public class NokiaOtaBrowserSettings implements WbxmlDocument
48  {    
49      public static final String WBXML_SETTINGS_CONTENT_TYPE = "application/x-wap-prov.browser-settings";
50      public static final String XML_SETTINGS_CONTENT_TYPE = "application/x-wap-prov.browser-settings";
51      public static final String XML_BOOKMARKS_CONTENT_TYPE = "application/x-wap-prov.browser-bookmarks";
52          
53      public static final String[] OTA_TAG_TOKENS = {
54          "CHARACTERISTIC-LIST", // 05
55          "CHARACTERISTIC", // 06
56          "PARM", // 07
57      };
58  
59      public static final String[] OTA_ATTR_START_TOKENS = {
60          "", // 05
61          "TYPE=ADDRESS", // 06
62          "TYPE=URL", // 07
63          "TYPE=NAME", // 08
64          "", // 09
65          "", // 0A
66          "", // 0B
67          "", // 0C
68          "", // 0D
69          "", // 0E
70          "", // 0F
71          "NAME", // 10
72          "VALUE", // 11
73          "NAME=BEARER", // 12
74          "NAME=PROXY", //13
75          "NAME=PORT", //14
76          "NAME=NAME", //15
77          "NAME=PROXY_TYPE", //16
78          "NAME=URL", //17
79          "NAME=PROXY_AUTHNAME", //18
80          "NAME=PROXY_AUTHSECRET", //19
81          "NAME=SMS_SMSC_ADDRESS", //1A
82          "NAME=USSD_SERVICE_CODE", //1B
83          "NAME=GPRS_ACCESSPOINTNAME", //1C
84          "NAME=PPP_LOGINTYPE", //1D
85          "NAME=PROXY_LOGINTYPE", //1E
86          "", //1F
87          "", //20
88          "NAME=CSD_DIALSTRING", //21
89          "NAME=PPP_AUTHTYPE", //22
90          "NAME=PPP_AUTHNAME", //23
91          "NAME=PPP_AUTHSECRET", //24
92          "", //25
93          "", //26
94          "", //27
95          "NAME=CSD_CALLTYPE", //28
96          "NAME=CSD_CALLSPEED", //29
97          "", //2A
98          "", //2B
99          "", //2C
100         "", //2D
101         "", //2E
102         "", //2F
103         "", //30
104         "", //31
105         "", //32
106         "", //33
107         "", //34
108         "", //35
109         "", //36
110         "", //37
111         "", //38
112         "", //39
113         "", //3A
114         "", //3B
115         "", //3C
116         "", //3D
117         "", //3E
118         "", //3F
119         "", //40
120         "", //41
121         "", //42
122         "", //43
123         "", //44
124         "VALUE=GSM/CSD", //45
125         "VALUE=GSM/SMS", //46
126         "VALUE=GSM/USSD", //47
127         "VALUE=IS-136/CSD", //48
128         "VALUE=GPRS", //49
129         "", //4A
130         "", //4B
131         "", //4C
132         "", //4D
133         "", //4E
134         "", //4F
135         "", //50
136         "", //51
137         "", //52
138         "", //53
139         "", //54
140         "", //55
141         "", //56
142         "", //57
143         "", //58
144         "", //59
145         "", //5A
146         "", //5B
147         "", //5C
148         "", //5D
149         "", //5E
150         "", //5F
151         "VALUE=9200", //60
152         "VALUE=9201", //61
153         "VALUE=9202", //62
154         "VALUE=9203", //63
155         "VALUE=AUTOMATIC", //64
156         "VALUE=MANUAL", //65
157         "", //66
158         "", //67
159         "", //68
160         "", //69
161         "VALUE=AUTO", //6A
162         "VALUE=9600", //6B
163         "VALUE=14400", //6C
164         "VALUE=19200", //6D
165         "VALUE=28800", //6E
166         "VALUE=38400", //6F
167         "VALUE=PAP", //70
168         "VALUE=CHAP", //71
169         "VALUE=ANALOGUE", //72
170         "VALUE=ISDN", //73
171         "VALUE=43200", //74
172         "VALUE=57600", //75
173         "VALUE=MSISDN_NO", //76
174         "VALUE=IPV4", //77
175         "VALUE=MSCHAP", //78
176         "", //79
177         "", //7A
178         "", //7B
179         "TYPE=MMSURL", //7C
180         "TYPE=ID", //7D
181         "NAME=ISPNAME", //7E
182         "TYPE=BOOKMARK", //7F
183     };
184 
185     public static final String[] OTA_ATTR_VALUE_TOKENS = {
186         "", // 85
187         "", // 86
188         "", // 87
189     };
190 
191     /* ADDRESS, URL, NAME, ID, MMSURL, BOOKMARK */
192     
193     /* ADDRESS: 
194      *  BEARER
195      *  PPP_AUTHTYPE    
196      *  PPP_AUTHSECRET
197      *  PPP_LOGINTYPE
198      *  PROXY
199      *  PROXY_TYPE
200      *  PROXY_AUTHNAME
201      *  PROXY_AUTHSECRET
202      *  PROXY_LOGINTYPE
203      *  PORT
204      *  CSD_DIALSTRING
205      *  CSD_CALLTYPE
206      *  CSD_CALLSPEED
207      *  ISP_NAME
208      *  SMS_SMSC_ADDRESS
209      *  USSD_SERVICE_CODE
210      *  GPRS_ACCESSPOINTNAME
211      */
212     
213     /*
214      * URL or MMSURL:
215      */
216     
217     /*
218      * NAME:
219      */
220     
221     /*
222      * BOOKMARK:
223      *  NAME
224      *  URL
225      */
226     protected List myBookmarks;
227     
228     /*
229      * ID:
230      */
231     
232     public NokiaOtaBrowserSettings()
233     {
234         myBookmarks = new LinkedList();
235     }
236     
237     protected void writeBookmarksTo(XmlWriter xmlWriter) throws IOException
238     {
239         Iterator bookmarkIterator = myBookmarks.iterator();
240         
241         while (bookmarkIterator.hasNext())
242         {
243             NokiaOtaBookmark otaBookmark = (NokiaOtaBookmark)bookmarkIterator.next();
244             otaBookmark.writeXmlTo(xmlWriter);
245         }
246     }
247     
248     public void addBookmark(String name, String url)
249     {
250         myBookmarks.add(new NokiaOtaBookmark(name, url));
251     }
252 
253     public String getContentType()
254     {
255         return XML_SETTINGS_CONTENT_TYPE;
256     }
257     
258     public String getWbxmlContentType()
259     {
260         return WBXML_SETTINGS_CONTENT_TYPE;
261     }
262 
263     public XmlWriter getWbxmlWriter(OutputStream os)
264     {
265         return new WbxmlWriter(os, OTA_TAG_TOKENS, OTA_ATTR_START_TOKENS, OTA_ATTR_VALUE_TOKENS);
266     }
267     
268     public void writeXmlTo(XmlWriter xmlWriter) throws IOException
269     {
270         xmlWriter.setDoctype("CHARACTERISTIC-LIST", "/DTD/characteristic_list.xml");
271         
272         // <CHARACTERISTIC-LIST>
273         xmlWriter.addStartElement("CHARACTERISTIC-LIST");
274         
275         // <CHARACTERISTIC TYPE="BOOKMARK"> ...
276         writeBookmarksTo(xmlWriter);
277         
278         // </CHARACTERISTIC-LIST>
279         xmlWriter.flush();
280     }
281 }