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")},
|
|
92 |
// {R_VPBK_FIELD_TYPE_CALLEROBJIMG , _L8("CallerObjImg")},
|
|
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")},
|
|
105 |
};
|
|
106 |
|
|
107 |
//Gets the size of the mappingTable
|
|
108 |
TInt CSearchFields::GetSizeofTable()
|
|
109 |
{
|
|
110 |
return (sizeof(mappingTable)/sizeof(MAPPING_TABLE));
|
|
111 |
}
|
|
112 |
|
|
113 |
|
|
114 |
//Gets the FieldId based on the index
|
|
115 |
TInt CSearchFields::GetIdfromIndex(TInt index)
|
|
116 |
{
|
|
117 |
return mappingTable[index].iFieldId;
|
|
118 |
}
|
|
119 |
|
|
120 |
|
|
121 |
//Takes Field value as the input and returns the corresponding contact model UID.
|
|
122 |
EXPORT_C TInt CSearchFields::GetIdFromFieldKey( TDesC8& aFieldValue )
|
|
123 |
{
|
|
124 |
if( !aFieldValue.Size() )
|
|
125 |
{
|
|
126 |
return KInvalidFieldID;
|
|
127 |
}
|
|
128 |
//calculate the no of entries in the mapping table
|
|
129 |
TInt noOfEntries = GetSizeofTable();
|
|
130 |
|
|
131 |
for(TInt index = 0; index < noOfEntries; index++)
|
|
132 |
{
|
|
133 |
if( !aFieldValue.Compare(mappingTable[index].iFieldValue) )
|
|
134 |
{
|
|
135 |
return GetIdfromIndex(index);
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
return KInvalidFieldID;
|
|
140 |
}
|
|
141 |
|
|
142 |
|
|
143 |
//Takes contact model field id as the input and returns the corresponding
|
|
144 |
//mapped field value
|
|
145 |
EXPORT_C TPtrC8 CSearchFields::GetFieldKeyFromId( TInt aFieldId )
|
|
146 |
{
|
|
147 |
//calculate the no of entries in the mapping table
|
|
148 |
TInt noOfEntries = GetSizeofTable();
|
|
149 |
TInt index;
|
|
150 |
for(index = 0; index < noOfEntries; index++)
|
|
151 |
{
|
|
152 |
if( aFieldId == mappingTable[index].iFieldId )
|
|
153 |
{
|
|
154 |
return mappingTable[index].iFieldValue;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
return TPtrC8(KNullDesC8);
|
|
158 |
}
|
|
159 |
|
|
160 |
|
|
161 |
//NewL method for CSearchFields class
|
|
162 |
EXPORT_C CSearchFields* CSearchFields::NewL(CContactService* aContactService)
|
|
163 |
{
|
|
164 |
CSearchFields* self=new (ELeave) CSearchFields();
|
|
165 |
CleanupStack::PushL(self);
|
|
166 |
self->ConstructL(aContactService);
|
|
167 |
CleanupStack::Pop(self);
|
|
168 |
return self;
|
|
169 |
}
|
|
170 |
|
|
171 |
//NewL overloaded
|
|
172 |
CSearchFields* CSearchFields::NewL()
|
|
173 |
{
|
|
174 |
return new (ELeave) CSearchFields();
|
|
175 |
}
|
|
176 |
|
|
177 |
//ConstructL()
|
|
178 |
void CSearchFields::ConstructL(CContactService* aContactService)
|
|
179 |
{
|
|
180 |
iContactService = aContactService;
|
|
181 |
iFieldList = CVPbkFieldTypeRefsList::NewL();
|
|
182 |
}
|
|
183 |
|
|
184 |
|
|
185 |
//Exported function, used to Append the fields the user is interested in.
|
|
186 |
EXPORT_C void CSearchFields::AppendL(TDesC8& aFieldName)
|
|
187 |
{
|
|
188 |
TInt fieldId = GetIdFromFieldKey(aFieldName);
|
|
189 |
if(fieldId != KInvalidFieldID)
|
|
190 |
{
|
|
191 |
iFieldList->AppendL(*(iContactService->GetFieldTypes()).Find(fieldId));
|
|
192 |
}
|
|
193 |
else
|
|
194 |
{
|
|
195 |
User::Leave(KErrArgument);
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
//Destructor
|
|
200 |
CSearchFields::~CSearchFields()
|
|
201 |
{
|
|
202 |
delete iFieldList;
|
|
203 |
}
|
|
204 |
|
|
205 |
//Returned the RefList of Fields constructed.
|
|
206 |
CVPbkFieldTypeRefsList* CSearchFields::GetFieldListL()
|
|
207 |
{
|
|
208 |
if(iFieldList->FieldTypeCount() == 0)
|
|
209 |
{
|
|
210 |
iFieldList->AppendL(*(iContactService->GetFieldTypes()).Find(R_VPBK_FIELD_TYPE_LASTNAME));
|
|
211 |
iFieldList->AppendL(*(iContactService->GetFieldTypes()).Find(R_VPBK_FIELD_TYPE_FIRSTNAME));
|
|
212 |
}
|
|
213 |
return iFieldList;
|
|
214 |
}
|
|
215 |
|