|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The contact class represents a social contact |
|
17 * Note: This class has dependencies on QtMobility project |
|
18 * |
|
19 */ |
|
20 |
|
21 #ifndef SMFCONTACT_H_ |
|
22 #define SMFCONTACT_H_ |
|
23 |
|
24 #include <qtcontacts.h> |
|
25 #include <qdatastream.h> |
|
26 #include <QSharedData> |
|
27 #include <QVariant> |
|
28 |
|
29 #include "smfclientglobal.h" |
|
30 #include "smfcontact_p.h" |
|
31 |
|
32 using namespace QtMobility; |
|
33 |
|
34 /** |
|
35 * Max size for one SmfContact |
|
36 */ |
|
37 const int MaxSmfContactSize = 1000; |
|
38 |
|
39 /** |
|
40 * @ingroup smf_common_group |
|
41 * The contact class represents a social contact |
|
42 * |
|
43 * Note: This class has dependencies on QtMobility project |
|
44 */ |
|
45 class SMFCOMMON_EXPORT SmfContact |
|
46 { |
|
47 public: |
|
48 /** |
|
49 * Constructor with default argument |
|
50 * @param aParent The parent object |
|
51 */ |
|
52 SmfContact( QObject *aParent = 0 ); |
|
53 |
|
54 /** |
|
55 * Copy Constructor |
|
56 * @param aOther The reference object |
|
57 */ |
|
58 SmfContact( const SmfContact &aOther ); |
|
59 |
|
60 /** |
|
61 * Overloaded = operator |
|
62 * @param aOther The reference object |
|
63 * @return The target reference value |
|
64 */ |
|
65 SmfContact& operator=( const SmfContact &aOther ); |
|
66 |
|
67 /** |
|
68 * Destructor |
|
69 */ |
|
70 ~SmfContact( ); |
|
71 |
|
72 public slots: |
|
73 /** |
|
74 * Method to get the available sub fields for contacts. |
|
75 * The following are the available sub types of a contact |
|
76 * QtMobility::QContactAddress Address; |
|
77 * QtMobility::QContactAnniversary Anniversary; |
|
78 * QtMobility::QContactAvatar Avatar; |
|
79 * QtMobility::QContactBirthday Birthday; |
|
80 * QtMobility::QContactId ContactId; |
|
81 * QtMobility::QContactEmailAddress EmailAddress; |
|
82 * QtMobility::QContactGender Gender; |
|
83 * QtMobility::QContactGeoLocation Geolocation; |
|
84 * QtMobility::QContactGuid Guid; |
|
85 * QtMobility::QContactName Name; |
|
86 * QtMobility::QContactNickname Nickname; |
|
87 * QtMobility::QContactNote Note; |
|
88 * QtMobility::QContactOnlineAccount OnlineAccount; |
|
89 * QtMobility::QContactOrganization Organization; |
|
90 * QtMobility::QContactPhoneNumber PhoneNumber; |
|
91 * QtMobility::QContactPresence Presence; |
|
92 * QtMobility::QContactThumbnail Thumbnail; |
|
93 * QtMobility::QContactTimestamp Timestamp; |
|
94 * QtMobility::QContactType Type; |
|
95 * QtMobility::QContactUrl Url; |
|
96 * @return The Available sub fields for this contact |
|
97 */ |
|
98 QStringList subTypes( ) const; |
|
99 |
|
100 /** |
|
101 * Method to convert an SmfContact to a QContact |
|
102 * Changes made to the returned QContact will not be reflected |
|
103 * in its parent SmfContact object |
|
104 * @param aContact QContact corresponding to SmfContact |
|
105 */ |
|
106 void convert( QContact &aContact ) const; |
|
107 |
|
108 /** |
|
109 * Method to get the value of a sub field for this contact |
|
110 * @param aSubType The sub field type |
|
111 * @return The value of the sub field subType |
|
112 * @see subTypes() |
|
113 */ |
|
114 QVariant value( const QString& aSubType ) const; |
|
115 |
|
116 /** |
|
117 * Method to set value for a subtype |
|
118 * @param aSubType The subtype string |
|
119 * @param value Thhe value to be set for the subtype |
|
120 */ |
|
121 void setValue(const QString& aSubType,QVariant& value); |
|
122 |
|
123 private: |
|
124 QSharedDataPointer<SmfContactPrivate> d; |
|
125 |
|
126 friend QDataStream &operator<<( QDataStream &aDataStream, |
|
127 const SmfContact &aContact ); |
|
128 |
|
129 friend QDataStream &operator>>( QDataStream &aDataStream, |
|
130 SmfContact &aContact ); |
|
131 |
|
132 }; |
|
133 |
|
134 |
|
135 /** |
|
136 * Method for Externalization. Writes the SmfContact object to |
|
137 * the stream and returns a reference to the stream. |
|
138 * @param aDataStream Stream to be written |
|
139 * @param aContact The SmfContact object to be externalized |
|
140 * @return reference to the written stream |
|
141 */ |
|
142 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
143 const SmfContact &aContact ); |
|
144 |
|
145 /** |
|
146 * Method for Internalization. Reads a SmfContact object from |
|
147 * the stream and returns a reference to the stream. |
|
148 * @param aDataStream Stream to be read |
|
149 * @param aContact The SmfContact object to be internalized |
|
150 * @return reference to the stream |
|
151 */ |
|
152 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
153 SmfContact &aContact ); |
|
154 |
|
155 |
|
156 typedef QList<SmfContact> SmfContactList; |
|
157 |
|
158 |
|
159 /** |
|
160 * Serialization support for QtMobility QContact classes |
|
161 */ |
|
162 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
163 const QContactAddress &aAddress ); |
|
164 |
|
165 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
166 QContactAddress &aAddress ); |
|
167 |
|
168 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
169 const QContactAnniversary &aAnniversary ); |
|
170 |
|
171 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
172 QContactAnniversary &aAnniversary ); |
|
173 |
|
174 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
175 const QContactAvatar &aAvatar ); |
|
176 |
|
177 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
178 QContactAvatar &aAvatar ); |
|
179 |
|
180 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
181 const QContactBirthday &aBirthday ); |
|
182 |
|
183 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
184 QContactBirthday &aBirthday ); |
|
185 |
|
186 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
187 const QContactEmailAddress &aEMail ); |
|
188 |
|
189 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
190 QContactEmailAddress &aEMail ); |
|
191 |
|
192 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
193 const QContactGender &aGender ); |
|
194 |
|
195 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
196 QContactGender &aGender ); |
|
197 |
|
198 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
199 const QContactGeoLocation &aGeolocation ); |
|
200 |
|
201 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
202 QContactGeoLocation &aGeolocation ); |
|
203 |
|
204 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
205 const QContactGuid &aGuid ); |
|
206 |
|
207 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
208 QContactGuid &aGuid ); |
|
209 |
|
210 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
211 const QContactId &aContactId ); |
|
212 |
|
213 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
214 QContactId &aContactId ); |
|
215 |
|
216 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
217 const QContactName &aName ); |
|
218 |
|
219 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
220 QContactName &aName ); |
|
221 |
|
222 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
223 const QContactNickname &aNickname ); |
|
224 |
|
225 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
226 QContactNickname &aNickname ); |
|
227 |
|
228 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
229 const QContactNote &aNote ); |
|
230 |
|
231 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
232 QContactNote &aNote ); |
|
233 |
|
234 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
235 const QContactOnlineAccount &aOnlineAccount ); |
|
236 |
|
237 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
238 QContactOnlineAccount &aOnlineAccount ); |
|
239 |
|
240 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
241 const QContactOrganization &aOrganization ); |
|
242 |
|
243 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
244 QContactOrganization &aOrganization ); |
|
245 |
|
246 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
247 const QContactPhoneNumber &aPhoneNumber ); |
|
248 |
|
249 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
250 QContactPhoneNumber &aPhoneNumber ); |
|
251 |
|
252 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
253 const QContactPresence &aPresence ); |
|
254 |
|
255 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
256 QContactPresence &aPresence ); |
|
257 |
|
258 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
259 const QContactThumbnail &aThumbnail ); |
|
260 |
|
261 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
262 QContactThumbnail &aThumbnail ); |
|
263 |
|
264 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
265 const QContactTimestamp &aTimestamp ); |
|
266 |
|
267 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
268 QContactTimestamp &aTimestamp ); |
|
269 |
|
270 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
271 const QContactType &aType ); |
|
272 |
|
273 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
274 QContactType &aType ); |
|
275 |
|
276 SMFCOMMON_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
277 const QContactUrl &aUrl ); |
|
278 |
|
279 SMFCOMMON_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
280 QContactUrl &aUrl ); |
|
281 |
|
282 |
|
283 // Make the class SmfContact known to QMetaType, so that as to register it. |
|
284 Q_DECLARE_METATYPE(SmfContact) |
|
285 Q_DECLARE_METATYPE(QList<SmfContact>) |
|
286 |
|
287 //make qt mobility related classes known to moc |
|
288 Q_DECLARE_METATYPE(QContactAddress) |
|
289 Q_DECLARE_METATYPE(QContactAnniversary) |
|
290 Q_DECLARE_METATYPE(QContactAvatar) |
|
291 Q_DECLARE_METATYPE(QContactBirthday) |
|
292 Q_DECLARE_METATYPE(QContactId) |
|
293 Q_DECLARE_METATYPE(QContactEmailAddress) |
|
294 Q_DECLARE_METATYPE(QContactGender) |
|
295 Q_DECLARE_METATYPE(QContactGeoLocation) |
|
296 Q_DECLARE_METATYPE(QContactGuid) |
|
297 Q_DECLARE_METATYPE(QContactName) |
|
298 Q_DECLARE_METATYPE(QContactNickname) |
|
299 Q_DECLARE_METATYPE(QContactNote) |
|
300 Q_DECLARE_METATYPE(QContactOnlineAccount) |
|
301 Q_DECLARE_METATYPE(QContactOrganization) |
|
302 Q_DECLARE_METATYPE(QContactPhoneNumber) |
|
303 Q_DECLARE_METATYPE(QContactPresence) |
|
304 Q_DECLARE_METATYPE(QContactThumbnail) |
|
305 Q_DECLARE_METATYPE(QContactTimestamp) |
|
306 Q_DECLARE_METATYPE(QContactType) |
|
307 Q_DECLARE_METATYPE(QContactUrl) |
|
308 |
|
309 #endif /* SMFCONTACT_H_ */ |