|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32std.h> |
|
17 #include <msventry.h> |
|
18 #include <bsp.h> |
|
19 #include <wapp.h> |
|
20 #include <wappdef.h> |
|
21 #include "wapperr.h" |
|
22 #include <wappstr.rsg> |
|
23 |
|
24 #include "CWappBookmark.h" |
|
25 #include "IspTableData.h" |
|
26 #include "IpBearerData.h" |
|
27 #include "SmsBearerData.h" |
|
28 #include "GprsBearerData.h" |
|
29 |
|
30 #include <mmssettingsproxybase.h> |
|
31 |
|
32 #include <msvstd.h> |
|
33 #include <msventry.h> |
|
34 #include <msvids.h> |
|
35 #include <msvuids.h> |
|
36 #include <mtclreg.h> |
|
37 |
|
38 #include <ipaddr.h> |
|
39 #include <barsc.h> |
|
40 #include <barsread.h> |
|
41 #include <bautils.h> |
|
42 |
|
43 #include <cbioasyncwaiter.h> |
|
44 #include <cmsvattachment.h> |
|
45 #include <mmsvattachmentmanager.h> |
|
46 #include <mmsvattachmentmanagersync.h> |
|
47 |
|
48 #ifdef SYMBIAN_BOOKMARK_DATABASE |
|
49 #include <bookmarkdatabase.h> |
|
50 #include <bookmark.h> |
|
51 #endif // SYMBIAN_BOOKMARK_DATABASE |
|
52 |
|
53 #ifdef _DEBUG |
|
54 const TUid KUidSmartMessageMtm = {0x10001262}; |
|
55 const TInt32 KUidBIOWAPAccessPointMsg = 0x10005532; |
|
56 #endif |
|
57 |
|
58 const TInt KMaxNameBufferLength = 35; |
|
59 |
|
60 _LIT8(KCRLinefeed, "\r\n"); |
|
61 _LIT8(KEBookmarkItemBegin, "BEGIN:eBOOKMARK\r\n"); // Precedes a Bookmark in the Bookmark file |
|
62 _LIT8(KEBookmarkItemName, "NAME:"); // Precedes a Bookmark Name |
|
63 _LIT8(KEBookmarkItemURL, "URL:"); // Precedes a Bookmark URL |
|
64 _LIT8(KEBookmarkType, "TYPE:Wap\r\n"); |
|
65 _LIT8(KEBookmarkItemEnd, "END:eBOOKMARK\r\n"); |
|
66 |
|
67 _LIT(KEBookmarkExtension, ".eBM"); |
|
68 |
|
69 _LIT(KWappResourceFile, "\\resource\\messaging\\wappstr.rsc"); |
|
70 |
|
71 const TUint32 KCharsetUCS2 = 1000; |
|
72 const TUint32 KCharsetUTF8 = 106; |
|
73 const TUint32 KCharsetASCII = 3; |
|
74 |
|
75 |
|
76 // The number of characters that are constant for an eBookmark |
|
77 // file. It is the sum of the above literals. |
|
78 // |
|
79 const TInt KEBookmarkConstantChars = 55; |
|
80 |
|
81 CMsvBIOWapAccessParser::CMsvBIOWapAccessParser(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs) |
|
82 : CBaseScriptParser2(aRegisteredParserDll, aEntry, aFs) |
|
83 { |
|
84 } |
|
85 |
|
86 EXPORT_C CMsvBIOWapAccessParser* CMsvBIOWapAccessParser::NewL(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs) |
|
87 { |
|
88 CMsvBIOWapAccessParser* self = new (ELeave) CMsvBIOWapAccessParser(aRegisteredParserDll, aEntry, aFs); |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 CMsvBIOWapAccessParser::~CMsvBIOWapAccessParser() |
|
96 { |
|
97 Cancel(); |
|
98 // Char Conversion |
|
99 delete iCharsetConverter; |
|
100 delete iSettings; |
|
101 delete iSmsBuf; |
|
102 delete iStringTable; |
|
103 if (iBookmarkList!=NULL) |
|
104 { |
|
105 iBookmarkList->ResetAndDestroy(); |
|
106 delete iBookmarkList; |
|
107 } |
|
108 delete iModemInitString; |
|
109 if (iParsedFieldArray != NULL) |
|
110 { |
|
111 iParsedFieldArray->ResetAndDestroy(); |
|
112 delete iParsedFieldArray; |
|
113 } |
|
114 delete iWapIpISPTable; |
|
115 delete iWapSmsTable; |
|
116 delete iWapGprsTable; |
|
117 delete iGsmCsdWapIpTable; |
|
118 delete iGprsWapIpTable; |
|
119 |
|
120 delete iDBSession; |
|
121 REComSession::FinalClose(); |
|
122 } |
|
123 |
|
124 // |
|
125 // ConstructL - ConstructL fn - creates the Parsed Field array, |
|
126 // and connects the file system if unconnected |
|
127 // |
|
128 void CMsvBIOWapAccessParser::ConstructL() |
|
129 { |
|
130 iParsedFieldArray = new(ELeave) CArrayPtrSeg<CParsedField>(16); |
|
131 iDBSession = CMDBSession::NewL(CMDBSession::LatestVersion()); |
|
132 iBookmarkList = new(ELeave) CArrayPtrSeg<CWappBookmark> (4);// 4 should be enough |
|
133 iGsmCsdData = EFalse; |
|
134 iGsmSmsData = EFalse; |
|
135 iGprsData = EFalse; |
|
136 iURLData = EFalse; |
|
137 iNameData = EFalse; |
|
138 iIdData = EFalse; |
|
139 iMMSURLData = EFalse; |
|
140 CActiveScheduler::Add(this); |
|
141 } |
|
142 |
|
143 // |
|
144 // ParseL - public method forming part of the API. Calls ChangeState to set |
|
145 // state for parsing. Helper functions do the parsing |
|
146 // |
|
147 void CMsvBIOWapAccessParser::ParseL(TRequestStatus& aStatus, const TDesC& aSms) |
|
148 { |
|
149 TMsvEntry entry = iEntry.Entry(); // Get the generic stuff |
|
150 iEntryId = entry.Id(); // store the TMsvId |
|
151 |
|
152 // Message must be unparsed, or parsed or committed - anything else is a big error |
|
153 __ASSERT_DEBUG(( entry.MtmData3() == BIO_MSG_ENTRY_UNPARSED |
|
154 || entry.MtmData3() == BIO_MSG_ENTRY_PARSED |
|
155 || entry.MtmData3() == BIO_MSG_ENTRY_PROCESSED), |
|
156 Panic(EWappErrMessageProcessed)); |
|
157 |
|
158 // Message must not be empty |
|
159 __ASSERT_DEBUG (aSms.Length() > 0 ,Panic( EWappEmptyBuffer)); |
|
160 |
|
161 // Already parsed....just return |
|
162 if(entry.MtmData3() == BIO_MSG_ENTRY_PARSED || entry.MtmData3() == BIO_MSG_ENTRY_PROCESSED) |
|
163 { |
|
164 iReport = &aStatus; |
|
165 User::RequestComplete(iReport, KErrNone); |
|
166 } |
|
167 // not parsed so start the Parsing operation |
|
168 else if(entry.MtmData3() == BIO_MSG_ENTRY_UNPARSED) |
|
169 { |
|
170 delete iSmsBuf; |
|
171 iSettings = NULL; |
|
172 iSmsBuf = aSms.AllocL(); |
|
173 ChangeStateL(EStart); // Do do initial processing, and go Active |
|
174 aStatus = KRequestPending; |
|
175 iReport = &aStatus; |
|
176 } |
|
177 else |
|
178 { |
|
179 User::Leave(KErrNotSupported); |
|
180 } |
|
181 } |
|
182 |
|
183 // |
|
184 // ProcessL() -- If parsed data is not already in memory, ProcessL loads it from the store |
|
185 // created during parsing. Creates a new entry in the WAP settings CommDb tables, from the data |
|
186 // |
|
187 void CMsvBIOWapAccessParser::ProcessL(TRequestStatus& aStatus) |
|
188 { |
|
189 // Calls ChangeState to get State Engine going. ( DoProcess does the hard work) |
|
190 |
|
191 iEntryId= iEntry.Entry().Id(); //store id of Bio Msg entry |
|
192 |
|
193 // Must be a smart/Bio message, of type WAP access point and not have the failure flag set |
|
194 __ASSERT_DEBUG(iEntry.Entry().iMtm==KUidSmartMessageMtm, Panic(EWappInvalidEntry)); |
|
195 __ASSERT_DEBUG(iEntry.Entry().iBioType ==KUidBIOWAPAccessPointMsg, Panic(EWappInvalidEntry)); |
|
196 __ASSERT_DEBUG(iEntry.Entry().Failed()== 0 , Panic(EWappInvalidEntry)); |
|
197 |
|
198 ResetProcessVariablesL(); // Reset variables to initial state |
|
199 ChangeStateL(EProcessInitialise); //Set the initial state |
|
200 |
|
201 aStatus = KRequestPending; |
|
202 iReport = &aStatus; |
|
203 } |
|
204 |
|
205 // DoCancel - Cancels the Active Object operation and returns control to the caller |
|
206 // |
|
207 void CMsvBIOWapAccessParser::DoCancel() |
|
208 { |
|
209 User::RequestComplete(iReport,KErrCancel); |
|
210 } |
|
211 |
|
212 // |
|
213 // RunL() - Called by the Active Scheduler when it finishes its Wait Loop. |
|
214 // Doesn't do much as ParseL and Process keep going until they are complete. |
|
215 // Returns the current status. |
|
216 // |
|
217 void CMsvBIOWapAccessParser::RunL() |
|
218 { |
|
219 iCompleted = iStatus.Int(); |
|
220 |
|
221 if (iCompleted != KErrNone) |
|
222 { |
|
223 User::RequestComplete(iReport,iCompleted); |
|
224 return; |
|
225 } |
|
226 TInt currentState = iState; |
|
227 TRAPD(error, CallChangeStateL(currentState)); |
|
228 switch (currentState) |
|
229 { |
|
230 case EStart: |
|
231 case EProcessInitialise: |
|
232 case EProcessMessage: |
|
233 if (error!=KErrNone) |
|
234 User::RequestComplete(iReport, error); // Return error code |
|
235 break; |
|
236 case EParseMessage: |
|
237 case ECompleteMessage: |
|
238 User::RequestComplete(iReport, iCompleted); // Nothing more - allow calling RunL to complete and return status |
|
239 break; |
|
240 default: |
|
241 break; |
|
242 } |
|
243 } |
|
244 |
|
245 void CMsvBIOWapAccessParser::CallChangeStateL(TInt aState) |
|
246 { |
|
247 switch (aState) |
|
248 { |
|
249 case EStart: |
|
250 ChangeStateL(EParseMessage); |
|
251 break; |
|
252 case EProcessInitialise: |
|
253 ChangeStateL(EProcessMessage); |
|
254 break; |
|
255 case EProcessMessage: |
|
256 ChangeStateL(ECompleteMessage); // last stage change iMtmData3 |
|
257 break; |
|
258 default: |
|
259 break; |
|
260 } |
|
261 } |
|
262 |
|
263 // |
|
264 // ChangeStateL - Used to advance the state to the next level. |
|
265 // Makes most of the important calls. |
|
266 // |
|
267 void CMsvBIOWapAccessParser::ChangeStateL(TParseSession aState) |
|
268 { |
|
269 iState = aState; |
|
270 switch (iState) |
|
271 { |
|
272 case EStart: // Check the data we've got - if OK get the Active Stuff going |
|
273 if (!iSmsBuf) |
|
274 User::Leave(KWappErrNullValue); |
|
275 else if (iSmsBuf->Length() == 0) |
|
276 User::Leave(KWappErrContent); |
|
277 break; |
|
278 case EParseMessage: |
|
279 iSms = iSmsBuf->Des(); // initialise TLex object |
|
280 ParseMessageL(); |
|
281 break; |
|
282 case EProcessInitialise: |
|
283 if (!iSmsParsed) |
|
284 RestoreParsedDataL(); |
|
285 PreProcessL(); //Scan iParsedFieldArray extracting data - leaves if data is invalid |
|
286 ValidateCharacteristicsL(); // Ensures that the mix of characteristic is valid |
|
287 break; |
|
288 case EProcessMessage: |
|
289 DoProcessL(); // Do the proper processing of and committing to CommDb |
|
290 break; |
|
291 case ECompleteMessage: |
|
292 CompleteMessageL(); |
|
293 break; |
|
294 default: |
|
295 break; |
|
296 } |
|
297 |
|
298 // Finished this step -add ourselves to Scheduler,& return error code to calling thread. |
|
299 RequestComplete(iStatus, KErrNone); |
|
300 SetActive(); |
|
301 } |
|
302 |
|
303 // |
|
304 // ParseMessageL() - Performs various checks, if data has been saved it restores it |
|
305 // else it calls DoParseL which does the hard stuff). |
|
306 // |
|
307 void CMsvBIOWapAccessParser::ParseMessageL() |
|
308 { |
|
309 // MUST have Bio message, of type WAP access point and no failure flag set |
|
310 __ASSERT_DEBUG(iEntry.Entry().iMtm==KUidSmartMessageMtm, Panic(EWappInvalidEntry)); |
|
311 __ASSERT_DEBUG(iEntry.Entry().iBioType ==KUidBIOWAPAccessPointMsg, Panic(EWappInvalidEntry)); |
|
312 __ASSERT_DEBUG(iEntry.Entry().Failed()== 0 , Panic(EWappInvalidEntry)); |
|
313 |
|
314 // Message already parsed(includes processed). Just restore data and return |
|
315 if (iEntry.Entry().MtmData3() == BIO_MSG_ENTRY_PARSED || |
|
316 iEntry.Entry().MtmData3() == BIO_MSG_ENTRY_PROCESSED) |
|
317 iSmsParsed = ETrue; // Have a store produced during parsing. |
|
318 else |
|
319 iSmsParsed = EFalse; |
|
320 |
|
321 if(iSmsParsed) // parsed before - restore data |
|
322 { |
|
323 RestoreParsedDataL(); |
|
324 return; |
|
325 } |
|
326 |
|
327 DoParseL(); // Does the actual parsing of the message contents |
|
328 SettingsNamePresentL(); // Check for Name Characteristic- if not found appends a default one |
|
329 StoreParsedDataL(); // Saves the parsed fields to store & sets TMSvEntry values |
|
330 iSmsParsed=ETrue; |
|
331 } |
|
332 |
|
333 // |
|
334 // CompleteMessageL() - Completes the ProcessL operation, by setting the iMtmData3 |
|
335 // flag to BIO_MSG_ENTRY_PROCESSEDMessage body, and TMsvEntry's |
|
336 // iDescription and iDetails are left unchanged |
|
337 // |
|
338 void CMsvBIOWapAccessParser::CompleteMessageL() |
|
339 { |
|
340 TMsvEntry entry= iEntry.Entry(); |
|
341 entry.SetMtmData3(BIO_MSG_ENTRY_PROCESSED); |
|
342 |
|
343 iEntry.ChangeL(entry); |
|
344 } |
|
345 |
|
346 // |
|
347 // RequestComplete() - Completes an AO operation, and passes control back to the caller |
|
348 // |
|
349 void CMsvBIOWapAccessParser::RequestComplete(TRequestStatus& aStatus, TInt aError) |
|
350 { |
|
351 TRequestStatus* p = &aStatus; |
|
352 User::RequestComplete(p, aError); |
|
353 } |
|
354 |
|
355 // |
|
356 // DoParseL() - Parses through encoded message body extracting the fields from the characteristics |
|
357 // Uses helper functions to handle reading and storing of characteristics and parms. |
|
358 // Parsing performed in one continuous operation. |
|
359 // |
|
360 void CMsvBIOWapAccessParser::DoParseL() |
|
361 { |
|
362 const TInt KDecimalSizeOfMaxInt = 10; // length of 0xFFFFFFFF in a string in decimal |
|
363 TBuf<KDecimalSizeOfMaxInt> localBuf; |
|
364 TChar thisCharacter; |
|
365 |
|
366 thisCharacter = GetNextMessageByteL(); // Read the first char to get XML version number |
|
367 /* |
|
368 The version byte contains the the major version minus one in the upper four bits |
|
369 of the 8 bit integer, and the minor version in the lower four bits. |
|
370 */ |
|
371 TUint wbxmlversionbyte = thisCharacter; |
|
372 TUint majorversion = ((wbxmlversionbyte & 0xF0) + 0x10) - 0x0F; // gives the major version, eg if wbxml spec version 1.2, it gives 1. |
|
373 TUint minorversion = wbxmlversionbyte & 0x0F; //gives the minor version, eg if wbxml spec version 1.2, it gives 2. |
|
374 |
|
375 iWBXMLversionX10 = (majorversion *10) + minorversion; //i.e. If actual version is 1.1 this is *10 to remove the decimal place. |
|
376 |
|
377 //Append this to the array |
|
378 localBuf.NumUC(iWBXMLversionX10,EDecimal); //Format to a decimal string |
|
379 AppendDataPairL(KWappXMLversion, localBuf); // Append to array of parsed fields |
|
380 |
|
381 // Now need to get the 32bit int encoded over a number of bytes |
|
382 iPublicID = Read_mb_u_int32L(); // Read in a multi byte 32bit int value |
|
383 localBuf.NumUC(iPublicID, EHex); // Format to a string as hex |
|
384 AppendDataPairL(KWappPublicID, localBuf); |
|
385 |
|
386 // WAP Binary XML version 1.1 also has additional info for the character set. |
|
387 if (iWBXMLversionX10 !=10) // If WAP Binary XML version > 1.0 |
|
388 iCharacterSet = Read_mb_u_int32L(); // Get the character set |
|
389 else |
|
390 //This is the character set MIBenum for UTF-8. |
|
391 //According to WBXML spec version 1.1 and 1.2, this is the default which should |
|
392 //be assumed if the charset value is not available. Value 0 must not be used. |
|
393 iCharacterSet = 106; |
|
394 |
|
395 delete iCharsetConverter; |
|
396 iCharsetConverter = NULL; |
|
397 iCharsetConverter = CWapCharsetConverter::NewL(iFs, iCharacterSet); |
|
398 |
|
399 localBuf.NumUC(iCharacterSet, EHex); // Convert to string as hex |
|
400 AppendDataPairL(KWappCharacterSet,localBuf); |
|
401 |
|
402 // Coded string table length - don't need this once we have string table |
|
403 // as we store copies of the strings within parsed data fields |
|
404 TUint32 stringTableLength = Read_mb_u_int32L(); |
|
405 |
|
406 //Read in string table if it exists, i.e. length >0 otherwise skip this step |
|
407 if (stringTableLength>0) |
|
408 { |
|
409 iStringTable = HBufC::NewL(stringTableLength); |
|
410 iSms.Mark(); // Mark the current position |
|
411 |
|
412 TUint32 remaining = iSms.RemainderFromMark().Length(); //Eliminates warning about comparison in next line |
|
413 |
|
414 if ( remaining > stringTableLength) // Sting Table doesn't exceed end of message |
|
415 iSms.Inc(stringTableLength); // so increment to the character following the string table |
|
416 else |
|
417 User::Leave(KWappErrEOS); // Table exceeds message length - unrecoverable error |
|
418 iStringTable->Des().Copy(iSms.MarkedToken()); |
|
419 } |
|
420 |
|
421 thisCharacter = GetNextMessageByteL(); |
|
422 //This should be a Characteristic List with content, but no attributes |
|
423 if (thisCharacter == (KWAPP_CHAR_LIST+KWAPP_TAG_CONTENT)) |
|
424 { |
|
425 // Main loop - keep moving through the message, until we reach the end or error |
|
426 TBool finished = EFalse; |
|
427 while (!finished) |
|
428 { |
|
429 // Read in characteristics, any order is accepted |
|
430 if (!iSms.Eos() && (iSms.Peek() & 0x3F) == KWAPP_CHARACTERISTIC) |
|
431 { |
|
432 // Read in characteristic, inc. its terminator tag - no terminator =error! |
|
433 ReadCharacteristicL(); |
|
434 } |
|
435 else |
|
436 { |
|
437 if (iSms.Eos()) // Error end of message |
|
438 User::Leave(KWappErrEOS); |
|
439 else if ((TUint)iSms.Peek()==KWAPP_END_TAG) // END Tag - OK we've finished! |
|
440 finished = ETrue; |
|
441 else if ( (iSms.Peek()& 0x3F != KWAPP_CHARACTERISTIC) || (iSms.Peek() != KWAPP_END_TAG) ) |
|
442 User::Leave(KWappErrUnexpectedValue); //Not a Characteristic or END token |
|
443 } |
|
444 } |
|
445 } // End of if (thisCharacter == (KWAPP_CHAR_LIST..... ) |
|
446 else |
|
447 User::Leave(KWappErrMandatoryTagMissing); |
|
448 } |
|
449 // end CMsvBIOWapAccessParser::DoParseL() |
|
450 |
|
451 // |
|
452 // ReadCharacteristicL() - Reads in a characteristic from the message. |
|
453 // |
|
454 void CMsvBIOWapAccessParser::ReadCharacteristicL() |
|
455 { |
|
456 TBool hasContent; |
|
457 TInt characteristicIndex=0; // start position in array for this characteristic |
|
458 CParsedField* parsedField = new(ELeave)CParsedField(); |
|
459 CleanupStack::PushL(parsedField); |
|
460 |
|
461 TChar currentCharacter = GetNextMessageByteL(); |
|
462 iCurrentCharacteristic =EWappUnknown; // Reset flag for current characteristic's type |
|
463 |
|
464 // Use bit comparison of token with mask 0x3F to check explicitly that correct |
|
465 // bits are set i.e. that bits 0-5 = 0x06 (NB Actual value = 0x86 or =0xC6) |
|
466 if ( ( currentCharacter & 0x3F) != KWAPP_CHARACTERISTIC ) // i.e. not or 0x06 |
|
467 User::Leave(KWappErrUnexpectedValue); |
|
468 else |
|
469 { |
|
470 if ( !(currentCharacter & KWAPP_TAG_ATTRIBUTES)) // Bit 7 must be set! |
|
471 User::Leave(KWappErrNoAttributes); |
|
472 if (currentCharacter & KWAPP_TAG_CONTENT) //Bit 6 is set - characteristic has content |
|
473 hasContent =ETrue; |
|
474 else |
|
475 hasContent =EFalse; |
|
476 |
|
477 |
|
478 // *************** IMPORTANT NOTE ************************ |
|
479 // An XML element name without a defined token is sent as an inline string or |
|
480 // string table ref. prefixed by the TYPE token 0x05 (ie "TYPE="). (True for |
|
481 // WirelessFuture web site!!) THE ONLY UNDEFINED Type tag is BOOKMARK in version |
|
482 // 1.0. Therefore if it's 0x05 - check the version. For 1.0 read next char. |
|
483 // Token must be an inline string or string table ref.Otherwise we have an error. |
|
484 // **************************************************************************** |
|
485 |
|
486 // Read the next byte - info on the type of our characteristic |
|
487 currentCharacter = (TUint) GetNextMessageByteL(); |
|
488 |
|
489 // Check if the tokens 0x05 "TYPE=" - should be for WBXML version = 1.0 |
|
490 // Read next character |
|
491 if (currentCharacter == KWAPP_TYPE) |
|
492 { |
|
493 // "TYPE=" should be followed by an inline string, or string table reference |
|
494 // So read another char & increment a place - should now 0x03 or 0x83 |
|
495 currentCharacter = (TUint) GetNextMessageByteL(); |
|
496 if ( !(currentCharacter & KWAPP_STR_I) && // Is current character != 0x03 ? |
|
497 !(currentCharacter & KWAPP_STR_T)) // or != 0x83 |
|
498 User::Leave(KWappErrUnexpectedValue); // Doc is badly formed doc - leave |
|
499 } |
|
500 |
|
501 // NB for address characteristics, need to store position of the start, so that |
|
502 // we can search for certain fields. If they're not present we must add defaults. |
|
503 // Could just scan from the end of the array, but if we miss our target then may |
|
504 // just increment past this characteristic, through previous ones. |
|
505 |
|
506 switch (currentCharacter) |
|
507 { |
|
508 case KWAPP_ADDR_TYPE: // Token = 0x06 |
|
509 { |
|
510 AppendNameFieldL(KWappCharAddress); |
|
511 characteristicIndex = iParsedFieldArray->Count()-1; // Store index for this element |
|
512 iCurrentCharacteristic = EWappAddressCharacteristic; //General code for an address |
|
513 break; |
|
514 } |
|
515 case KWAPP_URL_TYPE: //Token = 0x07 |
|
516 { |
|
517 AppendNameFieldL(KWappCharURL); |
|
518 iCurrentCharacteristic = EWappURLCharacteristic; // it's a URL characteristic |
|
519 break; |
|
520 } |
|
521 case KWAPP_NAME_TYPE: // Token = 0x08 |
|
522 { |
|
523 AppendNameFieldL(KWappCharName); |
|
524 iCurrentCharacteristic = EWappNameCharacteristic;//it's a NAME characteristic |
|
525 break; |
|
526 } |
|
527 case KWAPP_STR_I: // Token = 0x03 , Global WAP XML value |
|
528 { |
|
529 // Null terminated inline string follows the token, call fn to read it |
|
530 parsedField->SetFieldNameL(*ReadInlineStringLC()); |
|
531 CleanupStack::PopAndDestroy(); //inline string |
|
532 break; |
|
533 } |
|
534 case KWAPP_STR_T: // Token = 0x83, Global WAP XML value |
|
535 { |
|
536 // multi byte 32 bit integer follows, an reference to an offset in the string table |
|
537 TUint32 offset =0; |
|
538 offset = Read_mb_u_int32L(); // read in the integer |
|
539 parsedField->SetFieldNameL(*ReadStringTableReferenceLC(offset));//Get string table value,& set the descriptor |
|
540 CleanupStack::PopAndDestroy(); // string table reference |
|
541 break; |
|
542 } |
|
543 case KWAPP_ID: // Token = 0x7D. Used in version 5.0 |
|
544 { |
|
545 AppendNameFieldL(KWappCharID); |
|
546 iCurrentCharacteristic = EWappIDCharacteristic; |
|
547 break; |
|
548 } |
|
549 case KWAPP_BOOKMARK: // Token = 07F, currently bookmarks stored in file |
|
550 { |
|
551 AppendNameFieldL(KWappCharBookmark); |
|
552 iCurrentCharacteristic = EWappBookmarkCharacteristic; |
|
553 break; |
|
554 } |
|
555 case KWAPP_MMS_URL: |
|
556 { |
|
557 AppendNameFieldL(KWappCharMMSURL); |
|
558 iCurrentCharacteristic = EWappMMSURLCharacteristic; |
|
559 break; |
|
560 } |
|
561 default: |
|
562 User::Leave(KWappErrUnrecognised); // Unrecognised token or somethings badly wrong |
|
563 } |
|
564 |
|
565 |
|
566 // If iCurrentCharacteristic isn't set we've just read in a string table ref |
|
567 // or inline string. Now check the token and set the flag. |
|
568 if (iCurrentCharacteristic == EWappUnknown) |
|
569 { |
|
570 // Get index of last element |
|
571 if (parsedField->FieldName().CompareF(KWappAddr)==0) |
|
572 { |
|
573 iCurrentCharacteristic = EWappAddressCharacteristic; |
|
574 AppendNameFieldL(KWappCharAddress); |
|
575 characteristicIndex = iParsedFieldArray->Count()-1;//May be an address so store index |
|
576 } |
|
577 else if (parsedField->FieldName().CompareF(KWappURL)==0) |
|
578 { |
|
579 iCurrentCharacteristic = EWappURLCharacteristic; |
|
580 AppendNameFieldL(KWappCharURL); |
|
581 } |
|
582 else if (parsedField->FieldName().CompareF(KWappMMSURL)==0) |
|
583 { |
|
584 iCurrentCharacteristic = EWappMMSURLCharacteristic; |
|
585 AppendNameFieldL(KWappCharMMSURL); |
|
586 } |
|
587 else if (parsedField->FieldName().CompareF(KWappName)==0) |
|
588 { |
|
589 iCurrentCharacteristic = EWappNameCharacteristic; |
|
590 AppendNameFieldL(KWappCharName); |
|
591 } |
|
592 else if (parsedField->FieldName().CompareF(KWappBookmark)==0) |
|
593 { |
|
594 iCurrentCharacteristic = EWappBookmarkCharacteristic; |
|
595 AppendNameFieldL(KWappCharBookmark); |
|
596 } |
|
597 else if (parsedField->FieldName().CompareF(KWappID)==0) |
|
598 { |
|
599 iCurrentCharacteristic = EWappIDCharacteristic; |
|
600 AppendNameFieldL(KWappCharID); |
|
601 } |
|
602 else |
|
603 { |
|
604 User::Leave(KWappErrUnrecognised);// Unrecognised characteristic type |
|
605 } |
|
606 } |
|
607 CleanupStack::PopAndDestroy(parsedField); |
|
608 |
|
609 //Check for a VALUE attribute before checking for Parms |
|
610 currentCharacter =(TUint) GetNextMessageByteL(); |
|
611 if (currentCharacter ==KWAPP_VALUE_ATTRIB) |
|
612 { |
|
613 // Have a value following the TYPE - read in value and store it. |
|
614 TInt lastElement = iParsedFieldArray->Count()-1; |
|
615 currentCharacter = (TUint) GetNextMessageByteL(); |
|
616 |
|
617 if (currentCharacter == KWAPP_STR_I) //Inline string |
|
618 { |
|
619 iParsedFieldArray->At(lastElement)->SetFieldValueL(*ReadInlineStringLC()); //Set value of last element in array |
|
620 CleanupStack::PopAndDestroy(); |
|
621 } |
|
622 |
|
623 else if (currentCharacter ==KWAPP_STR_T) //String table reference |
|
624 { |
|
625 TUint32 tableOffset = Read_mb_u_int32L(); |
|
626 iParsedFieldArray->At(lastElement)->SetFieldValueL(*ReadStringTableReferenceLC(tableOffset)); //Set Value of last element in array |
|
627 CleanupStack::PopAndDestroy(); |
|
628 } |
|
629 |
|
630 else |
|
631 { |
|
632 User::Leave(KWappErrUnexpectedValue); |
|
633 } |
|
634 |
|
635 // Read the next character for the END TAG check in the following line |
|
636 currentCharacter = (TUint)GetNextMessageByteL(); |
|
637 } |
|
638 |
|
639 //Check the character- should be 0x01 the end of the characteristic header |
|
640 if (!currentCharacter ==KWAPP_END_TAG) // Not END - error condition |
|
641 { |
|
642 User::Leave(KWappErrNoTermination); |
|
643 } |
|
644 |
|
645 // We shouldn't be at the end of the message. The next byte should be one of the following |
|
646 // - PARM if this characteristic has content, |
|
647 // - start of another characteristic |
|
648 // - END token (0x01). |
|
649 // So take a peek at the next byte |
|
650 TUint peekAhead; |
|
651 |
|
652 if (iSms.Eos()) |
|
653 User::Leave(KWappErrEOS); // Somethings wrong - message end |
|
654 |
|
655 peekAhead = (TUint) iSms.Peek(); |
|
656 |
|
657 // Type is Set - address,URL,Name, Bookmark or ID. Check hasContent flag set correctly. |
|
658 if ( ((iCurrentCharacteristic == EWappAddressCharacteristic) && !hasContent) || //Address must have Content |
|
659 ((iCurrentCharacteristic == EWappNameCharacteristic) && !hasContent) || //Name must have Content |
|
660 ((iCurrentCharacteristic == EWappBookmarkCharacteristic) && !hasContent)|| //Bookmark must have Content |
|
661 ((iCurrentCharacteristic == EWappIDCharacteristic) && !hasContent) || //ID must have Content |
|
662 ((iCurrentCharacteristic == EWappURLCharacteristic) && hasContent) || // Url must NOT have Content |
|
663 ((iCurrentCharacteristic == EWappMMSURLCharacteristic) && hasContent) ) // MmsUrl does not have content |
|
664 User::Leave(KWappErrContent); // Test for validity of content flag failed. |
|
665 |
|
666 |
|
667 if (hasContent) // passed previous test, - exclude URL as hasContent=EFalse |
|
668 { |
|
669 if ( (peekAhead & 0x3F) ==KWAPP_PARM) // bit comparison with 0x07 |
|
670 { |
|
671 // Check sucessful, now check for attributes and content (0x80, & 0x40) |
|
672 if ( (peekAhead & KWAPP_TAG_ATTRIBUTES) && ( !(peekAhead & KWAPP_TAG_CONTENT) ) ) |
|
673 { |
|
674 //Have attributes, and no content - ALL OK! |
|
675 currentCharacter = (TUint32) GetNextMessageByteL(); |
|
676 while (currentCharacter != KWAPP_END_TAG) |
|
677 { |
|
678 ReadParmL(); // Sets iCurrentCharacteristic for addresses |
|
679 |
|
680 currentCharacter = (TUint32) GetNextMessageByteL(); // Get the next character from message |
|
681 |
|
682 if ( (currentCharacter != (KWAPP_PARM+KWAPP_TAG_ATTRIBUTES)) |
|
683 && (currentCharacter !=KWAPP_END_TAG) ) // Not 0x87, nor 0x01 = error |
|
684 User::Leave(KWappErrUnexpectedValue); |
|
685 } |
|
686 } |
|
687 else // Token MUST be 0x87, parms MUST have content but NO attributes! |
|
688 User::Leave(KWappErrNoAttributes); |
|
689 } |
|
690 else //Bits 0-5 are Not 0x07 Should be a PARM token |
|
691 User::Leave(KWappErrUnexpectedValue); |
|
692 } //END of (hasContent) |
|
693 } |
|
694 // END of if ( !( (TUint32)currentCharacter & KWAPP_CHARACTERISTIC) ) |
|
695 |
|
696 |
|
697 |
|
698 // ************************** MANDATORY PARMS & DEFAULT VALUES ************************** |
|
699 // Finished reading in the parms for the characteristic. Each Address Characteristic |
|
700 // has it's own set of defaults. If this is an address - ensure defaults are present. |
|
701 |
|
702 |
|
703 // CHARACTERISTIC TYPE = ADDRESS, BEARER TYPE = GSM/CSD or IS-136/CSD |
|
704 // Bearer, Proxy, and Csd_Dialstring are mandatory.. |
|
705 // Auth. Names and Passwords don't have defaults so are not set here! |
|
706 |
|
707 if ( iCurrentCharacteristic == EWappGsmCsdCharacteristic|| |
|
708 iCurrentCharacteristic == EWappIS136CsdCharacteristic ) |
|
709 { |
|
710 //Required PARMS OTA v4.0 v5.0 |
|
711 //CSD- PROXY Y Y |
|
712 // PORT add default of 9200 |
|
713 // CSD_DIALSTRING Y Y |
|
714 // CSD_AUTHNAME Y N |
|
715 // CSD_AUTHSECRET Y N |
|
716 // CSD_CALLTYPE Y Add default of PAP |
|
717 // CSD_CALLSPEED Y Add default of AUTO |
|
718 |
|
719 // Check mandatory PARMS present else bad message - unrecoverable error! |
|
720 TInt index; |
|
721 |
|
722 // OTA v4.0 & 5.0: required Parms present? |
|
723 index = LocateParsedFieldName(KWappProxy,characteristicIndex); |
|
724 if (index == KErrNotFound) // TODO can this be null? || (iParsedFieldArray->At(index)->FieldValue() == TPtrC())) |
|
725 User::Leave(KWappErrMandatoryTagMissing); |
|
726 |
|
727 index = LocateParsedFieldName(KWappCsdDial,characteristicIndex); |
|
728 if (index == KErrNotFound) // Can this be Null?? || (iParsedFieldArray->At(index)->FieldValue() == TPtrC()) ) |
|
729 User::Leave(KWappErrMandatoryTagMissing); |
|
730 |
|
731 // OTA v4.0 only, mandatory Parms present? |
|
732 if (iWBXMLversionX10 == 10) |
|
733 { |
|
734 index = LocateParsedFieldName(KWappPPPAuthName,characteristicIndex); |
|
735 if (index == KErrNotFound)// Can this be NULL || (iParsedFieldArray->At(index)->FieldValue() == TPtrC())) |
|
736 User::Leave(KWappErrMandatoryTagMissing); |
|
737 |
|
738 index = LocateParsedFieldName(KWappPPPAuthSecret,characteristicIndex); |
|
739 if (index == KErrNotFound) // Can this be a Null value? || (iParsedFieldArray->At(index)->FieldValue() == TPtrC()) ) |
|
740 User::Leave(KWappErrMandatoryTagMissing); |
|
741 } |
|
742 |
|
743 // Search for PORT from beginning of this characteristic to array end or next |
|
744 // Characteristic - whichever's first. NB this is currently the last characteristic in array! |
|
745 |
|
746 index = LocateParsedFieldName(KWappPort, characteristicIndex); |
|
747 if (index ==KErrNotFound) // Not Found - add the default value |
|
748 { |
|
749 index = LocateParsedFieldName(KWappProxy,characteristicIndex); // Mandatory - check already made |
|
750 InsertDataPairL(KWappPort, KWappPort9200, index+1); |
|
751 } |
|
752 |
|
753 // Check for the PPP_AUTHTYPE element |
|
754 index = LocateParsedFieldName(KWappPPPAuthType, characteristicIndex); |
|
755 if (index ==KErrNotFound) // Not Found - add the default value |
|
756 { |
|
757 index = LocateParsedFieldName(KWappCsdDial, characteristicIndex); // always present |
|
758 // Create new element,NAME="PPP_CALLTYPE", VALUE="PAP" |
|
759 InsertDataPairL(KWappPPPAuthType, KWappPAP, index+1); |
|
760 } |
|
761 |
|
762 // Check for the CSD_CALLTYPE element |
|
763 index = LocateParsedFieldName(KWappCsdCallType, characteristicIndex); |
|
764 if (index ==KErrNotFound) // Not Found - add the default value |
|
765 { |
|
766 index = LocateParsedFieldName(KWappPPPAuthType, characteristicIndex); |
|
767 if (index ==KErrNotFound) |
|
768 User::Leave(KWappErrMandatoryTagMissing); // Error - should be here from step above!!! |
|
769 else |
|
770 // Create new element,NAME="CSD_CALLTYPE", VALUE="ANALOGUE" |
|
771 InsertDataPairL(KWappCsdCallType, KWappAnalogue, index+1); |
|
772 } |
|
773 |
|
774 // Check for the CSD_CALLSPEED element |
|
775 index = LocateParsedFieldName(KWappCsdCallSpeed, characteristicIndex); |
|
776 if (index ==KErrNotFound) // Not Found - add the default value |
|
777 { |
|
778 index = LocateParsedFieldName(KWappCsdCallType,characteristicIndex); |
|
779 if (index ==KErrNotFound) |
|
780 User::Leave(KWappErrMandatoryTagMissing); // Error - should be here from step above!!! |
|
781 else |
|
782 //Create new PARM, |
|
783 // If CSD_CALLTYPE="ANALOGUE" -> NAME="CSD_CALLSPEED", VALUE="AUTO" |
|
784 // else if CSD_CALLTYPE="ISDN" -> NAME="CSD_CALLSPEED", VALUE="9600" |
|
785 if (iParsedFieldArray->At(index)->FieldValue().CompareF(KWappISDN)==0) |
|
786 InsertDataPairL(KWappCsdCallSpeed, KWappSpeed9600, index+1); |
|
787 else |
|
788 InsertDataPairL(KWappCsdCallSpeed, KWappSpeedAuto, index+1); |
|
789 } |
|
790 }// END of if(iCurrentCharacteristic == EWappCSDCharacteristic)|| ....... |
|
791 |
|
792 |
|
793 // CHARACTERISTIC TYPE = ADDRESS, BEARER TYPE = GSM/SMS |
|
794 // Only the PORT PARM value is optional - all the rest are mandatory |
|
795 |
|
796 if (iCurrentCharacteristic == EWappGsmSmsCharacteristic) |
|
797 { |
|
798 //Required PARMS OTA v4.0 v5.0 |
|
799 //SMS- PROXY Y Y |
|
800 // SMS_SMSC_ADDRESS Y |
|
801 |
|
802 // Check that required fields are present - badly formed message otherwise |
|
803 TInt fieldIndex = LocateParsedFieldName(KWappProxy, characteristicIndex); |
|
804 if (fieldIndex == KErrNotFound ) // TODO Check if this can be null || (iParsedFieldArray->At(fieldIndex)->FieldValue().Length()==0) ) |
|
805 User::Leave(KWappErrMandatoryTagMissing); |
|
806 |
|
807 fieldIndex = LocateParsedFieldName(KWappSMSCAddress, characteristicIndex); |
|
808 if ((fieldIndex ==KErrNotFound)) // TODO Check if this can be null || (iParsedFieldArray->At(fieldIndex)->FieldValue().Length()==0) ) |
|
809 User::Leave(KWappErrMandatoryTagMissing); |
|
810 |
|
811 |
|
812 if (LocateParsedFieldName(KWappPort, characteristicIndex) ==KErrNotFound) //Tag not found |
|
813 { |
|
814 fieldIndex = LocateParsedFieldName(KWappProxy, characteristicIndex); //Mandatory field |
|
815 // Create a new element, NAME="PORT", VALUE="9200" |
|
816 InsertDataPairL(KWappPort,KWappPort9200, fieldIndex+1); |
|
817 } |
|
818 }//END of if(iCurrentCharacteristic == EWappSMSCharacteristic) |
|
819 |
|
820 |
|
821 // CHARACTERISTIC TYPE = ADDRESS, BEARER TYPE = GSM/USSD |
|
822 if (iCurrentCharacteristic == EWappGsmUssdCharacteristic) |
|
823 { |
|
824 |
|
825 //Only USSD Service Code is mandatory - MUST not be NULL |
|
826 TInt index = LocateParsedFieldName(KWappUSSDCode, characteristicIndex); |
|
827 if (index == KErrNotFound || iParsedFieldArray->At(index)->FieldValue().Length()==0) |
|
828 User::Leave(KWappErrMandatoryTagMissing); |
|
829 |
|
830 // PROXY is optional for USSD but has no default value |
|
831 // Do have defaults for PROXY_TYPE and PORT |
|
832 if (LocateParsedFieldName(KWappProxyType, characteristicIndex) ==KErrNotFound) //Tag not found |
|
833 { |
|
834 index = LocateParsedFieldName(KWappUSSDCode, characteristicIndex); //Mandatory field |
|
835 |
|
836 // Create a new element, NAME="PROXY_TYPE", VALUE="MSISDNNO" |
|
837 InsertDataPairL(KWappProxyType,KWappMsisdnNo, index+1); |
|
838 } |
|
839 |
|
840 if ( LocateParsedFieldName(KWappPort, characteristicIndex) == KErrNotFound) // Not Found - add the default value |
|
841 { |
|
842 index = LocateParsedFieldName(KWappProxyType,characteristicIndex); |
|
843 if (index ==KErrNotFound) |
|
844 User::Leave(KWappErrMandatoryTagMissing); // Error - should be here from step above!!! |
|
845 else // Create new element,NAME="PORT", VALUE="9200" |
|
846 InsertDataPairL(KWappPort, KWappPort9200, index+1); |
|
847 } |
|
848 } // END of - if (iCurrentCharacteristic == EWappGsmUssdCharacteristic)... |
|
849 |
|
850 |
|
851 // CHARACTERISTIC TYPE = ADDRESS, BEARER TYPE = GPRS |
|
852 if (iCurrentCharacteristic == EWappGprsCharacteristic) |
|
853 { |
|
854 // AHF - Removed check for tag GPRSACCESSPOINTNAME - no longer mandatory in OTA v7.0 |
|
855 |
|
856 // Check that mandatory PROXY field is present - else it's a badly formed msg |
|
857 TInt index = LocateParsedFieldName(KWappProxy, characteristicIndex); |
|
858 if (index == KErrNotFound ) |
|
859 User::Leave(KWappErrMandatoryTagMissing); |
|
860 |
|
861 //Search for optional Port field - if not found, search for mandatory Proxy field and insert "9200" |
|
862 index = LocateParsedFieldName(KWappPort, characteristicIndex); |
|
863 if (index ==KErrNotFound) |
|
864 { |
|
865 index = LocateParsedFieldName(KWappProxy,characteristicIndex); // Mandatory - check already made |
|
866 InsertDataPairL(KWappPort, KWappPort9200, index+1); // NAME="PORT", VALUE = "9200" |
|
867 } |
|
868 |
|
869 // Check for the PPP_AUTHTYPE element - add default value if not found |
|
870 index = LocateParsedFieldName(KWappPPPAuthType, characteristicIndex); |
|
871 if (index ==KErrNotFound) |
|
872 { |
|
873 index = LocateParsedFieldName(KWappCsdDial, characteristicIndex); // always present |
|
874 InsertDataPairL(KWappPPPAuthType, KWappPAP, index+1); // NAME="PPP_CALLTYPE", VALUE="PAP" |
|
875 } |
|
876 } |
|
877 |
|
878 |
|
879 |
|
880 } |
|
881 // END of CMsvBIOWapAccessParser::ReadCharacteristicL() |
|
882 |
|
883 // |
|
884 // ReadParmL() - Reads in contents of a PARM & inserts into iParsedFieldArray |
|
885 // as a CParsedField object. ASSUME that the PARM tag has |
|
886 // been read & verified before this is called. Consequently |
|
887 // now positioned at the start of the attributes |
|
888 |
|
889 void CMsvBIOWapAccessParser::ReadParmL() |
|
890 { |
|
891 |
|
892 CParsedField* parsedField = new(ELeave) CParsedField; |
|
893 CleanupStack::PushL(parsedField); |
|
894 TChar currentCharacter = GetNextMessageByteL(); |
|
895 |
|
896 switch ((TUint) currentCharacter) |
|
897 { |
|
898 case KWAPP_NAME_ATTRIB: //0x10 "NAME=..." ,string(inline or table ref.) should follow |
|
899 { |
|
900 //Start of NAME attribute, check for inline string/string table reference |
|
901 currentCharacter=GetNextMessageByteL(); |
|
902 if ((TUint32) currentCharacter == KWAPP_STR_I) |
|
903 { |
|
904 parsedField->SetFieldNameL(*ReadInlineStringLC()); |
|
905 CleanupStack::PopAndDestroy(); |
|
906 } |
|
907 else if ((TUint32) currentCharacter== KWAPP_STR_T) |
|
908 { |
|
909 TUint32 offset = Read_mb_u_int32L(); |
|
910 parsedField->SetFieldNameL(*ReadStringTableReferenceLC(offset)); |
|
911 CleanupStack::PopAndDestroy(); |
|
912 } |
|
913 else // it isn't an inline string or string table ref - ERROR! |
|
914 User::Leave(KWappErrNoTermination); |
|
915 break; |
|
916 } |
|
917 case KWAPP_BEARER: //0x12 NAME="BEARER" |
|
918 { |
|
919 parsedField->SetFieldNameL(KWappBearer); |
|
920 break; |
|
921 } |
|
922 case KWAPP_PROXY: //0x13 NAME="PROXY" (Mandatory for GSM/CSD, GSM/SMS, IS136/CSD) |
|
923 { |
|
924 parsedField->SetFieldNameL(KWappProxy); |
|
925 break; |
|
926 } |
|
927 case KWAPP_PORT ://0x14 NAME="PORT" |
|
928 { |
|
929 parsedField->SetFieldNameL(KWappPort); |
|
930 break; |
|
931 } |
|
932 case KWAPP_NAME ://0x15 NAME = "NAME" |
|
933 { |
|
934 parsedField->SetFieldNameL(KWappName); |
|
935 break; |
|
936 } |
|
937 case KWAPP_PROXYTYPE ://0x16 NAME="PROXY_TYPE" |
|
938 { |
|
939 parsedField->SetFieldNameL(KWappProxyType); |
|
940 break; |
|
941 } |
|
942 case KWAPP_URL : // 0x17 NAME="URL" |
|
943 { |
|
944 parsedField->SetFieldNameL(KWappURL); |
|
945 break; |
|
946 } |
|
947 case KWAPP_PROXY_AUTHNAME : // 0x18 NAME="PROXY_AUTHNAME" |
|
948 { |
|
949 parsedField->SetFieldNameL(KWappProxyAuthName); |
|
950 break; |
|
951 } |
|
952 case KWAPP_PROXY_AUTHSECRET : //0x19 NAME="PROXY_AUTHSECRET" |
|
953 { |
|
954 parsedField->SetFieldNameL(KWappProxyAuthSecret); |
|
955 break; |
|
956 } |
|
957 case KWAPP_PROXY_LOGIN_TYPE : |
|
958 { |
|
959 parsedField->SetFieldNameL(KWappProxyLoginType); |
|
960 break; |
|
961 } |
|
962 case KWAPP_SMS_SMSC_ADDR : //0x1A NAME="SMS_SMSC_ADDR" (Mandatory field for GSM/SMS) |
|
963 { |
|
964 parsedField->SetFieldNameL(KWappSMSCAddress); |
|
965 break; |
|
966 } |
|
967 case KWAPP_USSD_SERV_CODE : //0x1B NAME="USSD_SER_CODE" (Mandatory for GSM/USSD) |
|
968 { |
|
969 parsedField->SetFieldNameL(KWappUSSDCode); |
|
970 break; |
|
971 } |
|
972 case KWAPP_ACCESS_POINT_NAME : //0x1C NAME="ACCESSPOINTNAME" (Mandatory for GPRS) |
|
973 { |
|
974 parsedField->SetFieldNameL(KWappAccessPointName); |
|
975 break; |
|
976 } |
|
977 case KWAPP_CSD_DIALSTRING : //0x21 NAME="CSD_DIALSTRING" (Mandatory for GSM/CSD,IS136/CSD) |
|
978 { |
|
979 parsedField->SetFieldNameL(KWappCsdDial); |
|
980 break; |
|
981 } |
|
982 case KWAPP_PPP_AUTHTYPE : //0x22 NAME="CSD_AUTHTYPE" |
|
983 { |
|
984 parsedField->SetFieldNameL(KWappPPPAuthType); |
|
985 break; |
|
986 } |
|
987 case KWAPP_PPP_AUTHNAME : //0x23 NAME="CSD_AUTHNAME" |
|
988 { |
|
989 parsedField->SetFieldNameL(KWappPPPAuthName); |
|
990 break; |
|
991 } |
|
992 case KWAPP_PPP_AUTHSECRET : //0x24 NAME="CSD_AUTHSECRET" |
|
993 { |
|
994 parsedField->SetFieldNameL(KWappPPPAuthSecret); |
|
995 break; |
|
996 } |
|
997 case KWAPP_PPP_LOGIN_TYPE : |
|
998 { |
|
999 parsedField->SetFieldNameL(KWappPPPLoginType); |
|
1000 break; |
|
1001 } |
|
1002 case KWAPP_CSD_CALLTYPE : // 0x25 NAME="CSD_CALLTYPE" |
|
1003 { |
|
1004 parsedField->SetFieldNameL(KWappCsdCallType); |
|
1005 break; |
|
1006 } |
|
1007 case KWAPP_CSD_CALLSPEED : //0x28 NAME="CSD_CALLSPEED" |
|
1008 { |
|
1009 parsedField->SetFieldNameL(KWappCsdCallSpeed); |
|
1010 break; |
|
1011 } |
|
1012 case KWAPP_NAME_ISP : //0x7E NAME="ISP_NAME" |
|
1013 { |
|
1014 parsedField->SetFieldNameL(KWappISP); |
|
1015 break; |
|
1016 } |
|
1017 |
|
1018 default: |
|
1019 User::Leave(KWappErrUnexpectedValue); // don't recognise the tag |
|
1020 } |
|
1021 |
|
1022 // The early version of the WAP server, supporting version 4.0 of the Nokia OTA specs |
|
1023 // codes up PROXY_AUTHNAME & PROXY_AUTHSECRET as the PROXY token followed by |
|
1024 // a string/str ref. So we MUST check if inline string/str table ref follows |
|
1025 if (currentCharacter==KWAPP_PROXY) |
|
1026 { |
|
1027 if (iSms.Eos()) |
|
1028 User::Leave(KWappErrEOS); // ERROR - Unexpected end of message!! Nothing to peek at! |
|
1029 else if ( ((TUint)iSms.Peek() == KWAPP_STR_I) || ((TUint)iSms.Peek() == KWAPP_STR_T)) |
|
1030 { |
|
1031 // String follows immediately after Name token not a Value Tag |
|
1032 TUint32 anOffset; |
|
1033 currentCharacter = GetNextMessageByteL(); |
|
1034 HBufC* name = NULL; |
|
1035 if ((TUint) currentCharacter == KWAPP_STR_I) |
|
1036 { |
|
1037 name = ReadInlineStringLC(); |
|
1038 } |
|
1039 else |
|
1040 { |
|
1041 if ((TUint) currentCharacter != KWAPP_STR_T) |
|
1042 User::Leave(KWappErrUnexpectedValue); // Should not get here unless something is very wrong! |
|
1043 anOffset = Read_mb_u_int32L(); |
|
1044 name = ReadStringTableReferenceLC(anOffset); |
|
1045 } |
|
1046 |
|
1047 //Defect fix for Def021848-Incorrect use of ReAllocL in wapp |
|
1048 HBufC* newName = name->ReAllocL(name->Length() + parsedField->FieldName().Length()); |
|
1049 CleanupStack::Pop(name);//Remove name from the Cleanup Stack as it would have been deleted by ReAllocL() |
|
1050 CleanupStack::PushL(newName); |
|
1051 newName->Des().Append(parsedField->FieldName()); //insert PROXY at front of string |
|
1052 parsedField->SetFieldNameL(*newName); //replace current string with new one |
|
1053 CleanupStack::PopAndDestroy(newName); |
|
1054 } |
|
1055 } |
|
1056 |
|
1057 TBool addParsedField = ETrue; |
|
1058 |
|
1059 currentCharacter=GetNextMessageByteL(); //Get next byte - should be the Value tag |
|
1060 switch( (TUint32) currentCharacter) |
|
1061 { |
|
1062 case KWAPP_VALUE_ATTRIB : // 0x11 "VALUE=", string(inline or table ref) follows |
|
1063 { |
|
1064 if (iSms.Eos()) |
|
1065 { |
|
1066 User::Leave(KWappErrEOS); // ERROR - Unexpected end of message!! Nothing to peek at! |
|
1067 } |
|
1068 //Check for 0x01 (KWAPP_END_TAG) - assign fieldvalue with empty value and ignore the other |
|
1069 if ( ((TUint)iSms.Peek() == KWAPP_END_TAG)) //Something wrong - Wrong PARAM Value |
|
1070 { |
|
1071 addParsedField = EFalse; |
|
1072 break; |
|
1073 } |
|
1074 // Start of VALUE attribute, string should follow |
|
1075 currentCharacter= GetNextMessageByteL(); |
|
1076 if ((TUint32) currentCharacter == KWAPP_STR_I) //Inline string |
|
1077 { |
|
1078 HBufC* value = ReadInlineStringLC(); |
|
1079 parsedField->SetFieldValueL(*value); |
|
1080 CleanupStack::PopAndDestroy(); |
|
1081 } |
|
1082 else if ((TUint32) currentCharacter== KWAPP_STR_T) //String Table ref |
|
1083 { |
|
1084 TUint32 offset = Read_mb_u_int32L(); // Read 32bit int |
|
1085 HBufC* value = ReadStringTableReferenceLC(offset); // Read in characters |
|
1086 parsedField->SetFieldValueL(*value); |
|
1087 CleanupStack::PopAndDestroy(); |
|
1088 } |
|
1089 else //Not an inline string or string table ref - somethings wrong! |
|
1090 User::Leave(KWappErrUnexpectedValue); |
|
1091 break; |
|
1092 } |
|
1093 case KWAPP_GSM_SMS_OLD : // 0x41 VALUE="GSM/SMS" |
|
1094 { |
|
1095 // Old value of GSM/SMS tag - ONLY valid for Version 4.0 of the specs, ie WBXML = 1.0! |
|
1096 parsedField->SetFieldValueL(KWappGsmSms); |
|
1097 break; |
|
1098 } |
|
1099 case KWAPP_GSM_CSD : // 0x45 VALUE="GSM/CSD" |
|
1100 { |
|
1101 parsedField->SetFieldValueL(KWappGsmCsd); |
|
1102 break; |
|
1103 } |
|
1104 case KWAPP_GSM_SMS_NEW : // 0x46 VALUE="GSM/SMS" ONLY valid for Version 5.0 of the specs, i.e.WBXML = 1.1! |
|
1105 { |
|
1106 parsedField->SetFieldValueL(KWappGsmSms); |
|
1107 break; |
|
1108 } |
|
1109 case KWAPP_GSM_USSD : //0x47 VALUE="GSM/USSD" only defined for version 5.0 only |
|
1110 { |
|
1111 parsedField->SetFieldValueL(KWappGsmUssd); |
|
1112 break; |
|
1113 } |
|
1114 case KWAPP_IS136 : // 0x48 VALUE="IS136/CSD" for version 5.0 only |
|
1115 { |
|
1116 parsedField->SetFieldValueL(KWappIS136Csd); |
|
1117 break; |
|
1118 } |
|
1119 case KWAPP_GPRS : // 0x49 VALUE="GSM/GPRS" |
|
1120 { |
|
1121 parsedField->SetFieldValueL(KWappGprs); |
|
1122 break; |
|
1123 } |
|
1124 case KWAPP_PORT_9200 : // 0x60 VALUE="9200" |
|
1125 { |
|
1126 parsedField->SetFieldValueL(KWappPort9200); |
|
1127 break; |
|
1128 } |
|
1129 case KWAPP_PORT_9201 : // 0x61 VALUE="9201" |
|
1130 { |
|
1131 parsedField->SetFieldValueL(KWappPort9201); |
|
1132 break; |
|
1133 } |
|
1134 case KWAPP_PORT_9202 : // 0x62 VALUE="9202" |
|
1135 { |
|
1136 parsedField->SetFieldValueL(KWappPort9202); |
|
1137 break; |
|
1138 } |
|
1139 case KWAPP_PORT_9203 : // 0x63 VALUE="9203" |
|
1140 { |
|
1141 parsedField->SetFieldValueL(KWappPort9203); |
|
1142 break; |
|
1143 } |
|
1144 case KWAPP_AUTOMATIC : // 0x64 |
|
1145 { |
|
1146 parsedField->SetFieldValueL(KWappAuthAutomatic); |
|
1147 break; |
|
1148 } |
|
1149 case KWAPP_MANUAL : // 0x65 |
|
1150 { |
|
1151 parsedField->SetFieldValueL(KWappAuthManual); |
|
1152 break; |
|
1153 } |
|
1154 case KWAPP_SPEED_AUTO : // 0x6A VALUE="AUTO" |
|
1155 { |
|
1156 parsedField->SetFieldValueL(KWappSpeedAuto); |
|
1157 break; |
|
1158 } |
|
1159 case KWAPP_SPEED_9600 : // 0x6B VALUE="9600" |
|
1160 { |
|
1161 parsedField->SetFieldValueL(KWappSpeed9600); |
|
1162 break; |
|
1163 } |
|
1164 case KWAPP_SPEED_14400 : // 0x6C VALUE="14400" |
|
1165 { |
|
1166 parsedField->SetFieldValueL(KWappSpeed14400); |
|
1167 break; |
|
1168 } |
|
1169 case KWAPP_SPEED_19200 : //0x6D VALUE="19200" |
|
1170 { |
|
1171 parsedField->SetFieldValueL(KWappSpeed19200); |
|
1172 break; |
|
1173 } |
|
1174 case KWAPP_SPEED_28800 : //0x6E VALUE="28800" |
|
1175 { |
|
1176 parsedField->SetFieldValueL(KWappSpeed28800); |
|
1177 break; |
|
1178 } |
|
1179 case KWAPP_SPEED_38400 : //0X6F VALUE="38400" |
|
1180 { |
|
1181 parsedField->SetFieldValueL(KWappSpeed38400); |
|
1182 break; |
|
1183 } |
|
1184 case KWAPP_PAP : // 0x70 VALUE="PAP" |
|
1185 { |
|
1186 parsedField->SetFieldValueL(KWappPAP); |
|
1187 break; |
|
1188 } |
|
1189 case KWAPP_CHAP : //0X71 VALUE="CHAP" |
|
1190 { |
|
1191 parsedField->SetFieldValueL(KWappCHAP); |
|
1192 break; |
|
1193 } |
|
1194 case KWAPP_ANALOGUE : //0X72 VALUE="ANALOGUE" |
|
1195 { |
|
1196 parsedField->SetFieldValueL(KWappAnalogue); |
|
1197 break; |
|
1198 } |
|
1199 case KWAPP_ISDN : //0X73 VALUE="ISDN" |
|
1200 { |
|
1201 parsedField->SetFieldValueL(KWappISDN); |
|
1202 break; |
|
1203 } |
|
1204 case KWAPP_SPEED_43200 : //0X74 VALUE="43200" |
|
1205 { |
|
1206 parsedField->SetFieldValueL(KWappSpeed43200); |
|
1207 break; |
|
1208 } |
|
1209 case KWAPP_SPEED_56700 : //0X75 VALUE="56700" |
|
1210 { |
|
1211 parsedField->SetFieldValueL(KWappSpeed56700); |
|
1212 break; |
|
1213 } |
|
1214 case KWAPP_MSISDN_NO : //0X76 VALUE="MSISDN_NO" |
|
1215 { |
|
1216 parsedField->SetFieldValueL(KWappMsisdnNo); |
|
1217 break; |
|
1218 } |
|
1219 case KWAPP_IPV4 : //OX77 VALUE="IPV4" |
|
1220 { |
|
1221 parsedField->SetFieldValueL(KWappIpv4); |
|
1222 |
|
1223 break; |
|
1224 } |
|
1225 case KWAPP_MSCHAP : //0x78 VALUE="MSCHAP" |
|
1226 { |
|
1227 parsedField->SetFieldValueL(KWappMSCHAP); |
|
1228 break; |
|
1229 } |
|
1230 |
|
1231 default: |
|
1232 User::Leave(KWappErrUnexpectedValue); // Unknown tag - can't process it |
|
1233 } |
|
1234 |
|
1235 // If iCurrentCharacteristic is a general address type and NAME="BEARER". Then |
|
1236 // set the current type flag to the correct type, so we know exactly what we're dealing with |
|
1237 if (iCurrentCharacteristic==EWappAddressCharacteristic |
|
1238 && parsedField->FieldName().CompareF(KWappBearer)==0) |
|
1239 { |
|
1240 if (parsedField->FieldValue().CompareF(KWappGsmCsd)==0) |
|
1241 iCurrentCharacteristic =EWappGsmCsdCharacteristic; |
|
1242 else if (parsedField->FieldValue().CompareF(KWappGsmSms)==0) |
|
1243 iCurrentCharacteristic = EWappGsmSmsCharacteristic; |
|
1244 else if (parsedField->FieldValue().CompareF(KWappGsmUssd)==0) |
|
1245 iCurrentCharacteristic = EWappGsmUssdCharacteristic; |
|
1246 else if (parsedField->FieldValue().CompareF(KWappIS136Csd)==0) |
|
1247 iCurrentCharacteristic = EWappIS136CsdCharacteristic; |
|
1248 else if (parsedField->FieldValue().CompareF(KWappGprs)==0) |
|
1249 iCurrentCharacteristic = EWappGprsCharacteristic; |
|
1250 else |
|
1251 User::Leave(KWappErrUnrecognised); |
|
1252 } |
|
1253 |
|
1254 // Got our Name and Value fields- check next byte - should be 0x01 =END |
|
1255 currentCharacter = GetNextMessageByteL(); |
|
1256 |
|
1257 if (currentCharacter != KWAPP_END_TAG) // Our PARM is not correctly terminated! |
|
1258 User::Leave(KWappErrNoTermination); |
|
1259 |
|
1260 // Check flag to see if parsed field should be added or not |
|
1261 if (addParsedField) |
|
1262 { |
|
1263 // Extracted the NAME and VALUE so create a container and append to our array |
|
1264 iParsedFieldArray->AppendL(parsedField); |
|
1265 CleanupStack::Pop(parsedField); |
|
1266 } |
|
1267 else |
|
1268 { |
|
1269 CleanupStack::PopAndDestroy(parsedField); |
|
1270 } |
|
1271 } |
|
1272 //End of CMsvBIOWapAccessParser::ReadParmL() |
|
1273 |
|
1274 |
|
1275 // SettingsNamePresentL() - Check if the NAME characteristic is defined. if it isn't add |
|
1276 // a default one that is unique. Use a base stem of "WAP Settings" and |
|
1277 // append a suffix to it. The suffix is calculated by incrementing, until |
|
1278 // a unique digit is found. |
|
1279 // |
|
1280 void CMsvBIOWapAccessParser::SettingsNamePresentL() |
|
1281 { |
|
1282 TBool nameDefined = EFalse; // Is a Name characteristic present? |
|
1283 TBool bearerPresent = EFalse; // Is address characteristic present? |
|
1284 |
|
1285 // Search for the start of a NAME characteristic - i.e. Field Name="NAME" |
|
1286 TInt nFields = iParsedFieldArray->Count(); |
|
1287 |
|
1288 TInt loopCount=0; |
|
1289 while (loopCount < nFields && !nameDefined) |
|
1290 { |
|
1291 if (iParsedFieldArray->At(loopCount)->FieldName().CompareF(KWappCharName)==0) |
|
1292 { |
|
1293 // At start of a Name characteristic |
|
1294 // Make sure that we won't try checking past the end of the array |
|
1295 if (loopCount+1 < nFields) // NB loopCount started at zero |
|
1296 { |
|
1297 // Verify that this is followed by NAME parm - NAME token & a non NULL value |
|
1298 if (iParsedFieldArray->At(loopCount+1)->FieldName().CompareF(KWappName)==0) |
|
1299 { |
|
1300 if (iParsedFieldArray->At(loopCount+1)->FieldValue().Length()!=0) |
|
1301 nameDefined = ETrue; |
|
1302 } |
|
1303 } |
|
1304 } |
|
1305 loopCount++; |
|
1306 } |
|
1307 |
|
1308 loopCount = 0; |
|
1309 while (loopCount < nFields) |
|
1310 { |
|
1311 // Beginning of an Address Characteristic? |
|
1312 if (iParsedFieldArray->At(loopCount)->FieldName().CompareF(KWappCharAddress) ==0) |
|
1313 bearerPresent = ETrue; // Assume all Parms are present- will leave later if not! |
|
1314 loopCount++; |
|
1315 } |
|
1316 |
|
1317 if (nameDefined ==EFalse && bearerPresent) // NAME characteristic not defined - add a default |
|
1318 { |
|
1319 TBuf<KCommsDbSvrMaxColumnNameLength> recordName; |
|
1320 HBufC* nameBuffer = HBufC::NewLC(30); |
|
1321 TInt currentRecord = 1; |
|
1322 TBool nameExists = EFalse; |
|
1323 |
|
1324 TFileName fileName; |
|
1325 Dll::FileName(fileName); |
|
1326 TParse parse; |
|
1327 parse.Set(KWappResourceFile, &fileName, NULL); |
|
1328 fileName = parse.FullName(); |
|
1329 BaflUtils::NearestLanguageFile(iFs, fileName); |
|
1330 |
|
1331 RResourceFile resourceFile; |
|
1332 resourceFile.OpenL(iFs, fileName); |
|
1333 CleanupClosePushL(resourceFile); |
|
1334 HBufC8* buffer = resourceFile.AllocReadLC(DEFAULT_WAP_SETTINGS_NAME); |
|
1335 TResourceReader resourceReader; |
|
1336 resourceReader.SetBuffer(buffer); |
|
1337 TPtrC defaultSettingsName = resourceReader.ReadTPtrC(); |
|
1338 CCDWAPAccessPointRecord *wapRecord = static_cast<CCDWAPAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPAccessPointRecord)); |
|
1339 CleanupStack::PushL(wapRecord); |
|
1340 nameBuffer->Des().Format(defaultSettingsName, currentRecord); // create our name string |
|
1341 while(!nameExists) |
|
1342 { |
|
1343 wapRecord->iRecordName.SetMaxLengthL(nameBuffer->Length()); |
|
1344 wapRecord->iRecordName = *nameBuffer; |
|
1345 |
|
1346 if(wapRecord->FindL(*iDBSession)) |
|
1347 { |
|
1348 ++currentRecord; |
|
1349 nameBuffer->Des().Format(defaultSettingsName, currentRecord); |
|
1350 } |
|
1351 else |
|
1352 nameExists = ETrue; |
|
1353 } |
|
1354 CleanupStack::PopAndDestroy(wapRecord); |
|
1355 |
|
1356 // Add characteristic header, then name and value to the parsed fields |
|
1357 AppendNameFieldL(KWappCharName); |
|
1358 AppendDataPairL(KWappName, nameBuffer->Des()); |
|
1359 CleanupStack::PopAndDestroy(3, nameBuffer); // nameBuffer, resourceFile, buffer |
|
1360 } |
|
1361 |
|
1362 }//END of SettingsNamePresentL() |
|
1363 |
|
1364 // RestoreParsedDataL() - Restores CParsedField data into the array |
|
1365 // |
|
1366 // |
|
1367 void CMsvBIOWapAccessParser::RestoreParsedDataL() |
|
1368 { |
|
1369 // Assume that our server message context is correctly set to the Bio Msg entry |
|
1370 iEntry.SetEntryL(iEntryId); |
|
1371 |
|
1372 // Has the entry been parsed,(iMtmData3 =1) or parsed & processed (iMtmData3 =2) |
|
1373 // If not leave with error code |
|
1374 if ( iEntry.Entry().MtmData3() != BIO_MSG_ENTRY_PARSED |
|
1375 && iEntry.Entry().MtmData3() != BIO_MSG_ENTRY_PROCESSED) |
|
1376 { |
|
1377 iSmsParsed=EFalse; // Entry has not been parsed yet no data to restore |
|
1378 User::Leave(KWappErrMsgUnparsed); |
|
1379 } |
|
1380 |
|
1381 if(!iEntry.HasStoreL()) |
|
1382 { |
|
1383 iSmsParsed=EFalse; // Entry has no store - not parsed yet? |
|
1384 User::Leave(KWappErrStoreNotFound); |
|
1385 } |
|
1386 //Message has been parsed and data stored = restore it! |
|
1387 CMsvStore* store=iEntry.EditStoreL(); |
|
1388 CleanupStack::PushL(store); |
|
1389 RestoreL(*store); |
|
1390 CleanupStack::PopAndDestroy();//store |
|
1391 |
|
1392 //Now set a few key variables using the data in the iParsedFieldArray |
|
1393 TLex myLex; |
|
1394 if (iParsedFieldArray->At(0)->FieldName().CompareF(KWappXMLversion)==0) |
|
1395 { |
|
1396 myLex =iParsedFieldArray->At(0)->FieldName(); |
|
1397 myLex.Mark(); |
|
1398 myLex.Val(iWBXMLversionX10, EDecimal); |
|
1399 } |
|
1400 else |
|
1401 User::Leave(KWappErrMandatoryTagMissing); // error- XML version is missing |
|
1402 |
|
1403 // Field at index=1 is PublicID - don't currently need this |
|
1404 // Field at index=2 is Character Set - will present if XML version =1.1, but not for 1.0 |
|
1405 |
|
1406 if (iWBXMLversionX10==11) |
|
1407 { // Have the Character Set |
|
1408 if (iParsedFieldArray->At(2)->FieldName().CompareF(KWappCharacterSet)==0 ) |
|
1409 { |
|
1410 myLex =iParsedFieldArray->At(1)->FieldName(); |
|
1411 myLex.Mark(); //Mark the start. |
|
1412 myLex.Val(iCharacterSet, EHex); |
|
1413 } |
|
1414 } |
|
1415 else |
|
1416 iCharacterSet=0; |
|
1417 } |
|
1418 // End of function CMsvBIOWapAccessParser::RestoreParsedDataL() |
|
1419 |
|
1420 // StoreParsedDataL() - stores array of parsed data in a store - calls base class StoreL() |
|
1421 // |
|
1422 void CMsvBIOWapAccessParser::StoreParsedDataL() |
|
1423 { |
|
1424 // Set to the current Entry id, create a store & save data |
|
1425 iEntry.SetEntryL(iEntryId); |
|
1426 CMsvStore* store=iEntry.EditStoreL(); |
|
1427 CleanupStack::PushL(store); |
|
1428 StoreL(*store); |
|
1429 CleanupStack::PopAndDestroy();//store |
|
1430 |
|
1431 // Set the parsed flag on the TMsvEntry |
|
1432 iEntry.SetEntryL(iEntryId); |
|
1433 TMsvEntry entry= iEntry.Entry(); |
|
1434 entry.SetMtmData3(BIO_MSG_ENTRY_PARSED); |
|
1435 |
|
1436 iEntry.ChangeL(entry); |
|
1437 } |
|
1438 |
|
1439 // |
|
1440 // ResetProcessVariablesL()-Resets array of bookmarks and recreates the objects mapping to CommDb Table s |
|
1441 // |
|
1442 // |
|
1443 void CMsvBIOWapAccessParser::ResetProcessVariablesL() |
|
1444 { |
|
1445 // Re-set boolean flags |
|
1446 iGsmCsdData = EFalse; |
|
1447 iGsmSmsData = EFalse; |
|
1448 iGprsData = EFalse; |
|
1449 iURLData = EFalse; |
|
1450 iMMSURLData = EFalse; |
|
1451 iNameData = EFalse; |
|
1452 iIdData = EFalse; |
|
1453 // Zero IDs |
|
1454 iRecordId = 0; |
|
1455 iWapAccessPtID = 0; |
|
1456 iWapLocation = 0; |
|
1457 iWapChargeCard = 0; |
|
1458 |
|
1459 iBookmarkList->ResetAndDestroy(); |
|
1460 |
|
1461 iWAPSettingsName.Set(TPtrC()); // Null the value in this descriptor |
|
1462 |
|
1463 delete iGsmCsdWapIpTable; |
|
1464 iGsmCsdWapIpTable = NULL; |
|
1465 delete iGprsWapIpTable; |
|
1466 iGprsWapIpTable =NULL; |
|
1467 delete iWapIpISPTable; |
|
1468 iWapIpISPTable = NULL; |
|
1469 delete iWapSmsTable; |
|
1470 iWapSmsTable = NULL; |
|
1471 delete iWapGprsTable; |
|
1472 iWapGprsTable = NULL; |
|
1473 delete iModemInitString; |
|
1474 iModemInitString = NULL; |
|
1475 } |
|
1476 |
|
1477 // |
|
1478 // Read_mb_u_int32() -- Helper function that uses the TLex iSms to extract a 32-bit |
|
1479 // integer encoded in a number of bytes. If Bit7 of the first |
|
1480 // byte is set, the number continues over into the next byte, |
|
1481 // and so on. If Bit7 is not set then it's the last byte. |
|
1482 // |
|
1483 TUint32 CMsvBIOWapAccessParser::Read_mb_u_int32L() |
|
1484 { |
|
1485 TUint32 decodedValue = 0; |
|
1486 TBool completed =EFalse; |
|
1487 |
|
1488 while(!completed) |
|
1489 { |
|
1490 TUint32 thisByte = (TUint) GetNextMessageByteL(); // cast the character returned by Get to a TUint32 |
|
1491 if (decodedValue & 0x2000000) // is Bit25 set? If so, bitshifting 7 places |
|
1492 User::Leave(KWappErrOutsideBoundaries); // left will cause overflow |
|
1493 |
|
1494 (decodedValue = decodedValue<<7); // assignment to keep compiler happy |
|
1495 //shift current value 7 places to the left, i.e. *256 |
|
1496 |
|
1497 if ( (thisByte & KWAPP_MB_INT32_CONTINUATION) ) |
|
1498 { |
|
1499 // bit 7 set, integer continues into next byte so keep processing |
|
1500 thisByte = thisByte & 0x7F; // mask Bit7 by AND'ing with all other bits |
|
1501 // set to 1, i.e. 01111111 =0x7F |
|
1502 decodedValue += thisByte; |
|
1503 // leave completed set to EFalse |
|
1504 } |
|
1505 else // bit 7 isn't set, processing's completed so set flag |
|
1506 { |
|
1507 decodedValue += thisByte; |
|
1508 completed = ETrue; |
|
1509 } |
|
1510 } |
|
1511 return decodedValue; |
|
1512 } |
|
1513 |
|
1514 // |
|
1515 // GetStringTableItemL() - Returns the string contained within the string table starting |
|
1516 // at the offset passed in as a parameter. |
|
1517 // |
|
1518 HBufC* CMsvBIOWapAccessParser::ReadStringTableReferenceLC(TUint32 anOffset) |
|
1519 { |
|
1520 if (iStringTable ==NULL) |
|
1521 User::Leave(KWappErrStringTable); // Making a call to an nonexistant object! |
|
1522 TUint32 stringTableLength = iStringTable->Length(); |
|
1523 if (stringTableLength<=0) //Nothing to process, or worse, an error! |
|
1524 User::Leave(KWappErrOutsideBoundaries); //Past end of table |
|
1525 if (anOffset >= stringTableLength) // anOffset must be < last element of buffer |
|
1526 User::Leave(KWappErrOutsideBoundaries); // Last element must be NULL terminator! |
|
1527 |
|
1528 TUint32 stringTableItem = anOffset; // Current element in iStringTable |
|
1529 TUint32 stringLength=0; // Length of string |
|
1530 while ( iStringTable->Des()[stringTableItem] !=KWAPP_STR_TERM) |
|
1531 { |
|
1532 // increment through the String Table to first NULL terminator |
|
1533 stringTableItem++; |
|
1534 if (stringTableItem > (TUint)iStringTable->Length()) // Cast to remove warning, Length >=0 |
|
1535 User::Leave(KWappErrOutsideBoundaries); // Problem -gone past the end of the descriptor |
|
1536 stringLength++; |
|
1537 } |
|
1538 // return a descriptor starting at the offset and up to the char before the NULL terminator |
|
1539 |
|
1540 // Char Conversion |
|
1541 TPtrC data = iStringTable->Des().Mid(stringTableItem, stringTableLength-1); |
|
1542 HBufC* text = HBufC::NewLC(data.Length()); |
|
1543 TPtr des(text->Des()); |
|
1544 iCharsetConverter->ConvertL(data, des); |
|
1545 return text; |
|
1546 } |
|
1547 |
|
1548 |
|
1549 /* |
|
1550 Finds the end of the UCS2 string. Each character is represented by exactly 2bytes of data |
|
1551 According to WBXML version 1.0 |
|
1552 "if a character encoding includes a NULL then that NULL character must be used as the termination character" |
|
1553 Hence we are assuming that the end of the string is marked by two NULL bytes. |
|
1554 */ |
|
1555 void CMsvBIOWapAccessParser::ReadUCS2StringL() |
|
1556 { |
|
1557 TBool endofinlinestring = EFalse; |
|
1558 TBool endoflexstring = EFalse; |
|
1559 TBool foundNull; |
|
1560 |
|
1561 while (!endoflexstring && !endofinlinestring) |
|
1562 { |
|
1563 foundNull = EFalse; |
|
1564 endoflexstring = iSms.Eos(); |
|
1565 |
|
1566 if (!endoflexstring) |
|
1567 { |
|
1568 if (iSms.Peek() == KWAPP_STR_TERM) |
|
1569 { |
|
1570 foundNull = ETrue; |
|
1571 } |
|
1572 |
|
1573 iSms.Inc(); |
|
1574 if (iSms.Eos()) //check we haven't reached the end of the sms |
|
1575 User::Leave(KWappErrEOS); |
|
1576 |
|
1577 else if (foundNull && iSms.Peek()== KWAPP_STR_TERM) |
|
1578 endofinlinestring = ETrue; |
|
1579 } |
|
1580 else |
|
1581 User::Leave(KWappErrEOS); |
|
1582 } |
|
1583 |
|
1584 } |
|
1585 |
|
1586 |
|
1587 |
|
1588 /* |
|
1589 According to WBXML version 1.0 |
|
1590 "if a character encoding includes a NULL then that NULL character must |
|
1591 be used as the termination character" |
|
1592 |
|
1593 Finding the end of the ASCII string: |
|
1594 This is simply done as each character is represented by a maximum |
|
1595 of 7 bits of data, hence each character is one byte only. |
|
1596 Thus, it is assumed that the end of the string is marked by a NULL which in ASCII is 0x00 |
|
1597 |
|
1598 so the string "hi" would be represented as |
|
1599 0x68 0x69 0x00 |
|
1600 |
|
1601 Finding the end of the UTF-8 string. |
|
1602 From RFC 2279: |
|
1603 "In UTF-8, characters are encoded using sequences of 1 to 6 octets. |
|
1604 The only octet of a "sequence" of one has the higher-order bit set to |
|
1605 0, the remaining 7 bits being used to encode the character value. In |
|
1606 a sequence of n octets, n>1, the initial octet has the n higher-order |
|
1607 bits set to 1, followed by a bit set to 0. The remaining bit(s) of |
|
1608 that octet contain bits from the value of the character to be |
|
1609 encoded. The following octet(s) all have the higher-order bit set to |
|
1610 1 and the following bit set to 0, leaving 6 bits in each to contain |
|
1611 bits from the character to be encoded. |
|
1612 |
|
1613 The table below summarizes the format of these different octet types. |
|
1614 The letter x indicates bits available for encoding bits of the UCS-4 |
|
1615 character value. |
|
1616 |
|
1617 UCS-4 range (hex.) UTF-8 octet sequence (binary) |
|
1618 0000 0000-0000 007F 0xxxxxxx |
|
1619 0000 0080-0000 07FF 110xxxxx 10xxxxxx |
|
1620 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx |
|
1621 |
|
1622 0001 0000-001F FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
1623 0020 0000-03FF FFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx |
|
1624 0400 0000-7FFF FFFF 1111110x 10xxxxxx ... 10xxxxxx |
|
1625 " |
|
1626 ASCII values 0-127 are represented in UTF8 by one byte with the msb set to 0. |
|
1627 |
|
1628 This means that no byte in a stream of bytes representing a (non NULL) character will ever be 0x00. |
|
1629 So there will only be one 0x00 in the string and this will represent the end of the string. |
|
1630 |
|
1631 For example |
|
1632 the string of roman numerals "VIIIIII" where VIII is the first character and III is the second character |
|
1633 would be represented in UTF-8 as: |
|
1634 |
|
1635 0xE2 0x85 0xA2 0xE2 0x85 0xA7 0x00 |
|
1636 |
|
1637 The single byte 0x00 is the NULL terminator representing the end of the string. |
|
1638 */ |
|
1639 void CMsvBIOWapAccessParser::ReadASCIIorUTF8StringL() |
|
1640 { |
|
1641 while (!iSms.Eos() && iSms.Peek() !=KWAPP_STR_TERM /*0x00*/) |
|
1642 { |
|
1643 iSms.Inc(); |
|
1644 } |
|
1645 |
|
1646 if (iSms.Eos()) // End of the string! Other chars should follow |
|
1647 User::Leave(KWappErrEOS); |
|
1648 |
|
1649 } |
|
1650 |
|
1651 /* |
|
1652 because iSms is a TLex it is padded out and so |
|
1653 when parsing unicode strings you end up with unnecessary characters |
|
1654 */ |
|
1655 |
|
1656 //HBufC* CMsvBIOWapAccessParser::RemovePadding() |
|
1657 //{ |
|
1658 //} |
|
1659 |
|
1660 |
|
1661 // |
|
1662 // ReadInlineStringL() - Returns the string begining at the current position in the |
|
1663 // message. Increments TLex position until string termination found. |
|
1664 // |
|
1665 HBufC* CMsvBIOWapAccessParser::ReadInlineStringLC() |
|
1666 { |
|
1667 if (!iSms.Eos())//Mark the starting point of the string |
|
1668 iSms.Mark(); |
|
1669 else // End of the string! Can't proceed! |
|
1670 User::Leave(KWappErrEOS); |
|
1671 |
|
1672 //find the end of the string by taking into accout how it is encoded |
|
1673 switch (iCharacterSet) |
|
1674 { |
|
1675 case KCharsetASCII: |
|
1676 case KCharsetUTF8: |
|
1677 ReadASCIIorUTF8StringL(); |
|
1678 break; |
|
1679 case KCharsetUCS2: |
|
1680 ReadUCS2StringL(); |
|
1681 break; |
|
1682 default: |
|
1683 User::Leave(KErrNotSupported); |
|
1684 break; |
|
1685 }; |
|
1686 |
|
1687 //the end of the string has been found so mark it. |
|
1688 TPtrC data =iSms.MarkedToken(); |
|
1689 iSms.Inc(); //Increment up to the KWAPP_STR_TERM so next time we read the char after the end of the string |
|
1690 /* |
|
1691 Marked token is now converted to unicode |
|
1692 for the purpose of applying to commdb for example. |
|
1693 */ |
|
1694 |
|
1695 // Char Conversion |
|
1696 //for unicode parsing to remove unnecessary padding |
|
1697 if (iCharacterSet == KCharsetUCS2) |
|
1698 { |
|
1699 HBufC* text = HBufC::NewMaxLC(data.Length() / 2); |
|
1700 TPtr destext(text->Des()); |
|
1701 |
|
1702 TInt j = 0; |
|
1703 TInt i = 1; |
|
1704 |
|
1705 while (j < data.Length() / 2) |
|
1706 { |
|
1707 destext[j] = data[i]; |
|
1708 i += 2; |
|
1709 j++; |
|
1710 } |
|
1711 |
|
1712 return text; |
|
1713 } |
|
1714 else |
|
1715 { |
|
1716 HBufC* text = HBufC::NewMaxLC(data.Length()); |
|
1717 TPtr destext(text->Des()); |
|
1718 |
|
1719 iCharsetConverter->ConvertL(data, destext); |
|
1720 |
|
1721 return text; |
|
1722 } |
|
1723 } |
|
1724 |
|
1725 |
|
1726 // |
|
1727 // AppendDataPairL() - Appends a CParsedField containing data from the message, to the |
|
1728 // array of parsed fields (iParsedFieldsArray). |
|
1729 // |
|
1730 void CMsvBIOWapAccessParser::AppendDataPairL(const TDesC& aFieldName, const TDesC& aFieldValue) |
|
1731 { |
|
1732 // Appends a CParsedField object to iParsedFieldArray. |
|
1733 // Both fields have valid data |
|
1734 CParsedField* localData = new (ELeave) CParsedField; |
|
1735 CleanupStack::PushL(localData); |
|
1736 localData->SetFieldNameL(aFieldName); |
|
1737 localData->SetFieldValueL(aFieldValue); |
|
1738 CleanupStack::Pop(); |
|
1739 iParsedFieldArray->AppendL(localData); |
|
1740 } |
|
1741 |
|
1742 // |
|
1743 // AppendNameFieldL() - Appends a CParsedField containing just a Name from the message, |
|
1744 // to the array of parsed fields (iParsedFieldsArray). |
|
1745 // |
|
1746 void CMsvBIOWapAccessParser::AppendNameFieldL(const TDesC& aFieldName) |
|
1747 { |
|
1748 // Appends a CParsedField object to iParsedFieldArray. |
|
1749 // Only the Name field has valid data, the Value field is left NULL |
|
1750 CParsedField* localData = new (ELeave) CParsedField; |
|
1751 CleanupStack::PushL(localData); |
|
1752 localData->SetFieldNameL(aFieldName); |
|
1753 localData->SetFieldValueL(KNullDesC); // Set to an empty descriptor |
|
1754 CleanupStack::Pop(); |
|
1755 iParsedFieldArray->AppendL(localData); |
|
1756 } |
|
1757 |
|
1758 void CMsvBIOWapAccessParser::InsertDataPairL(const TDesC& aFieldName, const TDesC& aFieldValue, TInt anIndex) |
|
1759 { |
|
1760 // check that the position is valid! Leave if out of bounds |
|
1761 // Limits 0 - insert at front of array, iParsedData->Count() append to end |
|
1762 if (!(anIndex<= iParsedFieldArray->Count() && anIndex >= 0) ) |
|
1763 User::Leave(KErrArgument); |
|
1764 CParsedField* localField = new (ELeave)CParsedField; |
|
1765 CleanupStack::PushL(localField); |
|
1766 localField->SetFieldNameL(aFieldName); |
|
1767 localField->SetFieldValueL(aFieldValue); |
|
1768 CleanupStack::Pop(); |
|
1769 iParsedFieldArray->InsertL(anIndex, localField); |
|
1770 } |
|
1771 |
|
1772 TChar CMsvBIOWapAccessParser::GetNextMessageByteL() |
|
1773 { |
|
1774 if (iSms.Eos()) // Error - unexpectedly reached the end of the TLex buffer!!!!! |
|
1775 User::Leave(KWappErrEOS); |
|
1776 return iSms.Get(); |
|
1777 } |
|
1778 |
|
1779 TInt CMsvBIOWapAccessParser::LocateParsedFieldName(const TDesC& aFieldName, const TInt aStartIndex) |
|
1780 { |
|
1781 //Searches from a start pos'n, default=0, until either finds a match, or end of array |
|
1782 TInt count=aStartIndex; |
|
1783 TBool nextCharacteristic =EFalse; |
|
1784 |
|
1785 //loop until end of the array, found the first match or found another Characteristic! |
|
1786 TInt nFields = iParsedFieldArray->Count(); |
|
1787 while (count < nFields && // End of array? |
|
1788 (iParsedFieldArray->At(count)->FieldName().CompareF(aFieldName) !=0) && //Match found? |
|
1789 !nextCharacteristic ) |
|
1790 { |
|
1791 |
|
1792 if ( (count !=aStartIndex) && (IsCharacteristicName(count)) ) |
|
1793 // Not 1st first element of characteristic and found field for another |
|
1794 // characteristic- Must have reached next characteristic - stop looping |
|
1795 { |
|
1796 nextCharacteristic =ETrue; |
|
1797 } |
|
1798 |
|
1799 ++count; |
|
1800 } |
|
1801 |
|
1802 if (count < nFields && !nextCharacteristic) // found a match in the array, even if it is last element |
|
1803 return count; |
|
1804 else |
|
1805 return KErrNotFound; // Didn't find a match or reached next characteristic - flag the errror |
|
1806 } |
|
1807 |
|
1808 // |
|
1809 // DoProcessL() - Workhorse for ProcessL function. Extracts information from parsed field |
|
1810 // array into separate objects. Writes settings to the COMMS DB, if |
|
1811 // there is data for at least one bearer type. Saves any Bookmarks to file. |
|
1812 // |
|
1813 void CMsvBIOWapAccessParser::DoProcessL() |
|
1814 { |
|
1815 if (iGsmCsdData || iGsmSmsData || iGprsData) |
|
1816 { |
|
1817 WriteDataToDBL(); |
|
1818 } |
|
1819 WriteBookmarksToFileL(); |
|
1820 |
|
1821 if( iMMSURLData ) |
|
1822 { |
|
1823 WriteMMSURLL(); |
|
1824 } |
|
1825 |
|
1826 if (!iGprsData && !iGsmCsdData && !iGsmSmsData && !iMMSURLData && (iBookmarkList->Count()==0)) |
|
1827 { |
|
1828 // No bearers, no bookmarks - must be a settings message - wouldn't be here otherwise |
|
1829 if (iNameData && iURLData) // iIDData optional |
|
1830 { |
|
1831 UpdateStartPageUrlL(); // update the URL of the start page in WAP table |
|
1832 } |
|
1833 } |
|
1834 |
|
1835 } |
|
1836 |
|
1837 // |
|
1838 // PreProcessL - goes through the fields in the array of parsed data, extracting information |
|
1839 // only extracts information for first of each of the 4 bearer types - i.e. max |
|
1840 // of 4 entries in the ISP/WAP tables. Additional address characteristics are |
|
1841 // ignored. |
|
1842 // |
|
1843 void CMsvBIOWapAccessParser::PreProcessL() |
|
1844 { |
|
1845 TInt arrayPtr=0; // current position in the array of ParsedFields |
|
1846 |
|
1847 while (arrayPtr < iParsedFieldArray->Count()) |
|
1848 { |
|
1849 // Check current field if characteristic - peek at next field -> bearer type |
|
1850 // GSM/CSD - extract data from GSM/CSD Address characteristic |
|
1851 // GSM/SMS - extract data from GSM/SMS Address characteristic |
|
1852 // GPRS - extract data from GPRS Address characteristic |
|
1853 // GSM/USSD - TO DO, GSM/USSD Address characteristic unsupported |
|
1854 // IS136/CSD - TO DO, IS136/CSD Address characteristic unsupported |
|
1855 // ID - extract data from ID characteristic |
|
1856 // NAME - extract data from NAME characteristic |
|
1857 // URL - extract data from URL characteristic |
|
1858 // BOOKMARK - extract Bookmark characteristic & append to Bookmark array |
|
1859 // Otherwise report an error |
|
1860 |
|
1861 // Increment past WBXML Version, public ID or character set to the data we want |
|
1862 if ((iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappXMLversion) ==0) || |
|
1863 (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappPublicID) ==0)|| |
|
1864 (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappCharacterSet) ==0)) |
|
1865 |
|
1866 arrayPtr++; |
|
1867 else if (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappCharAddress) ==0) |
|
1868 { |
|
1869 // Stepped past first 3 fields & its an Address Characteristic |
|
1870 // So read the next line to determine type of bearer |
|
1871 |
|
1872 TPtrC addressValue; |
|
1873 arrayPtr++; //increment to the next element |
|
1874 |
|
1875 if (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappBearer)==0) |
|
1876 addressValue.Set(iParsedFieldArray->At(arrayPtr)->FieldValue()); // Note the bearer type |
|
1877 else |
|
1878 User::Leave(KWappErrMandatoryTagMissing); // Not a BEARER - error! |
|
1879 |
|
1880 // Next - either extract the bearer data into the table objects, if this is the |
|
1881 // first of this type, or skip past the data to the next characteristic. |
|
1882 if ((addressValue.CompareF(KWappGsmCsd)==0)) |
|
1883 { |
|
1884 // GSM/CSD Characteristic so add data to ISP and WAP table objects, or go to next characteristic |
|
1885 ExtractBearerDataL(arrayPtr); |
|
1886 } |
|
1887 |
|
1888 else if ((addressValue.CompareF(KWappGsmSms)==0)) |
|
1889 { |
|
1890 // GSM/CSD Characteristic so either add data to ISP and WAP table objects, or skip past to next characteristic |
|
1891 ExtractBearerDataL(arrayPtr); |
|
1892 } |
|
1893 |
|
1894 else if (addressValue.CompareF(KWappGsmUssd)==0) |
|
1895 { |
|
1896 User::Leave(KWappErrNotSupported); // Don't support these at the moment! |
|
1897 |
|
1898 // ExtractBearerDataL(arrayPtr); //Add data to ISP and WAP table objects |
|
1899 } |
|
1900 |
|
1901 else if (addressValue.CompareF(KWappIS136Csd)==0) |
|
1902 { |
|
1903 User::Leave(KWappErrNotSupported); // Don't do these at the moment! |
|
1904 // ExtractBearerDataL(arrayPtr); //Add data to ISP and WAP table objects |
|
1905 } |
|
1906 else if (addressValue.CompareF(KWappGprs)==0) |
|
1907 { |
|
1908 ExtractBearerDataL(arrayPtr); |
|
1909 } |
|
1910 else |
|
1911 User::Leave(KWappErrUnrecognised); // Value doesn't match any of the known ones |
|
1912 } |
|
1913 |
|
1914 // Check if it's a URL characteristic |
|
1915 else if (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappCharURL) ==0) |
|
1916 { |
|
1917 // The URL Characteristic has NO PARM elements only a value |
|
1918 |
|
1919 if (iURLData == EFalse) // Not been set previously |
|
1920 { |
|
1921 // Use the first instance of a URL - set it to the characteristic value even if it's null |
|
1922 iUrl.Set(iParsedFieldArray->At(arrayPtr)->FieldValue()); |
|
1923 iURLData = ETrue; |
|
1924 } |
|
1925 arrayPtr++; |
|
1926 } |
|
1927 |
|
1928 // Check if it's a Name Characteristic |
|
1929 else if (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappCharName) ==0) |
|
1930 { |
|
1931 // The NAME Characteristic should have EXACTLY 1 PARM element |
|
1932 arrayPtr++; // increment to the Parm in this characteristic |
|
1933 if (arrayPtr == iParsedFieldArray->Count() || |
|
1934 iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappName)!=0) |
|
1935 User::Leave(KWappErrBadMessage); |
|
1936 |
|
1937 // Initialise the Settings Name variable if it hasn't been set |
|
1938 if (iWAPSettingsName.Length()==0) |
|
1939 { |
|
1940 // Use the first instance of NAME - set it to the value even if it's null |
|
1941 iWAPSettingsName.Set(iParsedFieldArray->At(arrayPtr)->FieldValue()); |
|
1942 iNameData = ETrue; |
|
1943 } |
|
1944 |
|
1945 while ( arrayPtr< iParsedFieldArray->Count() && !(IsCharacteristicName(arrayPtr)) ) |
|
1946 arrayPtr++; // increment to beginning of next characteristic |
|
1947 |
|
1948 } |
|
1949 |
|
1950 //Is it a BOOKMARK ? Bookmarks must contain EXACTLY 2 PARM elements - NAME then URL |
|
1951 else if (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappCharBookmark)==0) |
|
1952 { |
|
1953 arrayPtr++; |
|
1954 ExtractBookmarkDataL(arrayPtr); |
|
1955 } |
|
1956 |
|
1957 // Is it an ID characteristic ? |
|
1958 else if (iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappCharID) ==0) |
|
1959 { |
|
1960 arrayPtr++; //Increment to the NAME Parm |
|
1961 |
|
1962 // End of array or PARM Type != NAME |
|
1963 if (arrayPtr == iParsedFieldArray->Count() || |
|
1964 iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappName)!=0) |
|
1965 User::Leave(KWappErrBadMessage); |
|
1966 |
|
1967 if (iIdData == EFalse) |
|
1968 { |
|
1969 // Use the 1st instance of an ID - set to value even if it's null! |
|
1970 iID.Set(iParsedFieldArray->At(arrayPtr)->FieldValue()); |
|
1971 iIdData = ETrue; |
|
1972 } |
|
1973 |
|
1974 while ( arrayPtr< iParsedFieldArray->Count() && !(IsCharacteristicName(arrayPtr)) ) |
|
1975 arrayPtr++; // increment to beginning of next characteristic |
|
1976 } |
|
1977 else if(iParsedFieldArray->At(arrayPtr)->FieldName().CompareF(KWappCharMMSURL) ==0) |
|
1978 { |
|
1979 // The MMSURL Characteristic has NO PARM elements only a value |
|
1980 |
|
1981 if (iMMSURLData == EFalse) // Not been set previously |
|
1982 { |
|
1983 // Use the first instance of a URL - set it to the characteristic value even if it's null |
|
1984 iMMSUrl.Set(iParsedFieldArray->At(arrayPtr)->FieldValue()); |
|
1985 iMMSURLData = ETrue; |
|
1986 } |
|
1987 |
|
1988 arrayPtr++; // Increment to the next element in the array |
|
1989 } |
|
1990 |
|
1991 else // Unrecognised characteristic token |
|
1992 User::Leave(KWappErrUnrecognised); |
|
1993 } |
|
1994 } |
|
1995 // END of function CMsvBIOWapAccessParser::PreProcessL() |
|
1996 |
|
1997 // |
|
1998 // ExtractBearerDataL() - |
|
1999 // |
|
2000 // Called by PreProcessL when it finds an address bearer type. Uses the reference to |
|
2001 // the current position in iParsedFieldArray to extract info to insert into CWapTableData |
|
2002 // and CIspTableData objects. Increment the index position as the function scans |
|
2003 // through the iParsedFieldArray - ensures the value in calling function is correct. |
|
2004 // |
|
2005 void CMsvBIOWapAccessParser::ExtractBearerDataL(TInt& aCurrentPos) |
|
2006 { |
|
2007 |
|
2008 TWappBearerType currentBearer = EWappUnknownBearer; |
|
2009 |
|
2010 // local flags - |
|
2011 // For all address characteristics, only process 1st instance of each parm type - ignore the rest |
|
2012 TBool bearer = EFalse; |
|
2013 TBool proxy = EFalse; |
|
2014 TBool port = EFalse; |
|
2015 TBool csdDialstring = EFalse; |
|
2016 TBool pppAuthType = EFalse; |
|
2017 TBool pppAuthName = EFalse; |
|
2018 TBool pppAuthSecret = EFalse; |
|
2019 TBool pppLoginType = EFalse; |
|
2020 TBool csdCallType = EFalse; |
|
2021 TBool csdCallSpeed = EFalse; |
|
2022 TBool pxAuthName = EFalse; |
|
2023 TBool pxAuthSecret = EFalse; |
|
2024 TBool pxLoginType = EFalse; |
|
2025 TBool ispName = EFalse; |
|
2026 TBool smsSMSCAddr = EFalse; |
|
2027 // TBool ussdServiceCode = EFalse; //Currently not used - will be needed if GSM/USSD supported |
|
2028 |
|
2029 TInt arrayEnd = iParsedFieldArray->Count(); |
|
2030 TCsdCallType callType =EAnalogue; |
|
2031 TCsdCallSpeed callSpeed =EAutobauding; |
|
2032 |
|
2033 // First check - current parm MUST BE A BEARER |
|
2034 // Following Parms can be in any order, but the first must be a BEARER. |
|
2035 |
|
2036 if (iParsedFieldArray->At(aCurrentPos)->FieldName().CompareF(KWappBearer) !=0) |
|
2037 User::Leave(KWappErrMandatoryTagMissing); // First Parm is not a BEARER - big problem!! |
|
2038 |
|
2039 |
|
2040 while ( aCurrentPos< arrayEnd && // Stop checking if past the array end, or next value |
|
2041 !(IsCharacteristicName(aCurrentPos)) ) // is another Characteristic, ie. address, URL, Bookmark, ID or Name |
|
2042 { |
|
2043 TPtrC fieldName = iParsedFieldArray->At(aCurrentPos)->FieldName(); |
|
2044 if (IsValidTokenNameL(aCurrentPos) !=KErrNone) //Validate this Parm Name |
|
2045 User::Leave(KWappErrUnrecognised); |
|
2046 |
|
2047 // Check the next parsed field data - BEARER type |
|
2048 |
|
2049 if (fieldName.CompareF(KWappBearer) ==0) |
|
2050 { |
|
2051 //Set the current local bearer type, & then bearer variable |
|
2052 TPtrC currentValue = iParsedFieldArray->At(aCurrentPos)->FieldValue(); |
|
2053 if (currentValue.CompareF(KWappGsmCsd) ==0) |
|
2054 { |
|
2055 if (!bearer) // first time here! |
|
2056 { |
|
2057 if (!iGsmCsdData) // No previous GSM bearers |
|
2058 { |
|
2059 iGsmCsdWapIpTable = CWapIpBearerData::NewL(); // Create the required table mapping objects |
|
2060 iWapIpISPTable = CIspTableData::NewL(); |
|
2061 currentBearer = EWappGsmCsdBearer;// set local bearer type variable |
|
2062 bearer = ETrue; // ignore further BEARER's only for this characteristic |
|
2063 } |
|
2064 else // Already got data increment to next characteristic and return |
|
2065 { |
|
2066 while ( aCurrentPos< arrayEnd && !(IsCharacteristicName(aCurrentPos)) ) |
|
2067 aCurrentPos++; // increment to beginning of next characteristic |
|
2068 return; // return to PrePocessL |
|
2069 } |
|
2070 } |
|
2071 } |
|
2072 |
|
2073 else if (currentValue.CompareF(KWappGsmSms) ==0) |
|
2074 { |
|
2075 if (!bearer) // haven't set the bearer type yet, ignore all after first |
|
2076 { |
|
2077 if (!iGsmSmsData) // No previous SMS bearers |
|
2078 { |
|
2079 iWapSmsTable = CWapSmsBearerData::NewL(); |
|
2080 currentBearer =EWappGsmSmsBearer; |
|
2081 bearer = ETrue; // ignore any further BEARERs in this Characteristic |
|
2082 } |
|
2083 else // Already got bearer data goto next characteristic & return |
|
2084 { |
|
2085 while ( aCurrentPos< arrayEnd && !(IsCharacteristicName(aCurrentPos)) ) |
|
2086 aCurrentPos++; // increment to beginning of next characteristic |
|
2087 return; // return to PrePocessL |
|
2088 } |
|
2089 } |
|
2090 } |
|
2091 |
|
2092 else if (currentValue.CompareF(KWappGsmUssd) ==0) |
|
2093 { |
|
2094 currentBearer =EWappGsmUssdBearer; |
|
2095 //NB Add support for USSD bearer here when required |
|
2096 // NOTE - must consider proxy & proxy type with USSD! |
|
2097 User::Leave(KWappErrNotSupported); |
|
2098 } |
|
2099 |
|
2100 else if (currentValue.CompareF(KWappIS136Csd) ==0) |
|
2101 { |
|
2102 currentBearer =EWappIS136CsdBearer; |
|
2103 //NB Add support for IS 136 when required |
|
2104 // NOTE - will it be the same as for GSM/CSD ? |
|
2105 User::Leave(KWappErrNotSupported); |
|
2106 } |
|
2107 else if (currentValue.CompareF(KWappGprs) ==0) |
|
2108 { |
|
2109 if (!bearer) // first time here! |
|
2110 { |
|
2111 if (!iGprsData) // No previous bearers |
|
2112 { |
|
2113 iGprsWapIpTable = CWapIpBearerData::NewL(); // Create the required table mapping objects |
|
2114 iWapGprsTable = CWapGprsBearerData::NewL(); |
|
2115 iWapIpISPTable = CIspTableData::NewL(); |
|
2116 currentBearer = EWappGprsBearer;// set local bearer type variable |
|
2117 bearer = ETrue; // ignore further BEARER's only for this characteristic |
|
2118 } |
|
2119 else // Already got bearer data, increment to next characteristic and return |
|
2120 { |
|
2121 while ( aCurrentPos< arrayEnd && !(IsCharacteristicName(aCurrentPos)) ) |
|
2122 aCurrentPos++; // increment to beginning of next characteristic |
|
2123 return; // return to PrePocessL |
|
2124 } |
|
2125 } |
|
2126 } |
|
2127 else |
|
2128 User::Leave(KWappErrUnrecognised); // Unknown bearer type - Help!!!! |
|
2129 } |
|
2130 |
|
2131 //Check for the PROXY characteristics - String used to set Table Data |
|
2132 |
|
2133 // CSD proxy value into iIspTable::iGateway - goes in ISP_IP_GATEWAY |
|
2134 // iWapTable::iGatewayAddr - goes into WAP_GATEWAY_ADDRESS |
|
2135 // SMS proxy value into iWapTable::iGatewayAddr - goes into WAP_GATEWAY_ADDRESS |
|
2136 |
|
2137 // NB If support for USSD, or IS136 required, add additional code here. |
|
2138 else if (fieldName.CompareF(KWappProxy) ==0) |
|
2139 { |
|
2140 if(!proxy) // First PROXY for this characteristic |
|
2141 { |
|
2142 switch(currentBearer) |
|
2143 { |
|
2144 case EWappGsmSmsBearer: |
|
2145 iWapSmsTable->iGatewayAddr.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2146 break; |
|
2147 case EWappGsmCsdBearer: |
|
2148 iGsmCsdWapIpTable->iGatewayAddr->SetAddrL(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2149 iWapIpISPTable->iGateway->SetAddrL(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2150 break; |
|
2151 case EWappGprsBearer: |
|
2152 iGprsWapIpTable->iGatewayAddr->SetAddrL(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2153 iWapGprsTable->iGatewayAddr->SetAddrL(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2154 break; |
|
2155 default: |
|
2156 User::Leave(KWappErrUnrecognised); // Unrecognised currentBearer |
|
2157 } |
|
2158 proxy = ETrue; |
|
2159 } |
|
2160 } |
|
2161 |
|
2162 |
|
2163 //Check for the PORT characteristics - first encounter set it, ignore it afterwards |
|
2164 else if ((fieldName.CompareF(KWappPort)==0) && !port) |
|
2165 { |
|
2166 // Record that we've checked a port value - should be one of 4 values! |
|
2167 |
|
2168 if ( (iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappPort9200) ==0) |
|
2169 ||(iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappPort9201) ==0) |
|
2170 ||(iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappPort9202) ==0) |
|
2171 ||(iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappPort9203) ==0)) |
|
2172 |
|
2173 { |
|
2174 if (currentBearer == EWappGsmSmsBearer) |
|
2175 iWapSmsTable->iPort.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2176 else if (currentBearer == EWappGsmCsdBearer) |
|
2177 iGsmCsdWapIpTable->iPort.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2178 else if (currentBearer == EWappGprsBearer) |
|
2179 iGprsWapIpTable->iPort.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2180 } |
|
2181 else |
|
2182 { |
|
2183 if (currentBearer == EWappGsmSmsBearer) |
|
2184 iWapSmsTable->iPort.Set(KWappPort9200); |
|
2185 else if (currentBearer == EWappGsmCsdBearer) |
|
2186 iGsmCsdWapIpTable->iPort.Set(KWappPort9200); |
|
2187 else if (currentBearer == EWappGprsBearer) |
|
2188 iGprsWapIpTable->iPort.Set(KWappPort9200); |
|
2189 } |
|
2190 port = ETrue; |
|
2191 } |
|
2192 |
|
2193 |
|
2194 // ******* Following group are for GSM/CSD & IS136/CSD - GSM/SMS and GSM/USSD follow after ******** |
|
2195 |
|
2196 // Is it a CSD_DIALSTRING? |
|
2197 else if (fieldName.CompareF(KWappCsdDial)==0) |
|
2198 { |
|
2199 // Must be either GSM/CSD or IS136/CSD |
|
2200 if ( (currentBearer != EWappGsmCsdBearer) && |
|
2201 (currentBearer != EWappIS136CsdBearer) ) |
|
2202 User::Leave(KWappErrUnexpectedValue); |
|
2203 else if (!csdDialstring) |
|
2204 { |
|
2205 iWapIpISPTable->iDefaultPhoneNum.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2206 csdDialstring=ETrue; |
|
2207 } |
|
2208 } |
|
2209 |
|
2210 // Check for PPP_AUTHTYPE |
|
2211 // Now don't set the iIFName - always "ppp" & this protocol takes care of rest |
|
2212 else if (fieldName.CompareF(KWappPPPAuthType)==0 && !pppAuthType) |
|
2213 { |
|
2214 if(currentBearer==EWappGprsBearer) |
|
2215 { |
|
2216 if(iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappPAP)==0) |
|
2217 iWapGprsTable->iPlainTextAuthDisabled = EFalse; |
|
2218 else |
|
2219 iWapGprsTable->iPlainTextAuthDisabled = ETrue; |
|
2220 } |
|
2221 // set the flag so we don't check again |
|
2222 pppAuthType =ETrue; |
|
2223 } |
|
2224 |
|
2225 // Check if its a PPP_AUTHNAME |
|
2226 else if (fieldName.CompareF(KWappPPPAuthName)==0) |
|
2227 { |
|
2228 if (!pppAuthName) |
|
2229 { |
|
2230 switch(currentBearer) |
|
2231 { |
|
2232 case EWappGsmCsdBearer: |
|
2233 case EWappIS136CsdBearer: |
|
2234 iWapIpISPTable->iLoginName.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2235 break; |
|
2236 case EWappGprsBearer: |
|
2237 iWapGprsTable->iLoginName.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2238 break; |
|
2239 default: |
|
2240 // SMS, USSD and GPRS don't have CSD authentication names |
|
2241 User::Leave(KWappErrUnexpectedValue); |
|
2242 } |
|
2243 pppAuthName = ETrue; |
|
2244 } |
|
2245 } |
|
2246 |
|
2247 // Is it PPP_AUTHSECRET? |
|
2248 else if (fieldName.CompareF(KWappPPPAuthSecret)==0 ) |
|
2249 { |
|
2250 |
|
2251 if (!pppAuthSecret) |
|
2252 { |
|
2253 switch(currentBearer) |
|
2254 { |
|
2255 case EWappGsmCsdBearer: |
|
2256 case EWappIS136CsdBearer: |
|
2257 iWapIpISPTable->iLoginPass.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2258 break; |
|
2259 case EWappGprsBearer: |
|
2260 iWapGprsTable->iLoginPass.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2261 break; |
|
2262 default: |
|
2263 // SMS, GPRS & USSD don't have authentication type |
|
2264 User::Leave(KWappErrUnexpectedValue); |
|
2265 } |
|
2266 pppAuthSecret = ETrue; |
|
2267 } |
|
2268 } |
|
2269 // Is it a PPP_LOGIN_TYPE? |
|
2270 else if (fieldName.CompareF(KWappPPPLoginType)==0) |
|
2271 { |
|
2272 if(!pppLoginType) |
|
2273 { |
|
2274 const TDesC& val = iParsedFieldArray->At(aCurrentPos)->FieldValue(); |
|
2275 switch(currentBearer) |
|
2276 { |
|
2277 case EWappGsmCsdBearer: |
|
2278 case EWappIS136CsdBearer: |
|
2279 { |
|
2280 if(val.CompareF(KWappAuthAutomatic)==0) |
|
2281 { |
|
2282 iWapIpISPTable->iIFPromptForAuthentication = EFalse; |
|
2283 iWapIpISPTable->iPromptForLoginDetails = EFalse; |
|
2284 } |
|
2285 else |
|
2286 { |
|
2287 iWapIpISPTable->iIFPromptForAuthentication = ETrue; |
|
2288 iWapIpISPTable->iPromptForLoginDetails = ETrue; |
|
2289 } |
|
2290 } |
|
2291 break; |
|
2292 case EWappGprsBearer: |
|
2293 { |
|
2294 if(val.CompareF(KWappAuthAutomatic)==0) |
|
2295 iWapGprsTable->iIFPromptForAuth = EFalse; |
|
2296 else |
|
2297 iWapGprsTable->iIFPromptForAuth = ETrue; |
|
2298 } |
|
2299 break; |
|
2300 default: |
|
2301 User::Leave(KWappErrUnexpectedValue); |
|
2302 } |
|
2303 } |
|
2304 pppLoginType = ETrue; |
|
2305 } |
|
2306 |
|
2307 // Is it a CSD_CALLTYPE? |
|
2308 else if (fieldName.CompareF(KWappCsdCallType)==0) |
|
2309 { |
|
2310 // ONLY GSM/CSD bearer has call types |
|
2311 if ( (currentBearer != EWappGsmCsdBearer) ) |
|
2312 User::Leave(KWappErrUnexpectedValue); |
|
2313 |
|
2314 else if (!csdCallType) |
|
2315 { |
|
2316 // Can have values ANALOGUE (don't set nothing) & ISDN (set modem init string) |
|
2317 if (iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappISDN)==0) |
|
2318 { |
|
2319 // TODO implement this function when Symbian know device specs |
|
2320 SetModemInitStringL(); |
|
2321 callType = EIsdn; |
|
2322 } |
|
2323 else if ((iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappAnalogue)==0)) |
|
2324 { |
|
2325 callType = EAnalogue; |
|
2326 } |
|
2327 else |
|
2328 callType = EAnalogue; // Not recognised so set to default of ANALOGUE |
|
2329 csdCallType =ETrue; |
|
2330 } |
|
2331 } |
|
2332 |
|
2333 //Check if its a CSD_CALLSPEED |
|
2334 else if (fieldName.CompareF(KWappCsdCallSpeed)==0) |
|
2335 { |
|
2336 // ONLY CSD bearer has call speed - anything else is an error |
|
2337 if (currentBearer != EWappGsmCsdBearer) |
|
2338 User::Leave(KWappErrUnexpectedValue); |
|
2339 else if (!csdCallSpeed) |
|
2340 { |
|
2341 TPtrC value = iParsedFieldArray->At(aCurrentPos)->FieldValue(); |
|
2342 // Set the local variable for callspeed - will set the iIspTable value at end of fn |
|
2343 if (value.CompareF(KWappSpeedAuto)==0) |
|
2344 callSpeed = EAutobauding ; // Auto speed select - device chooses |
|
2345 else if (value.CompareF(KWappSpeed9600)==0) |
|
2346 callSpeed = E9600baud; |
|
2347 else if (value.CompareF(KWappSpeed14400)==0) |
|
2348 callSpeed = E14400baud; |
|
2349 else if (value.CompareF(KWappSpeed19200)==0) |
|
2350 callSpeed = E19200baud; |
|
2351 else if (value.CompareF(KWappSpeed28800)==0) |
|
2352 callSpeed = E28800baud; |
|
2353 else if (value.CompareF(KWappSpeed38400)==0) |
|
2354 callSpeed = E38400baud; |
|
2355 else if (value.CompareF(KWappSpeed43200)==0) |
|
2356 callSpeed = E43200baud; |
|
2357 else if (value.CompareF(KWappSpeed56700)==0) |
|
2358 callSpeed = E57600baud; |
|
2359 else |
|
2360 callSpeed = EAutobauding;// Set to the default of AUTO |
|
2361 |
|
2362 csdCallSpeed =ETrue; |
|
2363 } |
|
2364 } |
|
2365 |
|
2366 // Check if its a PROXY_AUTHNAME - must be CSD or GPRS |
|
2367 else if (fieldName.CompareF(KWappProxyAuthName)==0 ) |
|
2368 { |
|
2369 switch(currentBearer) |
|
2370 { |
|
2371 case EWappGsmCsdBearer: |
|
2372 case EWappIS136CsdBearer: |
|
2373 if (!pxAuthName) |
|
2374 { |
|
2375 iGsmCsdWapIpTable->iProxyAuthName.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2376 pxAuthName =ETrue; |
|
2377 } |
|
2378 break; |
|
2379 case EWappGprsBearer: |
|
2380 if (!pxAuthName) |
|
2381 { |
|
2382 iGprsWapIpTable->iProxyAuthName.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2383 pxAuthName =ETrue; |
|
2384 } |
|
2385 break; |
|
2386 default: |
|
2387 User::Leave(KWappErrUnexpectedValue); |
|
2388 } |
|
2389 } |
|
2390 |
|
2391 // Is it a PROXY_AUTHSECRET? |
|
2392 else if (fieldName.CompareF(KWappProxyAuthSecret)==0) |
|
2393 { |
|
2394 switch(currentBearer) |
|
2395 { |
|
2396 case EWappGsmCsdBearer: |
|
2397 case EWappIS136CsdBearer: |
|
2398 if (!pxAuthSecret) |
|
2399 { |
|
2400 iGsmCsdWapIpTable->iProxyAuthSecret.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2401 pxAuthSecret =ETrue; |
|
2402 } |
|
2403 break; |
|
2404 case EWappGprsBearer: |
|
2405 if (!pxAuthSecret) |
|
2406 { |
|
2407 iGprsWapIpTable->iProxyAuthSecret.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2408 pxAuthSecret =ETrue; |
|
2409 } |
|
2410 break; |
|
2411 default: |
|
2412 User::Leave(KWappErrUnexpectedValue); |
|
2413 } |
|
2414 } |
|
2415 |
|
2416 // Is it a PROXY_LOGIN_TYPE? |
|
2417 |
|
2418 else if (fieldName.CompareF(KWappProxyLoginType)==0) |
|
2419 { |
|
2420 //We just set the variable in the mapping object for the WAP IP Bearer Table. Don't do anything with it yet. |
|
2421 switch(currentBearer) |
|
2422 { |
|
2423 case EWappGsmCsdBearer: |
|
2424 case EWappIS136CsdBearer: |
|
2425 if (!pxAuthSecret) |
|
2426 { |
|
2427 if (iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappAuthAutomatic)) |
|
2428 iGsmCsdWapIpTable->iProxyUseAutoLogin = ETrue; |
|
2429 else |
|
2430 iGsmCsdWapIpTable->iProxyUseAutoLogin = EFalse; |
|
2431 } |
|
2432 break; |
|
2433 case EWappGprsBearer: |
|
2434 if (!pxAuthSecret) |
|
2435 { |
|
2436 if (iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappAuthAutomatic)) |
|
2437 iGprsWapIpTable->iProxyUseAutoLogin = ETrue; |
|
2438 else |
|
2439 iGprsWapIpTable->iProxyUseAutoLogin = EFalse; |
|
2440 } |
|
2441 break; |
|
2442 default: |
|
2443 User::Leave(KWappErrUnexpectedValue); |
|
2444 } |
|
2445 |
|
2446 |
|
2447 pxLoginType = ETrue; |
|
2448 } |
|
2449 |
|
2450 |
|
2451 // Is it a ISP _NAME element? |
|
2452 else if (fieldName.CompareF(KWappISP)==0) |
|
2453 { |
|
2454 // Must be a CSD or Grps bearer |
|
2455 if ( (currentBearer != EWappGsmCsdBearer) && |
|
2456 (currentBearer != EWappIS136CsdBearer) && |
|
2457 (currentBearer != EWappGprsBearer) ) |
|
2458 User::Leave(KWappErrUnexpectedValue); |
|
2459 else if (!ispName) |
|
2460 { |
|
2461 iWapIpISPTable->iISPDescription.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2462 ispName =ETrue; |
|
2463 } |
|
2464 } |
|
2465 |
|
2466 |
|
2467 // ****************** Following are for GSM/SMS settings ********************* |
|
2468 else if (fieldName.CompareF(KWappSMSCAddress)==0) |
|
2469 { |
|
2470 if (currentBearer != EWappGsmSmsBearer) |
|
2471 User::Leave(KWappErrUnexpectedValue);// Only SMS has a SMSC address - error condition |
|
2472 else if (!smsSMSCAddr) |
|
2473 { |
|
2474 iWapSmsTable->iWapServiceAddr.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2475 smsSMSCAddr = ETrue; |
|
2476 } |
|
2477 } |
|
2478 |
|
2479 //Check for PROXY_TYPE characteristic |
|
2480 |
|
2481 // TO DO When/If USSD support is required! Add it here |
|
2482 // Need to know how to set Addressing Scheme for USSD & CSD/SMS/etc!!!!! |
|
2483 // Currently only alter value of dummy variable to keep the compiler happy |
|
2484 else if (fieldName.CompareF(KWappProxyType) ==0) |
|
2485 { |
|
2486 // Must be a USSD or GPRS bearer type - otherwise error! |
|
2487 if (currentBearer == EWappGsmUssdBearer) |
|
2488 { |
|
2489 // NB If USSD support req'd,set the Addressing type here. NB Not yet defined in CommDb! |
|
2490 } |
|
2491 else if(currentBearer == EWappGprsBearer) |
|
2492 { |
|
2493 if(iParsedFieldArray->At(aCurrentPos)->FieldValue().CompareF(KWappIpv4)!=0) |
|
2494 User::Leave(KWappErrUnrecognised); |
|
2495 } |
|
2496 else |
|
2497 User::Leave(KWappErrUnrecognised); |
|
2498 } |
|
2499 |
|
2500 // Check for USSD service code |
|
2501 else if (fieldName.CompareF(KWappUSSDCode)==0) |
|
2502 { |
|
2503 if (currentBearer == EWappGsmUssdBearer) |
|
2504 { |
|
2505 // NB - If USSD support req'd, set the Service Centre Address here! |
|
2506 } |
|
2507 else |
|
2508 User::Leave(KWappErrUnrecognised); // Not a USSD address, so shouldn't be here - error |
|
2509 } |
|
2510 |
|
2511 // Access point is GPRS only |
|
2512 else if (fieldName.CompareF(KWappAccessPointName)==0) |
|
2513 { |
|
2514 if (currentBearer == EWappGprsBearer) |
|
2515 { |
|
2516 iWapGprsTable->iAccessPointName.Set(iParsedFieldArray->At(aCurrentPos)->FieldValue()); |
|
2517 } |
|
2518 else |
|
2519 User::Leave(KWappErrUnrecognised); // Shouldn't have a GPRS address if we aren't GPRS! |
|
2520 } |
|
2521 |
|
2522 aCurrentPos++; |
|
2523 }// END of the While loop |
|
2524 |
|
2525 if (currentBearer == EWappGsmCsdBearer) |
|
2526 { |
|
2527 if (!iGsmCsdData) |
|
2528 { |
|
2529 if (!pppLoginType) |
|
2530 { |
|
2531 // Login type not set so determine value for whether login and authorisation set |
|
2532 if (iWapIpISPTable->iLoginName.Length()!=0 && iWapIpISPTable->iLoginPass.Length()!=0) |
|
2533 { |
|
2534 iWapIpISPTable->iPromptForLoginDetails =EFalse; |
|
2535 iWapIpISPTable->iIFPromptForAuthentication =EFalse; |
|
2536 } |
|
2537 } |
|
2538 if (! pxLoginType) |
|
2539 if (iGsmCsdWapIpTable->iProxyAuthName.Length()!=0 && iGsmCsdWapIpTable->iProxyAuthSecret.Length()!=0) |
|
2540 { |
|
2541 iGsmCsdWapIpTable->iProxyUseAutoLogin = ETrue; |
|
2542 } |
|
2543 |
|
2544 // Set the iIspTable->iCsdCallSpeed member - need the calltype and the callspeed values |
|
2545 if (callType == EAnalogue) |
|
2546 { |
|
2547 switch (callSpeed) |
|
2548 { |
|
2549 case EAutobauding: |
|
2550 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeedAutobauding; |
|
2551 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV34; |
|
2552 break; |
|
2553 case E9600baud: |
|
2554 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeed9600; |
|
2555 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV32; |
|
2556 break; |
|
2557 case E14400baud: |
|
2558 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeed14400; |
|
2559 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV34; |
|
2560 break; |
|
2561 case E19200baud: |
|
2562 iWapIpISPTable->iCallSpeed =RMobileCall::ESpeed19200; |
|
2563 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV34; |
|
2564 break; |
|
2565 case E28800baud: |
|
2566 iWapIpISPTable->iCallSpeed =RMobileCall::ESpeed28800; |
|
2567 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV34; |
|
2568 break; |
|
2569 case E38400baud: |
|
2570 case E43200baud: |
|
2571 case E57600baud: |
|
2572 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeedAutobauding; |
|
2573 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV34; |
|
2574 break; |
|
2575 default: //SHOULD be one of the above! |
|
2576 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeedAutobauding; |
|
2577 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV34; |
|
2578 break; |
|
2579 } |
|
2580 } |
|
2581 else if (!iGsmCsdData && callType == EIsdn) |
|
2582 { |
|
2583 iWapIpISPTable->iCallDataProtocol = RMobileCall::EProtocolV110; |
|
2584 switch (callSpeed) |
|
2585 { |
|
2586 case EAutobauding: |
|
2587 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeedAutobauding; |
|
2588 break; |
|
2589 case E9600baud: |
|
2590 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeed9600; |
|
2591 break; |
|
2592 case E14400baud: |
|
2593 iWapIpISPTable->iCallSpeed =RMobileCall::ESpeed14400; |
|
2594 break; |
|
2595 case E19200baud: |
|
2596 iWapIpISPTable->iCallSpeed =RMobileCall::ESpeed19200; |
|
2597 break; |
|
2598 case E28800baud: |
|
2599 iWapIpISPTable->iCallSpeed =RMobileCall::ESpeed28800; |
|
2600 break; |
|
2601 case E38400baud: |
|
2602 iWapIpISPTable->iCallSpeed =RMobileCall::ESpeed38400; |
|
2603 break; |
|
2604 case E43200baud: |
|
2605 iWapIpISPTable->iCallSpeed =RMobileCall::ESpeed48000; |
|
2606 break; |
|
2607 case E57600baud: |
|
2608 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeed56000; |
|
2609 break; |
|
2610 default: //SHOULD be one of the above! |
|
2611 iWapIpISPTable->iCallSpeed = RMobileCall::ESpeedAutobauding; |
|
2612 break; |
|
2613 } |
|
2614 } |
|
2615 else |
|
2616 User::Leave(KWappErrUnrecognised); //Unrecognised value for calltype - error |
|
2617 } |
|
2618 iGsmCsdData = ETrue; |
|
2619 } |
|
2620 |
|
2621 else if (currentBearer == EWappGsmSmsBearer) |
|
2622 iGsmSmsData = ETrue; |
|
2623 else if(currentBearer == EWappGprsBearer) |
|
2624 { |
|
2625 if (!pppLoginType) |
|
2626 { |
|
2627 if (iWapGprsTable->iLoginName.Length() > 0 && iWapGprsTable->iLoginPass.Length() > 0) |
|
2628 iWapGprsTable->iIFPromptForAuth =EFalse; |
|
2629 } |
|
2630 iGprsData = ETrue; |
|
2631 } |
|
2632 |
|
2633 } |
|
2634 // End of function CMsvBIOWapAccessParser::ExtractBearerDataL() |
|
2635 |
|
2636 // |
|
2637 // ExtractBookmarkDataL() - |
|
2638 // Extracts bookmark from parsed data. Adds default if name field is not |
|
2639 // set. Discards the Bookmark if URL field is blank (ie nothing added to Bookmark |
|
2640 // List) NB exactly 2 PARMs in a bookmark, NAME & URL, any order. |
|
2641 // |
|
2642 void CMsvBIOWapAccessParser::ExtractBookmarkDataL(TInt& aIndex) |
|
2643 { |
|
2644 TPtrC tempPtr; |
|
2645 TBool foundName = EFalse; |
|
2646 TBool foundURL = EFalse; |
|
2647 TInt parmsChecked = 0; |
|
2648 |
|
2649 HBufC* bookmarkName = NULL; |
|
2650 HBufC* bookmarkURL = NULL; |
|
2651 |
|
2652 // Should be set to the next parm in the Bookmark NOTE: Can't properly check that |
|
2653 // an Empty Name or URL Parsed field is not the start of another characteristic |
|
2654 while (aIndex < iParsedFieldArray->Count() && !IsCharacteristicName(aIndex)) |
|
2655 { |
|
2656 // check token is correct - copy NAME |
|
2657 if (parmsChecked <2 && iParsedFieldArray->At(aIndex)->FieldName().CompareF(KWappName) ==0) |
|
2658 { |
|
2659 if (foundName ==EFalse) |
|
2660 { |
|
2661 tempPtr.Set(iParsedFieldArray->At(aIndex)->FieldValue()); |
|
2662 if (tempPtr.Length()==0) |
|
2663 tempPtr.Set(KWappDefaultBMName); |
|
2664 bookmarkName = tempPtr.AllocL(); |
|
2665 CleanupStack::PushL(bookmarkName); |
|
2666 foundName =ETrue; |
|
2667 } |
|
2668 parmsChecked++; |
|
2669 } |
|
2670 else if (parmsChecked <2 && iParsedFieldArray->At(aIndex)->FieldName().CompareF(KWappURL)==0) |
|
2671 { |
|
2672 if (foundURL == EFalse) |
|
2673 { |
|
2674 tempPtr.Set(iParsedFieldArray->At(aIndex)->FieldValue()); |
|
2675 if (tempPtr.Length() > 0) |
|
2676 { |
|
2677 bookmarkURL = tempPtr.AllocL(); |
|
2678 CleanupStack::PushL(bookmarkURL); |
|
2679 foundURL =ETrue; |
|
2680 } |
|
2681 } |
|
2682 parmsChecked++; |
|
2683 } |
|
2684 // Advance to next field if not at the end of the array |
|
2685 if (aIndex <iParsedFieldArray->Count()) |
|
2686 aIndex++; |
|
2687 } |
|
2688 // If we've only looked at 2 Parms and have both a Name AND URL |
|
2689 // it's a well-formed bookmark so add to it to our List |
|
2690 if (foundName && foundURL && parmsChecked ==2) |
|
2691 { |
|
2692 CWappBookmark* newBookmark = CWappBookmark::NewLC(); |
|
2693 newBookmark->SetNameL(*bookmarkName); |
|
2694 newBookmark->SetUrlL(*bookmarkURL); |
|
2695 iBookmarkList->AppendL(newBookmark); |
|
2696 CleanupStack::Pop(); // release newBookmark |
|
2697 } |
|
2698 if(bookmarkName) CleanupStack::PopAndDestroy(); |
|
2699 if(bookmarkURL) CleanupStack::PopAndDestroy(); |
|
2700 } |
|
2701 |
|
2702 // |
|
2703 // ValidateCharacteristicsL() - Validates the data extracted by PreProcessL. |
|
2704 // |
|
2705 // Following are legitimate messages |
|
2706 // - entirely bookmarks |
|
2707 // - 1+ bearers with any no of other characteristics |
|
2708 // - Non-Null URL and Non Null name of existing settings records |
|
2709 // |
|
2710 // Any other combinations are invalid i.e. |
|
2711 // |
|
2712 // Bookmarks with ID/URL/NAME & NO Bearer |
|
2713 // |
|
2714 void CMsvBIOWapAccessParser::ValidateCharacteristicsL() |
|
2715 { |
|
2716 |
|
2717 // Bookmarks message - bookmarks & no bearers, should be no URL, ID or Settings Name |
|
2718 if ((iBookmarkList->Count() >0) && |
|
2719 !(iGsmCsdData || iGsmSmsData || iGprsData) && |
|
2720 (iURLData || iNameData || iIdData)) |
|
2721 User::Leave(KWappErrBadMessage); |
|
2722 |
|
2723 // start page update message - URL+NAME but no Bearers, no bookmarks |
|
2724 if (iURLData && iNameData && |
|
2725 !(iGsmCsdData || iGsmSmsData || iGprsData) && |
|
2726 (iBookmarkList->Count()==0) && |
|
2727 ((iUrl.Length()==0) || (iWAPSettingsName.Length()==0))) |
|
2728 User::Leave(KWappErrBadMessage); |
|
2729 |
|
2730 if ((iGsmCsdData || iGsmSmsData || iGprsData) && |
|
2731 (iWAPSettingsName.Length()==0)) // Need a name for CommDb - default |
|
2732 User::Leave(KWappErrBadMessage); // should have been given if nothing in message |
|
2733 } |
|
2734 |
|
2735 // |
|
2736 // IsCharacteristicName - Returns ETrue if the Name at the index is a genuine |
|
2737 // Characteristic Type and the Value is NULL |
|
2738 // |
|
2739 TBool CMsvBIOWapAccessParser::IsCharacteristicName(TInt anIndex) |
|
2740 { |
|
2741 TPtrC name = iParsedFieldArray->At(anIndex)->FieldName(); |
|
2742 if ( |
|
2743 (name.CompareF(KWappCharAddress) ==0) || // Address |
|
2744 (name.CompareF(KWappCharURL) ==0) || // URL |
|
2745 (name.CompareF(KWappCharMMSURL) ==0) || // MMS URL |
|
2746 (name.CompareF(KWappCharName) ==0) || // NAME |
|
2747 (name.CompareF(KWappCharBookmark) ==0) || // Bookmark |
|
2748 (name.CompareF(KWappCharID) ==0) ) // ID |
|
2749 return ETrue; // Is a characteristic name |
|
2750 else |
|
2751 return EFalse; // Not a characteristic name |
|
2752 } |
|
2753 |
|
2754 // |
|
2755 // SetModemInitStringL() - Sets the modem initialisation string |
|
2756 // |
|
2757 void CMsvBIOWapAccessParser::SetModemInitStringL() // Sets the modem initialisation string |
|
2758 { |
|
2759 delete iModemInitString; |
|
2760 iModemInitString =NULL; |
|
2761 iModemInitString=KDummyModemInitStr().AllocL(); |
|
2762 } |
|
2763 |
|
2764 |
|
2765 void CMsvBIOWapAccessParser::DeleteCommDatTableEntryL(TMDBElementId aElementName, const TDesC& aCsdNameStr) |
|
2766 { |
|
2767 switch (aElementName) |
|
2768 { |
|
2769 case KCDTIdWAPIPBearerRecord: |
|
2770 { |
|
2771 CCDWAPIPBearerRecord *wapIPRecord = static_cast<CCDWAPIPBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPIPBearerRecord)); |
|
2772 CleanupStack::PushL(wapIPRecord); |
|
2773 wapIPRecord->iWAPAccessPointId = iWapAccessPtID; |
|
2774 |
|
2775 if(wapIPRecord->FindL(*iDBSession)) |
|
2776 { |
|
2777 TUint32 accessId = wapIPRecord->iWAPIAP; |
|
2778 if ( !((iGsmCsdData && iGsmCsdWapIpTable->iIapId == accessId) || |
|
2779 (iGprsData && iGprsWapIpTable->iIapId == accessId))) |
|
2780 { |
|
2781 wapIPRecord->DeleteL(*iDBSession); |
|
2782 } |
|
2783 } |
|
2784 CleanupStack::PopAndDestroy(wapIPRecord); |
|
2785 } |
|
2786 break; |
|
2787 case KCDTIdWAPSMSBearerRecord: |
|
2788 { |
|
2789 CCDWAPSMSBearerRecord *smsRecord = static_cast<CCDWAPSMSBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPSMSBearerRecord)); |
|
2790 CleanupStack::PushL(smsRecord); |
|
2791 smsRecord->iWAPAccessPointId = iWapAccessPtID; |
|
2792 if(smsRecord->FindL(*iDBSession)) |
|
2793 { |
|
2794 smsRecord->DeleteL(*iDBSession); |
|
2795 } |
|
2796 CleanupStack::PopAndDestroy(smsRecord); |
|
2797 } |
|
2798 break; |
|
2799 case KCDTIdIAPRecord: |
|
2800 { |
|
2801 CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); |
|
2802 CleanupStack::PushL(iapRecord); |
|
2803 iapRecord->iRecordName.SetMaxLengthL(aCsdNameStr.Length()); |
|
2804 iapRecord->iRecordName = aCsdNameStr; |
|
2805 if(iapRecord->FindL(*iDBSession)) |
|
2806 { |
|
2807 iapRecord->DeleteL(*iDBSession); |
|
2808 } |
|
2809 CleanupStack::PopAndDestroy(iapRecord); |
|
2810 } |
|
2811 break; |
|
2812 case KCDTIdDialOutISPRecord: |
|
2813 { |
|
2814 CCDDialOutISPRecord *dialOutISPRecord = static_cast<CCDDialOutISPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdDialOutISPRecord)); |
|
2815 CleanupStack::PushL(dialOutISPRecord); |
|
2816 dialOutISPRecord->iRecordName.SetMaxLengthL(aCsdNameStr.Length()); |
|
2817 dialOutISPRecord->iRecordName = aCsdNameStr; |
|
2818 if(dialOutISPRecord->FindL(*iDBSession)) |
|
2819 { |
|
2820 dialOutISPRecord->DeleteL(*iDBSession); |
|
2821 } |
|
2822 CleanupStack::PopAndDestroy(dialOutISPRecord); |
|
2823 } |
|
2824 break; |
|
2825 case KCDTIdOutgoingGprsRecord: |
|
2826 { |
|
2827 CCDOutgoingGprsRecord *gprsRecord = static_cast<CCDOutgoingGprsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord)); |
|
2828 CleanupStack::PushL(gprsRecord); |
|
2829 gprsRecord->iRecordName.SetMaxLengthL(aCsdNameStr.Length()); |
|
2830 gprsRecord->iRecordName = aCsdNameStr; |
|
2831 if(gprsRecord->FindL(*iDBSession)) |
|
2832 { |
|
2833 gprsRecord->DeleteL(*iDBSession); |
|
2834 } |
|
2835 CleanupStack::PopAndDestroy(gprsRecord); |
|
2836 } |
|
2837 break; |
|
2838 } |
|
2839 } |
|
2840 |
|
2841 void CMsvBIOWapAccessParser::WriteDataToDBL() |
|
2842 { |
|
2843 // Should have a table for at least one bearer!! |
|
2844 __ASSERT_DEBUG (iWapSmsTable != NULL || iWapGprsTable != NULL || (iGsmCsdWapIpTable != NULL && iWapIpISPTable !=NULL), |
|
2845 Panic(EWappNullPointer)); |
|
2846 |
|
2847 if (iWAPSettingsName.Length()==0) |
|
2848 { |
|
2849 iWAPSettingsName.Set(KWapDefaultSettingsName); |
|
2850 } |
|
2851 |
|
2852 TBuf<KMaxNameBufferLength> csdNameStr; |
|
2853 csdNameStr.Copy(iWAPSettingsName); |
|
2854 csdNameStr.Append(KGsmCsdSuffix); |
|
2855 if (iGsmCsdData) |
|
2856 { |
|
2857 iCurrentBearerType = EWappGsmCsdBearer; // Set the bearer type indicator for use in next functions |
|
2858 |
|
2859 WriteToCommDatDialOutISPTableL(csdNameStr); |
|
2860 SetWapIspEntryIdL(csdNameStr); // Sets iWapIspID |
|
2861 |
|
2862 WriteToCommsDatIAPTableL(csdNameStr); |
|
2863 SetWapIapEntryIdL(csdNameStr, *iGsmCsdWapIpTable); // Sets iWapIapID |
|
2864 } |
|
2865 else |
|
2866 { |
|
2867 DeleteCommDatTableEntryL(KCDTIdDialOutISPRecord,csdNameStr); |
|
2868 DeleteCommDatTableEntryL(KCDTIdIAPRecord,csdNameStr); |
|
2869 } |
|
2870 |
|
2871 TBuf<KMaxNameBufferLength> gprsNameStr; |
|
2872 gprsNameStr.Copy(iWAPSettingsName); |
|
2873 gprsNameStr.Append(KGprsSuffix); |
|
2874 if(iGprsData) |
|
2875 { |
|
2876 iCurrentBearerType = EWappGprsBearer; |
|
2877 WriteToCommDatGprsTableL(gprsNameStr); |
|
2878 SetWapIspEntryIdL(gprsNameStr); // Sets iWapIspID |
|
2879 WriteToCommsDatIAPTableL(gprsNameStr); |
|
2880 |
|
2881 SetWapIapEntryIdL(gprsNameStr, *iGprsWapIpTable); // Sets iWapIapID |
|
2882 } |
|
2883 else |
|
2884 { |
|
2885 DeleteCommDatTableEntryL(KCDTIdOutgoingGprsRecord,gprsNameStr); |
|
2886 DeleteCommDatTableEntryL(KCDTIdIAPRecord,gprsNameStr); |
|
2887 } |
|
2888 |
|
2889 WriteToCommDatWapAccessPointTableL(iWAPSettingsName); |
|
2890 |
|
2891 SetWapAPEntryIdL(); |
|
2892 |
|
2893 |
|
2894 if (iGsmCsdData) |
|
2895 { |
|
2896 // Set the flag so that correct mapping object is used to set the data in the WAP IP Bearer table |
|
2897 iCurrentBearerType = EWappGsmCsdBearer; |
|
2898 WriteToCommDatWapIpBearerTableL(); |
|
2899 } |
|
2900 else |
|
2901 { |
|
2902 DeleteCommDatTableEntryL(KCDTIdWAPIPBearerRecord,csdNameStr); |
|
2903 } |
|
2904 |
|
2905 |
|
2906 if ((iGprsData)) |
|
2907 { |
|
2908 // Set the flag so that correct mapping object is used to set the data in the WAP IP Bearer table |
|
2909 iCurrentBearerType = EWappGprsBearer; |
|
2910 WriteToCommDatWapIpBearerTableL(); |
|
2911 } |
|
2912 else |
|
2913 { |
|
2914 DeleteCommDatTableEntryL(KCDTIdWAPIPBearerRecord,gprsNameStr); |
|
2915 } |
|
2916 |
|
2917 |
|
2918 if (iGsmSmsData) |
|
2919 { |
|
2920 WriteToCommDatWapSmsBearerTableL(); |
|
2921 } |
|
2922 else |
|
2923 { |
|
2924 DeleteCommDatTableEntryL(KCDTIdWAPSMSBearerRecord,iWAPSettingsName); |
|
2925 } |
|
2926 |
|
2927 |
|
2928 |
|
2929 |
|
2930 // if ((iGsmCsdData) && iModemInitString) // Only if CSD and has string set (ie ISDN) |
|
2931 // CreateTableL(TPtrC(MODEM), iWAPSettingsName); //TODO Not yet implemented |
|
2932 } |
|
2933 |
|
2934 // End of function CMsvBIOWapAccessParser::WriteDataToDBL() |
|
2935 |
|
2936 |
|
2937 void CMsvBIOWapAccessParser::WriteToCommsDatIAPTableL(const TDesC& aRecName) |
|
2938 { |
|
2939 CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); |
|
2940 CleanupStack::PushL(iapRecord); |
|
2941 iapRecord->iRecordName.SetMaxLengthL(aRecName.Length()); |
|
2942 iapRecord->iRecordName = aRecName; |
|
2943 |
|
2944 TBool newRecord = EFalse; |
|
2945 if(!iapRecord->FindL(*iDBSession)) |
|
2946 { |
|
2947 iapRecord->SetRecordId(KCDNewRecordRequest); |
|
2948 newRecord = ETrue; |
|
2949 } |
|
2950 |
|
2951 switch (iCurrentBearerType) |
|
2952 { |
|
2953 case EWappGsmCsdBearer: |
|
2954 { |
|
2955 iapRecord->iService = iWapIpISPTable->iISPCommDbRecordId; |
|
2956 iapRecord->iServiceType.SetMaxLengthL(((TPtrC)KCDTypeNameDialOutISP).Length()); |
|
2957 iapRecord->iServiceType = (TPtrC)KCDTypeNameDialOutISP; |
|
2958 |
|
2959 //there are 7 fields in IAP table which cannot have null values, and so when creating an IAP record we were only filling in one of the fields which meant we were submitting a record with lots of null values which can't be handled. |
|
2960 iapRecord->iBearer = (TUint32)2; |
|
2961 |
|
2962 iapRecord->iBearerType.SetMaxLengthL(((TPtrC)KCDTypeNameModemBearer).Length()); |
|
2963 iapRecord->iBearerType = (TPtrC)KCDTypeNameModemBearer; |
|
2964 iapRecord->iNetwork = (TUint32)1; |
|
2965 iapRecord->iNetworkWeighting = (TUint32)0; |
|
2966 iapRecord->iLocation = (TUint32)4; |
|
2967 } |
|
2968 break; |
|
2969 case EWappGprsBearer: |
|
2970 { |
|
2971 iapRecord->iService = iWapGprsTable->iGprsCommDbRecordId; |
|
2972 iapRecord->iServiceType.SetMaxLengthL(((TPtrC)KCDTypeNameDialOutISP).Length()); |
|
2973 iapRecord->iServiceType = (TPtrC)KCDTypeNameOutgoingWCDMA; |
|
2974 |
|
2975 //there are 7 fields in IAP table which cannot have null values, and so when creating an IAP record we were only filling in one of the fields which meant we were submitting a record with lots of null values which can't be handled. |
|
2976 iapRecord->iBearer = (TUint32)2; |
|
2977 iapRecord->iBearerType.SetMaxLengthL(((TPtrC)KCDTypeNameModemBearer).Length()); |
|
2978 iapRecord->iBearerType = (TPtrC)KCDTypeNameModemBearer; |
|
2979 iapRecord->iNetwork = (TUint32)1; |
|
2980 iapRecord->iNetworkWeighting = (TUint32)0; |
|
2981 iapRecord->iLocation = (TUint32)4; |
|
2982 } |
|
2983 break; |
|
2984 default: |
|
2985 break; |
|
2986 } |
|
2987 |
|
2988 if(newRecord) |
|
2989 { |
|
2990 iapRecord->StoreL(*iDBSession); |
|
2991 } |
|
2992 else |
|
2993 { |
|
2994 iapRecord->ModifyL(*iDBSession); |
|
2995 } |
|
2996 |
|
2997 CleanupStack::PopAndDestroy(iapRecord); |
|
2998 } |
|
2999 |
|
3000 void CMsvBIOWapAccessParser::WriteToCommDatWapSmsBearerTableL() |
|
3001 { |
|
3002 CCDWAPSMSBearerRecord *wapSMSBearerRecord = static_cast<CCDWAPSMSBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPSMSBearerRecord)); |
|
3003 CleanupStack::PushL(wapSMSBearerRecord); |
|
3004 //Search based on WAPAccessPointId |
|
3005 wapSMSBearerRecord->iWAPAccessPointId = iWapAccessPtID; |
|
3006 |
|
3007 TBool newRecord = EFalse; |
|
3008 if(!wapSMSBearerRecord->FindL(*iDBSession)) |
|
3009 { |
|
3010 wapSMSBearerRecord->SetRecordId(KCDNewRecordRequest); |
|
3011 newRecord = ETrue; |
|
3012 } |
|
3013 |
|
3014 wapSMSBearerRecord->iWAPGatewayAddress.SetMaxLengthL(iWapSmsTable->iGatewayAddr.Length()); |
|
3015 wapSMSBearerRecord->iWAPGatewayAddress = iWapSmsTable->iGatewayAddr; |
|
3016 |
|
3017 wapSMSBearerRecord->iWAPServiceCentreAddress.SetMaxLengthL(iWapSmsTable->iWapServiceAddr.Length()); |
|
3018 wapSMSBearerRecord->iWAPServiceCentreAddress = iWapSmsTable->iWapServiceAddr; |
|
3019 |
|
3020 wapSMSBearerRecord->iWAPWSPOption = GetWSPType(iWapSmsTable->iPort); |
|
3021 wapSMSBearerRecord->iWAPSecurity = UseSecurity(iWapSmsTable->iPort); |
|
3022 |
|
3023 if(newRecord) |
|
3024 { |
|
3025 wapSMSBearerRecord->StoreL(*iDBSession); |
|
3026 } |
|
3027 else |
|
3028 { |
|
3029 wapSMSBearerRecord->ModifyL(*iDBSession); |
|
3030 } |
|
3031 |
|
3032 CleanupStack::PopAndDestroy(wapSMSBearerRecord); |
|
3033 } |
|
3034 |
|
3035 void CMsvBIOWapAccessParser::WriteToCommDatWapIpBearerTableL() |
|
3036 { |
|
3037 CCDWAPIPBearerRecord *wapIPBearerRecord = static_cast<CCDWAPIPBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPIPBearerRecord)); |
|
3038 CleanupStack::PushL(wapIPBearerRecord); |
|
3039 //Search based on WAPAccessPointId |
|
3040 wapIPBearerRecord->iWAPAccessPointId = iWapAccessPtID; |
|
3041 |
|
3042 TBool newRecord = EFalse; |
|
3043 if(!wapIPBearerRecord->FindL(*iDBSession)) |
|
3044 { |
|
3045 wapIPBearerRecord->SetRecordId(KCDNewRecordRequest); |
|
3046 newRecord = ETrue; |
|
3047 } |
|
3048 |
|
3049 CWapIpBearerData* wapIpTableData = NULL; |
|
3050 switch (iCurrentBearerType) |
|
3051 { |
|
3052 case EWappGsmCsdBearer: |
|
3053 { |
|
3054 wapIpTableData = iGsmCsdWapIpTable; |
|
3055 } |
|
3056 break; |
|
3057 case EWappGprsBearer: |
|
3058 { |
|
3059 wapIpTableData = iGprsWapIpTable; |
|
3060 } |
|
3061 break; |
|
3062 default: |
|
3063 User::Leave(KWappErrUnexpectedValue); |
|
3064 } |
|
3065 __ASSERT_DEBUG(wapIpTableData, Panic(KWappErrNullValue)); |
|
3066 |
|
3067 wapIPBearerRecord->iWAPAccessPointId = iWapAccessPtID; |
|
3068 wapIPBearerRecord->iWAPIAP = wapIpTableData->iIapId; // Get from SetWapEntryIdsL |
|
3069 |
|
3070 wapIPBearerRecord->iWAPGatewayAddress.SetMaxLengthL((wapIpTableData->iGatewayAddr->Addr()).Length()); |
|
3071 wapIPBearerRecord->iWAPGatewayAddress = wapIpTableData->iGatewayAddr->Addr(); |
|
3072 |
|
3073 wapIPBearerRecord->iWAPWSPOption = GetWSPType(wapIpTableData->iPort); |
|
3074 wapIPBearerRecord->iWAPSecurity = UseSecurity(wapIpTableData->iPort); |
|
3075 |
|
3076 TLex lex = wapIpTableData->iPort; |
|
3077 TInt port = 0; |
|
3078 User::LeaveIfError(lex.Val(port)); |
|
3079 wapIPBearerRecord->iWAPProxyPort = port; |
|
3080 |
|
3081 wapIPBearerRecord->iWAPProxyLoginName.SetMaxLengthL(wapIpTableData->iProxyAuthName.Length()); |
|
3082 wapIPBearerRecord->iWAPProxyLoginName = wapIpTableData->iProxyAuthName; |
|
3083 |
|
3084 wapIPBearerRecord->iWAPProxyLoginPass.SetMaxLengthL(wapIpTableData->iProxyAuthSecret.Length()); |
|
3085 wapIPBearerRecord->iWAPProxyLoginPass = wapIpTableData->iProxyAuthSecret; |
|
3086 |
|
3087 if(newRecord) |
|
3088 { |
|
3089 wapIPBearerRecord->StoreL(*iDBSession); |
|
3090 } |
|
3091 else |
|
3092 { |
|
3093 wapIPBearerRecord->ModifyL(*iDBSession); |
|
3094 } |
|
3095 |
|
3096 CleanupStack::PopAndDestroy(wapIPBearerRecord); |
|
3097 } |
|
3098 |
|
3099 void CMsvBIOWapAccessParser::WriteToCommDatWapAccessPointTableL(const TDesC& aRecName) |
|
3100 { |
|
3101 CCDWAPAccessPointRecord *wapAPRecord = static_cast<CCDWAPAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPAccessPointRecord)); |
|
3102 CleanupStack::PushL(wapAPRecord); |
|
3103 wapAPRecord->iRecordName.SetMaxLengthL(aRecName.Length()); |
|
3104 wapAPRecord->iRecordName = aRecName; |
|
3105 TBool newRecord = EFalse; |
|
3106 if(!wapAPRecord->FindL(*iDBSession)) |
|
3107 { |
|
3108 wapAPRecord->SetRecordId(KCDNewRecordRequest); |
|
3109 newRecord = ETrue; |
|
3110 } |
|
3111 |
|
3112 if (iUrl.Length() != 0) |
|
3113 { |
|
3114 wapAPRecord->iWAPStartPage.SetMaxLengthL(iUrl.Length()); |
|
3115 wapAPRecord->iWAPStartPage = iUrl; |
|
3116 } |
|
3117 |
|
3118 if ((iGsmCsdData) || (iGprsData)) |
|
3119 wapAPRecord->iWAPCurrentBearer = TPtrC(WAP_IP_BEARER); |
|
3120 else if (iGsmSmsData) |
|
3121 wapAPRecord->iWAPCurrentBearer = TPtrC(WAP_SMS_BEARER); |
|
3122 else |
|
3123 User::Leave(KWappErrUnexpectedValue); |
|
3124 |
|
3125 if(newRecord) |
|
3126 { |
|
3127 wapAPRecord->StoreL(*iDBSession); |
|
3128 } |
|
3129 else |
|
3130 { |
|
3131 wapAPRecord->ModifyL(*iDBSession); |
|
3132 } |
|
3133 |
|
3134 CleanupStack::PopAndDestroy(wapAPRecord); |
|
3135 } |
|
3136 |
|
3137 void CMsvBIOWapAccessParser::WriteToCommDatGprsTableL(const TDesC& aRecName) |
|
3138 { |
|
3139 CCDOutgoingGprsRecord *gprsRecord = static_cast<CCDOutgoingGprsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord)); |
|
3140 CleanupStack::PushL(gprsRecord); |
|
3141 gprsRecord->iRecordName.SetMaxLengthL(aRecName.Length()); |
|
3142 gprsRecord->iRecordName = aRecName; |
|
3143 |
|
3144 TBool newRecord = EFalse; |
|
3145 if(!gprsRecord->FindL(*iDBSession)) |
|
3146 { |
|
3147 gprsRecord->SetRecordId(KCDNewRecordRequest); |
|
3148 newRecord = ETrue; |
|
3149 } |
|
3150 |
|
3151 gprsRecord->iGPRSAPN.SetMaxLengthL(iWapGprsTable->iAccessPointName.Length()); |
|
3152 gprsRecord->iGPRSAPN = iWapGprsTable->iAccessPointName; |
|
3153 |
|
3154 gprsRecord->iGPRSPDPType = iWapGprsTable->iPDPType; |
|
3155 |
|
3156 gprsRecord->iGPRSPDPAddress.SetMaxLengthL(iWapGprsTable->iPDPAddress->Des().Length()); |
|
3157 gprsRecord->iGPRSPDPAddress = iWapGprsTable->iPDPAddress->Des(); |
|
3158 |
|
3159 gprsRecord->iGPRSIfPromptForAuth = iWapGprsTable->iIFPromptForAuth; |
|
3160 |
|
3161 gprsRecord->iGPRSIfAuthName.SetMaxLengthL(iWapGprsTable->iLoginName.Length()); |
|
3162 gprsRecord->iGPRSIfAuthName = iWapGprsTable->iLoginName; |
|
3163 |
|
3164 gprsRecord->iGPRSIfAuthPass.SetMaxLengthL(iWapGprsTable->iLoginPass.Length()); |
|
3165 gprsRecord->iGPRSIfAuthPass = iWapGprsTable->iLoginPass; |
|
3166 |
|
3167 gprsRecord->iGPRSIPGateway.SetMaxLengthL(iWapGprsTable->iGatewayAddr->Addr().Length()); |
|
3168 gprsRecord->iGPRSIPGateway = iWapGprsTable->iGatewayAddr->Addr(); |
|
3169 |
|
3170 gprsRecord->iGPRSIPAddrFromServer = iWapGprsTable->iIpAddrFromServer; |
|
3171 |
|
3172 gprsRecord->iGPRSIPDNSAddrFromServer = iWapGprsTable->iIPDnsAddrFromServer; |
|
3173 gprsRecord->iGPRSDisablePlainTextAuth = iWapGprsTable->iPlainTextAuthDisabled; |
|
3174 |
|
3175 if(newRecord) |
|
3176 { |
|
3177 gprsRecord->StoreL(*iDBSession); |
|
3178 } |
|
3179 else |
|
3180 { |
|
3181 gprsRecord->ModifyL(*iDBSession); |
|
3182 } |
|
3183 |
|
3184 CleanupStack::PopAndDestroy(gprsRecord); |
|
3185 } |
|
3186 |
|
3187 void CMsvBIOWapAccessParser::WriteToCommDatDialOutISPTableL(const TDesC& aRecName) |
|
3188 { |
|
3189 CCDDialOutISPRecord *dialoutRecord = static_cast<CCDDialOutISPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdDialOutISPRecord)); |
|
3190 CleanupStack::PushL(dialoutRecord); |
|
3191 dialoutRecord->iRecordName.SetMaxLengthL(aRecName.Length()); |
|
3192 dialoutRecord->iRecordName = aRecName; |
|
3193 |
|
3194 TBool newRecord = EFalse; |
|
3195 if(!dialoutRecord->FindL(*iDBSession)) |
|
3196 { |
|
3197 dialoutRecord->SetRecordId(KCDNewRecordRequest); |
|
3198 newRecord = ETrue; |
|
3199 |
|
3200 iWapIpISPTable->iISPCommDbRecordId = dialoutRecord->iRecordTag.RecordId(); |
|
3201 } |
|
3202 |
|
3203 //It's time to write values |
|
3204 (dialoutRecord->iDescription).SetMaxLengthL(iWapIpISPTable->iISPDescription.Length()); |
|
3205 dialoutRecord->iDescription = iWapIpISPTable->iISPDescription; |
|
3206 |
|
3207 dialoutRecord->iType = iWapIpISPTable->iISPType; |
|
3208 |
|
3209 dialoutRecord->iDefaultTelNum.SetMaxLengthL(iWapIpISPTable->iDefaultPhoneNum.Length()); |
|
3210 dialoutRecord->iDefaultTelNum = iWapIpISPTable->iDefaultPhoneNum; |
|
3211 |
|
3212 dialoutRecord->iDialResolution = iWapIpISPTable->iDialResolution; //Mandatory, ETrue default |
|
3213 |
|
3214 dialoutRecord->iUseLoginScript = iWapIpISPTable->iUseScript; //Mandatory, EFalse by default |
|
3215 |
|
3216 if (iWapIpISPTable->iLoginScript.Length() != 0) |
|
3217 { |
|
3218 (dialoutRecord->iLoginScript).SetMaxLengthL(iWapIpISPTable->iLoginScript.Length()); |
|
3219 dialoutRecord->iLoginScript = iWapIpISPTable->iLoginScript; |
|
3220 } |
|
3221 dialoutRecord->iPromptForLogin = iWapIpISPTable->iPromptForLoginDetails; // Mandatory, ETrue by default |
|
3222 dialoutRecord->iLoginName.SetMaxLengthL((iWapIpISPTable->iLoginName).Length()); |
|
3223 dialoutRecord->iLoginName = iWapIpISPTable->iLoginName; |
|
3224 |
|
3225 (dialoutRecord->iLoginPass).SetMaxLengthL((iWapIpISPTable->iLoginPass).Length()); |
|
3226 dialoutRecord->iLoginPass = iWapIpISPTable->iLoginPass; |
|
3227 |
|
3228 dialoutRecord->iDisplayPct = iWapIpISPTable->iDisplayPCT; |
|
3229 |
|
3230 (dialoutRecord->iIfParams).SetMaxLengthL((iWapIpISPTable->iIFParams).Length()); |
|
3231 dialoutRecord->iIfParams = iWapIpISPTable->iIFParams; |
|
3232 |
|
3233 (dialoutRecord->iIfNetworks).SetMaxLengthL((iWapIpISPTable->iIFNetworks->Des()).Length()); |
|
3234 dialoutRecord->iIfNetworks = iWapIpISPTable->iIFNetworks->Des(); // Set to "IP" |
|
3235 |
|
3236 dialoutRecord->iIfPromptForAuth = iWapIpISPTable->iPromptForLoginDetails; //Mandatory, default is ETrue |
|
3237 |
|
3238 (dialoutRecord->iIfAuthName).SetMaxLengthL((iWapIpISPTable->iLoginName).Length()); |
|
3239 dialoutRecord->iIfAuthName = iWapIpISPTable->iLoginName; |
|
3240 |
|
3241 (dialoutRecord->iIfAuthPass).SetMaxLengthL((iWapIpISPTable->iLoginPass).Length()); |
|
3242 dialoutRecord->iIfAuthPass = iWapIpISPTable->iLoginPass; |
|
3243 |
|
3244 dialoutRecord->iIfAuthRetries = iWapIpISPTable->iNumAuthAttempts; |
|
3245 |
|
3246 dialoutRecord->iIfCallbackEnabled = iWapIpISPTable->iCallBackEnabled; |
|
3247 if (iWapIpISPTable->iCallBackEnabled) |
|
3248 { |
|
3249 dialoutRecord->iIfCallbackType = iWapIpISPTable->iCallBackType; |
|
3250 TPtr8 tempPtr(0,0); |
|
3251 tempPtr.Copy(iWapIpISPTable->iCallBackInfo); |
|
3252 |
|
3253 dialoutRecord->iIfCallbackInfo.SetMaxLengthL(tempPtr.Length()); |
|
3254 dialoutRecord->iIfCallbackInfo = tempPtr; |
|
3255 dialoutRecord->iCallbackTimeout = 10000; |
|
3256 } |
|
3257 |
|
3258 dialoutRecord->iIpAddrFromServer = iWapIpISPTable->iAddrFromServer; //Mandatory set to True |
|
3259 |
|
3260 (dialoutRecord->iIpAddr).SetMaxLengthL((iWapIpISPTable->iInOutAddress->Addr()).Length()); |
|
3261 dialoutRecord->iIpNetMask = iWapIpISPTable->iNetmask->Addr(); |
|
3262 |
|
3263 (dialoutRecord->iIpGateway).SetMaxLengthL((iWapIpISPTable->iGateway->Addr()).Length()); |
|
3264 dialoutRecord->iIpGateway = iWapIpISPTable->iGateway->Addr(); |
|
3265 |
|
3266 dialoutRecord->iIpDnsAddrFromServer = iWapIpISPTable->iDNSFromServer; |
|
3267 // Following will write NULL strings to database, clearing any previous settings. |
|
3268 |
|
3269 (dialoutRecord->iIpNameServer1).SetMaxLengthL((iWapIpISPTable->iDNS1->Addr()).Length()); |
|
3270 dialoutRecord->iIpNameServer1 = iWapIpISPTable->iDNS1->Addr(); |
|
3271 |
|
3272 (dialoutRecord->iIpNameServer2).SetMaxLengthL((iWapIpISPTable->iDNS2->Addr()).Length()); |
|
3273 dialoutRecord->iIpNameServer2 = iWapIpISPTable->iDNS2->Addr(); |
|
3274 |
|
3275 dialoutRecord->iEnableIpHeaderComp = iWapIpISPTable->iHeaderCompressionEnabled; |
|
3276 // Don't bother with LCP extensions - leave as null field |
|
3277 dialoutRecord->iDisablePlainTextAuth = iWapIpISPTable->iPlainTextAuthDisabled; |
|
3278 dialoutRecord->iEnableSwComp = iWapIpISPTable->iSwCompressionEnabled; |
|
3279 dialoutRecord->iBearerSpeed = iWapIpISPTable->iCallSpeed; |
|
3280 dialoutRecord->iBearerProtocol = iWapIpISPTable->iCallDataProtocol; |
|
3281 |
|
3282 if(newRecord) |
|
3283 { |
|
3284 dialoutRecord->StoreL(*iDBSession); |
|
3285 } |
|
3286 else |
|
3287 { |
|
3288 dialoutRecord->ModifyL(*iDBSession); |
|
3289 } |
|
3290 |
|
3291 CleanupStack::PopAndDestroy(dialoutRecord); |
|
3292 } |
|
3293 |
|
3294 |
|
3295 // |
|
3296 // SetWapIspEntryIdL - The iCurrentBearerType variable MUST be correctly set before this |
|
3297 // function is called. Searches the appropriate Service table - DIAL_OUT_ISP |
|
3298 // or OUTGOING_WCDMA - for records named as aEntryName (which should be unique!) |
|
3299 // When it finds the record, it uses the record ID to set the class member iWapIspID. |
|
3300 // |
|
3301 void CMsvBIOWapAccessParser::SetWapIspEntryIdL(const TDesC& aEntryName) |
|
3302 { |
|
3303 TUint32 recId = 0; |
|
3304 switch (iCurrentBearerType) |
|
3305 { |
|
3306 case EWappGsmCsdBearer: |
|
3307 { |
|
3308 CCDDialOutISPRecord *dialOutRecord = static_cast<CCDDialOutISPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdDialOutISPRecord)); |
|
3309 CleanupStack::PushL(dialOutRecord); |
|
3310 dialOutRecord->iRecordName.SetMaxLengthL(aEntryName.Length()); |
|
3311 dialOutRecord->iRecordName = aEntryName; |
|
3312 |
|
3313 if (dialOutRecord->FindL(*iDBSession)) |
|
3314 { |
|
3315 recId = dialOutRecord->iRecordTag.RecordId(); |
|
3316 } |
|
3317 else |
|
3318 { |
|
3319 User::Leave(KErrNotFound); |
|
3320 } |
|
3321 CleanupStack::PopAndDestroy(dialOutRecord); |
|
3322 } |
|
3323 break; |
|
3324 case EWappGprsBearer: |
|
3325 { |
|
3326 CCDOutgoingGprsRecord *gprsRecord = static_cast<CCDOutgoingGprsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord)); |
|
3327 CleanupStack::PushL(gprsRecord); |
|
3328 gprsRecord->iRecordName.SetMaxLengthL(aEntryName.Length()); |
|
3329 gprsRecord->iRecordName = aEntryName; |
|
3330 |
|
3331 if (gprsRecord->FindL(*iDBSession)) |
|
3332 { |
|
3333 recId = gprsRecord->iRecordTag.RecordId(); |
|
3334 } |
|
3335 else |
|
3336 { |
|
3337 User::Leave(KErrNotFound); |
|
3338 } |
|
3339 CleanupStack::PopAndDestroy(gprsRecord); |
|
3340 } |
|
3341 break; |
|
3342 default: |
|
3343 User::Leave(KWappErrUnexpectedValue); |
|
3344 } |
|
3345 |
|
3346 switch (iCurrentBearerType) |
|
3347 { |
|
3348 case EWappGsmCsdBearer: |
|
3349 iWapIpISPTable->iISPCommDbRecordId = recId; |
|
3350 break; |
|
3351 case EWappGprsBearer: |
|
3352 iWapGprsTable->iGprsCommDbRecordId = recId; |
|
3353 break; |
|
3354 default: |
|
3355 User::Leave(KWappErrUnexpectedValue); |
|
3356 break; |
|
3357 } |
|
3358 } |
|
3359 |
|
3360 |
|
3361 // |
|
3362 // SetWapIapEntryIdL - Searches the IAP database for records of the same name |
|
3363 // as aEntryName (which should be unique!). When it finds the |
|
3364 // record, it uses the record ID to set the class member iWapIapID. |
|
3365 // |
|
3366 void CMsvBIOWapAccessParser::SetWapIapEntryIdL(const TDesC& aEntryName, CWapIpBearerData& aWapIpTable) |
|
3367 { |
|
3368 CCDIAPRecord *iAPRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); |
|
3369 CleanupStack::PushL(iAPRecord); |
|
3370 iAPRecord->iRecordName.SetMaxLengthL(aEntryName.Length()); |
|
3371 iAPRecord->iRecordName = aEntryName; |
|
3372 |
|
3373 if (iAPRecord->FindL(*iDBSession)) |
|
3374 { |
|
3375 aWapIpTable.iIapId = iAPRecord->iRecordTag.RecordId(); |
|
3376 } |
|
3377 else |
|
3378 { |
|
3379 User::Leave(KErrNotFound); |
|
3380 } |
|
3381 CleanupStack::PopAndDestroy(iAPRecord); |
|
3382 } |
|
3383 |
|
3384 // |
|
3385 // SetWapIspEntryIdL - Searches the WAP_ACCESS_POINT table for records of the same name |
|
3386 // as iWapSettingsName (which should be unique!). When it finds the |
|
3387 // record, it uses the record ID to set the class member iWapIspID. |
|
3388 // |
|
3389 void CMsvBIOWapAccessParser::SetWapAPEntryIdL() |
|
3390 { |
|
3391 CCDWAPAccessPointRecord *wapAccessRecord = static_cast<CCDWAPAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPAccessPointRecord)); |
|
3392 CleanupStack::PushL(wapAccessRecord); |
|
3393 wapAccessRecord->iRecordName.SetMaxLengthL(iWAPSettingsName.Length()); |
|
3394 wapAccessRecord->iRecordName = iWAPSettingsName; |
|
3395 |
|
3396 if (wapAccessRecord->FindL(*iDBSession)) |
|
3397 { |
|
3398 iWapAccessPtID = wapAccessRecord->iRecordTag.RecordId(); // set the WAP AP table ID |
|
3399 } |
|
3400 else |
|
3401 { |
|
3402 User::Leave(KErrNotFound); |
|
3403 } |
|
3404 CleanupStack::PopAndDestroy(wapAccessRecord); |
|
3405 } |
|
3406 |
|
3407 |
|
3408 void CMsvBIOWapAccessParser::WriteMMSURLL() |
|
3409 { |
|
3410 |
|
3411 // check that the version of the MMS settings proxy dll is suitable |
|
3412 RImplInfoPtrArray list; |
|
3413 REComSession::ListImplementationsL(KMMSSettingsProxyInterfaceUid, list); |
|
3414 TInt count = list.Count(); |
|
3415 TBool found = EFalse; |
|
3416 // may be more than one implementation, look for the 'right' one |
|
3417 while (!found && count-- > 0) |
|
3418 { |
|
3419 if (list[count]->ImplementationUid() == KMMSSettingsProxyBaseUid && |
|
3420 list[count]->Version() == KMMSSettingsProxyVersionSupported) |
|
3421 { |
|
3422 // Found supported version - stop looking. |
|
3423 found = ETrue; |
|
3424 } |
|
3425 } |
|
3426 list.ResetAndDestroy(); |
|
3427 // if there are no implementations or the version is unsupported, then leave |
|
3428 if (!found) |
|
3429 User::Leave(KErrNotFound); |
|
3430 |
|
3431 CMMSSettingsProxyBase* settings = CMMSSettingsProxyBase::NewL(KMMSSettingsProxyBaseUid); |
|
3432 CleanupStack::PushL(settings); |
|
3433 |
|
3434 TSglQue<TMMSSettingsPair> settingList(_FOFF(TMMSSettingsPair, iLink)); |
|
3435 |
|
3436 // Different MMS implementations require different things. Pass all the things they might |
|
3437 // want and allow the implementation to use those it chooses. |
|
3438 |
|
3439 // The MMS Url |
|
3440 TMMSSettingsPair urlPair; |
|
3441 urlPair.iName.Set(KMMSUrl); |
|
3442 urlPair.iValue = &iMMSUrl; |
|
3443 settingList.AddFirst(urlPair); |
|
3444 |
|
3445 |
|
3446 TBuf<KMaxNameBufferLength> nameStr; |
|
3447 nameStr.Copy(iWAPSettingsName); |
|
3448 if (iGsmCsdData) |
|
3449 { |
|
3450 nameStr.Append(KGsmCsdSuffix); |
|
3451 } |
|
3452 |
|
3453 if(iGprsData) |
|
3454 { |
|
3455 nameStr.Append(KGprsSuffix); |
|
3456 } |
|
3457 |
|
3458 |
|
3459 TUint32 id=0; |
|
3460 |
|
3461 switch (iCurrentBearerType) |
|
3462 { |
|
3463 case EWappGsmCsdBearer: |
|
3464 { |
|
3465 CCDDialOutISPRecord *dialOutISPRecord = static_cast<CCDDialOutISPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdDialOutISPRecord)); |
|
3466 CleanupStack::PushL(dialOutISPRecord); |
|
3467 dialOutISPRecord->iRecordName.SetMaxLengthL(nameStr.Length()); |
|
3468 dialOutISPRecord->iRecordName = nameStr; |
|
3469 if(!dialOutISPRecord->FindL(*iDBSession)) |
|
3470 { |
|
3471 User::Leave(KErrNotFound); |
|
3472 } |
|
3473 id = dialOutISPRecord->iRecordTag.RecordId(); |
|
3474 CleanupStack::PopAndDestroy(dialOutISPRecord); |
|
3475 } |
|
3476 break; |
|
3477 case EWappGprsBearer: |
|
3478 { |
|
3479 CCDOutgoingGprsRecord *gprsRecord = static_cast<CCDOutgoingGprsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord)); |
|
3480 CleanupStack::PushL(gprsRecord); |
|
3481 gprsRecord->iRecordName.SetMaxLengthL(nameStr.Length()); |
|
3482 gprsRecord->iRecordName = nameStr; |
|
3483 |
|
3484 if(!gprsRecord->FindL(*iDBSession)) |
|
3485 { |
|
3486 User::Leave(KErrNotFound); |
|
3487 } |
|
3488 id = gprsRecord->iRecordTag.RecordId(); |
|
3489 CleanupStack::PopAndDestroy(gprsRecord); |
|
3490 } |
|
3491 break; |
|
3492 default: |
|
3493 User::Leave(KWappErrUnexpectedValue); |
|
3494 } |
|
3495 |
|
3496 TMMSSettingsPair commDbRecordId; |
|
3497 commDbRecordId.iName.Set(KCommDbRecordId); |
|
3498 commDbRecordId.iValue = &id; |
|
3499 settingList.AddFirst(commDbRecordId); |
|
3500 |
|
3501 TMMSSettingsPair msvServerEntryPair; |
|
3502 // 24/08/04 |
|
3503 // In messaging API v2, iEntry is no longer a CMsvServerEntry, but rather a CMsvEntry. |
|
3504 // For this reason, the following code has been changed. |
|
3505 // This breaks data compatability. |
|
3506 // CMsvEntry |
|
3507 msvServerEntryPair.iName.Set(KMsvEntry); |
|
3508 msvServerEntryPair.iValue = &iEntry; |
|
3509 settingList.AddFirst(msvServerEntryPair); |
|
3510 |
|
3511 settings->SetMMSValuesL(settingList); |
|
3512 CleanupStack::PopAndDestroy(settings); |
|
3513 } |
|
3514 |
|
3515 |
|
3516 // GetWSPTypeL - Helper function used by IP and SMS functions above. Returns appropriate enum |
|
3517 // |
|
3518 TCommsDbWapWspOption CMsvBIOWapAccessParser::GetWSPType(TDesC& aPortValue) |
|
3519 { |
|
3520 TCommsDbWapWspOption wspType; |
|
3521 |
|
3522 // Is it Connection Orientated link ? |
|
3523 if ( (aPortValue.CompareF(KWappPort9201)==0)|| |
|
3524 (aPortValue.CompareF(KWappPort9203)==0) ) |
|
3525 |
|
3526 wspType=EWapWspOptionConnectionOriented; |
|
3527 |
|
3528 else |
|
3529 if ( (aPortValue.CompareF(KWappPort9200)==0)|| |
|
3530 (aPortValue.CompareF(KWappPort9202)==0) ) |
|
3531 |
|
3532 wspType=EWapWspOptionConnectionless; |
|
3533 else //unknown type - so apply the default |
|
3534 wspType=EWapWspOptionConnectionless; |
|
3535 |
|
3536 return wspType; |
|
3537 } |
|
3538 |
|
3539 TBool CMsvBIOWapAccessParser::UseSecurity(TDesC& aPortValue) |
|
3540 { |
|
3541 TBool useWapSecurity; |
|
3542 // Is it unsecured link? |
|
3543 if ( (aPortValue.CompareF(KWappPort9200)==0)|| |
|
3544 (aPortValue.CompareF(KWappPort9201)==0) ) |
|
3545 useWapSecurity=EFalse; |
|
3546 else |
|
3547 if ( (aPortValue.CompareF(KWappPort9202)==0)|| |
|
3548 (aPortValue.CompareF(KWappPort9203)==0) ) |
|
3549 useWapSecurity=ETrue; |
|
3550 else // unknown Port value - shouldn't happen but use default anyway |
|
3551 useWapSecurity = EFalse; |
|
3552 |
|
3553 return useWapSecurity; |
|
3554 } |
|
3555 |
|
3556 // UpdateStartPageUrlL() - Searchs the WAP table for a match to the name and updates |
|
3557 // the WAP_START_PAGE field with the value in the URL char of the message |
|
3558 // |
|
3559 |
|
3560 void CMsvBIOWapAccessParser::UpdateStartPageUrlL() |
|
3561 { |
|
3562 __ASSERT_DEBUG(iWAPSettingsName.Length() != 0, Panic(EWappEmptyBuffer)); |
|
3563 __ASSERT_DEBUG(iUrl.Length() != 0, Panic(EWappEmptyBuffer)); |
|
3564 |
|
3565 CCDWAPAccessPointRecord *wapAPRecord = static_cast<CCDWAPAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPAccessPointRecord)); |
|
3566 CleanupStack::PushL(wapAPRecord); |
|
3567 wapAPRecord->iRecordName.SetMaxLengthL(iWAPSettingsName.Length()); |
|
3568 wapAPRecord->iRecordName = iWAPSettingsName; |
|
3569 |
|
3570 if(!wapAPRecord->FindL(*iDBSession)) |
|
3571 { |
|
3572 User::Leave(KErrNotFound); |
|
3573 } |
|
3574 wapAPRecord->iWAPStartPage.SetMaxLengthL(iUrl.Length()); |
|
3575 wapAPRecord->iWAPStartPage = iUrl; |
|
3576 wapAPRecord->ModifyL(*iDBSession); |
|
3577 CleanupStack::PopAndDestroy(wapAPRecord); |
|
3578 } |
|
3579 |
|
3580 |
|
3581 // |
|
3582 // IsValidTokenNameL() - Checks that the name field at the position specified is |
|
3583 // a valid Characteristic or Parm name |
|
3584 // |
|
3585 |
|
3586 TInt CMsvBIOWapAccessParser::IsValidTokenNameL(const TInt aArrayIndex) |
|
3587 { |
|
3588 TPtrC name; |
|
3589 |
|
3590 name.Set(iParsedFieldArray->At(aArrayIndex)->FieldName()); |
|
3591 |
|
3592 if ( (name.CompareF(KWappXMLversion) ==0)|| |
|
3593 (name.CompareF(KWappPublicID) ==0)|| |
|
3594 (name.CompareF(KWappCharacterSet) ==0)|| |
|
3595 (name.CompareF(KWappCharAddress) ==0)|| // ADDRESS Characteristic |
|
3596 (name.CompareF(KWappCharURL) ==0)|| // URL Characteristic |
|
3597 (name.CompareF(KWappCharMMSURL) ==0)|| // URL Characteristic |
|
3598 (name.CompareF(KWappCharName) ==0)|| // NAME Characteristic OR ATTRIBUTE |
|
3599 (name.CompareF(KWappCharBookmark) ==0)|| // BOOKMARK Characteristic |
|
3600 (name.CompareF(KWappCharID) ==0)|| // ID Characteristic |
|
3601 (name.CompareF(KWappURL) ==0)|| // URL Parm |
|
3602 (name.CompareF(KWappName) ==0)|| // NAME Parm OR ATTRIBUTE |
|
3603 (name.CompareF(KWappBearer) ==0)|| // BEARER Attribute |
|
3604 (name.CompareF(KWappProxy) ==0)|| // PROXY |
|
3605 (name.CompareF(KWappPort) ==0)|| // PORT |
|
3606 (name.CompareF(KWappProxyType) ==0)|| // PROXY_TYPE - for USSD only |
|
3607 (name.CompareF(KWappProxyAuthName) ==0)|| // PROXY_AUTHNAME |
|
3608 (name.CompareF(KWappProxyAuthSecret) ==0)|| // PROXY_AUTHSECRET |
|
3609 (name.CompareF(KWappProxyLoginType) ==0)|| // PROXY_LOGIN_TYPE |
|
3610 (name.CompareF(KWappSMSCAddress) ==0)|| // SMS_SMSC_ADDRESS |
|
3611 (name.CompareF(KWappUSSDCode) ==0)|| // USSD SERVICE CODE |
|
3612 (name.CompareF(KWappAccessPointName) ==0)|| // ACCESSPOINTNAME |
|
3613 (name.CompareF(KWappCsdDial) ==0)|| // CSD_DIALSTRING |
|
3614 (name.CompareF(KWappPPPAuthType) ==0)|| // PPP_AUTHTYPE |
|
3615 (name.CompareF(KWappPPPAuthName) ==0)|| // PPP_AUTHNAME |
|
3616 (name.CompareF(KWappPPPAuthSecret) ==0)|| // PPP_AUTHSECRET |
|
3617 (name.CompareF(KWappPPPLoginType) ==0)|| // PPP_LOGIN_TYPE |
|
3618 (name.CompareF(KWappCsdCallType) ==0)|| // CSD_CALLTYPE |
|
3619 (name.CompareF(KWappCsdCallSpeed) ==0)|| // CSD_CALLSPEED |
|
3620 (name.CompareF(KWappISP) ==0) ) // ISP_NAME |
|
3621 |
|
3622 |
|
3623 return KErrNone; |
|
3624 else |
|
3625 return KWappErrUnrecognised; |
|
3626 } |
|
3627 |
|
3628 // |
|
3629 // WriteBookmarksToFileL() - Store Bookmarks as an attachment file |
|
3630 // in the .eBM format. If the system runs out of memory while |
|
3631 // the bookmarks are being written to the file, the file will be |
|
3632 // deleted. For example, if 2 bookmarks have already been written |
|
3633 // to the file, and the writing of the third bookmark fails, the |
|
3634 // file will be deleted. Otherwise, a failure of file writing would |
|
3635 // need to be handled differently from memory allocation failure. |
|
3636 // |
|
3637 void CMsvBIOWapAccessParser::WriteBookmarksToFileL() |
|
3638 { |
|
3639 |
|
3640 TInt numberOfItems = iBookmarkList->Count(); |
|
3641 |
|
3642 if (numberOfItems > 0) // Only create a file if there is something |
|
3643 //to save |
|
3644 { |
|
3645 |
|
3646 TFileName filePath; |
|
3647 |
|
3648 |
|
3649 // build the filename |
|
3650 TMsvId entryId = iEntry.Entry().Id(); |
|
3651 filePath.Num(entryId,EHex); |
|
3652 filePath.Append(KEBookmarkExtension); |
|
3653 |
|
3654 // Get the attachment manager and create an empty attachment file |
|
3655 CMsvStore* store = iEntry.EditStoreL(); |
|
3656 CleanupStack::PushL(store); |
|
3657 |
|
3658 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
3659 MMsvAttachmentManagerSync& managerSync = store->AttachmentManagerExtensionsL(); |
|
3660 RemoveAttachmentIfExistL(filePath, manager, managerSync); |
|
3661 CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); |
|
3662 CleanupStack::PushL(attachment); |
|
3663 attachment->SetAttachmentNameL(filePath); |
|
3664 |
|
3665 RFile file; |
|
3666 managerSync.CreateAttachmentL(filePath, file, attachment); |
|
3667 CleanupStack::Pop(attachment); // ownership passed |
|
3668 |
|
3669 CleanupClosePushL(file); |
|
3670 |
|
3671 |
|
3672 #ifdef SYMBIAN_BOOKMARK_DATABASE |
|
3673 // Open the bookmark database ready to add the bookmarks |
|
3674 RBkDatabase bookmarkDb; |
|
3675 bookmarkDb.OpenL(); |
|
3676 CleanupClosePushL(bookmarkDb); |
|
3677 #endif // SYMBIAN_BOOKMARK_DATABASE |
|
3678 |
|
3679 // Stream each bookmark into the file. |
|
3680 // The eBookmark file must contain only 8bit ascii. |
|
3681 // Add a linefeed to the end of each line. |
|
3682 |
|
3683 TInt count = 0; |
|
3684 |
|
3685 while(count < numberOfItems) |
|
3686 { |
|
3687 CWappBookmark& item = *iBookmarkList->At(count); |
|
3688 |
|
3689 // Allocate enough space to hold the full bookmark entry. |
|
3690 |
|
3691 TInt length = item.Name().Length() + |
|
3692 item.Url().Length() + |
|
3693 KEBookmarkConstantChars; |
|
3694 |
|
3695 HBufC8* writeBuf = HBufC8::NewLC(length); |
|
3696 |
|
3697 TPtr8 des = writeBuf->Des(); |
|
3698 |
|
3699 des.Append(KEBookmarkItemBegin); |
|
3700 des.Append(KEBookmarkItemURL); |
|
3701 des.Append(item.Url()); |
|
3702 des.Append(KCRLinefeed); |
|
3703 des.Append(KEBookmarkItemName); |
|
3704 des.Append(item.Name()); |
|
3705 des.Append(KCRLinefeed); |
|
3706 des.Append(KEBookmarkType); |
|
3707 des.Append(KEBookmarkItemEnd); |
|
3708 |
|
3709 User::LeaveIfError(file.Write(des)); |
|
3710 |
|
3711 CleanupStack::PopAndDestroy(); |
|
3712 |
|
3713 #ifdef SYMBIAN_BOOKMARK_DATABASE |
|
3714 // Add the bookmark to the bookmark database |
|
3715 RBkBookmark bookmark = bookmarkDb.CreateBookmarkL(); |
|
3716 CleanupClosePushL(bookmark); |
|
3717 bookmark.SetTitleL(item.Name()); |
|
3718 // Convert Uri to 8-bit |
|
3719 HBufC8* bookmarkUri = HBufC8::NewLC(item.Url().Length()); |
|
3720 bookmarkUri->Des().Copy(item.Url()); |
|
3721 bookmark.SetUriL(*bookmarkUri); |
|
3722 CleanupStack::PopAndDestroy(2, &bookmark); // bookmarkUri, bookmark |
|
3723 #endif // SYMBIAN_BOOKMARK_DATABASE |
|
3724 |
|
3725 count++; |
|
3726 } |
|
3727 |
|
3728 #ifdef SYMBIAN_BOOKMARK_DATABASE |
|
3729 // Commit all the added bookmarks and close bookmark db |
|
3730 bookmarkDb.CommitL(); |
|
3731 CleanupStack::PopAndDestroy(&bookmarkDb); |
|
3732 #endif // SYMBIAN_BOOKMARK_DATABASE |
|
3733 |
|
3734 // File writing has completed, set the size in the attachment |
|
3735 TInt fileSize; |
|
3736 User::LeaveIfError(file.Size(fileSize)); |
|
3737 attachment->SetSize(fileSize); |
|
3738 |
|
3739 // commit the changes |
|
3740 store->CommitL(); |
|
3741 CleanupStack::PopAndDestroy(2, store); // file, store |
|
3742 |
|
3743 } |
|
3744 } |
|
3745 // End of function WriteBookmarksToFileL() |
|
3746 |
|
3747 void CMsvBIOWapAccessParser::RemoveAttachmentIfExistL(const TDesC& aFileName, MMsvAttachmentManager& aManager, MMsvAttachmentManagerSync& aManagerSync) |
|
3748 { |
|
3749 // If an attachment already exists with the same filename then delete |
|
3750 // the existing one so multiple files of the same name dont exist |
|
3751 for( TInt ii=0; ii<aManager.AttachmentCount(); ++ii ) |
|
3752 { |
|
3753 CMsvAttachment* attachmentInfo = aManager.GetAttachmentInfoL(ii); |
|
3754 CleanupStack::PushL(attachmentInfo); |
|
3755 if( attachmentInfo->AttachmentName().CompareF(aFileName) == 0 ) |
|
3756 { |
|
3757 |
|
3758 // We have a match, delete the attachment as we will have |
|
3759 // to add it as new one |
|
3760 aManagerSync.RemoveAttachmentL(ii); |
|
3761 CleanupStack::PopAndDestroy(attachmentInfo); // attachmentInfo |
|
3762 break; |
|
3763 } |
|
3764 CleanupStack::PopAndDestroy(attachmentInfo); |
|
3765 } |
|
3766 } |
|
3767 |
|
3768 void CMsvBIOWapAccessParser::Panic(TInt aPanic) |
|
3769 { |
|
3770 User::Panic(KWappDll, aPanic); |
|
3771 } |
|
3772 |
|
3773 |
|
3774 CWapCharsetConverter* CWapCharsetConverter::NewL(RFs& aFs, TUint aMibEnum) |
|
3775 { |
|
3776 CWapCharsetConverter* self = new (ELeave) CWapCharsetConverter(aFs); |
|
3777 CleanupStack::PushL(self); |
|
3778 self->ConstructL(aMibEnum); |
|
3779 CleanupStack::Pop(self); |
|
3780 return self; |
|
3781 } |
|
3782 |
|
3783 void CWapCharsetConverter::ConstructL(TInt aMibEnum) |
|
3784 { |
|
3785 iConverter = CCnvCharacterSetConverter::NewL(); |
|
3786 iAvailableCharsets = iConverter->CreateArrayOfCharacterSetsAvailableL(iFs); |
|
3787 |
|
3788 if(aMibEnum == 0) |
|
3789 { |
|
3790 iParseable = EFalse; |
|
3791 return; |
|
3792 } |
|
3793 |
|
3794 TInt charset = iConverter->ConvertMibEnumOfCharacterSetToIdentifierL(aMibEnum, iFs); |
|
3795 |
|
3796 if(charset==0) |
|
3797 { |
|
3798 iParseable = EFalse; |
|
3799 return; |
|
3800 } |
|
3801 |
|
3802 CCnvCharacterSetConverter::TAvailability t = iConverter->PrepareToConvertToOrFromL(charset, iFs); |
|
3803 iParseable = (t == CCnvCharacterSetConverter::EAvailable); |
|
3804 } |
|
3805 |
|
3806 void CWapCharsetConverter::ConvertL(const TDesC& aSource, TDes& aSink) |
|
3807 { |
|
3808 if(iParseable) |
|
3809 { |
|
3810 //defect fix for Inc021752 |
|
3811 HBufC8* des = HBufC8::NewLC(aSource.Length()); |
|
3812 des->Des().Copy(aSource); |
|
3813 |
|
3814 TInt state = CCnvCharacterSetConverter::KStateDefault; |
|
3815 |
|
3816 //defect fix for Inc021752 |
|
3817 User::LeaveIfError(iConverter->ConvertToUnicode(aSink, *des, state)); |
|
3818 CleanupStack::PopAndDestroy(des); |
|
3819 } |
|
3820 else |
|
3821 { |
|
3822 aSink.Copy(aSource); |
|
3823 } |
|
3824 } |
|
3825 |
|
3826 CWapCharsetConverter::~CWapCharsetConverter() |
|
3827 { |
|
3828 delete iConverter; |
|
3829 delete iAvailableCharsets; |
|
3830 } |