31
|
1 |
/*
|
|
2 |
* Copyright (c) 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: QT contact resolver interface
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// SYSTEM INCLUDES
|
|
19 |
#include "qtcontacts.h"
|
|
20 |
#include "qcontactdetailfilter.h"
|
|
21 |
#include <QList>
|
|
22 |
|
|
23 |
// USER INCLUDES
|
|
24 |
#include "ccscontactsresolver.h"
|
|
25 |
// ======================== Member Functions ====================
|
|
26 |
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
// CCsContactsResolver::ContactsResolver
|
|
29 |
// @see contactsresolver.h
|
|
30 |
// ----------------------------------------------------------------------------
|
|
31 |
CCsContactsResolver::CCsContactsResolver(QContactManager* manager):
|
|
32 |
mPhonebookManager(manager)
|
|
33 |
{
|
|
34 |
// do nothing
|
|
35 |
}
|
|
36 |
// ----------------------------------------------------------------------------
|
|
37 |
// CCsContactsResolver::~ContactsResolver
|
|
38 |
// @see contactsresolver.h
|
|
39 |
// ----------------------------------------------------------------------------
|
|
40 |
CCsContactsResolver::~CCsContactsResolver()
|
|
41 |
{
|
|
42 |
// do nothing
|
|
43 |
}
|
|
44 |
|
|
45 |
// ----------------------------------------------------------------------------
|
|
46 |
// CCsContactsResolver::resolveContact
|
|
47 |
// @see contactsresolver.h
|
|
48 |
// ----------------------------------------------------------------------------
|
|
49 |
bool CCsContactsResolver::resolveContact(
|
|
50 |
const QString &address,
|
|
51 |
CCsContactDetail &contactDetail)
|
|
52 |
{
|
|
53 |
QContactDetailFilter phoneFilter;
|
|
54 |
phoneFilter.setDetailDefinitionName(
|
|
55 |
QContactPhoneNumber::DefinitionName,
|
|
56 |
QContactPhoneNumber::FieldNumber);
|
|
57 |
|
|
58 |
phoneFilter.setValue(address);
|
|
59 |
phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
|
|
60 |
|
|
61 |
QList<QContact> matchingContacts = mPhonebookManager->contacts(phoneFilter);
|
|
62 |
|
|
63 |
if ( matchingContacts.count() > 0 ) {
|
|
64 |
QContact match = matchingContacts.at(0);
|
|
65 |
// Fill the contact details
|
|
66 |
contactDetail.contactId = match.localId();
|
|
67 |
contactDetail.displayName = match.displayLabel();
|
|
68 |
return true;
|
|
69 |
}
|
|
70 |
return false;
|
|
71 |
}
|
|
72 |
|
|
73 |
// ----------------------------------------------------------------------------
|
|
74 |
// CCsContactsResolver::resolveContactId
|
|
75 |
// @see contactsresolver.h
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
void CCsContactsResolver::resolveContactId(
|
|
78 |
const quint32 &contactId,
|
|
79 |
CCsContactDetail &contactDetail)
|
|
80 |
{
|
|
81 |
// Fetch back the persisted contact
|
|
82 |
QContact contact = mPhonebookManager->contact(contactId);
|
|
83 |
contactDetail.contactId = contact.localId();
|
|
84 |
|
|
85 |
contactDetail.displayName = contact.displayLabel();
|
|
86 |
|
|
87 |
QList<QContactPhoneNumber> numbers = contact.details<QContactPhoneNumber>();
|
|
88 |
int numberCount = numbers.count();
|
|
89 |
|
|
90 |
for ( int a=0; a<numberCount ;++a)
|
|
91 |
{
|
|
92 |
QString phoneNumber= numbers.at(a).number();
|
|
93 |
contactDetail.addressList.append(phoneNumber);
|
|
94 |
}
|
|
95 |
}
|
|
96 |
|
|
97 |
// EOF
|