|
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: Valid contact data info. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cpimcontactvalidator.h" |
|
21 #include "pimcontact.h" |
|
22 #include "logger.h" |
|
23 |
|
24 CPIMContactValidator* CPIMContactValidator::NewL() |
|
25 { |
|
26 JELOG2(EPim); |
|
27 CPIMContactValidator* self = NewLC(); |
|
28 CleanupStack::Pop(self); |
|
29 return self; |
|
30 } |
|
31 |
|
32 CPIMContactValidator* CPIMContactValidator::NewLC() |
|
33 { |
|
34 JELOG2(EPim); |
|
35 CPIMContactValidator* self = new(ELeave) CPIMContactValidator(); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 CPIMContactValidator::CPIMContactValidator() : |
|
42 CPIMValidator(EPIMContactAttrAsst | EPIMContactAttrAuto |
|
43 | EPIMContactAttrFax | EPIMContactAttrHome | EPIMContactAttrMobile |
|
44 | EPIMContactAttrOther | EPIMContactAttrPager |
|
45 | EPIMContactAttrPreferred | EPIMContactAttrSms | EPIMContactAttrWork |
|
46 | EPIMContactAttrExtVideoCall) |
|
47 { |
|
48 JELOG2(EPim); |
|
49 } |
|
50 |
|
51 void CPIMContactValidator::ConstructL() |
|
52 { |
|
53 JELOG2(EPim); |
|
54 CPIMValidator::ConstructL(); |
|
55 |
|
56 iValidFields->AppendL(TPIMFieldAndType(EPIMContactAddr, |
|
57 EPIMFieldStringArray)); |
|
58 |
|
59 iValidFields->AppendL(TPIMFieldAndType(EPIMContactBirthday, EPIMFieldDate)); |
|
60 |
|
61 iValidFields->AppendL(TPIMFieldAndType(EPIMContactClass, EPIMFieldInt)); |
|
62 |
|
63 iValidFields->AppendL(TPIMFieldAndType(EPIMContactEmail, EPIMFieldString)); |
|
64 |
|
65 iValidFields->AppendL(TPIMFieldAndType(EPIMContactFormattedAddr, |
|
66 EPIMFieldString)); |
|
67 |
|
68 iValidFields->AppendL(TPIMFieldAndType(EPIMContactFormattedName, |
|
69 EPIMFieldString)); |
|
70 |
|
71 iValidFields->AppendL(TPIMFieldAndType(EPIMContactName, |
|
72 EPIMFieldStringArray)); |
|
73 |
|
74 iValidFields->AppendL( |
|
75 TPIMFieldAndType(EPIMContactNickname, EPIMFieldString)); |
|
76 |
|
77 iValidFields->AppendL(TPIMFieldAndType(EPIMContactNote, EPIMFieldString)); |
|
78 |
|
79 iValidFields->AppendL(TPIMFieldAndType(EPIMContactOrg, EPIMFieldString)); |
|
80 |
|
81 iValidFields->AppendL(TPIMFieldAndType(EPIMContactPhoto, EPIMFieldBinary)); |
|
82 |
|
83 iValidFields->AppendL( |
|
84 TPIMFieldAndType(EPIMContactPhotoUrl, EPIMFieldString)); |
|
85 |
|
86 iValidFields->AppendL(TPIMFieldAndType(EPIMContactPublicKey, |
|
87 EPIMFieldBinary)); |
|
88 |
|
89 iValidFields->AppendL(TPIMFieldAndType(EPIMContactPublicKeyString, |
|
90 EPIMFieldString)); |
|
91 |
|
92 iValidFields->AppendL(TPIMFieldAndType(EPIMContactRevision, EPIMFieldDate)); |
|
93 |
|
94 iValidFields->AppendL(TPIMFieldAndType(EPIMContactTel, EPIMFieldString)); |
|
95 |
|
96 iValidFields->AppendL(TPIMFieldAndType(EPIMContactTitle, EPIMFieldString)); |
|
97 |
|
98 iValidFields->AppendL(TPIMFieldAndType(EPIMContactUid, EPIMFieldString)); |
|
99 |
|
100 iValidFields->AppendL(TPIMFieldAndType(EPIMContactUrl, EPIMFieldString)); |
|
101 |
|
102 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtWvUserId, |
|
103 EPIMFieldString)); |
|
104 |
|
105 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtSip, EPIMFieldString)); |
|
106 |
|
107 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtDtmf, EPIMFieldString)); |
|
108 |
|
109 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtDepartment, |
|
110 EPIMFieldString)); |
|
111 |
|
112 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtAssistantName, |
|
113 EPIMFieldString)); |
|
114 |
|
115 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtSpouse, |
|
116 EPIMFieldString)); |
|
117 |
|
118 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtChildren, |
|
119 EPIMFieldString)); |
|
120 |
|
121 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtAnniversary, |
|
122 EPIMFieldDate)); |
|
123 |
|
124 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtVoip, EPIMFieldString)); |
|
125 |
|
126 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtPTT, EPIMFieldString)); |
|
127 |
|
128 iValidFields->AppendL(TPIMFieldAndType(EPIMContactExtSWIS, EPIMFieldString)); |
|
129 } |
|
130 |
|
131 CPIMContactValidator::~CPIMContactValidator() |
|
132 { |
|
133 JELOG2(EPim); |
|
134 } |
|
135 |
|
136 TInt CPIMContactValidator::NumElementsL(const TPIMField& aStringArrayField) const |
|
137 { |
|
138 JELOG2(EPim); |
|
139 TInt retVal = 0; |
|
140 |
|
141 if (aStringArrayField == EPIMContactAddr) |
|
142 { |
|
143 retVal = EPIMContactAddrNumElements; |
|
144 } |
|
145 else if (aStringArrayField == EPIMContactName) |
|
146 { |
|
147 retVal = EPIMContactNameNumElements; |
|
148 } |
|
149 else |
|
150 { |
|
151 User::Leave(KErrArgument); |
|
152 } |
|
153 |
|
154 return retVal; |
|
155 } |
|
156 |
|
157 TBool CPIMContactValidator::IsValidIntegerValue(const TPIMField& aField, |
|
158 const TInt& aValue) const |
|
159 { |
|
160 JELOG2(EPim); |
|
161 TBool retVal = ETrue; |
|
162 |
|
163 if (aField == EPIMContactClass) |
|
164 { |
|
165 // contact class has predefined values |
|
166 if ((aValue != EPIMContactClassConfidential) && (aValue |
|
167 != EPIMContactClassPrivate) && (aValue != EPIMContactClassPublic)) |
|
168 { |
|
169 // not one of predefined values |
|
170 retVal = EFalse; |
|
171 } |
|
172 } |
|
173 // else any integer is OK |
|
174 |
|
175 return retVal; |
|
176 } |
|
177 |
|
178 TBool CPIMContactValidator::IsValidStringArrayValue(const TPIMField& aField, |
|
179 const CDesCArray& aValue) const |
|
180 { |
|
181 JELOG2(EPim); |
|
182 TBool retVal = EFalse; |
|
183 |
|
184 if (aField == EPIMContactAddr) |
|
185 { |
|
186 retVal = (aValue.Count() == EPIMContactAddrNumElements); |
|
187 } |
|
188 else if (aField == EPIMContactName) |
|
189 { |
|
190 retVal = (aValue.Count() == EPIMContactNameNumElements); |
|
191 } |
|
192 // else leave retVal EFalse, because we don't recognize the |
|
193 // string array field |
|
194 |
|
195 return retVal; |
|
196 } |
|
197 |
|
198 // End of File |