2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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"
27 #include <drm_client.h>
28 #include <dbus/dbus-glib.h>
30 static unsigned short wapPushPortList [] = {0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F};
33 const SMS_PUSH_APP_INFO_S pushDefaultApplication [] =
35 {(char*)"text/vnd.wap.si", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SI},
36 {(char*)"application/vnd.wap.sic", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SIC},
37 {(char*)"text/vnd.wap.sl", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SL},
38 {(char*)"application/vnd.wap.slc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SLC},
39 {(char*)"text/vnd.wap.co", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_CO},
40 {(char*)"application/vnd.wap.coc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_COC},
42 {(char*)"application/vnd.wap.mms-message", (char*)"X-Wap-Application-Id: x-wap-application:mms.ua\r\n", SMS_WAP_APPLICATION_MMS_UA},
44 {(char*)"application/vnd.wap.sia", (char*)"X-Wap-Application-Id: x-wap-application:push.sia\r\n", SMS_WAP_APPLICATION_PUSH_SIA},
46 {(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},
47 {(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},
48 {(char*)"application/vnd.syncml.notification", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION},
49 {(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},
50 {(char*)"application/vnd.syncml+wbxml", (char*)"X-Wap-Application-Id:x-wap-application:push.syncml", SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML},
52 {(char*)"application/vnd.wap.locc+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_WBXML},
53 {(char*)"application/vnd.wap.loc+xml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_XML},
55 {(char*)"application/vnd.oma.dd+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_XML},
56 {(char*)"application/vnd.oma.drm.message", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_MESSAGE},
57 {(char*)"application/vnd.oma.drm.content", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_CONETENT},
58 {(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},
59 {(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},
60 {(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},
61 {(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},
62 {(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},
63 {(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},
65 {(char*)"text/vnd.wap.connectivity-xml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML},
66 {(char*)"application/vnd.wap.connectivity-wbxml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML},
68 {(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},
69 {(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},
70 {(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},
71 {(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},
72 {(char*)"text/vnd.wap.emn+xml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_XML},
73 {(char*)"application/vnd.wap.emn+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML},
74 {(char*)"application/vnd.wv.csp.cir", (char*)"X-Wap-Application-Id: x-wap-application:wv.ua\r\n", SMS_WAP_APPLICATION_PUSH_IMPS_CIR},
75 {(char*)"application/vnd.omaloc-supl-init", (char*)"X-Wap-Application-Id: x-oma-application:ulp.ua\r\n", SMS_WAP_APPLICATION_LBS},
80 char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
81 char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
83 const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000};
85 const unsigned char wspHeaderFieldCount = 0x43;
86 const unsigned char wspContentsTypeCount = 0x34;
87 const unsigned long wspLanguageCount = 0x11a;
88 const unsigned char wspSecurityTypeCount = 0x04;
91 static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] =
93 { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
94 { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
95 { (char*)"application/pkcs7-mime", 0x37 },
96 { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
97 { (char*)"application/vnd.wap.signed-certificate", 0x39 },
98 { (char*)"application/vnd.wap.cert-response", 0x3A },
99 { (char*)"application/xhtml+xml", 0x3B },
100 { (char*)"application/wml+xml", 0x3C },
101 { (char*)"text/css", 0x3D },
103 { (char*)"application/vnd.wap.mms-message", 0x3E },
105 { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
106 { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
107 { (char*)"application/vnd.wap.loc+xml", 0x41 },
108 { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
109 { (char*)"application/vnd.syncml.dm+xml", 0x43 },
110 { (char*)"application/vnd.syncml.notification", 0x44 },
111 { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
112 { (char*)"application/vnd.wv.csp.cir", 0x46 },
114 { (char*)"application/vnd.oma.dd+xml", 0x47},
115 { (char*)"application/vnd.oma.drm.message", 0x48 },
116 { (char*)"application/vnd.oma.drm.content", 0x49 },
117 { (char*)"application/vnd.oma.drm.rights+xml", 0x4A },
118 { (char*)"application/vnd.oma.drm.rights+wbxml", 0x4B },
119 { (char*)"application/vnd.syncml.ds.notification", 0x4E},
120 { (char*)"application/mikey", 0x52},
125 const char* wspHeaderFieldName[] =
127 (char*)"Accept", //0x00
128 (char*)"Accept-Charset",
129 (char*)"Accept-Encoding",
130 (char*)"Accept-Language",
131 (char*)"Accept-Ranges",
134 (char*)"Authorization",
135 (char*)"Cache-Control",
137 (char*)"Content-Base", //0x0a
138 (char*)"Content-Encoding",
139 (char*)"Content-Language",
140 (char*)"Content-Length",
141 (char*)"Content-Location",
142 (char*)"Content-MD5",
143 (char*)"Content-Range", //0x10
144 (char*)"Content-Type",
148 (char*)"From", //0x15
150 (char*)"If-Modified-Since",
152 (char*)"If-None-Match",
153 (char*)"If-Range", //0x1a
154 (char*)"If-Unmodified-Since",
156 (char*)"Last-Modified",
157 (char*)"Max-Forwards",
159 (char*)"Proxy-Authenticate", //0x20
160 (char*)"Proxy-Authorization",
164 (char*)"Retry-After", //0x25
166 (char*)"Transfer-Encodig",
169 (char*)"Vary", //0x2a
172 (char*)"Www-Authenticate",
173 (char*)"Content-Disposition",
174 (char*)"X-Wap-Application-Id",
175 (char*)"X-Wap-Content-URI", //0x30
176 (char*)"X-Wap-Iinitiator-URI",
177 (char*)"Accept-Application", // Back
178 (char*)"Bearer-Indication",
180 (char*)"Profile", //0x35
181 (char*)"Profile-Diff",
182 (char*)"Profile-Warning", // end of WAP 1.2
185 (char*)"Trailer", //0x3a
186 (char*)"Accept-Charset", //Back
187 (char*)"Accept-Encoding", // Back
188 (char*)"Cache-Control", // back
189 (char*)"Content-Range",
191 (char*)"Content-ID", //x40
194 (char*)"Encoding-Version"
198 const SMS_WSP_CHARSET_S wspCharset[] =
200 { (char*)"big5", 0x07ea },
201 { (char*)"iso-10646-ucs-2", 0x03e8 },
202 { (char*)"iso-8859-1", 0x04 },
203 { (char*)"iso-8859-2", 0x05 },
204 { (char*)"iso-8859-3", 0x06 },
205 { (char*)"iso-8859-4", 0x07 },
206 { (char*)"iso-8859-5", 0x08 },
207 { (char*)"iso-8859-6", 0x09 },
208 { (char*)"iso-8859-7", 0x0a },
209 { (char*)"iso-8859-8", 0x0b },
210 { (char*)"iso-8859-9", 0x0c },
211 { (char*)"shift-JIS", 0x11 },
212 { (char*)"us-ascii", 0x03 },
213 { (char*)"utf-8", 0x6a },
214 { (char*)"none", 0x26 },
215 { (char*)"", 0xffff }
220 const char* wspEncodeMethod[] =
228 const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] =
230 { (char*)"*/*", 0x00 },
231 { (char*)"text/*", 0x01 },
232 { (char*)"text/html", 0x02 },
233 { (char*)"text/plain", 0x03 },
234 { (char*)"text/x-hdml", 0x04 },
235 { (char*)"text/x-ttml", 0x05 },
236 { (char*)"text/x-vCalendar", 0x06 },
237 { (char*)"text/x-vCard", 0x07 },
238 { (char*)"text/vnd.wap.wml", 0x08 },
239 { (char*)"text/vnd.wap.wmlscript", 0x09 },
240 { (char*)"text/vnd.wap.wta-event", 0x0a },
241 { (char*)"multipart/*", 0x0b },
242 { (char*)"multipart/mixed", 0x0c },
243 { (char*)"multipart/form-data", 0x0d },
244 { (char*)"multipart/byteranges", 0x0e },
245 { (char*)"multipart/alternative", 0x0f },
246 { (char*)"application/*", 0x10 },
247 { (char*)"application/java-vm", 0x11 },
248 { (char*)"application/x-www-form-urlencoded", 0x12 },
249 { (char*)"application/x-hdmlc", 0x13 },
250 { (char*)"application/vnd.wap.wmlc", 0x14 },
251 { (char*)"application/vnd.wap.wmlscriptc", 0x15 },
252 { (char*)"application/vnd.wap.wta-eventc", 0x16 },
253 { (char*)"application/vnd.wap.uaprof", 0x17 },
254 { (char*)"application/vnd.wap.wtls-ca-certificate", 0x18 },
255 { (char*)"application/vnd.wap.wtls-user-certificate", 0x19 },
256 { (char*)"application/x-x509-ca-cert", 0x1a },
257 { (char*)"application/x-x509-user-cert", 0x1b },
258 { (char*)"image/*", 0x1c },
259 { (char*)"image/gif", 0x1d },
260 { (char*)"image/jpeg", 0x1e },
261 { (char*)"image/tiff", 0x1f },
262 { (char*)"image/png", 0x20 },
263 { (char*)"image/vnd.wap.wbmp", 0x21 },
264 { (char*)"application/vnd.wap.multipart.*", 0x22 },
265 { (char*)"application/vnd.wap.multipart.mixed", 0x23 },
266 { (char*)"application/vnd.wap.multipart.form-data", 0x24 },
267 { (char*)"application/vnd.wap.multipart.byteranges", 0x25 },
268 { (char*)"application/vnd.wap.multipart.alternative", 0x26 },
269 { (char*)"application/xml", 0x27 },
270 { (char*)"text/xml",0x28 },
271 { (char*)"application/vnd.wap.wbxml", 0x29 },
272 { (char*)"application/x-x968-cross-cert", 0x2a },
273 { (char*)"application/x-x968-ca-cert", 0x2b },
274 { (char*)"application/x-x968-user-cert", 0x2c },
275 { (char*)"text/vnd.wap.si", 0x2d },
276 { (char*)"application/vnd.wap.sic", 0x2e },
277 { (char*)"text/vnd.wap.sl", 0x2f },
278 { (char*)"application/vnd.wap.slc", 0x30 },
279 { (char*)"text/vnd.wap.co", 0x31 },
280 { (char*)"application/vnd.wap.coc", 0x32 },
281 { (char*)"application/vnd.wap.multipart.related", 0x33 },
282 { (char*)"application/vnd.wap.sia", 0x34 },
284 { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
285 { (char*)"application/vnd.connectivity-wbxml", 0x36 },
286 { (char*)"application/pkcs7-mime", 0x37 },
287 { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
288 { (char*)"application/vnd.wap.signed-certificate", 0x39 },
289 { (char*)"application/vnd.wap.cert-response", 0x3A },
290 { (char*)"application/xhtml+xml", 0x3B },
291 { (char*)"application/wml+xml", 0x3C },
292 { (char*)"text/css", 0x3D },
294 { (char*)"application/vnd.wap.mms-message", 0x3E },
296 { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
297 { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
298 { (char*)"application/vnd.wap.loc+xml", 0x41 },
299 { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
300 { (char*)"application/vnd.syncml.dm+xml", 0x43 },
301 { (char*)"application/vnd.syncml.notification", 0x44 },
302 { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
303 { (char*)"application/vnd.wv.csp.cir", 0x46 }
306 static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]=
308 { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
309 { (char*)"application/vnd.omaloc-supl-init", 0x312},
310 { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
313 const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_WAP_UNREGISTER_CONTENTS_TYPE_S);
315 const SMS_WSP_LANGUAGE_S wspLanguage[] =
317 { (char*)"English", 0x19 },
318 { (char*)"en", 0x19 },
319 { (char*)"Korean", 0x3d },
320 { (char*)"*", 0x00 },
321 { (char*)"Afar", 0x01 },
322 { (char*)"aa", 0x01 },
323 { (char*)"Abkhazian", 0x02 },
324 { (char*)"ab", 0x02 },
325 { (char*)"Afrikaans", 0x03 },
326 { (char*)"af", 0x03 },
327 { (char*)"Amharic", 0x04 },
328 { (char*)"am", 0x04 },
329 { (char*)"Arabic", 0x05 },
330 { (char*)"ar", 0x05 },
331 { (char*)"Assamese", 0x06 },
332 { (char*)"as", 0x06 },
333 { (char*)"Aymara", 0x07 },
334 { (char*)"ay", 0x07 },
335 { (char*)"Azerbaijani", 0x08 },
336 { (char*)"az", 0x08 },
337 { (char*)"Bashkir", 0x09 },
338 { (char*)"ba", 0x09 },
339 { (char*)"Byelorussian", 0x0a },
340 { (char*)"be", 0x0a },
341 { (char*)"Bulgarian", 0x0b },
342 { (char*)"bg", 0x0b },
343 { (char*)"Bihari", 0x0c },
344 { (char*)"bh", 0x0c },
345 { (char*)"Bislama", 0x0d },
346 { (char*)"bi", 0x0f },
347 { (char*)"Bengali", 0x0e },
348 { (char*)"Bangla", 0x0e },
349 { (char*)"bn", 0x0e },
350 { (char*)"Tibetan", 0x0f },
351 { (char*)"bo", 0x0f },
352 { (char*)"Breton", 0x10 },
353 { (char*)"br", 0x10 },
354 { (char*)"Catalan", 0x11 },
355 { (char*)"ca", 0x11 },
356 { (char*)"Corsican", 0x12 },
357 { (char*)"co", 0x12 },
358 { (char*)"Czech", 0x13 },
359 { (char*)"cs", 0x13 },
360 { (char*)"Welsh", 0x14 },
361 { (char*)"cy", 0x14 },
362 { (char*)"Denish", 0x15 },
363 { (char*)"da", 0x15 },
364 { (char*)"German", 0x16 },
365 { (char*)"de", 0x16 },
366 { (char*)"Bhutani", 0x17 },
367 { (char*)"dz", 0x17 },
368 { (char*)"Greek", 0x18 },
369 { (char*)"el", 0x18 },
370 { (char*)"Esperanto", 0x81 },
371 { (char*)"eo", 0x1a },
372 { (char*)"Spanish", 0x1b },
373 { (char*)"es", 0x1b },
374 { (char*)"Estonian", 0x1c },
375 { (char*)"et", 0x1c },
376 { (char*)"Basque", 0x1d },
377 { (char*)"eu", 0x1d },
378 { (char*)"Persian", 0x1e },
379 { (char*)"fa", 0x1e },
380 { (char*)"Finnish", 0x1f },
381 { (char*)"fi", 0x1f },
382 { (char*)"Fiji", 0x20 },
383 { (char*)"fj", 0x20 },
384 { (char*)"Faeroese", 0x82 },
385 { (char*)"fo", 0x82 },
386 { (char*)"French", 0x22 },
387 { (char*)"fr", 0x22 },
388 { (char*)"Frisian", 0x83 },
389 { (char*)"fy", 0x83 },
390 { (char*)"Irish", 0x24 },
391 { (char*)"ga", 0x24 },
392 { (char*)"Scots Gaelic", 0x25 },
393 { (char*)"gd", 0x25 },
394 { (char*)"Galician", 0x26 },
395 { (char*)"gl", 0x26 },
396 { (char*)"Guarani", 0x27 },
397 { (char*)"gn", 0x27 },
398 { (char*)"Gujarati", 0x28 },
399 { (char*)"gu", 0x28 },
400 { (char*)"Hausa", 0x29 },
401 { (char*)"ha", 0x29 },
402 { (char*)"Hebrew", 0x2a },
403 { (char*)"he", 0x2a },
404 { (char*)"Hindi", 0x2b },
405 { (char*)"hi", 0x2b },
406 { (char*)"Croatian", 0x2c },
407 { (char*)"hr", 0x2c },
408 { (char*)"Hungarian", 0x2d },
409 { (char*)"hu", 0x2d },
410 { (char*)"Armenian", 0x2e },
411 { (char*)"hy", 0x2e },
412 { (char*)"Interlingua", 0x84 },
413 { (char*)"ia", 0x84 },
414 { (char*)"Indonesian", 0x30 },
415 { (char*)"id", 0x30 },
416 { (char*)"Interlingue", 0x86 },
417 { (char*)"ie", 0x86 },
418 { (char*)"Maori", 0x47 },
419 { (char*)"mi", 0x47 },
420 { (char*)"Macedonian", 0x48 },
421 { (char*)"mk", 0x48 },
422 { (char*)"Malayalam", 0x49 },
423 { (char*)"ml", 0x49 },
424 { (char*)"Mongolian", 0x4a },
425 { (char*)"mn", 0x4a },
426 { (char*)"Moldavian", 0x4b },
427 { (char*)"mo", 0x4d },
428 { (char*)"Marathi", 0x4c },
429 { (char*)"mr", 0x4c },
430 { (char*)"Malay", 0x4d },
431 { (char*)"ms", 0x4d },
432 { (char*)"Maltese", 0x4e },
433 { (char*)"mt", 0x4e },
434 { (char*)"Burmese", 0x4f },
435 { (char*)"my", 0x4f },
436 { (char*)"Nauru", 0x50 },
437 { (char*)"na", 0x50 },
438 { (char*)"Nepali", 0x51 },
439 { (char*)"ne", 0x51 },
440 { (char*)"Dutch", 0x52 },
441 { (char*)"nl", 0x52 },
442 { (char*)"Norwegian", 0x53 },
443 { (char*)"no", 0x53 },
444 { (char*)"Occitan", 0x54 },
445 { (char*)"oc", 0x54 },
446 { (char*)"(Afan) Oromo", 0x55 },
447 { (char*)"(Afan)Oromo", 0x55 },
448 { (char*)"om", 0x55 },
449 { (char*)"Oriya", 0x56 },
450 { (char*)"or", 0x56 },
451 { (char*)"Punjabi", 0x57 },
452 { (char*)"pa", 0x57 },
453 { (char*)"Polish", 0x58 },
454 { (char*)"po", 0x58 },
455 { (char*)"Pashto", 0x59 },
456 { (char*)"Pushto", 0x59 },
457 { (char*)"ps", 0x59 },
458 { (char*)"Portugurse", 0x5a },
459 { (char*)"pt", 0x5a },
460 { (char*)"Quechua", 0x5b },
461 { (char*)"qu", 0x5b },
462 { (char*)"Rhaeto-Romance", 0x8c },
463 { (char*)"rm", 0x8c },
464 { (char*)"Kirundi", 0x5d },
465 { (char*)"rn", 0x5d },
466 { (char*)"Romanian", 0x5e },
467 { (char*)"ro", 0x5e },
468 { (char*)"Russian", 0x5f },
469 { (char*)"ru", 0x5f },
470 { (char*)"Kinyarwanda", 0x60 },
471 { (char*)"rw", 0x60 },
472 { (char*)"Sanskrit", 0x61 },
473 { (char*)"sa", 0x61 },
474 { (char*)"Sindhi", 0x62 },
475 { (char*)"sd", 0x62 },
476 { (char*)"Sangho", 0x63 },
477 { (char*)"sg", 0x63 },
478 { (char*)"Serbo-Croatian", 0x64 },
479 { (char*)"sh", 0x64 },
480 { (char*)"Sinhalese", 0x65 },
481 { (char*)"si", 0x65 },
482 { (char*)"Slovak", 0x66 },
483 { (char*)"sk", 0x66 },
484 { (char*)"Slovenian", 0x67 },
485 { (char*)"sl", 0x67 },
486 { (char*)"Samoan", 0x68 },
487 { (char*)"sm", 0x68 },
488 { (char*)"Shona", 0x69 },
489 { (char*)"sn", 0x69 },
490 { (char*)"Somali", 0x6a },
491 { (char*)"so", 0x6a },
492 { (char*)"Albanian", 0x6b },
493 { (char*)"sq", 0x6b },
494 { (char*)"Serbian", 0x6c },
495 { (char*)"sr", 0x6c },
496 { (char*)"Siswati", 0x6d },
497 { (char*)"ss", 0x6d },
498 { (char*)"Sesotho", 0x6e },
499 { (char*)"st", 0x6e },
500 { (char*)"Sundanese", 0x6f },
501 { (char*)"su", 0x6f },
502 { (char*)"Swedish", 0x70 },
503 { (char*)"sv", 0x70 },
504 { (char*)"Swahili", 0x71 },
505 { (char*)"sw", 0x71 },
506 { (char*)"Tamil", 0x72 },
507 { (char*)"ta", 0x72 },
508 { (char*)"Telugu", 0x73 },
509 { (char*)"te", 0x73 },
510 { (char*)"Tajik", 0x74 },
511 { (char*)"tg", 0x74 },
512 { (char*)"Thai", 0x75 },
513 { (char*)"th", 0x75 },
514 { (char*)"Tigrinya", 0x76 },
515 { (char*)"ti", 0x76 },
516 { (char*)"Turkmen", 0x77 },
517 { (char*)"tk", 0x77 },
518 { (char*)"Inupiak", 0x87 },
519 { (char*)"ik", 0x87 },
520 { (char*)"Icelandic", 0x33 },
521 { (char*)"is", 0x33 },
522 { (char*)"Italian", 0x34 },
523 { (char*)"it", 0x34 },
524 { (char*)"Inuktitut", 0x89 },
525 { (char*)"iu", 0x89 },
526 { (char*)"Japanese", 0x36 },
527 { (char*)"ja", 0x36 },
528 { (char*)"Javanese", 0x37 },
529 { (char*)"jw", 0x37 },
530 { (char*)"Georgian", 0x38 },
531 { (char*)"ka", 0x38 },
532 { (char*)"Kazakh", 0x39 },
533 { (char*)"kk", 0x39 },
534 { (char*)"Gerrnlandic", 0x8a },
535 { (char*)"kl", 0x8a },
536 { (char*)"Cambodian", 0x3b },
537 { (char*)"km", 0x3b },
538 { (char*)"Kannada", 0x3c },
539 { (char*)"kn", 0x3c },
540 { (char*)"Kashmiri", 0x3e },
541 { (char*)"ks", 0x3e },
542 { (char*)"Kurdish", 0x3f },
543 { (char*)"ku", 0x3f },
544 { (char*)"Kirghiz", 0x40 },
545 { (char*)"ky", 0x40 },
546 { (char*)"Latin", 0x8b },
547 { (char*)"la", 0x8b },
548 { (char*)"Lingala", 0x42 },
549 { (char*)"ln", 0x42 },
550 { (char*)"Laothian", 0x43 },
551 { (char*)"lo", 0x43 },
552 { (char*)"Lithuanian", 0x44 },
553 { (char*)"lt", 0x44 },
554 { (char*)"Lavian", 0x45 },
555 { (char*)"Lettish", 0x45 },
556 { (char*)"lv", 0x45 },
557 { (char*)"Malagasy", 0x46 },
558 { (char*)"mg", 0x46 },
559 { (char*)"Tagalog", 0x78 },
560 { (char*)"tl", 0x78 },
561 { (char*)"Setswana", 0x79 },
562 { (char*)"tn", 0x79 },
563 { (char*)"Tonga", 0x7a },
564 { (char*)"to", 0x7a },
565 { (char*)"Turkish", 0x7b },
566 { (char*)"tr", 0x7b },
567 { (char*)"Tsonga", 0x7c },
568 { (char*)"ts", 0x7c },
569 { (char*)"Tatar", 0x7d },
570 { (char*)"tt", 0x7d },
571 { (char*)"Twi", 0x7e },
572 { (char*)"tw", 0x7e },
573 { (char*)"Uighur", 0x7f },
574 { (char*)"ug", 0x7f },
575 { (char*)"Ukrainian", 0x1a },
576 { (char*)"uk", 0x1a },
577 { (char*)"Urdu", 0x21 },
578 { (char*)"ur", 0x21 },
579 { (char*)"Uzbek", 0x23 },
580 { (char*)"uz", 0x23 },
581 { (char*)"Vietnamese", 0x2f },
582 { (char*)"vi", 0x2f },
583 { (char*)"Volapuk", 0x85 },
584 { (char*)"vo", 0x85 },
585 { (char*)"Wolof", 0x31 },
586 { (char*)"wo" , 0x31 },
587 { (char*)"Xhosa", 0x32 },
588 { (char*)"xh", 0x32 },
589 { (char*)"Yiddish", 0x88 },
590 { (char*)"yi", 0x88 },
591 { (char*)"Yoruba", 0x35 },
592 { (char*)"yo", 0x35 },
593 { (char*)"Zhuang", 0x3a },
594 { (char*)"z", 0x3a },
595 { (char*)"Chinese", 0x41 },
596 { (char*)"ch", 0x41 },
597 { (char*)"Zulu", 0x5c },
598 { (char*)"zu", 0x5c },
599 { (char*)"Ko", 0x3d }
603 const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] =
605 { (char*)"x-wap-application:*", 0x00 },
606 { (char*)"x-wap-application:push.sia", 0x01},
607 { (char*)"x-wap-application:wml.ua", 0x02 },
608 { (char*)"x-wap-application:wta.ua", 0x03 },
609 { (char*)"x-wap-application:mms.ua", 0x04 },
610 { (char*)"x-wap-application:push.syncml", 0x05 },
611 { (char*)"x-wap-application:loc.ua", 0x06 },
612 { (char*)"x-wap-application:syncml.dm", 0x07 },
613 { (char*)"x-wap-application:drm.ua", 0x08 },
614 { (char*)"x-wap-application:emn.ua", 0x09 },
615 { (char*)"x-oma-docomo:xmd.mail.ua", 0x905C },
619 const char* wspCacheControl[] =
626 (char*)"Only-if-cached",
629 (char*)"No-transform",
630 (char*)"Must-revalidate",
631 (char*)"Proxy-revalidate"
634 const SMS_WSP_METHOD_TYPE_S wspMethodType[] =
636 { (char*)"GET", 0x40 },
637 { (char*)"OPTIONS", 0x41 },
638 { (char*)"HEAD", 0x42 },
639 { (char*)"DELETE", 0x43 },
640 { (char*)"TRACE", 0x44 },
641 { (char*)"POST", 0x60 },
642 { (char*)"PUT", 0x61 }
646 const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] =
648 {(char*)"NETWPIN",0x00},
649 {(char*)"USERPIN",0x01},
650 {(char*)"USERNETWPIN",0x02},
651 {(char*)"USERPINMAC",0x03}
656 const char* wspWeek[] =
668 const char* wspWeekDay[] =
679 const char* wspMonth[] =
697 /*==================================================================================================
698 IMPLEMENTATION OF SmsPluginWapPushHandler - Member Functions
699 ==================================================================================================*/
700 SmsPluginWapPushHandler* SmsPluginWapPushHandler::pInstance = NULL;
703 SmsPluginWapPushHandler::SmsPluginWapPushHandler()
705 memset(&tmpAddress, 0x00, sizeof(tmpAddress));
709 SmsPluginWapPushHandler::~SmsPluginWapPushHandler()
715 SmsPluginWapPushHandler* SmsPluginWapPushHandler::instance()
718 pInstance = new SmsPluginWapPushHandler();
724 bool SmsPluginWapPushHandler::IsWapPushMsg(SMS_USERDATA_S *pUserData)
728 if (pUserData == NULL) {
729 MSG_DEBUG("pUserData is NULL");
733 int PortCount = sizeof(wapPushPortList)/sizeof(wapPushPortList[0]);
735 MSG_DEBUG("Port Count [%d]", PortCount);
737 for (int i = 0; i < pUserData->headerCnt; i++) {
738 if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
739 /** Have to check something??? */
740 } else if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
742 for (int j = 0; j < PortCount; j++) {
743 if (pUserData->header[i].udh.appPort16bit.destPort == wapPushPortList[j]) {
744 MSG_DEBUG("Wap Push Msg : [%04x]", wapPushPortList[j]);
757 SMS_WAP_APP_CODE_T SmsPluginWapPushHandler::getAppCode(const char *pPushHeader)
759 int appCount = sizeof(pushDefaultApplication)/sizeof(pushDefaultApplication[0]) - 1;
761 unsigned char *header = NULL;
762 SMS_WAP_APP_CODE_T appCode = SMS_WAP_APPLICATION_DEFAULT;
764 MSG_DEBUG("Application Count [%d]", appCount);
766 for (int i = 0; i < appCount; i++) {
768 header = (unsigned char*)strcasestr(pPushHeader, pushDefaultApplication[i].pContentType);
770 if (header != NULL) {
771 appCode = pushDefaultApplication[i].appCode;
776 if (appCode == SMS_WAP_APPLICATION_DEFAULT) {
777 MSG_DEBUG("Application Type is not supported");
779 MSG_DEBUG("Find Application [%d]", appCode);
787 void SmsPluginWapPushHandler::copyDeliverData(SMS_DELIVER_S *pDeliver)
789 tmpAddress.ton = pDeliver->originAddress.ton;
790 tmpAddress.npi = pDeliver->originAddress.npi;
792 strncpy(tmpAddress.address, pDeliver->originAddress.address, MAX_ADDRESS_LEN);
794 MSG_DEBUG("Address [%s]", tmpAddress.address);
796 tmpTimeStamp.format = pDeliver->timeStamp.format;
798 if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
799 tmpTimeStamp.time.absolute.year = pDeliver->timeStamp.time.absolute.year;
800 tmpTimeStamp.time.absolute.month = pDeliver->timeStamp.time.absolute.month;
801 tmpTimeStamp.time.absolute.day = pDeliver->timeStamp.time.absolute.day;
802 tmpTimeStamp.time.absolute.hour = pDeliver->timeStamp.time.absolute.hour;
803 tmpTimeStamp.time.absolute.minute = pDeliver->timeStamp.time.absolute.minute;
804 tmpTimeStamp.time.absolute.second = pDeliver->timeStamp.time.absolute.second;
805 tmpTimeStamp.time.absolute.timeZone = pDeliver->timeStamp.time.absolute.timeZone;
810 void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize)
814 #ifdef MSG_FW_FOR_DEBUG
815 MSG_DEBUG("DataSize [%d]", DataSize);
817 MSG_DEBUG("[pUserData]");
818 for (int i = 0; i < DataSize; i++)
820 printf("[%02x]", pUserData[i]);
825 unsigned char* pPDUTypeData = (unsigned char*)pUserData;
826 unsigned long PDUTypeDataLen = DataSize;
828 char* pPushHeader = NULL;
829 AutoPtr<char> pushHeaderBuf(&pPushHeader);
830 unsigned long pushHeaderLen = 0;
832 char* pPushBody = NULL;
833 AutoPtr<char> PushBodyBuf(&pPushBody);
834 unsigned long pushBodyLen = 0;
836 unsigned long iPDU = 1;
838 char* pWspHeader = NULL;
839 AutoPtr<char> WspHeaderBuf(&pWspHeader);
840 unsigned long wspHeaderLen = 0;
842 char* pWspBody = NULL;
843 AutoPtr<char> WspBodyBuf(&pWspBody);
844 unsigned long wspBodyLen = 0;
849 pushHeaderLen = wspRetriveUintvarDecode( pPDUTypeData, &iPDU );
851 MSG_DEBUG("PDUTypeDataLen [%d]", PDUTypeDataLen);
852 MSG_DEBUG("pushHeaderLen [%d]", pushHeaderLen);
853 MSG_DEBUG("iPDU [%d]", iPDU);
855 wspHeaderLen = pushHeaderLen + iPDU;
857 MSG_DEBUG("wspBodyLen [%d]", wspBodyLen);
859 if (wspHeaderLen > 0) {
861 pWspHeader = new char[wspHeaderLen];
863 if (pWspHeader == NULL) {
864 MSG_DEBUG("pWspHeader Memory Allocation Failed");
867 memcpy(pWspHeader, pPDUTypeData, wspHeaderLen);
871 #ifdef MSG_FW_FOR_DEBUG
872 MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
874 MSG_DEBUG("[pWspHeader]");
875 for (int i = 0; i < wspHeaderLen; i++)
877 printf("[%02x]", pWspHeader[i]);
882 /** return if it is below case error */
883 if (PDUTypeDataLen < wspHeaderLen) {
884 MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
888 /** Finding wspBody Information */
889 wspBodyLen = PDUTypeDataLen - wspHeaderLen;
891 if (wspBodyLen > 0) {
893 pWspBody = new char[wspBodyLen];
895 if (pWspBody == NULL) {
896 MSG_DEBUG("pWspBody Memory Allocation Failed");
899 memcpy(pWspBody, pPDUTypeData + wspHeaderLen, wspBodyLen);
905 wspDecodeHeader(pPDUTypeData + iPDU, pushHeaderLen, PDUTypeDataLen - (iPDU + pushHeaderLen), TRUE, &pPushHeader);
907 iPDU = iPDU + pushHeaderLen;
909 pushBodyLen = PDUTypeDataLen - iPDU ;
911 if (pushBodyLen > 0) {
912 pPushBody = new char[pushBodyLen];
914 if (pPushBody == NULL) {
915 MSG_DEBUG("pPushBody Memory Allocation Failed");
918 memcpy(pPushBody, pPDUTypeData+ iPDU, pushBodyLen);
925 handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen);
931 void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
935 if (pPushBody == NULL) {
936 MSG_DEBUG("pPushBody is NULL");
940 SMS_WAP_APP_CODE_T appCode = getAppCode(pPushHeader);
942 /** check Push message receive setting */
943 bool bPushRecv = false;
945 MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
947 if ((bPushRecv == false) && (appCode != SMS_WAP_APPLICATION_MMS_UA)) {
948 MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
953 case SMS_WAP_APPLICATION_MMS_UA:
954 MSG_DEBUG("Received MMS Notification");
955 handleMMSNotification(pPushBody, PushBodyLen);
958 case SMS_WAP_APPLICATION_PUSH_SI:
959 MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
960 handleSIMessage(pPushBody, PushBodyLen, true);
963 case SMS_WAP_APPLICATION_PUSH_SIC:
964 MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
965 handleSIMessage(pPushBody, PushBodyLen, false);
968 case SMS_WAP_APPLICATION_PUSH_SL:
969 MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
970 handleSLMessage(pPushBody, PushBodyLen, true);
973 case SMS_WAP_APPLICATION_PUSH_SLC:
974 MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
975 handleSLMessage(pPushBody, PushBodyLen, false);
978 case SMS_WAP_APPLICATION_PUSH_CO:
979 MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
980 handleCOMessage(pPushBody, PushBodyLen, true);
983 case SMS_WAP_APPLICATION_PUSH_COC:
984 MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
985 handleCOMessage(pPushBody, PushBodyLen, false);
988 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
989 MSG_DEBUG("Received DM BOOTSTRAP");
990 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
993 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
994 MSG_DEBUG("Received DM BOOTSTRAP");
995 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
998 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
999 MSG_DEBUG("Received Provisioning");
1000 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1003 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
1004 MSG_DEBUG("Received Provisioning");
1005 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1008 case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
1009 case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
1010 MSG_DEBUG("Received Provisioning");
1011 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1014 case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
1015 MSG_DEBUG("Received DM Notification");
1016 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1019 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
1020 MSG_DEBUG("Received DS Notification");
1021 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1024 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
1025 MSG_DEBUG("Received DS Notification");
1026 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1029 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
1030 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
1031 MSG_DEBUG("Received DRM UA");
1033 if (pPushBody != NULL)
1034 handleDrmVer1(pPushBody, PushBodyLen);
1038 case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
1039 case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
1040 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
1041 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
1042 MSG_DEBUG("Received DRM V2");
1046 case SMS_WAP_APPLICATION_PUSH_EMAIL:
1047 case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
1048 case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
1049 MSG_DEBUG("Received Email");
1053 case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
1054 MSG_DEBUG("Received IMPS CIR");
1058 case SMS_WAP_APPLICATION_LBS :
1059 MSG_DEBUG("Received LBS related message");
1060 SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
1064 case SMS_WAP_APPLICATION_PUSH_SIA :
1065 MSG_DEBUG("Received SIA");
1070 MSG_DEBUG("Unknown Application [%d]", appCode);
1077 static void launchProcessByAppcode(int appcode)
1080 GError *error = NULL;
1081 DBusGConnection *connection = NULL;
1082 DBusGProxy *dbus_proxy;
1085 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
1086 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
1087 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
1088 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
1089 case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
1090 case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
1091 case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
1093 connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
1094 if (error != NULL) {
1095 MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
1096 g_error_free(error);
1099 dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadmagent",
1100 "/com/samsung/omadmagent", "com.samsung.omadmagent");
1101 MSG_DEBUG("dbus_proxy %x", dbus_proxy);
1102 dbus_g_proxy_call(dbus_proxy, "Hello_Agent", &error, G_TYPE_INVALID, G_TYPE_INVALID);
1103 g_object_unref(dbus_proxy);
1104 dbus_g_connection_unref(connection);
1108 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
1109 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
1111 connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
1112 if (error != NULL) {
1113 MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
1114 g_error_free(error);
1117 dbus_proxy = dbus_g_proxy_new_for_name(connection, "com.samsung.omadsagent",
1118 "/com/samsung/omadsagent", "com.samsung.omadsagent");
1119 MSG_DEBUG("dbus_proxy %x", dbus_proxy);
1120 dbus_g_proxy_call(dbus_proxy, "Hello_Agent", &error, G_TYPE_INVALID, G_TYPE_INVALID);
1121 g_object_unref(dbus_proxy);
1122 dbus_g_connection_unref(connection);
1132 void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
1136 if (pPushBody == NULL) {
1137 MSG_DEBUG("pPushBody is NULL");
1141 msg_error_t err = MSG_SUCCESS;
1142 int pushEvt_cnt = 0;
1143 char app_id[MAX_WAPPUSH_ID_LEN] = {0,};
1144 SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
1146 err = storageHandler->getRegisteredPushEvent(pPushHeader, &pushEvt_cnt, app_id);
1147 MSG_DEBUG("pushEvt_cnt: %d", pushEvt_cnt);
1148 if(err != MSG_SUCCESS) {
1149 MSG_DEBUG("Fail to get registered push event");
1153 for(int i = 0; i < pushEvt_cnt; ++i) {
1155 /** check Push message receive setting */
1156 bool bPushRecv = false;
1158 MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv);
1160 storageHandler->getnthPushEvent(i, &appcode);
1161 MSG_DEBUG("pushEvt_cnt: %d, appcode: %d", pushEvt_cnt, appcode);
1162 if ((bPushRecv == false) && (appcode != SMS_WAP_APPLICATION_MMS_UA)) {
1163 MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
1167 launchProcessByAppcode(appcode);
1170 case SMS_WAP_APPLICATION_MMS_UA:
1171 MSG_DEBUG("Received MMS Notification");
1172 handleMMSNotification(pPushBody, PushBodyLen);
1175 case SMS_WAP_APPLICATION_PUSH_SI:
1176 MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
1177 handleSIMessage(pPushBody, PushBodyLen, true);
1180 case SMS_WAP_APPLICATION_PUSH_SIC:
1181 MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
1182 handleSIMessage(pPushBody, PushBodyLen, false);
1185 case SMS_WAP_APPLICATION_PUSH_SL:
1186 MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
1187 handleSLMessage(pPushBody, PushBodyLen, true);
1190 case SMS_WAP_APPLICATION_PUSH_SLC:
1191 MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
1192 handleSLMessage(pPushBody, PushBodyLen, false);
1195 case SMS_WAP_APPLICATION_PUSH_CO:
1196 MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
1197 handleCOMessage(pPushBody, PushBodyLen, true);
1200 case SMS_WAP_APPLICATION_PUSH_COC:
1201 MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
1202 handleCOMessage(pPushBody, PushBodyLen, false);
1205 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
1206 MSG_DEBUG("Received DM BOOTSTRAP");
1207 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1210 case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
1211 MSG_DEBUG("Received DM BOOTSTRAP");
1212 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1215 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
1216 MSG_DEBUG("Received Provisioning");
1217 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1220 case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
1221 MSG_DEBUG("Received Provisioning");
1222 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1225 case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
1226 case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
1227 MSG_DEBUG("Received Provisioning");
1228 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1231 case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
1232 MSG_DEBUG("Received DM Notification");
1233 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1236 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
1237 MSG_DEBUG("Received DS Notification");
1238 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1241 case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
1242 MSG_DEBUG("Received DS Notification");
1243 SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
1246 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
1247 case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
1248 MSG_DEBUG("Received DRM UA");
1250 if (pPushBody != NULL)
1251 handleDrmVer1(pPushBody, PushBodyLen);
1255 case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
1256 case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
1257 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
1258 case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
1259 MSG_DEBUG("Received DRM V2");
1263 case SMS_WAP_APPLICATION_PUSH_EMAIL:
1264 case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
1265 case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
1266 MSG_DEBUG("Received Email");
1270 case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
1271 MSG_DEBUG("Received IMPS CIR");
1275 case SMS_WAP_APPLICATION_LBS :
1276 MSG_DEBUG("Received LBS related message");
1277 SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
1281 case SMS_WAP_APPLICATION_PUSH_SIA :
1282 MSG_DEBUG("Received SIA");
1287 SmsPluginEventHandler::instance()->handlePushMsgIncoming(pPushHeader, pPushBody, PushBodyLen, app_id);
1291 storageHandler->releasePushEvent();
1297 void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen)
1301 #ifdef MSG_FW_FOR_DEBUG
1302 printf("\n\n[handleMMSNotification] Push Body.\n");
1304 for (int i = 0; i < PushBodyLen; i++)
1306 printf(" [%02x]", pPushBody[i]);
1311 /** Make MSG_MESSAGE_INFO_S */
1312 MSG_MESSAGE_INFO_S msgInfo;
1313 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
1315 createMsgInfo(&msgInfo);
1317 /** Convert Type values */
1318 msgInfo.msgType.mainType = MSG_MMS_TYPE;
1319 msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
1320 msgInfo.storageId = MSG_STORAGE_PHONE;
1321 msgInfo.dataSize = PushBodyLen;
1323 if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
1324 msgInfo.bTextSms = false;
1326 /** Save Message Data into File */
1327 char fileName[MSG_FILENAME_LEN_MAX+1];
1328 memset(fileName, 0x00, sizeof(fileName));
1330 if (MsgCreateFileName(fileName) == false)
1331 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1333 if (MsgWriteIpcFile(fileName, pPushBody, msgInfo.dataSize) == false)
1334 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1336 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1338 msgInfo.bTextSms = true;
1340 memcpy(msgInfo.msgText, pPushBody, msgInfo.dataSize);
1341 msgInfo.msgText[msgInfo.dataSize] = '\0';
1344 msg_error_t err = MSG_SUCCESS;
1346 /** Add MMS Noti Msg into DB */
1347 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
1349 if (err == MSG_SUCCESS) {
1351 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1353 if (err != MSG_SUCCESS) {
1354 MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
1357 MSG_DEBUG("addMessage() Error !! [%d]", err);
1363 void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText)
1367 MSG_PUSH_MESSAGE_S pushMsg = {};
1369 xmlDocPtr xmlDoc = NULL;
1370 xmlNodePtr topNode = NULL;
1371 xmlNodePtr indNode = NULL;
1373 xmlChar* tmpXmlChar = NULL;
1375 if (pPushBody == NULL) {
1376 MSG_DEBUG("pPushBody is NULL");
1380 getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
1382 if (xmlDoc == NULL) {
1383 MSG_DEBUG("xmlDoc is NULL");
1387 topNode = xmlDocGetRootElement(xmlDoc);
1389 if (topNode == NULL) {
1390 MSG_DEBUG("topNode is NULL");
1395 indNode = topNode->xmlChildrenNode;
1397 while (indNode != NULL) {
1398 if (!xmlStrcmp(indNode->name, (const xmlChar*) "indication")) {
1399 MSG_DEBUG("indNode->name = %s\n", indNode->name);
1403 indNode = indNode->next;
1406 if (indNode == NULL) {
1407 MSG_DEBUG("indNode is NULL.");
1411 /** temporary set to max. */
1412 pushMsg.expires = 0xFFFFFFFF;
1414 /** setting received time */
1415 time_t t = time(NULL);
1416 time_t utfTime = time(&t);
1418 pushMsg.received = (unsigned long)utfTime;
1420 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
1422 if (tmpXmlChar == NULL) {
1423 MSG_DEBUG("href is NULL.");
1427 if (tmpXmlChar != NULL)
1428 strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
1430 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_SI_ID_TAG);
1432 if (tmpXmlChar != NULL)
1433 strncpy(pushMsg.id, (char*)tmpXmlChar, MAX_WAPPUSH_ID_LEN-1);
1435 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CREATED_TAG);
1437 if (tmpXmlChar != NULL)
1438 pushMsg.created = convertXmlCharToSec((char*)tmpXmlChar);
1440 if (pushMsg.created == 0)
1441 pushMsg.created = pushMsg.received;
1443 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_EXPIRES_TAG);
1445 if (tmpXmlChar != NULL)
1446 pushMsg.expires = convertXmlCharToSec((char*)tmpXmlChar);
1448 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
1450 pushMsg.action = convertSIActionStrToEnum((char*)tmpXmlChar);
1452 tmpXmlChar = xmlNodeListGetString(xmlDoc, indNode->xmlChildrenNode, 1);
1454 if (tmpXmlChar == NULL) {
1455 MSG_DEBUG("contents is NULL.");
1459 strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
1461 /** Write push Msg to file */
1462 char fileName[MSG_FILENAME_LEN_MAX+1];
1463 memset(fileName, 0x00, sizeof(fileName));
1465 if (MsgCreateFileName(fileName) == false) {
1467 xmlFree(tmpXmlChar);
1468 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1471 if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false) {
1473 xmlFree(tmpXmlChar);
1474 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1477 /** Pack Message Info Structure */
1478 MSG_MESSAGE_INFO_S msgInfo;
1480 createMsgInfo(&msgInfo);
1482 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1484 /** Convert Type values */
1485 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1486 msgInfo.msgType.subType = MSG_WAP_SI_SMS;
1488 msgInfo.dataSize = sizeof(pushMsg);
1491 xmlFree(tmpXmlChar);
1493 msg_error_t err = MSG_SUCCESS;
1495 /** Add WAP Push Msg into DB */
1496 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
1498 if (err == MSG_SUCCESS) {
1500 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1502 if (err != MSG_SUCCESS){
1503 MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
1506 MSG_DEBUG("addMessage() Error !! [%d]", err);
1515 void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, bool isText)
1519 MSG_PUSH_MESSAGE_S pushMsg = {};
1521 xmlDocPtr xmlDoc = NULL;
1522 xmlNodePtr topNode = NULL;
1523 xmlNodePtr indNode = NULL;
1525 xmlChar* tmpXmlChar = NULL;
1527 msg_error_t err = MSG_SUCCESS;
1529 if (pPushBody == NULL) {
1530 MSG_DEBUG("pPushBody is NULL \n" );
1534 getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
1536 if (xmlDoc == NULL) {
1537 MSG_DEBUG("xmlDoc is NULL \n" );
1541 topNode = xmlDocGetRootElement(xmlDoc);
1543 if (topNode == NULL) {
1544 MSG_DEBUG("Empty Document." );
1548 MSG_DEBUG("Not an empty Document and topNode->name = %s \n",topNode->name );
1553 while (indNode != NULL) {
1554 if (!xmlStrcmp(indNode->name, (const xmlChar*) "sl")) {
1555 MSG_DEBUG("indNode->name = %s\n",indNode->name);
1559 indNode = indNode->next;
1562 /** setting received time setting */
1563 time_t t = time(NULL);
1564 time_t utfTime = time(&t);
1566 pushMsg.received = (unsigned long)utfTime;
1568 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
1570 if (tmpXmlChar == NULL) {
1571 MSG_DEBUG("href is NULL.");
1575 strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
1577 tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
1578 pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
1580 /** Setting other parameters in default values */
1581 pushMsg.created = pushMsg.received;
1582 /** temporary set to MAX value. */
1583 pushMsg.expires = 0xFFFFFFFF;
1585 MSG_DEBUG("check pushMsg data");
1586 MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
1587 MSG_DEBUG("pushMsg.received : [%d]", pushMsg.received);
1588 MSG_DEBUG("pushMsg.created : [%d]", pushMsg.created);
1589 MSG_DEBUG("pushMsg.expires : [%d]", pushMsg.expires);
1590 MSG_DEBUG("pushMsg.id : [%s]", pushMsg.id);
1591 MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
1592 MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
1594 /** Write push Msg to file */
1595 char fileName[MSG_FILENAME_LEN_MAX+1];
1596 memset(fileName, 0x00, sizeof(fileName));
1598 if (MsgCreateFileName(fileName) == false)
1599 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1601 if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
1602 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1604 /** Pack Message Info Structure */
1605 MSG_MESSAGE_INFO_S msgInfo;
1607 createMsgInfo(&msgInfo);
1609 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1611 /** Convert Type values */
1612 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1613 msgInfo.msgType.subType = MSG_WAP_SL_SMS;
1615 /** Update Msg Text */
1616 strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
1618 msgInfo.dataSize = sizeof(pushMsg);
1620 MSG_DEBUG("dataSize : %d", msgInfo.dataSize);
1622 /** Callback to MSG FW */
1623 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1625 if (err != MSG_SUCCESS)
1626 MSG_DEBUG("callbackMsgIncoming is failed, err=[%d]", err);
1629 xmlFree(tmpXmlChar);
1636 void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText)
1638 MSG_PUSH_CACHEOP_S cacheOp;
1640 xmlDocPtr xmlDoc = NULL;
1641 xmlNodePtr topNode = NULL;
1642 xmlNodePtr indNode = NULL;
1644 memset(&cacheOp, 0x00, sizeof(cacheOp));
1646 MSG_DEBUG("Enter handleCOMessage");
1648 if (pPushBody == NULL) {
1649 MSG_DEBUG("pPushBody is NULL \n" );
1653 getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
1655 if (xmlDoc == NULL) {
1656 MSG_DEBUG("xmlDoc is NULL \n" );
1660 topNode = xmlDocGetRootElement(xmlDoc);
1661 if (topNode == NULL) {
1662 MSG_DEBUG("Warning:Empty Document\n" );
1667 indNode = topNode->xmlChildrenNode;
1670 while(indNode != NULL) {
1672 xmlChar* tmpUrl = NULL;
1673 if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_OBJ)) {
1674 MSG_DEBUG("indNode->name = %s\n", indNode->name);
1676 tmpUrl = xmlGetProp(indNode, (xmlChar*) SMS_PUSH_XML_CO_URI);
1678 if (tmpUrl != NULL) {
1679 strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
1681 MSG_DEBUG("%dth invalObjectUrl is <%s>\n", cacheOp.invalObjectCnt, cacheOp.invalObjectUrl[cacheOp.invalObjectCnt-1]);
1683 MSG_DEBUG("NO href value from the xmlDoc\n");
1685 } else if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_SVC)) {
1686 MSG_DEBUG("indNode->name = %s\n",indNode->name);
1687 tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
1689 if (tmpUrl != NULL) {
1690 strncpy(cacheOp.invalServiceUrl[cacheOp.invalServiceCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
1691 MSG_DEBUG("%dth invalServiceUrl is <%s>\n", cacheOp.invalServiceCnt, cacheOp.invalServiceUrl[cacheOp.invalServiceCnt-1]);
1693 MSG_DEBUG("NO href value from the xmlDoc\n");
1700 indNode = indNode->next;
1703 /** Write push Msg to file */
1704 char fileName[MSG_FILENAME_LEN_MAX+1];
1705 memset(fileName, 0x00, sizeof(fileName));
1707 if (MsgCreateFileName(fileName) == false) {
1709 THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
1712 if (MsgWriteIpcFile(fileName, (char*)(&cacheOp), sizeof(cacheOp)) == false) {
1714 THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
1717 /** Pack Message Info Structure */
1718 MSG_MESSAGE_INFO_S msgInfo;
1720 createMsgInfo(&msgInfo);
1722 strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
1724 /** Convert Type values */
1725 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1726 msgInfo.msgType.subType = MSG_WAP_CO_SMS;
1728 msgInfo.dataSize = sizeof(cacheOp);
1730 msg_error_t err = MSG_SUCCESS;
1732 /** Add WAP Push Msg into DB */
1733 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
1735 if (err == MSG_SUCCESS) {
1737 err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
1739 if (err != MSG_SUCCESS) {
1740 MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
1743 MSG_DEBUG("addMessage() Error !! [%d]", err);
1752 void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
1754 int drmRt = DRM_RETURN_SUCCESS;
1756 AutoPtr<char> buf(&cid);
1758 MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message.");
1759 drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE;
1760 drm_register_lic_info_s lic_req_info;
1761 drm_register_lic_resp_s lic_resp_info;
1763 bzero(&lic_req_info, sizeof(drm_register_lic_info_s));
1764 bzero(&lic_resp_info, sizeof(drm_register_lic_resp_s));
1765 bzero(lic_req_info.lic_data, sizeof(lic_req_info.lic_data));
1767 memcpy(lic_req_info.lic_data, pPushBody, PushBodyLen);
1769 lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS;
1770 lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_WAPPUSH;
1771 lic_req_info.operation_callback.callback = NULL;
1773 drmRt = drm_process_request(request_type, &lic_req_info, &lic_resp_info);
1774 if (drmRt == DRM_RETURN_SUCCESS) {
1775 MSG_DEBUG("DRM successfully registed to drm-service.");
1777 MSG_DEBUG("Fail to regist DRM to drm-service.");
1784 void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
1786 /** Convert class Type values */
1787 pMsgInfo->msgType.classType = MSG_CLASS_NONE;
1789 /** set folder id (temporary) */
1790 pMsgInfo->folderId = MSG_INBOX_ID;
1792 pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
1793 pMsgInfo->bRead = false;
1794 pMsgInfo->bProtected = false;
1795 pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
1796 pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
1799 time_t rawtime = time(NULL);
1801 /*** Comment below lines to save local UTC time..... (it could be used later.)
1803 if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
1805 MSG_DEBUG("year : %d", tmpTimeStamp.time.absolute.year);
1806 MSG_DEBUG("month : %d", tmpTimeStamp.time.absolute.month);
1807 MSG_DEBUG("day : %d", tmpTimeStamp.time.absolute.day);
1808 MSG_DEBUG("hour : %d", tmpTimeStamp.time.absolute.hour);
1809 MSG_DEBUG("minute : %d", tmpTimeStamp.time.absolute.minute);
1810 MSG_DEBUG("second : %d", tmpTimeStamp.time.absolute.second);
1811 MSG_DEBUG("timezone : %d", tmpTimeStamp.time.absolute.timeZone);
1813 char displayTime[32];
1817 memset(&timeinfo, 0x00, sizeof(tm));
1819 timeinfo.tm_year = (tmpTimeStamp.time.absolute.year + 100);
1820 timeinfo.tm_mon = (tmpTimeStamp.time.absolute.month - 1);
1821 timeinfo.tm_mday = tmpTimeStamp.time.absolute.day;
1822 timeinfo.tm_hour = tmpTimeStamp.time.absolute.hour;
1823 timeinfo.tm_min = tmpTimeStamp.time.absolute.minute;
1824 timeinfo.tm_sec = tmpTimeStamp.time.absolute.second;
1825 timeinfo.tm_isdst = 0;
1827 rawtime = mktime(&timeinfo);
1829 MSG_DEBUG("tzname[0] [%s]", tzname[0]);
1830 MSG_DEBUG("tzname[1] [%s]", tzname[1]);
1831 MSG_DEBUG("timezone [%d]", timezone);
1832 MSG_DEBUG("daylight [%d]", daylight);
1834 memset(displayTime, 0x00, sizeof(displayTime));
1835 strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
1836 MSG_DEBUG("displayTime [%s]", displayTime);
1838 rawtime -= (tmpTimeStamp.time.absolute.timeZone * (3600/4));
1840 timeTM = localtime(&rawtime);
1841 memset(displayTime, 0x00, sizeof(displayTime));
1842 strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
1843 MSG_DEBUG("displayTime [%s]", displayTime);
1845 rawtime -= timezone;
1847 timeTM = localtime(&rawtime);
1848 memset(displayTime, 0x00, sizeof(displayTime));
1849 strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
1850 MSG_DEBUG("displayTime [%s]", displayTime);
1855 pMsgInfo->displayTime = rawtime;
1857 /** Convert Address values */
1858 pMsgInfo->nAddressCnt = 1;
1859 pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
1860 strncpy(pMsgInfo->addressList[0].addressVal, tmpAddress.address, MAX_ADDRESS_VAL_LEN);
1862 pMsgInfo->msgPort.valid = false;
1863 pMsgInfo->msgPort.dstPort = 0;
1864 pMsgInfo->msgPort.srcPort = 0;
1868 void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
1870 if (pPushBody == NULL) {
1871 MSG_DEBUG("pPushBody is NULL");
1877 *pXmlDoc = xmlParseMemory(pPushBody, strlen(pPushBody));
1879 WB_UTINY* xmldata = NULL;
1880 WBXMLConvWBXML2XML *conv = NULL;
1881 WBXMLError ret = WBXML_OK;
1883 ret = wbxml_conv_wbxml2xml_create(&conv);
1884 if (ret != WBXML_OK)
1887 ret = wbxml_conv_wbxml2xml_run(conv, (WB_UTINY*)pPushBody, (WB_ULONG)PushBodyLen, &xmldata, NULL);
1889 wbxml_conv_wbxml2xml_destroy(conv);
1891 if (ret != WBXML_OK ||xmldata == NULL) {
1892 MSG_DEBUG("xmldata is NULL. Error code is [%d].\n", ret);
1896 MSG_DEBUG("xmldata : \n%s\n", xmldata);
1898 *pXmlDoc = xmlParseMemory((char*)xmldata, strlen((char*)xmldata));
1903 unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
1905 struct tm timeStruct;
1906 time_t nTimeInSec = 0;
1908 int i = 0, index = 0;
1910 memset(tmpBuf, 0x00, sizeof(tmpBuf));
1911 memset(&timeStruct, 0x00, sizeof(struct tm));
1914 if (strlen(pDate)<20)
1917 MSG_DEBUG("pDate [%s]", pDate);
1920 for (i = 0; i < 4; i++) {
1921 tmpBuf[i] = pDate[index++];
1925 timeStruct.tm_year = (atoi( tmpBuf)-1900);
1928 for (i = 0; i < 2; i++) {
1929 tmpBuf[i] = pDate[index++];
1933 timeStruct.tm_mon = (atoi( tmpBuf) - 1);
1936 for (i = 0; i < 2; i++) {
1937 tmpBuf[i] = pDate[index++];
1941 timeStruct.tm_mday = atoi( tmpBuf);
1944 for (i = 0; i < 2; i++) {
1945 tmpBuf[i] = pDate[index++];
1949 timeStruct.tm_hour = atoi( tmpBuf);
1952 for (i = 0; i < 2; i++) {
1953 tmpBuf[i] = pDate[index++];
1957 timeStruct.tm_min = atoi( tmpBuf);
1960 for (i = 0; i < 2; i++) {
1961 tmpBuf[i] = pDate[index++];
1965 timeStruct.tm_sec = atoi( tmpBuf);
1967 nTimeInSec = mktime(&timeStruct);
1972 msg_push_action_t SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pAction)
1976 if (pAction == NULL) {
1977 MSG_DEBUG("pAction is NULL. Setting to default action type.");
1978 return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
1981 /** compare with signal-none. */
1982 comp = strcmp( "signal-none", pAction );
1984 return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
1986 /** compare with signal-low. */
1987 comp = strcmp( "signal-low", pAction );
1989 return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
1991 /** compare with signal-medium. */
1992 comp = strcmp( "signal-medium", pAction );
1994 return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
1996 /** compare with signal-high. */
1997 comp = strcmp( "signal-high", pAction );
1999 return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
2001 /** compare with delete. */
2002 comp = strcmp( "delete", pAction );
2004 return MSG_PUSH_SI_ACTION_DELETE;
2006 /** signal-medium is default action value. */
2007 return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
2011 msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pAction)
2015 if (pAction == NULL) {
2016 MSG_DEBUG( "MSG_DEBUG is NULL. Setting to default action type.\n" );
2017 return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
2020 /** compare pSrcStr with execute-low. */
2021 comp = strcmp( "execute-low", pAction );
2023 return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
2025 /** compare pSrcStr with execute-high. */
2026 comp = strcmp( "execute-high", pAction );
2028 return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
2030 /** compare pSrcStr with cache. */
2031 comp = strcmp( "cache", pAction );
2033 return MSG_PUSH_SL_ACTION_CACHE;
2035 /** default SL action value is execute-low. */
2036 return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
2041 unsigned long SmsPluginWapPushHandler::wspRetriveUintvarDecode( unsigned char* sourceData, unsigned long* currentPointer )
2043 unsigned long i = 0;
2044 unsigned long decodedValue;
2046 while (sourceData[*currentPointer +i] >= 0x80) i++;
2048 decodedValue = wspDecodeUintvar( i+1, sourceData + *currentPointer );
2049 *currentPointer = *currentPointer + i + 1;
2050 MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%d .\n",decodedValue );
2051 return decodedValue;
2055 unsigned long SmsPluginWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar )
2058 unsigned long decodedUintvar = 0;
2061 for (i = 0 ; i < length; i++) {
2062 decodedUintvar = decodedUintvar + ( wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f ));
2065 return decodedUintvar;
2069 void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
2071 unsigned long iField;
2072 bool continueField = FALSE;
2073 unsigned long currentLength;
2075 char* encodedHeader = NULL;
2076 AutoPtr<char> encodedHeaderbuf(&encodedHeader);
2078 char* outTemper = NULL;
2080 char* temper = NULL;
2081 AutoPtr<char> temperbuf(&temper);
2083 unsigned char track;
2084 unsigned long iEncodedHeader = 0;
2085 unsigned char fieldCode = 0xff;
2087 /* outTemper is Decoded Headers.
2088 temper is Single Decoded Header.
2090 if (NULL == ( outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
2091 MSG_DEBUG("outTemper Memory allocation is failed.\n" );
2094 memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
2095 currentLength = WSP_STANDARD_STR_LEN_MAX;
2097 MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n" );
2103 MSG_DEBUG("wspDecodeHeader: RAW data \n" );
2104 for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) {
2106 szTempBuf[0] = 0x00;
2107 sprintf( szTempBuf, "%2X ", sEncodedHeader[loop] );
2109 if (AcStrlen( szBuf ) + 7 < 64) {
2110 strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
2112 strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
2113 MSG_DEBUG("[%s]", szBuf);
2115 strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 );
2118 strncat( szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1 );
2119 MSG_DEBUG("[%s]", szBuf);
2120 MSG_DEBUG("fContentType=%d \n",fContentType );
2121 /* operation for content-type */
2122 /* makes psuedo- content-type fieldcode */
2123 /* 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. */
2126 encodedHeader = new char[ encodedHeaderLen + 1 ];
2127 if (encodedHeader == NULL) {
2128 MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
2131 encodedHeader[0] = 0x91;
2132 memcpy( encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen );
2134 encodedHeader = new char[ encodedHeaderLen ];
2135 if (encodedHeader == NULL) {
2136 MSG_DEBUG("encodedHeader Memory allocation is failed.\n" );
2140 memcpy( encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen );
2143 /* Is it reacehd end of header? */
2144 while (iEncodedHeader < encodedHeaderLen) {
2145 /* Get memory for single header */
2146 temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
2147 if (temper == NULL) {
2148 MSG_DEBUG("temper Memory allocation is failed.\n" );
2152 memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
2154 /* this section presents header code page shifting procedure
2155 This part can be implemented by future request.
2156 if (track == 0x 7f )
2158 track = encodedHeader[iEncodedHeader];
2160 if (track == 0x00) {
2161 MSG_DEBUG("WspLDecodeHeader: fieldcode is 0 \n" );
2162 strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
2165 } else if (( track > 0 ) && ( track < 0x20 )) {
2167 } else if (( track < 0x7f ) && ( track > 0x1f )) { /* In this case, first byte is normal string. So it's considered to unknown header. */
2168 unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
2169 unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
2171 strncpy( (char*)fieldName, (char*)(encodedHeader + iEncodedHeader ),WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
2172 fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
2173 iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldName ) + 1;
2174 strncpy( (char*)fieldValue, (char*)(encodedHeader + iEncodedHeader ), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
2175 fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
2176 iEncodedHeader = iEncodedHeader + AcStrlen( (char*)fieldValue ) + 1;
2178 strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2179 strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2180 strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2181 /* this means 'don't process anymore.' */
2184 } else if (track > 0x7f) {
2185 /* In case of first byte is field code, else case is error. */
2187 /*if (( track & 0x7f ) <= wspHeaderFieldCount ) */
2190 unsigned long fieldValueLen = encodedHeader[iEncodedHeader + 1];
2191 unsigned char fieldValue[1275];
2192 fieldCode = track & 0x7f;
2194 if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 ))
2196 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] );
2199 memset(fieldValue, 0, 1275);
2201 /* add field name */
2202 /* 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. */
2203 if (!continueField) {
2204 strncat( (char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2205 strncat( (char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2206 continueField = FALSE;
2209 /* field value is string */
2210 /* In this case, it just copy field value. */
2211 if (( fieldValueLen > LENGTH_QUOTE ) && ( fieldValueLen < 0x80 )) {
2213 /* string field value should be NULL terminated */
2214 strncat( (char*)temper, (char*)(encodedHeader + iEncodedHeader + 1 ), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2215 strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2217 iEncodedHeader = iEncodedHeader + AcStrlen( (char*)encodedHeader + iEncodedHeader + 1 ) + 2;
2220 /* first field value is length */
2221 /* If first byte of field value is length value, allocate field value by the length.
2222 In field value, data is
2223 1D 03 8F 24 24 - Then 8F 24 24 is field value.
2224 1D 1F 33.... - Then allocate 33H for FieldValue.
2226 1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
2227 1D 8F 24 24 - In this case, original data is wrong.
2228 If accept-charset: ISO-10646-ucs-2;Q=0.7 is
2231 03 - field value length
2232 03 E8 47 - field value
2233 it's decoded by above value.
2235 if (fieldValueLen < 0x20) {
2237 if (fieldValueLen == LENGTH_QUOTE) {
2239 /* field length is encoded in UINTVAR */
2240 unsigned long uintvarLen = 0;
2241 fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen );
2242 memcpy( fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen );
2243 iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
2247 if (fieldValueLen == 1) {
2248 /* field value is one byte integer over 0x80 */
2249 /** make it two byte integer */
2250 fieldValue[0] = 0x00;
2251 memcpy( fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
2253 iEncodedHeader = iEncodedHeader + 1 + 2;
2255 memcpy( fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen );
2256 fieldValue[fieldValueLen] = 0;
2257 iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
2258 if (( fieldValueLen == 0 ) || ( fieldValueLen == 0x80 )) {
2259 MSG_DEBUG("%X \n", encodedHeader[iEncodedHeader] );
2264 /* field value is single encoded */
2265 if (fieldValueLen > 0x7f) {
2266 fieldValue[0] = encodedHeader[iEncodedHeader + 1];
2268 iEncodedHeader = iEncodedHeader + 2;
2270 /* processing normal pre-defined field decoding */
2272 MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode );
2273 MSG_DEBUG("WspLDecodeHeader: fieldSize %d\n", fieldValueLen );
2275 if (( fieldCode > wspHeaderFieldCount ) && ( fieldCode != 0xff )) {
2276 MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track );
2277 strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
2282 switch ( fieldCode )
2284 /* accept charset */
2285 /* It's normal way of field process. */
2288 unsigned long i = 0;
2291 /* Case of length of charset greater than 1 are two thigins.
2292 1. code length of charset is greater than 1.
2293 2. It include parameter.
2296 if (1 != fieldValueLen) {
2297 code = wspHeaderDecodeInteger( fieldValue );
2298 /* Calculate iField. */
2299 if (fieldValue[0] < 0x80 )
2300 iField = fieldValue[0];
2304 while ( wspCharset[i].charsetCode != code )
2306 strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2307 /* If parameter exist */
2308 if (iField < fieldValueLen) {
2310 AutoPtr<char> parambuf(¶m);
2311 wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, ¶m);
2312 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2315 code = fieldValue[0] & 0x7f;
2317 while (( wspCharset[i].charsetCode != code ) && ( wspCharset[i].charsetCode != 0xffff )) i++;
2318 strncat( (char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2325 /* Like below routine, Same decoding routine process together. */
2326 /* Accept-encoding */
2328 /* content-encoding */
2333 integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen );
2334 if (integerValue > 2) {
2335 MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
2338 strncat( (char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2341 /* contents type decoder */
2347 unsigned long contentsTypeCode;
2348 unsigned long i = 0;
2349 /* encoded content type length body */
2350 unsigned long tempLen;
2352 /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
2353 if (0 == fieldValueLen) {
2354 strncat( (char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2357 /* 01 AE --> 00 AE --> AE*/
2358 if (fieldValueLen == 2 && fieldValue[0] == 0) {
2359 memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
2360 MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
2363 if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
2364 if (fieldValue[0] > 0x80) {
2366 } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
2367 fieldValue[3] = fieldValue[2];
2368 fieldValue[2] = fieldValue[1];
2369 fieldValue[1] = fieldValue[0];
2370 fieldValue[0] = 0x02;
2373 MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n" );
2375 tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
2380 char* szExtendedContent;
2382 contentsTypeCode = fieldValue[0] & 0x7f;
2383 while (( wspContentsType[i].contentsTypeCode != contentsTypeCode ) && ( i < wspContentsTypeCount )) i++;
2385 /* If specified content type doesn't exist */
2386 if (i < wspContentsTypeCount)
2387 strncat( (char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2389 szExtendedContent = wspExtendedDecodeType( (char)contentsTypeCode );
2391 if (szExtendedContent != NULL) {
2392 MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n " );
2393 strncat( (char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2396 contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
2398 while ((wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspUnregisteredContentsTypeCount)) i++;
2400 /** If there is a Content-Type assigned, */
2401 if (i < wspUnregisteredContentsTypeCount)
2402 strncat ((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2407 tempLen = AcStrlen( (char*)fieldValue ) + 1;
2409 strncat ((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2410 MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
2413 /* If there is a parameter */
2414 if (tempLen < fieldValueLen) {
2416 AutoPtr<char> parambuf(¶m);
2417 wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, ¶m);
2418 if (param != NULL) {
2419 strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2420 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2427 /* content-language */
2429 /* accept-language */
2432 unsigned long i = 0;
2434 unsigned long tempLen;
2435 if ((fieldValue[0] < 0x20 ) || (fieldValue[0] > 0x80 )) {
2436 if (fieldValue[0] > 0x80 )
2439 tempLen = fieldValue[0];
2441 tempLen = AcStrlen( (char*)fieldValue ) + 1;
2446 code = wspHeaderDecodeInteger( fieldValue );
2447 while ( wspLanguage[i].languageCode != code) {
2449 if (i == wspLanguageCount)
2453 if (i < wspLanguageCount) {
2454 strncat( (char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2457 strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
2460 if (tempLen < fieldValueLen) {
2462 AutoPtr<char> parambuf(¶m);
2463 wspHeaderDecodeQValue( fieldValueLen - tempLen, fieldValue + tempLen, ¶m );
2464 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2472 /* content-length */
2476 /* Bearer-indication */
2482 unsigned char temp[16];
2484 if (( fieldValueLen == 2 ) && ( fieldValue[0] > 0x7f ))
2485 AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]);
2488 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
2489 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2492 /* X-Wap-Application-Id */
2495 unsigned char temp[64];
2498 if (fieldValueLen == 2 && fieldValue[0] == 0) {
2499 memcpy( fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1 );
2500 MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n" );
2504 integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
2506 int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
2507 for(int i = 0; i < count ; ++i)
2509 if((unsigned int)integerValue == wspHeaderApplId[i].parameterCode)
2511 snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
2512 strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1);
2518 /* Accept-Application */
2520 if (0x80 == fieldValue[0]) {
2521 strncat( (char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2524 unsigned char temp[16];
2526 if (( fieldValueLen == 2 ) && ( fieldValue[0] == 1 ))
2527 AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]);
2530 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ));
2531 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1);
2539 /* if-unmodified-since */
2543 /* if-modified-since */
2550 char* decodedString = NULL;
2551 AutoPtr<char> decodedStringbuf(&decodedString);
2552 wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString);
2553 strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2559 if (fieldValue[0] == 0x80 )
2560 strncat( (char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2564 if (fieldValue[0] == 0x80 )
2565 strncat( (char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2566 if (fieldValue[0] == 0x81 )
2567 strncat( (char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-strlen(temper)-1 );
2572 unsigned char temp[1275];
2573 memcpy( temp, fieldValue, (size_t)fieldValueLen );
2574 temp[fieldValueLen] = 0;
2575 wspHeaderCopyDecodedString( temp, ¤tLength, &temper );
2581 /* proxy - authorization */
2583 if (fieldValue[0] == 0x80) {
2584 char* addString = NULL;
2585 AutoPtr<char> addStringbuf(&addString);
2586 wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString );
2587 strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2589 iField = AcStrlen( (char*)fieldValue) + 1;
2591 strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2592 if (iField < fieldValueLen) {
2594 AutoPtr<char> parambuf(¶m);
2595 wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m );
2596 if (param != NULL) {
2597 strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2598 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2608 /* Proxy-authenticate */
2610 if (0 == fieldValueLen )
2612 if (fieldValue[0] == 0x80) {
2613 char* addString = NULL;
2614 AutoPtr<char> addStringbuf(&addString);
2615 wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString );
2616 strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2618 unsigned char authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
2619 unsigned char realmValue[WSP_STANDARD_STR_LEN_MAX];
2620 unsigned char addedString[WSP_STANDARD_STR_LEN_MAX];
2622 strncpy( (char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
2623 iField = AcStrlen( (char*)authScheme ) + 1;
2624 strncpy( (char*)realmValue, (char*)(fieldValue + iField ), WSP_STANDARD_STR_LEN_MAX-1);
2625 iField = iField + AcStrlen( (char*)realmValue ) + 1;
2626 sprintf( (char*)addedString, "%s %s", authScheme, realmValue );
2627 wspHeaderCopyDecodedString( addedString, ¤tLength, &temper );
2629 if (iField < fieldValueLen) {
2631 AutoPtr<char> parambuf(¶m);
2632 wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, ¶m );
2633 if (param != NULL) {
2634 strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2635 wspHeaderCopyDecodedString( (unsigned char*)param, ¤tLength, &temper );
2641 /* content -range */
2644 unsigned long first, len, last;
2646 unsigned char temp[16];
2649 strncat( (char*)temper," bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2651 first = wspRetriveUintvarDecode( fieldValue, &iField );
2652 len = wspRetriveUintvarDecode( fieldValue, &iField );
2653 /* 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.
2655 last = first + contentsLength - 1;
2657 sprintf( (char*)temp, "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len );
2658 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2665 char* cacheString = NULL;
2666 AutoPtr<char> cacheStringbuf(&cacheString);
2668 wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString );
2669 strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2675 if (fieldValue[0] == 0x80) {
2676 strncat( (char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2678 if (1 < fieldValueLen) {
2680 AutoPtr<char> parambuf(¶m);
2681 wspHeaderDecodeParameter( fieldValue, fieldValueLen, ¶m );
2683 if (param != NULL) {
2684 strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2685 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2696 unsigned long i = 0;
2697 while ( wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen ) != wspMethodType[i].methodCode ) i++;
2698 strncat( (char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2703 strncat( (char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2704 if (fieldValue[0] == 0x80) {
2705 unsigned char temp[16];
2706 unsigned long first, last;
2709 first = wspRetriveUintvarDecode( fieldValue, &iField );
2710 last = wspRetriveUintvarDecode( fieldValue, &iField );
2712 sprintf( (char*)temp, "%u-%u", (unsigned int)first, (unsigned int)last );
2713 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2715 if (fieldValue[0] == 0x81) {
2716 unsigned char temp[16];
2717 unsigned long suffix;
2719 suffix = wspRetriveUintvarDecode( fieldValue, &iField );
2721 sprintf( (char*)temp, "-%u", (unsigned int)suffix );
2727 if (fieldValue[0] == 0x80) {
2729 AutoPtr<char> tempbuf(&temp);
2731 wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp );
2732 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2735 if (fieldValue[0] == 0x81) {
2736 unsigned char temp[16];
2738 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen ));
2739 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2742 /* transfer-encoding */
2744 /* No other cases allowed */
2745 if (fieldValue[0] == 0x80 )
2746 strncat( (char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2752 int integerValue = wspHeaderDecodeIntegerByLength(fieldValue,fieldValueLen );
2753 if (integerValue > wspHeaderFieldCount) {
2754 MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n",wspHeaderFieldCount);
2757 strncat( (char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2764 unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
2766 if (fieldValue[0] < 0x20 )
2767 iField = fieldValue[0];
2770 sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, iField ));
2771 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2772 if (iField < fieldValueLen) {
2773 unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
2774 unsigned char text[WSP_STANDARD_STR_LEN_MAX];
2775 strncpy( (char*)agent, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
2776 iField = iField + AcStrlen((char*)agent ) + 1;
2777 strncpy((char*)text, (char*)(fieldValue + iField ),WSP_STANDARD_STR_LEN_MAX-1);
2779 sprintf( (char*)temp, " %s %s", agent, text );
2780 wspHeaderCopyDecodedString( temp, ¤tLength, &temper );
2784 /* content-disposition */
2786 if (fieldValue[0] == 0x80 )
2787 strncat( (char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2789 if (fieldValue[0] == 0x81 )
2790 strncat( (char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2792 if (1 < fieldValueLen) {
2794 AutoPtr<char> parambuf(¶m);
2795 wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m );
2797 if (param != NULL) {
2798 strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2799 strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2805 temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
2806 memcpy( temper, fieldValue, (size_t)fieldValueLen );
2808 /* Profile-Warning */
2811 unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
2813 sprintf( (char*)temp, "%lX", wspHeaderDecodeInteger(fieldValue ));
2815 temp[1] = (unsigned char)0x30;
2817 if (fieldValueLen > 1) {
2818 /* copy warn-target - URI */
2819 strncat( (char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
2820 if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) {
2821 /* copy warn-date */
2822 char* decodedString = NULL;
2823 AutoPtr<char> decodedStringbuf(&decodedString);
2824 wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString );
2825 strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 );
2828 strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2839 /* It deosn't finished decoding yet. */
2840 if (( iEncodedHeader < encodedHeaderLen ) && ( fieldCode != 0xff )) {
2841 /* In here, iEncodedHeader already point next field code to be decoded. */
2842 /* If this code is same, then set continueField else add CRLF. */
2843 if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f )) {
2844 strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2845 continueField = TRUE;
2847 strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2848 continueField = FALSE;
2851 strncat( (char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 );
2854 /* add single header to total headers */
2855 strncat( (char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1 );
2856 MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper );
2861 MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n" );
2863 *pHeader = outTemper;
2870 unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger( unsigned char* data )
2872 /* we only can handle max 32bit integer */
2876 unsigned long integer;
2877 unsigned char seg[4];
2880 returner.integer = 0;
2882 if (data[0] < 0x80) {
2883 unsigned long IntLen = 0;
2885 IntLen = (data[0]>0x04) ? 0x04:data[0];
2887 MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %d\n", data[0], IntLen);
2889 for (i=0; i<IntLen; i++)
2890 returner.seg[IntLen-( i+1)] = data[i+1];
2892 return returner.integer;
2895 return data[0] & 0x7f;
2899 void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsigned char* data, char** pDecodedString)
2901 unsigned short qBase = 0;
2904 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
2905 if (*pDecodedString == NULL) {
2906 MSG_DEBUG("WspLHeaderDecodeQValue:MemAlloc failed\n");
2910 memcpy( &qBase, data, (size_t)length );
2911 qValue = (float)qBase;
2913 qValue = qValue - 100;
2914 qValue = qValue / 1000;
2915 sprintf( (char*)*pDecodedString, "; q=%.3f", qValue );
2917 /* qValue variable is divided by 100. And it's multiplied by 100.
2918 It's to resolve problem of changed 0.01 of qValue. */
2919 unsigned long qValueTemp;
2920 qValue = qValue - 1;
2921 qValue = qValue / 100;
2922 qValueTemp = (unsigned long)(qValue * 100);
2923 if (0 == (qValueTemp % 10 ))
2924 sprintf( (char*)*pDecodedString, "; q=%.1f", qValue );
2926 sprintf( (char*)*pDecodedString, "; q=%.2f", qValue );
2932 unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length )
2937 unsigned long integer;
2938 unsigned short seg[4];
2941 returner.integer = 0;
2944 return data[0] & 0x7f;
2946 returner.integer = 0;
2948 for (i = 0 ; i < length; i++) {
2949 returner.integer = returner.integer + ( data[i] * (0x1 << ( ( length - ( i + 1)) * 8 )));
2950 MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %d \n", returner.integer );
2953 return returner.integer;
2957 char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType )
2961 while ( wspExtendedContentsType[i].contentsTypeCode != contentType) {
2962 if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
2967 return (char*)wspExtendedContentsType[i].contentsTypeName;
2971 void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, unsigned long length, char** pParam)
2973 char* param = *pParam;
2975 unsigned long SecurityTypeCode;
2976 unsigned long i = 0;
2978 if (data[0] < 0x80) {
2979 /* unknown parameter type */
2980 param = new char[WSP_STANDARD_STR_LEN_MAX];
2982 if (param == NULL) {
2983 MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n" );
2987 strncpy( (char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
2989 if (NO_VALUE == data[AcStrlen( (char*)param ) + 1]) {
2994 strncat( (char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
2995 strncat( (char*)param, (char*)(data + AcStrlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
3002 switch ( data[0] & 0x7f )
3005 wspHeaderDecodeQValue( length - 1, data + 1, ¶m);
3008 wspHeaderDecodeCharset( length - 1 , data + 1, ¶m);
3011 wspHeaderDecodeVersion( length - 1, data + 1, ¶m);
3015 //param = (unsigned char *)malloc( (size_t)WSP_STANDARD_STR_LEN_MAX );
3016 param = new char[WSP_STANDARD_STR_LEN_MAX];
3017 if (param == NULL) {
3018 MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
3021 sprintf( (char*)param, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 ));
3025 param = new char[WSP_STANDARD_STR_LEN_MAX];
3027 if (param == NULL) {
3028 MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
3031 sprintf( (char*)param, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 ));
3035 param = new char[WSP_STANDARD_STR_LEN_MAX];
3037 if (param == NULL) {
3038 MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
3041 strncpy( (char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
3042 memcpy( param + 5, data + 1, length - 1 );
3043 param[5 + length - 1] = '\0';
3047 param = new char[WSP_STANDARD_STR_LEN_MAX];
3049 if (param == NULL) {
3050 MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
3053 strncpy( (char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
3054 memcpy( param + 9, (char*)(data + 1), (size_t)(length - 1) );
3055 param[9 + length - 1] = '\0';
3062 /*OMA Provisioning*/
3064 param = new char[WSP_STANDARD_STR_LEN_MAX];
3066 if (param == NULL) {
3067 MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
3070 strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
3071 SecurityTypeCode = data[1] & 0x7f;
3072 while (( i < wspSecurityTypeCount ) && ( wspSecurityType[i].SecurityTypeCode != SecurityTypeCode )) i++;
3074 if (i < wspSecurityTypeCount) {
3075 strncat( (char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
3078 if (0x12 == (data[2] & 0x7f)) {
3079 strncat( (char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 );
3080 memcpy(param+AcStrlen( (char*)param),(char*)(data+3),(size_t)length-3 );
3095 void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsigned char* data, char**pDecodedString)
3098 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3100 if (*pDecodedString == NULL) {
3101 MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n");
3105 strncpy( (char*)*pDecodedString, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
3107 if (data[0] > 0x80) {
3108 unsigned long code = wspHeaderDecodeInteger(data );
3109 unsigned long i = 0;
3110 while (wspCharset[i].charsetCode != code) {
3111 if (wspCharset[i].charsetCode == 0xffff) {
3116 strncat( (char*)*pDecodedString, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pDecodedString)-1 );
3118 unsigned long lastLen = AcStrlen((char*)*pDecodedString);
3119 memcpy( (char*)(*pDecodedString + lastLen), data, (size_t)length );
3120 *pDecodedString[length + lastLen] = '\0';
3128 void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsigned char* data, char** pDecodedString )
3130 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3132 if (*pDecodedString == NULL) {
3133 MSG_DEBUG("WspLHeaderDecodeVersion:MemAlloc failed\n");
3138 /* untyped version */
3139 memcpy( *pDecodedString, data, (size_t)length );
3142 unsigned char majorVer = ((data[0] & 0x7f ) >> 4 );
3143 unsigned char minorVer = data[0] & 0x0f;
3144 sprintf( (char*)*pDecodedString, "level=%u.%u", majorVer, minorVer );
3151 void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, unsigned char* data, char** pDecodedString )
3156 MSG_DEBUG("WspLHeaderDecodeDateValue: \n" );
3158 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3160 if (*pDecodedString == NULL) {
3161 MSG_DEBUG( "WspLHeaderDecodeDateValue:MemAlloc failed\n");
3165 lTime = wspHeaderDecodeIntegerByLength(data, length);
3167 pTMData = (struct tm*)gmtime((const time_t* )&lTime);
3169 if (pTMData == NULL) {
3170 MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail \n" );
3171 strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
3175 /* check date value validity */
3177 if (( pTMData->tm_wday > 6 ) || (pTMData->tm_mon > 12 ) || (pTMData->tm_mday > 31 ))
3179 MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday );
3180 strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
3185 #ifdef MSG_FW_FOR_DEBUG
3186 /** Date type selection */
3187 switch ( wspMachineStatus.dateType )
3189 /* UNIX asciitime function */
3190 case UNIX_DATE_TYPE :
3191 sprintf( (char*)decodedString, "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
3192 pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
3194 case RFC1123_DATE_TYPE :
3195 sprintf( (char*)decodedString, "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday,
3196 wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
3198 case RFC850_DATE_TYPE :
3199 /* Have some Y2K Problems */
3200 /* 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. */
3201 sprintf( (char*)decodedString, "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday,
3202 wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec );
3207 /**UNIX_DATE_TYPE : */
3208 sprintf( (char*)*pDecodedString, "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
3209 pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 );
3215 void SmsPluginWapPushHandler::wspHeaderCopyDecodedString( unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper )
3217 unsigned long elementLen = AcStrlen( (char*)szDecodedString );
3218 char* temper2 = NULL;
3221 *currentLen = *currentLen + elementLen + 2;
3223 if ( *currentLen > AcStrlen( (char*)* pTemper ) + 2) {
3224 temper2 = new char[(*currentLen + 1 )];
3226 if (temper2 == NULL) {
3227 MSG_DEBUG( "WspLHeaderCopyDecodedString:MemAlloc failed\n");
3230 strncpy( (char*)temper2, (char*)* pTemper, *currentLen);
3232 strncpy( (char*)temper2, (char*)szDecodedString, *currentLen);
3241 void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
3243 unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
3244 unsigned char passWd[WSP_STANDARD_STR_LEN_MAX];
3245 unsigned long iField = 0;
3247 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
3249 if (*pDecodedString == NULL) {
3250 MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n" );
3254 /* skip 'basic' code */
3256 sscanf((char*)(fieldValue + iField), "%s", userId );
3257 iField = iField + AcStrlen( (char*)userId ) + 1;
3258 sscanf( (char*)(fieldValue + iField), "%s", passWd );
3259 iField = iField + AcStrlen( (char*)userId ) + 1;
3260 sprintf( (char*)*pDecodedString, "basic %s/%s", userId, passWd );
3266 void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString )
3268 unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
3269 unsigned long iField = 0;
3271 *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
3273 if (*pDecodedString == NULL) {
3274 MSG_DEBUG( "WspLHeaderDecodeChallenge:MemAlloc failed\n");
3278 /* skip 'basic' code */
3280 sscanf( (char*)(fieldValue + iField), "%s", userId );
3281 iField = iField + AcStrlen( (char*)userId ) + 1;
3283 sprintf( (char*)*pDecodedString, "basic realm=\"%s\"", userId );
3289 void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString)
3291 unsigned char paramString[WSP_STANDARD_STR_LEN_MAX];
3292 unsigned char cacheCode;
3294 *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
3295 if (*pCacheString == NULL) {
3296 MSG_DEBUG( "WspLHeaderDecodeCacheControl:MemAlloc failed\n");
3300 if (1 == fieldValueLen) {
3301 /* only one directive */
3302 if (fieldValue[0] > 0x8b) {
3303 return; /* It's error detection. can be omitted. */
3305 strncpy( (char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
3309 if (fieldValue[0] > 0x7f) {
3310 /* directive that has parameter */
3311 cacheCode = fieldValue[0] & 0x7f;
3312 switch ( cacheCode )
3319 if (fieldValue[1] > 0x7f) {
3320 /* well known field name */
3321 strncpy( (char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f],WSP_STANDARD_STR_LEN_MAX-1 );
3322 paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
3324 /* unknown field name */
3325 strncpy( (char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
3335 sprintf( (char*)paramString, "%u", (unsigned int)wspHeaderDecodeInteger( fieldValue + 1));
3342 sprintf((char*)*pCacheString, "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString );
3344 /* cache extentions */
3345 /* In case of come directive of doesn't specified string style */
3347 unsigned long stringLen;
3349 strncpy( (char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
3350 stringLen = AcStrlen((char*)*pCacheString );
3352 if (stringLen + 1 < fieldValueLen) {
3354 if (fieldValue[stringLen+ 1] > 0x7f) {
3355 int untyped = (int)wspHeaderDecodeIntegerByLength( fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1 ));
3357 sprintf( szString, "%d", untyped );
3358 strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
3359 strncat( (char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
3361 if (fieldValue[fieldValueLen] == 0) {
3362 strncat( (char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1 );
3363 strncat( (char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);