|
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 #include "cnttransformringtone.h" |
|
42 #include "cntmodelextuids.h" |
|
43 |
|
44 #include "qcontactringtone.h" |
|
45 |
|
46 QList<CContactItemField *> CntTransformRingtone::transformDetailL(const QContactDetail &detail) |
|
47 { |
|
48 if(detail.definitionName() != QContactRingtone::DefinitionName) |
|
49 User::Leave(KErrArgument); |
|
50 |
|
51 QList<CContactItemField *> fieldList; |
|
52 |
|
53 const QContactRingtone &ringtone(static_cast<const QContactRingtone&>(detail)); |
|
54 |
|
55 if (ringtone.audioRingtoneUrl().isValid()) { |
|
56 transformToTextFieldL(detail, fieldList, |
|
57 ringtone.audioRingtoneUrl().toString(), KUidContactFieldRingTone, |
|
58 KUidContactFieldVCardMapUnknown, false); |
|
59 } |
|
60 |
|
61 if (ringtone.videoRingtoneUrl().isValid()) { |
|
62 transformToTextFieldL(detail, fieldList, |
|
63 ringtone.videoRingtoneUrl().toString(), KUidContactFieldVideoRingTone, |
|
64 KUidContactFieldVCardMapUnknown, false); |
|
65 } |
|
66 |
|
67 return fieldList; |
|
68 } |
|
69 |
|
70 QContactDetail *CntTransformRingtone::transformItemField(const CContactItemField& field, const QContact &contact) |
|
71 { |
|
72 QContactRingtone *ringtone = new QContactRingtone(contact.detail<QContactRingtone>()); |
|
73 |
|
74 // XXX ringtone can have multiple values from different fields glommed together |
|
75 CContactTextField* storage = field.TextStorage(); |
|
76 QString ringtoneString = QString::fromUtf16(storage->Text().Ptr(), storage->Text().Length()); |
|
77 |
|
78 if (field.ContentType().ContainsFieldType(KUidContactFieldRingTone)) { |
|
79 ringtone->setAudioRingtoneUrl(ringtoneString); |
|
80 } |
|
81 else if (field.ContentType().ContainsFieldType(KUidContactFieldVideoRingTone)) { |
|
82 ringtone->setVideoRingtoneUrl(ringtoneString); |
|
83 } |
|
84 |
|
85 // XXX need to remove old one somehow |
|
86 |
|
87 return ringtone; |
|
88 } |
|
89 |
|
90 bool CntTransformRingtone::supportsField(TUint32 fieldType) const |
|
91 { |
|
92 bool ret = false; |
|
93 if (fieldType == KUidContactFieldRingTone.iUid || |
|
94 fieldType == KUidContactFieldVideoRingTone.iUid) { |
|
95 ret = true; |
|
96 } |
|
97 return ret; |
|
98 } |
|
99 |
|
100 bool CntTransformRingtone::supportsDetail(QString detailName) const |
|
101 { |
|
102 bool ret = false; |
|
103 if (detailName == QContactRingtone::DefinitionName) { |
|
104 ret = true; |
|
105 } |
|
106 return ret; |
|
107 } |
|
108 |
|
109 QList<TUid> CntTransformRingtone::supportedSortingFieldTypes(QString /*detailFieldName*/) const |
|
110 { |
|
111 // Sorting not supported |
|
112 return QList<TUid>(); |
|
113 } |
|
114 |
|
115 |
|
116 /*! |
|
117 * Checks whether the subtype is supported |
|
118 * |
|
119 * \a subType The subtype to be checked |
|
120 * \return True if this subtype is supported |
|
121 */ |
|
122 bool CntTransformRingtone::supportsSubType(const QString& /*subType*/) const |
|
123 { |
|
124 // XXX todo |
|
125 return false; |
|
126 } |
|
127 |
|
128 /*! |
|
129 * Returns the filed id corresponding to a field |
|
130 * |
|
131 * \a fieldName The name of the supported field |
|
132 * \return fieldId for the fieldName, 0 if not supported |
|
133 */ |
|
134 quint32 CntTransformRingtone::getIdForField(const QString& /*fieldName*/) const |
|
135 { |
|
136 // XXX todo |
|
137 return 0; |
|
138 } |
|
139 |
|
140 /*! |
|
141 * Modifies the detail definitions. The default detail definitions are |
|
142 * queried from QContactManagerEngine::schemaDefinitions and then modified |
|
143 * with this function in the transform leaf classes. |
|
144 * |
|
145 * \a definitions The detail definitions to modify. |
|
146 * \a contactType The contact type the definitions apply for. |
|
147 */ |
|
148 void CntTransformRingtone::detailDefinitions(QMap<QString, QContactDetailDefinition> &definitions, const QString& contactType) const |
|
149 { |
|
150 Q_UNUSED(contactType); |
|
151 |
|
152 if(definitions.contains(QContactRingtone::DefinitionName)) { |
|
153 QContactDetailDefinition d = definitions.value(QContactRingtone::DefinitionName); |
|
154 QMap<QString, QContactDetailFieldDefinition> fields = d.fields(); |
|
155 |
|
156 // Context not supported in symbian back-end, remove |
|
157 fields.remove(QContactRingtone::FieldContext); |
|
158 // nor vibe thingy |
|
159 fields.remove(QContactRingtone::FieldVibrationRingtoneUrl); |
|
160 |
|
161 d.setFields(fields); |
|
162 d.setUnique(true); |
|
163 |
|
164 // Replace original definitions |
|
165 definitions.insert(d.name(), d); |
|
166 } |
|
167 } |