|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #ifndef __NBCNTTESTLIB_H__ |
|
18 #define __NBCNTTESTLIB_H__ |
|
19 |
|
20 #include <cntitem.h> |
|
21 |
|
22 IMPORT_C void PrintContactL(const TDesC& aFilename, const CContactItem& aContact); |
|
23 |
|
24 const TInt KEmailAddrLen = 4; |
|
25 |
|
26 class CCntItemModifier; |
|
27 |
|
28 class CCntItemBuilder : public CBase |
|
29 { |
|
30 public: |
|
31 IMPORT_C static CCntItemBuilder* NewLC(const CContactTemplate& aTemplate); |
|
32 IMPORT_C ~CCntItemBuilder(); |
|
33 IMPORT_C CContactItem* GetCntItemLC();// Returning ownership. |
|
34 |
|
35 private: |
|
36 void ConstructL(); |
|
37 inline CCntItemBuilder (const CContactTemplate& aTemplate); |
|
38 void FillWithRandomDataL(CContactItem& aContactItem); |
|
39 void SetRandomWordL (TDes& aBuf, TInt32 aType); |
|
40 void SetRandomAlphaString(TDes& aBuf,TInt aLength); |
|
41 |
|
42 TText RandomAlphaCharCode (); |
|
43 TText RandomNumericCharCode (); |
|
44 TText RandomAlphaNumbericCharCode(); |
|
45 TText RandomCharCode (TText aLowerBound,TText aUpperBound,TText aException); |
|
46 TText RandomCharCode (TText aLowerBound,TText aUpperBound); |
|
47 void SetRandomNumericString (TDes& aBuf, TInt aLength); |
|
48 void SetRandomAlphaNumericString(TDes& aBuf,TInt aLength); |
|
49 |
|
50 private: |
|
51 const CContactTemplate& iTemplate; |
|
52 CCntItemModifier* iCntModifier; |
|
53 }; |
|
54 |
|
55 |
|
56 class CCntItemModifier : public CBase |
|
57 { |
|
58 public: |
|
59 IMPORT_C static CCntItemModifier* NewLC(); |
|
60 IMPORT_C ~CCntItemModifier(); |
|
61 IMPORT_C void SetTextFieldL (TFieldType aFieldType, const TDesC& aText, CContactItem& aContactItem); |
|
62 IMPORT_C void SetTextFieldL (const CContentType& aTypesToMatch,const TDesC& aText, CContactItem& aContactItem) const; |
|
63 IMPORT_C void SetTextFieldL (TFieldType aFieldType, TFieldType a2ndFieldType, |
|
64 TFieldType a3rdFieldType, const TDesC& aText, |
|
65 CContactItem& aContactItem) const; |
|
66 IMPORT_C void SetTextFieldL (TFieldType aFieldType, TFieldType a2ndFieldType, |
|
67 const TDesC& aText, CContactItem& aContactItem) const; |
|
68 IMPORT_C void SetTextFieldL (TFieldType aFieldType, TFieldType a2ndFieldType, |
|
69 TFieldType a3rdFieldType, TFieldType a4thFieldType, |
|
70 const TDesC& aText, CContactItem& aContactItem) const; |
|
71 |
|
72 IMPORT_C TBool FindTextFieldL (TFieldType aFieldType, TFieldType a2ndFieldType, |
|
73 const TDesC& aText, |
|
74 CContactItem& aContactItem) const; |
|
75 IMPORT_C TBool FindTextFieldL(TFieldType aFieldType, |
|
76 const TDesC& aText, |
|
77 CContactItem& aContactItem) const; |
|
78 IMPORT_C TBool FindTextFieldL(TFieldType aFieldType, TFieldType a2ndFieldType, |
|
79 TFieldType a3rdFieldType, TFieldType a4thFieldType, |
|
80 const TDesC& aText, CContactItem& aContactItem) const; |
|
81 |
|
82 |
|
83 private: |
|
84 TInt FindField (TFieldType aFieldType, CContactItem& aContactItem) const; |
|
85 |
|
86 CContactItemField& FindFieldL(TFieldType aFieldType, CContactItem& aContactItem) const; |
|
87 CContactItemField& FindFieldL(const CContentType& aTypesToMatch, CContactItem& aContactItem) const; |
|
88 |
|
89 void InsertTextFieldL (TFieldType aID, const TDesC& aStringOfStuff, CContactItem& aContactItem); |
|
90 |
|
91 private: |
|
92 inline CCntItemModifier (){}; |
|
93 |
|
94 }; |
|
95 |
|
96 |
|
97 class TContact |
|
98 { |
|
99 private: |
|
100 class TProp |
|
101 { |
|
102 public: |
|
103 TProp(TUid aUid1, TUid aUid2, CContactItem* aCnt) : |
|
104 iUid1(aUid1), iUid2(aUid2), iCnt(aCnt) |
|
105 {}; |
|
106 void operator= (const TDesC& aStr); |
|
107 operator const TPtrC(); |
|
108 |
|
109 private: |
|
110 CContactItemField& Find(); |
|
111 |
|
112 TUid iUid1; |
|
113 TUid iUid2; |
|
114 CContactItem* iCnt; |
|
115 }; |
|
116 |
|
117 class TWorkHome |
|
118 { |
|
119 public: |
|
120 TWorkHome(TUid aUid, CContactItem* aCnt) |
|
121 : Work(aUid, KUidContactFieldVCardMapWORK, aCnt), |
|
122 Home(aUid, KUidContactFieldVCardMapHOME, aCnt) |
|
123 {}; |
|
124 |
|
125 TProp Work; |
|
126 TProp Home; |
|
127 }; |
|
128 |
|
129 |
|
130 public: |
|
131 TContact(CContactItem* aCnt); |
|
132 |
|
133 |
|
134 //Entries |
|
135 |
|
136 //TProp Title; |
|
137 TProp FirstName; |
|
138 //TProp MiddleName; |
|
139 //TProp LastName; |
|
140 //TProp SuffixName; |
|
141 |
|
142 |
|
143 TWorkHome Email; |
|
144 TWorkHome Address; |
|
145 |
|
146 private: |
|
147 CContactItem* iCnt; |
|
148 }; |
|
149 |
|
150 |
|
151 |
|
152 class TCnt |
|
153 { |
|
154 private: |
|
155 class TGetSet |
|
156 { |
|
157 friend class TCnt; |
|
158 public: |
|
159 TGetSet(CContactItem*& aCnt) : iCnt(aCnt), iIndex(NULL) {}; |
|
160 |
|
161 IMPORT_C operator const TPtrC(); |
|
162 IMPORT_C CContactItemField& Field(); |
|
163 |
|
164 |
|
165 IMPORT_C void operator= (const TDesC& aStr); |
|
166 IMPORT_C TBool operator==(const TDesC& aStr); |
|
167 IMPORT_C TGetSet& operator & (TUid aUid); |
|
168 |
|
169 //Array functionality |
|
170 IMPORT_C void operator+= (const TDesC& aStr); |
|
171 IMPORT_C TGetSet& operator[](TInt aIndex); |
|
172 IMPORT_C TInt Count(); |
|
173 |
|
174 private: |
|
175 CContactItemField* Find(); |
|
176 private: |
|
177 CContentType* iContType; |
|
178 CContactItem*& iCnt; |
|
179 TInt iIndex; |
|
180 }; |
|
181 |
|
182 public: |
|
183 |
|
184 TCnt(CContactItem*& aContact) |
|
185 :iTaker(aContact) {}; |
|
186 |
|
187 IMPORT_C TGetSet& operator[](TUid aUid); |
|
188 |
|
189 private: |
|
190 TGetSet iTaker; |
|
191 }; |
|
192 |
|
193 |
|
194 |
|
195 inline CCntItemBuilder::CCntItemBuilder (const CContactTemplate& aTemplate):iTemplate(aTemplate) {}; |
|
196 |
|
197 |
|
198 |
|
199 #define KWork KUidContactFieldVCardMapWORK |
|
200 #define KHome KUidContactFieldVCardMapHOME |
|
201 #define KVoice KUidContactFieldVCardMapVOICE |
|
202 #define KCell KUidContactFieldVCardMapCELL |
|
203 #define KPager KUidContactFieldVCardMapPAGER |
|
204 #define KWv KUidContactFieldVCardMapWV |
|
205 |
|
206 #define KPoc KUidContactFieldVCardMapPOC |
|
207 #define KSwis KUidContactFieldVCardMapSWIS |
|
208 #define KVoip KUidContactFieldVCardMapVOIP |
|
209 |
|
210 #endif |