1 /* |
|
2 * Copyright (c) 2008-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: Main class for svtmatching. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <implementationproxy.h> |
|
20 #include <data_caging_path_literals.hrh> |
|
21 |
|
22 #include "svtmatching.h" |
|
23 #include "svtsettingshandler.h" |
|
24 #include "svturiparser.h" |
|
25 |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 void CSvtMatching::ConstructL() |
|
33 { |
|
34 iSettingsHandler = CSvtSettingsHandler::NewL(); |
|
35 iUriParser = CSvtUriParser::NewL(); |
|
36 } |
|
37 |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CSvtMatching::CSvtMatching() |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CSvtMatching* CSvtMatching::NewL() |
|
51 { |
|
52 CSvtMatching* self = new ( ELeave ) CSvtMatching; |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CSvtMatching::~CSvtMatching() |
|
64 { |
|
65 delete iUriParser; |
|
66 delete iSettingsHandler; |
|
67 delete iOriginalAddress; |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Initializes plugin |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CSvtMatching::InitializeL( |
|
76 TUint aServiceId, |
|
77 const TDesC& aOrigAddress ) |
|
78 { |
|
79 if ( 0 == aOrigAddress.Length() || |
|
80 0 == aServiceId ) |
|
81 { |
|
82 User::Leave( KErrArgument ); |
|
83 } |
|
84 |
|
85 iSettingsHandler->InitializeSettingsL( aServiceId ); |
|
86 |
|
87 // Check original address for spaces. If found found begin or end |
|
88 // of string, remove them. |
|
89 RBuf checkedAddress; |
|
90 CleanupClosePushL( checkedAddress ); |
|
91 iUriParser->CheckForSpacesL( aOrigAddress, checkedAddress ); |
|
92 |
|
93 // Realloc buffer |
|
94 delete iOriginalAddress; |
|
95 iOriginalAddress = NULL; |
|
96 iOriginalAddress = HBufC::NewL( checkedAddress.Length() ); |
|
97 iOriginalAddress->Des().Copy( checkedAddress ); |
|
98 CleanupStack::PopAndDestroy( &checkedAddress ); |
|
99 |
|
100 iServiceId = aServiceId; |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // Gets address and meaningful digits for matching. |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 TInt CSvtMatching::GetAddressForMatching( |
|
109 RBuf& aParsedAddress, |
|
110 TInt& aMeaningfulDigits ) |
|
111 { |
|
112 if( iServiceId == 0 || !iOriginalAddress ) |
|
113 { |
|
114 return KErrNotReady; |
|
115 } |
|
116 |
|
117 aParsedAddress.Close(); |
|
118 TInt ret = aParsedAddress.Create( iOriginalAddress->Length() ); |
|
119 |
|
120 if ( KErrNone == ret ) |
|
121 { |
|
122 TRAP( ret, iUriParser->ParseAddressL( |
|
123 iSettingsHandler->IgnoreDomainPartValue(), |
|
124 *iOriginalAddress, |
|
125 aParsedAddress ) ); |
|
126 |
|
127 if ( KErrNone == ret ) |
|
128 { |
|
129 aMeaningfulDigits = iSettingsHandler->MeaningfulDigits(); |
|
130 } |
|
131 } |
|
132 return ret; |
|
133 } |
|
134 |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Gets contact store uris |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 TInt CSvtMatching::GetContactStoreUris( CDesCArray& aStoreUris ) |
|
141 { |
|
142 if( iServiceId == 0 ) |
|
143 { |
|
144 return KErrNotReady; |
|
145 } |
|
146 |
|
147 return iSettingsHandler->GetContactStoreUris( aStoreUris ); |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // Gets remote party name |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 TInt CSvtMatching::GetRemotePartyName( RBuf& aRemotePartyName ) |
|
156 { |
|
157 if( iServiceId == 0 || !iOriginalAddress ) |
|
158 { |
|
159 return KErrNotReady; |
|
160 } |
|
161 |
|
162 aRemotePartyName.Close(); |
|
163 |
|
164 TInt ret = iUriParser->DisplayNameFromUri( |
|
165 *iOriginalAddress, |
|
166 aRemotePartyName ); |
|
167 |
|
168 if ( KErrNoMemory == ret ) |
|
169 { |
|
170 return ret; |
|
171 } |
|
172 |
|
173 // If displayname is not found aRemotePartyName |
|
174 // will be empty and return value is still KErrNone. |
|
175 return KErrNone; |
|
176 } |
|
177 |
|
178 |
|
179 |
|
180 // ========================== OTHER EXPORTED FUNCTIONS ======================= |
|
181 |
|
182 // |
|
183 // Rest of the file is for ECom initialization. |
|
184 // |
|
185 |
|
186 // Map the interface UIDs |
|
187 const TImplementationProxy ImplementationTable[] = |
|
188 { |
|
189 IMPLEMENTATION_PROXY_ENTRY( |
|
190 0x2001E2A5, CSvtMatching::NewL ) |
|
191 }; |
|
192 |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // ImplementationGroupProxy implements for ECom |
|
196 // Exported proxy for instantiation method resolution |
|
197 // Returns: ImplementationTable |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
201 TInt& aTableCount ) |
|
202 { |
|
203 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
204 return ImplementationTable; |
|
205 } |
|
206 |
|