|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 #ifndef SYMBIAN_BACKEND_USE_SQLITE |
|
42 |
|
43 #include "cnttransformonlineaccountsimple.h" |
|
44 |
|
45 QList<CContactItemField *> CntTransformOnlineAccount::transformDetailL(const QContactDetail &detail) |
|
46 { |
|
47 if(detail.definitionName() != QContactOnlineAccount::DefinitionName) |
|
48 User::Leave(KErrArgument); |
|
49 |
|
50 QList<CContactItemField *> fieldList; |
|
51 |
|
52 //cast to phonenumber |
|
53 const QContactOnlineAccount &onlineAccount(static_cast<const QContactOnlineAccount&>(detail)); |
|
54 |
|
55 //get the subType |
|
56 QStringList subTypes = onlineAccount.subTypes(); |
|
57 |
|
58 //no subtype |
|
59 if(!subTypes.count()) |
|
60 { |
|
61 User::LeaveIfError(KErrArgument); |
|
62 } |
|
63 else if (subTypes.contains(QContactOnlineAccount::SubTypeSipVoip)) { |
|
64 //internet |
|
65 transformToTextFieldL(onlineAccount, fieldList, onlineAccount.accountUri(), KUidContactFieldSIPID, KUidContactFieldVCardMapVOIP, false); |
|
66 } else if (subTypes.contains(QContactOnlineAccount::SubTypeVideoShare)) { |
|
67 //share video |
|
68 transformToTextFieldL( onlineAccount, fieldList, onlineAccount.accountUri(), KUidContactFieldSIPID, KUidContactFieldVCardMapSWIS, false); |
|
69 } else if (subTypes.contains(QContactOnlineAccount::SubTypeSip)) { |
|
70 //sip |
|
71 transformToTextFieldL( onlineAccount, fieldList, onlineAccount.accountUri(), KUidContactFieldSIPID, KUidContactFieldVCardMapSIPID, false); |
|
72 } |
|
73 else |
|
74 { |
|
75 User::LeaveIfError(KErrNotSupported); |
|
76 } |
|
77 |
|
78 return fieldList; |
|
79 } |
|
80 |
|
81 QContactDetail *CntTransformOnlineAccount::transformItemField(const CContactItemField& field, const QContact &contact) |
|
82 { |
|
83 Q_UNUSED(contact); |
|
84 |
|
85 QContactOnlineAccount *onlineAccount = new QContactOnlineAccount(); |
|
86 CContactTextField* storage = field.TextStorage(); |
|
87 QString onlineAccountString = QString::fromUtf16(storage->Text().Ptr(), storage->Text().Length()); |
|
88 |
|
89 // Adding Online Account Detail. |
|
90 for (int i = 0; i < field.ContentType().FieldTypeCount(); i++) { |
|
91 |
|
92 if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapVOIP)) { |
|
93 onlineAccount->setAccountUri(onlineAccountString); |
|
94 onlineAccount->setSubTypes(QContactOnlineAccount::SubTypeSipVoip); |
|
95 } |
|
96 else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapSWIS)) { |
|
97 onlineAccount->setAccountUri(onlineAccountString); |
|
98 onlineAccount->setSubTypes(QContactOnlineAccount::SubTypeVideoShare); |
|
99 } |
|
100 else if (field.ContentType().ContainsFieldType(KUidContactFieldVCardMapSIPID)) { |
|
101 onlineAccount->setAccountUri(onlineAccountString); |
|
102 onlineAccount->setSubTypes(QContactOnlineAccount::SubTypeSip); |
|
103 } |
|
104 } |
|
105 |
|
106 // set context |
|
107 for (int i = 0; i < field.ContentType().FieldTypeCount(); i++) { |
|
108 setContexts(field.ContentType().FieldType(i), *onlineAccount); |
|
109 } |
|
110 |
|
111 return onlineAccount; |
|
112 } |
|
113 |
|
114 bool CntTransformOnlineAccount::supportsDetail(QString detailName) const |
|
115 { |
|
116 bool ret = false; |
|
117 if (detailName == QContactOnlineAccount::DefinitionName) { |
|
118 ret = true; |
|
119 } |
|
120 return ret; |
|
121 } |
|
122 |
|
123 QList<TUid> CntTransformOnlineAccount::supportedFields() const |
|
124 { |
|
125 return QList<TUid>() |
|
126 << KUidContactFieldSIPID; |
|
127 } |
|
128 |
|
129 QList<TUid> CntTransformOnlineAccount::supportedSortingFieldTypes(QString detailFieldName) const |
|
130 { |
|
131 QList<TUid> uids; |
|
132 if (detailFieldName == QContactOnlineAccount::FieldAccountUri) { |
|
133 uids << KUidContactFieldSIPID; |
|
134 } |
|
135 return uids; |
|
136 } |
|
137 |
|
138 |
|
139 /*! |
|
140 * Checks whether the subtype is supported |
|
141 * |
|
142 * \a subType The subtype to be checked |
|
143 * \return True if this subtype is supported |
|
144 */ |
|
145 bool CntTransformOnlineAccount::supportsSubType(const QString& subType) const |
|
146 { |
|
147 if(QContactOnlineAccount::FieldSubTypes == subType) { |
|
148 return true; |
|
149 } else { |
|
150 return false; |
|
151 } |
|
152 } |
|
153 |
|
154 /*! |
|
155 * Returns the filed id corresponding to a field |
|
156 * |
|
157 * \a fieldName The name of the supported field |
|
158 * \return fieldId for the fieldName, 0 if not supported |
|
159 */ |
|
160 quint32 CntTransformOnlineAccount::getIdForField(const QString& fieldName) const |
|
161 { |
|
162 if (QContactOnlineAccount::FieldAccountUri == fieldName) |
|
163 return 0; |
|
164 else if (QContactOnlineAccount::SubTypeSip == fieldName) |
|
165 return KUidContactFieldSIPID.iUid; |
|
166 else if (QContactOnlineAccount::SubTypeSipVoip == fieldName) |
|
167 return KUidContactFieldVCardMapVOIP.iUid; |
|
168 else if (QContactOnlineAccount::SubTypeVideoShare == fieldName) |
|
169 return KUidContactFieldVCardMapSWIS.iUid; |
|
170 else |
|
171 return 0; |
|
172 } |
|
173 |
|
174 /*! |
|
175 * Modifies the detail definitions. The default detail definitions are |
|
176 * queried from QContactManagerEngine::schemaDefinitions and then modified |
|
177 * with this function in the transform leaf classes. |
|
178 * |
|
179 * \a definitions The detail definitions to modify. |
|
180 * \a contactType The contact type the definitions apply for. |
|
181 */ |
|
182 void CntTransformOnlineAccount::detailDefinitions(QMap<QString, QContactDetailDefinition> &definitions, const QString& contactType) const |
|
183 { |
|
184 Q_UNUSED(contactType); |
|
185 |
|
186 if(definitions.contains(QContactOnlineAccount::DefinitionName)) { |
|
187 QContactDetailDefinition d = definitions.value(QContactOnlineAccount::DefinitionName); |
|
188 QMap<QString, QContactDetailFieldDefinition> fields = d.fields(); |
|
189 QContactDetailFieldDefinition f; |
|
190 |
|
191 // Not all fields are supported |
|
192 fields.remove(QContactOnlineAccount::FieldCapabilities); |
|
193 fields.remove(QContactOnlineAccount::FieldDetailUri); |
|
194 fields.remove(QContactOnlineAccount::FieldLinkedDetailUris); |
|
195 fields.remove(QContactOnlineAccount::FieldServiceProvider); |
|
196 fields.remove(QContactOnlineAccount::FieldContext); |
|
197 |
|
198 // Support only certain subtypes |
|
199 f.setDataType(QVariant::StringList); |
|
200 QVariantList subTypes; |
|
201 subTypes << QString(QLatin1String(QContactOnlineAccount::SubTypeSip)); |
|
202 subTypes << QString(QLatin1String(QContactOnlineAccount::SubTypeSipVoip)); |
|
203 subTypes << QString(QLatin1String(QContactOnlineAccount::SubTypeVideoShare)); |
|
204 f.setAllowableValues(subTypes); |
|
205 fields[QContactOnlineAccount::FieldSubTypes] = f; |
|
206 |
|
207 d.setFields(fields); |
|
208 |
|
209 // Replace original definitions |
|
210 definitions.insert(d.name(), d); |
|
211 } |
|
212 } |
|
213 |
|
214 #endif // SYMBIAN_BACKEND_USE_SQLITE |