author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 24 Sep 2009 12:43:20 +0300 | |
changeset 12 | f4292e0e20df |
parent 10 | fc9cf246af83 |
child 27 | 02682e02e51f |
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 |
#include <MVPbkContactFieldTextData.h> |
|
21 |
#include <MVPbkContactLink.h> |
|
22 |
#include <MVPbkContactLinkArray.h> |
|
23 |
#include <MVPbkContactGroup.h> |
|
24 |
#include <barsread.h> |
|
25 |
#include <eikenv.h> |
|
26 |
#include <TVPbkFieldTypeMapping.h> |
|
27 |
#include <MVPbkContactFieldTextData.h> |
|
28 |
#include <MVPbkContactFieldData.h> |
|
29 |
#include <MVPbkContactFieldBinaryData.h> |
|
30 |
#include <MVPbkContactFieldDateTimeData.h> |
|
31 |
#include <MVPbkStoreContactField.h> |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
32 |
#include <MVPbkContactFieldUriData.h> |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
33 |
_LIT8(KXSPID,"IMPP"); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
34 |
_LIT(KXSPIDLabel,"IMPP"); |
5 | 35 |
|
36 |
#include "singlecontact.h" |
|
37 |
||
38 |
//NewL method for CSingleContact class. It holds MVPbkStoreContact variable as its member |
|
39 |
CSingleContact* CSingleContact::NewL(MVPbkStoreContact* aSingleContact, Ttype aIndicator) |
|
40 |
{ |
|
41 |
CSingleContact* self = new( ELeave ) CSingleContact(); |
|
42 |
CleanupStack::PushL( self ); |
|
43 |
self->ConstructL(aSingleContact, aIndicator); |
|
44 |
CleanupStack::Pop( self ); |
|
45 |
return self; |
|
46 |
} |
|
47 |
||
48 |
EXPORT_C |
|
49 |
CSingleContact* CSingleContact::NewL() |
|
50 |
{ |
|
51 |
CSingleContact* self = new( ELeave ) CSingleContact(); |
|
52 |
CleanupStack::PushL( self ); |
|
53 |
self->iContactId = KNullDesC8().AllocL(); |
|
54 |
CleanupStack::Pop( self ); |
|
55 |
return self; |
|
56 |
} |
|
57 |
||
58 |
||
59 |
// --------------------------------------------------------------------------- |
|
60 |
//Constructor |
|
61 |
// --------------------------------------------------------------------------- |
|
62 |
CSingleContact::CSingleContact() |
|
63 |
{ |
|
64 |
} |
|
65 |
||
66 |
void CSingleContact::ConstructL(MVPbkStoreContact* aSingleContact, Ttype aIndicator) |
|
67 |
{ |
|
68 |
iIndicator = aIndicator; |
|
69 |
iContactId = KNullDesC8().AllocL(); |
|
70 |
ConvertContactToFieldListL(aSingleContact); |
|
71 |
} |
|
72 |
||
73 |
void CSingleContact::ConvertContactToFieldListL(MVPbkStoreContact* aSingleContact) |
|
74 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
75 |
TBool XSPID = EFalse; |
5 | 76 |
|
77 |
if(aSingleContact) |
|
78 |
{ |
|
79 |
TInt fieldCount = aSingleContact->Fields().FieldCount(); |
|
80 |
CSingleContactField* field = NULL; |
|
81 |
for(TInt fieldIndex = 0; fieldIndex < fieldCount ; fieldIndex++) |
|
82 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
83 |
TPtrC8 fieldKey; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
84 |
if(XSPID == EFalse) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
85 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
86 |
MVPbkStoreContactField& fieldval = aSingleContact->Fields().FieldAt(fieldIndex); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
87 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
88 |
//Get the fieldKey of the field |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
89 |
fieldKey.Set(CSearchFields::GetFieldKeyFromId(fieldval.BestMatchingFieldType()->FieldTypeResId())); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
90 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
91 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
92 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
93 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
94 |
fieldIndex--; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
95 |
MVPbkStoreContactField& fieldval = aSingleContact->Fields().FieldAt(fieldIndex); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
96 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
97 |
//Get the fieldKey of the field |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
98 |
fieldKey.Set(CSearchFields::GetFieldKeyFromId(fieldval.BestMatchingFieldType()->FieldTypeResId())); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
99 |
XSPID = EFalse; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
100 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
101 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
102 |
if(fieldKey.Compare(KXSPID) == 0) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
103 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
104 |
XSPID = ETrue; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
105 |
field = GetXSPIDFieldL(aSingleContact, fieldIndex); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
106 |
if(field != NULL) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
107 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
108 |
iFields.Append(field); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
109 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
110 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
111 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
112 |
{ |
5 | 113 |
field = NextFieldL(aSingleContact, fieldIndex); |
114 |
if(field !=NULL) |
|
115 |
{ |
|
116 |
iFields.AppendL(field); |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
120 |
} |
5 | 121 |
delete aSingleContact; |
122 |
||
123 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
124 |
CSingleContactField* CSingleContact::GetXSPIDFieldL(MVPbkStoreContact* aSingleContact, TInt& aIndex) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
125 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
126 |
CSingleContactField* contactField = CSingleContactField::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
127 |
CleanupStack::PushL(contactField); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
128 |
TPtrC uri; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
129 |
if(iIndicator == EContacts) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
130 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
131 |
MVPbkStoreContactField& field = aSingleContact->Fields().FieldAt(aIndex); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
132 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
133 |
//Get the fieldKey of the field |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
134 |
TPtrC8 fieldKeyXspid = CSearchFields::GetFieldKeyFromId(field.BestMatchingFieldType()->FieldTypeResId()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
135 |
if(fieldKeyXspid.Compare(KNullDesC8) == 0) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
136 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
137 |
CleanupStack::PopAndDestroy(contactField); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
138 |
return NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
139 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
140 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
141 |
RPointerArray<HBufC> xspidArray; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
142 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
143 |
while(fieldKeyXspid.Compare(KXSPID) == 0) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
144 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
145 |
TPtrC label(field.FieldLabel()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
146 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
147 |
TVPbkFieldStorageType storageType = field.FieldData().DataType(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
148 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
149 |
if(EVPbkFieldStorageTypeUri == storageType ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
150 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
151 |
//TDesC val = label.Alloc(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
152 |
uri.Set((MVPbkContactFieldUriData::Cast(field.FieldData())).Uri()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
153 |
/* TBuf<10> bufVal1; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
154 |
bufVal1.Copy(label); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
155 |
TBuf<100> bufVal2; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
156 |
bufVal2.Copy(uri); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
157 |
bufVal1.Append(_L(":")); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
158 |
bufVal1.Append(bufVal2); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
159 |
HBufC* xspidVal = bufVal1.AllocLC();*/ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
160 |
xspidArray.AppendL(uri.AllocL()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
161 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
162 |
aIndex++; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
163 |
MVPbkStoreContactField& field = aSingleContact->Fields().FieldAt(aIndex); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
164 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
165 |
fieldKeyXspid.Set(CSearchFields::GetFieldKeyFromId(field.BestMatchingFieldType()->FieldTypeResId())); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
166 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
167 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
168 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
169 |
contactField->SetUriFieldParamsL(KXSPID,KXSPIDLabel,xspidArray); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
170 |
CleanupStack::Pop(contactField); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
171 |
return contactField; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
172 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
173 |
return NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
174 |
} |
5 | 175 |
//Returns the Next field in the contact if any, otherwise returns NULL |
176 |
CSingleContactField* CSingleContact::NextFieldL(MVPbkStoreContact* aSingleContact, TInt aIndex) |
|
177 |
{ |
|
178 |
TPtrC text(KNullDesC); |
|
179 |
TTime time; |
|
180 |
TPtrC8 val; |
|
181 |
||
182 |
CSingleContactField* contactField = CSingleContactField::NewL(); |
|
183 |
CleanupStack::PushL(contactField); |
|
184 |
if(iIndicator == EContacts) |
|
185 |
{ |
|
186 |
//Get the field at iFieldIndex in the contact |
|
187 |
MVPbkStoreContactField& field = aSingleContact->Fields().FieldAt(aIndex); |
|
188 |
||
189 |
//Get the fieldKey of the field |
|
12
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
190 |
const MVPbkFieldType* fieldType = field.BestMatchingFieldType(); |
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
191 |
if(fieldType == NULL) |
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
192 |
{ |
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
193 |
CleanupStack::PopAndDestroy(contactField); |
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
194 |
return NULL; |
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
195 |
} |
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
196 |
TInt idval = fieldType->FieldTypeResId(); |
f4292e0e20df
Revision: 200937
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
197 |
TPtrC8 fieldKey = CSearchFields::GetFieldKeyFromId(idval); |
5 | 198 |
if(fieldKey.Compare(KNullDesC8) == 0) |
199 |
{ |
|
200 |
CleanupStack::PopAndDestroy(contactField); |
|
201 |
return NULL; |
|
202 |
} |
|
203 |
//Get the label of the field |
|
204 |
TPtrC label(field.FieldLabel()); |
|
205 |
||
206 |
//Get the value of the field |
|
207 |
||
208 |
TVPbkFieldStorageType storageType = field.FieldData().DataType(); |
|
209 |
//TBuf<KMinHeapGrowBy> value; |
|
210 |
||
211 |
if( EVPbkFieldStorageTypeBinary == storageType ) |
|
212 |
{ |
|
213 |
val.Set((MVPbkContactFieldBinaryData::Cast(field.FieldData())).BinaryData()); |
|
214 |
//value.Copy(val); |
|
215 |
} |
|
216 |
else if( EVPbkFieldStorageTypeDateTime == storageType ) |
|
217 |
{ |
|
218 |
time = (MVPbkContactFieldDateTimeData::Cast(field.FieldData())).DateTime(); |
|
219 |
contactField->SetDateTime(time); |
|
220 |
} |
|
221 |
else |
|
222 |
{ |
|
223 |
text.Set((MVPbkContactFieldTextData::Cast(field.FieldData())).Text()); |
|
224 |
} |
|
225 |
||
226 |
//Set the parameters in CSingleContactField object |
|
227 |
contactField->SetFieldParamsL(fieldKey, label, text); |
|
228 |
||
229 |
} |
|
230 |
else if(iIndicator == EGroups) |
|
231 |
{ |
|
232 |
TPtrC groupLabel = (aSingleContact->Group())->GroupLabel(); |
|
233 |
||
234 |
MVPbkContactLinkArray* linkArray = (aSingleContact->Group())->ItemsContainedLC(); |
|
235 |
TInt noOfEntries = linkArray->Count(); |
|
236 |
if(noOfEntries > 0) |
|
237 |
{ |
|
238 |
RPointerArray<HBufC8> array(noOfEntries); |
|
239 |
CleanupClosePushL(array); |
|
240 |
const HBufC8* packedLink; |
|
241 |
||
242 |
for(int i=0; i<noOfEntries; i++) |
|
243 |
{ |
|
244 |
packedLink = const_cast <MVPbkContactLink&>(linkArray->At(i)).PackLC(); |
|
245 |
array.AppendL(packedLink); |
|
246 |
} |
|
247 |
||
248 |
//Set the parameters in CSingleContactField object |
|
249 |
contactField->SetFieldParamsL(groupLabel, array); |
|
250 |
||
251 |
CleanupStack::Pop(noOfEntries); |
|
252 |
CleanupStack::Pop(&array); |
|
253 |
} |
|
254 |
else |
|
255 |
{ |
|
256 |
RPointerArray<HBufC8> array; |
|
257 |
//Set the parameters in CSingleContactField object |
|
258 |
contactField->SetFieldParamsL(groupLabel, array); |
|
259 |
} |
|
260 |
CleanupStack::PopAndDestroy(); |
|
261 |
} |
|
262 |
CleanupStack::Pop(contactField); |
|
263 |
return contactField; |
|
264 |
} |
|
265 |
// --------------------------------------------------------------------------- |
|
266 |
//Sets the contact id of a contact |
|
267 |
// --------------------------------------------------------------------------- |
|
268 |
EXPORT_C void CSingleContact::SetContactIdL(const TDesC8& aContactId) |
|
269 |
{ |
|
270 |
if(iContactId) |
|
271 |
{ |
|
272 |
delete iContactId; |
|
273 |
iContactId = NULL; |
|
274 |
} |
|
275 |
iContactId = aContactId.AllocL(); |
|
276 |
} |
|
277 |
||
278 |
// --------------------------------------------------------------------------- |
|
279 |
//Gets the contact id of a contact |
|
280 |
// --------------------------------------------------------------------------- |
|
281 |
EXPORT_C TDesC8& CSingleContact::GetContactId() |
|
282 |
{ |
|
283 |
return *iContactId; |
|
284 |
} |
|
285 |
// --------------------------------------------------------------------------- |
|
286 |
// CSingleContact::RemoveFieldL |
|
287 |
// Removes the specified field from the contact |
|
288 |
// --------------------------------------------------------------------------- |
|
289 |
||
290 |
EXPORT_C TInt CSingleContact::RemoveField(TInt aIndex) |
|
291 |
{ |
|
292 |
TInt retVal = KErrArgument; |
|
293 |
||
294 |
if((aIndex >= 0) && (aIndex < iFields.Count())) |
|
295 |
{ |
|
296 |
delete iFields[aIndex]; |
|
297 |
iFields[aIndex] = NULL; |
|
298 |
iFields.Remove(aIndex); |
|
299 |
retVal = KErrNone; |
|
300 |
} |
|
301 |
||
302 |
return retVal; |
|
303 |
} |
|
304 |
||
305 |
||
306 |
// --------------------------------------------------------------------------- |
|
307 |
// CSingleContact::RemoveAllFields |
|
308 |
// Removes all fields from the contact |
|
309 |
// --------------------------------------------------------------------------- |
|
310 |
||
311 |
EXPORT_C void CSingleContact::RemoveAllFields() |
|
312 |
{ |
|
313 |
iFields.ResetAndDestroy(); |
|
314 |
} |
|
315 |
||
316 |
||
317 |
// --------------------------------------------------------------------------- |
|
318 |
// CSingleContact::AddFieldToContactL |
|
319 |
// Add a Field to Contact |
|
320 |
// --------------------------------------------------------------------------- |
|
321 |
||
322 |
EXPORT_C void CSingleContact::AddFieldToContactL( const CSingleContactField* aField ) |
|
323 |
{ |
|
324 |
iFields.AppendL(aField); |
|
325 |
} |
|
326 |
||
327 |
||
328 |
//Destructor |
|
329 |
CSingleContact::~CSingleContact() |
|
330 |
{ |
|
331 |
iFields.ResetAndDestroy(); |
|
332 |
delete iContactId; |
|
333 |
} |
|
334 |
||
335 |
||
336 |
//Get the number of fields in the contact |
|
337 |
EXPORT_C |
|
338 |
TInt CSingleContact::FieldCount() |
|
339 |
{ |
|
340 |
return iFields.Count(); |
|
341 |
} |
|
342 |
//Get the field at the index; |
|
343 |
EXPORT_C |
|
344 |
CSingleContactField* CSingleContact::FieldAt(TInt aIndex) |
|
345 |
{ |
|
346 |
if((aIndex >= 0) && (aIndex < iFields.Count())) |
|
347 |
{ |
|
348 |
return iFields[aIndex]; |
|
349 |
} |
|
350 |
else |
|
351 |
{ |
|
352 |
return NULL; |
|
353 |
} |
|
354 |
} |
|
355 |