1 miutpars.h |
1 // Copyright (c) 1998-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #if !defined (__MIUTPARS_H__) |
|
17 #define __MIUTPARS_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 // comment out line below to switch ON Internet message checking |
|
22 //#define __NO_EMAIL_ADDRESS_CHECKING__ |
|
23 |
|
24 class TImMessageField |
|
25 /** Parses email message header fields for valid Internet email addresses, |
|
26 comments and aliases. |
|
27 |
|
28 A comment is a string surrounded by parentheses, as defined in RFC822, 3.1.4. |
|
29 |
|
30 An alias is defined as any substring which appears to the left of a legal email address: |
|
31 for example, the string "this is an alias" in "this is an alias <an.email@address.com>". |
|
32 |
|
33 For email addresses, the string being parsed: |
|
34 1) must contain an @ character, surrounded by valid address characters; |
|
35 2) may not contain more than one address or @ character; |
|
36 3) may contain aliases and comments. |
|
37 |
|
38 Note the following about the implementation of this class: |
|
39 |
|
40 1. Functions that test subject lines, ValidSubjectLine(), and alias names, ValidAliasName(), were |
|
41 initially written to test that the strings did not contain characters outside a limited |
|
42 ASCII range. Unicode characters are now allowed, so these functions now always return true. |
|
43 |
|
44 2. Of the four overloads of GetValidInternetEmailAddressFromString(), only the first has a meaningful |
|
45 implementation. |
|
46 |
|
47 @publishedAll |
|
48 @released |
|
49 */ |
|
50 { |
|
51 public: |
|
52 IMPORT_C TBool ValidInternetEmailAddress(const TDesC16& aAddress); |
|
53 IMPORT_C TBool ValidInternetEmailAddress(const TDesC16& aAddress, TInt& rFirstBadCharPos); |
|
54 IMPORT_C TBool ValidInternetEmailAddress(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar); |
|
55 IMPORT_C TBool ValidInternetEmailAddress(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar, TInt& rFirstBadCharPos); |
|
56 |
|
57 IMPORT_C TBool ValidInternetEmailAddressChar(const TChar& aChar); |
|
58 |
|
59 IMPORT_C TBool ValidSubjectLine(const TDesC16& aSubjectLine); |
|
60 IMPORT_C TBool ValidSubjectLine(const TDesC16& aSubjectLine, TInt& rFirstBadCharPos); |
|
61 |
|
62 IMPORT_C TBool ValidSubjectLineChar(const TChar& aChar); |
|
63 |
|
64 IMPORT_C TBool ValidAliasName(const TDesC16& aAliasName); |
|
65 IMPORT_C TBool ValidAliasName(const TDesC16& aAliasName, TInt& rFirstBadCharPos); |
|
66 |
|
67 IMPORT_C TPtrC16 GetValidInternetEmailAddressFromString(const TDesC16& aAddress); |
|
68 IMPORT_C TPtrC16 GetValidInternetEmailAddressFromString(const TDesC16& aAddress, TInt& rError); |
|
69 IMPORT_C TPtrC16 GetValidInternetEmailAddressFromString(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar); |
|
70 IMPORT_C TPtrC16 GetValidInternetEmailAddressFromString(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar, TInt& rError); |
|
71 |
|
72 IMPORT_C TPtrC16 GetValidAlias(const TDesC16& aAddress); |
|
73 IMPORT_C TPtrC16 GetValidAlias(const TDesC16& aAddress, TInt& rError); |
|
74 |
|
75 IMPORT_C TPtrC16 GetValidComment(const TDesC16& aAddress); |
|
76 IMPORT_C TPtrC16 GetValidComment(const TDesC16& aAddress, TInt& rError); |
|
77 TBool TruncateAddressString(const TDesC16& aDesc, TInt aLimit, TInt& aLastChar); |
|
78 private: |
|
79 TBool isValidEmailAddress(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar); |
|
80 TBool isLegalEmailAddress(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar); |
|
81 TBool isSurroundedByRoundBrackets(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar); |
|
82 TBool isSurroundedByAngledBrackets(const TDesC16& aAddress, TInt& rFirstChar, TInt& rLastChar, TInt aAtPos); |
|
83 TBool isEnclosedSubString(const TDesC16& anAddress, const TChar& aLeftBracket, const TChar& aRightBracket,TInt& aLeftPos, TInt& aRightPos); |
|
84 TBool isValidString(const TDesC16& anAddress, TInt& aFirstBadCharPos); |
|
85 TBool isValidChar(const TChar& aChar); |
|
86 TBool isValidEmailString(const TDesC16& anAddress, TInt& aFirstBadCharPos); |
|
87 TBool isValidEmailChar(const TChar& aChar); |
|
88 TBool LocateSubString(const TDesC16& anAddress, const TInt atPos, TInt& rFirstChar, TInt& rLastChar); |
|
89 TBool hasAngledBrackets(const TDesC16& anAddress); |
|
90 TBool isValid_ISO88591String(const TDesC16& aString,TInt& aPos); |
|
91 TBool isValidRoutedEmailAddress(const TDesC16& anAddress); |
|
92 TBool isValidDomainNameChar(const TChar& aChar); |
|
93 TBool isValidMailboxChar(const TChar& aChar); |
|
94 TBool isDotChar(const TChar& aChar); |
|
95 }; |
|
96 |
|
97 |
|
98 #endif // !defined __MIUTPARS_H__ |