author | Pat Downey <patd@symbian.org> |
Wed, 01 Sep 2010 12:28:47 +0100 | |
branch | RCL_3 |
changeset 45 | a9c0808a1095 |
parent 10 | fc9cf246af83 |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2007 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 the License "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 <MVPbkFieldType.h> |
|
20 |
||
21 |
#include "searchfields.h" |
|
22 |
#include "singlecontact.h" |
|
23 |
||
24 |
//Initialization of the mapping table |
|
25 |
MAPPING_TABLE mappingTable[SIZEOFTABLE] = |
|
26 |
{ |
|
27 |
// {R_VPBK_SYNCRONIZATION_FIELD_PROPERTY , _L8("Sync")}, |
|
28 |
{R_VPBK_FIELD_TYPE_LASTNAME , _L8("LastName")}, |
|
29 |
// {R_VPBK_FIELD_TYPE_LASTNAMEREADING , _L8("LastNameReading")}, |
|
30 |
{R_VPBK_FIELD_TYPE_FIRSTNAME , _L8("FirstName")}, |
|
31 |
// {R_VPBK_FIELD_TYPE_FIRSTNAMEREADING , _L8("FirstNameReading")}, |
|
32 |
{R_VPBK_FIELD_TYPE_PREFIX , _L8("Prefix")}, |
|
33 |
{R_VPBK_FIELD_TYPE_SUFFIX , _L8("Suffix")}, |
|
34 |
{R_VPBK_FIELD_TYPE_SECONDNAME , _L8("SecondName")}, |
|
35 |
{R_VPBK_FIELD_TYPE_LANDPHONEHOME , _L8("LandPhoneHome")}, |
|
36 |
{R_VPBK_FIELD_TYPE_MOBILEPHONEHOME , _L8("MobilePhoneHome")}, |
|
37 |
{R_VPBK_FIELD_TYPE_VIDEONUMBERHOME , _L8("VideoNumberHome")}, |
|
38 |
{R_VPBK_FIELD_TYPE_FAXNUMBERHOME , _L8("FaxNumberHome")}, |
|
39 |
{R_VPBK_FIELD_TYPE_VOIPHOME , _L8("VoipHome")}, |
|
40 |
{R_VPBK_FIELD_TYPE_EMAILHOME , _L8("EmailHome")}, |
|
41 |
{R_VPBK_FIELD_TYPE_URLHOME , _L8("URLHome")}, |
|
42 |
{R_VPBK_FIELD_TYPE_ADDRLABELHOME , _L8("AddrLabelHome")}, |
|
43 |
{R_VPBK_FIELD_TYPE_ADDRPOHOME , _L8("AddrPOHome")}, |
|
44 |
{R_VPBK_FIELD_TYPE_ADDREXTHOME , _L8("AddrEXTHome")}, |
|
45 |
{R_VPBK_FIELD_TYPE_ADDRSTREETHOME , _L8("AddrStreetHome")}, |
|
46 |
{R_VPBK_FIELD_TYPE_ADDRLOCALHOME , _L8("AddrLocalHome")}, |
|
47 |
{R_VPBK_FIELD_TYPE_ADDRREGIONHOME , _L8("AddrRegionHome")}, |
|
48 |
{R_VPBK_FIELD_TYPE_ADDRPOSTCODEHOME , _L8("AddrPostCodeHome")}, |
|
49 |
{R_VPBK_FIELD_TYPE_ADDRCOUNTRYHOME , _L8("AddrCountryHome")}, |
|
50 |
{R_VPBK_FIELD_TYPE_JOBTITLE , _L8("JobTitle")}, |
|
51 |
{R_VPBK_FIELD_TYPE_COMPANYNAME , _L8("CompanyName")}, |
|
52 |
{R_VPBK_FIELD_TYPE_LANDPHONEWORK , _L8("LandPhoneWork")}, |
|
53 |
{R_VPBK_FIELD_TYPE_MOBILEPHONEWORK , _L8("MobilePhoneWork")}, |
|
54 |
{R_VPBK_FIELD_TYPE_VIDEONUMBERWORK , _L8("VideoNumberWork")}, |
|
55 |
{R_VPBK_FIELD_TYPE_FAXNUMBERWORK , _L8("FaxNumberWork")}, |
|
56 |
{R_VPBK_FIELD_TYPE_VOIPWORK , _L8("VoipWork")}, |
|
57 |
{R_VPBK_FIELD_TYPE_EMAILWORK , _L8("EmailWork")}, |
|
58 |
{R_VPBK_FIELD_TYPE_URLWORK , _L8("URLWork")}, |
|
59 |
{R_VPBK_FIELD_TYPE_ADDRLABELWORK , _L8("AddrLabelWork")}, |
|
60 |
{R_VPBK_FIELD_TYPE_ADDRPOWORK , _L8("AddrPOWork")}, |
|
61 |
{R_VPBK_FIELD_TYPE_ADDREXTWORK , _L8("AddrEXTWork")}, |
|
62 |
{R_VPBK_FIELD_TYPE_ADDRSTREETWORK , _L8("AddrStreetWork")}, |
|
63 |
{R_VPBK_FIELD_TYPE_ADDRLOCALWORK , _L8("AddrLocalWork")}, |
|
64 |
{R_VPBK_FIELD_TYPE_ADDRREGIONWORK , _L8("AddrRegionWork")}, |
|
65 |
{R_VPBK_FIELD_TYPE_ADDRPOSTCODEWORK , _L8("AddrPostCodeWork")}, |
|
66 |
{R_VPBK_FIELD_TYPE_ADDRCOUNTRYWORK , _L8("AddrCountryWork")}, |
|
67 |
{R_VPBK_FIELD_TYPE_LANDPHONEGEN , _L8("LandPhoneGen")}, |
|
68 |
{R_VPBK_FIELD_TYPE_MOBILEPHONEGEN , _L8("MobilePhoneGen")}, |
|
69 |
{R_VPBK_FIELD_TYPE_VIDEONUMBERGEN , _L8("VideoNumberGen")}, |
|
70 |
{R_VPBK_FIELD_TYPE_FAXNUMBERGEN , _L8("FaxNumberGen")}, |
|
71 |
{R_VPBK_FIELD_TYPE_VOIPGEN , _L8("VOIPGen")}, |
|
72 |
{R_VPBK_FIELD_TYPE_POC , _L8("POC")}, |
|
73 |
{R_VPBK_FIELD_TYPE_SWIS , _L8("SWIS")}, |
|
74 |
{R_VPBK_FIELD_TYPE_SIP , _L8("SIP")}, |
|
75 |
{R_VPBK_FIELD_TYPE_EMAILGEN , _L8("EmailGen")}, |
|
76 |
{R_VPBK_FIELD_TYPE_URLGEN , _L8("URLGen")}, |
|
77 |
{R_VPBK_FIELD_TYPE_ADDRLABELGEN , _L8("AddrLabelGen")}, |
|
78 |
{R_VPBK_FIELD_TYPE_ADDRPOGEN , _L8("AddrPOGen")}, |
|
79 |
{R_VPBK_FIELD_TYPE_ADDREXTGEN , _L8("AddrExtGen")}, |
|
80 |
{R_VPBK_FIELD_TYPE_ADDRSTREETGEN , _L8("AddrStreetGen")}, |
|
81 |
{R_VPBK_FIELD_TYPE_ADDRLOCALGEN , _L8("AddrLocalGen")}, |
|
82 |
{R_VPBK_FIELD_TYPE_ADDRREGIONGEN , _L8("AddrRegionGen")}, |
|
83 |
{R_VPBK_FIELD_TYPE_ADDRPOSTCODEGEN , _L8("AddrPostCodeGen")}, |
|
84 |
{R_VPBK_FIELD_TYPE_ADDRCOUNTRYGEN , _L8("AddrCountryGen")}, |
|
85 |
{R_VPBK_FIELD_TYPE_PAGERNUMBER , _L8("PageNumber")}, |
|
86 |
{R_VPBK_FIELD_TYPE_DTMFSTRING , _L8("DTMFString")}, |
|
87 |
// {R_VPBK_FIELD_TYPE_WVADDRESS , _L8("WVAddress")}, |
|
88 |
{R_VPBK_FIELD_TYPE_DATE , _L8("Date")}, |
|
89 |
{R_VPBK_FIELD_TYPE_NOTE , _L8("Note")}, |
|
90 |
// {R_VPBK_FIELD_TYPE_THUMBNAILPIC , _L8("ThumbNailPic")}, |
|
91 |
{R_VPBK_FIELD_TYPE_RINGTONE , _L8("Ringtone")}, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
92 |
{R_VPBK_FIELD_TYPE_CALLEROBJIMG , _L8("CallerObjImg")}, |
5 | 93 |
// {R_VPBK_FIELD_TYPE_CALLEROBJTEXT , _L8("CallerObjText")}, |
94 |
{R_VPBK_FIELD_TYPE_MIDDLENAME , _L8("MiddleName")}, |
|
95 |
{R_VPBK_FIELD_TYPE_DEPARTMENT , _L8("Department")}, |
|
96 |
{R_VPBK_FIELD_TYPE_ASSTNAME , _L8("AsstName")}, |
|
97 |
{R_VPBK_FIELD_TYPE_SPOUSE , _L8("Spouse")}, |
|
98 |
{R_VPBK_FIELD_TYPE_CHILDREN , _L8("Children")}, |
|
99 |
{R_VPBK_FIELD_TYPE_ASSTPHONE , _L8("AsstPhone")}, |
|
100 |
{R_VPBK_FIELD_TYPE_CARPHONE , _L8("CarPhone")}, |
|
101 |
{R_VPBK_FIELD_TYPE_ANNIVERSARY , _L8("Anniversary")}, |
|
102 |
{R_VPBK_FIELD_TYPE_SYNCCLASS , _L8("SyncClass")}, |
|
103 |
{R_VPBK_FIELD_TYPE_LOCPRIVACY , _L8("LOCPrivacy")}, |
|
104 |
// {R_VPBK_FIELD_TYPE_GENLABEL , _L8("GenLabel")}, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
105 |
{R_VPBK_FIELD_TYPE_IMPP , _L8("IMPP")}, |
5 | 106 |
}; |
107 |
||
108 |
//Gets the size of the mappingTable |
|
109 |
TInt CSearchFields::GetSizeofTable() |
|
110 |
{ |
|
111 |
return (sizeof(mappingTable)/sizeof(MAPPING_TABLE)); |
|
112 |
} |
|
113 |
||
114 |
||
115 |
//Gets the FieldId based on the index |
|
116 |
TInt CSearchFields::GetIdfromIndex(TInt index) |
|
117 |
{ |
|
118 |
return mappingTable[index].iFieldId; |
|
119 |
} |
|
120 |
||
121 |
||
122 |
//Takes Field value as the input and returns the corresponding contact model UID. |
|
123 |
EXPORT_C TInt CSearchFields::GetIdFromFieldKey( TDesC8& aFieldValue ) |
|
124 |
{ |
|
125 |
if( !aFieldValue.Size() ) |
|
126 |
{ |
|
127 |
return KInvalidFieldID; |
|
128 |
} |
|
129 |
//calculate the no of entries in the mapping table |
|
130 |
TInt noOfEntries = GetSizeofTable(); |
|
131 |
||
132 |
for(TInt index = 0; index < noOfEntries; index++) |
|
133 |
{ |
|
134 |
if( !aFieldValue.Compare(mappingTable[index].iFieldValue) ) |
|
135 |
{ |
|
136 |
return GetIdfromIndex(index); |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
return KInvalidFieldID; |
|
141 |
} |
|
142 |
||
143 |
||
144 |
//Takes contact model field id as the input and returns the corresponding |
|
145 |
//mapped field value |
|
146 |
EXPORT_C TPtrC8 CSearchFields::GetFieldKeyFromId( TInt aFieldId ) |
|
147 |
{ |
|
148 |
//calculate the no of entries in the mapping table |
|
149 |
TInt noOfEntries = GetSizeofTable(); |
|
150 |
TInt index; |
|
151 |
for(index = 0; index < noOfEntries; index++) |
|
152 |
{ |
|
153 |
if( aFieldId == mappingTable[index].iFieldId ) |
|
154 |
{ |
|
155 |
return mappingTable[index].iFieldValue; |
|
156 |
} |
|
157 |
} |
|
158 |
return TPtrC8(KNullDesC8); |
|
159 |
} |
|
160 |
||
161 |
||
162 |
//NewL method for CSearchFields class |
|
163 |
EXPORT_C CSearchFields* CSearchFields::NewL(CContactService* aContactService) |
|
164 |
{ |
|
165 |
CSearchFields* self=new (ELeave) CSearchFields(); |
|
166 |
CleanupStack::PushL(self); |
|
167 |
self->ConstructL(aContactService); |
|
168 |
CleanupStack::Pop(self); |
|
169 |
return self; |
|
170 |
} |
|
171 |
||
172 |
//NewL overloaded |
|
173 |
CSearchFields* CSearchFields::NewL() |
|
174 |
{ |
|
175 |
return new (ELeave) CSearchFields(); |
|
176 |
} |
|
177 |
||
178 |
//ConstructL() |
|
179 |
void CSearchFields::ConstructL(CContactService* aContactService) |
|
180 |
{ |
|
181 |
iContactService = aContactService; |
|
182 |
iFieldList = CVPbkFieldTypeRefsList::NewL(); |
|
183 |
} |
|
184 |
||
185 |
||
186 |
//Exported function, used to Append the fields the user is interested in. |
|
187 |
EXPORT_C void CSearchFields::AppendL(TDesC8& aFieldName) |
|
188 |
{ |
|
189 |
TInt fieldId = GetIdFromFieldKey(aFieldName); |
|
190 |
if(fieldId != KInvalidFieldID) |
|
191 |
{ |
|
192 |
iFieldList->AppendL(*(iContactService->GetFieldTypes()).Find(fieldId)); |
|
193 |
} |
|
194 |
else |
|
195 |
{ |
|
196 |
User::Leave(KErrArgument); |
|
197 |
} |
|
198 |
} |
|
199 |
||
200 |
//Destructor |
|
201 |
CSearchFields::~CSearchFields() |
|
202 |
{ |
|
203 |
delete iFieldList; |
|
204 |
} |
|
205 |
||
206 |
//Returned the RefList of Fields constructed. |
|
207 |
CVPbkFieldTypeRefsList* CSearchFields::GetFieldListL() |
|
208 |
{ |
|
209 |
if(iFieldList->FieldTypeCount() == 0) |
|
210 |
{ |
|
211 |
iFieldList->AppendL(*(iContactService->GetFieldTypes()).Find(R_VPBK_FIELD_TYPE_LASTNAME)); |
|
212 |
iFieldList->AppendL(*(iContactService->GetFieldTypes()).Find(R_VPBK_FIELD_TYPE_FIRSTNAME)); |
|
213 |
} |
|
214 |
return iFieldList; |
|
215 |
} |
|
216 |