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 test suite 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 QORGANIZERMALICIOUSPLUGIN_P_H |
35 | #define QORGANIZERMALICIOUSPLUGIN_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 <QObject> |
49 | |
50 | #include <QtOrganizer/qorganizermanager.h> |
51 | #include <QtOrganizer/qorganizermanagerengine.h> |
52 | #include <QtOrganizer/qorganizermanagerenginefactory.h> |
53 | |
54 | QT_FORWARD_DECLARE_CLASS(QThread) |
55 | |
56 | QTORGANIZER_USE_NAMESPACE |
57 | |
58 | class MaliciousThreadObject; |
59 | class MaliciousAsyncManagerEngine : public QOrganizerManagerEngine |
60 | { |
61 | Q_OBJECT |
62 | |
63 | public: |
64 | MaliciousAsyncManagerEngine(); |
65 | ~MaliciousAsyncManagerEngine(); |
66 | |
67 | QString managerName() const; |
68 | bool startRequest(QOrganizerAbstractRequest *req); |
69 | bool cancelRequest(QOrganizerAbstractRequest *req); |
70 | |
71 | QMap<QString, QString> managerParameters() const { return QMap<QString, QString>(); } |
72 | int managerVersion() const { return 0; } |
73 | |
74 | // items |
75 | QList<QOrganizerItem> items(const QList<QOrganizerItemId> &itemIds, const QOrganizerItemFetchHint &fetchHint, |
76 | QMap<int, QOrganizerManager::Error> *errorMap, QOrganizerManager::Error *error) |
77 | { |
78 | return QOrganizerManagerEngine::items(itemIds, fetchHint, errorMap, error); |
79 | } |
80 | |
81 | QList<QOrganizerItem> items(const QOrganizerItemFilter &filter, const QDateTime &startDateTime, |
82 | const QDateTime &endDateTime, int maxCount, |
83 | const QList<QOrganizerItemSortOrder> &sortOrders, |
84 | const QOrganizerItemFetchHint &fetchHint, QOrganizerManager::Error *error) |
85 | { |
86 | return QOrganizerManagerEngine::items(filter, startDateTime, endDateTime, maxCount, sortOrders, fetchHint, error); |
87 | } |
88 | |
89 | QList<QOrganizerItemId> itemIds(const QOrganizerItemFilter &filter, const QDateTime &startDateTime, |
90 | const QDateTime &endDateTime, const QList<QOrganizerItemSortOrder> &sortOrders, |
91 | QOrganizerManager::Error *error) |
92 | { |
93 | return QOrganizerManagerEngine::itemIds(filter, startDateTime, endDateTime, sortOrders, error); |
94 | } |
95 | |
96 | QList<QOrganizerItem> itemOccurrences(const QOrganizerItem &parentItem, const QDateTime &startDateTime, |
97 | const QDateTime &endDateTime, int maxCount, |
98 | const QOrganizerItemFetchHint &fetchHint, QOrganizerManager::Error *error) |
99 | { |
100 | return QOrganizerManagerEngine::itemOccurrences(parentItem, startDateTime, endDateTime, maxCount, fetchHint, error); |
101 | } |
102 | |
103 | QList<QOrganizerItem> itemsForExport(const QDateTime &startDateTime, const QDateTime &endDateTime, |
104 | const QOrganizerItemFilter &filter, |
105 | const QList<QOrganizerItemSortOrder> &sortOrders, |
106 | const QOrganizerItemFetchHint &fetchHint, QOrganizerManager::Error *error) |
107 | { |
108 | return QOrganizerManagerEngine::itemsForExport(startDateTime, endDateTime, filter, sortOrders, fetchHint, error); |
109 | } |
110 | |
111 | bool saveItems(QList<QOrganizerItem> *items, const QList<QOrganizerItemDetail::DetailType> &detailMask, |
112 | QMap<int, QOrganizerManager::Error> *errorMap, QOrganizerManager::Error *error) |
113 | { |
114 | return QOrganizerManagerEngine::saveItems(items, detailMask, errorMap, error); |
115 | } |
116 | |
117 | bool removeItems(const QList<QOrganizerItemId> &itemIds, QMap<int, QOrganizerManager::Error> *errorMap, QOrganizerManager::Error *error) |
118 | { |
119 | return QOrganizerManagerEngine::removeItems(itemIds, errorMap, error); |
120 | } |
121 | |
122 | bool removeItems(const QList<QOrganizerItem> *items, QMap<int, QOrganizerManager::Error> *errorMap, QOrganizerManager::Error *error) |
123 | { |
124 | return QOrganizerManagerEngine::removeItems(items, errorMap, error); |
125 | } |
126 | |
127 | // collections |
128 | QOrganizerCollectionId defaultCollectionId() const |
129 | { |
130 | return QOrganizerManagerEngine::defaultCollectionId(); |
131 | } |
132 | |
133 | QOrganizerCollection collection(const QOrganizerCollectionId &collectionId, QOrganizerManager::Error *error) |
134 | { |
135 | return QOrganizerManagerEngine::collection(collectionId, error); |
136 | } |
137 | |
138 | QList<QOrganizerCollection> collections(QOrganizerManager::Error *error) |
139 | { |
140 | return QOrganizerManagerEngine::collections(error); |
141 | } |
142 | |
143 | bool saveCollection(QOrganizerCollection *collection, QOrganizerManager::Error *error) |
144 | { |
145 | return QOrganizerManagerEngine::saveCollection(collection, error); |
146 | } |
147 | |
148 | bool removeCollection(const QOrganizerCollectionId &collectionId, QOrganizerManager::Error *error) |
149 | { |
150 | return QOrganizerManagerEngine::removeCollection(collectionId, error); |
151 | } |
152 | |
153 | /* Asynchronous Request Support */ |
154 | void requestDestroyed(QOrganizerAbstractRequest *req); |
155 | bool waitForRequestFinished(QOrganizerAbstractRequest *req, int msecs) { return QOrganizerManagerEngine::waitForRequestFinished(request: req, msecs); } |
156 | |
157 | QList<QOrganizerItemFilter::FilterType> supportedFilters() const |
158 | { |
159 | return QOrganizerManagerEngine::supportedFilters(); |
160 | } |
161 | |
162 | QList<QOrganizerItemType::ItemType> supportedItemTypes() const |
163 | { |
164 | return QOrganizerManagerEngine::supportedItemTypes(); |
165 | } |
166 | QList<QOrganizerItemDetail::DetailType> supportedItemDetails(QOrganizerItemType::ItemType itemType) const |
167 | { |
168 | return QOrganizerManagerEngine::supportedItemDetails(itemType); |
169 | } |
170 | |
171 | signals: |
172 | void doStartRequest(QOrganizerAbstractRequest *req); |
173 | void doFinishRequest(QOrganizerAbstractRequest *req); |
174 | |
175 | private: |
176 | QThread *thread; |
177 | MaliciousThreadObject *threadObject; |
178 | }; |
179 | |
180 | |
181 | class MaliciousEngineFactory : public QOrganizerManagerEngineFactory |
182 | { |
183 | Q_OBJECT |
184 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QOrganizerManagerEngineFactoryInterface" FILE "malicious.json" ) |
185 | |
186 | public: |
187 | QString managerName() const; |
188 | QOrganizerManagerEngine *engine(const QMap<QString, QString> ¶meters, QOrganizerManager::Error *error); |
189 | |
190 | private: |
191 | MaliciousAsyncManagerEngine mame; |
192 | }; |
193 | |
194 | #endif // QORGANIZERMALICIOUSPLUGIN_P_H |
195 | |