2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "MsgCppTypes.h"
19 #include "MsgGconfWrapper.h"
20 #include "MsgException.h"
21 #include "MsgUtilFile.h"
22 #include "SmsPluginStorage.h"
23 #include "SmsPluginTransport.h"
24 #include "SmsPluginEventHandler.h"
25 #include "SmsPluginWapPushHandler.h"
28 #include <drm_client.h>
29 #include <dbus/dbus-glib.h>
31 static unsigned short wapPushPortList [] = {0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F};
34 const SMS_PUSH_APP_INFO_S pushDefaultApplication [] =
36 {(char*)"text/vnd.wap.si", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SI},
37 {(char*)"application/vnd.wap.sic", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SIC},
38 {(char*)"text/vnd.wap.sl", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SL},
39 {(char*)"application/vnd.wap.slc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SLC},
40 {(char*)"text/vnd.wap.co", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_CO},
41 {(char*)"application/vnd.wap.coc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_COC},
43 {(char*)"application/vnd.wap.mms-message", (char*)"X-Wap-Application-Id: x-wap-application:mms.ua\r\n", SMS_WAP_APPLICATION_MMS_UA},
45 {(char*)"application/vnd.wap.sia", (char*)"X-Wap-Application-Id: x-wap-application:push.sia\r\n", SMS_WAP_APPLICATION_PUSH_SIA},
47 {(char*)"application/vnd.syncml.dm+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP},
48 {(char*)"application/vnd.syncml.dm+xml", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML},
49 {(char*)"application/vnd.syncml.notification", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION},
50 {(char*)"application/vnd.syncml.ds.notification", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.ds\r\n", SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION},
51 {(char*)"application/vnd.syncml+wbxml", (char*)"X-Wap-Application-Id:x-wap-application:push.syncml", SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML},
53 {(char*)"application/vnd.wap.locc+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_WBXML},
54 {(char*)"application/vnd.wap.loc+xml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_XML},
56 {(char*)"application/vnd.oma.dd+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_XML},
57 {(char*)"application/vnd.oma.drm.message", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_MESSAGE},
58 {(char*)"application/vnd.oma.drm.content", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_CONETENT},
59 {(char*)"application/vnd.oma.drm.rights+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML},
60 {(char*)"application/vnd.oma.drm.rights+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML},
61 {(char*)"application/vnd.oma.drm.ro+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_RO_XML},
62 {(char*)"application/vnd.oma.drm.roap-pdu+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML},
63 {(char*)"application/vnd.oma.drm.roap-trigger+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML},
64 {(char*)"application/vnd.oma.drm.roap-trigger+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML},
66 {(char*)"text/vnd.wap.connectivity-xml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML},
67 {(char*)"application/vnd.wap.connectivity-wbxml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML},
69 {(char*)"application/x-wap-prov.browser-settings", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS},
70 {(char*)"application/x-wap-prov.browser-bookmarks", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS},
71 {(char*)"application/x-wap-prov.syncset+xml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_SYNCSET_WBXML},
72 {(char*)"application/x-wap-prov.syncset+wbxml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_SYNCSET_XML},
73 {(char*)"text/vnd.wap.emn+xml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_XML},
74 {(char*)"application/vnd.wap.emn+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML},
75 {(char*)"application/vnd.wv.csp.cir", (char*)"X-Wap-Application-Id: x-wap-application:wv.ua\r\n", SMS_WAP_APPLICATION_PUSH_IMPS_CIR},
76 {(char*)"application/vnd.omaloc-supl-init", (char*)"X-Wap-Application-Id: x-oma-application:ulp.ua\r\n", SMS_WAP_APPLICATION_LBS},
81 char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
82 char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
84 const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000};
86 const unsigned char wspHeaderFieldCount = 0x43;
87 const unsigned char wspContentsTypeCount = 0x34;
88 const unsigned long wspLanguageCount = 0x11a;
89 const unsigned char wspSecurityTypeCount = 0x04;
92 static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] =
94 { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
95 { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
96 { (char*)"application/pkcs7-mime", 0x37 },
97 { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
98 { (char*)"application/vnd.wap.signed-certificate", 0x39 },
99 { (char*)"application/vnd.wap.cert-response", 0x3A },
100 { (char*)"application/xhtml+xml", 0x3B },
101 { (char*)"application/wml+xml", 0x3C },
102 { (char*)"text/css", 0x3D },
104 { (char*)"application/vnd.wap.mms-message", 0x3E },
106 { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
107 { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
108 { (char*)"application/vnd.wap.loc+xml", 0x41 },
109 { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
110 { (char*)"application/vnd.syncml.dm+xml", 0x43 },
111 { (char*)"application/vnd.syncml.notification", 0x44 },
112 { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
113 { (char*)"application/vnd.wv.csp.cir", 0x46 },
115 { (char*)"application/vnd.oma.dd+xml", 0x47},
116 { (char*)"application/vnd.oma.drm.message", 0x48 },
117 { (char*)"application/vnd.oma.drm.content", 0x49 },
118 { (char*)"application/vnd.oma.drm.rights+xml", 0x4A },
119 { (char*)"application/vnd.oma.drm.rights+wbxml", 0x4B },
120 { (char*)"application/vnd.syncml.ds.notification", 0x4E},
121 { (char*)"application/mikey", 0x52},
126 const char* wspHeaderFieldName[] =
128 (char*)"Accept", //0x00
129 (char*)"Accept-Charset",
130 (char*)"Accept-Encoding",
131 (char*)"Accept-Language",
132 (char*)"Accept-Ranges",
135 (char*)"Authorization",
136 (char*)"Cache-Control",
138 (char*)"Content-Base", //0x0a
139 (char*)"Content-Encoding",
140 (char*)"Content-Language",
141 (char*)"Content-Length",
142 (char*)"Content-Location",
143 (char*)"Content-MD5",
144 (char*)"Content-Range", //0x10
145 (char*)"Content-Type",
149 (char*)"From", //0x15
151 (char*)"If-Modified-Since",
153 (char*)"If-None-Match",
154 (char*)"If-Range", //0x1a
155 (char*)"If-Unmodified-Since",
157 (char*)"Last-Modified",
158 (char*)"Max-Forwards",
160 (char*)"Proxy-Authenticate", //0x20
161 (char*)"Proxy-Authorization",
165 (char*)"Retry-After", //0x25
167 (char*)"Transfer-Encodig",
170 (char*)"Vary", //0x2a
173 (char*)"Www-Authenticate",
174 (char*)"Content-Disposition",
175 (char*)"X-Wap-Application-Id",
176 (char*)"X-Wap-Content-URI", //0x30
177 (char*)"X-Wap-Iinitiator-URI",
178 (char*)"Accept-Application", // Back
179 (char*)"Bearer-Indication",
181 (char*)"Profile", //0x35
182 (char*)"Profile-Diff",
183 (char*)"Profile-Warning", // end of WAP 1.2
186 (char*)"Trailer", //0x3a
187 (char*)"Accept-Charset", //Back
188 (char*)"Accept-Encoding", // Back
189 (char*)"Cache-Control", // back
190 (char*)"Content-Range",
192 (char*)"Content-ID", //x40
195 (char*)"Encoding-Version"
199 const SMS_WSP_CHARSET_S wspCharset[] =
201 { (char*)"big5", 0x07ea },
202 { (char*)"iso-10646-ucs-2", 0x03e8 },
203 { (char*)"iso-8859-1", 0x04 },
204 { (char*)"iso-8859-2", 0x05 },
205 { (char*)"iso-8859-3", 0x06 },
206 { (char*)"iso-8859-4", 0x07 },
207 { (char*)"iso-8859-5", 0x08 },
208 { (char*)"iso-8859-6", 0x09 },
209 { (char*)"iso-8859-7", 0x0a },
210 { (char*)"iso-8859-8", 0x0b },
211 { (char*)"iso-8859-9", 0x0c },
212 { (char*)"shift-JIS", 0x11 },
213 { (char*)"us-ascii", 0x03 },
214 { (char*)"utf-8", 0x6a },
215 { (char*)"none", 0x26 },
216 { (char*)"", 0xffff }
221 const char* wspEncodeMethod[] =
229 const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] =
231 { (char*)"*/*", 0x00 },
232 { (char*)"text/*", 0x01 },
233 { (char*)"text/html", 0x02 },
234 { (char*)"text/plain", 0x03 },
235 { (char*)"text/x-hdml", 0x04 },
236 { (char*)"text/x-ttml", 0x05 },
237 { (char*)"text/x-vCalendar", 0x06 },
238 { (char*)"text/x-vCard", 0x07 },
239 { (char*)"text/vnd.wap.wml", 0x08 },
240 { (char*)"text/vnd.wap.wmlscript", 0x09 },
241 { (char*)"text/vnd.wap.wta-event", 0x0a },
242 { (char*)"multipart/*", 0x0b },
243 { (char*)"multipart/mixed", 0x0c },
244 { (char*)"multipart/form-data", 0x0d },
245 { (char*)"multipart/byteranges", 0x0e },
246 { (char*)"multipart/alternative", 0x0f },
247 { (char*)"application/*", 0x10 },
248 { (char*)"application/java-vm", 0x11 },
249 { (char*)"application/x-www-form-urlencoded", 0x12 },
250 { (char*)"application/x-hdmlc", 0x13 },
251 { (char*)"application/vnd.wap.wmlc", 0x14 },
252 { (char*)"application/vnd.wap.wmlscriptc", 0x15 },
253 { (char*)"application/vnd.wap.wta-eventc", 0x16 },
254 { (char*)"application/vnd.wap.uaprof", 0x17 },
255 { (char*)"application/vnd.wap.wtls-ca-certificate", 0x18 },
256 { (char*)"application/vnd.wap.wtls-user-certificate", 0x19 },
257 { (char*)"application/x-x509-ca-cert", 0x1a },
258 { (char*)"application/x-x509-user-cert", 0x1b },
259 { (char*)"image/*", 0x1c },
260 { (char*)"image/gif", 0x1d },
261 { (char*)"image/jpeg", 0x1e },
262 { (char*)"image/tiff", 0x1f },
263 { (char*)"image/png", 0x20 },
264 { (char*)"image/vnd.wap.wbmp", 0x21 },
265 { (char*)"application/vnd.wap.multipart.*", 0x22 },
266 { (char*)"application/vnd.wap.multipart.mixed", 0x23 },
267 { (char*)"application/vnd.wap.multipart.form-data", 0x24 },
268 { (char*)"application/vnd.wap.multipart.byteranges", 0x25 },
269 { (char*)"application/vnd.wap.multipart.alternative", 0x26 },
270 { (char*)"application/xml", 0x27 },
271 { (char*)"text/xml",0x28 },
272 { (char*)"application/vnd.wap.wbxml", 0x29 },
273 { (char*)"application/x-x968-cross-cert", 0x2a },
274 { (char*)"application/x-x968-ca-cert", 0x2b },
275 { (char*)"application/x-x968-user-cert", 0x2c },
276 { (char*)"text/vnd.wap.si", 0x2d },
277 { (char*)"application/vnd.wap.sic", 0x2e },
278 { (char*)"text/vnd.wap.sl", 0x2f },
279 { (char*)"application/vnd.wap.slc", 0x30 },
280 { (char*)"text/vnd.wap.co", 0x31 },
281 { (char*)"application/vnd.wap.coc", 0x32 },
282 { (char*)"application/vnd.wap.multipart.related", 0x33 },
283 { (char*)"application/vnd.wap.sia", 0x34 },
285 { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
286 { (char*)"application/vnd.connectivity-wbxml", 0x36 },
287 { (char*)"application/pkcs7-mime", 0x37 },
288 { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
289 { (char*)"application/vnd.wap.signed-certificate", 0x39 },
290 { (char*)"application/vnd.wap.cert-response", 0x3A },
291 { (char*)"application/xhtml+xml", 0x3B },
292 { (char*)"application/wml+xml", 0x3C },
293 { (char*)"text/css", 0x3D },
295 { (char*)"application/vnd.wap.mms-message", 0x3E },
297 { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
298 { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
299 { (char*)"application/vnd.wap.loc+xml", 0x41 },
300 { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
301 { (char*)"application/vnd.syncml.dm+xml", 0x43 },
302 { (char*)"application/vnd.syncml.notification", 0x44 },
303 { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
304 { (char*)"application/vnd.wv.csp.cir", 0x46 }
307 static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]=
309 { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
310 { (char*)"application/vnd.omaloc-supl-init", 0x312},
311 { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
314 const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_WAP_UNREGISTER_CONTENTS_TYPE_S);
316 const SMS_WSP_LANGUAGE_S wspLanguage[] =
318 { (char*)"English", 0x19 },
319 { (char*)"en", 0x19 },
320 { (char*)"Korean", 0x3d },
321 { (char*)"*", 0x00 },
322 { (char*)"Afar", 0x01 },
323 { (char*)"aa", 0x01 },
324 { (char*)"Abkhazian", 0x02 },
325 { (char*)"ab", 0x02 },
326 { (char*)"Afrikaans", 0x03 },
327 { (char*)"af", 0x03 },
328 { (char*)"Amharic", 0x04 },
329 { (char*)"am", 0x04 },
330 { (char*)"Arabic", 0x05 },
331 { (char*)"ar", 0x05 },
332 { (char*)"Assamese", 0x06 },
333 { (char*)"as", 0x06 },
334 { (char*)"Aymara", 0x07 },
335 { (char*)"ay", 0x07 },
336 { (char*)"Azerbaijani", 0x08 },
337 { (char*)"az", 0x08 },
338 { (char*)"Bashkir", 0x09 },
339 { (char*)"ba", 0x09 },
340 { (char*)"Byelorussian", 0x0a },
341 { (char*)"be", 0x0a },
342 { (char*)"Bulgarian", 0x0b },
343 { (char*)"bg", 0x0b },
344 { (char*)"Bihari", 0x0c },
345 { (char*)"bh", 0x0c },
346 { (char*)"Bislama", 0x0d },
347 { (char*)"bi", 0x0f },
348 { (char*)"Bengali", 0x0e },
349 { (char*)"Bangla", 0x0e },
350 { (char*)"bn", 0x0e },
351 { (char*)"Tibetan", 0x0f },
352 { (char*)"bo", 0x0f },
353 { (char*)"Breton", 0x10 },
354 { (char*)"br", 0x10 },
355 { (char*)"Catalan", 0x11 },
356 { (char*)"ca", 0x11 },
357 { (char*)"Corsican", 0x12 },
358 { (char*)"co", 0x12 },
359 { (char*)"Czech", 0x13 },
360 { (char*)"cs", 0x13 },
361 { (char*)"Welsh", 0x14 },
362 { (char*)"cy", 0x14 },
363 { (char*)"Denish", 0x15 },
364 { (char*)"da", 0x15 },
365 { (char*)"German", 0x16 },
366 { (char*)"de", 0x16 },
367 { (char*)"Bhutani", 0x17 },
368 { (char*)"dz", 0x17 },
369 { (char*)"Greek", 0x18 },
370 { (char*)"el", 0x18 },
371 { (char*)"Esperanto", 0x81 },
372 { (char*)"eo", 0x1a },
373 { (char*)"Spanish", 0x1b },
374 { (char*)"es", 0x1b },
375 { (char*)"Estonian", 0x1c },
376 { (char*)"et", 0x1c },
377 { (char*)"Basque", 0x1d },
378 { (char*)"eu", 0x1d },
379 { (char*)"Persian", 0x1e },
380 { (char*)"fa", 0x1e },
381 { (char*)"Finnish", 0x1f },
382 { (char*)"fi", 0x1f },
383 { (char*)"Fiji", 0x20 },
384 { (char*)"fj", 0x20 },
385 { (char*)"Faeroese", 0x82 },
386 { (char*)"fo", 0x82 },
387 { (char*)"French", 0x22 },
388 { (char*)"fr", 0x22 },
389 { (char*)"Frisian", 0x83 },
390 { (char*)"fy", 0x83 },
391 { (char*)"Irish", 0x24 },
392 { (char*)"ga", 0x24 },
393 { (char*)"Scots Gaelic", 0x25 },
394 { (char*)"gd", 0x25 },
395 { (char*)"Galician", 0x26 },
396 { (char*)"gl", 0x26 },
397 { (char*)"Guarani", 0x27 },
398 { (char*)"gn", 0x27 },
399 { (char*)"Gujarati", 0x28 },
400 { (char*)"gu", 0x28 },
401 { (char*)"Hausa", 0x29 },
402 { (char*)"ha", 0x29 },
403 { (char*)"Hebrew", 0x2a },
404 { (char*)"he", 0x2a },
405 { (char*)"Hindi", 0x2b },
406 { (char*)"hi", 0x2b },
407 { (char*)"Croatian", 0x2c },
408 { (char*)"hr", 0x2c },
409 { (char*)"Hungarian", 0x2d },
410 { (char*)"hu", 0x2d },
411 { (char*)"Armenian", 0x2e },
412 { (char*)"hy", 0x2e },
413 { (char*)"Interlingua", 0x84 },
414 { (char*)"ia", 0x84 },
415 { (char*)"Indonesian", 0x30 },
416 { (char*)"id", 0x30 },
417 { (char*)"Interlingue", 0x86 },
418 { (char*)"ie", 0x86 },
419 { (char*)"Maori", 0x47 },
420 { (char*)"mi", 0x47 },
421 { (char*)"Macedonian", 0x48 },
422 { (char*)"mk", 0x48 },
423 { (char*)"Malayalam", 0x49 },
424 { (char*)"ml", 0x49 },
425 { (char*)"Mongolian", 0x4a },
426 { (char*)"mn", 0x4a },
427 { (char*)"Moldavian", 0x4b },
428 { (char*)"mo", 0x4d },
429 { (char*)"Marathi", 0x4c },
430 { (char*)"mr", 0x4c },
431 { (char*)"Malay", 0x4d },
432 { (char*)"ms", 0x4d },
433 { (char*)"Maltese", 0x4e },
434 { (char*)"mt", 0x4e },
435 { (char*)"Burmese", 0x4f },
436 { (char*)"my", 0x4f },
437 { (char*)"Nauru", 0x50 },
438 { (char*)"na", 0x50 },
439 { (char*)"Nepali", 0x51 },
440 { (char*)"ne", 0x51 },
441 { (char*)"Dutch", 0x52 },
442 { (char*)"nl", 0x52 },
443 { (char*)"Norwegian", 0x53 },
444 { (char*)"no", 0x53 },
445 { (char*)"Occitan", 0x54 },
446 { (char*)"oc", 0x54 },
447 { (char*)"(Afan) Oromo", 0x55 },
448 { (char*)"(Afan)Oromo", 0x55 },
449 { (char*)"om", 0x55 },
450 { (char*)"Oriya", 0x56 },
451 { (char*)"or", 0x56 },
452 { (char*)"Punjabi", 0x57 },
453 { (char*)"pa", 0x57 },
454 { (char*)"Polish", 0x58 },
455 { (char*)"po", 0x58 },
456 { (char*)"Pashto", 0x59 },
457 { (char*)"Pushto", 0x59 },
458 { (char*)"ps", 0x59 },
459 { (char*)"Portugurse", 0x5a },
460 { (char*)"pt", 0x5a },
461 { (char*)"Quechua", 0x5b },
462 { (char*)"qu", 0x5b },
463 { (char*)"Rhaeto-Romance", 0x8c },
464 { (char*)"rm", 0x8c },
465 { (char*)"Kirundi", 0x5d },
466 { (char*)"rn", 0x5d },
467 { (char*)"Romanian", 0x5e },
468 { (char*)"ro", 0x5e },
469 { (char*)"Russian", 0x5f },
470 { (char*)"ru", 0x5f },
471 { (char*)"Kinyarwanda", 0x60 },
472 { (char*)"rw", 0x60 },
473 { (char*)"Sanskrit", 0x61 },
474 { (char*)"sa", 0x61 },
475 { (char*)"Sindhi", 0x62 },
476 { (char*)"sd", 0x62 },
477 { (char*)"Sangho", 0x63 },
478 { (char*)"sg", 0x63 },
479 { (char*)"Serbo-Croatian", 0x64 },
480 { (char*)"sh", 0x64 },
481 { (char*)"Sinhalese", 0x65 },
482 { (char*)"si", 0x65 },
483 { (char*)"Slovak", 0x66 },
484 { (char*)"sk", 0x66 },
485 { (char*)"Slovenian", 0x67 },
486 { (char*)"sl", 0x67 },
487 { (char*)"Samoan", 0x68 },
488 { (char*)"sm", 0x68 },
489 { (char*)"Shona", 0x69 },
490 { (char*)"sn", 0x69 },
491 { (char*)"Somali", 0x6a },
492 { (char*)"so", 0x6a },
493 { (char*)"Albanian", 0x6b },
494 { (char*)"sq", 0x6b },
495 { (char*)"Serbian", 0x6c },
496 { (char*)"sr", 0x6c },
497 { (char*)"Siswati", 0x6d },
498 { (char*)"ss", 0x6d },
499 { (char*)"Sesotho", 0x6e },
500 { (char*)"st", 0x6e },
501 { (char*)"Sundanese", 0x6f },
502 { (char*)"su", 0x6f },
503 { (char*)"Swedish", 0x70 },
504 { (char*)"sv", 0x70 },
505 { (char*)"Swahili", 0x71 },
506 { (char*)"sw", 0x71 },
507 { (char*)"Tamil", 0x72 },
508 { (char*)"ta", 0x72 },
509 { (char*)"Telugu", 0x73 },
510 { (char*)"te", 0x73 },
511 { (char*)"Tajik", 0x74 },
512 { (char*)"tg", 0x74 },
513 { (char*)"Thai", 0x75 },
514 { (char*)"th", 0x75 },
515 { (char*)"Tigrinya", 0x76 },
516 { (char*)"ti", 0x76 },
517 { (char*)"Turkmen", 0x77 },
518 { (char*)"tk", 0x77 },
519 { (char*)"Inupiak", 0x87 },
520 { (char*)"ik", 0x87 },
521 { (char*)"Icelandic", 0x33 },
522 { (char*)"is", 0x33 },
523 { (char*)"Italian", 0x34 },
524 { (char*)"it", 0x34 },
525 { (char*)"Inuktitut", 0x89 },
526 { (char*)"iu", 0x89 },
527 { (char*)"Japanese", 0x36 },
528 { (char*)"ja", 0x36 },
529 { (char*)"Javanese", 0x37 },
530 { (char*)"jw", 0x37 },
531 { (char*)"Georgian", 0x38 },
532 { (char*)"ka", 0x38 },
533 { (char*)"Kazakh", 0x39 },
534 { (char*)"kk", 0x39 },
535 { (char*)"Gerrnlandic", 0x8a },
536 { (char*)"kl", 0x8a },
537 { (char*)"Cambodian", 0x3b },
538 { (char*)"km", 0x3b },
539 { (char*)"Kannada", 0x3c },
540 { (char*)"kn", 0x3c },
541 { (char*)"Kashmiri", 0x3e },
542 { (char*)"ks", 0x3e },
543 { (char*)"Kurdish", 0x3f },
544 { (char*)"ku", 0x3f },
545 { (char*)"Kirghiz", 0x40 },
546 { (char*)"ky", 0x40 },
547 { (char*)"Latin", 0x8b },
548 { (char*)"la", 0x8b },
549 { (char*)"Lingala", 0x42 },
550 { (char*)"ln", 0x42 },
551 { (char*)"Laothian", 0x43 },
552 { (char*)"lo", 0x43 },
553 { (char*)"Lithuanian", 0x44 },
554 { (char*)"lt", 0x44 },
555 { (char*)"Lavian", 0x45 },
556 { (char*)"Lettish", 0x45 },
557 { (char*)"lv", 0x45 },
558 { (char*)"Malagasy", 0x46 },
559 { (char*)"mg", 0x46 },
560 { (char*)"Tagalog", 0x78 },
561 { (char*)"tl", 0x78 },
562 { (char*)"Setswana", 0x79 },
563 { (char*)"tn", 0x79 },
564 { (char*)"Tonga", 0x7a },
565 { (char*)"to", 0x7a },
566 { (char*)"Turkish", 0x7b },
567 { (char*)"tr", 0x7b },
568 { (char*)"Tsonga", 0x7c },
569 { (char*)"ts", 0x7c },
570 { (char*)"Tatar", 0x7d },
571 { (char*)"tt", 0x7d },
572 { (char*)"Twi", 0x7e },
573 { (char*)"tw", 0x7e },
574 { (char*)"Uighur", 0x7f },
575 { (char*)"ug", 0x7f },
576 { (char*)"Ukrainian", 0x1a },
577 { (char*)"uk", 0x1a },
578 { (char*)"Urdu", 0x21 },
579 { (char*)"ur", 0x21 },
580 { (char*)"Uzbek", 0x23 },
581 { (char*)"uz", 0x23 },
582 { (char*)"Vietnamese", 0x2f },
583 { (char*)"vi", 0x2f },
584 { (char*)"Volapuk", 0x85 },
585 { (char*)"vo", 0x85 },
586 { (char*)"Wolof", 0x31 },
587 { (char*)"wo" , 0x31 },
588 { (char*)"Xhosa", 0x32 },
589 { (char*)"xh", 0x32 },
590 { (char*)"Yiddish", 0x88 },
591 { (char*)"yi", 0x88 },
592 { (char*)"Yoruba", 0x35 },
593 { (char*)"yo", 0x35 },
594 { (char*)"Zhuang", 0x3a },
595 { (char*)"z", 0x3a },
596 { (char*)"Chinese", 0x41 },
597 { (char*)"ch", 0x41 },
598 { (char*)"Zulu", 0x5c },
599 { (char*)"zu", 0x5c },
600 { (char*)"Ko", 0x3d }
604 const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] =
606 { (char*)"x-wap-application:*", 0x00 },
607 { (char*)"x-wap-application:push.sia", 0x01},
608 { (char*)"x-wap-application:wml.ua", 0x02 },
609 { (char*)"x-wap-application:wta.ua", 0x03 },
610 { (char*)"x-wap-application:mms.ua", 0x04 },
611 { (char*)"x-wap-application:push.syncml", 0x05 },
612 { (char*)"x-wap-application:loc.ua", 0x06 },
613 { (char*)"x-wap-application:syncml.dm", 0x07 },
614 { (char*)"x-wap-application:drm.ua", 0x08 },
615 { (char*)"x-wap-application:emn.ua", 0x09 },
616 { (char*)"x-oma-docomo:xmd.mail.ua", 0x905C },
620 const char* wspCacheControl[] =
627 (char*)"Only-if-cached",
630 (char*)"No-transform",
631 (char*)"Must-revalidate",
632 (char*)"Proxy-revalidate"
635 const SMS_WSP_METHOD_TYPE_S wspMethodType[] =
637 { (char*)"GET", 0x40 },
638 { (char*)"OPTIONS", 0x41 },
639 { (char*)"HEAD", 0x42 },
640 { (char*)"DELETE", 0x43 },
641 { (char*)"TRACE", 0x44 },
642 { (char*)"POST", 0x60 },
643 { (char*)"PUT", 0x61 }
647 const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] =
649 {(char*)"NETWPIN",0x00},
650 {(char*)"USERPIN",0x01},
651 {(char*)"USERNETWPIN",0x02},
652 {(char*)"USERPINMAC",0x03}
657 const char* wspWeek[] =
669 const char* wspWeekDay[] =
680 const char* wspMonth[] =
698 /*==================================================================================================
699 IMPLEMENTATION OF SmsPluginWapPushHandler - Member Functions
700 ==================================================================================================*/
701 SmsPluginWapPushHandler* SmsPluginWapPushHandler::pInstance = NULL;
704 SmsPluginWapPushHandler::SmsPluginWapPushHandler()
706 memset(&tmpAddress, 0x00, sizeof(tmpAddress));
710 SmsPluginWapPushHandler::~SmsPluginWapPushHandler()
716 SmsPluginWapPushHandler* SmsPluginWapPushHandler::instance()
719 pInstance = new SmsPluginWapPushHandler();
725 bool SmsPluginWapPushHandler::IsWapPushMsg(SMS_USERDATA_S *pUserData)
729 if (pUserData == NULL) {
730 MSG_DEBUG("pUserData is NULL");
734 int PortCount = sizeof(wapPushPortList)/sizeof(wapPushPortList[0]);
736 MSG_DEBUG("Port Count [%d]", PortCount);
738 for (int i = 0; i < pUserData->headerCnt; i++) {
739 if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
740 /** Have to check something??? */
741 } else if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
743 for (int j = 0; j < PortCount; j++) {
744 if (pUserData->header[i].udh.appPort16bit.destPort == wapPushPortList[j]) {
745 MSG_DEBUG("Wap Push Msg : [%04x]", wapPushPortList[j]);
758 SMS_WAP_APP_CODE_T SmsPluginWapPushHandler::getAppCode(const char *pPushHeader)
760 int appCount = sizeof(pushDefaultApplication)/sizeof(pushDefaultApplication[0]) - 1;
762 unsigned char *header = NULL;
763 SMS_WAP_APP_CODE_T appCode = SMS_WAP_APPLICATION_DEFAULT;
765 MSG_DEBUG("Application Count [%d]", appCount);
767 for (int i = 0; i < appCount; i++) {
769 header = (unsigned char*)strcasestr(pPushHeader, pushDefaultApplication[i].pContentType);
771 if (header != NULL) {
772 appCode = pushDefaultApplication[i].appCode;
777 if (appCode == SMS_WAP_APPLICATION_DEFAULT) {
778 MSG_DEBUG("Application Type is not supported");
780 MSG_DEBUG("Find Application [%d]", appCode);
788 void SmsPluginWapPushHandler::copyDeliverData(SMS_DELIVER_S *pDeliver)
790 tmpAddress.ton = pDeliver->originAddress.ton;
791 tmpAddress.npi = pDeliver->originAddress.npi;
793 strncpy(tmpAddress.address, pDeliver->originAddress.address, MAX_ADDRESS_LEN);
795 MSG_DEBUG("Address [%s]", tmpAddress.address);
797 tmpTimeStamp.format = pDeliver->timeStamp.format;
799 if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
800 tmpTimeStamp.time.absolute.year = pDeliver->timeStamp.time.absolute.year;
801 tmpTimeStamp.time.absolute.month = pDeliver->timeStamp.time.absolute.month;
802 tmpTimeStamp.time.absolute.day = pDeliver->timeStamp.time.absolute.day;
803 tmpTimeStamp.time.absolute.hour = pDeliver->timeStamp.time.absolute.hour;
804 tmpTimeStamp.time.absolute.minute = pDeliver->timeStamp.time.absolute.minute;
805 tmpTimeStamp.time.absolute.second = pDeliver->timeStamp.time.absolute.second;
806 tmpTimeStamp.time.absolute.timeZone = pDeliver->timeStamp.time.absolute.timeZone;
811 void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize)
815 #ifdef MSG_FW_FOR_DEBUG
816 MSG_DEBUG("DataSize [%d]", DataSize);
818 MSG_DEBUG("[pUserData]");
819 for (int i = 0; i < DataSize; i++)
821 printf("[%02x]", pUserData[i]);
826 unsigned char* pPDUTypeData = (unsigned char*)pUserData;
827 unsigned long PDUTypeDataLen = DataSize;
829 char* pPushHeader = NULL;
830 AutoPtr<char> pushHeaderBuf(&pPushHeader);
831 unsigned long pushHeaderLen = 0;
833 char* pPushBody = NULL;
834 AutoPtr<char> PushBodyBuf(&pPushBody);
835 unsigned long pushBodyLen = 0;
837 unsigned long iPDU = 1;
839 char* pWspHeader = NULL;
840 AutoPtr<char> WspHeaderBuf(&pWspHeader);
841 unsigned long wspHeaderLen = 0;
843 char* pWspBody = NULL;
844 AutoPtr<char> WspBodyBuf(&pWspBody);
845 unsigned long wspBodyLen = 0;
850 pushHeaderLen = wspRetriveUintvarDecode( pPDUTypeData, &iPDU );
852 MSG_DEBUG("PDUTypeDataLen [%d]", PDUTypeDataLen);
853 MSG_DEBUG("pushHeaderLen [%d]", pushHeaderLen);
854 MSG_DEBUG("iPDU [%d]", iPDU);
856 wspHeaderLen = pushHeaderLen + iPDU;
858 MSG_DEBUG("wspBodyLen [%d]", wspBodyLen);
860 if (wspHeaderLen > 0) {
862 pWspHeader = new char[wspHeaderLen];
864 if (pWspHeader == NULL) {
865 MSG_DEBUG("pWspHeader Memory Allocation Failed");
868 memcpy(pWspHeader, pPDUTypeData, wspHeaderLen);
872 #ifdef MSG_FW_FOR_DEBUG
873 MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
875 MSG_DEBUG("[pWspHeader]");
876 for (int i = 0; i < wspHeaderLen; i++)
878 printf("[%02x]", pWspHeader[i]);
883 /** return if it is below case error */
884 if (PDUTypeDataLen < wspHeaderLen) {
885 MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
889 /** Finding wspBody Information */
890 wspBodyLen = PDUTypeDataLen - wspHeaderLen;
892 if (wspBodyLen > 0) {
894 pWspBody = new char[wspBodyLen];
896 if (pWspBody == NULL) {
897 MSG_DEBUG("pWspBody Memory Allocation Failed");
900 memcpy(pWspBody, pPDUTypeData + wspHeaderLen, wspBodyLen);
906 wspDecodeHeader(pPDUTypeData + iPDU, pushHeaderLen, PDUTypeDataLen - (iPDU + pushHeaderLen), TRUE, &pPushHeader);
908 iPDU = iPDU + pushHeaderLen;
910 pushBodyLen = PDUTypeDataLen - iPDU ;
912 if (pushBodyLen > 0) {
913 pPushBody = new char[pushBodyLen];
915 if (pPushBody == NULL) {
916 MSG_DEBUG("pPushBody Memory Allocation Failed");
919 memcpy(pPushBody, pPDUTypeData+ iPDU, pushBodyLen);
926 handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen);
932 void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
936 if (pPushBody == NULL) {
937 MSG_DEBUG("pPushBody is NULL");
941 SMS_WAP_APP_CODE_T appCode = getAppCode(pPushHeader);
943 /** check Push message receive setting */
944 bool bPushRecv = false;
946 MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
948 if ((bPushRecv == false) && (appCode != SMS_WAP_APPLICATION_MMS_UA)) {
949 MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
954 case SMS_WAP_APPLICATION_MMS_UA:
955 MSG_DEBUG("Received MMS Notification");
956 handleMMSNotification(pPushBody, PushBodyLen);
959 case SMS_WAP_APPLICATION_PUSH_SI:
960 MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
961 handleSIMessage(pPushBody, PushBodyLen, true);
964 case SMS_WAP_APPLICATION_PUSH_SIC:
965 MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
966 handleSIMessage(pPushBody, PushBodyLen, false);
969 case SMS_WAP_APPLICATION_PUSH_SL:
970 MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
971 handleSLMessage(pPushBody, PushBodyLen, true);
974 case SMS_WAP_APPLICATION_PUSH_SLC:
975 MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
976 handleSLMessage(pPushBody, PushBodyLen, false);
979 case SMS_WAP_APPLICATION_PUSH_CO:
980 MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
981 handleCOMessage(pPushBody, PushBodyLen, true);
984 case SMS_WAP_APPLICATION_PUSH_COC:
985 MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
986 handleCOMessage(pPushBody, PushBodyLen, false);
989 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
990 MSG_DEBUG("Received DM BOOTSTRAP");
991 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
994 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
995 MSG_DEBUG("Received DM BOOTSTRAP");
996 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
999 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
1000 MSG_DEBUG("Received Provisioning");
1001 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1004 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
1005 MSG_DEBUG("Received Provisioning");
1006 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1009 case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
1010 case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
1011 MSG_DEBUG("Received Provisioning");
1012 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1015 case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
1016 MSG_DEBUG("Received DM Notification");
1017 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1020 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
1021 MSG_DEBUG("Received DS Notification");
1022 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1025 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
1026 MSG_DEBUG("Received DS Notification");
1027 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1030 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
1031 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
1032 MSG_DEBUG("Received DRM UA");
1034 if (pPushBody != NULL)
1035 handleDrmVer1(pPushBody, PushBodyLen);
1039 case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
1040 case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
1041 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
1042 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
1043 MSG_DEBUG("Received DRM V2");
1047 case SMS_WAP_APPLICATION_PUSH_EMAIL:
1048 case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
1049 case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
1050 MSG_DEBUG("Received Email");
1054 case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
1055 MSG_DEBUG("Received IMPS CIR");
1059 case SMS_WAP_APPLICATION_LBS :
1060 MSG_DEBUG("Received LBS related message");
1061 SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
1065 case SMS_WAP_APPLICATION_PUSH_SIA :
1066 MSG_DEBUG("Received SIA");
1071 MSG_DEBUG("Unknown Application [%d]", appCode);
1079 static void launchProcessByAppcode(int appcode)
1082 GError *error = NULL;
1083 DBusGConnection *connection = NULL;
1084 DBusGProxy *dbus_proxy;
1087 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
1088 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
1089 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
1090 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
1091 case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
1092 case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
1093 case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
1095 connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
1096 if (error != NULL) {
1097 MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
1098 g_error_free(error);
1101 dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadmagent",
1102 "/com/samsung/omadmagent", "com.samsung.omadmagent");
1103 MSG_DEBUG("dbus_proxy %x", dbus_proxy);
1104 dbus_g_proxy_call(dbus_proxy, "Hello_Agent", &error, G_TYPE_INVALID, G_TYPE_INVALID);
1105 g_object_unref(dbus_proxy);
1106 dbus_g_connection_unref(connection);
1110 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
1111 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
1113 connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
1114 if (error != NULL) {
1115 MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
1116 g_error_free(error);
1119 dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadsagent",
1120 "/com/samsung/omadsagent", "com.samsung.omadsagent");
1121 MSG_DEBUG("dbus_proxy %x", dbus_proxy);
1122 dbus_g_proxy_call(dbus_proxy, "Hello_Agent", &error, G_TYPE_INVALID, G_TYPE_INVALID);
1123 g_object_unref(dbus_proxy);
1124 dbus_g_connection_unref(connection);
1135 void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
1139 if (pPushBody == NULL) {
1140 MSG_DEBUG("pPushBody is NULL");
1144 msg_error_t err = MSG_SUCCESS;
1145 int pushEvt_cnt = 0;
1146 char app_id[MAX_WAPPUSH_ID_LEN] = {0,};
1147 char content_type[MAX_WAPPUSH_CONTENT_TYPE_LEN] = {0,};
1148 SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
1150 err = storageHandler->getRegisteredPushEvent(pPushHeader, &pushEvt_cnt, app_id, content_type);
1151 MSG_DEBUG("pushEvt_cnt: %d", pushEvt_cnt);
1152 if(err != MSG_SUCCESS) {
1153 MSG_DEBUG("Fail to get registered push event");
1157 for(int i = 0; i < pushEvt_cnt; ++i) {
1159 /** check Push message receive setting */
1160 bool bPushRecv = false;
1162 MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
1164 storageHandler->getnthPushEvent(i, &appcode);
1165 MSG_DEBUG("pushEvt_cnt: %d, appcode: %d", pushEvt_cnt, appcode);
1166 if ((bPushRecv == false) && (appcode != SMS_WAP_APPLICATION_MMS_UA)) {
1167 MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
1171 launchProcessByAppcode(appcode);
1174 case SMS_WAP_APPLICATION_MMS_UA:
1175 MSG_DEBUG("Received MMS Notification");
1176 handleMMSNotification(pPushBody, PushBodyLen);
1179 case SMS_WAP_APPLICATION_PUSH_SI:
1180 MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
1181 handleSIMessage(pPushBody, PushBodyLen, true);
1184 case SMS_WAP_APPLICATION_PUSH_SIC:
1185 MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
1186 handleSIMessage(pPushBody, PushBodyLen, false);
1189 case SMS_WAP_APPLICATION_PUSH_SL:
1190 MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
1191 handleSLMessage(pPushBody, PushBodyLen, true);
1194 case SMS_WAP_APPLICATION_PUSH_SLC:
1195 MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
1196 handleSLMessage(pPushBody, PushBodyLen, false);
1199 case SMS_WAP_APPLICATION_PUSH_CO:
1200 MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
1201 handleCOMessage(pPushBody, PushBodyLen, true);
1204 case SMS_WAP_APPLICATION_PUSH_COC:
1205 MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
1206 handleCOMessage(pPushBody, PushBodyLen, false);
1209 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
1210 MSG_DEBUG("Received DM BOOTSTRAP");
1211 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1214 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
1215 MSG_DEBUG("Received DM BOOTSTRAP");
1216 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1219 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
1220 MSG_DEBUG("Received Provisioning");
1221 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1224 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
1225 MSG_DEBUG("Received Provisioning");
1226 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1229 case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
1230 case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
1231 MSG_DEBUG("Received Provisioning");
1232 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1235 case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
1236 MSG_DEBUG("Received DM Notification");
1237 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1240 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
1241 MSG_DEBUG("Received DS Notification");
1242 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1245 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
1246 MSG_DEBUG("Received DS Notification");
1247 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1250 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
1251 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
1252 MSG_DEBUG("Received DRM UA");
1254 if (pPushBody != NULL)
1255 handleDrmVer1(pPushBody, PushBodyLen);
1259 case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
1260 case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
1261 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
1262 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
1263 MSG_DEBUG("Received DRM V2");
1267 case SMS_WAP_APPLICATION_PUSH_EMAIL:
1268 case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
1269 case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
1270 MSG_DEBUG("Received Email");
1275 case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
1276 MSG_DEBUG("Received IMPS CIR");
1280 case SMS_WAP_APPLICATION_LBS :
1281 MSG_DEBUG("Received LBS related message");
1282 SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
1286 case SMS_WAP_APPLICATION_PUSH_SIA :
1287 MSG_DEBUG("Received SIA");
1292 SmsPluginEventHandler::instance()->handlePushMsgIncoming(pPushHeader, pPushBody, PushBodyLen, app_id, content_type);
1296 storageHandler->releasePushEvent();
1302 void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen)
1306 #ifdef MSG_FW_FOR_DEBUG
1307 printf("\n\n[handleMMSNotification] Push Body.\n");
1309 for (int i = 0; i < PushBodyLen; i++)
1311 printf(" [%02x]", pPushBody[i]);
1316 /** Make MSG_MESSAGE_INFO_S */
1317 MSG_MESSAGE_INFO_S msgInfo;
1318 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
1320 createMsgInfo(&msgInfo);
1322 /** Convert Type values */
1323 msgInfo.msgType.mainType = MSG_MMS_TYPE;
1324 msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
1325 msgInfo.storageId = MSG_STORAGE_PHONE;
1326 msgInfo.dataSize = PushBodyLen;
1328 if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
1329 msgInfo.bTextSms = false;
1331 /** Save Message Data into File */
1332 char fileName[MSG_FILENAME_LEN_MAX+1];
1333 memset(fileName, 0x00, sizeof(fileName));
1335 if (MsgCreateFileName(fileName) == false)
1336 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1338 if (MsgWriteIpcFile(fileName, pPushBody, msgInfo.dataSize) == false)
1339 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1341 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1343 msgInfo.bTextSms = true;
1345 memcpy(msgInfo.msgText, pPushBody, msgInfo.dataSize);
1346 msgInfo.msgText[msgInfo.dataSize] = '\0';
1349 msg_error_t err = MSG_SUCCESS;
1351 /** Add MMS Noti Msg into DB */
1352 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
1354 if (err == MSG_SUCCESS) {
1356 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1358 if (err != MSG_SUCCESS) {
1359 MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
1362 MSG_DEBUG("addMessage() Error !! [%d]", err);
1368 void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText)
1372 MSG_PUSH_MESSAGE_S pushMsg = {};
1374 xmlDocPtr xmlDoc = NULL;
1375 xmlNodePtr topNode = NULL;
1376 xmlNodePtr indNode = NULL;
1378 xmlChar* tmpXmlChar = NULL;
1380 if (pPushBody == NULL) {
1381 MSG_DEBUG("pPushBody is NULL");
1385 getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
1387 if (xmlDoc == NULL) {
1388 MSG_DEBUG("xmlDoc is NULL");
1392 topNode = xmlDocGetRootElement(xmlDoc);
1394 if (topNode == NULL) {
1395 MSG_DEBUG("topNode is NULL");
1400 indNode = topNode->xmlChildrenNode;
1402 while (indNode != NULL) {
1403 if (!xmlStrcmp(indNode->name, (const xmlChar*) "indication")) {
1404 MSG_DEBUG("indNode->name = %s\n", indNode->name);
1408 indNode = indNode->next;
1411 if (indNode == NULL) {
1412 MSG_DEBUG("indNode is NULL.");
1416 /** temporary set to max. */
1417 pushMsg.expires = 0xFFFFFFFF;
1419 /** setting received time */
1420 time_t t = time(NULL);
1421 time_t utfTime = time(&t);
1423 pushMsg.received = (unsigned long)utfTime;
1425 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
1427 if (tmpXmlChar == NULL) {
1428 MSG_DEBUG("href is NULL.");
1432 if (tmpXmlChar != NULL)
1433 strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
1435 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_SI_ID_TAG);
1437 if (tmpXmlChar != NULL)
1438 strncpy(pushMsg.id, (char*)tmpXmlChar, MAX_WAPPUSH_ID_LEN-1);
1440 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CREATED_TAG);
1442 if (tmpXmlChar != NULL)
1443 pushMsg.created = convertXmlCharToSec((char*)tmpXmlChar);
1445 if (pushMsg.created == 0)
1446 pushMsg.created = pushMsg.received;
1448 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_EXPIRES_TAG);
1450 if (tmpXmlChar != NULL)
1451 pushMsg.expires = convertXmlCharToSec((char*)tmpXmlChar);
1453 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
1455 pushMsg.action = convertSIActionStrToEnum((char*)tmpXmlChar);
1457 tmpXmlChar = xmlNodeListGetString(xmlDoc, indNode->xmlChildrenNode, 1);
1459 if (tmpXmlChar == NULL) {
1460 MSG_DEBUG("contents is NULL.");
1464 strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
1466 /** Write push Msg to file */
1467 char fileName[MSG_FILENAME_LEN_MAX+1];
1468 memset(fileName, 0x00, sizeof(fileName));
1470 if (MsgCreateFileName(fileName) == false) {
1472 xmlFree(tmpXmlChar);
1473 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1476 if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false) {
1478 xmlFree(tmpXmlChar);
1479 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1482 /** Pack Message Info Structure */
1483 MSG_MESSAGE_INFO_S msgInfo;
1485 createMsgInfo(&msgInfo);
1487 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1489 /** Convert Type values */
1490 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1491 msgInfo.msgType.subType = MSG_WAP_SI_SMS;
1493 msgInfo.dataSize = sizeof(pushMsg);
1496 xmlFree(tmpXmlChar);
1498 msg_error_t err = MSG_SUCCESS;
1500 /** Add WAP Push Msg into DB */
1501 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
1503 if (err == MSG_SUCCESS) {
1505 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1507 if (err != MSG_SUCCESS){
1508 MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
1511 MSG_DEBUG("addMessage() Error !! [%d]", err);
1520 void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, bool isText)
1524 MSG_PUSH_MESSAGE_S pushMsg = {};
1526 xmlDocPtr xmlDoc = NULL;
1527 xmlNodePtr topNode = NULL;
1528 xmlNodePtr indNode = NULL;
1530 xmlChar* tmpXmlChar = NULL;
1532 msg_error_t err = MSG_SUCCESS;
1534 if (pPushBody == NULL) {
1535 MSG_DEBUG("pPushBody is NULL \n" );
1539 getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
1541 if (xmlDoc == NULL) {
1542 MSG_DEBUG("xmlDoc is NULL \n" );
1546 topNode = xmlDocGetRootElement(xmlDoc);
1548 if (topNode == NULL) {
1549 MSG_DEBUG("Empty Document." );
1553 MSG_DEBUG("Not an empty Document and topNode->name = %s \n",topNode->name );
1558 while (indNode != NULL) {
1559 if (!xmlStrcmp(indNode->name, (const xmlChar*) "sl")) {
1560 MSG_DEBUG("indNode->name = %s\n",indNode->name);
1564 indNode = indNode->next;
1567 /** setting received time setting */
1568 time_t t = time(NULL);
1569 time_t utfTime = time(&t);
1571 pushMsg.received = (unsigned long)utfTime;
1573 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
1575 if (tmpXmlChar == NULL) {
1576 MSG_DEBUG("href is NULL.");
1580 strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
1582 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
1583 pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
1585 /** Setting other parameters in default values */
1586 pushMsg.created = pushMsg.received;
1587 /** temporary set to MAX value. */
1588 pushMsg.expires = 0xFFFFFFFF;
1590 MSG_DEBUG("check pushMsg data");
1591 MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
1592 MSG_DEBUG("pushMsg.received : [%d]", pushMsg.received);
1593 MSG_DEBUG("pushMsg.created : [%d]", pushMsg.created);
1594 MSG_DEBUG("pushMsg.expires : [%d]", pushMsg.expires);
1595 MSG_DEBUG("pushMsg.id : [%s]", pushMsg.id);
1596 MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
1597 MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
1599 /** Write push Msg to file */
1600 char fileName[MSG_FILENAME_LEN_MAX+1];
1601 memset(fileName, 0x00, sizeof(fileName));
1603 if (MsgCreateFileName(fileName) == false)
1604 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1606 if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
1607 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1609 /** Pack Message Info Structure */
1610 MSG_MESSAGE_INFO_S msgInfo;
1612 createMsgInfo(&msgInfo);
1614 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1616 /** Convert Type values */
1617 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1618 msgInfo.msgType.subType = MSG_WAP_SL_SMS;
1620 /** Update Msg Text */
1621 strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
1623 msgInfo.dataSize = sizeof(pushMsg);
1625 MSG_DEBUG("dataSize : %d", msgInfo.dataSize);
1627 /** Callback to MSG FW */
1628 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1630 if (err != MSG_SUCCESS)
1631 MSG_DEBUG("callbackMsgIncoming is failed, err=[%d]", err);
1634 xmlFree(tmpXmlChar);
1641 void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText)
1643 MSG_PUSH_CACHEOP_S cacheOp;
1645 xmlDocPtr xmlDoc = NULL;
1646 xmlNodePtr topNode = NULL;
1647 xmlNodePtr indNode = NULL;
1649 memset(&cacheOp, 0x00, sizeof(cacheOp));
1651 MSG_DEBUG("Enter handleCOMessage");
1653 if (pPushBody == NULL) {
1654 MSG_DEBUG("pPushBody is NULL \n" );
1658 getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
1660 if (xmlDoc == NULL) {
1661 MSG_DEBUG("xmlDoc is NULL \n" );
1665 topNode = xmlDocGetRootElement(xmlDoc);
1666 if (topNode == NULL) {
1667 MSG_DEBUG("Warning:Empty Document\n" );
1672 indNode = topNode->xmlChildrenNode;
1675 while(indNode != NULL) {
1677 xmlChar* tmpUrl = NULL;
1678 if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_OBJ)) {
1679 MSG_DEBUG("indNode->name = %s\n", indNode->name);
1681 tmpUrl = xmlGetProp(indNode, (xmlChar*) SMS_PUSH_XML_CO_URI);
1683 if (tmpUrl != NULL) {
1684 strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
1686 MSG_DEBUG("%dth invalObjectUrl is <%s>\n", cacheOp.invalObjectCnt, cacheOp.invalObjectUrl[cacheOp.invalObjectCnt-1]);
1688 MSG_DEBUG("NO href value from the xmlDoc\n");
1690 } else if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_SVC)) {
1691 MSG_DEBUG("indNode->name = %s\n",indNode->name);
1692 tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
1694 if (tmpUrl != NULL) {
1695 strncpy(cacheOp.invalServiceUrl[cacheOp.invalServiceCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
1696 MSG_DEBUG("%dth invalServiceUrl is <%s>\n", cacheOp.invalServiceCnt, cacheOp.invalServiceUrl[cacheOp.invalServiceCnt-1]);
1698 MSG_DEBUG("NO href value from the xmlDoc\n");
1705 indNode = indNode->next;
1708 /** Write push Msg to file */
1709 char fileName[MSG_FILENAME_LEN_MAX+1];
1710 memset(fileName, 0x00, sizeof(fileName));
1712 if (MsgCreateFileName(fileName) == false) {
1714 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1717 if (MsgWriteIpcFile(fileName, (char*)(&cacheOp), sizeof(cacheOp)) == false) {
1719 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1722 /** Pack Message Info Structure */
1723 MSG_MESSAGE_INFO_S msgInfo;
1725 createMsgInfo(&msgInfo);
1727 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1729 /** Convert Type values */
1730 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1731 msgInfo.msgType.subType = MSG_WAP_CO_SMS;
1733 msgInfo.dataSize = sizeof(cacheOp);
1735 msg_error_t err = MSG_SUCCESS;
1737 /** Add WAP Push Msg into DB */
1738 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
1740 if (err == MSG_SUCCESS) {
1742 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1744 if (err != MSG_SUCCESS) {
1745 MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
1748 MSG_DEBUG("addMessage() Error !! [%d]", err);
1757 void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
1759 int drmRt = DRM_RETURN_SUCCESS;
1761 AutoPtr<char> buf(&cid);
1763 MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message.");
1764 drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE;
1765 drm_register_lic_info_s lic_req_info;
1766 drm_register_lic_resp_s lic_resp_info;
1768 bzero(&lic_req_info, sizeof(drm_register_lic_info_s));
1769 bzero(&lic_resp_info, sizeof(drm_register_lic_resp_s));
1770 bzero(lic_req_info.lic_data, sizeof(lic_req_info.lic_data));
1772 memcpy(lic_req_info.lic_data, pPushBody, PushBodyLen);
1774 lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS;
1775 lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_WAPPUSH;
1776 lic_req_info.operation_callback.callback = NULL;
1778 drmRt = drm_process_request(request_type, &lic_req_info, &lic_resp_info);
1779 if (drmRt == DRM_RETURN_SUCCESS) {
1780 MSG_DEBUG("DRM successfully registed to drm-service.");
1782 MSG_DEBUG("Fail to regist DRM to drm-service.");
1789 void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
1791 /** Convert class Type values */
1792 pMsgInfo->msgType.classType = MSG_CLASS_NONE;
1794 /** set folder id (temporary) */
1795 pMsgInfo->folderId = MSG_INBOX_ID;
1797 pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
1798 pMsgInfo->bRead = false;
1799 pMsgInfo->bProtected = false;
1800 pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
1801 pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
1804 time_t rawtime = time(NULL);
1806 /*** Comment below lines to save local UTC time..... (it could be used later.)
1808 if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
1810 MSG_DEBUG("year : %d", tmpTimeStamp.time.absolute.year);
1811 MSG_DEBUG("month : %d", tmpTimeStamp.time.absolute.month);
1812 MSG_DEBUG("day : %d", tmpTimeStamp.time.absolute.day);
1813 MSG_DEBUG("hour : %d", tmpTimeStamp.time.absolute.hour);
1814 MSG_DEBUG("minute : %d", tmpTimeStamp.time.absolute.minute);
1815 MSG_DEBUG("second : %d", tmpTimeStamp.time.absolute.second);
1816 MSG_DEBUG("timezone : %d", tmpTimeStamp.time.absolute.timeZone);
1818 char displayTime[32];
1822 memset(&timeinfo, 0x00, sizeof(tm));
1824 timeinfo.tm_year = (tmpTimeStamp.time.absolute.year + 100);
1825 timeinfo.tm_mon = (tmpTimeStamp.time.absolute.month - 1);
1826 timeinfo.tm_mday = tmpTimeStamp.time.absolute.day;
1827 timeinfo.tm_hour = tmpTimeStamp.time.absolute.hour;
1828 timeinfo.tm_min = tmpTimeStamp.time.absolute.minute;
1829 timeinfo.tm_sec = tmpTimeStamp.time.absolute.second;
1830 timeinfo.tm_isdst = 0;
1832 rawtime = mktime(&timeinfo);
1834 MSG_DEBUG("tzname[0] [%s]", tzname[0]);
1835 MSG_DEBUG("tzname[1] [%s]", tzname[1]);
1836 MSG_DEBUG("timezone [%d]", timezone);
1837 MSG_DEBUG("daylight [%d]", daylight);
1839 memset(displayTime, 0x00, sizeof(displayTime));
1840 strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
1841 MSG_DEBUG("displayTime [%s]", displayTime);
1843 rawtime -= (tmpTimeStamp.time.absolute.timeZone * (3600/4));
1845 timeTM = localtime(&rawtime);
1846 memset(displayTime, 0x00, sizeof(displayTime));
1847 strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
1848 MSG_DEBUG("displayTime [%s]", displayTime);
1850 rawtime -= timezone;
1852 timeTM = localtime(&rawtime);
1853 memset(displayTime, 0x00, sizeof(displayTime));
1854 strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
1855 MSG_DEBUG("displayTime [%s]", displayTime);
1860 pMsgInfo->displayTime = rawtime;
1862 /** Convert Address values */
1863 pMsgInfo->nAddressCnt = 1;
1864 pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
1865 strncpy(pMsgInfo->addressList[0].addressVal, tmpAddress.address, MAX_ADDRESS_VAL_LEN);
1867 pMsgInfo->msgPort.valid = false;
1868 pMsgInfo->msgPort.dstPort = 0;
1869 pMsgInfo->msgPort.srcPort = 0;
1873 void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
1875 if (pPushBody == NULL) {
1876 MSG_DEBUG("pPushBody is NULL");
1882 *pXmlDoc = xmlParseMemory(pPushBody, strlen(pPushBody));
1884 WB_UTINY* xmldata = NULL;
1885 WBXMLConvWBXML2XML *conv = NULL;
1886 WBXMLError ret = WBXML_OK;
1888 ret = wbxml_conv_wbxml2xml_create(&conv);
1889 if (ret != WBXML_OK)
1892 ret = wbxml_conv_wbxml2xml_run(conv, (WB_UTINY*)pPushBody, (WB_ULONG)PushBodyLen, &xmldata, NULL);
1894 wbxml_conv_wbxml2xml_destroy(conv);
1896 if (ret != WBXML_OK ||xmldata == NULL) {
1897 MSG_DEBUG("xmldata is NULL. Error code is [%d].\n", ret);
1901 MSG_DEBUG("xmldata : \n%s\n", xmldata);
1903 *pXmlDoc = xmlParseMemory((char*)xmldata, strlen((char*)xmldata));
1908 unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
1910 struct tm timeStruct;
1911 time_t nTimeInSec = 0;
1913 int i = 0, index = 0;
1915 memset(tmpBuf, 0x00, sizeof(tmpBuf));
1916 memset(&timeStruct, 0x00, sizeof(struct tm));
1919 if (strlen(pDate)<20)
1922 MSG_DEBUG("pDate [%s]", pDate);
1925 for (i = 0; i < 4; i++) {
1926 tmpBuf[i] = pDate[index++];
1930 timeStruct.tm_year = (atoi( tmpBuf)-1900);
1933 for (i = 0; i < 2; i++) {
1934 tmpBuf[i] = pDate[index++];
1938 timeStruct.tm_mon = (atoi( tmpBuf) - 1);
1941 for (i = 0; i < 2; i++) {
1942 tmpBuf[i] = pDate[index++];
1946 timeStruct.tm_mday = atoi( tmpBuf);
1949 for (i = 0; i < 2; i++) {
1950 tmpBuf[i] = pDate[index++];
1954 timeStruct.tm_hour = atoi( tmpBuf);
1957 for (i = 0; i < 2; i++) {
1958 tmpBuf[i] = pDate[index++];
1962 timeStruct.tm_min = atoi( tmpBuf);
1965 for (i = 0; i < 2; i++) {
1966 tmpBuf[i] = pDate[index++];
1970 timeStruct.tm_sec = atoi( tmpBuf);
1972 nTimeInSec = mktime(&timeStruct);
1977 msg_push_action_t SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pAction)
1981 if (pAction == NULL) {
1982 MSG_DEBUG("pAction is NULL. Setting to default action type.");
1983 return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
1986 /** compare with signal-none. */
1987 comp = strcmp( "signal-none", pAction );
1989 return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
1991 /** compare with signal-low. */
1992 comp = strcmp( "signal-low", pAction );
1994 return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
1996 /** compare with signal-medium. */
1997 comp = strcmp( "signal-medium", pAction );
1999 return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
2001 /** compare with signal-high. */
2002 comp = strcmp( "signal-high", pAction );
2004 return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
2006 /** compare with delete. */
2007 comp = strcmp( "delete", pAction );
2009 return MSG_PUSH_SI_ACTION_DELETE;
2011 /** signal-medium is default action value. */
2012 return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
2016 msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pAction)
2020 if (pAction == NULL) {
2021 MSG_DEBUG( "MSG_DEBUG is NULL. Setting to default action type.\n" );
2022 return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
2025 /** compare pSrcStr with execute-low. */
2026 comp = strcmp( "execute-low", pAction );
2028 return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
2030 /** compare pSrcStr with execute-high. */
2031 comp = strcmp( "execute-high", pAction );
2033 return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
2035 /** compare pSrcStr with cache. */
2036 comp = strcmp( "cache", pAction );
2038 return MSG_PUSH_SL_ACTION_CACHE;
2040 /** default SL action value is execute-low. */
2041 return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
2046 unsigned long SmsPluginWapPushHandler::wspRetriveUintvarDecode( unsigned char* sourceData, unsigned long* currentPointer )
2048 unsigned long i = 0;
2049 unsigned long decodedValue;
2051 while (sourceData[*currentPointer +i] >= 0x80) i++;
2053 decodedValue = wspDecodeUintvar( i+1, sourceData + *currentPointer );
2054 *currentPointer = *currentPointer + i + 1;
2055 MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%d .\n",decodedValue );
2056 return decodedValue;
2060 unsigned long SmsPluginWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar )
2063 unsigned long decodedUintvar = 0;
2066 for (i = 0 ; i < length; i++) {
2067 decodedUintvar = decodedUintvar + ( wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f ));
2070 return decodedUintvar;
2074 void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
2076 unsigned long iField;
2077 bool continueField = FALSE;
2078 unsigned long currentLength;
2080 char* encodedHeader = NULL;
2081 AutoPtr<char> encodedHeaderbuf(&encodedHeader);
2083 char* outTemper = NULL;
2085 char* temper = NULL;
2086 AutoPtr<char> temperbuf(&temper);
2088 unsigned char track;
2089 unsigned long iEncodedHeader = 0;
2090 unsigned char fieldCode = 0xff;
2092 /* outTemper is Decoded Headers.
2093 temper is Single Decoded Header.
2095 if (NULL == ( outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
2096 MSG_DEBUG("outTemper Memory allocation is failed.\n" );
2099 memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
2100 currentLength = WSP_STANDARD_STR_LEN_MAX;
2102 MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n" );
2108 MSG_DEBUG("wspDecodeHeader: RAW data \n" );
2109 for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) {
2111 szTempBuf[0] = 0x00;
2112 sprintf( szTempBuf, "%2X ", sEncodedHeader[loop] );
2114 if (AcStrlen( szBuf ) + 7 < 64) {
2115 strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
2117 strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
2118 MSG_DEBUG("[%s]", szBuf);
2120 strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
2123 strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
2124 MSG_DEBUG("[%s]", szBuf);
2125 MSG_DEBUG("fContentType=%d \n",fContentType );
2126 /* operation for content-type */
2127 /* makes psuedo- content-type fieldcode */
2128 /* content - type is processed with header. But it's come without field code. So existence of fContentType can decide adding content type header field code whether ContentType + general header is or not. */
2131 encodedHeader = new char[ encodedHeaderLen + 1 ];
2132 if (encodedHeader == NULL) {
2133 MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
2136 encodedHeader[0] = 0x91;
2137 memcpy( encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen );
2139 encodedHeader = new char[ encodedHeaderLen ];
2140 if (encodedHeader == NULL) {
2141 MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
2145 memcpy( encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen );
2148 /* Is it reacehd end of header? */
2149 while (iEncodedHeader < encodedHeaderLen) {
2150 /* Get memory for single header */
2151 temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
2152 if (temper == NULL) {
2153 MSG_DEBUG("temper Memory allocation is failed.\n" );
2157 memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
2159 /* this section presents header code page shifting procedure
2160 This part can be implemented by future request.
2161 if (track == 0x 7f )
2163 track = encodedHeader[iEncodedHeader];
2165 if (track == 0x00) {
2166 MSG_DEBUG("WspLDecodeHeader: fieldcode is 0 \n" );
2167 strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
2170 } else if (( track > 0 ) && ( track < 0x20 )) {
2172 } else if (( track < 0x7f ) && ( track > 0x1f )) { /* In this case, first byte is normal string. So it's considered to unknown header. */
2173 unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
2174 unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
2176 strncpy( (char*)fieldName, (char*)(encodedHeader + iEncodedHeader ),WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
2177 fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
2178 iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldName ) + 1;
2179 strncpy( (char*)fieldValue, (char*)(encodedHeader + iEncodedHeader ), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
2180 fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
2181 iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldValue ) + 1;
2183 strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2184 strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2185 strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2186 /* this means 'don't process anymore.' */
2189 } else if (track > 0x7f) {
2190 /* In case of first byte is field code, else case is error. */
2192 /*if (( track & 0x7f ) <= wspHeaderFieldCount ) */
2195 unsigned long fieldValueLen = encodedHeader[iEncodedHeader + 1];
2196 unsigned char fieldValue[1275];
2197 fieldCode = track & 0x7f;
2199 if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 ))
2201 dprint( DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5] );
2204 memset(fieldValue, 0, 1275);
2206 /* add field name */
2207 /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
2208 if (!continueField) {
2209 strncat( (char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2210 strncat( (char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2211 continueField = FALSE;
2214 /* field value is string */
2215 /* In this case, it just copy field value. */
2216 if (( fieldValueLen > LENGTH_QUOTE ) && ( fieldValueLen < 0x80 )) {
2218 /* string field value should be NULL terminated */
2219 strncat( (char*)temper, (char*)(encodedHeader + iEncodedHeader + 1 ), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2220 strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2222 iEncodedHeader = iEncodedHeader + AcStrlen( (char*)encodedHeader + iEncodedHeader + 1 ) + 2;
2225 /* first field value is length */
2226 /* If first byte of field value is length value, allocate field value by the length.
2227 In field value, data is
2228 1D 03 8F 24 24 - Then 8F 24 24 is field value.
2229 1D 1F 33.... - Then allocate 33H for FieldValue.
2231 1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
2232 1D 8F 24 24 - In this case, original data is wrong.
2233 If accept-charset: ISO-10646-ucs-2;Q=0.7 is
2236 03 - field value length
2237 03 E8 47 - field value
2238 it's decoded by above value.
2240 if (fieldValueLen < 0x20) {
2242 if (fieldValueLen == LENGTH_QUOTE) {
2244 /* field length is encoded in UINTVAR */
2245 unsigned long uintvarLen = 0;
2246 fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen );
2247 memcpy( fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen );
2248 iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
2252 if (fieldValueLen == 1) {
2253 /* field value is one byte integer over 0x80 */
2254 /** make it two byte integer */
2255 fieldValue[0] = 0x00;
2256 memcpy( fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
2258 iEncodedHeader = iEncodedHeader + 1 + 2;
2260 memcpy( fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen );
2261 fieldValue[fieldValueLen] = 0;
2262 iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
2263 if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 )) {
2264 MSG_DEBUG("%X \n", encodedHeader[iEncodedHeader] );
2269 /* field value is single encoded */
2270 if (fieldValueLen > 0x7f) {
2271 fieldValue[0] = encodedHeader[iEncodedHeader + 1];
2273 iEncodedHeader = iEncodedHeader + 2;
2275 /* processing normal pre-defined field decoding */
2277 MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode );
2278 MSG_DEBUG("WspLDecodeHeader: fieldSize %d\n", fieldValueLen );
2280 if (( fieldCode > wspHeaderFieldCount ) && ( fieldCode != 0xff )) {
2281 MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track );
2282 strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
2287 switch ( fieldCode )
2289 /* accept charset */
2290 /* It's normal way of field process. */
2293 unsigned long i = 0;
2296 /* Case of length of charset greater than 1 are two thigins.
2297 1. code length of charset is greater than 1.
2298 2. It include parameter.
2301 if (1 != fieldValueLen) {
2302 code = wspHeaderDecodeInteger( fieldValue );
2303 /* Calculate iField. */
2304 if (fieldValue[0] < 0x80 )
2305 iField = fieldValue[0];
2309 while ( wspCharset[i].charsetCode != code )
2311 strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2312 /* If parameter exist */
2313 if (iField < fieldValueLen) {
2315 AutoPtr<char> parambuf(¶m);
2316 wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, ¶m);
2317 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2320 code = fieldValue[0] & 0x7f;
2322 while (( wspCharset[i].charsetCode != code ) && ( wspCharset[i].charsetCode != 0xffff )) i++;
2323 strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2330 /* Like below routine, Same decoding routine process together. */
2331 /* Accept-encoding */
2333 /* content-encoding */
2338 integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen );
2339 if (integerValue > 2) {
2340 MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
2343 strncat( (char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2346 /* contents type decoder */
2352 unsigned long contentsTypeCode;
2353 unsigned long i = 0;
2354 /* encoded content type length body */
2355 unsigned long tempLen;
2357 /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
2358 if (0 == fieldValueLen) {
2359 strncat( (char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2362 /* 01 AE --> 00 AE --> AE*/
2363 if (fieldValueLen == 2 && fieldValue[0] == 0) {
2364 memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
2365 MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
2368 if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
2369 if (fieldValue[0] > 0x80) {
2371 } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
2372 fieldValue[3] = fieldValue[2];
2373 fieldValue[2] = fieldValue[1];
2374 fieldValue[1] = fieldValue[0];
2375 fieldValue[0] = 0x02;
2378 MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n" );
2380 tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
2385 char* szExtendedContent;
2387 contentsTypeCode = fieldValue[0] & 0x7f;
2388 while (( wspContentsType[i].contentsTypeCode != contentsTypeCode ) && ( i < wspContentsTypeCount )) i++;
2390 /* If specified content type doesn't exist */
2391 if (i < wspContentsTypeCount)
2392 strncat( (char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2394 szExtendedContent = wspExtendedDecodeType( (char)contentsTypeCode );
2396 if (szExtendedContent != NULL) {
2397 MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n " );
2398 strncat( (char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2401 contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
2403 while ((wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspUnregisteredContentsTypeCount)) i++;
2405 /** If there is a Content-Type assigned, */
2406 if (i < wspUnregisteredContentsTypeCount)
2407 strncat ((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2412 tempLen = AcStrlen( (char*)fieldValue ) + 1;
2414 strncat ((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2415 MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
2418 /* If there is a parameter */
2419 if (tempLen < fieldValueLen) {
2421 AutoPtr<char> parambuf(¶m);
2422 wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, ¶m);
2423 if (param != NULL) {
2424 strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2425 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2432 /* content-language */
2434 /* accept-language */
2437 unsigned long i = 0;
2439 unsigned long tempLen;
2440 if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
2441 if (fieldValue[0] > 0x80 )
2444 tempLen = fieldValue[0];
2446 tempLen = AcStrlen( (char*)fieldValue ) + 1;
2451 code = wspHeaderDecodeInteger( fieldValue );
2452 while ( wspLanguage[i].languageCode != code) {
2454 if (i == wspLanguageCount)
2458 if (i < wspLanguageCount) {
2459 strncat( (char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2462 strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2465 if (tempLen < fieldValueLen) {
2467 AutoPtr<char> parambuf(¶m);
2468 wspHeaderDecodeQValue( fieldValueLen - tempLen, fieldValue + tempLen, ¶m );
2469 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2477 /* content-length */
2481 /* Bearer-indication */
2487 unsigned char temp[16];
2489 if (( fieldValueLen == 2 ) && ( fieldValue[0] > 0x7f ))
2490 AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]);
2493 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
2494 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2497 /* X-Wap-Application-Id */
2500 unsigned char temp[64];
2503 if (fieldValueLen == 2 && fieldValue[0] == 0) {
2504 memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
2505 MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
2509 integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
2511 int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
2512 for(int i = 0; i < count ; ++i)
2514 if((unsigned int)integerValue == wspHeaderApplId[i].parameterCode)
2516 snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
2517 strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1);
2523 /* Accept-Application */
2525 if (0x80 == fieldValue[0]) {
2526 strncat( (char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2529 unsigned char temp[16];
2531 if (( fieldValueLen == 2 ) && ( fieldValue[0] == 1 ))
2532 AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]);
2535 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
2536 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1);
2544 /* if-unmodified-since */
2548 /* if-modified-since */
2555 char* decodedString = NULL;
2556 AutoPtr<char> decodedStringbuf(&decodedString);
2557 wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString);
2558 strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2564 if (fieldValue[0] == 0x80 )
2565 strncat( (char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2569 if (fieldValue[0] == 0x80 )
2570 strncat( (char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2571 if (fieldValue[0] == 0x81 )
2572 strncat( (char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2577 unsigned char temp[1275];
2578 memcpy( temp, fieldValue, (size_t)fieldValueLen );
2579 temp[fieldValueLen] = 0;
2580 wspHeaderCopyDecodedString( temp, ¤tLength, &temper );
2586 /* proxy - authorization */
2588 if (fieldValue[0] == 0x80) {
2589 char* addString = NULL;
2590 AutoPtr<char> addStringbuf(&addString);
2591 wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString );
2592 strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2594 iField = AcStrlen( (char*)fieldValue) + 1;
2596 strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2597 if (iField < fieldValueLen) {
2599 AutoPtr<char> parambuf(¶m);
2600 wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m );
2601 if (param != NULL) {
2602 strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2603 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2613 /* Proxy-authenticate */
2615 if (0 == fieldValueLen )
2617 if (fieldValue[0] == 0x80) {
2618 char* addString = NULL;
2619 AutoPtr<char> addStringbuf(&addString);
2620 wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString );
2621 strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2623 unsigned char authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
2624 unsigned char realmValue[WSP_STANDARD_STR_LEN_MAX];
2625 unsigned char addedString[WSP_STANDARD_STR_LEN_MAX];
2627 strncpy( (char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
2628 iField = AcStrlen( (char*)authScheme ) + 1;
2629 strncpy( (char*)realmValue, (char*)(fieldValue + iField ), WSP_STANDARD_STR_LEN_MAX-1);
2630 iField = iField + AcStrlen( (char*)realmValue ) + 1;
2631 sprintf( (char*)addedString, "%s %s", authScheme, realmValue );
2632 wspHeaderCopyDecodedString( addedString, ¤tLength, &temper );
2634 if (iField < fieldValueLen) {
2636 AutoPtr<char> parambuf(¶m);
2637 wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, ¶m );
2638 if (param != NULL) {
2639 strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2640 wspHeaderCopyDecodedString( (unsigned char*)param, ¤tLength, &temper );
2646 /* content -range */
2649 unsigned long first, len, last;
2651 unsigned char temp[16];
2654 strncat( (char*)temper," bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2656 first = wspRetriveUintvarDecode( fieldValue, &iField );
2657 len = wspRetriveUintvarDecode( fieldValue, &iField );
2658 /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length.
2660 last = first + contentsLength - 1;
2662 sprintf( (char*)temp, "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len );
2663 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2670 char* cacheString = NULL;
2671 AutoPtr<char> cacheStringbuf(&cacheString);
2673 wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString );
2674 strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2680 if (fieldValue[0] == 0x80) {
2681 strncat( (char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2683 if (1 < fieldValueLen) {
2685 AutoPtr<char> parambuf(¶m);
2686 wspHeaderDecodeParameter( fieldValue, fieldValueLen, ¶m );
2688 if (param != NULL) {
2689 strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2690 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2701 unsigned long i = 0;
2702 while ( wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ) != wspMethodType[i].methodCode ) i++;
2703 strncat( (char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2708 strncat( (char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2709 if (fieldValue[0] == 0x80) {
2710 unsigned char temp[16];
2711 unsigned long first, last;
2714 first = wspRetriveUintvarDecode( fieldValue, &iField );
2715 last = wspRetriveUintvarDecode( fieldValue, &iField );
2717 sprintf( (char*)temp, "%u-%u", (unsigned int)first, (unsigned int)last );
2718 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2720 if (fieldValue[0] == 0x81) {
2721 unsigned char temp[16];
2722 unsigned long suffix;
2724 suffix = wspRetriveUintvarDecode( fieldValue, &iField );
2726 sprintf( (char*)temp, "-%u", (unsigned int)suffix );
2732 if (fieldValue[0] == 0x80) {
2734 AutoPtr<char> tempbuf(&temp);
2736 wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp );
2737 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2740 if (fieldValue[0] == 0x81) {
2741 unsigned char temp[16];
2743 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen ));
2744 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2747 /* transfer-encoding */
2749 /* No other cases allowed */
2750 if (fieldValue[0] == 0x80 )
2751 strncat( (char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2757 int integerValue = wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen );
2758 if (integerValue > wspHeaderFieldCount) {
2759 MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n",wspHeaderFieldCount);
2762 strncat( (char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2769 unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
2771 if (fieldValue[0] < 0x20 )
2772 iField = fieldValue[0];
2775 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, iField ));
2776 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2777 if (iField < fieldValueLen) {
2778 unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
2779 unsigned char text[WSP_STANDARD_STR_LEN_MAX];
2780 strncpy( (char*)agent, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
2781 iField = iField + AcStrlen((char*)agent ) + 1;
2782 strncpy((char*)text, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
2784 sprintf( (char*)temp, " %s %s", agent, text );
2785 wspHeaderCopyDecodedString( temp, ¤tLength, &temper );
2789 /* content-disposition */
2791 if (fieldValue[0] == 0x80 )
2792 strncat( (char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2794 if (fieldValue[0] == 0x81 )
2795 strncat( (char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2797 if (1 < fieldValueLen) {
2799 AutoPtr<char> parambuf(¶m);
2800 wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m );
2802 if (param != NULL) {
2803 strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2804 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2810 temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
2811 memcpy( temper, fieldValue, (size_t)fieldValueLen );
2813 /* Profile-Warning */
2816 unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
2818 sprintf( (char*)temp, "%lX", wspHeaderDecodeInteger(fieldValue ));
2820 temp[1] = (unsigned char)0x30;
2822 if (fieldValueLen > 1) {
2823 /* copy warn-target - URI */
2824 strncat( (char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
2825 if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) {
2826 /* copy warn-date */
2827 char* decodedString = NULL;
2828 AutoPtr<char> decodedStringbuf(&decodedString);
2829 wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString );
2830 strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
2833 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2844 /* It deosn't finished decoding yet. */
2845 if (( iEncodedHeader < encodedHeaderLen ) && ( fieldCode != 0xff )) {
2846 /* In here, iEncodedHeader already point next field code to be decoded. */
2847 /* If this code is same, then set continueField else add CRLF. */
2848 if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f )) {
2849 strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2850 continueField = TRUE;
2852 strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2853 continueField = FALSE;
2856 strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2859 /* add single header to total headers */
2860 strncat( (char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1 );
2861 MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper );
2866 MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n" );
2868 *pHeader = outTemper;
2875 unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger( unsigned char* data )
2877 /* we only can handle max 32bit integer */
2881 unsigned long integer;
2882 unsigned char seg[4];
2885 returner.integer = 0;
2887 if (data[0] < 0x80) {
2888 unsigned long IntLen = 0;
2890 IntLen = (data[0]>0x04) ? 0x04:data[0];
2892 MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %d\n", data[0], IntLen);
2894 for (i=0; i<IntLen; i++)
2895 returner.seg[IntLen-( i+1)] = data[i+1];
2897 return returner.integer;
2900 return data[0] & 0x7f;
2904 void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsigned char* data, char** pDecodedString)
2906 unsigned short qBase = 0;
2909 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
2910 if (*pDecodedString == NULL) {
2911 MSG_DEBUG("WspLHeaderDecodeQValue:MemAlloc failed\n");
2915 memcpy( &qBase, data, (size_t)length );
2916 qValue = (float)qBase;
2918 qValue = qValue - 100;
2919 qValue = qValue / 1000;
2920 sprintf( (char*)*pDecodedString, "; q=%.3f", qValue );
2922 /* qValue variable is divided by 100. And it's multiplied by 100.
2923 It's to resolve problem of changed 0.01 of qValue. */
2924 unsigned long qValueTemp;
2925 qValue = qValue - 1;
2926 qValue = qValue / 100;
2927 qValueTemp = (unsigned long)(qValue * 100);
2928 if (0 == (qValueTemp % 10 ))
2929 sprintf( (char*)*pDecodedString, "; q=%.1f", qValue );
2931 sprintf( (char*)*pDecodedString, "; q=%.2f", qValue );
2937 unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length )
2942 unsigned long integer;
2943 unsigned short seg[4];
2946 returner.integer = 0;
2949 return data[0] & 0x7f;
2951 returner.integer = 0;
2953 for (i = 0 ; i < length; i++) {
2954 returner.integer = returner.integer + ( data[i] * (0x1 << ( ( length - ( i + 1)) * 8 )));
2955 MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %d \n", returner.integer );
2958 return returner.integer;
2962 char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType )
2966 while ( wspExtendedContentsType[i].contentsTypeCode != contentType) {
2967 if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
2972 return (char*)wspExtendedContentsType[i].contentsTypeName;
2976 void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, unsigned long length, char** pParam)
2978 char* param = *pParam;
2980 unsigned long SecurityTypeCode;
2981 unsigned long i = 0;
2983 if (data[0] < 0x80) {
2984 /* unknown parameter type */
2985 param = new char[WSP_STANDARD_STR_LEN_MAX];
2987 if (param == NULL) {
2988 MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n" );
2992 strncpy( (char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
2994 if (NO_VALUE == data[AcStrlen( (char*)param ) + 1]) {
2999 strncat( (char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
3000 strncat( (char*)param, (char*)(data + AcStrlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
3007 switch ( data[0] & 0x7f )
3010 wspHeaderDecodeQValue( length - 1, data + 1, ¶m);
3013 wspHeaderDecodeCharset( length - 1 , data + 1, ¶m);
3016 wspHeaderDecodeVersion( length - 1, data + 1, ¶m);
3020 //param = (unsigned char *)malloc( (size_t)WSP_STANDARD_STR_LEN_MAX );
3021 param = new char[WSP_STANDARD_STR_LEN_MAX];
3022 if (param == NULL) {
3023 MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
3026 sprintf( (char*)param, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 ));
3030 param = new char[WSP_STANDARD_STR_LEN_MAX];
3032 if (param == NULL) {
3033 MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
3036 sprintf( (char*)param, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 ));
3040 param = new char[WSP_STANDARD_STR_LEN_MAX];
3042 if (param == NULL) {
3043 MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
3046 strncpy( (char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
3047 memcpy( param + 5, data + 1, length - 1 );
3048 param[5 + length - 1] = '\0';
3052 param = new char[WSP_STANDARD_STR_LEN_MAX];
3054 if (param == NULL) {
3055 MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
3058 strncpy( (char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
3059 memcpy( param + 9, (char*)(data + 1), (size_t)(length - 1) );
3060 param[9 + length - 1] = '\0';
3067 /*OMA Provisioning*/
3069 param = new char[WSP_STANDARD_STR_LEN_MAX];
3071 if (param == NULL) {
3072 MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
3075 strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
3076 SecurityTypeCode = data[1] & 0x7f;
3077 while (( i < wspSecurityTypeCount ) && ( wspSecurityType[i].SecurityTypeCode != SecurityTypeCode )) i++;
3079 if (i < wspSecurityTypeCount) {
3080 strncat( (char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
3083 if (0x12 == (data[2] & 0x7f)) {
3084 strncat( (char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
3085 memcpy(param+AcStrlen( (char*)param),(char*)(data+3),(size_t)length-3 );
3100 void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsigned char* data, char**pDecodedString)
3103 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3105 if (*pDecodedString == NULL) {
3106 MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n");
3110 strncpy( (char*)*pDecodedString, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
3112 if (data[0] > 0x80) {
3113 unsigned long code = wspHeaderDecodeInteger(data );
3114 unsigned long i = 0;
3115 while (wspCharset[i].charsetCode != code) {
3116 if (wspCharset[i].charsetCode == 0xffff) {
3121 strncat( (char*)*pDecodedString, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pDecodedString)-1 );
3123 unsigned long lastLen = AcStrlen((char*)*pDecodedString);
3124 memcpy( (char*)(*pDecodedString + lastLen), data, (size_t)length );
3125 *pDecodedString[length + lastLen] = '\0';
3133 void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsigned char* data, char** pDecodedString )
3135 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3137 if (*pDecodedString == NULL) {
3138 MSG_DEBUG("WspLHeaderDecodeVersion:MemAlloc failed\n");
3143 /* untyped version */
3144 memcpy( *pDecodedString, data, (size_t)length );
3147 unsigned char majorVer = ((data[0] & 0x7f ) >> 4 );
3148 unsigned char minorVer = data[0] & 0x0f;
3149 sprintf( (char*)*pDecodedString, "level=%u.%u", majorVer, minorVer );
3156 void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, unsigned char* data, char** pDecodedString )
3161 MSG_DEBUG("WspLHeaderDecodeDateValue: \n" );
3163 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3165 if (*pDecodedString == NULL) {
3166 MSG_DEBUG( "WspLHeaderDecodeDateValue:MemAlloc failed\n");
3170 lTime = wspHeaderDecodeIntegerByLength(data, length);
3172 pTMData = (struct tm*)gmtime((const time_t* )&lTime);
3174 if (pTMData == NULL) {
3175 MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail \n" );
3176 strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
3180 /* check date value validity */
3182 if (( pTMData->tm_wday > 6 ) || (pTMData->tm_mon > 12 ) || (pTMData->tm_mday > 31 ))
3184 MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday );
3185 strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
3190 #ifdef MSG_FW_FOR_DEBUG
3191 /** Date type selection */
3192 switch ( wspMachineStatus.dateType )
3194 /* UNIX asciitime function */
3195 case UNIX_DATE_TYPE :
3196 sprintf( (char*)decodedString, "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
3197 pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
3199 case RFC1123_DATE_TYPE :
3200 sprintf( (char*)decodedString, "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday,
3201 wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
3203 case RFC850_DATE_TYPE :
3204 /* Have some Y2K Problems */
3205 /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used. */
3206 sprintf( (char*)decodedString, "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday,
3207 wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
3212 /**UNIX_DATE_TYPE : */
3213 sprintf( (char*)*pDecodedString, "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
3214 pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
3220 void SmsPluginWapPushHandler::wspHeaderCopyDecodedString( unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper )
3222 unsigned long elementLen = AcStrlen( (char*)szDecodedString );
3223 char* temper2 = NULL;
3226 *currentLen = *currentLen + elementLen + 2;
3228 if ( *currentLen > AcStrlen( (char*)* pTemper ) + 2) {
3229 temper2 = new char[(*currentLen + 1 )];
3231 if (temper2 == NULL) {
3232 MSG_DEBUG( "WspLHeaderCopyDecodedString:MemAlloc failed\n");
3235 strncpy( (char*)temper2, (char*)* pTemper, *currentLen);
3237 strncpy( (char*)temper2, (char*)szDecodedString, *currentLen);
3246 void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
3248 unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
3249 unsigned char passWd[WSP_STANDARD_STR_LEN_MAX];
3250 unsigned long iField = 0;
3252 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
3254 if (*pDecodedString == NULL) {
3255 MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n" );
3259 /* skip 'basic' code */
3261 sscanf((char*)(fieldValue + iField), "%s", userId );
3262 iField = iField + AcStrlen( (char*)userId ) + 1;
3263 sscanf( (char*)(fieldValue + iField), "%s", passWd );
3264 iField = iField + AcStrlen( (char*)userId ) + 1;
3265 sprintf( (char*)*pDecodedString, "basic %s/%s", userId, passWd );
3271 void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
3273 unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
3274 unsigned long iField = 0;
3276 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3278 if (*pDecodedString == NULL) {
3279 MSG_DEBUG( "WspLHeaderDecodeChallenge:MemAlloc failed\n");
3283 /* skip 'basic' code */
3285 sscanf( (char*)(fieldValue + iField), "%s", userId );
3286 iField = iField + AcStrlen( (char*)userId ) + 1;
3288 sprintf( (char*)*pDecodedString, "basic realm=\"%s\"", userId );
3294 void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString)
3296 unsigned char paramString[WSP_STANDARD_STR_LEN_MAX];
3297 unsigned char cacheCode;
3299 *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
3300 if (*pCacheString == NULL) {
3301 MSG_DEBUG( "WspLHeaderDecodeCacheControl:MemAlloc failed\n");
3305 if (1 == fieldValueLen) {
3306 /* only one directive */
3307 if (fieldValue[0] > 0x8b) {
3308 return; /* It's error detection. can be omitted. */
3310 strncpy( (char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
3314 if (fieldValue[0] > 0x7f) {
3315 /* directive that has parameter */
3316 cacheCode = fieldValue[0] & 0x7f;
3317 switch ( cacheCode )
3324 if (fieldValue[1] > 0x7f) {
3325 /* well known field name */
3326 strncpy( (char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f],WSP_STANDARD_STR_LEN_MAX-1 );
3327 paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
3329 /* unknown field name */
3330 strncpy( (char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
3340 sprintf( (char*)paramString, "%u", (unsigned int)wspHeaderDecodeInteger( fieldValue + 1));
3347 sprintf((char*)*pCacheString, "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString );
3349 /* cache extentions */
3350 /* In case of come directive of doesn't specified string style */
3352 unsigned long stringLen;
3354 strncpy( (char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
3355 stringLen = AcStrlen((char*)*pCacheString );
3357 if (stringLen + 1 < fieldValueLen) {
3359 if (fieldValue[stringLen+ 1] > 0x7f) {
3360 int untyped = (int)wspHeaderDecodeIntegerByLength( fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1 ));
3362 sprintf( szString, "%d", untyped );
3363 strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
3364 strncat( (char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
3366 if (fieldValue[fieldValueLen] == 0) {
3367 strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
3368 strncat( (char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);