Merge lp:~renatofilho/qtorganizer5-eds/changes-notify into lp:~ubuntu-sdk-team/qtorganizer5-eds/trunk
- changes-notify
- Merge into trunk
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Gustavo Pichorim Boiko | ||||
| Approved revision: | 20 | ||||
| Merged at revision: | 15 | ||||
| Proposed branch: | lp:~renatofilho/qtorganizer5-eds/changes-notify | ||||
| Merge into: | lp:~ubuntu-sdk-team/qtorganizer5-eds/trunk | ||||
| Diff against target: |
1229 lines (+583/-119) 14 files modified
qorganizer/CMakeLists.txt (+2/-0) qorganizer/qorganizer-eds-collection-engineid.cpp (+25/-19) qorganizer/qorganizer-eds-collection-engineid.h (+2/-2) qorganizer/qorganizer-eds-engine.cpp (+180/-47) qorganizer/qorganizer-eds-engine.h (+10/-3) qorganizer/qorganizer-eds-engineid.cpp (+21/-19) qorganizer/qorganizer-eds-engineid.h (+4/-4) qorganizer/qorganizer-eds-fetchrequestdata.cpp (+1/-0) qorganizer/qorganizer-eds-requestdata.cpp (+6/-2) qorganizer/qorganizer-eds-savecollectionrequestdata.cpp (+1/-1) qorganizer/qorganizer-eds-viewwatcher.cpp (+211/-0) qorganizer/qorganizer-eds-viewwatcher.h (+63/-0) tests/unittest/collections-test.cpp (+28/-19) tests/unittest/itemid-test.cpp (+29/-3) |
||||
| To merge this branch: | bzr merge lp:~renatofilho/qtorganizer5-eds/changes-notify | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| PS Jenkins bot | continuous-integration | Approve | |
| Gustavo Pichorim Boiko (community) | Approve | ||
|
Review via email:
|
|||
This proposal supersedes a proposal from 2013-09-25.
Commit message
*Fixed default source/collection load;
*Implemented changes notify.
Description of the change
| PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
| PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:14
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
| PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:15
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
| PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:16
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 17. By Renato Araujo Oliveira Filho
-
Fixed crash during view watcher destructor.
| PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:17
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 18. By Renato Araujo Oliveira Filho
-
Implemented parse for attendee list.
| PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:18
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 19. By Renato Araujo Oliveira Filho
-
Removed tests which need EDS (causes problem on jenkins)
| PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:19
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 20. By Renato Araujo Oliveira Filho
-
removed duplicated code.
| Gustavo Pichorim Boiko (boiko) wrote : | # |
Looks good!
| PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:20
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
| PS Jenkins bot (ps-jenkins) : | # |
| Kunal Parmar (pkunal-parmar) wrote : | # |
works fine for calendar usecases.
Preview Diff
| 1 | === modified file 'qorganizer/CMakeLists.txt' |
| 2 | --- qorganizer/CMakeLists.txt 2013-09-04 01:33:06 +0000 |
| 3 | +++ qorganizer/CMakeLists.txt 2013-10-07 16:14:04 +0000 |
| 4 | @@ -12,6 +12,7 @@ |
| 5 | qorganizer-eds-requestdata.cpp |
| 6 | qorganizer-eds-savecollectionrequestdata.cpp |
| 7 | qorganizer-eds-saverequestdata.cpp |
| 8 | + qorganizer-eds-viewwatcher.cpp |
| 9 | ) |
| 10 | |
| 11 | set(QORGANIZER_BACKEND_HDRS |
| 12 | @@ -24,6 +25,7 @@ |
| 13 | qorganizer-eds-requestdata.h |
| 14 | qorganizer-eds-savecollectionrequestdata.h |
| 15 | qorganizer-eds-saverequestdata.h |
| 16 | + qorganizer-eds-viewwatcher.h |
| 17 | ) |
| 18 | |
| 19 | add_library(${QORGANIZER_BACKEND}-lib STATIC |
| 20 | |
| 21 | === modified file 'qorganizer/qorganizer-eds-collection-engineid.cpp' |
| 22 | --- qorganizer/qorganizer-eds-collection-engineid.cpp 2013-09-03 03:57:58 +0000 |
| 23 | +++ qorganizer/qorganizer-eds-collection-engineid.cpp 2013-10-07 16:14:04 +0000 |
| 24 | @@ -17,12 +17,10 @@ |
| 25 | */ |
| 26 | |
| 27 | #include "qorganizer-eds-collection-engineid.h" |
| 28 | - |
| 29 | - |
| 30 | - |
| 31 | -QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId(ESource *source, |
| 32 | - const QString &managerUri) |
| 33 | - : m_managerUri(managerUri), m_esource(source) |
| 34 | +#include "qorganizer-eds-engineid.h" |
| 35 | + |
| 36 | +QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId(ESource *source) |
| 37 | + : m_esource(source) |
| 38 | { |
| 39 | g_object_ref(m_esource); |
| 40 | m_collectionId = QString::fromUtf8(e_source_get_uid(m_esource)); |
| 41 | @@ -39,26 +37,36 @@ |
| 42 | } |
| 43 | |
| 44 | QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId() |
| 45 | - : QOrganizerCollectionEngineId() |
| 46 | + : QOrganizerCollectionEngineId(), |
| 47 | + m_esource(0) |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId(const QOrganizerEDSCollectionEngineId& other) |
| 52 | - : QOrganizerCollectionEngineId(), m_collectionId(other.m_collectionId) |
| 53 | + : QOrganizerCollectionEngineId(), |
| 54 | + m_collectionId(other.m_collectionId), |
| 55 | + m_esource(other.m_esource), |
| 56 | + m_sourceType(other.m_sourceType) |
| 57 | { |
| 58 | + if (m_esource) { |
| 59 | + g_object_ref(m_esource); |
| 60 | + } |
| 61 | } |
| 62 | |
| 63 | QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId(const QString& idString) |
| 64 | - : QOrganizerCollectionEngineId() |
| 65 | + : QOrganizerCollectionEngineId(), |
| 66 | + m_esource(0) |
| 67 | { |
| 68 | - int colonIndex = idString.indexOf(QStringLiteral(":")); |
| 69 | - m_managerUri = idString.mid(0, colonIndex).toUInt(); |
| 70 | - m_collectionId = idString.mid(colonIndex+1); |
| 71 | + // separate engine id part, if full id given |
| 72 | + m_collectionId = idString.contains(":") ? idString.mid(idString.lastIndexOf(":")+1) : idString; |
| 73 | } |
| 74 | |
| 75 | QOrganizerEDSCollectionEngineId::~QOrganizerEDSCollectionEngineId() |
| 76 | { |
| 77 | - g_object_unref(m_esource); |
| 78 | + if (m_esource) { |
| 79 | + g_object_unref(m_esource); |
| 80 | + m_esource = 0; |
| 81 | + } |
| 82 | } |
| 83 | |
| 84 | bool QOrganizerEDSCollectionEngineId::isEqualTo(const QOrganizerCollectionEngineId* other) const |
| 85 | @@ -74,8 +82,6 @@ |
| 86 | { |
| 87 | // order by collection, then by item in collection. |
| 88 | const QOrganizerEDSCollectionEngineId* otherPtr = static_cast<const QOrganizerEDSCollectionEngineId*>(other); |
| 89 | - if (m_managerUri < otherPtr->m_managerUri) |
| 90 | - return true; |
| 91 | if (m_collectionId < otherPtr->m_collectionId) |
| 92 | return true; |
| 93 | return false; |
| 94 | @@ -83,17 +89,17 @@ |
| 95 | |
| 96 | QString QOrganizerEDSCollectionEngineId::managerUri() const |
| 97 | { |
| 98 | - return m_managerUri; |
| 99 | + return QOrganizerEDSEngineId::managerUriStatic(); |
| 100 | } |
| 101 | |
| 102 | QString QOrganizerEDSCollectionEngineId::toString() const |
| 103 | { |
| 104 | - return (m_managerUri + QLatin1Char(':') + m_collectionId); |
| 105 | + return m_collectionId; |
| 106 | } |
| 107 | |
| 108 | QOrganizerEDSCollectionEngineId* QOrganizerEDSCollectionEngineId::clone() const |
| 109 | { |
| 110 | - return new QOrganizerEDSCollectionEngineId(m_esource, m_managerUri); |
| 111 | + return new QOrganizerEDSCollectionEngineId(m_esource); |
| 112 | } |
| 113 | |
| 114 | uint QOrganizerEDSCollectionEngineId::hash() const |
| 115 | @@ -104,7 +110,7 @@ |
| 116 | #ifndef QT_NO_DEBUG_STREAM |
| 117 | QDebug& QOrganizerEDSCollectionEngineId::debugStreamOut(QDebug& dbg) const |
| 118 | { |
| 119 | - dbg.nospace() << "QOrganizerEDSCollectionEngineId(" << m_managerUri << "," << m_collectionId << ")"; |
| 120 | + dbg.nospace() << "QOrganizerEDSCollectionEngineId(" << managerUri() << "," << m_collectionId << ")"; |
| 121 | return dbg.maybeSpace(); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | === modified file 'qorganizer/qorganizer-eds-collection-engineid.h' |
| 126 | --- qorganizer/qorganizer-eds-collection-engineid.h 2013-09-03 03:57:58 +0000 |
| 127 | +++ qorganizer/qorganizer-eds-collection-engineid.h 2013-10-07 16:14:04 +0000 |
| 128 | @@ -49,13 +49,13 @@ |
| 129 | |
| 130 | private: |
| 131 | QString m_collectionId; |
| 132 | - QString m_managerUri; |
| 133 | ESource *m_esource; |
| 134 | ECalClientSourceType m_sourceType; |
| 135 | |
| 136 | - QOrganizerEDSCollectionEngineId(ESource *source, const QString &managerUri); |
| 137 | + QOrganizerEDSCollectionEngineId(ESource *source); |
| 138 | |
| 139 | friend class QOrganizerEDSEngine; |
| 140 | + friend class ViewWatcher; |
| 141 | }; |
| 142 | |
| 143 | |
| 144 | |
| 145 | === modified file 'qorganizer/qorganizer-eds-engine.cpp' |
| 146 | --- qorganizer/qorganizer-eds-engine.cpp 2013-09-07 23:37:27 +0000 |
| 147 | +++ qorganizer/qorganizer-eds-engine.cpp 2013-10-07 16:14:04 +0000 |
| 148 | @@ -25,6 +25,7 @@ |
| 149 | #include "qorganizer-eds-removerequestdata.h" |
| 150 | #include "qorganizer-eds-savecollectionrequestdata.h" |
| 151 | #include "qorganizer-eds-removecollectionrequestdata.h" |
| 152 | +#include "qorganizer-eds-viewwatcher.h" |
| 153 | |
| 154 | #include <QtCore/qdebug.h> |
| 155 | #include <QtCore/QPointer> |
| 156 | @@ -64,6 +65,7 @@ |
| 157 | return new QOrganizerEDSEngine(); |
| 158 | } |
| 159 | |
| 160 | + |
| 161 | QOrganizerEDSEngine::QOrganizerEDSEngine() |
| 162 | { |
| 163 | qDebug() << Q_FUNC_INFO; |
| 164 | @@ -73,16 +75,19 @@ |
| 165 | QOrganizerEDSEngine::~QOrganizerEDSEngine() |
| 166 | { |
| 167 | qDebug() << Q_FUNC_INFO; |
| 168 | - m_collections.clear(); |
| 169 | - m_collectionsMap.clear(); |
| 170 | + Q_FOREACH(QOrganizerCollection col, m_collections) { |
| 171 | + unregisterCollection(col.id()); |
| 172 | + } |
| 173 | + Q_ASSERT(m_collections.count() == 0); |
| 174 | + Q_ASSERT(m_collectionsMap.count() == 0); |
| 175 | + Q_ASSERT(m_viewWatchers.count() == 0); |
| 176 | } |
| 177 | |
| 178 | QString QOrganizerEDSEngine::managerName() const |
| 179 | { |
| 180 | - return QStringLiteral("eds"); |
| 181 | + return QOrganizerEDSEngineId::managerNameStatic(); |
| 182 | } |
| 183 | |
| 184 | - |
| 185 | /*! \reimp |
| 186 | */ |
| 187 | QMap<QString, QString> QOrganizerEDSEngine::managerParameters() const |
| 188 | @@ -160,7 +165,7 @@ |
| 189 | delete data; |
| 190 | return; |
| 191 | } else { |
| 192 | - data->appendResults(parseEvents(data->collection(), events)); |
| 193 | + data->appendResults(parseEvents(data->collection(), events, false)); |
| 194 | } |
| 195 | itemsAsyncStart(data); |
| 196 | } |
| 197 | @@ -385,8 +390,7 @@ |
| 198 | |
| 199 | item.setCollectionId(data->collectionId()); |
| 200 | QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(data->collectionId().toString(), |
| 201 | - QString::fromUtf8(uid), |
| 202 | - data->parent()->managerUri()); |
| 203 | + QString::fromUtf8(uid)); |
| 204 | item.setId(QOrganizerItemId(eid)); |
| 205 | item.setGuid(QString::fromUtf8(uid)); |
| 206 | } |
| 207 | @@ -845,14 +849,25 @@ |
| 208 | << QOrganizerItemType::TypeTodoOccurrence; |
| 209 | } |
| 210 | |
| 211 | -void QOrganizerEDSEngine::registerCollection(const QOrganizerCollection &collection, QOrganizerEDSCollectionEngineId *edsId) |
| 212 | +void QOrganizerEDSEngine::registerCollection(const QOrganizerCollection &collection, |
| 213 | + QOrganizerEDSCollectionEngineId *edsId) |
| 214 | { |
| 215 | m_collections << collection; |
| 216 | m_collectionsMap.insert(collection.id().toString(), edsId); |
| 217 | + ViewWatcher *viewW = m_viewWatchers.take(collection.id()); |
| 218 | + if (viewW) { |
| 219 | + delete m_viewWatchers.take(collection.id()); |
| 220 | + } |
| 221 | + m_viewWatchers.insert(collection.id(), new ViewWatcher(this, collection.id(), edsId)); |
| 222 | } |
| 223 | |
| 224 | void QOrganizerEDSEngine::unregisterCollection(const QOrganizerCollectionId &collectionId) |
| 225 | { |
| 226 | + ViewWatcher *viewW = m_viewWatchers.take(collectionId); |
| 227 | + if (viewW) { |
| 228 | + delete viewW; |
| 229 | + } |
| 230 | + |
| 231 | Q_FOREACH(QOrganizerCollection col, m_collections) { |
| 232 | if (col.id() == collectionId) { |
| 233 | m_collections.removeAll(col); |
| 234 | @@ -875,33 +890,42 @@ |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | - ESource *defaultSource = e_source_registry_ref_default_address_book(registry); |
| 239 | + // We use calendar as default source, if you are trying to use other source type |
| 240 | + // you need to set the item source id manually |
| 241 | + ESource *defaultCalendarSource = e_source_registry_ref_default_calendar(registry); |
| 242 | + |
| 243 | GList *sources = e_source_registry_list_sources(registry, 0); |
| 244 | for(int i=0, iMax=g_list_length(sources); i < iMax; i++) { |
| 245 | ESource *source = E_SOURCE(g_list_nth_data(sources, i)); |
| 246 | |
| 247 | - if (e_source_has_extension(source, E_SOURCE_EXTENSION_CALENDAR) || |
| 248 | - e_source_has_extension(source, E_SOURCE_EXTENSION_TASK_LIST) || |
| 249 | - e_source_has_extension(source, E_SOURCE_EXTENSION_MEMO_LIST)) |
| 250 | + bool isCalendar = e_source_has_extension(source, E_SOURCE_EXTENSION_CALENDAR); |
| 251 | + bool isTaskList = e_source_has_extension(source, E_SOURCE_EXTENSION_TASK_LIST); |
| 252 | + bool isMemoList = e_source_has_extension(source, E_SOURCE_EXTENSION_MEMO_LIST); |
| 253 | + bool isAlarms = e_source_has_extension(source, E_SOURCE_EXTENSION_ALARMS); |
| 254 | + |
| 255 | + if (e_source_get_enabled(source) && |
| 256 | + (isCalendar || isTaskList || isMemoList || isAlarms)) |
| 257 | { |
| 258 | //TODO get metadata (color, etc..) |
| 259 | QOrganizerEDSCollectionEngineId *edsId = 0; |
| 260 | - QOrganizerCollection collection = parseSource(source, managerUri(), &edsId); |
| 261 | + QOrganizerCollection collection = parseSource(source, &edsId); |
| 262 | |
| 263 | registerCollection(collection, edsId); |
| 264 | |
| 265 | - if (e_source_compare_by_display_name(source, defaultSource) == 0) { |
| 266 | - qDebug() << "Default Source" << e_source_get_display_name(source); |
| 267 | + if (e_source_equal(defaultCalendarSource, source)) { |
| 268 | m_defaultCollection = collection; |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | g_list_free_full (sources, g_object_unref); |
| 274 | + |
| 275 | + if (defaultCalendarSource) { |
| 276 | + g_object_unref(defaultCalendarSource); |
| 277 | + } |
| 278 | + |
| 279 | g_object_unref(registry); |
| 280 | - if (defaultSource) { |
| 281 | - g_object_unref(defaultSource); |
| 282 | - } |
| 283 | + |
| 284 | qDebug() << m_collections.count() << "Collection loaded"; |
| 285 | } |
| 286 | |
| 287 | @@ -916,25 +940,29 @@ |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | +void QOrganizerEDSEngine::updateCollection(QOrganizerCollection *collection, |
| 292 | + ESource *source) |
| 293 | +{ |
| 294 | + collection->setMetaData(QOrganizerCollection::KeyName, |
| 295 | + QString::fromUtf8(e_source_get_display_name(source))); |
| 296 | +} |
| 297 | + |
| 298 | QOrganizerCollection QOrganizerEDSEngine::parseSource(ESource *source, |
| 299 | - const QString &managerUri, |
| 300 | QOrganizerEDSCollectionEngineId **edsId) |
| 301 | { |
| 302 | - *edsId = new QOrganizerEDSCollectionEngineId(source, managerUri); |
| 303 | + *edsId = new QOrganizerEDSCollectionEngineId(source); |
| 304 | QOrganizerCollectionId id(*edsId); |
| 305 | QOrganizerCollection collection; |
| 306 | |
| 307 | collection.setId(id); |
| 308 | - collection.setMetaData(QOrganizerCollection::KeyName, |
| 309 | - QString::fromUtf8(e_source_get_display_name(source))); |
| 310 | - |
| 311 | + updateCollection(&collection, source); |
| 312 | return collection; |
| 313 | } |
| 314 | |
| 315 | -QOrganizerCollection QOrganizerEDSEngine::parseSource(ESource *source, const QString &managerUri) |
| 316 | +QOrganizerCollection QOrganizerEDSEngine::parseSource(ESource *source) |
| 317 | { |
| 318 | QOrganizerEDSCollectionEngineId *edsId = 0; |
| 319 | - return parseSource(source, managerUri, &edsId); |
| 320 | + return parseSource(source, &edsId); |
| 321 | } |
| 322 | |
| 323 | QDateTime QOrganizerEDSEngine::fromIcalTime(struct icaltimetype value) |
| 324 | @@ -1195,6 +1223,64 @@ |
| 325 | item->saveDetail(&tp); |
| 326 | } |
| 327 | |
| 328 | +void QOrganizerEDSEngine::parseAttendeeList(ECalComponent *comp, QOrganizerItem *item) |
| 329 | +{ |
| 330 | + GSList *attendeeList = 0; |
| 331 | + e_cal_component_get_attendee_list(comp, &attendeeList); |
| 332 | + for (GSList *attendeeIter=attendeeList; attendeeIter != 0; attendeeIter = attendeeIter->next) { |
| 333 | + ECalComponentAttendee *attendee = static_cast<ECalComponentAttendee *>(attendeeIter->data); |
| 334 | + QOrganizerEventAttendee qAttendee; |
| 335 | + |
| 336 | + qAttendee.setName(QString::fromUtf8(attendee->cn)); |
| 337 | + qAttendee.setEmailAddress(QString::fromUtf8(attendee->member)); |
| 338 | + |
| 339 | + switch(attendee->role) { |
| 340 | + case ICAL_ROLE_REQPARTICIPANT: |
| 341 | + qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleRequiredParticipant); |
| 342 | + break; |
| 343 | + case ICAL_ROLE_OPTPARTICIPANT: |
| 344 | + qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleOptionalParticipant); |
| 345 | + break; |
| 346 | + case ICAL_ROLE_CHAIR: |
| 347 | + qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleChairperson); |
| 348 | + break; |
| 349 | + case ICAL_ROLE_NONE: |
| 350 | + default: |
| 351 | + qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleNonParticipant); |
| 352 | + break; |
| 353 | + } |
| 354 | + |
| 355 | + switch(attendee->status) { |
| 356 | + case ICAL_PARTSTAT_ACCEPTED: |
| 357 | + qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusAccepted); |
| 358 | + break; |
| 359 | + case ICAL_PARTSTAT_DECLINED: |
| 360 | + qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusDeclined); |
| 361 | + break; |
| 362 | + case ICAL_PARTSTAT_TENTATIVE: |
| 363 | + qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusTentative); |
| 364 | + break; |
| 365 | + case ICAL_PARTSTAT_DELEGATED: |
| 366 | + qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusDelegated); |
| 367 | + break; |
| 368 | + case ICAL_PARTSTAT_COMPLETED: |
| 369 | + qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusCompleted); |
| 370 | + break; |
| 371 | + case ICAL_PARTSTAT_INPROCESS: |
| 372 | + qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusInProcess); |
| 373 | + break; |
| 374 | + case ICAL_PARTSTAT_NEEDSACTION: |
| 375 | + case ICAL_PARTSTAT_NONE: |
| 376 | + default: |
| 377 | + qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusUnknown); |
| 378 | + break; |
| 379 | + |
| 380 | + } |
| 381 | + item->saveDetail(&qAttendee); |
| 382 | + } |
| 383 | + e_cal_component_free_attendee_list(attendeeList); |
| 384 | +} |
| 385 | + |
| 386 | QOrganizerItem *QOrganizerEDSEngine::parseEvent(ECalComponent *comp) |
| 387 | { |
| 388 | QOrganizerEvent *event = new QOrganizerEvent(); |
| 389 | @@ -1373,13 +1459,20 @@ |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | -QList<QOrganizerItem> QOrganizerEDSEngine::parseEvents(QOrganizerEDSCollectionEngineId *collection, GSList *events) |
| 394 | +QList<QOrganizerItem> QOrganizerEDSEngine::parseEvents(QOrganizerEDSCollectionEngineId *collection, |
| 395 | + GSList *events, |
| 396 | + bool isIcalEvents) |
| 397 | { |
| 398 | QList<QOrganizerItem> items; |
| 399 | - for(int i=0, iMax=g_slist_length(events); i < iMax; i++) { |
| 400 | + for (GSList *l = events; l; l = l->next) { |
| 401 | QOrganizerItem *item; |
| 402 | - ECalComponent *comp = E_CAL_COMPONENT(g_slist_nth_data(events, i)); |
| 403 | - |
| 404 | + ECalComponent *comp; |
| 405 | + if (isIcalEvents) { |
| 406 | + icalcomponent *clone = icalcomponent_new_clone(static_cast<icalcomponent*>(l->data)); |
| 407 | + comp = e_cal_component_new_from_icalcomponent(clone); |
| 408 | + } else { |
| 409 | + comp = E_CAL_COMPONENT(l->data); |
| 410 | + } |
| 411 | |
| 412 | //type |
| 413 | ECalComponentVType vType = e_cal_component_get_vtype(comp); |
| 414 | @@ -1408,8 +1501,7 @@ |
| 415 | QOrganizerCollectionId cId = QOrganizerCollectionId(collection); |
| 416 | |
| 417 | QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(collection->m_collectionId, |
| 418 | - QString::fromUtf8(uid), |
| 419 | - collection->managerUri()); |
| 420 | + QString::fromUtf8(uid)); |
| 421 | item->setId(QOrganizerItemId(eid)); |
| 422 | item->setCollectionId(cId); |
| 423 | parseDescription(comp, item); |
| 424 | @@ -1417,25 +1509,14 @@ |
| 425 | parseComments(comp, item); |
| 426 | parseTags(comp, item); |
| 427 | parseReminders(comp, item); |
| 428 | - |
| 429 | -// //Attendee |
| 430 | -// GList *attendeeList = 0; |
| 431 | -// e_cal_component_get_attendee_list(comp, &attendeeList); |
| 432 | -// for(int ci=0, ciMax=g_list_length(attendeeList); ci < ciMax; ci++) { |
| 433 | -// ECalComponentAttendee *attendee = static_cast<ECalComponentAttendee *>(g_list_nth_data(attendeeList, ci)); |
| 434 | -// QOrganizerEventAttendee qAttendee; |
| 435 | -// qAttendee.setAttendeeId(QString::fromUtf8(attendee->member)); |
| 436 | -// qAttendee.setEmailAddress(QString::fromUtf8(attendee->member)); |
| 437 | -// qAttendee.setName(QString::fromUtf8(attendee->member)); |
| 438 | -// //TODO: check |
| 439 | -// qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleRequiredParticipant); |
| 440 | -// qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusAccepted); |
| 441 | - |
| 442 | -// item.saveDetail(&qAttendee); |
| 443 | -// } |
| 444 | + parseAttendeeList(comp, item); |
| 445 | |
| 446 | items << *item; |
| 447 | delete item; |
| 448 | + |
| 449 | + if (isIcalEvents) { |
| 450 | + g_object_unref(comp); |
| 451 | + } |
| 452 | } |
| 453 | return items; |
| 454 | } |
| 455 | @@ -1685,6 +1766,57 @@ |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | +void QOrganizerEDSEngine::parseAttendeeList(const QOrganizerItem &item, ECalComponent *comp) |
| 460 | +{ |
| 461 | + GSList *attendeeList = 0; |
| 462 | + Q_FOREACH(QOrganizerEventAttendee attendee, item.details(QOrganizerItemDetail::TypeEventAttendee)) { |
| 463 | + ECalComponentAttendee *calAttendee = g_new0(ECalComponentAttendee, 1); |
| 464 | + |
| 465 | + calAttendee->cn = g_strdup(attendee.name().toUtf8().constData()); |
| 466 | + calAttendee->value = g_strconcat("MAILTO:", attendee.emailAddress().toUtf8().constData(), NULL); |
| 467 | + switch(attendee.participationRole()) { |
| 468 | + case QOrganizerEventAttendee::RoleRequiredParticipant: |
| 469 | + calAttendee->role = ICAL_ROLE_REQPARTICIPANT; |
| 470 | + break; |
| 471 | + case QOrganizerEventAttendee::RoleOptionalParticipant: |
| 472 | + calAttendee->role = ICAL_ROLE_OPTPARTICIPANT; |
| 473 | + break; |
| 474 | + case QOrganizerEventAttendee::RoleChairperson: |
| 475 | + calAttendee->role = ICAL_ROLE_CHAIR; |
| 476 | + break; |
| 477 | + default: |
| 478 | + calAttendee->role = ICAL_ROLE_NONE; |
| 479 | + } |
| 480 | + |
| 481 | + switch(attendee.participationStatus()) { |
| 482 | + case QOrganizerEventAttendee::StatusAccepted: |
| 483 | + calAttendee->status = ICAL_PARTSTAT_ACCEPTED; |
| 484 | + break; |
| 485 | + case QOrganizerEventAttendee::StatusDeclined: |
| 486 | + calAttendee->status = ICAL_PARTSTAT_DECLINED; |
| 487 | + break; |
| 488 | + case QOrganizerEventAttendee::StatusTentative: |
| 489 | + calAttendee->status = ICAL_PARTSTAT_TENTATIVE; |
| 490 | + break; |
| 491 | + case QOrganizerEventAttendee::StatusDelegated: |
| 492 | + calAttendee->status = ICAL_PARTSTAT_DELEGATED; |
| 493 | + break; |
| 494 | + case QOrganizerEventAttendee::StatusInProcess: |
| 495 | + calAttendee->status = ICAL_PARTSTAT_INPROCESS; |
| 496 | + break; |
| 497 | + case QOrganizerEventAttendee::StatusCompleted: |
| 498 | + calAttendee->status = ICAL_PARTSTAT_COMPLETED; |
| 499 | + break; |
| 500 | + case QOrganizerEventAttendee::StatusUnknown: |
| 501 | + default: |
| 502 | + calAttendee->status = ICAL_PARTSTAT_NONE; |
| 503 | + break; |
| 504 | + } |
| 505 | + attendeeList = g_slist_append(attendeeList, calAttendee); |
| 506 | + } |
| 507 | + e_cal_component_set_attendee_list(comp, attendeeList); |
| 508 | +} |
| 509 | + |
| 510 | ECalComponent *QOrganizerEDSEngine::createDefaultComponent(ECalClient *client, |
| 511 | icalcomponent_kind iKind, |
| 512 | ECalComponentVType eType) |
| 513 | @@ -1932,6 +2064,7 @@ |
| 514 | parseComments(item, comp); |
| 515 | parseTags(item, comp); |
| 516 | parseReminders(item, comp); |
| 517 | + parseAttendeeList(item, comp); |
| 518 | |
| 519 | if (!item.id().isNull()) { |
| 520 | e_cal_component_commit_sequence(comp); |
| 521 | |
| 522 | === modified file 'qorganizer/qorganizer-eds-engine.h' |
| 523 | --- qorganizer/qorganizer-eds-engine.h 2013-09-07 23:37:27 +0000 |
| 524 | +++ qorganizer/qorganizer-eds-engine.h 2013-10-07 16:14:04 +0000 |
| 525 | @@ -38,6 +38,7 @@ |
| 526 | class RemoveRequestData; |
| 527 | class SaveCollectionRequestData; |
| 528 | class RemoveCollectionRequestData; |
| 529 | +class ViewWatcher; |
| 530 | |
| 531 | class QOrganizerEDSEngine : public QtOrganizer::QOrganizerManagerEngine |
| 532 | { |
| 533 | @@ -137,6 +138,7 @@ |
| 534 | |
| 535 | QtOrganizer::QOrganizerCollection m_defaultCollection; |
| 536 | QList<FetchRequestData*> m_pendingFetchRequest; |
| 537 | + QMap<QtOrganizer::QOrganizerCollectionId, ViewWatcher*> m_viewWatchers; |
| 538 | |
| 539 | void loadCollections(); |
| 540 | void registerCollection(const QtOrganizer::QOrganizerCollection &collection, QOrganizerEDSCollectionEngineId *edsId); |
| 541 | @@ -144,9 +146,10 @@ |
| 542 | |
| 543 | ESource *findSource(const QtOrganizer::QOrganizerCollectionId &id) const; |
| 544 | |
| 545 | - static QtOrganizer::QOrganizerCollection parseSource(ESource *source, const QString &managerUri); |
| 546 | - static QtOrganizer::QOrganizerCollection parseSource(ESource *source, const QString &managerUri, QOrganizerEDSCollectionEngineId **edsId); |
| 547 | - static QList<QtOrganizer::QOrganizerItem> parseEvents(QOrganizerEDSCollectionEngineId *collection, GSList *events); |
| 548 | + static void updateCollection(QtOrganizer::QOrganizerCollection *collection, ESource *source); |
| 549 | + static QtOrganizer::QOrganizerCollection parseSource(ESource *source); |
| 550 | + static QtOrganizer::QOrganizerCollection parseSource(ESource *source, QOrganizerEDSCollectionEngineId **edsId); |
| 551 | + static QList<QtOrganizer::QOrganizerItem> parseEvents(QOrganizerEDSCollectionEngineId *collection, GSList *events, bool isIcalEvents); |
| 552 | static GSList *parseItems(ECalClient *client, QList<QtOrganizer::QOrganizerItem> items); |
| 553 | |
| 554 | // QOrganizerItem -> ECalComponent |
| 555 | @@ -170,6 +173,7 @@ |
| 556 | static void parseDueDate(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); |
| 557 | static void parseProgress(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); |
| 558 | static void parseStatus(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); |
| 559 | + static void parseAttendeeList(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); |
| 560 | |
| 561 | // ECalComponent -> QOrganizerItem |
| 562 | static void parseSummary(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); |
| 563 | @@ -191,6 +195,8 @@ |
| 564 | static void parseDueDate(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); |
| 565 | static void parseProgress(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); |
| 566 | static void parseStatus(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); |
| 567 | + static void parseAttendeeList(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); |
| 568 | + |
| 569 | |
| 570 | static QDateTime fromIcalTime(struct icaltimetype value); |
| 571 | static QtOrganizer::QOrganizerItem *parseEvent(ECalComponent *comp); |
| 572 | @@ -246,6 +252,7 @@ |
| 573 | friend class FetchRequestData; |
| 574 | friend class SaveCollectionRequestData; |
| 575 | friend class RemoveCollectionRequestData; |
| 576 | + friend class ViewWatcher; |
| 577 | }; |
| 578 | |
| 579 | #endif |
| 580 | |
| 581 | === modified file 'qorganizer/qorganizer-eds-engineid.cpp' |
| 582 | --- qorganizer/qorganizer-eds-engineid.cpp 2013-08-16 02:52:55 +0000 |
| 583 | +++ qorganizer/qorganizer-eds-engineid.cpp 2013-10-07 16:14:04 +0000 |
| 584 | @@ -26,10 +26,8 @@ |
| 585 | } |
| 586 | |
| 587 | QOrganizerEDSEngineId::QOrganizerEDSEngineId(const QString &collectionId, |
| 588 | - const QString &id, |
| 589 | - const QString& managerUri) |
| 590 | + const QString &id) |
| 591 | : QOrganizerItemEngineId(), |
| 592 | - m_managerUri(managerUri), |
| 593 | m_collectionId(collectionId), |
| 594 | m_itemId(id) |
| 595 | { |
| 596 | @@ -41,7 +39,6 @@ |
| 597 | |
| 598 | QOrganizerEDSEngineId::QOrganizerEDSEngineId(const QOrganizerEDSEngineId& other) |
| 599 | : QOrganizerItemEngineId(), |
| 600 | - m_managerUri(other.m_managerUri), |
| 601 | m_collectionId(other.m_collectionId), |
| 602 | m_itemId(other.m_itemId) |
| 603 | { |
| 604 | @@ -50,14 +47,11 @@ |
| 605 | QOrganizerEDSEngineId::QOrganizerEDSEngineId(const QString& idString) |
| 606 | : QOrganizerItemEngineId() |
| 607 | { |
| 608 | - int temp = 0; |
| 609 | - int colonIndex = idString.indexOf(QStringLiteral(":"), 0); |
| 610 | - m_managerUri = idString.mid(temp, colonIndex); |
| 611 | - temp = colonIndex + 1; |
| 612 | - colonIndex = idString.indexOf(QStringLiteral(":"), temp); |
| 613 | - m_collectionId = idString.mid(temp, (colonIndex-temp)); |
| 614 | - temp = colonIndex + 1; |
| 615 | - m_itemId = idString.mid(temp); |
| 616 | + QString edsIdPart = idString.contains(":") ? idString.mid(idString.lastIndexOf(":")+1) : idString; |
| 617 | + QStringList idParts = edsIdPart.split("/"); |
| 618 | + Q_ASSERT(idParts.count() == 2); |
| 619 | + m_collectionId = idParts.first(); |
| 620 | + m_itemId = idParts.last(); |
| 621 | } |
| 622 | |
| 623 | bool QOrganizerEDSEngineId::isEqualTo(const QOrganizerItemEngineId* other) const |
| 624 | @@ -75,8 +69,6 @@ |
| 625 | { |
| 626 | // order by collection, then by item in collection. |
| 627 | const QOrganizerEDSEngineId* otherPtr = static_cast<const QOrganizerEDSEngineId*>(other); |
| 628 | - if (m_managerUri < otherPtr->m_managerUri) |
| 629 | - return true; |
| 630 | if (m_collectionId < otherPtr->m_collectionId) |
| 631 | return true; |
| 632 | if (m_collectionId == otherPtr->m_collectionId) |
| 633 | @@ -86,17 +78,17 @@ |
| 634 | |
| 635 | QString QOrganizerEDSEngineId::managerUri() const |
| 636 | { |
| 637 | - return m_managerUri; |
| 638 | + return managerUriStatic(); |
| 639 | } |
| 640 | |
| 641 | QString QOrganizerEDSEngineId::toString() const |
| 642 | { |
| 643 | - return (m_collectionId + QLatin1Char(':') + m_itemId); |
| 644 | + return QString("%1/%2").arg(m_collectionId).arg(m_itemId); |
| 645 | } |
| 646 | |
| 647 | QOrganizerItemEngineId* QOrganizerEDSEngineId::clone() const |
| 648 | { |
| 649 | - return new QOrganizerEDSEngineId(m_collectionId, m_itemId, m_managerUri); |
| 650 | + return new QOrganizerEDSEngineId(m_collectionId, m_itemId); |
| 651 | } |
| 652 | |
| 653 | uint QOrganizerEDSEngineId::hash() const |
| 654 | @@ -107,10 +99,20 @@ |
| 655 | #ifndef QT_NO_DEBUG_STREAM |
| 656 | QDebug& QOrganizerEDSEngineId::debugStreamOut(QDebug& dbg) const |
| 657 | { |
| 658 | - dbg.nospace() << "QOrganizerItemMemoryEngineId(" << m_managerUri << ", " << m_collectionId << ", " << m_itemId << ")"; |
| 659 | + dbg.nospace() << "QOrganizerEDSEngineId(" << managerNameStatic() << ", " << m_collectionId << ", " << m_itemId << ")"; |
| 660 | return dbg.maybeSpace(); |
| 661 | } |
| 662 | |
| 663 | +QString QOrganizerEDSEngineId::managerNameStatic() |
| 664 | +{ |
| 665 | + return QStringLiteral("eds"); |
| 666 | +} |
| 667 | + |
| 668 | +QString QOrganizerEDSEngineId::managerUriStatic() |
| 669 | +{ |
| 670 | + return QStringLiteral("qtorganizer:eds:"); |
| 671 | +} |
| 672 | + |
| 673 | QString QOrganizerEDSEngineId::toComponentId(const QtOrganizer::QOrganizerItemId &itemId) |
| 674 | { |
| 675 | return toComponentId(itemId.toString()); |
| 676 | @@ -118,7 +120,7 @@ |
| 677 | |
| 678 | QString QOrganizerEDSEngineId::toComponentId(const QString &itemId) |
| 679 | { |
| 680 | - return itemId.split(":").last(); |
| 681 | + return itemId.split("/").last(); |
| 682 | } |
| 683 | |
| 684 | #endif |
| 685 | |
| 686 | === modified file 'qorganizer/qorganizer-eds-engineid.h' |
| 687 | --- qorganizer/qorganizer-eds-engineid.h 2013-08-16 02:52:55 +0000 |
| 688 | +++ qorganizer/qorganizer-eds-engineid.h 2013-10-07 16:14:04 +0000 |
| 689 | @@ -29,9 +29,8 @@ |
| 690 | { |
| 691 | public: |
| 692 | QOrganizerEDSEngineId(); |
| 693 | - QOrganizerEDSEngineId(const QString &collectionId, |
| 694 | - const QString &id, |
| 695 | - const QString& managerUri); |
| 696 | + QOrganizerEDSEngineId(const QString& collectionId, |
| 697 | + const QString& id); |
| 698 | ~QOrganizerEDSEngineId(); |
| 699 | QOrganizerEDSEngineId(const QOrganizerEDSEngineId& other); |
| 700 | QOrganizerEDSEngineId(const QString& idString); |
| 701 | @@ -49,11 +48,12 @@ |
| 702 | QDebug& debugStreamOut(QDebug& dbg) const; |
| 703 | #endif |
| 704 | |
| 705 | + static QString managerUriStatic(); |
| 706 | + static QString managerNameStatic(); |
| 707 | static QString toComponentId(const QtOrganizer::QOrganizerItemId &itemId); |
| 708 | static QString toComponentId(const QString &itemId); |
| 709 | |
| 710 | private: |
| 711 | - QString m_managerUri; |
| 712 | QString m_collectionId; |
| 713 | QString m_itemId; |
| 714 | friend class QOrganizerEDSEngine; |
| 715 | |
| 716 | === modified file 'qorganizer/qorganizer-eds-fetchrequestdata.cpp' |
| 717 | --- qorganizer/qorganizer-eds-fetchrequestdata.cpp 2013-09-07 23:37:27 +0000 |
| 718 | +++ qorganizer/qorganizer-eds-fetchrequestdata.cpp 2013-10-07 16:14:04 +0000 |
| 719 | @@ -36,6 +36,7 @@ |
| 720 | QOrganizerEDSCollectionEngineId* FetchRequestData::nextCollection() |
| 721 | { |
| 722 | m_current = 0; |
| 723 | + setClient(0); |
| 724 | if (m_collections.size()) { |
| 725 | m_current = m_collections.takeFirst(); |
| 726 | return m_current; |
| 727 | |
| 728 | === modified file 'qorganizer/qorganizer-eds-requestdata.cpp' |
| 729 | --- qorganizer/qorganizer-eds-requestdata.cpp 2013-09-03 03:57:58 +0000 |
| 730 | +++ qorganizer/qorganizer-eds-requestdata.cpp 2013-10-07 16:14:04 +0000 |
| 731 | @@ -33,8 +33,11 @@ |
| 732 | |
| 733 | RequestData::~RequestData() |
| 734 | { |
| 735 | - g_cancellable_cancel(m_cancellable); |
| 736 | - g_object_unref(m_cancellable); |
| 737 | + if (m_cancellable) { |
| 738 | + g_cancellable_cancel(m_cancellable); |
| 739 | + g_object_unref(m_cancellable); |
| 740 | + } |
| 741 | + |
| 742 | |
| 743 | if (m_client) { |
| 744 | g_object_unref(m_client); |
| 745 | @@ -68,6 +71,7 @@ |
| 746 | g_object_unref(m_cancellable); |
| 747 | m_cancellable = 0; |
| 748 | } |
| 749 | + QOrganizerManagerEngine::updateRequestState(m_req, QOrganizerAbstractRequest::CanceledState); |
| 750 | } |
| 751 | |
| 752 | void RequestData::setClient(EClient *client) |
| 753 | |
| 754 | === modified file 'qorganizer/qorganizer-eds-savecollectionrequestdata.cpp' |
| 755 | --- qorganizer/qorganizer-eds-savecollectionrequestdata.cpp 2013-09-04 01:33:06 +0000 |
| 756 | +++ qorganizer/qorganizer-eds-savecollectionrequestdata.cpp 2013-10-07 16:14:04 +0000 |
| 757 | @@ -64,7 +64,7 @@ |
| 758 | ESource *source = E_SOURCE(g_list_nth_data(m_sources, m_currentSource)); |
| 759 | QOrganizerEDSCollectionEngineId *edsId = 0; |
| 760 | |
| 761 | - QOrganizerCollection collection = QOrganizerEDSEngine::parseSource(source, parent()->managerUri(), &edsId); |
| 762 | + QOrganizerCollection collection = QOrganizerEDSEngine::parseSource(source, &edsId); |
| 763 | parent()->registerCollection(collection, edsId); |
| 764 | |
| 765 | m_results.append(collection); |
| 766 | |
| 767 | === added file 'qorganizer/qorganizer-eds-viewwatcher.cpp' |
| 768 | --- qorganizer/qorganizer-eds-viewwatcher.cpp 1970-01-01 00:00:00 +0000 |
| 769 | +++ qorganizer/qorganizer-eds-viewwatcher.cpp 2013-10-07 16:14:04 +0000 |
| 770 | @@ -0,0 +1,211 @@ |
| 771 | +/* |
| 772 | + * Copyright 2013 Canonical Ltd. |
| 773 | + * |
| 774 | + * This file is part of ubuntu-pim-service. |
| 775 | + * |
| 776 | + * contact-service-app is free software; you can redistribute it and/or modify |
| 777 | + * it under the terms of the GNU General Public License as published by |
| 778 | + * the Free Software Foundation; version 3. |
| 779 | + * |
| 780 | + * contact-service-app is distributed in the hope that it will be useful, |
| 781 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 782 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 783 | + * GNU General Public License for more details. |
| 784 | + * |
| 785 | + * You should have received a copy of the GNU General Public License |
| 786 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 787 | + */ |
| 788 | + |
| 789 | +#include "qorganizer-eds-viewwatcher.h" |
| 790 | +#include "qorganizer-eds-fetchrequestdata.h" |
| 791 | +#include "qorganizer-eds-engineid.h" |
| 792 | + |
| 793 | +#include <QtOrganizer/QOrganizerAbstractRequest> |
| 794 | +#include <QtOrganizer/QOrganizerManagerEngine> |
| 795 | +#include <QtOrganizer/QOrganizerItemId> |
| 796 | + |
| 797 | +using namespace QtOrganizer; |
| 798 | + |
| 799 | +QString ViewWatcher::m_dateFilter; |
| 800 | + |
| 801 | +ViewWatcher::ViewWatcher(QOrganizerEDSEngine *engine, |
| 802 | + const QOrganizerCollectionId &collectionId, |
| 803 | + QOrganizerEDSCollectionEngineId *edsId) |
| 804 | + : m_parent(engine), |
| 805 | + m_edsId(edsId), |
| 806 | + m_eClient(0), |
| 807 | + m_eView(0), |
| 808 | + m_eventLoop(0) |
| 809 | +{ |
| 810 | + if (m_dateFilter.isEmpty()) { |
| 811 | + QDateTime startDate; |
| 812 | + startDate.setMSecsSinceEpoch(0); |
| 813 | + |
| 814 | + QDateTime endDate; |
| 815 | + endDate.setMSecsSinceEpoch(std::numeric_limits<qint64>::max()); |
| 816 | + |
| 817 | + m_dateFilter = QString("(occur-in-time-range? " |
| 818 | + "(make-time \"%1\") (make-time \"%2\"))") |
| 819 | + .arg(isodate_from_time_t(startDate.toTime_t())) |
| 820 | + .arg(isodate_from_time_t(endDate.toTime_t())); |
| 821 | + |
| 822 | + } |
| 823 | + m_cancellable = g_cancellable_new(); |
| 824 | + e_cal_client_connect(m_edsId->m_esource, |
| 825 | + m_edsId->m_sourceType, |
| 826 | + m_cancellable, |
| 827 | + (GAsyncReadyCallback) ViewWatcher::clientConnected, |
| 828 | + this); |
| 829 | +} |
| 830 | + |
| 831 | +ViewWatcher::~ViewWatcher() |
| 832 | +{ |
| 833 | + clear(); |
| 834 | +} |
| 835 | + |
| 836 | +void ViewWatcher::clientConnected(GObject *sourceObject, GAsyncResult *res, ViewWatcher *self) |
| 837 | +{ |
| 838 | + Q_UNUSED(sourceObject); |
| 839 | + GError *gError = 0; |
| 840 | + self->m_eClient = E_CAL_CLIENT(e_cal_client_connect_finish(res, &gError)); |
| 841 | + if (gError) { |
| 842 | + qWarning() << "Fail to connect with server (" |
| 843 | + << e_source_get_display_name(self->m_edsId->m_esource) << "):" |
| 844 | + << gError->message; |
| 845 | + g_error_free(gError); |
| 846 | + gError = 0; |
| 847 | + if (self->m_eventLoop) { |
| 848 | + self->m_eventLoop->quit(); |
| 849 | + } |
| 850 | + } else { |
| 851 | + e_cal_client_get_view(self->m_eClient, |
| 852 | + self->m_dateFilter.toUtf8().data(), |
| 853 | + self->m_cancellable, |
| 854 | + (GAsyncReadyCallback) ViewWatcher::viewReady, |
| 855 | + self); |
| 856 | + } |
| 857 | +} |
| 858 | + |
| 859 | +void ViewWatcher::viewReady(GObject *sourceObject, GAsyncResult *res, ViewWatcher *self) |
| 860 | +{ |
| 861 | + Q_UNUSED(sourceObject); |
| 862 | + GError *gError = 0; |
| 863 | + ECalClientView *view = 0; |
| 864 | + e_cal_client_get_view_finish(self->m_eClient, res, &view, &gError); |
| 865 | + if (gError) { |
| 866 | + qWarning() << "Fail to open view (" |
| 867 | + << e_source_get_display_name(self->m_edsId->m_esource) << "):" |
| 868 | + << gError->message; |
| 869 | + g_error_free(gError); |
| 870 | + gError = 0; |
| 871 | + } else { |
| 872 | + self->m_eView = view; |
| 873 | + |
| 874 | + g_signal_connect(view, |
| 875 | + "objects-added", |
| 876 | + (GCallback) ViewWatcher::onObjectsAdded, |
| 877 | + self); |
| 878 | + |
| 879 | + g_signal_connect(view, |
| 880 | + "objects-removed", |
| 881 | + (GCallback) ViewWatcher::onObjectsRemoved, |
| 882 | + self); |
| 883 | + |
| 884 | + g_signal_connect(view, |
| 885 | + "objects-modified", |
| 886 | + (GCallback) ViewWatcher::onObjectsModified, |
| 887 | + self); |
| 888 | + e_cal_client_view_set_flags(view, E_CAL_CLIENT_VIEW_FLAGS_NONE, NULL); |
| 889 | + e_cal_client_view_start(view, &gError); |
| 890 | + if (gError) { |
| 891 | + qWarning() << "Fail to start view (" |
| 892 | + << e_source_get_display_name(self->m_edsId->m_esource) << "):" |
| 893 | + << gError->message; |
| 894 | + g_error_free(gError); |
| 895 | + gError = 0; |
| 896 | + } else { |
| 897 | + qDebug() << "Listening for changes on (" |
| 898 | + << e_source_get_display_name(self->m_edsId->m_esource) << ")"; |
| 899 | + } |
| 900 | + g_clear_object(&self->m_cancellable); |
| 901 | + } |
| 902 | + |
| 903 | + if (self->m_eventLoop) { |
| 904 | + self->m_eventLoop->quit(); |
| 905 | + } |
| 906 | +} |
| 907 | + |
| 908 | +void ViewWatcher::clear() |
| 909 | +{ |
| 910 | + if (m_cancellable) { |
| 911 | + g_cancellable_cancel(m_cancellable); |
| 912 | + wait(); |
| 913 | + g_clear_object(&m_cancellable); |
| 914 | + } |
| 915 | + |
| 916 | + if (m_eView) { |
| 917 | + g_clear_object(&m_eView); |
| 918 | + } |
| 919 | + |
| 920 | + if (m_eClient) { |
| 921 | + g_clear_object(&m_eClient); |
| 922 | + } |
| 923 | +} |
| 924 | + |
| 925 | +void ViewWatcher::wait() |
| 926 | +{ |
| 927 | + if (m_cancellable) { |
| 928 | + QEventLoop eventLoop; |
| 929 | + m_eventLoop = &eventLoop; |
| 930 | + eventLoop.exec(); |
| 931 | + m_eventLoop = 0; |
| 932 | + } |
| 933 | +} |
| 934 | + |
| 935 | +void ViewWatcher::onObjectsAdded(ECalClientView *view, |
| 936 | + GSList *objects, |
| 937 | + ViewWatcher *self) |
| 938 | +{ |
| 939 | + Q_UNUSED(view); |
| 940 | + QList<QOrganizerItem> items; |
| 941 | + |
| 942 | + items = QOrganizerEDSEngine::parseEvents(self->m_edsId, objects, true); |
| 943 | + QOrganizerItemChangeSet changeSet; |
| 944 | + |
| 945 | + Q_FOREACH(QOrganizerItem item, items) { |
| 946 | + changeSet.insertAddedItem(item.id()); |
| 947 | + } |
| 948 | + changeSet.emitSignals(self->m_parent); |
| 949 | +} |
| 950 | + |
| 951 | +void ViewWatcher::onObjectsRemoved(ECalClientView *view, |
| 952 | + GSList *objects, |
| 953 | + ViewWatcher *self) |
| 954 | +{ |
| 955 | + Q_UNUSED(view); |
| 956 | + QOrganizerItemChangeSet changeSet; |
| 957 | + |
| 958 | + for (GSList *l = objects; l; l = l->next) { |
| 959 | + ECalComponentId *id = static_cast<ECalComponentId*>(l->data); |
| 960 | + |
| 961 | + QOrganizerEDSEngineId *itemId = new QOrganizerEDSEngineId(self->m_edsId->toString(), |
| 962 | + QString::fromUtf8(id->uid)); |
| 963 | + changeSet.insertRemovedItem(QOrganizerItemId(itemId)); |
| 964 | + } |
| 965 | + changeSet.emitSignals(self->m_parent); |
| 966 | +} |
| 967 | + |
| 968 | +void ViewWatcher::onObjectsModified(ECalClientView *view, |
| 969 | + GSList *objects, |
| 970 | + ViewWatcher *self) |
| 971 | +{ |
| 972 | + QList<QOrganizerItem> items; |
| 973 | + |
| 974 | + items = QOrganizerEDSEngine::parseEvents(self->m_edsId, objects, true); |
| 975 | + QOrganizerItemChangeSet changeSet; |
| 976 | + |
| 977 | + Q_FOREACH(QOrganizerItem item, items) { |
| 978 | + changeSet.insertChangedItem(item.id()); |
| 979 | + } |
| 980 | + changeSet.emitSignals(self->m_parent); |
| 981 | +} |
| 982 | |
| 983 | === added file 'qorganizer/qorganizer-eds-viewwatcher.h' |
| 984 | --- qorganizer/qorganizer-eds-viewwatcher.h 1970-01-01 00:00:00 +0000 |
| 985 | +++ qorganizer/qorganizer-eds-viewwatcher.h 2013-10-07 16:14:04 +0000 |
| 986 | @@ -0,0 +1,63 @@ |
| 987 | +/* |
| 988 | + * Copyright 2013 Canonical Ltd. |
| 989 | + * |
| 990 | + * This file is part of ubuntu-pim-service. |
| 991 | + * |
| 992 | + * contact-service-app is free software; you can redistribute it and/or modify |
| 993 | + * it under the terms of the GNU General Public License as published by |
| 994 | + * the Free Software Foundation; version 3. |
| 995 | + * |
| 996 | + * contact-service-app is distributed in the hope that it will be useful, |
| 997 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 998 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 999 | + * GNU General Public License for more details. |
| 1000 | + * |
| 1001 | + * You should have received a copy of the GNU General Public License |
| 1002 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1003 | + */ |
| 1004 | + |
| 1005 | +#ifndef __QORGANIZER_EDS_VIEWWATCHER_H__ |
| 1006 | +#define __QORGANIZER_EDS_VIEWWATCHER_H__ |
| 1007 | + |
| 1008 | +#include "qorganizer-eds-engine.h" |
| 1009 | + |
| 1010 | +#include <QtCore/QList> |
| 1011 | +#include <QtCore/QObject> |
| 1012 | +#include <QtCore/QEventLoop> |
| 1013 | + |
| 1014 | +#include <libecal/libecal.h> |
| 1015 | + |
| 1016 | +class ViewWatcher : public QObject |
| 1017 | +{ |
| 1018 | + Q_OBJECT |
| 1019 | +public: |
| 1020 | + ViewWatcher(QOrganizerEDSEngine *engine, |
| 1021 | + const QtOrganizer::QOrganizerCollectionId &collectionId, |
| 1022 | + QOrganizerEDSCollectionEngineId *edsId); |
| 1023 | + virtual ~ViewWatcher(); |
| 1024 | + void append(ECalClientView *view, FetchRequestData *data); |
| 1025 | + void clear(); |
| 1026 | + void wait(); |
| 1027 | + |
| 1028 | +Q_SIGNALS: |
| 1029 | + void viewProcessed(ECalClientView *view, gpointer data); |
| 1030 | + |
| 1031 | +private: |
| 1032 | + QOrganizerEDSEngine *m_parent; |
| 1033 | + GCancellable *m_cancellable; |
| 1034 | + QOrganizerEDSCollectionEngineId *m_edsId; |
| 1035 | + ECalClient *m_eClient; |
| 1036 | + ECalClientView *m_eView; |
| 1037 | + QEventLoop *m_eventLoop; |
| 1038 | + |
| 1039 | + static QString m_dateFilter; |
| 1040 | + |
| 1041 | + static void clientConnected(GObject *sourceObject, GAsyncResult *res, ViewWatcher *self); |
| 1042 | + static void viewReady(GObject *sourceObject, GAsyncResult *res, ViewWatcher *self); |
| 1043 | + |
| 1044 | + static void onObjectsAdded(ECalClientView *view, GSList *objects, ViewWatcher *self); |
| 1045 | + static void onObjectsRemoved(ECalClientView *view, GSList *objects, ViewWatcher *self); |
| 1046 | + static void onObjectsModified(ECalClientView *view, GSList *objects, ViewWatcher *self); |
| 1047 | +}; |
| 1048 | + |
| 1049 | +#endif |
| 1050 | |
| 1051 | === modified file 'tests/unittest/collections-test.cpp' |
| 1052 | --- tests/unittest/collections-test.cpp 2013-09-05 22:32:45 +0000 |
| 1053 | +++ tests/unittest/collections-test.cpp 2013-10-07 16:14:04 +0000 |
| 1054 | @@ -36,31 +36,42 @@ |
| 1055 | static const QString defaultTaskCollectionName; |
| 1056 | static const QString collectionTypePropertyName; |
| 1057 | static const QString taskListTypeName; |
| 1058 | + QOrganizerEDSEngine *m_engine; |
| 1059 | + |
| 1060 | private Q_SLOTS: |
| 1061 | + void init() |
| 1062 | + { |
| 1063 | + m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1064 | + } |
| 1065 | + |
| 1066 | + void cleanup() |
| 1067 | + { |
| 1068 | + delete m_engine; |
| 1069 | + m_engine = 0; |
| 1070 | + } |
| 1071 | + |
| 1072 | void testCreateCollection() |
| 1073 | { |
| 1074 | - QOrganizerEDSEngine *engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1075 | - |
| 1076 | QOrganizerCollection collection; |
| 1077 | QtOrganizer::QOrganizerManager::Error error; |
| 1078 | collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
| 1079 | |
| 1080 | - QVERIFY(engine->saveCollection(&collection, &error)); |
| 1081 | + QVERIFY(m_engine->saveCollection(&collection, &error)); |
| 1082 | QCOMPARE(error, QOrganizerManager::NoError); |
| 1083 | QVERIFY(!collection.id().isNull()); |
| 1084 | } |
| 1085 | |
| 1086 | void testCreateTaskList() |
| 1087 | { |
| 1088 | - QOrganizerEDSEngine *engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1089 | + m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1090 | |
| 1091 | QOrganizerCollection collection; |
| 1092 | QtOrganizer::QOrganizerManager::Error error; |
| 1093 | collection.setMetaData(QOrganizerCollection::KeyName, defaultTaskCollectionName); |
| 1094 | collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); |
| 1095 | |
| 1096 | - QSignalSpy createdCollection(engine, SIGNAL(collectionsAdded(QList<QOrganizerCollectionId>))); |
| 1097 | - QVERIFY(engine->saveCollection(&collection, &error)); |
| 1098 | + QSignalSpy createdCollection(m_engine, SIGNAL(collectionsAdded(QList<QOrganizerCollectionId>))); |
| 1099 | + QVERIFY(m_engine->saveCollection(&collection, &error)); |
| 1100 | QCOMPARE(error, QOrganizerManager::NoError); |
| 1101 | QVERIFY(!collection.id().isNull()); |
| 1102 | |
| 1103 | @@ -69,12 +80,12 @@ |
| 1104 | QList<QVariant> args = createdCollection.takeFirst(); |
| 1105 | QCOMPARE(args.count(), 1); |
| 1106 | |
| 1107 | - QVERIFY(engine->collections(&error).contains(collection)); |
| 1108 | - delete engine; |
| 1109 | + QVERIFY(m_engine->collections(&error).contains(collection)); |
| 1110 | + delete m_engine; |
| 1111 | |
| 1112 | // recreate and check if the new collection is listed |
| 1113 | - engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1114 | - QVERIFY(engine->collections(&error).contains(collection)); |
| 1115 | + m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1116 | + QVERIFY(m_engine->collections(&error).contains(collection)); |
| 1117 | } |
| 1118 | |
| 1119 | void testCreateTask() |
| 1120 | @@ -82,13 +93,14 @@ |
| 1121 | static QString displayLabelValue = QStringLiteral("Todo test"); |
| 1122 | static QString descriptionValue = QStringLiteral("Todo description"); |
| 1123 | |
| 1124 | - QOrganizerEDSEngine *engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1125 | + m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
| 1126 | |
| 1127 | QOrganizerCollection collection; |
| 1128 | QtOrganizer::QOrganizerManager::Error error; |
| 1129 | collection.setMetaData(QOrganizerCollection::KeyName, defaultTaskCollectionName + "2"); |
| 1130 | collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); |
| 1131 | - QVERIFY(engine->saveCollection(&collection, &error)); |
| 1132 | + |
| 1133 | + QVERIFY(m_engine->saveCollection(&collection, &error)); |
| 1134 | |
| 1135 | QOrganizerTodo todo; |
| 1136 | todo.setCollectionId(collection.id()); |
| 1137 | @@ -98,9 +110,9 @@ |
| 1138 | |
| 1139 | QMap<int, QtOrganizer::QOrganizerManager::Error> errorMap; |
| 1140 | QList<QOrganizerItem> items; |
| 1141 | - QSignalSpy createdItem(engine, SIGNAL(itemsAdded(QList<QOrganizerItemId>))); |
| 1142 | + QSignalSpy createdItem(m_engine, SIGNAL(itemsAdded(QList<QOrganizerItemId>))); |
| 1143 | items << todo; |
| 1144 | - bool saveResult = engine->saveItems(&items, |
| 1145 | + bool saveResult = m_engine->saveItems(&items, |
| 1146 | QList<QtOrganizer::QOrganizerItemDetail::DetailType>(), |
| 1147 | &errorMap, |
| 1148 | &error); |
| 1149 | @@ -121,7 +133,7 @@ |
| 1150 | |
| 1151 | filter.setCollectionId(collection.id()); |
| 1152 | |
| 1153 | - items = engine->items(filter, |
| 1154 | + items = m_engine->items(filter, |
| 1155 | QDateTime(), |
| 1156 | QDateTime(), |
| 1157 | 10, |
| 1158 | @@ -137,12 +149,11 @@ |
| 1159 | QCOMPARE(result.displayLabel(), todo.displayLabel()); |
| 1160 | QCOMPARE(result.description(), todo.description()); |
| 1161 | |
| 1162 | - |
| 1163 | // check if the item is listead by id |
| 1164 | QList<QOrganizerItemId> ids; |
| 1165 | ids << todo.id(); |
| 1166 | |
| 1167 | - items = engine->items(ids, hint, &errorMap, &error); |
| 1168 | + items = m_engine->items(ids, hint, &errorMap, &error); |
| 1169 | QCOMPARE(items.count(), 1); |
| 1170 | result = static_cast<QOrganizerTodo>(items[0]); |
| 1171 | todo = items[0]; |
| 1172 | @@ -150,8 +161,6 @@ |
| 1173 | QCOMPARE(result.startDateTime(), todo.startDateTime()); |
| 1174 | QCOMPARE(result.displayLabel(), todo.displayLabel()); |
| 1175 | QCOMPARE(result.description(), todo.description()); |
| 1176 | - |
| 1177 | - delete engine; |
| 1178 | } |
| 1179 | |
| 1180 | void testRemoveCollection() |
| 1181 | |
| 1182 | === modified file 'tests/unittest/itemid-test.cpp' |
| 1183 | --- tests/unittest/itemid-test.cpp 2013-08-16 02:52:55 +0000 |
| 1184 | +++ tests/unittest/itemid-test.cpp 2013-10-07 16:14:04 +0000 |
| 1185 | @@ -24,7 +24,7 @@ |
| 1186 | #include <QtOrganizer> |
| 1187 | |
| 1188 | #include "qorganizer-eds-engineid.h" |
| 1189 | - |
| 1190 | +#include "qorganizer-eds-collection-engineid.h" |
| 1191 | |
| 1192 | using namespace QtOrganizer; |
| 1193 | |
| 1194 | @@ -35,8 +35,34 @@ |
| 1195 | private Q_SLOTS: |
| 1196 | void testRetriveItemId() |
| 1197 | { |
| 1198 | - QString id("qtorganizer:eds::system-calendar:20130814T212003Z-13580-1000-1995-22@ubuntu"); |
| 1199 | - QCOMPARE(QOrganizerEDSEngineId::toComponentId(id), QStringLiteral("20130814T212003Z-13580-1000-1995-22@ubuntu")); |
| 1200 | + QString id("qtorganizer:eds::system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu"); |
| 1201 | + QCOMPARE(QOrganizerEDSEngineId::toComponentId(id), |
| 1202 | + QStringLiteral("20130814T212003Z-13580-1000-1995-22@ubuntu")); |
| 1203 | + } |
| 1204 | + |
| 1205 | + void testCreateFromString() |
| 1206 | + { |
| 1207 | + QOrganizerEDSEngineId id("system-calendar", "20130814T212003Z-13580-1000-1995-22@ubuntu"); |
| 1208 | + QCOMPARE(id.toString(), |
| 1209 | + QStringLiteral("system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); |
| 1210 | + } |
| 1211 | + |
| 1212 | + void testCollectionIdFromString() |
| 1213 | + { |
| 1214 | + QOrganizerEDSCollectionEngineId id(QStringLiteral("qtorganizer:eds::system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); |
| 1215 | + QOrganizerEDSCollectionEngineId id2(QStringLiteral("eds::system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); |
| 1216 | + QOrganizerEDSCollectionEngineId id3(QStringLiteral("system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); |
| 1217 | + QVERIFY(id.isEqualTo(&id2)); |
| 1218 | + QVERIFY(id2.isEqualTo(&id3)); |
| 1219 | + } |
| 1220 | + |
| 1221 | + void testCreateOrganizerId() |
| 1222 | + { |
| 1223 | + QOrganizerEDSEngineId id("system-calendar", "20130814T212003Z-13580-1000-1995-22@ubuntu"); |
| 1224 | + QOrganizerItemId id2(new QOrganizerEDSEngineId(id)); |
| 1225 | + QCOMPARE(id2.managerUri(), QStringLiteral("qtorganizer:eds:")); |
| 1226 | + QString targetId = QString("qtorganizer:eds::") + id.toString(); |
| 1227 | + QCOMPARE(id2.toString(), targetId); |
| 1228 | } |
| 1229 | }; |
| 1230 |
FAILED: Continuous integration, rev:13 /code.launchpad .net/~renatofil ho/qtorganizer5 -eds/fix- default- source/ +merge/ 187434/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http:// jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-ci/ 5/ jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-saucy- amd64-ci/ 5 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-saucy- armhf-ci/ 5 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-saucy- armhf-ci/ 5/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-saucy- i386-ci/ 5
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ qtorganizer5- eds-ci/ 5/rebuild
http://