|
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 "SmfClientGlobal.h" |
|
26 #include <qdatastream.h> |
|
27 #include <QSharedData> |
|
28 #include <QVariant> |
|
29 //#include <smfclientglobal.h> |
|
30 #include "smfcontact_p.h" |
|
31 |
|
32 using namespace QtMobility; |
|
33 |
|
34 |
|
35 //TODO:- For the time being we'll just store a string SmfContact |
|
36 /** |
|
37 * @ingroup smf_common_group |
|
38 * The contact class represents a social contact |
|
39 * |
|
40 * Note: This class has dependencies on QtMobility project |
|
41 */ |
|
42 //QList<SmfContact> gives error for serialization if its derived from QObject |
|
43 class SMFCLIENT_EXPORT SmfContact //: public QObject |
|
44 { |
|
45 //Q_OBJECT |
|
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 * Destructor |
|
62 */ |
|
63 ~SmfContact( ); |
|
64 //Q_DECLARE_LATIN1_LITERAL(SubTypeAddress, "Address"); |
|
65 //Q_DECLARE_LATIN1_LITERAL(SubTypeAnniversary, "Anniversary"); |
|
66 //Q_DECLARE_LATIN1_LITERAL(SubTypeAvatar, "Avatar"); |
|
67 //Q_DECLARE_LATIN1_LITERAL(SubTypeBirthday, "Birthday"); |
|
68 //Q_DECLARE_LATIN1_LITERAL(SubTypeContactId, "ContactId"); |
|
69 //Q_DECLARE_LATIN1_LITERAL(SubTypeEmailAddress, "EmailAddress"); |
|
70 //Q_DECLARE_LATIN1_LITERAL(SubTypeGender, "Gender"); |
|
71 //Q_DECLARE_LATIN1_LITERAL(SubTypeGeolocation, "Geolocation"); |
|
72 //Q_DECLARE_LATIN1_LITERAL(SubTypeGuid, "Guid"); |
|
73 //Q_DECLARE_LATIN1_LITERAL(SubTypeName, "Name"); |
|
74 //Q_DECLARE_LATIN1_LITERAL(SubTypeNickname, "Nickname"); |
|
75 //Q_DECLARE_LATIN1_LITERAL(SubTypeNote, "Note"); |
|
76 //Q_DECLARE_LATIN1_LITERAL(SubTypeOnlineAccount, "OnlineAccount"); |
|
77 //Q_DECLARE_LATIN1_LITERAL(SubTypeOrganization, "Organization"); |
|
78 //Q_DECLARE_LATIN1_LITERAL(SubTypePhoneNumber, "PhoneNumber"); |
|
79 //Q_DECLARE_LATIN1_LITERAL(SubTypeTimestamp, "Timestamp"); |
|
80 //Q_DECLARE_LATIN1_LITERAL(SubTypeType, "Type"); |
|
81 //Q_DECLARE_LATIN1_LITERAL(SubTypeUrl, "Url"); |
|
82 public slots: |
|
83 /** |
|
84 * Method to get the available sub fields for contacts. |
|
85 * The following are the available sub types of a contact |
|
86 * QtMobility::QContactAddress Address; |
|
87 * QtMobility::QContactAnniversary Anniversary; |
|
88 * QtMobility::QContactAvatar Avatar; |
|
89 * QtMobility::QContactBirthday Birthday; |
|
90 * QtMobility::QContactId ContactId; |
|
91 * QtMobility::QContactEmailAddress EmailAddress; |
|
92 * QtMobility::QContactGender Gender; |
|
93 * QtMobility::QContactGeolocation Geolocation; |
|
94 * QtMobility::QContactGuid Guid; |
|
95 * QtMobility::QContactName Name; |
|
96 * QtMobility::QContactNickname Nickname; |
|
97 * QtMobility::QContactNote Note; |
|
98 * QtMobility::QContactOnlineAccount OnlineAccount; |
|
99 * QtMobility::QContactOrganization Organization; |
|
100 * QtMobility::QContactPhoneNumber PhoneNumber; |
|
101 * QtMobility::QContactTimestamp Timestamp; |
|
102 * QtMobility::QContactType Type; |
|
103 * QtMobility::QContactUrl Url; |
|
104 * @return The Available sub fields for this contact |
|
105 */ |
|
106 |
|
107 QStringList subTypes( ) const; |
|
108 |
|
109 /** |
|
110 * Method to convert an SmfContact to a QContact |
|
111 * Changes made to the returned QContact will not be reflected |
|
112 * in its parent SmfContact object |
|
113 * @param aContact QContact corresponding to SmfContact |
|
114 */ |
|
115 void convert( QContact &aContact ) const; |
|
116 |
|
117 /** |
|
118 * Method to get the value of a sub field for this contact |
|
119 * @param aSubType The sub field type |
|
120 * @return The value of the sub field subType |
|
121 * @see subTypes() |
|
122 */ |
|
123 QVariant value( const QString& aSubType ) const; |
|
124 |
|
125 /** |
|
126 * Method to set value for a subtype |
|
127 */ |
|
128 void setValue(const QString& aSubType,QVariant& value); |
|
129 void writeLog(QString log) const; |
|
130 private: |
|
131 QSharedDataPointer<SmfContactPrivate> d; |
|
132 |
|
133 friend QDataStream &operator<<( QDataStream &aDataStream, |
|
134 const SmfContact &aContact ); |
|
135 |
|
136 friend QDataStream &operator>>( QDataStream &aDataStream, |
|
137 SmfContact &aContact ); |
|
138 |
|
139 }; |
|
140 |
|
141 |
|
142 /** |
|
143 * Method for Externalization. Writes the SmfContact object to |
|
144 * the stream and returns a reference to the stream. |
|
145 * @param aDataStream Stream to be written |
|
146 * @param aContact The SmfContact object to be externalized |
|
147 * @return reference to the written stream |
|
148 */ |
|
149 SMFCLIENT_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
150 const SmfContact &aContact ); |
|
151 |
|
152 /** |
|
153 * Method for Internalization. Reads a SmfContact object from |
|
154 * the stream and returns a reference to the stream. |
|
155 * @param aDataStream Stream to be read |
|
156 * @param aContact The SmfContact object to be internalized |
|
157 * @return reference to the stream |
|
158 */ |
|
159 SMFCLIENT_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
160 SmfContact &aContact ); |
|
161 typedef QList<SmfContact> SmfContactList; |
|
162 /** |
|
163 * Serialization support for Qt mobility contact |
|
164 */ |
|
165 SMFCLIENT_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
166 const QContactName &aContact ); |
|
167 |
|
168 SMFCLIENT_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
169 QContactName &aContact ); |
|
170 // Make the class SmfContact known to QMetaType, so that as to register it. |
|
171 Q_DECLARE_METATYPE(SmfContact) |
|
172 Q_DECLARE_METATYPE(QList<SmfContact>) |
|
173 |
|
174 //make qt mobility related classes known to moc |
|
175 Q_DECLARE_METATYPE(QContactAddress) |
|
176 Q_DECLARE_METATYPE(QContactAnniversary) |
|
177 Q_DECLARE_METATYPE(QContactAvatar) |
|
178 Q_DECLARE_METATYPE(QContactBirthday) |
|
179 Q_DECLARE_METATYPE(QContactId) |
|
180 Q_DECLARE_METATYPE(QContactEmailAddress) |
|
181 Q_DECLARE_METATYPE(QContactGender) |
|
182 Q_DECLARE_METATYPE(QContactGuid) |
|
183 Q_DECLARE_METATYPE(QContactName) |
|
184 Q_DECLARE_METATYPE(QContactNickname) |
|
185 Q_DECLARE_METATYPE(QContactNote) |
|
186 Q_DECLARE_METATYPE(QContactOnlineAccount) |
|
187 Q_DECLARE_METATYPE(QContactOrganization) |
|
188 Q_DECLARE_METATYPE(QContactPhoneNumber) |
|
189 Q_DECLARE_METATYPE(QContactTimestamp) |
|
190 Q_DECLARE_METATYPE(QContactType) |
|
191 Q_DECLARE_METATYPE(QContactUrl) |
|
192 |
|
193 #endif /* SMFCONTACT_H_ */ |