62
|
1 |
/*
|
|
2 |
* Copyright (c) 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: Implementation of CPhCntSpeedDialImpl class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <spdiadialogs.h>
|
|
20 |
#include <MVPbkContactLink.h>
|
|
21 |
#include <PbkFields.hrh>
|
|
22 |
#include <avkon.mbg>
|
|
23 |
#include <eikimage.h>
|
|
24 |
#include <aknconsts.h>
|
|
25 |
|
|
26 |
#include "CPhCntSpeedDialMonitor.h"
|
|
27 |
#include "cphcntspeeddialimpl.h"
|
|
28 |
#include "cphcntspeeddialcontactlinkfetch.h"
|
|
29 |
#include "MPhoneCntPbkOwner.h"
|
|
30 |
#include "cphcntfetchcontact.h"
|
|
31 |
#include "CPhCntContactStores.h"
|
|
32 |
#include "MPhCntContactManager.h"
|
|
33 |
#include "CPhCntContact.h"
|
|
34 |
#include "cphcntvpbkcontactid.h"
|
|
35 |
#include "CPhCntContactManager.h"
|
|
36 |
|
|
37 |
// ======== MEMBER FUNCTIONS ========
|
|
38 |
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
// Default constructor.
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
CPhCntSpeedDialImpl::CPhCntSpeedDialImpl( MPhoneCntPbkOwner& aPbkOwner ) :
|
|
44 |
iContactManager( *aPbkOwner.ContactManager() ),
|
|
45 |
iPbkOwner( aPbkOwner )
|
|
46 |
{
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// CPhCntSpeedDialImpl::ConstructL
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
void CPhCntSpeedDialImpl::ConstructL()
|
|
54 |
{
|
|
55 |
iSpeedDialContactLinkFetcher =
|
|
56 |
CPhCntSpeedDialContactLinkFetch::NewL( iContactManager );
|
|
57 |
|
|
58 |
iContactStores = CPhCntContactStores::NewL( iContactManager );
|
|
59 |
|
|
60 |
iContactFetcher = CPhCntFetchContact::NewL( *iContactStores );
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// CPhCntSpeedDialImpl::FetchContact
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
TInt CPhCntSpeedDialImpl::FetchContact(
|
|
68 |
TInt aSpeedDialPosition,
|
|
69 |
CPhCntContact*& aContact )
|
|
70 |
{
|
|
71 |
TRAPD( err,
|
|
72 |
const MVPbkContactLink& linkToSpeedDialContact =
|
|
73 |
iSpeedDialContactLinkFetcher->FetchSpeedDialLinkL(
|
|
74 |
aSpeedDialPosition );
|
|
75 |
|
|
76 |
|
|
77 |
err =
|
|
78 |
iContactFetcher->FetchContact( linkToSpeedDialContact, aContact );
|
|
79 |
)
|
|
80 |
return err;
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// CPhCntSpeedDialImpl::CopyNumberL
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
void CPhCntSpeedDialImpl::CopyNumberL(
|
|
88 |
TDes& aCopyTo,
|
|
89 |
const TDesC& aNumber )
|
|
90 |
{
|
|
91 |
if( aCopyTo.MaxLength() >= aNumber.Length() )
|
|
92 |
{
|
|
93 |
aCopyTo.Copy( aNumber );
|
|
94 |
}
|
|
95 |
else
|
|
96 |
{
|
|
97 |
User::Leave( KErrArgument );
|
|
98 |
}
|
|
99 |
}
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// CPhCntSpeedDialImpl::CopyContactInfoToFieldInfoL
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
void CPhCntSpeedDialImpl::CopyContactInfoToFieldInfoL(
|
|
105 |
CPhCntContact& aContact,
|
|
106 |
TInt aSpeedDialPosition,
|
|
107 |
TSpdDialFieldInfo& aFieldInfo )
|
|
108 |
{
|
|
109 |
TPhCntNumber speedDial = aContact.SpeedDialNumber( aSpeedDialPosition );
|
|
110 |
aFieldInfo.iNumberType = speedDial.Type();
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
// CPhCntSpeedDialImpl::NewL
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
CPhCntSpeedDialImpl* CPhCntSpeedDialImpl::NewL(
|
|
118 |
MPhoneCntPbkOwner& aPbkOwner )
|
|
119 |
{
|
|
120 |
CPhCntSpeedDialImpl* self =
|
|
121 |
CPhCntSpeedDialImpl::NewLC( aPbkOwner );
|
|
122 |
|
|
123 |
CleanupStack::Pop( self );
|
|
124 |
return self;
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
// CPhCntSpeedDialImpl::NewLC
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
CPhCntSpeedDialImpl* CPhCntSpeedDialImpl::NewLC(
|
|
132 |
MPhoneCntPbkOwner& aPbkOwner )
|
|
133 |
{
|
|
134 |
CPhCntSpeedDialImpl* self = new( ELeave )
|
|
135 |
CPhCntSpeedDialImpl( aPbkOwner );
|
|
136 |
|
|
137 |
CleanupStack::PushL( self );
|
|
138 |
self->ConstructL();
|
|
139 |
return self;
|
|
140 |
}
|
|
141 |
|
|
142 |
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
// Destructor
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
CPhCntSpeedDialImpl::~CPhCntSpeedDialImpl()
|
|
148 |
{
|
|
149 |
delete iContactFetcher;
|
|
150 |
delete iContactStores;
|
|
151 |
delete iSpeedDialContactLinkFetcher;
|
|
152 |
delete iSpdDial;
|
|
153 |
}
|
|
154 |
|
|
155 |
// ---------------------------------------------------------------------------
|
|
156 |
// CPhCntSpeedDialImpl::GetSpeedDialFieldInfoL
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
void CPhCntSpeedDialImpl::GetSpeedDialFieldInfoL(
|
|
160 |
TInt aSpeedDialPosition,
|
|
161 |
TSpdDialFieldInfo& aFieldInfo )
|
|
162 |
{
|
|
163 |
CPhCntContact* contact = NULL;
|
|
164 |
User::LeaveIfError( FetchContact( aSpeedDialPosition, contact ) );
|
|
165 |
|
|
166 |
CleanupStack::PushL( contact );
|
|
167 |
|
|
168 |
CopyContactInfoToFieldInfoL( *contact, aSpeedDialPosition, aFieldInfo );
|
|
169 |
|
|
170 |
CleanupStack::PopAndDestroy( contact );
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
// CPhCntSpeedDialImpl::GetSpeedDialFieldL
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
TInt CPhCntSpeedDialImpl::GetSpeedDialFieldL(
|
|
178 |
TInt aSpeedDialPosition,
|
|
179 |
TDes& aPhoneNumber )
|
|
180 |
{
|
|
181 |
CPhCntContact* contact = NULL;
|
|
182 |
const TInt err = FetchContact( aSpeedDialPosition, contact );
|
|
183 |
if( !err )
|
|
184 |
{
|
|
185 |
CleanupStack::PushL( contact );
|
|
186 |
TPhCntNumber speedDial( contact->SpeedDialNumber( aSpeedDialPosition ) );
|
|
187 |
CopyNumberL( aPhoneNumber, speedDial.Number() );
|
|
188 |
CleanupStack::PopAndDestroy( contact );
|
|
189 |
}
|
|
190 |
return err;
|
|
191 |
}
|
|
192 |
|
|
193 |
// ---------------------------------------------------------------------------
|
|
194 |
// CPhCntSpeedDialImpl::GetSpeedDialFieldL
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
//
|
|
197 |
TInt CPhCntSpeedDialImpl::GetSpeedDialFieldL(
|
|
198 |
TInt aSpeedDialPosition,
|
|
199 |
TDes& aPhoneNumber,
|
|
200 |
TSpdDialFieldInfo& aFieldInfo )
|
|
201 |
{
|
|
202 |
CPhCntContact* contact = NULL;
|
|
203 |
const TInt err = FetchContact( aSpeedDialPosition, contact );
|
|
204 |
|
|
205 |
if( !err )
|
|
206 |
{
|
|
207 |
CleanupStack::PushL( contact );
|
|
208 |
TPhCntNumber speedDial( contact->SpeedDialNumber( aSpeedDialPosition ) );
|
|
209 |
CopyNumberL( aPhoneNumber, speedDial.Number() );
|
|
210 |
CopyContactInfoToFieldInfoL( *contact, aSpeedDialPosition, aFieldInfo );
|
|
211 |
CleanupStack::PopAndDestroy( contact );
|
|
212 |
}
|
|
213 |
return err;
|
|
214 |
}
|
|
215 |
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
// CPhCntSpeedDialImpl::FetchNumberL
|
|
218 |
// -----------------------------------------------------------------------------
|
|
219 |
//
|
|
220 |
TInt CPhCntSpeedDialImpl::FetchNumberL(
|
|
221 |
TInt aSpeedDialPosition,
|
|
222 |
TDes& aPhoneNumber )
|
|
223 |
{
|
|
224 |
CPhCntContact* contact = NULL;
|
|
225 |
TInt err = FetchContact( aSpeedDialPosition, contact );
|
|
226 |
|
|
227 |
if( !err )
|
|
228 |
{
|
|
229 |
CleanupStack::PushL( contact );
|
|
230 |
TPhCntNumber speedDial( contact->SpeedDialNumber( aSpeedDialPosition ) );
|
|
231 |
CopyNumberL( aPhoneNumber, speedDial.Number() );
|
|
232 |
CleanupStack::PopAndDestroy( contact );
|
|
233 |
}
|
|
234 |
return err;
|
|
235 |
}
|
|
236 |
|
|
237 |
// -----------------------------------------------------------------------------
|
|
238 |
// CPhCntSpeedDialImpl::AssignSpeedDialFieldL
|
|
239 |
// -----------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
TInt CPhCntSpeedDialImpl::AssignSpeedDialFieldL(
|
|
242 |
TInt aSpeedDialPosition,
|
|
243 |
TDes& aPhoneNumber )
|
|
244 |
{
|
|
245 |
CVPbkContactManager* contactMg =
|
|
246 |
&iPbkOwner.ContactManager()->ContactManager();
|
|
247 |
if ( !iSpdDial )
|
|
248 |
{
|
|
249 |
iSpdDial = CSpdiaDialogs::NewL( *contactMg );
|
|
250 |
}
|
|
251 |
MVPbkContactLink *link = NULL;
|
|
252 |
TInt err = iSpdDial->ShowAssign( aSpeedDialPosition, link );
|
|
253 |
delete iSpdDial;
|
|
254 |
iSpdDial = NULL;
|
|
255 |
delete link;
|
|
256 |
link = NULL;
|
|
257 |
|
|
258 |
if ( err == KErrNone )
|
|
259 |
{
|
|
260 |
err = FetchNumberL( aSpeedDialPosition, aPhoneNumber );
|
|
261 |
}
|
|
262 |
return err;
|
|
263 |
}
|
|
264 |
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// CPhCntSpeedDialImpl::AssignSpeedDialFieldL
|
|
267 |
// -----------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
TInt CPhCntSpeedDialImpl::AssignSpeedDialFieldL(
|
|
270 |
TInt aSpeedDialPosition,
|
|
271 |
TDes& aPhoneNumber,
|
|
272 |
TSpdDialFieldInfo& aFieldInfo )
|
|
273 |
{
|
|
274 |
TInt err = AssignSpeedDialFieldL( aSpeedDialPosition, aPhoneNumber );
|
|
275 |
if ( err == KErrNone )
|
|
276 |
{
|
|
277 |
GetSpeedDialFieldInfoL( aSpeedDialPosition, aFieldInfo );
|
|
278 |
}
|
|
279 |
return err;
|
|
280 |
}
|
|
281 |
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
// CPhCntSpeedDialImpl::Cancel
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
void CPhCntSpeedDialImpl::Cancel()
|
|
287 |
{
|
|
288 |
if ( iSpdDial )
|
|
289 |
{
|
|
290 |
iSpdDial->Cancel();
|
|
291 |
}
|
|
292 |
}
|
|
293 |
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
// CPhCntSpeedDialImpl::CreateNumberTypeIconLC
|
|
296 |
// -----------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
CEikImage* CPhCntSpeedDialImpl::CreateNumberTypeIconLC(
|
|
299 |
TInt aNumberType )
|
|
300 |
{
|
|
301 |
TUint icon;
|
|
302 |
TUint mask;
|
|
303 |
switch ( aNumberType )
|
|
304 |
{
|
|
305 |
case EPbkFieldIdPhoneNumberMobile:
|
|
306 |
icon = EMbmAvkonQgn_prop_nrtyp_mobile;
|
|
307 |
mask = EMbmAvkonQgn_prop_nrtyp_mobile_mask;
|
|
308 |
break;
|
|
309 |
case EPbkFieldIdPagerNumber:
|
|
310 |
icon = EMbmAvkonQgn_prop_nrtyp_pager;
|
|
311 |
mask = EMbmAvkonQgn_prop_nrtyp_pager_mask;
|
|
312 |
break;
|
|
313 |
case EPbkFieldIdPhoneNumberVideo:
|
|
314 |
icon = EMbmAvkonQgn_prop_nrtyp_video;
|
|
315 |
mask = EMbmAvkonQgn_prop_nrtyp_video_mask;
|
|
316 |
break;
|
|
317 |
case EPbkFieldIdVOIP:
|
|
318 |
icon = EMbmAvkonQgn_prop_nrtyp_voip;
|
|
319 |
mask = EMbmAvkonQgn_prop_nrtyp_voip_mask;
|
|
320 |
break;
|
|
321 |
case EPbkFieldIdPhoneNumberGeneral:
|
|
322 |
case EPbkFieldIdPhoneNumberHome:
|
|
323 |
case EPbkFieldIdPhoneNumberWork:
|
|
324 |
case EPbkFieldIdFaxNumber:
|
|
325 |
default:
|
|
326 |
icon = EMbmAvkonQgn_prop_nrtyp_phone;
|
|
327 |
mask = EMbmAvkonQgn_prop_nrtyp_phone_mask;
|
|
328 |
break;
|
|
329 |
}
|
|
330 |
|
|
331 |
CEikImage* iconImg = new ( ELeave ) CEikImage;
|
|
332 |
CleanupStack::PushL( iconImg );
|
|
333 |
|
|
334 |
CFbsBitmap* iconBmp = new ( ELeave ) CFbsBitmap;
|
|
335 |
CleanupStack::PushL( iconBmp );
|
|
336 |
User::LeaveIfError( iconBmp->Load(
|
|
337 |
KAvkonBitmapFile(),
|
|
338 |
icon,
|
|
339 |
ETrue ) );
|
|
340 |
|
|
341 |
CFbsBitmap* iconMaskBmp = new ( ELeave ) CFbsBitmap;
|
|
342 |
CleanupStack::PushL( iconMaskBmp );
|
|
343 |
User::LeaveIfError( iconMaskBmp->Load(
|
|
344 |
KAvkonBitmapFile(),
|
|
345 |
mask,
|
|
346 |
ETrue ) );
|
|
347 |
|
|
348 |
CleanupStack::Pop( iconMaskBmp );
|
|
349 |
CleanupStack::Pop( iconBmp );
|
|
350 |
|
|
351 |
iconImg->SetPicture( iconBmp, iconMaskBmp );
|
|
352 |
iconImg->SetPictureOwnedExternally( EFalse );
|
|
353 |
|
|
354 |
return iconImg;
|
|
355 |
}
|
|
356 |
|
|
357 |
// End of File
|