1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2015 The Qt Company Ltd. |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtVersit module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL21$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 2.1 or version 3 as published by the Free |
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
22 | ** following information to ensure the GNU Lesser General Public License |
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
25 | ** |
26 | ** As a special exception, The Qt Company gives you certain additional |
27 | ** rights. These rights are described in The Qt Company LGPL Exception |
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
29 | ** |
30 | ** $QT_END_LICENSE$ |
31 | ** |
32 | ****************************************************************************/ |
33 | |
34 | #ifndef QVERSITCONTACTEXPORTER_P_H |
35 | #define QVERSITCONTACTEXPORTER_P_H |
36 | |
37 | // |
38 | // W A R N I N G |
39 | // ------------- |
40 | // |
41 | // This file is not part of the Qt API. It exists purely as an |
42 | // implementation detail. This header file may change from version to |
43 | // version without notice, or even be removed. |
44 | // |
45 | // We mean it. |
46 | // |
47 | |
48 | #include <QtCore/qhash.h> |
49 | #include <QtCore/qlist.h> |
50 | #include <QtCore/qmap.h> |
51 | |
52 | #include <QtVersit/qversitdocument.h> |
53 | #include <QtVersit/qversitproperty.h> |
54 | |
55 | QT_BEGIN_NAMESPACE_CONTACTS |
56 | class QContact; |
57 | class QContactDetail; |
58 | QT_END_NAMESPACE_CONTACTS |
59 | |
60 | QTCONTACTS_USE_NAMESPACE |
61 | |
62 | QT_BEGIN_NAMESPACE_VERSIT |
63 | |
64 | class QVersitContactHandler; |
65 | |
66 | class QVersitContactExporterPrivate |
67 | { |
68 | public: |
69 | QVersitContactExporterPrivate(const QStringList& profiles = QStringList()); |
70 | ~QVersitContactExporterPrivate(); |
71 | |
72 | void exportContact(const QContact& contact, QVersitDocument& versitDocument); |
73 | |
74 | protected: |
75 | static void ensureDocumentContainsName(QVersitDocument* document); |
76 | void encodeName(const QContactDetail& detail, |
77 | const QVersitDocument& document, |
78 | QList<QVersitProperty>* removedProperties, |
79 | QList<QVersitProperty>* generatedProperties, |
80 | QSet<int> *processedFields); |
81 | void encodePhoneNumber(const QContactDetail& detail, |
82 | QList<QVersitProperty>* generatedProperties, |
83 | QSet<int> *processedFields); |
84 | void encodeEmail(const QContactDetail& detail, |
85 | QList<QVersitProperty>* generatedProperties, |
86 | QSet<int> *processedFields); |
87 | void encodeAddress(const QContactDetail& detail, |
88 | QList<QVersitProperty>* generatedProperties, |
89 | QSet<int> *processedFields); |
90 | void encodeUrl(const QContactDetail& detail, |
91 | QList<QVersitProperty>* generatedProperties, |
92 | QSet<int> *processedFields); |
93 | void encodeUid(const QContactDetail& detail, |
94 | QList<QVersitProperty>* generatedProperties, |
95 | QSet<int> *processedFields); |
96 | void encodeRev(const QContactDetail& detail, |
97 | QList<QVersitProperty>* generatedProperties, |
98 | QSet<int> *processedFields); |
99 | void encodeVersion(const QContactDetail &detail, |
100 | QList<QVersitProperty>* generatedProperties, |
101 | QSet<int> *processedFields); |
102 | void encodeBirthDay(const QContactDetail& detail, |
103 | QList<QVersitProperty>* generatedProperties, |
104 | QSet<int> *processedFields); |
105 | void encodeNote(const QContactDetail& detail, |
106 | QList<QVersitProperty>* generatedProperties, |
107 | QSet<int> *processedFields); |
108 | void encodeGeoLocation( |
109 | const QContactDetail& detail, |
110 | QList<QVersitProperty>* generatedProperties, |
111 | QSet<int>* processedFields); |
112 | void encodeOrganization(const QContactDetail& detail, |
113 | QList<QVersitProperty>* generatedProperties, |
114 | QSet<int> *processedFields); |
115 | void encodeRingtone(const QContactDetail &detail, |
116 | QList<QVersitProperty>* generatedProperties, |
117 | QSet<int> *processedFields); |
118 | void encodeAvatar(const QContactDetail &detail, |
119 | QList<QVersitProperty>* generatedProperties, |
120 | QSet<int> *processedFields); |
121 | void encodeGender(const QContactDetail &detail, |
122 | QList<QVersitProperty>* generatedProperties, |
123 | QSet<int> *processedFields); |
124 | void encodeNickname(const QContactDetail &detail, |
125 | const QVersitDocument& document, |
126 | QList<QVersitProperty>* removedProperties, |
127 | QList<QVersitProperty>* generatedProperties, |
128 | QSet<int> *processedFields); |
129 | void encodeTag(const QContactDetail &detail, |
130 | const QVersitDocument& document, |
131 | QList<QVersitProperty>* removedProperties, |
132 | QList<QVersitProperty>* generatedProperties, |
133 | QSet<int> *processedFields); |
134 | void encodeAnniversary(const QContactDetail &detail, |
135 | QList<QVersitProperty>* generatedProperties, |
136 | QSet<int> *processedFields); |
137 | void encodeOnlineAccount(const QContactDetail &detail, |
138 | QList<QVersitProperty>* generatedProperties, |
139 | QSet<int> *processedFields); |
140 | void encodeFamily(const QContactDetail &detail, |
141 | QList<QVersitProperty>* generatedProperties, |
142 | QSet<int> *processedFields); |
143 | void encodeFavorite(const QContactDetail &detail, |
144 | QList<QVersitProperty>* generatedProperties, |
145 | QSet<int> *processedFields); |
146 | void encodeDisplayLabel( |
147 | const QContactDetail &detail, |
148 | const QVersitDocument& document, |
149 | QList<QVersitProperty>* removedProperties, |
150 | QList<QVersitProperty>* generatedProperties, |
151 | QSet<int>* processedFields); |
152 | void encodeExtendedDetail(const QContactDetail &detail, |
153 | QList<QVersitProperty>* generatedProperties, |
154 | QSet<int> *processedFields); |
155 | |
156 | bool isValidRemoteUrl(const QString& resourceIdentifier); |
157 | void encodeParameters(QVersitProperty& property, |
158 | const QContactDetail::DetailType detailType, |
159 | const QList<int> &contexts, |
160 | const QList<int> &subTypes=QList<int>()); |
161 | bool encodeContentFromFile(const QString& resourcePath, QVersitProperty& property); |
162 | |
163 | public: // Data |
164 | QList<QVersitDocument> mDocuments; |
165 | QMap<int, QVersitContactExporter::Error> mErrors; |
166 | QVersitContactExporterDetailHandler* mDetailHandler; |
167 | QVersitContactExporterDetailHandlerV2* mDetailHandler2; |
168 | QList<QVersitContactHandler*> mPluginDetailHandlers; |
169 | int mDetailHandlerVersion; |
170 | QVersitDefaultResourceHandler* mDefaultResourceHandler; |
171 | QVersitResourceHandler* mResourceHandler; |
172 | |
173 | // detail type -> <field type, versit property name>: |
174 | QMap<QContactDetail::DetailType, QPair<int, QString> > mPropertyMappings; |
175 | QMap< QPair<QContactDetail::DetailType, int>, QString> mSubTypeMappings; |
176 | QHash< int ,QString> mContextMappings; |
177 | }; |
178 | |
179 | QT_END_NAMESPACE_VERSIT |
180 | |
181 | #endif // QVERSITCONTACTEXPORTER_P_H |
182 | |