author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 23 Jun 2010 18:09:17 +0300 | |
changeset 43 | 35b64624a9e7 |
parent 31 | ebfee66fde93 |
child 47 | 5b14749788d7 |
child 70 | a15d9966050f |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: General utilities for unified editor and plugin |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// INCLUDE FILES |
|
19 |
#include <centralrepository.h> // CRepository |
|
20 |
#include <CoreApplicationUIsSDKCRKeys.h> // offline CR keys |
|
21 |
#include <rcustomerserviceprofilecache.h> |
|
22 |
#include <MmsEngineDomainCRKeys.h> |
|
23 |
#include <MsgMediaResolver.h> |
|
24 |
#include <DRMHelper.h> |
|
25 |
||
26 |
#include "MessagingVariant.hrh" |
|
27 |
#include "MessagingInternalCRKeys.h" // Keys |
|
28 |
#include "UniEditorGenUtils.h" |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
29 |
#include <xqconversions.h> |
31 | 30 |
|
31 |
// CONSTANTS |
|
32 |
const TInt KMuiuCharQuote = '\"'; |
|
33 |
const TInt KMuiuCharBackSlash = '\\'; |
|
34 |
const TInt KMuiuCharDot = '.'; |
|
35 |
const TInt KMuiuCharSpace = ' '; |
|
36 |
const TInt KMuiuCharDel = 127; |
|
37 |
const TInt KMuiuCharAt = '@'; |
|
38 |
const TInt KMuiuSpecialCharStrLen = 12; |
|
39 |
_LIT( KRFC822Specials,"()<>@,;:\\\"[]"); |
|
40 |
||
41 |
// ============================ MEMBER FUNCTIONS =============================== |
|
42 |
||
43 |
// ---------------------------------------------------- |
|
44 |
// UniEditorGenUtils::UniEditorGenUtils |
|
45 |
// @see header |
|
46 |
// ---------------------------------------------------- |
|
47 |
UniEditorGenUtils::UniEditorGenUtils() : |
|
48 |
mAbsMaxConcatenatedSms(-1), |
|
49 |
mAbsMaxSmsCharacters(-1), |
|
50 |
mMaxMmsSize(-1) |
|
51 |
{ |
|
52 |
||
53 |
} |
|
54 |
||
55 |
// ---------------------------------------------------- |
|
56 |
// UniEditorGenUtils::~UniEditorGenUtils |
|
57 |
// @see header |
|
58 |
// ---------------------------------------------------- |
|
59 |
UniEditorGenUtils::~UniEditorGenUtils() |
|
60 |
{ |
|
61 |
||
62 |
} |
|
63 |
// ---------------------------------------------------- |
|
64 |
// UniEditorGenUtils::ReadEmailOverSmsSettingsL |
|
65 |
// @see header |
|
66 |
// ---------------------------------------------------- |
|
67 |
TInt UniEditorGenUtils::ReadEmailOverSmsSettingsL( |
|
68 |
TDes& aSmsc, |
|
69 |
TDes& aDestinationAddress, |
|
70 |
TBool& aModifiable ) |
|
71 |
{ |
|
72 |
// Create storage |
|
73 |
CRepository* storage = CRepository::NewLC( KCRUidSmum ); |
|
74 |
storage->Get( KSumEmailSC, aSmsc ); |
|
75 |
storage->Get( KSumEmailGateway, aDestinationAddress ); |
|
76 |
storage->Get( KSumEmailModifiable, aModifiable ); |
|
77 |
CleanupStack::PopAndDestroy(); // storage |
|
78 |
return KErrNone; |
|
79 |
} |
|
80 |
||
81 |
// ---------------------------------------------------- |
|
82 |
// UniEditorGenUtils::WriteEmailOverSmsSettingsL |
|
83 |
// @see header |
|
84 |
// ---------------------------------------------------- |
|
85 |
TInt UniEditorGenUtils::WriteEmailOverSmsSettingsL( |
|
86 |
const TDes& aSmsc, |
|
87 |
const TDes& aDestinationAddress, |
|
88 |
const TBool& aModifiable ) |
|
89 |
{ |
|
90 |
// Create storage |
|
91 |
CRepository* storage = CRepository::NewLC( KCRUidSmum ); |
|
92 |
storage->Set( KSumEmailSC, aSmsc ); |
|
93 |
storage->Set( KSumEmailGateway, aDestinationAddress ); |
|
94 |
storage->Set( KSumEmailModifiable, aModifiable ); |
|
95 |
CleanupStack::PopAndDestroy(); // storage |
|
96 |
return KErrNone; |
|
97 |
} |
|
98 |
||
99 |
// --------------------------------------------------------- |
|
100 |
// UniEditorGenUtils::IsPhoneOfflineL |
|
101 |
// @see header |
|
102 |
// --------------------------------------------------------- |
|
103 |
TBool UniEditorGenUtils::IsPhoneOfflineL() |
|
104 |
{ |
|
105 |
TInt connAllowed ( 1 ); |
|
106 |
CRepository* repository ( CRepository::NewL( KCRUidCoreApplicationUIs ) ); |
|
107 |
TInt err = repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed ); |
|
108 |
delete repository; |
|
109 |
repository = NULL; |
|
110 |
if ( !err && !connAllowed ) |
|
111 |
{ |
|
112 |
return ETrue; |
|
113 |
} |
|
114 |
else |
|
115 |
{ |
|
116 |
return EFalse; |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
// ---------------------------------------------------- |
|
121 |
// UniEditorGenUtils::AcceptEmailAddressesL |
|
122 |
// @see header |
|
123 |
// ---------------------------------------------------- |
|
124 |
TBool UniEditorGenUtils::AcceptEmailAddressesL() |
|
125 |
{ |
|
126 |
CRepository* repository ( CRepository::NewL( KCRUidMuiuVariation ) ); |
|
127 |
TInt features = 0; |
|
128 |
TBool emailOverSmsVariationOn = false; |
|
129 |
TBool acceptEmailAddresses = false; |
|
130 |
||
131 |
if ( repository->Get( KMuiuSmsFeatures, features ) == KErrNone ) |
|
132 |
{ |
|
133 |
if ( features & KSmsFeatureIdEmailOverSms ) |
|
134 |
{ |
|
135 |
emailOverSmsVariationOn = ETrue; |
|
136 |
} |
|
137 |
} |
|
138 |
||
139 |
delete repository; |
|
140 |
||
141 |
//TODO chk with Jerry if below is needed |
|
142 |
RCustomerServiceProfileCache* cspProfile = new (ELeave) RCustomerServiceProfileCache; |
|
143 |
TInt error = cspProfile->Open(); |
|
144 |
||
145 |
if ( error == KErrNone ) |
|
146 |
{ |
|
147 |
if ( emailOverSmsVariationOn ) |
|
148 |
{ |
|
149 |
||
150 |
// EmailOverSms bit was variated ON so let's check the bit from SIM |
|
151 |
// Get tele services flags from CSP |
|
152 |
RMobilePhone::TCspValueAdded params; |
|
153 |
// Read the CPHS bit so we know if EmailOverSms is supported |
|
154 |
error = cspProfile->CspCPHSValueAddedServices( params ); |
|
155 |
||
156 |
||
157 |
if ( error == KErrNone && |
|
158 |
params >= 0 && |
|
159 |
params & RMobilePhone::KCspSMMOEmail ) |
|
160 |
{ |
|
161 |
// It's supported |
|
162 |
acceptEmailAddresses= true; |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
cspProfile->Close(); |
|
167 |
delete cspProfile; |
|
168 |
||
169 |
return acceptEmailAddresses; |
|
170 |
} |
|
171 |
||
172 |
// ---------------------------------------------------- |
|
173 |
// UniEditorGenUtils::VerifyEmailAddressesL |
|
174 |
// @see header |
|
175 |
// ---------------------------------------------------- |
|
176 |
TBool UniEditorGenUtils::VerifyEmailAddressesL( ConvergedMessageAddressList addrList) |
|
177 |
{ |
|
178 |
TBool emailAddrPresent = EFalse; |
|
179 |
int addrCount = addrList.count(); |
|
180 |
for(int i=0; i< addrCount; i++) |
|
181 |
{ |
|
182 |
QString addr = addrList.at(i)->address(); |
|
183 |
// check if email address, contains at least 3 characters |
|
184 |
if(addr.size() >= 3) |
|
185 |
{ |
|
186 |
// search for @ from the address |
|
187 |
// however, it can't be the first or the last item |
|
188 |
for(int i = 1; i < addr.size() - 1; i++) |
|
189 |
{ |
|
190 |
if(addr.at(i) == '@') |
|
191 |
{ |
|
192 |
emailAddrPresent = ETrue; |
|
193 |
break; |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
} |
|
198 |
return emailAddrPresent; |
|
199 |
} |
|
200 |
||
201 |
// ---------------------------------------------------- |
|
202 |
// UniEditorGenUtils::UTF8Size |
|
203 |
// @see header |
|
204 |
// ---------------------------------------------------- |
|
205 |
TInt UniEditorGenUtils::UTF8Size( QString aText ) |
|
206 |
{ |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
207 |
HBufC* text = XQConversions::qStringToS60Desc(aText); |
31 | 208 |
TPtrC ptr = text->Des(); |
209 |
||
210 |
TInt count = 0; |
|
211 |
TInt sizeInBytes = 0; |
|
212 |
TUint16 charValue; |
|
213 |
while ( count < ptr.Length() ) |
|
214 |
{ |
|
215 |
charValue = ptr[count]; |
|
216 |
if ( charValue < 0x80 ) |
|
217 |
{ |
|
218 |
sizeInBytes += 1; |
|
219 |
} |
|
220 |
else if ( charValue < 0x800 ) |
|
221 |
{ |
|
222 |
sizeInBytes += 2; |
|
223 |
} |
|
224 |
else //if ( charValue < 0x10000 ) |
|
225 |
{ |
|
226 |
sizeInBytes += 3; |
|
227 |
} |
|
228 |
count++; |
|
229 |
} |
|
230 |
return sizeInBytes; |
|
231 |
} |
|
232 |
||
233 |
// ---------------------------------------------------- |
|
234 |
// UniEditorGenUtils::MaxSmsRecipientsL |
|
235 |
// @see header |
|
236 |
// ---------------------------------------------------- |
|
237 |
TInt UniEditorGenUtils::MaxSmsRecipientsL() |
|
238 |
{ |
|
239 |
CRepository* repository ( CRepository::NewL( KCRUidUniEditor ) ); |
|
240 |
TInt maxSmsRecipients = KDefaultSmsRecipients; |
|
241 |
||
242 |
if ( (repository->Get( KUniEditorSoftLimitRecipientCount, maxSmsRecipients ) |
|
243 |
!= KErrNone) || (maxSmsRecipients <= 0) ) |
|
244 |
{ |
|
245 |
// Unreasonable count, change it back to default value |
|
246 |
maxSmsRecipients = KDefaultSmsRecipients; |
|
247 |
} |
|
248 |
delete repository; |
|
249 |
||
250 |
return maxSmsRecipients; |
|
251 |
} |
|
252 |
||
253 |
// ---------------------------------------------------- |
|
254 |
// UniEditorGenUtils::MaxMmsRecipientsL |
|
255 |
// @see header |
|
256 |
// ---------------------------------------------------- |
|
257 |
TInt UniEditorGenUtils::MaxMmsRecipientsL() |
|
258 |
{ |
|
259 |
CRepository* repository ( CRepository::NewL( KCRUidUniEditor ) ); |
|
260 |
TInt maxMmsRecipients = KDefaultMmsRecipients; |
|
261 |
||
262 |
if ( (repository->Get( KUniEditorMaxRecipientCount, maxMmsRecipients ) |
|
263 |
!= KErrNone) || (maxMmsRecipients <= 0)) |
|
264 |
{ |
|
265 |
// Unreasonable count, change it back to default value |
|
266 |
maxMmsRecipients = KDefaultMmsRecipients; |
|
267 |
} |
|
268 |
delete repository; |
|
269 |
||
270 |
return maxMmsRecipients; |
|
271 |
} |
|
272 |
||
273 |
// ---------------------------------------------------- |
|
274 |
// UniEditorGenUtils::MaxMmsMsgSizeL |
|
275 |
// @see header |
|
276 |
// ---------------------------------------------------- |
|
277 |
TInt UniEditorGenUtils::MaxMmsMsgSizeL() |
|
278 |
{ |
|
279 |
// optimized, to read only once from CR |
|
280 |
if(mMaxMmsSize == -1) |
|
281 |
{// not read yet, so read it now |
|
282 |
mMaxMmsSize = KDefaultMaxSize; |
|
283 |
||
284 |
CRepository* repository = CRepository::NewL( KCRUidMmsEngine ); |
|
285 |
CleanupStack::PushL( repository ); |
|
286 |
||
287 |
repository->Get( KMmsEngineMaximumSendSize, mMaxMmsSize ); |
|
288 |
||
289 |
CleanupStack::PopAndDestroy( repository ); |
|
290 |
} |
|
291 |
||
292 |
return mMaxMmsSize; |
|
293 |
} |
|
294 |
||
295 |
// ---------------------------------------------------- |
|
296 |
// UniEditorGenUtils::getFileInfoL |
|
297 |
// @see header |
|
298 |
// ---------------------------------------------------- |
|
299 |
void UniEditorGenUtils::getFileInfoL(QString filePath, |
|
300 |
int& size, |
|
301 |
QString& mimetype, |
|
302 |
TMsgMediaType& mediaType) |
|
303 |
{ |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
304 |
HBufC* filepath = XQConversions::qStringToS60Desc(filePath); |
31 | 305 |
int fileSize = 0; |
306 |
||
307 |
CMsgMediaResolver* mediaResolver; |
|
308 |
||
309 |
if(filepath) |
|
310 |
{ |
|
311 |
CleanupStack::PushL(filepath); |
|
312 |
||
313 |
mediaResolver = CMsgMediaResolver::NewLC(); |
|
314 |
||
315 |
RFile file = mediaResolver->FileHandleL(*filepath); |
|
316 |
file.Size(fileSize); |
|
317 |
fileSize+= KEstimatedMimeHeaderSize; |
|
318 |
size = fileSize; |
|
319 |
TDataType datatype; |
|
320 |
mediaResolver->RecognizeL( file, datatype ); |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
321 |
mimetype = XQConversions::s60Desc8ToQString(datatype.Des8()); |
31 | 322 |
mediaType = mediaResolver->MediaType(datatype.Des8()); |
323 |
||
324 |
CleanupStack::PopAndDestroy(mediaResolver); |
|
325 |
CleanupStack::PopAndDestroy(filepath); |
|
326 |
} |
|
327 |
||
328 |
return; |
|
329 |
} |
|
330 |
||
331 |
// ---------------------------------------------------- |
|
332 |
// UniEditorGenUtils::MaxSmsMsgSizeL |
|
333 |
// @see header |
|
334 |
// ---------------------------------------------------- |
|
335 |
int UniEditorGenUtils::MaxSmsMsgSizeL(bool unicode) |
|
336 |
{ |
|
337 |
int maxLength = 0; |
|
338 |
int lengthOne = 0; |
|
339 |
int lengthMany = 0; |
|
340 |
||
341 |
getSmsCharacterLimits(lengthOne, lengthMany, unicode); |
|
342 |
maxLength = lengthOne; |
|
343 |
||
344 |
int maxSmsParts = absoluteMaxSmsPartsL(); |
|
345 |
if(maxSmsParts > 1) |
|
346 |
{ |
|
347 |
maxLength = maxSmsParts * lengthMany; |
|
348 |
} |
|
349 |
/* UniEditor soft limit, may not be needed |
|
350 |
int maxSmsCharacters = absoluteMaxSmsCharactersL(); |
|
351 |
if(maxSmsCharacters > 0) |
|
352 |
{ |
|
353 |
maxLength = maxSmsCharacters; |
|
354 |
} |
|
355 |
*/ |
|
356 |
return maxLength; |
|
357 |
} |
|
358 |
||
359 |
// ---------------------------------------------------- |
|
360 |
// UniEditorGenUtils::getSmsCharacterLimits |
|
361 |
// @see header |
|
362 |
// ---------------------------------------------------- |
|
363 |
void UniEditorGenUtils::getSmsCharacterLimits(int& singlePartLength, |
|
364 |
int& concatenatedPartLength, |
|
365 |
bool unicode) |
|
366 |
{ |
|
367 |
if(unicode) |
|
368 |
{ |
|
369 |
singlePartLength = KFirstUnicodeSmsLength; |
|
370 |
concatenatedPartLength = KUnicodeConcatenationInterval; |
|
371 |
} |
|
372 |
else |
|
373 |
{ |
|
374 |
singlePartLength = KFirstNormalSmsLength; |
|
375 |
concatenatedPartLength = KNormalConcatenationInterval; |
|
376 |
} |
|
377 |
} |
|
378 |
||
379 |
// ---------------------------------------------------- |
|
380 |
// UniEditorGenUtils::absoluteMaxSmsPartsL |
|
381 |
// @see header |
|
382 |
// ---------------------------------------------------- |
|
383 |
int UniEditorGenUtils::absoluteMaxSmsPartsL() |
|
384 |
{ |
|
385 |
// optimized, to read only once from CR |
|
386 |
if(mAbsMaxConcatenatedSms == -1) |
|
387 |
{ // not read yet, so read it now |
|
388 |
mAbsMaxConcatenatedSms = KDefaultMaxSmsSize; |
|
389 |
CRepository* repository = CRepository::NewL( KCRUidSmum ); |
|
390 |
CleanupStack::PushL( repository ); |
|
391 |
||
392 |
if ( repository->Get( KSmumMaxSubMsgCount, mAbsMaxConcatenatedSms ) || |
|
393 |
mAbsMaxConcatenatedSms < 1 || |
|
394 |
mAbsMaxConcatenatedSms > KMaxSmsSizeByStandard ) |
|
395 |
{ |
|
396 |
// Unreasonable count, change it back to 30 ( S60 default ) |
|
397 |
mAbsMaxConcatenatedSms = KMaxSmsSizeByStandard; |
|
398 |
} |
|
399 |
CleanupStack::PopAndDestroy( repository ); |
|
400 |
} |
|
401 |
return mAbsMaxConcatenatedSms; |
|
402 |
} |
|
403 |
||
404 |
// ---------------------------------------------------- |
|
405 |
// UniEditorGenUtils::absoluteMaxSmsCharactersL |
|
406 |
// @see header |
|
407 |
// ---------------------------------------------------- |
|
408 |
int UniEditorGenUtils::absoluteMaxSmsCharactersL() |
|
409 |
{ |
|
410 |
// optimized, to read only once from CR |
|
411 |
if(mAbsMaxSmsCharacters == -1) |
|
412 |
{// not read yet, so read it now |
|
413 |
CRepository* repository = CRepository::NewL( KCRUidUniEditor ); |
|
414 |
CleanupStack::PushL( repository ); |
|
415 |
repository->Get( KUniEditorMaxSmsCharacterCount, mAbsMaxSmsCharacters ); |
|
416 |
CleanupStack::PopAndDestroy( repository ); |
|
417 |
} |
|
418 |
return mAbsMaxSmsCharacters; |
|
419 |
} |
|
420 |
||
421 |
// --------------------------------------------------------- |
|
422 |
// UniEditorGenUtils::ConvertDigitsTo |
|
423 |
// @see header |
|
424 |
// --------------------------------------------------------- |
|
425 |
void UniEditorGenUtils::ConvertDigitsTo( TDes& aDes, TDigitType aDigitType ) |
|
426 |
{ |
|
427 |
TChar toArea = aDigitType; |
|
428 |
TInt length = aDes.Length(); |
|
429 |
for(int i=0; i<length; i++) |
|
430 |
{ |
|
431 |
TChar ch = aDes[i]; |
|
432 |
TChar base = NumberToBase(ch); |
|
433 |
switch (base) |
|
434 |
{ |
|
435 |
case EDigitTypeWestern: |
|
436 |
case EDigitTypeArabicIndic: |
|
437 |
case EDigitTypeEasternArabicIndic: |
|
438 |
case EDigitTypeDevanagari: |
|
439 |
case EDigitTypeThai: |
|
440 |
ch += toArea - base; |
|
441 |
aDes[i] = TUint16(ch); |
|
442 |
break; |
|
443 |
default: |
|
444 |
break; |
|
445 |
}; |
|
446 |
} |
|
447 |
} |
|
448 |
||
449 |
// --------------------------------------------------------- |
|
450 |
// UniEditorGenUtils::NumberToBase |
|
451 |
// @see header |
|
452 |
// --------------------------------------------------------- |
|
453 |
TChar UniEditorGenUtils::NumberToBase(TChar ch) |
|
454 |
{ |
|
455 |
TDigitType d[] = { EDigitTypeWestern, EDigitTypeArabicIndic, EDigitTypeEasternArabicIndic, EDigitTypeDevanagari, EDigitTypeThai }; |
|
456 |
TInt i = 0; |
|
457 |
TInt num = sizeof(d)/sizeof(d[0]); |
|
458 |
while(i<num) |
|
459 |
{ |
|
460 |
if (ch>TChar(d[i]) && ch<TChar(d[i]+10)) { return d[i]; } |
|
461 |
i++; |
|
462 |
} |
|
463 |
return ch; |
|
464 |
} |
|
465 |
||
466 |
// --------------------------------------------------------- |
|
467 |
// UniEditorGenUtils::ReplaceCharacters |
|
468 |
// @see header |
|
469 |
// --------------------------------------------------------- |
|
470 |
void UniEditorGenUtils::ReplaceCharacters(TDes &aDes, const TDesC &aChars, TChar aReplacement) |
|
471 |
{ |
|
472 |
TInt src = 0; |
|
473 |
TInt srclength = aDes.Length(); |
|
474 |
while(src < srclength) |
|
475 |
{ |
|
476 |
TChar c = aDes[src]; |
|
477 |
if (aChars.LocateF(c) != KErrNotFound) |
|
478 |
aDes[src] = TUint16(aReplacement); |
|
479 |
++src; |
|
480 |
} |
|
481 |
} |
|
482 |
||
483 |
// ---------------------------------------------------- |
|
484 |
// UniEditorGenUtils::IsValidEmailAddressL |
|
485 |
// @see header |
|
486 |
// ---------------------------------------------------- |
|
487 |
TBool UniEditorGenUtils::IsValidEmailAddress( const TDesC& aAddress ) |
|
488 |
{ |
|
489 |
TInt c; |
|
490 |
TInt length = aAddress.Length (); |
|
491 |
TBufC<KMuiuSpecialCharStrLen> rfc822Specials ( KRFC822Specials ); |
|
492 |
||
493 |
// first we validate the name portion (name@domain) |
|
494 |
if ( length && aAddress[0] == KMuiuCharDot ) |
|
495 |
{ |
|
496 |
return EFalse; |
|
497 |
} |
|
498 |
for ( c = 0 ; c < length ; c++ ) |
|
499 |
{ |
|
500 |
if ( aAddress[c] == KMuiuCharQuote && ( c == 0 || |
|
501 |
aAddress[c-1] == KMuiuCharDot || aAddress[c-1] == KMuiuCharQuote ) ) |
|
502 |
{ |
|
503 |
while ( ++c < length ) |
|
504 |
{ |
|
505 |
if ( aAddress[c] == KMuiuCharQuote ) |
|
506 |
{ |
|
507 |
if( (c + 1) == length) |
|
508 |
{ |
|
509 |
return EFalse; |
|
510 |
} |
|
511 |
break; |
|
512 |
} |
|
513 |
if ( aAddress[c] == KMuiuCharBackSlash && |
|
514 |
( aAddress[++c] == KMuiuCharSpace) ) |
|
515 |
{ |
|
516 |
continue; |
|
517 |
} |
|
518 |
if ( aAddress[c] <= KMuiuCharSpace || |
|
519 |
aAddress[c] >= KMuiuCharDel ) |
|
520 |
{ |
|
521 |
return EFalse; |
|
522 |
} |
|
523 |
} |
|
524 |
if ( c++ == length ) |
|
525 |
{ |
|
526 |
return EFalse; |
|
527 |
} |
|
528 |
if ( aAddress[c] == KMuiuCharAt ) |
|
529 |
{ |
|
530 |
break; |
|
531 |
} |
|
532 |
if ( aAddress[c] != KMuiuCharDot ) |
|
533 |
{ |
|
534 |
return EFalse; |
|
535 |
} |
|
536 |
continue; |
|
537 |
} |
|
538 |
if ( aAddress[c] == KMuiuCharAt ) |
|
539 |
{ |
|
540 |
break; |
|
541 |
} |
|
542 |
if ( aAddress[c] <= KMuiuCharSpace || aAddress[c] >= KMuiuCharDel ) |
|
543 |
{ |
|
544 |
return EFalse; |
|
545 |
} |
|
546 |
if ( rfc822Specials.Locate ( aAddress[c] ) != KErrNotFound ) |
|
547 |
{ |
|
548 |
return EFalse; |
|
549 |
} |
|
550 |
} |
|
551 |
if ( c == 0 || aAddress[c-1] == KMuiuCharDot ) |
|
552 |
{ |
|
553 |
return EFalse; |
|
554 |
} |
|
555 |
// next we validate the domain portion (name@domain) |
|
556 |
if ( c == length ) |
|
557 |
{ |
|
558 |
return EFalse; |
|
559 |
} |
|
560 |
else |
|
561 |
{ |
|
562 |
c++; |
|
563 |
return IsValidDomain ( aAddress.Mid ( ( c ) , length-c ) ); |
|
564 |
} |
|
565 |
} |
|
566 |
||
567 |
// ---------------------------------------------------- |
|
568 |
// UniEditorGenUtils::IsValidDomainL |
|
569 |
// @see header |
|
570 |
// ---------------------------------------------------- |
|
571 |
TBool UniEditorGenUtils::IsValidDomain ( const TDesC& aDomain ) |
|
572 |
{ |
|
573 |
TInt c = 0; |
|
574 |
TInt length = aDomain.Length (); |
|
575 |
TBufC<KMuiuSpecialCharStrLen> rfc822Specials ( KRFC822Specials ); |
|
576 |
||
577 |
if ( length == 0 ) |
|
578 |
{ |
|
579 |
return EFalse; |
|
580 |
} |
|
581 |
||
582 |
do |
|
583 |
{ |
|
584 |
if ( aDomain[c] == KMuiuCharDot ) |
|
585 |
{ |
|
586 |
if ( c == 0 || aDomain[c-1] == KMuiuCharDot ) |
|
587 |
{ |
|
588 |
return EFalse; |
|
589 |
} |
|
590 |
} |
|
591 |
if ( aDomain[c] <= KMuiuCharSpace || aDomain[c] >= KMuiuCharDel ) |
|
592 |
{ |
|
593 |
return EFalse; |
|
594 |
} |
|
595 |
if ( rfc822Specials.Locate( aDomain[c] ) != KErrNotFound ) |
|
596 |
{ |
|
597 |
return EFalse; |
|
598 |
} |
|
599 |
} |
|
600 |
while ( ++c < length ); |
|
601 |
||
602 |
return ( aDomain[length-1] != '.' ); |
|
603 |
} |
|
604 |
||
605 |
// End of file |