|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CSVTSIPURIPARSER_H |
|
21 #define C_CSVTSIPURIPARSER_H |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 /** |
|
26 * Provides services for SIP URI parsing. |
|
27 * |
|
28 * @lib svtlogging.dll |
|
29 * @since S60 v5.1 |
|
30 */ |
|
31 class CSvtSipUriParser : public CBase |
|
32 { |
|
33 |
|
34 public: |
|
35 |
|
36 /** Domain part clipping options for SIP URIs. */ |
|
37 enum TDomainPartClippingSetting |
|
38 { |
|
39 /** Domain part is not clipped. */ |
|
40 ENoClipping = 0, |
|
41 /** Domain part is clipped if user name part presents |
|
42 a telephony number. */ |
|
43 EClipDomainIfNumber = 1, |
|
44 /** Domain part is always clipped. */ |
|
45 EClipDomain = 2 |
|
46 }; |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 * @param aSipUri The SIP URI to be parsed. |
|
51 * @param aOptions Clipping options. |
|
52 */ |
|
53 static CSvtSipUriParser* NewL( const TDesC& aSipUri, |
|
54 TDomainPartClippingSetting aOptions ); |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 * @param aSipUri The SIP URI to be parsed. |
|
59 * @param aOptions Clipping options. |
|
60 */ |
|
61 static CSvtSipUriParser* NewLC( const TDesC& aSipUri, |
|
62 TDomainPartClippingSetting aOptions ); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 virtual ~CSvtSipUriParser(); |
|
68 |
|
69 /** |
|
70 * Returns parsed VoIP address if available. If VoIP address is not |
|
71 * available a KNullDesC is returned. That can happen in case of private |
|
72 * address. |
|
73 * |
|
74 * @since S60 v5.1 |
|
75 * @param aVoipAddress Parsed VoIP address or KNullDesC. |
|
76 * @return System wide error code. |
|
77 */ |
|
78 TInt GetVoipAddress( RBuf& aVoipAddress ) const; |
|
79 |
|
80 /** |
|
81 * Returns parsed phone number if available. If phone number is not |
|
82 * available a KNullDesC is returned. |
|
83 * |
|
84 * @since S60 v5.1 |
|
85 * @param aPhoneNumber Parsed phone number or KNullDesC. |
|
86 * @return System wide error code. |
|
87 */ |
|
88 TInt GetPhoneNumber( RBuf& aPhoneNumber ) const; |
|
89 |
|
90 /** |
|
91 * Returns display name if available. If display name is not available |
|
92 * a KNullDesC is returned. |
|
93 * |
|
94 * @since S60 v5.1 |
|
95 * @param aPhoneNumber Display name or KNullDesC. |
|
96 * @return System wide error code. |
|
97 */ |
|
98 TInt GetDisplayName( RBuf& aDisplayName ) const; |
|
99 |
|
100 private: |
|
101 |
|
102 CSvtSipUriParser() {}; |
|
103 |
|
104 CSvtSipUriParser( TDomainPartClippingSetting aOptions ); |
|
105 |
|
106 void ConstructL( const TDesC& aSipUri ); |
|
107 |
|
108 void ParseSipUriL( const TDesC& aSipUri ); |
|
109 |
|
110 void ParseDisplayNameL( const TDesC& aSipUri ); |
|
111 |
|
112 void RemoveElbows( TDes& sipUri ) const; |
|
113 |
|
114 void ParseUserNameL( const TDesC& aSipUri ); |
|
115 |
|
116 void ParseDomainL( const TDesC& aSipUri ); |
|
117 |
|
118 void ParsePrivateAddress(); |
|
119 |
|
120 TInt AddressLength( const TDesC& aUserName, const TDesC& aDomain, |
|
121 TDomainPartClippingSetting aClipSetting ) const; |
|
122 |
|
123 TBool IsAnonymousUri( const TDesC& aCandidate ) const; |
|
124 |
|
125 private: // data |
|
126 |
|
127 /** |
|
128 * Domain part clipping options. |
|
129 */ |
|
130 TDomainPartClippingSetting iOptions; |
|
131 |
|
132 /** |
|
133 * User name part of the parsed SIP URI. |
|
134 * Own. |
|
135 */ |
|
136 RBuf iUserName; |
|
137 |
|
138 /** |
|
139 * Domain name part of the parsed SIP URI. |
|
140 * Own. |
|
141 */ |
|
142 RBuf iDomain; |
|
143 |
|
144 /** |
|
145 * Display name from the parsed SIP URI if available. |
|
146 * Own. |
|
147 */ |
|
148 RBuf iDisplayName; |
|
149 |
|
150 }; |
|
151 |
|
152 #endif // C_CSVTSIPURIPARSER_H |