29
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: a single field with type
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "cvimpstfieldproperty.h"
|
|
20 |
|
|
21 |
#include "cvimpstfieldpropertyarray.h"
|
|
22 |
// From Virtual Phonebook
|
|
23 |
#include <MVPbkFieldType.h>
|
|
24 |
#include <MVPbkStoreContactField.h>
|
|
25 |
#include "vimpstdetailsview.hrh"
|
|
26 |
#include <MVPbkBaseContactField.h>
|
|
27 |
#include <MVPbkContactFieldData.h>
|
|
28 |
#include <MVPbkContactFieldTextData.h>
|
|
29 |
#include <MVPbkContactFieldUriData.h>
|
|
30 |
#include <MVPbkContactFieldDateTimeData.h>
|
|
31 |
// System includes
|
|
32 |
#include <barsread.h>
|
|
33 |
#include "uiservicetabtracer.h"
|
|
34 |
|
|
35 |
_LIT(KColon,":");
|
|
36 |
// --------------------------------------------------------------------------
|
|
37 |
// CVIMPSTFieldProperty::CVIMPSTFieldProperty
|
|
38 |
// --------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CVIMPSTFieldProperty::CVIMPSTFieldProperty( TInt aFieldId, TInt aIconId, TInt aMaxLength )
|
|
41 |
:iFieldId( aFieldId ),
|
|
42 |
iIconId( aIconId ),
|
|
43 |
iMaxLength( aMaxLength)
|
|
44 |
{
|
|
45 |
}
|
|
46 |
|
|
47 |
// --------------------------------------------------------------------------
|
|
48 |
// CVIMPSTFieldProperty::~CVIMPSTFieldProperty
|
|
49 |
// --------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CVIMPSTFieldProperty::~CVIMPSTFieldProperty()
|
|
52 |
{
|
|
53 |
delete iDefaultLabel;
|
|
54 |
delete iFieldData;
|
|
55 |
delete iField;
|
|
56 |
}
|
|
57 |
|
|
58 |
// --------------------------------------------------------------------------
|
|
59 |
// CVIMPSTFieldProperty::ConstructL
|
|
60 |
// --------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
inline void CVIMPSTFieldProperty::ConstructL(const TDesC& aDefaultLabel)
|
|
63 |
{
|
|
64 |
if( aDefaultLabel.Length() )
|
|
65 |
{
|
|
66 |
iDefaultLabel = aDefaultLabel.AllocL();
|
|
67 |
}
|
|
68 |
}
|
|
69 |
// --------------------------------------------------------------------------
|
|
70 |
// CVIMPSTFieldProperty::NewLC
|
|
71 |
// --------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CVIMPSTFieldProperty* CVIMPSTFieldProperty::NewLC
|
|
74 |
( TInt aFieldId, TInt aIconId, TInt aMaxLength, const TDesC& aDefaultLabel )
|
|
75 |
{
|
|
76 |
CVIMPSTFieldProperty* self = new( ELeave ) CVIMPSTFieldProperty( aFieldId, aIconId, aMaxLength);
|
|
77 |
CleanupStack::PushL( self );
|
|
78 |
self->ConstructL(aDefaultLabel);
|
|
79 |
return self;
|
|
80 |
}
|
|
81 |
|
|
82 |
// --------------------------------------------------------------------------
|
|
83 |
// CVIMPSTFieldProperty::IconId
|
|
84 |
// --------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
TInt CVIMPSTFieldProperty::IconId()
|
|
87 |
{
|
|
88 |
return iIconId;
|
|
89 |
}
|
|
90 |
|
|
91 |
// --------------------------------------------------------------------------
|
|
92 |
// CVIMPSTFieldProperty::FieldId
|
|
93 |
// --------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
TInt CVIMPSTFieldProperty::FieldId()
|
|
96 |
{
|
|
97 |
if( iFieldId == EVIMPSTFieldIdImpp ||
|
|
98 |
iFieldId == EVIMPSTFieldIdEmailAddress||
|
|
99 |
iFieldId == EVIMPSTFieldIdEmailGen )
|
|
100 |
{
|
|
101 |
// these fields are map to one field
|
|
102 |
return EVIMPSTFieldIdImpp;
|
|
103 |
}
|
|
104 |
return iFieldId;
|
|
105 |
}
|
|
106 |
// --------------------------------------------------------------------------
|
|
107 |
// CVIMPSTFieldProperty::DefaultLabelL
|
|
108 |
// --------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
const TDesC& CVIMPSTFieldProperty::DefaultLabelL()
|
|
111 |
{
|
|
112 |
if( iField && !iDefaultLabel )
|
|
113 |
{
|
|
114 |
iDefaultLabel = iField->FieldLabel().Left( iMaxLength ).AllocL();
|
|
115 |
}
|
|
116 |
|
|
117 |
if( iDefaultLabel )
|
|
118 |
{
|
|
119 |
return *iDefaultLabel;
|
|
120 |
}
|
|
121 |
|
|
122 |
return KNullDesC();
|
|
123 |
}
|
|
124 |
|
|
125 |
// --------------------------------------------------------------------------
|
|
126 |
// CVIMPSTFieldProperty::SetFieldTextL
|
|
127 |
// --------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
void CVIMPSTFieldProperty::SetFieldTextL(const TDesC& aText )
|
|
130 |
{
|
|
131 |
if( iFieldData )
|
|
132 |
{
|
|
133 |
delete iFieldData;
|
|
134 |
iFieldData = NULL;
|
|
135 |
}
|
|
136 |
iFieldData = aText.AllocL();
|
|
137 |
}
|
|
138 |
// --------------------------------------------------------------------------
|
|
139 |
// CVIMPSTFieldProperty::SetStoredFieldL
|
|
140 |
// --------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
void CVIMPSTFieldProperty::SetStoredFieldL(MVPbkStoreContactField& aField )
|
|
143 |
{
|
|
144 |
iField = aField.CloneLC();
|
|
145 |
CleanupStack::Pop();
|
|
146 |
}
|
|
147 |
|
|
148 |
// --------------------------------------------------------------------------
|
|
149 |
// CVIMPSTFieldProperty::FieldDataL
|
|
150 |
// --------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
const TDesC& CVIMPSTFieldProperty::FieldDataL()
|
|
153 |
{
|
|
154 |
TRACER_AUTO;
|
|
155 |
if( iField && !iFieldData )
|
|
156 |
{
|
|
157 |
const MVPbkContactFieldData& fieldData = iField->FieldData();
|
|
158 |
switch( fieldData.DataType() )
|
|
159 |
{
|
|
160 |
case EVPbkFieldStorageTypeText:
|
|
161 |
{
|
|
162 |
TPtrC text = MVPbkContactFieldTextData::Cast( fieldData ).Text();
|
|
163 |
iFieldData = text.AllocL();
|
|
164 |
break;
|
|
165 |
}
|
|
166 |
case EVPbkFieldStorageTypeUri:
|
|
167 |
{
|
|
168 |
const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast(fieldData);
|
|
169 |
|
|
170 |
HBufC* user = uri.Uri().AllocLC();
|
|
171 |
TPtr userPtr( user->Des() );
|
|
172 |
TInt index = userPtr.Find( KColon );
|
|
173 |
if( index != KErrNotFound )
|
|
174 |
{
|
|
175 |
TInt length = userPtr.Length();
|
|
176 |
iFieldData = userPtr.Right( length - index - 1 ).AllocL();
|
|
177 |
CleanupStack::PopAndDestroy(); //user
|
|
178 |
}
|
|
179 |
else
|
|
180 |
{
|
|
181 |
CleanupStack::Pop();// user
|
|
182 |
iFieldData = user;
|
|
183 |
}
|
|
184 |
|
|
185 |
break;
|
|
186 |
}
|
|
187 |
case EVPbkFieldStorageTypeDateTime:
|
|
188 |
{
|
|
189 |
const MVPbkContactFieldDateTimeData& dateData =
|
|
190 |
MVPbkContactFieldDateTimeData::Cast( fieldData );
|
|
191 |
TTime date = dateData.DateTime();
|
|
192 |
_LIT( KDateFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3" );
|
|
193 |
const TInt KDateLength( 12 );
|
|
194 |
HBufC* dateStr = HBufC::NewLC( KDateLength );
|
|
195 |
TPtr datePtr( dateStr->Des() );
|
|
196 |
date.FormatL( datePtr, KDateFormat, TLocale() );
|
|
197 |
CleanupStack::Pop( dateStr );
|
|
198 |
iFieldData = dateStr;
|
|
199 |
break;
|
|
200 |
}
|
|
201 |
default :
|
|
202 |
{
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
}
|
|
207 |
return iFieldData ? *iFieldData : KNullDesC();
|
|
208 |
}
|
|
209 |
|
|
210 |
|
|
211 |
// End of file
|