|
1 // Copyright (c) 2001-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 // This file contains the implementation for the classes defined in |
|
15 // MsgUrlParser.h |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @see MsgUrlParser.h |
|
22 */ |
|
23 |
|
24 // Local includes |
|
25 // |
|
26 #include "msgurlparser.h" |
|
27 |
|
28 TDelimitedAddressParser::TDelimitedAddressParser() |
|
29 : TDelimitedParserBase16() |
|
30 { |
|
31 SetDelimiter(TChar(',')); |
|
32 } |
|
33 |
|
34 void TDelimitedAddressParser::Parse(const TDesC& aAddress) |
|
35 { |
|
36 // Call base class function as it is protected |
|
37 TDelimitedParserBase16::Parse(aAddress); |
|
38 } |
|
39 |
|
40 TMailtoUrlParser::TMailtoUrlParser() |
|
41 { |
|
42 } |
|
43 |
|
44 void TMailtoUrlParser::Parse(const TDesC& aData) |
|
45 { |
|
46 // Contains the address segment |
|
47 TPtrC addressData; |
|
48 |
|
49 // Contains the body segment |
|
50 TPtrC bodyData; |
|
51 |
|
52 // Look for segment separator |
|
53 TInt pos = aData.Locate('?'); |
|
54 if (pos != KErrNotFound) |
|
55 { |
|
56 addressData.Set(aData.Left(pos)); |
|
57 |
|
58 // Sets everything after the segment separator - excludes '?' delimiter |
|
59 bodyData.Set(aData.Mid(pos+1)); |
|
60 } |
|
61 else |
|
62 { |
|
63 addressData.Set(aData); |
|
64 bodyData.Set(KNullDesC); |
|
65 } |
|
66 |
|
67 // Parse the address segment |
|
68 iAddressParser.Parse(addressData); |
|
69 |
|
70 // Parse the body segment |
|
71 iBodyParser.Parse(bodyData); |
|
72 } |
|
73 |
|
74 const TDelimitedAddressParser& TMailtoUrlParser::ExtractAddresses() const |
|
75 { |
|
76 return iAddressParser; |
|
77 } |
|
78 |
|
79 const TDelimitedBodyParser& TMailtoUrlParser::ExtractBody() const |
|
80 { |
|
81 return iBodyParser; |
|
82 } |
|
83 |
|
84 void ParseUtil::Subset(const TDesC& aDes, const TDesC& aSubset, TPtrC& aData) |
|
85 { |
|
86 TInt pos=0; |
|
87 |
|
88 while (pos<aDes.Length() && aSubset.Locate(aDes[pos]) != KErrNotFound) |
|
89 { |
|
90 ++pos; |
|
91 } |
|
92 |
|
93 aData.Set(aDes.Left(pos)); |
|
94 } |