Merge lp:~renatofilho/qtorganizer5-eds/fix-1240505 into lp:qtorganizer5-eds
- fix-1240505
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Gustavo Pichorim Boiko | ||||
Approved revision: | 29 | ||||
Merged at revision: | 25 | ||||
Proposed branch: | lp:~renatofilho/qtorganizer5-eds/fix-1240505 | ||||
Merge into: | lp:qtorganizer5-eds | ||||
Diff against target: |
555 lines (+329/-20) 9 files modified
qorganizer/CMakeLists.txt (+2/-0) qorganizer/qorganizer-eds-engine.cpp (+46/-3) qorganizer/qorganizer-eds-engine.h (+4/-0) qorganizer/qorganizer-eds-enginedata.h (+2/-1) qorganizer/qorganizer-eds-removebyidrequestdata.cpp (+131/-0) qorganizer/qorganizer-eds-removebyidrequestdata.h (+55/-0) qorganizer/qorganizer-eds-removerequestdata.cpp (+11/-8) qorganizer/qorganizer-eds-removerequestdata.h (+1/-0) tests/unittest/event-test.cpp (+77/-8) |
||||
To merge this branch: | bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1240505 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Pichorim Boiko (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+200436@code.launchpad.net |
Commit message
Implemented remove item by id;
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
- 26. By Renato Araujo Oliveira Filho
-
Added missing files.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:26
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 27. By Renato Araujo Oliveira Filho
-
Make sure that the item remove signal is fired.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:27
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 28. By Renato Araujo Oliveira Filho
-
Used Qstring to represet collectionId.
The function QOrganizerCollectionId: :fromString does not work if the plugin is not installed.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:28
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 29. By Renato Araujo Oliveira Filho
-
Emit the itemRemoved signal only once.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:29
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
Looks good!
Preview Diff
1 | === modified file 'qorganizer/CMakeLists.txt' | |||
2 | --- qorganizer/CMakeLists.txt 2013-12-03 18:45:04 +0000 | |||
3 | +++ qorganizer/CMakeLists.txt 2014-01-05 21:25:57 +0000 | |||
4 | @@ -11,6 +11,7 @@ | |||
5 | 11 | qorganizer-eds-engineid.cpp | 11 | qorganizer-eds-engineid.cpp |
6 | 12 | qorganizer-eds-removecollectionrequestdata.cpp | 12 | qorganizer-eds-removecollectionrequestdata.cpp |
7 | 13 | qorganizer-eds-removerequestdata.cpp | 13 | qorganizer-eds-removerequestdata.cpp |
8 | 14 | qorganizer-eds-removebyidrequestdata.cpp | ||
9 | 14 | qorganizer-eds-requestdata.cpp | 15 | qorganizer-eds-requestdata.cpp |
10 | 15 | qorganizer-eds-savecollectionrequestdata.cpp | 16 | qorganizer-eds-savecollectionrequestdata.cpp |
11 | 16 | qorganizer-eds-saverequestdata.cpp | 17 | qorganizer-eds-saverequestdata.cpp |
12 | @@ -27,6 +28,7 @@ | |||
13 | 27 | qorganizer-eds-engineid.h | 28 | qorganizer-eds-engineid.h |
14 | 28 | qorganizer-eds-removecollectionrequestdata.h | 29 | qorganizer-eds-removecollectionrequestdata.h |
15 | 29 | qorganizer-eds-removerequestdata.h | 30 | qorganizer-eds-removerequestdata.h |
16 | 31 | qorganizer-eds-removebyidrequestdata.h | ||
17 | 30 | qorganizer-eds-requestdata.h | 32 | qorganizer-eds-requestdata.h |
18 | 31 | qorganizer-eds-savecollectionrequestdata.h | 33 | qorganizer-eds-savecollectionrequestdata.h |
19 | 32 | qorganizer-eds-saverequestdata.h | 34 | qorganizer-eds-saverequestdata.h |
20 | 33 | 35 | ||
21 | === modified file 'qorganizer/qorganizer-eds-engine.cpp' | |||
22 | --- qorganizer/qorganizer-eds-engine.cpp 2013-12-11 15:23:52 +0000 | |||
23 | +++ qorganizer/qorganizer-eds-engine.cpp 2014-01-05 21:25:57 +0000 | |||
24 | @@ -24,6 +24,7 @@ | |||
25 | 24 | #include "qorganizer-eds-fetchbyidrequestdata.h" | 24 | #include "qorganizer-eds-fetchbyidrequestdata.h" |
26 | 25 | #include "qorganizer-eds-saverequestdata.h" | 25 | #include "qorganizer-eds-saverequestdata.h" |
27 | 26 | #include "qorganizer-eds-removerequestdata.h" | 26 | #include "qorganizer-eds-removerequestdata.h" |
28 | 27 | #include "qorganizer-eds-removebyidrequestdata.h" | ||
29 | 27 | #include "qorganizer-eds-savecollectionrequestdata.h" | 28 | #include "qorganizer-eds-savecollectionrequestdata.h" |
30 | 28 | #include "qorganizer-eds-removecollectionrequestdata.h" | 29 | #include "qorganizer-eds-removecollectionrequestdata.h" |
31 | 29 | #include "qorganizer-eds-viewwatcher.h" | 30 | #include "qorganizer-eds-viewwatcher.h" |
32 | @@ -43,6 +44,7 @@ | |||
33 | 43 | #include <QtOrganizer/QOrganizerItemFetchByIdRequest> | 44 | #include <QtOrganizer/QOrganizerItemFetchByIdRequest> |
34 | 44 | #include <QtOrganizer/QOrganizerItemSaveRequest> | 45 | #include <QtOrganizer/QOrganizerItemSaveRequest> |
35 | 45 | #include <QtOrganizer/QOrganizerItemRemoveRequest> | 46 | #include <QtOrganizer/QOrganizerItemRemoveRequest> |
36 | 47 | #include <QtOrganizer/QOrganizerItemRemoveByIdRequest> | ||
37 | 46 | #include <QtOrganizer/QOrganizerCollectionFetchRequest> | 48 | #include <QtOrganizer/QOrganizerCollectionFetchRequest> |
38 | 47 | #include <QtOrganizer/QOrganizerCollectionSaveRequest> | 49 | #include <QtOrganizer/QOrganizerCollectionSaveRequest> |
39 | 48 | #include <QtOrganizer/QOrganizerCollectionRemoveRequest> | 50 | #include <QtOrganizer/QOrganizerCollectionRemoveRequest> |
40 | @@ -457,7 +459,9 @@ | |||
41 | 457 | QOrganizerItem &item = items[i]; | 459 | QOrganizerItem &item = items[i]; |
42 | 458 | const gchar *uid = static_cast<const gchar*>(g_slist_nth_data(uids, i)); | 460 | const gchar *uid = static_cast<const gchar*>(g_slist_nth_data(uids, i)); |
43 | 459 | 461 | ||
45 | 460 | item.setCollectionId(QOrganizerCollectionId::fromString(data->currentCollection())); | 462 | QOrganizerEDSCollectionEngineId *edsCollectionId = new QOrganizerEDSCollectionEngineId(data->currentCollection()); |
46 | 463 | item.setCollectionId(QOrganizerCollectionId(edsCollectionId)); | ||
47 | 464 | |||
48 | 461 | QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(data->currentCollection(), | 465 | QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(data->currentCollection(), |
49 | 462 | QString::fromUtf8(uid)); | 466 | QString::fromUtf8(uid)); |
50 | 463 | item.setId(QOrganizerItemId(eid)); | 467 | item.setId(QOrganizerItemId(eid)); |
51 | @@ -497,6 +501,44 @@ | |||
52 | 497 | return true; | 501 | return true; |
53 | 498 | } | 502 | } |
54 | 499 | 503 | ||
55 | 504 | void QOrganizerEDSEngine::removeItemsByIdAsync(QOrganizerItemRemoveByIdRequest *req) | ||
56 | 505 | { | ||
57 | 506 | qDebug() << Q_FUNC_INFO; | ||
58 | 507 | if (req->itemIds().count() == 0) { | ||
59 | 508 | QOrganizerManagerEngine::updateItemRemoveByIdRequest(req, | ||
60 | 509 | QOrganizerManager::NoError, | ||
61 | 510 | QMap<int, QOrganizerManager::Error>(), | ||
62 | 511 | QOrganizerAbstractRequest::FinishedState); | ||
63 | 512 | return; | ||
64 | 513 | } | ||
65 | 514 | |||
66 | 515 | RemoveByIdRequestData *data = new RemoveByIdRequestData(this, req); | ||
67 | 516 | removeItemsByIdAsyncStart(data); | ||
68 | 517 | } | ||
69 | 518 | |||
70 | 519 | void QOrganizerEDSEngine::removeItemsByIdAsyncStart(RemoveByIdRequestData *data) | ||
71 | 520 | { | ||
72 | 521 | qDebug() << Q_FUNC_INFO; | ||
73 | 522 | QString collectionId = data->next(); | ||
74 | 523 | for(; !collectionId.isNull(); collectionId = data->next()) { | ||
75 | 524 | EClient *client = data->parent()->d->m_sourceRegistry->client(collectionId); | ||
76 | 525 | data->setClient(client); | ||
77 | 526 | g_object_unref(client); | ||
78 | 527 | GSList *ids = data->compIds(); | ||
79 | 528 | GError *gError = 0; | ||
80 | 529 | e_cal_client_remove_objects_sync(data->client(), ids, E_CAL_OBJ_MOD_ALL, 0, 0); | ||
81 | 530 | QCoreApplication::processEvents(); | ||
82 | 531 | if (gError) { | ||
83 | 532 | qWarning() << "Fail to remove Items" << gError->message; | ||
84 | 533 | g_error_free(gError); | ||
85 | 534 | gError = 0; | ||
86 | 535 | } | ||
87 | 536 | data->commit(); | ||
88 | 537 | } | ||
89 | 538 | data->finish(); | ||
90 | 539 | delete data; | ||
91 | 540 | } | ||
92 | 541 | |||
93 | 500 | void QOrganizerEDSEngine::removeItemsAsync(QOrganizerItemRemoveRequest *req) | 542 | void QOrganizerEDSEngine::removeItemsAsync(QOrganizerItemRemoveRequest *req) |
94 | 501 | { | 543 | { |
95 | 502 | qDebug() << Q_FUNC_INFO; | 544 | qDebug() << Q_FUNC_INFO; |
96 | @@ -746,6 +788,9 @@ | |||
97 | 746 | case QOrganizerAbstractRequest::ItemRemoveRequest: | 788 | case QOrganizerAbstractRequest::ItemRemoveRequest: |
98 | 747 | removeItemsAsync(qobject_cast<QOrganizerItemRemoveRequest*>(req)); | 789 | removeItemsAsync(qobject_cast<QOrganizerItemRemoveRequest*>(req)); |
99 | 748 | break; | 790 | break; |
100 | 791 | case QOrganizerAbstractRequest::ItemRemoveByIdRequest: | ||
101 | 792 | removeItemsByIdAsync(qobject_cast<QOrganizerItemRemoveByIdRequest*>(req)); | ||
102 | 793 | break; | ||
103 | 749 | case QOrganizerAbstractRequest::CollectionSaveRequest: | 794 | case QOrganizerAbstractRequest::CollectionSaveRequest: |
104 | 750 | saveCollectionAsync(qobject_cast<QOrganizerCollectionSaveRequest*>(req)); | 795 | saveCollectionAsync(qobject_cast<QOrganizerCollectionSaveRequest*>(req)); |
105 | 751 | break; | 796 | break; |
106 | @@ -2019,5 +2064,3 @@ | |||
107 | 2019 | 2064 | ||
108 | 2020 | return comps; | 2065 | return comps; |
109 | 2021 | } | 2066 | } |
110 | 2022 | |||
111 | 2023 | |||
112 | 2024 | 2067 | ||
113 | === modified file 'qorganizer/qorganizer-eds-engine.h' | |||
114 | --- qorganizer/qorganizer-eds-engine.h 2013-12-06 16:24:23 +0000 | |||
115 | +++ qorganizer/qorganizer-eds-engine.h 2014-01-05 21:25:57 +0000 | |||
116 | @@ -40,6 +40,7 @@ | |||
117 | 40 | class FetchByIdRequestData; | 40 | class FetchByIdRequestData; |
118 | 41 | class SaveRequestData; | 41 | class SaveRequestData; |
119 | 42 | class RemoveRequestData; | 42 | class RemoveRequestData; |
120 | 43 | class RemoveByIdRequestData; | ||
121 | 43 | class SaveCollectionRequestData; | 44 | class SaveCollectionRequestData; |
122 | 44 | class RemoveCollectionRequestData; | 45 | class RemoveCollectionRequestData; |
123 | 45 | class ViewWatcher; | 46 | class ViewWatcher; |
124 | @@ -207,6 +208,9 @@ | |||
125 | 207 | static void saveItemsAsyncCreated(GObject *source_object, GAsyncResult *res, SaveRequestData *data); | 208 | static void saveItemsAsyncCreated(GObject *source_object, GAsyncResult *res, SaveRequestData *data); |
126 | 208 | static void saveItemsAsyncModified(GObject *source_object, GAsyncResult *res, SaveRequestData *data); | 209 | static void saveItemsAsyncModified(GObject *source_object, GAsyncResult *res, SaveRequestData *data); |
127 | 209 | 210 | ||
128 | 211 | void removeItemsByIdAsync(QtOrganizer::QOrganizerItemRemoveByIdRequest *req); | ||
129 | 212 | static void removeItemsByIdAsyncStart(RemoveByIdRequestData *data); | ||
130 | 213 | |||
131 | 210 | void removeItemsAsync(QtOrganizer::QOrganizerItemRemoveRequest *req); | 214 | void removeItemsAsync(QtOrganizer::QOrganizerItemRemoveRequest *req); |
132 | 211 | static void removeItemsAsyncStart(RemoveRequestData *data); | 215 | static void removeItemsAsyncStart(RemoveRequestData *data); |
133 | 212 | 216 | ||
134 | 213 | 217 | ||
135 | === modified file 'qorganizer/qorganizer-eds-enginedata.h' | |||
136 | --- qorganizer/qorganizer-eds-enginedata.h 2013-12-01 17:29:50 +0000 | |||
137 | +++ qorganizer/qorganizer-eds-enginedata.h 2014-01-05 21:25:57 +0000 | |||
138 | @@ -41,8 +41,9 @@ | |||
139 | 41 | template<class K> | 41 | template<class K> |
140 | 42 | void emitSharedSignals(K* cs) | 42 | void emitSharedSignals(K* cs) |
141 | 43 | { | 43 | { |
143 | 44 | Q_FOREACH(QtOrganizer::QOrganizerManagerEngine* engine, m_sharedEngines) | 44 | Q_FOREACH(QtOrganizer::QOrganizerManagerEngine* engine, m_sharedEngines) { |
144 | 45 | cs->emitSignals(engine); | 45 | cs->emitSignals(engine); |
145 | 46 | } | ||
146 | 46 | } | 47 | } |
147 | 47 | 48 | ||
148 | 48 | ViewWatcher* watch(const QString &collectionId); | 49 | ViewWatcher* watch(const QString &collectionId); |
149 | 49 | 50 | ||
150 | === added file 'qorganizer/qorganizer-eds-removebyidrequestdata.cpp' | |||
151 | --- qorganizer/qorganizer-eds-removebyidrequestdata.cpp 1970-01-01 00:00:00 +0000 | |||
152 | +++ qorganizer/qorganizer-eds-removebyidrequestdata.cpp 2014-01-05 21:25:57 +0000 | |||
153 | @@ -0,0 +1,131 @@ | |||
154 | 1 | /* | ||
155 | 2 | * Copyright 2013 Canonical Ltd. | ||
156 | 3 | * | ||
157 | 4 | * This file is part of ubuntu-pim-service. | ||
158 | 5 | * | ||
159 | 6 | * contact-service-app is free software; you can redistribute it and/or modify | ||
160 | 7 | * it under the terms of the GNU General Public License as published by | ||
161 | 8 | * the Free Software Foundation; version 3. | ||
162 | 9 | * | ||
163 | 10 | * contact-service-app is distributed in the hope that it will be useful, | ||
164 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
165 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
166 | 13 | * GNU General Public License for more details. | ||
167 | 14 | * | ||
168 | 15 | * You should have received a copy of the GNU General Public License | ||
169 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
170 | 17 | */ | ||
171 | 18 | |||
172 | 19 | #include "qorganizer-eds-removebyidrequestdata.h" | ||
173 | 20 | #include "qorganizer-eds-engineid.h" | ||
174 | 21 | #include "qorganizer-eds-enginedata.h" | ||
175 | 22 | |||
176 | 23 | #include <QtOrganizer/QOrganizerManagerEngine> | ||
177 | 24 | #include <QtOrganizer/QOrganizerItemRemoveByIdRequest> | ||
178 | 25 | |||
179 | 26 | using namespace QtOrganizer; | ||
180 | 27 | |||
181 | 28 | RemoveByIdRequestData::RemoveByIdRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req) | ||
182 | 29 | : RequestData(engine, req), | ||
183 | 30 | m_sessionStaterd(0), | ||
184 | 31 | m_currentCompIds(0) | ||
185 | 32 | { | ||
186 | 33 | Q_FOREACH(const QOrganizerItemId &id, request<QOrganizerItemRemoveByIdRequest>()->itemIds()) { | ||
187 | 34 | QString strId = id.toString(); | ||
188 | 35 | QString collectionId; | ||
189 | 36 | if (strId.contains("/")) { | ||
190 | 37 | collectionId = strId.split("/").first(); | ||
191 | 38 | QSet<QOrganizerItemId> ids = m_pending.value(collectionId); | ||
192 | 39 | ids << id; | ||
193 | 40 | m_pending.insert(collectionId, ids); | ||
194 | 41 | } | ||
195 | 42 | } | ||
196 | 43 | } | ||
197 | 44 | |||
198 | 45 | RemoveByIdRequestData::~RemoveByIdRequestData() | ||
199 | 46 | { | ||
200 | 47 | } | ||
201 | 48 | |||
202 | 49 | void RemoveByIdRequestData::finish(QtOrganizer::QOrganizerManager::Error error) | ||
203 | 50 | { | ||
204 | 51 | QOrganizerManagerEngine::updateItemRemoveByIdRequest(request<QOrganizerItemRemoveByIdRequest>(), | ||
205 | 52 | error, | ||
206 | 53 | QMap<int, QOrganizerManager::Error>(), | ||
207 | 54 | QOrganizerAbstractRequest::FinishedState); | ||
208 | 55 | //The signal will be fired by the view watcher. Check ViewWatcher::onObjectsRemoved | ||
209 | 56 | //emitChangeset(&m_changeSet); | ||
210 | 57 | } | ||
211 | 58 | |||
212 | 59 | GSList *RemoveByIdRequestData::compIds() const | ||
213 | 60 | { | ||
214 | 61 | return m_currentCompIds; | ||
215 | 62 | } | ||
216 | 63 | |||
217 | 64 | void RemoveByIdRequestData::commit() | ||
218 | 65 | { | ||
219 | 66 | Q_ASSERT(m_sessionStaterd); | ||
220 | 67 | QOrganizerManagerEngine::updateItemRemoveByIdRequest(request<QOrganizerItemRemoveByIdRequest>(), | ||
221 | 68 | QtOrganizer::QOrganizerManager::NoError, | ||
222 | 69 | QMap<int, QOrganizerManager::Error>(), | ||
223 | 70 | QOrganizerAbstractRequest::ActiveState); | ||
224 | 71 | reset(); | ||
225 | 72 | } | ||
226 | 73 | |||
227 | 74 | GSList *RemoveByIdRequestData::parseIds(QSet<QOrganizerItemId> iids) | ||
228 | 75 | { | ||
229 | 76 | GSList *ids = 0; | ||
230 | 77 | Q_FOREACH(const QOrganizerItemId &iid, iids) { | ||
231 | 78 | ECalComponentId *id = g_new0(ECalComponentId, 1); | ||
232 | 79 | id->uid = g_strdup(QOrganizerEDSEngineId::toComponentId(iid).toUtf8().data()); | ||
233 | 80 | id->rid = NULL; | ||
234 | 81 | ids = g_slist_append(ids, id); | ||
235 | 82 | } | ||
236 | 83 | |||
237 | 84 | return ids; | ||
238 | 85 | } | ||
239 | 86 | |||
240 | 87 | QString RemoveByIdRequestData::next() | ||
241 | 88 | { | ||
242 | 89 | Q_ASSERT(!m_sessionStaterd); | ||
243 | 90 | |||
244 | 91 | if (m_pending.count() > 0) { | ||
245 | 92 | m_sessionStaterd = true; | ||
246 | 93 | m_currentCollectionId = m_pending.keys().first(); | ||
247 | 94 | m_currentIds = m_pending[m_currentCollectionId]; | ||
248 | 95 | m_currentCompIds = parseIds(m_currentIds); | ||
249 | 96 | m_pending.remove(m_currentCollectionId); | ||
250 | 97 | return m_currentCollectionId; | ||
251 | 98 | } | ||
252 | 99 | return QString(QString::null); | ||
253 | 100 | } | ||
254 | 101 | |||
255 | 102 | |||
256 | 103 | void RemoveByIdRequestData::reset() | ||
257 | 104 | { | ||
258 | 105 | m_currentIds.clear(); | ||
259 | 106 | m_currentCollectionId = QString(QString::null); | ||
260 | 107 | if (m_currentCompIds) { | ||
261 | 108 | g_slist_free_full(m_currentCompIds, (GDestroyNotify)e_cal_component_free_id); | ||
262 | 109 | m_currentCompIds = 0; | ||
263 | 110 | } | ||
264 | 111 | m_sessionStaterd = false; | ||
265 | 112 | } | ||
266 | 113 | |||
267 | 114 | void RemoveByIdRequestData::cancel() | ||
268 | 115 | { | ||
269 | 116 | Q_ASSERT(m_sessionStaterd); | ||
270 | 117 | RequestData::cancel(); | ||
271 | 118 | clear(); | ||
272 | 119 | } | ||
273 | 120 | |||
274 | 121 | void RemoveByIdRequestData::clear() | ||
275 | 122 | { | ||
276 | 123 | reset(); | ||
277 | 124 | m_pending.clear(); | ||
278 | 125 | setClient(0); | ||
279 | 126 | } | ||
280 | 127 | |||
281 | 128 | QString RemoveByIdRequestData::collectionId() const | ||
282 | 129 | { | ||
283 | 130 | return m_currentCollectionId; | ||
284 | 131 | } | ||
285 | 0 | 132 | ||
286 | === added file 'qorganizer/qorganizer-eds-removebyidrequestdata.h' | |||
287 | --- qorganizer/qorganizer-eds-removebyidrequestdata.h 1970-01-01 00:00:00 +0000 | |||
288 | +++ qorganizer/qorganizer-eds-removebyidrequestdata.h 2014-01-05 21:25:57 +0000 | |||
289 | @@ -0,0 +1,55 @@ | |||
290 | 1 | /* | ||
291 | 2 | * Copyright 2013 Canonical Ltd. | ||
292 | 3 | * | ||
293 | 4 | * This file is part of ubuntu-pim-service. | ||
294 | 5 | * | ||
295 | 6 | * contact-service-app is free software; you can redistribute it and/or modify | ||
296 | 7 | * it under the terms of the GNU General Public License as published by | ||
297 | 8 | * the Free Software Foundation; version 3. | ||
298 | 9 | * | ||
299 | 10 | * contact-service-app is distributed in the hope that it will be useful, | ||
300 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
301 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
302 | 13 | * GNU General Public License for more details. | ||
303 | 14 | * | ||
304 | 15 | * You should have received a copy of the GNU General Public License | ||
305 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
306 | 17 | */ | ||
307 | 18 | |||
308 | 19 | #ifndef __QORGANIZER_EDS_REMOVEBYIDQUESTDATA_H__ | ||
309 | 20 | #define __QORGANIZER_EDS_REMOVEBYIDQUESTDATA_H__ | ||
310 | 21 | |||
311 | 22 | #include "qorganizer-eds-requestdata.h" | ||
312 | 23 | |||
313 | 24 | #include <glib.h> | ||
314 | 25 | |||
315 | 26 | class RemoveByIdRequestData : public RequestData | ||
316 | 27 | { | ||
317 | 28 | public: | ||
318 | 29 | RemoveByIdRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); | ||
319 | 30 | ~RemoveByIdRequestData(); | ||
320 | 31 | |||
321 | 32 | QString collectionId() const; | ||
322 | 33 | |||
323 | 34 | void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); | ||
324 | 35 | |||
325 | 36 | GSList *compIds() const; | ||
326 | 37 | |||
327 | 38 | QString next(); | ||
328 | 39 | void commit(); | ||
329 | 40 | virtual void cancel(); | ||
330 | 41 | |||
331 | 42 | private: | ||
332 | 43 | QHash<QString, QSet<QtOrganizer::QOrganizerItemId> > m_pending; | ||
333 | 44 | QSet<QtOrganizer::QOrganizerItemId> m_currentIds; | ||
334 | 45 | QString m_currentCollectionId; | ||
335 | 46 | |||
336 | 47 | bool m_sessionStaterd; | ||
337 | 48 | GSList *m_currentCompIds; | ||
338 | 49 | |||
339 | 50 | void reset(); | ||
340 | 51 | void clear(); | ||
341 | 52 | GSList *parseIds(QSet<QtOrganizer::QOrganizerItemId> iids); | ||
342 | 53 | }; | ||
343 | 54 | |||
344 | 55 | #endif | ||
345 | 0 | 56 | ||
346 | === modified file 'qorganizer/qorganizer-eds-removerequestdata.cpp' | |||
347 | --- qorganizer/qorganizer-eds-removerequestdata.cpp 2013-12-11 13:16:50 +0000 | |||
348 | +++ qorganizer/qorganizer-eds-removerequestdata.cpp 2014-01-05 21:25:57 +0000 | |||
349 | @@ -74,7 +74,8 @@ | |||
350 | 74 | QMap<int, QOrganizerManager::Error>(), | 74 | QMap<int, QOrganizerManager::Error>(), |
351 | 75 | QOrganizerAbstractRequest::FinishedState); | 75 | QOrganizerAbstractRequest::FinishedState); |
352 | 76 | 76 | ||
354 | 77 | emitChangeset(&m_changeSet); | 77 | //The signal will be fired by the view watcher. Check ViewWatcher::onObjectsRemoved |
355 | 78 | //emitChangeset(&m_changeSet); | ||
356 | 78 | } | 79 | } |
357 | 79 | 80 | ||
358 | 80 | GSList *RemoveRequestData::compIds() const | 81 | GSList *RemoveRequestData::compIds() const |
359 | @@ -89,10 +90,7 @@ | |||
360 | 89 | QtOrganizer::QOrganizerManager::NoError, | 90 | QtOrganizer::QOrganizerManager::NoError, |
361 | 90 | QMap<int, QOrganizerManager::Error>(), | 91 | QMap<int, QOrganizerManager::Error>(), |
362 | 91 | QOrganizerAbstractRequest::ActiveState); | 92 | QOrganizerAbstractRequest::ActiveState); |
367 | 92 | 93 | reset(); | |
364 | 93 | m_changeSet.insertRemovedItems(m_currentIds); | ||
365 | 94 | m_currentCollectionId = QOrganizerCollectionId(); | ||
366 | 95 | clear(); | ||
368 | 96 | } | 94 | } |
369 | 97 | 95 | ||
370 | 98 | QOrganizerCollectionId RemoveRequestData::next() | 96 | QOrganizerCollectionId RemoveRequestData::next() |
371 | @@ -116,12 +114,11 @@ | |||
372 | 116 | clear(); | 114 | clear(); |
373 | 117 | } | 115 | } |
374 | 118 | 116 | ||
376 | 119 | void RemoveRequestData::clear() | 117 | void RemoveRequestData::reset() |
377 | 120 | { | 118 | { |
379 | 121 | m_changeSet.clearAll(); | 119 | m_currentCollectionId = QOrganizerCollectionId(); |
380 | 122 | m_currentIds.clear(); | 120 | m_currentIds.clear(); |
381 | 123 | 121 | ||
382 | 124 | setClient(0); | ||
383 | 125 | if (m_currentCompIds) { | 122 | if (m_currentCompIds) { |
384 | 126 | g_slist_free_full(m_currentCompIds, (GDestroyNotify)e_cal_component_free_id); | 123 | g_slist_free_full(m_currentCompIds, (GDestroyNotify)e_cal_component_free_id); |
385 | 127 | m_currentCompIds = 0; | 124 | m_currentCompIds = 0; |
386 | @@ -129,6 +126,12 @@ | |||
387 | 129 | m_sessionStaterd = false; | 126 | m_sessionStaterd = false; |
388 | 130 | } | 127 | } |
389 | 131 | 128 | ||
390 | 129 | void RemoveRequestData::clear() | ||
391 | 130 | { | ||
392 | 131 | reset(); | ||
393 | 132 | setClient(0); | ||
394 | 133 | } | ||
395 | 134 | |||
396 | 132 | QOrganizerCollectionId RemoveRequestData::collectionId() const | 135 | QOrganizerCollectionId RemoveRequestData::collectionId() const |
397 | 133 | { | 136 | { |
398 | 134 | return m_currentCollectionId; | 137 | return m_currentCollectionId; |
399 | 135 | 138 | ||
400 | === modified file 'qorganizer/qorganizer-eds-removerequestdata.h' | |||
401 | --- qorganizer/qorganizer-eds-removerequestdata.h 2013-12-01 21:48:44 +0000 | |||
402 | +++ qorganizer/qorganizer-eds-removerequestdata.h 2014-01-05 21:25:57 +0000 | |||
403 | @@ -50,6 +50,7 @@ | |||
404 | 50 | QtOrganizer::QOrganizerCollectionId m_currentCollectionId; | 50 | QtOrganizer::QOrganizerCollectionId m_currentCollectionId; |
405 | 51 | 51 | ||
406 | 52 | void clear(); | 52 | void clear(); |
407 | 53 | void reset(); | ||
408 | 53 | GSList* takeItemsIds(QtOrganizer::QOrganizerCollectionId collectionId); | 54 | GSList* takeItemsIds(QtOrganizer::QOrganizerCollectionId collectionId); |
409 | 54 | }; | 55 | }; |
410 | 55 | 56 | ||
411 | 56 | 57 | ||
412 | === modified file 'tests/unittest/event-test.cpp' | |||
413 | --- tests/unittest/event-test.cpp 2013-12-11 13:16:50 +0000 | |||
414 | +++ tests/unittest/event-test.cpp 2014-01-05 21:25:57 +0000 | |||
415 | @@ -37,17 +37,22 @@ | |||
416 | 37 | static const QString defaultTaskCollectionName; | 37 | static const QString defaultTaskCollectionName; |
417 | 38 | static const QString collectionTypePropertyName; | 38 | static const QString collectionTypePropertyName; |
418 | 39 | static const QString taskListTypeName; | 39 | static const QString taskListTypeName; |
419 | 40 | static int signalIndex; | ||
420 | 40 | 41 | ||
421 | 41 | QDateTime m_itemRemovedTime; | 42 | QDateTime m_itemRemovedTime; |
422 | 42 | QDateTime m_requestFinishedTime; | 43 | QDateTime m_requestFinishedTime; |
423 | 43 | QOrganizerEDSEngine *m_engine; | 44 | QOrganizerEDSEngine *m_engine; |
424 | 44 | QOrganizerCollection m_collection; | 45 | QOrganizerCollection m_collection; |
425 | 45 | 46 | ||
426 | 47 | |||
427 | 46 | private Q_SLOTS: | 48 | private Q_SLOTS: |
428 | 47 | void init() | 49 | void init() |
429 | 48 | { | 50 | { |
430 | 49 | EDSBaseTest::init(0); | 51 | EDSBaseTest::init(0); |
431 | 50 | 52 | ||
432 | 53 | signalIndex = 0; | ||
433 | 54 | m_itemRemovedTime = QDateTime(); | ||
434 | 55 | m_requestFinishedTime = QDateTime(); | ||
435 | 51 | m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); | 56 | m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
436 | 52 | 57 | ||
437 | 53 | QtOrganizer::QOrganizerManager::Error error; | 58 | QtOrganizer::QOrganizerManager::Error error; |
438 | @@ -69,12 +74,16 @@ | |||
439 | 69 | void itemRemoved() | 74 | void itemRemoved() |
440 | 70 | { | 75 | { |
441 | 71 | m_itemRemovedTime = QDateTime::currentDateTime(); | 76 | m_itemRemovedTime = QDateTime::currentDateTime(); |
442 | 77 | // avoid both signals to be fired at the same time | ||
443 | 78 | QTest::qSleep(100); | ||
444 | 72 | } | 79 | } |
445 | 73 | 80 | ||
446 | 74 | void requestFinished(QOrganizerAbstractRequest::State state) | 81 | void requestFinished(QOrganizerAbstractRequest::State state) |
447 | 75 | { | 82 | { |
448 | 76 | if (state == QOrganizerAbstractRequest::FinishedState) { | 83 | if (state == QOrganizerAbstractRequest::FinishedState) { |
450 | 77 | m_requestFinishedTime = QDateTime::currentDateTime(); | 84 | m_requestFinishedTime = QDateTime::currentDateTime(); |
451 | 85 | // avoid both signals to be fired at the same time | ||
452 | 86 | QTest::qSleep(100); | ||
453 | 78 | } | 87 | } |
454 | 79 | } | 88 | } |
455 | 80 | 89 | ||
456 | @@ -177,15 +186,13 @@ | |||
457 | 177 | &error); | 186 | &error); |
458 | 178 | QVERIFY(saveResult); | 187 | QVERIFY(saveResult); |
459 | 179 | QCOMPARE(error, QOrganizerManager::NoError); | 188 | QCOMPARE(error, QOrganizerManager::NoError); |
460 | 189 | QCOMPARE(items.size(), 1); | ||
461 | 180 | QVERIFY(errorMap.isEmpty()); | 190 | QVERIFY(errorMap.isEmpty()); |
462 | 181 | QVERIFY(!items[0].id().isNull()); | 191 | QVERIFY(!items[0].id().isNull()); |
463 | 182 | 192 | ||
464 | 183 | // append new item to be removed after the test | 193 | // append new item to be removed after the test |
465 | 184 | appendToRemove(items[0].id()); | 194 | appendToRemove(items[0].id()); |
466 | 185 | 195 | ||
467 | 186 | m_itemRemovedTime = QDateTime(); | ||
468 | 187 | m_requestFinishedTime = QDateTime(); | ||
469 | 188 | |||
470 | 189 | QOrganizerItemRemoveRequest req; | 196 | QOrganizerItemRemoveRequest req; |
471 | 190 | connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), | 197 | connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), |
472 | 191 | this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); | 198 | this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); |
473 | @@ -197,9 +204,71 @@ | |||
474 | 197 | m_engine->waitForRequestFinished(&req, -1); | 204 | m_engine->waitForRequestFinished(&req, -1); |
475 | 198 | 205 | ||
476 | 199 | // check if the signal item removed was fired after the request finish | 206 | // check if the signal item removed was fired after the request finish |
480 | 200 | QVERIFY(!m_itemRemovedTime.isValid()); | 207 | QTRY_VERIFY(m_requestFinishedTime.isValid()); |
481 | 201 | QVERIFY(m_requestFinishedTime.isValid()); | 208 | QTRY_VERIFY(m_itemRemovedTime.isValid()); |
482 | 202 | QVERIFY(m_requestFinishedTime > m_itemRemovedTime); | 209 | QVERIFY(m_itemRemovedTime > m_requestFinishedTime); |
483 | 210 | } | ||
484 | 211 | |||
485 | 212 | void testRemoveItemById() | ||
486 | 213 | { | ||
487 | 214 | static QString displayLabelValue = QStringLiteral("event to be removed"); | ||
488 | 215 | static QString descriptionValue = QStringLiteral("removable event"); | ||
489 | 216 | |||
490 | 217 | QOrganizerTodo todo; | ||
491 | 218 | todo.setCollectionId(m_collection.id()); | ||
492 | 219 | todo.setStartDateTime(QDateTime(QDate(2013, 9, 3), QTime(0,30,0))); | ||
493 | 220 | todo.setDisplayLabel(displayLabelValue); | ||
494 | 221 | todo.setDescription(descriptionValue); | ||
495 | 222 | |||
496 | 223 | QtOrganizer::QOrganizerManager::Error error; | ||
497 | 224 | QMap<int, QtOrganizer::QOrganizerManager::Error> errorMap; | ||
498 | 225 | QList<QOrganizerItem> items; | ||
499 | 226 | items << todo; | ||
500 | 227 | bool saveResult = m_engine->saveItems(&items, | ||
501 | 228 | QList<QtOrganizer::QOrganizerItemDetail::DetailType>(), | ||
502 | 229 | &errorMap, | ||
503 | 230 | &error); | ||
504 | 231 | QVERIFY(saveResult); | ||
505 | 232 | QCOMPARE(error, QOrganizerManager::NoError); | ||
506 | 233 | QVERIFY(errorMap.isEmpty()); | ||
507 | 234 | QOrganizerItemId id = items[0].id(); | ||
508 | 235 | QVERIFY(!id.isNull()); | ||
509 | 236 | |||
510 | 237 | // append new item to be removed after the test | ||
511 | 238 | appendToRemove(id); | ||
512 | 239 | |||
513 | 240 | QOrganizerItemRemoveByIdRequest req; | ||
514 | 241 | |||
515 | 242 | connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), | ||
516 | 243 | this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); | ||
517 | 244 | connect(m_engine, SIGNAL(itemsRemoved(QList<QOrganizerItemId>)), | ||
518 | 245 | this, SLOT(itemRemoved())); | ||
519 | 246 | req.setItemId(id); | ||
520 | 247 | |||
521 | 248 | m_engine->startRequest(&req); | ||
522 | 249 | m_engine->waitForRequestFinished(&req, -1); | ||
523 | 250 | |||
524 | 251 | // check if the signal item removed was fired after the request finish | ||
525 | 252 | QTRY_VERIFY(m_requestFinishedTime.isValid()); | ||
526 | 253 | QTRY_VERIFY(m_itemRemovedTime.isValid()); | ||
527 | 254 | QVERIFY(m_itemRemovedTime > m_requestFinishedTime); | ||
528 | 255 | |||
529 | 256 | // check if item was removed | ||
530 | 257 | QOrganizerItemSortOrder sort; | ||
531 | 258 | QOrganizerItemFetchHint hint; | ||
532 | 259 | QOrganizerItemIdFilter filter; | ||
533 | 260 | |||
534 | 261 | QList<QOrganizerItemId> ids; | ||
535 | 262 | ids << id; | ||
536 | 263 | filter.setIds(ids); | ||
537 | 264 | items = m_engine->items(filter, | ||
538 | 265 | QDateTime(), | ||
539 | 266 | QDateTime(), | ||
540 | 267 | 10, | ||
541 | 268 | sort, | ||
542 | 269 | hint, | ||
543 | 270 | &error); | ||
544 | 271 | QCOMPARE(items.count(), 0); | ||
545 | 203 | } | 272 | } |
546 | 204 | 273 | ||
547 | 205 | void testCreateMultipleItemsWithSameCollection() | 274 | void testCreateMultipleItemsWithSameCollection() |
548 | @@ -325,7 +394,7 @@ | |||
549 | 325 | const QString EventTest::defaultTaskCollectionName = QStringLiteral("TEST_EVENT_COLLECTION TASK LIST"); | 394 | const QString EventTest::defaultTaskCollectionName = QStringLiteral("TEST_EVENT_COLLECTION TASK LIST"); |
550 | 326 | const QString EventTest::collectionTypePropertyName = QStringLiteral("collection-type"); | 395 | const QString EventTest::collectionTypePropertyName = QStringLiteral("collection-type"); |
551 | 327 | const QString EventTest::taskListTypeName = QStringLiteral("Task List"); | 396 | const QString EventTest::taskListTypeName = QStringLiteral("Task List"); |
553 | 328 | 397 | int EventTest::signalIndex = 0; | |
554 | 329 | 398 | ||
555 | 330 | QTEST_MAIN(EventTest) | 399 | QTEST_MAIN(EventTest) |
556 | 331 | 400 |
FAILED: Continuous integration, rev:25 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-ci/ 65/ jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- amd64-ci/ 52/console jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- armhf-ci/ 52/console jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-trusty- i386-ci/ 52/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtorganizer 5-eds-ci/ 65/rebuild
http://