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 #include "csvtlogging.h" |
|
20 #include "csvtsettingshandler.h" |
|
21 #include "svtphonenumbervalidator.h" |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // CSvtLogging::CSvtLogging |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CSvtLogging::CSvtLogging() |
|
30 { |
|
31 |
|
32 } |
|
33 |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CSvtLogging::NewL |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CSvtLogging* CSvtLogging::NewL() |
|
40 { |
|
41 CSvtLogging* self = CSvtLogging::NewLC(); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CSvtLogging::NewLC |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CSvtLogging* CSvtLogging::NewLC() |
|
52 { |
|
53 CSvtLogging* self = new( ELeave ) CSvtLogging; |
|
54 CleanupStack::PushL( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CSvtLogging::~CSvtLogging |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CSvtLogging::~CSvtLogging() |
|
64 { |
|
65 delete iParser; |
|
66 delete iSettingsHandler; |
|
67 iSipUserName.Close(); |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // From class CLoggingPluginInterface. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CSvtLogging::InitializeL( |
|
76 TUint aServiceId, const TDesC& aOrigAddress ) |
|
77 { |
|
78 __ASSERT_ALWAYS( aOrigAddress.Length() != 0, User::Leave( KErrArgument ) ); |
|
79 |
|
80 iSipUserName.Close(); |
|
81 |
|
82 delete iSettingsHandler; |
|
83 iSettingsHandler = NULL; |
|
84 iSettingsHandler = CreateSvtSettingsHandlerL( aServiceId ); |
|
85 |
|
86 delete iParser; |
|
87 iParser = NULL; |
|
88 TInt domainClipSetting = iSettingsHandler->DomainPartClippingSetting(); |
|
89 TRAPD( result, iParser = |
|
90 CreateSipUriParserL( aOrigAddress, domainClipSetting ) ); |
|
91 if ( KErrNone != result ) |
|
92 { |
|
93 if ( KErrNoMemory == result ) |
|
94 { |
|
95 User::Leave( KErrNoMemory ); |
|
96 } |
|
97 else |
|
98 { |
|
99 // plugin is initialized with user name only |
|
100 iSipUserName.Assign( aOrigAddress.AllocL() ); |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // From class CLoggingPluginInterface. |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CSvtLogging::GetPhoneNumber( RBuf& aPhoneNumber ) |
|
111 { |
|
112 TInt result( KErrNone ); |
|
113 |
|
114 if ( iParser ) |
|
115 { |
|
116 result = iParser->GetPhoneNumber( aPhoneNumber ); |
|
117 } |
|
118 else if ( iSipUserName.Length() != 0 ) |
|
119 { |
|
120 if ( SvtPhoneNumberValidator::IsValidNumber( iSipUserName ) ) |
|
121 { |
|
122 if ( aPhoneNumber.MaxLength() < iSipUserName.Length() ) |
|
123 { |
|
124 result = aPhoneNumber.ReAlloc( iSipUserName.Length() ); |
|
125 } |
|
126 |
|
127 if ( KErrNone == result ) |
|
128 { |
|
129 aPhoneNumber.Copy( iSipUserName ); |
|
130 } |
|
131 } |
|
132 } |
|
133 else |
|
134 { |
|
135 result = KErrNotReady; |
|
136 } |
|
137 |
|
138 return result; |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // From class CLoggingPluginInterface. |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CSvtLogging::GetVoipAddress( RBuf& aVoipAddress ) |
|
147 { |
|
148 TInt result( KErrNone ); |
|
149 |
|
150 if ( iParser ) |
|
151 { |
|
152 result = iParser->GetVoipAddress( aVoipAddress ); |
|
153 } |
|
154 else if ( iSipUserName.Length() != 0 ) |
|
155 { |
|
156 if ( aVoipAddress.MaxLength() < iSipUserName.Length() ) |
|
157 { |
|
158 result = aVoipAddress.ReAlloc( iSipUserName.Length() ); |
|
159 } |
|
160 |
|
161 if ( KErrNone == result ) |
|
162 { |
|
163 aVoipAddress.Copy( iSipUserName ); |
|
164 } |
|
165 } |
|
166 else |
|
167 { |
|
168 result = KErrNotReady; |
|
169 } |
|
170 |
|
171 return result; |
|
172 } |
|
173 |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // From class CLoggingPluginInterface. |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 TInt CSvtLogging::GetMyAddress( RBuf& aMyAddress ) |
|
180 { |
|
181 TInt result( KErrNotReady ); |
|
182 if ( iSettingsHandler ) |
|
183 { |
|
184 TRAP( result, iSettingsHandler->GetUserAorL( aMyAddress ) ); |
|
185 } |
|
186 |
|
187 return result; |
|
188 } |
|
189 |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // From class CLoggingPluginInterface. |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 TInt CSvtLogging::GetRemotePartyName( RBuf& aRemotePartyName ) |
|
196 { |
|
197 TInt result( KErrNone ); |
|
198 |
|
199 if ( iParser ) |
|
200 { |
|
201 result = iParser->GetDisplayName( aRemotePartyName ); |
|
202 } |
|
203 else if ( iSipUserName.Length() != 0 ) |
|
204 { |
|
205 aRemotePartyName = KNullDesC(); |
|
206 } |
|
207 else |
|
208 { |
|
209 return KErrNotReady; |
|
210 } |
|
211 |
|
212 return result; |
|
213 } |
|
214 |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // CSvtLogging::CreateSvtSettingsHandlerL() |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 CSvtSettingsHandler* CSvtLogging::CreateSvtSettingsHandlerL( |
|
221 TUint aServiceId ) const |
|
222 { |
|
223 return CSvtSettingsHandler::NewL( aServiceId ); |
|
224 } |
|
225 |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CSvtLogging::CreateSipUriParserL() |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 CSvtSipUriParser* CSvtLogging::CreateSipUriParserL( |
|
232 const TDesC& aOrigAddress, TInt aDomainClipSetting ) const |
|
233 { |
|
234 return CSvtSipUriParser::NewL( aOrigAddress, |
|
235 ConvertToUriParserSetting( aDomainClipSetting ) ); |
|
236 } |
|
237 |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // CSvtLogging::ConvertToUriParserSetting() |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 CSvtSipUriParser::TDomainPartClippingSetting |
|
244 CSvtLogging::ConvertToUriParserSetting( |
|
245 TInt aDomainClipSetting ) const |
|
246 { |
|
247 CSvtSipUriParser::TDomainPartClippingSetting setting( |
|
248 CSvtSipUriParser::ENoClipping ); |
|
249 |
|
250 switch ( aDomainClipSetting ) |
|
251 { |
|
252 case 0: |
|
253 setting = CSvtSipUriParser::ENoClipping; |
|
254 break; |
|
255 case 1: |
|
256 setting = CSvtSipUriParser::EClipDomainIfNumber; |
|
257 break; |
|
258 case 2: |
|
259 setting = CSvtSipUriParser::EClipDomain; |
|
260 break; |
|
261 default: |
|
262 ASSERT( EFalse ); |
|
263 } |
|
264 |
|
265 return setting; |
|
266 } |
|