summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/cntvcard/cntvcardstd.cpp
blob: 313600b22bf86f675ceecc9846b7d9ad78efaf7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include "cntvcardutils.h"

// System Includes
#include <e32base.h>

// User includes
#include <cntitem.h>

// Constants
const TInt KCntVCardItemAndLabelGranularity = 7;


/**
 * Panic the thread with CNTVCARD as the category
 * 
 * @param aPanic Panic number
 */
GLDEF_C void Panic(TCntVCardPanic aPanic)
	{
	_LIT(KCntVCardPanicCategory,"CNTVCARD");
	User::Panic(KCntVCardPanicCategory,aPanic);
	}

/**
 * Array clean-up method 
 */
GLDEF_C void CleanUpResetAndDestroy(TAny *aArray)
	{
	if (aArray)
		{
		CArrayPtr<CContactItem>* array=(CArrayPtr<CContactItem>*)aArray;
		array->ResetAndDestroy();
		delete array;
		}
	}


/**
 * Standard Epoc32 Dll Entry point
 */




/**
 * Constructor
 */
CVCardItemAndLabel::CVCardItemAndLabel()
	{
	}

/**
 * Destructor
 */
CVCardItemAndLabel::~CVCardItemAndLabel()
	{
	delete iItems;
	delete iLabels;
	}

/**
 * Second phase constructor
 */
void CVCardItemAndLabel::ConstructL()
	{
	iItems = new(ELeave) CDesCArrayFlat(KCntVCardItemAndLabelGranularity);
	iLabels = new(ELeave) CDesCArrayFlat(KCntVCardItemAndLabelGranularity);
	}

/**
 * Static constructor
 * @return The constructed item and label
 */
CVCardItemAndLabel* CVCardItemAndLabel::NewLC()
	{
	CVCardItemAndLabel* self = new(ELeave) CVCardItemAndLabel();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

/**
 * Add an item
 * @param aItem The item name
 */
void CVCardItemAndLabel::AddItemL(const TDesC& aItem)
	{
	iItems->AppendL(aItem);
	}

/**
 * Add a label for an item
 * @param aLabel The item label
 */
void CVCardItemAndLabel::AddLabelL(const TDesC& aLabel)
	{
	iLabels->AppendL(aLabel);
	}

/**
 * The number of items present
 * @return The number of items present
 */
TInt CVCardItemAndLabel::ItemCount() const
	{
	return iItems->Count();
	}

/**
 * The number of labels present
 * @return The number of labels present
 */
TInt CVCardItemAndLabel::LabelCount() const
	{
	return iLabels->Count();
	}

/**
 * Access an item by index
 * @return The item at the specified index
 */
TPtrC CVCardItemAndLabel::Item(TInt aIndex) const
	{
	return iItems->MdcaPoint(aIndex);
	}

/**
 * Access a label by index
 * @return The label at the specified index
 */
TPtrC CVCardItemAndLabel::Label(TInt aIndex) const
	{
	return iLabels->MdcaPoint(aIndex);
	}

/**
 * Locate the index of a specified label.
 * @param aName The label being searched for
 * @param aPosition A reference parameter which is updated with the position of the
 *                  item if it is located.
 * @return An error code indicating whether the item was found or otherwise
 */
TInt CVCardItemAndLabel::FindLabel(const TDesC& aName, TInt& aPosition) const
	{
	return iLabels->Find(aName, aPosition);
	}

/**
 * Utility cleanup method
 * @param aArray An object of RPointerArray<CVCardItemAndLabel> which must be cleaned up
 */
void CVCardItemAndLabel::CleanUpResetDestroyAndCloseArray(TAny* aArray)
	{
	RPointerArray<CVCardItemAndLabel>* array = reinterpret_cast<RPointerArray<CVCardItemAndLabel>*>(aArray);
	if	(array)
		{
		array->ResetAndDestroy();
		array->Close();
		}
	}






/**
 * Constructor
 */
CVCardAddress::CVCardAddress(TUid aMapping)
:	iMapping(aMapping)
	{
	}

/**
 * Static constructor
 */
CVCardAddress* CVCardAddress::NewLC(TUid aMapping)
	{
	CVCardAddress* self = new(ELeave) CVCardAddress(aMapping);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}