qtorganizer5-eds-0.1.1+14.04.20140415.1/0000755000015301777760000000000012323306646017456 5ustar pbusernogroup00000000000000qtorganizer5-eds-0.1.1+14.04.20140415.1/cmake/0000755000015301777760000000000012323306646020536 5ustar pbusernogroup00000000000000qtorganizer5-eds-0.1.1+14.04.20140415.1/cmake/lcov.cmake0000644000015301777760000000502012323305647022500 0ustar pbusernogroup00000000000000# - This module creates a new 'lcov' target which generates # a coverage analysis html output. # LCOV is a graphical front-end for GCC's coverage testing tool gcov. Please see # http://ltp.sourceforge.net/coverage/lcov.php # # Usage: you must add an option to your CMakeLists.txt to build your application # with coverage support. Then you need to include this file to the lcov target. # # Example: # IF(BUILD_WITH_COVERAGE) # SET(CMAKE_C_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage") # SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage") # SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov") # include(${CMAKE_SOURCE_DIR}/cmake/lcov.cmake) # ENDIF(BUILD_WITH_COVERAGE) #============================================================================= # Copyright 2010 ascolab GmbH # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) set(REMOVE_PATTERN q*.h *.moc moc_*.cpp locale_facets.h new move.h) ## lcov target ADD_CUSTOM_TARGET(lcov) ADD_CUSTOM_COMMAND(TARGET lcov COMMAND mkdir -p coverage WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ADD_CUSTOM_COMMAND(TARGET lcov COMMAND lcov --directory . --zerocounters WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ADD_CUSTOM_COMMAND(TARGET lcov COMMAND make test WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ADD_CUSTOM_COMMAND(TARGET lcov COMMAND lcov --directory . --capture --output-file ./coverage/stap_all.info --no-checksum --compat-libtool WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ADD_CUSTOM_COMMAND(TARGET lcov COMMAND lcov --directory . -r ./coverage/stap_all.info ${REMOVE_PATTERN} --output-file ./coverage/stap.info WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ADD_CUSTOM_COMMAND(TARGET lcov COMMAND genhtml -o ./coverage --title "Code Coverage" --legend --show-details --demangle-cpp ./coverage/stap.info WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ADD_CUSTOM_COMMAND(TARGET lcov COMMAND echo "Open ${CMAKE_BINARY_DIR}/coverage/index.html to view the coverage analysis results." WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) qtorganizer5-eds-0.1.1+14.04.20140415.1/cmake/chewieplugin.cmake0000644000015301777760000000177712323305647024237 0ustar pbusernogroup00000000000000# -*- cmake -*- # Generates a rule to create chewie plugin # # Typical use - # # SET(SRC_FILES head1.h head2.h head3.h) # SET(LIBRARIES foolib barlib) # SET(QT_MODULES Core Qml) # SET(EXTRA_INCLUDE ${GLIB_INCLUDE_DIRS}) # CREATE_CHEWIE_PLUGIN(fooplugin LIBRARIES QT_MODULES EXTRA_INCLUDE SRC_FILES) macro(CREATE_CHEWIE_PLUGIN PLUGIN_NAME PLUGIN_LINK_LIBRARIES PLUGIN_QT_MODULES PLUGIN_EXTRA_INCLUDE PLUGIN_SOURCE) add_library(${PLUGIN_NAME} MODULE ${${PLUGIN_SOURCE}}) set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" LIBRARY_OUTPUT_DIRECTORY ${chewieplugins_BINARY_DIR}) target_link_libraries(${PLUGIN_NAME} ${${PLUGIN_LINK_LIBRARIES}}) qt5_use_modules(${PLUGIN_NAME} ${${PLUGIN_QT_MODULES}}) include_directories( ${libchewieui_SOURCE_DIR} ${${PLUGIN_EXTRA_INCLUDE}}) install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${CHEWIE_PLUGINS_DIR}) endmacro() qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/0000755000015301777760000000000012323306646021637 5ustar pbusernogroup00000000000000qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-enginedata.h0000644000015301777760000000334012323305647027037 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_ENGINEDATA_H__ #define __QORGANIZER_EDS_ENGINEDATA_H__ #include #include #include #include #include #include class SourceRegistry; class ViewWatcher; class RequestData; class QOrganizerEDSEngineData : public QSharedData { public: QOrganizerEDSEngineData(); QOrganizerEDSEngineData(const QOrganizerEDSEngineData& other); ~QOrganizerEDSEngineData(); template void emitSharedSignals(K* cs) { Q_FOREACH(QtOrganizer::QOrganizerManagerEngine* engine, m_sharedEngines) { cs->emitSignals(engine); } } ViewWatcher* watch(const QString &collectionId); void unWatch(const QString &collectionId); QAtomicInt m_refCount; SourceRegistry *m_sourceRegistry; QSet m_sharedEngines; private: QMap m_viewWatchers; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-factory.cpp0000644000015301777760000000172212323305711026734 0ustar pbusernogroup00000000000000#include "qorganizer-eds-factory.h" #include "qorganizer-eds-collection-engineid.h" #include "qorganizer-eds-engineid.h" #include "qorganizer-eds-engine.h" #include using namespace QtOrganizer; QOrganizerManagerEngine* QOrganizerEDSFactory::engine(const QMap& parameters, QOrganizerManager::Error* error) { Q_UNUSED(error); return QOrganizerEDSEngine::createEDSEngine(parameters); } QOrganizerItemEngineId* QOrganizerEDSFactory::createItemEngineId(const QMap& parameters, const QString& idString) const { Q_UNUSED(parameters); return new QOrganizerEDSEngineId(idString); } QOrganizerCollectionEngineId* QOrganizerEDSFactory::createCollectionEngineId(const QMap& parameters, const QString& idString) const { Q_UNUSED(parameters); return new QOrganizerEDSCollectionEngineId(idString); } QString QOrganizerEDSFactory::managerName() const { return QString::fromLatin1("eds"); } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-engine.cpp0000644000015301777760000025220612323305711026537 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-engine.h" #include "qorganizer-eds-engineid.h" #include "qorganizer-eds-collection-engineid.h" #include "qorganizer-eds-fetchrequestdata.h" #include "qorganizer-eds-fetchbyidrequestdata.h" #include "qorganizer-eds-fetchocurrencedata.h" #include "qorganizer-eds-saverequestdata.h" #include "qorganizer-eds-removerequestdata.h" #include "qorganizer-eds-removebyidrequestdata.h" #include "qorganizer-eds-savecollectionrequestdata.h" #include "qorganizer-eds-removecollectionrequestdata.h" #include "qorganizer-eds-viewwatcher.h" #include "qorganizer-eds-enginedata.h" #include "qorganizer-eds-source-registry.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace QtOrganizer; QOrganizerEDSEngineData *QOrganizerEDSEngine::m_globalData = 0; QOrganizerEDSEngine* QOrganizerEDSEngine::createEDSEngine(const QMap& parameters) { Q_UNUSED(parameters); if (!m_globalData) { m_globalData = new QOrganizerEDSEngineData(); m_globalData->m_sourceRegistry = new SourceRegistry; } m_globalData->m_refCount.ref(); return new QOrganizerEDSEngine(m_globalData); } QOrganizerEDSEngine::QOrganizerEDSEngine(QOrganizerEDSEngineData *data) : d(data) { d->m_sharedEngines << this; Q_FOREACH(const QString &collectionId, d->m_sourceRegistry->collectionsIds()){ onSourceAdded(collectionId); } connect(d->m_sourceRegistry, SIGNAL(sourceAdded(QString)), SLOT(onSourceAdded(QString))); connect(d->m_sourceRegistry, SIGNAL(sourceRemoved(QString)), SLOT(onSourceRemoved(QString))); d->m_sourceRegistry->load(); } QOrganizerEDSEngine::~QOrganizerEDSEngine() { Q_FOREACH(QOrganizerAbstractRequest *req, m_runningRequests.keys()) { req->cancel(); } Q_ASSERT(m_runningRequests.count() == 0); d->m_sharedEngines.remove(this); if (!d->m_refCount.deref()) { delete d; m_globalData = 0; } } QString QOrganizerEDSEngine::managerName() const { return QOrganizerEDSEngineId::managerNameStatic(); } /*! \reimp */ QMap QOrganizerEDSEngine::managerParameters() const { QMap params; return params; } void QOrganizerEDSEngine::itemsAsync(QOrganizerItemFetchRequest *req) { FetchRequestData *data = new FetchRequestData(this, d->m_sourceRegistry->collectionsIds(), req); itemsAsyncStart(data); } void QOrganizerEDSEngine::itemsAsyncStart(FetchRequestData *data) { QString collection = data->nextCollection(); if (!collection.isEmpty()) { EClient *client = data->parent()->d->m_sourceRegistry->client(collection); data->setClient(client); g_object_unref(client); if (data->hasDateInterval()) { e_cal_client_generate_instances(data->client(), data->startDate(), data->endDate(), data->cancellable(), (ECalRecurInstanceFn) QOrganizerEDSEngine::itemsAsyncListed, data, (GDestroyNotify) QOrganizerEDSEngine::itemsAsyncDone); } else { // if no date interval was set we return only the main events without recurrence e_cal_client_get_object_list_as_comps(E_CAL_CLIENT(client), data->dateFilter().toUtf8().data(), data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::itemsAsyncListedAsComps, data); } } else { data->finish(); delete data; } } void QOrganizerEDSEngine::itemsAsyncDone(FetchRequestData *data) { itemsAsyncStart(data); } void QOrganizerEDSEngine::itemsAsyncListed(ECalComponent *comp, time_t instanceStart, time_t instanceEnd, FetchRequestData *data) { Q_UNUSED(instanceStart); Q_UNUSED(instanceEnd); icalcomponent *icalComp = icalcomponent_new_clone(e_cal_component_get_icalcomponent(comp)); if (icalComp) { data->appendResult(icalComp); } } void QOrganizerEDSEngine::itemsAsyncListedAsComps(GObject *source, GAsyncResult *res, FetchRequestData *data) { Q_UNUSED(source); GError *gError = 0; GSList *events = 0; e_cal_client_get_object_list_as_comps_finish(E_CAL_CLIENT(data->client()), res, &events, &gError); if (gError) { qWarning() << "Fail to list events in calendar" << gError->message; g_error_free(gError); gError = 0; data->finish(QOrganizerManager::InvalidCollectionError); delete data; return; } else { data->appendResults(data->parent()->parseEvents(data->collection(), events, false)); } itemsAsyncStart(data); } void QOrganizerEDSEngine::itemsByIdAsync(QOrganizerItemFetchByIdRequest *req) { FetchByIdRequestData *data = new FetchByIdRequestData(this, req); itemsByIdAsyncStart(data); } void QOrganizerEDSEngine::itemsByIdAsyncStart(FetchByIdRequestData *data) { QString id = data->nextId(); if (!id.isEmpty()) { QStringList ids = id.split("/"); if (ids.length() == 2) { Q_ASSERT(ids.length() == 2); QString collectionId = ids[0]; QString rId; QString itemId = QOrganizerEDSEngineId::toComponentId(ids[1], &rId); EClient *client = data->parent()->d->m_sourceRegistry->client(collectionId); if (client) { data->setClient(client); e_cal_client_get_object(data->client(), itemId.toUtf8().data(), rId.toUtf8().data(), data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::itemsByIdAsyncListed, data); g_object_unref(client); return; } } } else if (data->end()) { data->finish(); delete data; return; } qWarning() << "Invalid item id" << id; data->appendResult(QOrganizerItem()); itemsByIdAsyncStart(data); } void QOrganizerEDSEngine::itemsByIdAsyncListed(GObject *client, GAsyncResult *res, FetchByIdRequestData *data) { Q_UNUSED(client); GError *gError = 0; icalcomponent *icalComp = 0; e_cal_client_get_object_finish(data->client(), res, &icalComp, &gError); if (gError) { qWarning() << "Fail to list events in calendar" << gError->message; g_error_free(gError); gError = 0; data->appendResult(QOrganizerItem()); } else if (icalComp) { GSList *events = g_slist_append(0, icalComp); QList items = data->parent()->parseEvents(data->currentCollectionId(), events, true); Q_ASSERT(items.size() == 1); data->appendResult(items[0]); g_slist_free_full(events, (GDestroyNotify) icalcomponent_free); } itemsByIdAsyncStart(data); } void QOrganizerEDSEngine::itemOcurrenceAsync(QOrganizerItemOccurrenceFetchRequest *req) { FetchOcurrenceData *data = new FetchOcurrenceData(this, req); QString rId; QString cId = QOrganizerEDSEngineId::toComponentId(req->parentItem().id(), &rId); EClient *client = data->parent()->d->m_sourceRegistry->client(req->parentItem().collectionId().toString()); if (client) { data->setClient(client); e_cal_client_get_object(data->client(), cId.toUtf8(), rId.toUtf8(), data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::itemOcurrenceAsyncGetObjectDone, data); g_object_unref(client); } else { qWarning() << "Fail to find collection:" << req->parentItem().collectionId(); data->finish(QOrganizerManager::DoesNotExistError); delete data; return; } } void QOrganizerEDSEngine::itemOcurrenceAsyncGetObjectDone(GObject *source, GAsyncResult *res, FetchOcurrenceData *data) { Q_UNUSED(source); GError *error = 0; icalcomponent *comp = 0; e_cal_client_get_object_finish(data->client(), res, &comp, &error); if (error) { qWarning() << "Fail to get object for id:" << data->request()->parentItem(); g_error_free(error); data->finish(QOrganizerManager::DoesNotExistError); delete data; return; } e_cal_client_generate_instances_for_object(data->client(), comp, data->startDate(), data->endDate(), data->cancellable(), (ECalRecurInstanceFn) QOrganizerEDSEngine::itemOcurrenceAsyncListed, data, (GDestroyNotify) QOrganizerEDSEngine::itemOcurrenceAsyncDone); } void QOrganizerEDSEngine::itemOcurrenceAsyncListed(ECalComponent *comp, time_t instanceStart, time_t instanceEnd, FetchOcurrenceData *data) { Q_UNUSED(instanceStart); Q_UNUSED(instanceEnd); icalcomponent *icalComp = icalcomponent_new_clone(e_cal_component_get_icalcomponent(comp)); if (icalComp) { data->appendResult(icalComp); } } void QOrganizerEDSEngine::itemOcurrenceAsyncDone(FetchOcurrenceData *data) { data->finish(); delete data; } QList QOrganizerEDSEngine::items(const QList &itemIds, const QOrganizerItemFetchHint &fetchHint, QMap *errorMap, QOrganizerManager::Error *error) { QOrganizerItemFetchByIdRequest *req = new QOrganizerItemFetchByIdRequest(this); req->setIds(itemIds); req->setFetchHint(fetchHint); startRequest(req); waitForRequestFinished(req, 0); if (error) { *error = req->error(); } if (errorMap) { *errorMap = req->errorMap(); } req->deleteLater(); return req->items(); } QList QOrganizerEDSEngine::items(const QOrganizerItemFilter &filter, const QDateTime &startDateTime, const QDateTime &endDateTime, int maxCount, const QList &sortOrders, const QOrganizerItemFetchHint &fetchHint, QOrganizerManager::Error *error) { QOrganizerItemFetchRequest *req = new QOrganizerItemFetchRequest(this); req->setFilter(filter); req->setStartDate(startDateTime); req->setEndDate(endDateTime); req->setMaxCount(maxCount); req->setSorting(sortOrders); req->setFetchHint(fetchHint); startRequest(req); waitForRequestFinished(req, 0); if (error) { *error = req->error(); } req->deleteLater(); return req->items(); } QList QOrganizerEDSEngine::itemIds(const QOrganizerItemFilter &filter, const QDateTime &startDateTime, const QDateTime &endDateTime, const QList &sortOrders, QOrganizerManager::Error *error) { qWarning() << Q_FUNC_INFO << "Not implemented"; QList items; if (error) { *error = QOrganizerManager::NotSupportedError; } return items; } QList QOrganizerEDSEngine::itemOccurrences(const QOrganizerItem &parentItem, const QDateTime &startDateTime, const QDateTime &endDateTime, int maxCount, const QOrganizerItemFetchHint &fetchHint, QOrganizerManager::Error *error) { QOrganizerItemOccurrenceFetchRequest *req = new QOrganizerItemOccurrenceFetchRequest(this); req->setParentItem(parentItem); req->setStartDate(startDateTime); req->setEndDate(endDateTime); req->setMaxOccurrences(maxCount); req->setFetchHint(fetchHint); startRequest(req); waitForRequestFinished(req, 0); if (error) { *error = req->error(); } req->deleteLater(); return req->itemOccurrences(); } QList QOrganizerEDSEngine::itemsForExport(const QDateTime &startDateTime, const QDateTime &endDateTime, const QOrganizerItemFilter &filter, const QList &sortOrders, const QOrganizerItemFetchHint &fetchHint, QOrganizerManager::Error *error) { qWarning() << Q_FUNC_INFO << "Not implemented"; if (error) { *error = QOrganizerManager::NotSupportedError; } return QList(); } void QOrganizerEDSEngine::saveItemsAsync(QOrganizerItemSaveRequest *req) { if (req->items().count() == 0) { QOrganizerManagerEngine::updateItemSaveRequest(req, QList(), QOrganizerManager::NoError, QMap(), QOrganizerAbstractRequest::FinishedState); return; } SaveRequestData *data = new SaveRequestData(this, req); saveItemsAsyncStart(data); } void QOrganizerEDSEngine::saveItemsAsyncStart(SaveRequestData *data) { QString collectionId = data->nextCollection(); if (collectionId.isNull() && data->end()) { data->finish(); delete data; return; } else { bool createItems = true; QList items = data->takeItemsToCreate(); if (items.isEmpty()) { createItems = false; items = data->takeItemsToUpdate(); } if (items.isEmpty()) { saveItemsAsyncStart(data); return; } if (collectionId.isEmpty() && createItems) { collectionId = data->parent()->d->m_sourceRegistry->defaultCollection().id().toString(); } EClient *client = data->parent()->d->m_sourceRegistry->client(collectionId); if (!client) { Q_FOREACH(const QOrganizerItem &i, items) { data->appendResult(i, QOrganizerManager::InvalidCollectionError); } saveItemsAsyncStart(data); return; } Q_ASSERT(client); data->setClient(client); g_object_unref(client); bool hasRecurrence = false; GSList *comps = parseItems(data->client(), items, &hasRecurrence); if (comps) { data->setWorkingItems(items); if (createItems) { e_cal_client_create_objects(data->client(), comps, data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::saveItemsAsyncCreated, data); } else { //WORKAROUND: There is no api to say what kind of update we want in case of update recurrence // items (E_CAL_OBJ_MOD_ALL, E_CAL_OBJ_MOD_THIS, E_CAL_OBJ_MOD_THISNADPRIOR, E_CAL_OBJ_MOD_THIS_AND_FUTURE) // as temporary solution the user can use "update-mode" property in QOrganizerItemSaveRequest object, // if not was specified, we will try to guess based on the event list. // If the event list does not cotain any recurrence event we will use E_CAL_OBJ_MOD_ALL // If the event list cotains any recurrence event we will use E_CAL_OBJ_MOD_THIS // all other cases should be explicitly specified using "update-mode" property int updateMode = data->updateMode(); if (updateMode == -1) { updateMode = hasRecurrence ? E_CAL_OBJ_MOD_THIS : E_CAL_OBJ_MOD_ALL; } e_cal_client_modify_objects(data->client(), comps, static_cast(updateMode), data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::saveItemsAsyncModified, data); } g_slist_free_full(comps, (GDestroyNotify) icalcomponent_free); } else { qWarning() << "Fail to translate items"; } } } void QOrganizerEDSEngine::saveItemsAsyncModified(GObject *source_object, GAsyncResult *res, SaveRequestData *data) { Q_UNUSED(source_object); GError *gError = 0; gboolean result = e_cal_client_modify_objects_finish(E_CAL_CLIENT(data->client()), res, &gError); QCoreApplication::processEvents(); if (gError) { qWarning() << "Fail to modify items" << gError->message; g_error_free(gError); gError = 0; Q_FOREACH(const QOrganizerItem &i, data->workingItems()) { data->appendResult(i, QOrganizerManager::UnspecifiedError); } } else { data->appendResults(data->workingItems()); } saveItemsAsyncStart(data); } void QOrganizerEDSEngine::saveItemsAsyncCreated(GObject *source_object, GAsyncResult *res, SaveRequestData *data) { Q_UNUSED(source_object); GError *gError = 0; GSList *uids = 0; e_cal_client_create_objects_finish(E_CAL_CLIENT(data->client()), res, &uids, &gError); QCoreApplication::processEvents(); if (gError) { qWarning() << "Fail to create items:" << gError->message; g_error_free(gError); gError = 0; Q_FOREACH(const QOrganizerItem &i, data->workingItems()) { data->appendResult(i, QOrganizerManager::UnspecifiedError); } } else { QString currentCollectionId = data->currentCollection(); if (currentCollectionId.isEmpty()) { currentCollectionId = data->parent()->defaultCollection(0).id().toString(); } QList items = data->workingItems(); for(uint i=0, iMax=g_slist_length(uids); i < iMax; i++) { QOrganizerItem &item = items[i]; const gchar *uid = static_cast(g_slist_nth_data(uids, i)); QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(currentCollectionId, QString::fromUtf8(uid)); item.setId(QOrganizerItemId(eid)); item.setGuid(QString::fromUtf8(uid)); QOrganizerEDSCollectionEngineId *edsCollectionId = new QOrganizerEDSCollectionEngineId(currentCollectionId); item.setCollectionId(QOrganizerCollectionId(edsCollectionId)); } g_slist_free_full(uids, g_free); data->appendResults(items); } saveItemsAsyncStart(data); } bool QOrganizerEDSEngine::saveItems(QList *items, const QList &detailMask, QMap *errorMap, QtOrganizer::QOrganizerManager::Error *error) { QOrganizerItemSaveRequest *req = new QOrganizerItemSaveRequest(this); req->setItems(*items); req->setDetailMask(detailMask); startRequest(req); waitForRequestFinished(req, 0); *errorMap = req->errorMap(); *error = req->error(); *items = req->items(); return (*error == QOrganizerManager::NoError); } void QOrganizerEDSEngine::removeItemsByIdAsync(QOrganizerItemRemoveByIdRequest *req) { if (req->itemIds().count() == 0) { QOrganizerManagerEngine::updateItemRemoveByIdRequest(req, QOrganizerManager::NoError, QMap(), QOrganizerAbstractRequest::FinishedState); return; } RemoveByIdRequestData *data = new RemoveByIdRequestData(this, req); removeItemsByIdAsyncStart(data); } void QOrganizerEDSEngine::removeItemsByIdAsyncStart(RemoveByIdRequestData *data) { QString collectionId = data->next(); for(; !collectionId.isNull(); collectionId = data->next()) { EClient *client = data->parent()->d->m_sourceRegistry->client(collectionId); data->setClient(client); g_object_unref(client); GSList *ids = data->compIds(); GError *gError = 0; e_cal_client_remove_objects_sync(data->client(), ids, E_CAL_OBJ_MOD_THIS, 0, 0); QCoreApplication::processEvents(); if (gError) { qWarning() << "Fail to remove Items" << gError->message; g_error_free(gError); gError = 0; } data->commit(); } data->finish(); delete data; } void QOrganizerEDSEngine::removeItemsAsync(QOrganizerItemRemoveRequest *req) { if (req->items().count() == 0) { QOrganizerManagerEngine::updateItemRemoveRequest(req, QOrganizerManager::NoError, QMap(), QOrganizerAbstractRequest::FinishedState); return; } RemoveRequestData *data = new RemoveRequestData(this, req); removeItemsAsyncStart(data); } void QOrganizerEDSEngine::removeItemsAsyncStart(RemoveRequestData *data) { QOrganizerCollectionId collection = data->next(); for(; !collection.isNull(); collection = data->next()) { EClient *client = data->parent()->d->m_sourceRegistry->client(collection.toString()); data->setClient(client); g_object_unref(client); GSList *ids = data->compIds(); GError *gError = 0; e_cal_client_remove_objects_sync(data->client(), ids, E_CAL_OBJ_MOD_THIS, 0, 0); QCoreApplication::processEvents(); if (gError) { qWarning() << "Fail to remove Items" << gError->message; g_error_free(gError); gError = 0; } data->commit(); } data->finish(); delete data; } bool QOrganizerEDSEngine::removeItems(const QList &itemIds, QMap *errorMap, QOrganizerManager::Error *error) { QOrganizerItemRemoveByIdRequest *req = new QOrganizerItemRemoveByIdRequest(this); req->setItemIds(itemIds); startRequest(req); waitForRequestFinished(req, 0); if (errorMap) { *errorMap = req->errorMap(); } if (error) { *error = req->error(); } return (*error == QOrganizerManager::NoError); } QOrganizerCollection QOrganizerEDSEngine::defaultCollection(QOrganizerManager::Error* error) { qWarning() << Q_FUNC_INFO << "Not implemented"; if (error) { *error = QOrganizerManager::NoError; } return d->m_sourceRegistry->defaultCollection(); } QOrganizerCollection QOrganizerEDSEngine::collection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error) { QOrganizerCollection collection = d->m_sourceRegistry->collection(collectionId.toString()); if (collection.id().isNull() && error) { *error = QOrganizerManager::DoesNotExistError; } return collection; } QList QOrganizerEDSEngine::collections(QOrganizerManager::Error* error) { QOrganizerCollectionFetchRequest *req = new QOrganizerCollectionFetchRequest(this); startRequest(req); waitForRequestFinished(req, 0); *error = req->error(); if (*error == QOrganizerManager::NoError) { return req->collections(); } else { return QList(); } } bool QOrganizerEDSEngine::saveCollection(QOrganizerCollection* collection, QOrganizerManager::Error* error) { QOrganizerCollectionSaveRequest *req = new QOrganizerCollectionSaveRequest(this); req->setCollection(*collection); startRequest(req); waitForRequestFinished(req, 0); *error = req->error(); if ((*error == QOrganizerManager::NoError) && (req->collections().count())) { *collection = req->collections()[0]; return true; } else { return false; } } void QOrganizerEDSEngine::saveCollectionAsync(QOrganizerCollectionSaveRequest *req) { if (req->collections().count() == 0) { QOrganizerManagerEngine::updateCollectionSaveRequest(req, QList(), QOrganizerManager::NoError, QMap(), QOrganizerAbstractRequest::FinishedState); return; } ESourceRegistry *registry = d->m_sourceRegistry->object(); SaveCollectionRequestData *requestData = new SaveCollectionRequestData(this, req); requestData->setRegistry(registry); if (requestData->prepareToCreate()) { e_source_registry_create_sources(registry, requestData->sourcesToCreate(), requestData->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::saveCollectionAsyncCommited, requestData); } else { requestData->prepareToUpdate(); saveCollectionUpdateAsyncStart(requestData); } } void QOrganizerEDSEngine::saveCollectionAsyncCommited(ESourceRegistry *registry, GAsyncResult *res, SaveCollectionRequestData *data) { GError *gError = 0; e_source_registry_create_sources_finish(registry, res, &gError); QCoreApplication::processEvents(); if (gError) { qWarning() << "Fail to create sources:" << gError->message; g_error_free(gError); data->finish(QOrganizerManager::InvalidCollectionError); delete data; } else { data->commitSourceCreated(); data->prepareToUpdate(); saveCollectionUpdateAsyncStart(data); } } void QOrganizerEDSEngine::saveCollectionUpdateAsyncStart(SaveCollectionRequestData *data) { ESource *source = data->nextSourceToUpdate(); if (source) { e_source_registry_commit_source(data->registry(), source, data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::saveCollectionUpdateAsynCommited, data); } else { data->finish(); delete data; } } void QOrganizerEDSEngine::saveCollectionUpdateAsynCommited(ESourceRegistry *registry, GAsyncResult *res, SaveCollectionRequestData *data) { GError *gError = 0; ESource *currentSource = data->nextSourceToUpdate(); e_source_registry_commit_source_finish(registry, res, &gError); QCoreApplication::processEvents(); if (gError) { qWarning() << "Fail to update collection" << gError->message; g_error_free(gError); data->commitSourceUpdated(currentSource, QOrganizerManager::InvalidCollectionError); } else { data->commitSourceUpdated(currentSource); } saveCollectionUpdateAsyncStart(data); } bool QOrganizerEDSEngine::removeCollection(const QOrganizerCollectionId& collectionId, QOrganizerManager::Error* error) { QOrganizerCollectionRemoveRequest *req = new QOrganizerCollectionRemoveRequest(this); req->setCollectionId(collectionId); startRequest(req); waitForRequestFinished(req, 0); *error = req->error(); return(*error == QOrganizerManager::NoError); } void QOrganizerEDSEngine::removeCollectionAsync(QtOrganizer::QOrganizerCollectionRemoveRequest *req) { if (req->collectionIds().count() == 0) { QOrganizerManagerEngine::updateCollectionRemoveRequest(req, QOrganizerManager::NoError, QMap(), QOrganizerAbstractRequest::FinishedState); return; } RemoveCollectionRequestData *requestData = new RemoveCollectionRequestData(this, req); removeCollectionAsyncStart(0, 0, requestData); } void QOrganizerEDSEngine::removeCollectionAsyncStart(GObject *sourceObject, GAsyncResult *res, RemoveCollectionRequestData *data) { if (sourceObject && res) { GError *gError = 0; if (data->remoteDeletable()) { e_source_remote_delete_finish(E_SOURCE(sourceObject), res, &gError); } else { e_source_remove_finish(E_SOURCE(sourceObject), res, &gError); } QCoreApplication::processEvents(); if (gError) { qWarning() << "Fail to remove collection" << gError->message; g_error_free(gError); data->commit(QOrganizerManager::InvalidCollectionError); } else { data->commit(); } } ESource *source = data->begin(); if (source) { if (e_source_get_remote_deletable(source)) { data->setRemoteDeletable(true); e_source_remote_delete(source, data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::removeCollectionAsyncStart, data); } else if (e_source_get_removable(source)) { e_source_remove(source, data->cancellable(), (GAsyncReadyCallback) QOrganizerEDSEngine::removeCollectionAsyncStart, data); } else { qWarning() << "Source not removable"; data->commit(QOrganizerManager::InvalidCollectionError); } } else { data->finish(); delete data; } } void QOrganizerEDSEngine::requestDestroyed(QOrganizerAbstractRequest* req) { RequestData *data = m_runningRequests.take(req); if (data) { delete data; } } bool QOrganizerEDSEngine::startRequest(QOrganizerAbstractRequest* req) { if (!req) return false; switch (req->type()) { case QOrganizerAbstractRequest::ItemFetchRequest: itemsAsync(qobject_cast(req)); break; case QOrganizerAbstractRequest::ItemFetchByIdRequest: itemsByIdAsync(qobject_cast(req)); break; case QOrganizerAbstractRequest::ItemOccurrenceFetchRequest: itemOcurrenceAsync(qobject_cast(req)); break; case QOrganizerAbstractRequest::CollectionFetchRequest: QOrganizerManagerEngine::updateCollectionFetchRequest(qobject_cast(req), d->m_sourceRegistry->collections(), QOrganizerManager::NoError, QOrganizerAbstractRequest::FinishedState); break; case QOrganizerAbstractRequest::ItemSaveRequest: saveItemsAsync(qobject_cast(req)); break; case QOrganizerAbstractRequest::ItemRemoveRequest: removeItemsAsync(qobject_cast(req)); break; case QOrganizerAbstractRequest::ItemRemoveByIdRequest: removeItemsByIdAsync(qobject_cast(req)); break; case QOrganizerAbstractRequest::CollectionSaveRequest: saveCollectionAsync(qobject_cast(req)); break; case QOrganizerAbstractRequest::CollectionRemoveRequest: removeCollectionAsync(qobject_cast(req)); break; default: updateRequestState(req, QOrganizerAbstractRequest::FinishedState); qWarning() << "No implemented request" << req->type(); break; } return true; } bool QOrganizerEDSEngine::cancelRequest(QOrganizerAbstractRequest* req) { RequestData *data = m_runningRequests.take(req); if (data) { data->cancel(); delete data; return true; } return false; } bool QOrganizerEDSEngine::waitForRequestFinished(QOrganizerAbstractRequest* req, int msecs) { Q_ASSERT(req); Q_UNUSED(msecs); QPointer r(req); while(r && (r->state() == QOrganizerAbstractRequest::ActiveState)) { QCoreApplication::processEvents(); } return true; } QList QOrganizerEDSEngine::supportedItemDetails(QOrganizerItemType::ItemType itemType) const { QList supportedDetails; supportedDetails << QOrganizerItemDetail::TypeItemType << QOrganizerItemDetail::TypeGuid << QOrganizerItemDetail::TypeTimestamp << QOrganizerItemDetail::TypeDisplayLabel << QOrganizerItemDetail::TypeDescription << QOrganizerItemDetail::TypeComment << QOrganizerItemDetail::TypeTag << QOrganizerItemDetail::TypeClassification << QOrganizerItemDetail::TypeExtendedDetail; if (itemType == QOrganizerItemType::TypeEvent) { supportedDetails << QOrganizerItemDetail::TypeRecurrence << QOrganizerItemDetail::TypeEventTime << QOrganizerItemDetail::TypePriority << QOrganizerItemDetail::TypeLocation << QOrganizerItemDetail::TypeReminder << QOrganizerItemDetail::TypeAudibleReminder << QOrganizerItemDetail::TypeEmailReminder << QOrganizerItemDetail::TypeVisualReminder; } else if (itemType == QOrganizerItemType::TypeTodo) { supportedDetails << QOrganizerItemDetail::TypeRecurrence << QOrganizerItemDetail::TypeTodoTime << QOrganizerItemDetail::TypePriority << QOrganizerItemDetail::TypeTodoProgress << QOrganizerItemDetail::TypeReminder << QOrganizerItemDetail::TypeAudibleReminder << QOrganizerItemDetail::TypeEmailReminder << QOrganizerItemDetail::TypeVisualReminder; } else if (itemType == QOrganizerItemType::TypeEventOccurrence) { supportedDetails << QOrganizerItemDetail::TypeParent << QOrganizerItemDetail::TypeEventTime << QOrganizerItemDetail::TypePriority << QOrganizerItemDetail::TypeLocation << QOrganizerItemDetail::TypeReminder << QOrganizerItemDetail::TypeAudibleReminder << QOrganizerItemDetail::TypeEmailReminder << QOrganizerItemDetail::TypeVisualReminder; } else if (itemType == QOrganizerItemType::TypeTodoOccurrence) { supportedDetails << QOrganizerItemDetail::TypeParent << QOrganizerItemDetail::TypeTodoTime << QOrganizerItemDetail::TypePriority << QOrganizerItemDetail::TypeTodoProgress << QOrganizerItemDetail::TypeReminder << QOrganizerItemDetail::TypeAudibleReminder << QOrganizerItemDetail::TypeEmailReminder << QOrganizerItemDetail::TypeVisualReminder; } else if (itemType == QOrganizerItemType::TypeJournal) { supportedDetails << QOrganizerItemDetail::TypeJournalTime; } else if (itemType == QOrganizerItemType::TypeNote) { // nothing ;) } else { supportedDetails.clear(); } return supportedDetails; } QList QOrganizerEDSEngine::supportedFilters() const { QList supported; supported << QOrganizerItemFilter::InvalidFilter << QOrganizerItemFilter::DetailFilter << QOrganizerItemFilter::DetailFieldFilter << QOrganizerItemFilter::DetailRangeFilter << QOrganizerItemFilter::IntersectionFilter << QOrganizerItemFilter::UnionFilter << QOrganizerItemFilter::IdFilter << QOrganizerItemFilter::CollectionFilter << QOrganizerItemFilter::DefaultFilter; return supported; } QList QOrganizerEDSEngine::supportedItemTypes() const { return QList() << QOrganizerItemType::TypeEvent << QOrganizerItemType::TypeEventOccurrence << QOrganizerItemType::TypeJournal << QOrganizerItemType::TypeNote << QOrganizerItemType::TypeTodo << QOrganizerItemType::TypeTodoOccurrence; } void QOrganizerEDSEngine::onSourceAdded(const QString &collectionId) { d->watch(collectionId); } void QOrganizerEDSEngine::onSourceRemoved(const QString &collectionId) { d->unWatch(collectionId); } void QOrganizerEDSEngine::onViewChanged(QOrganizerItemChangeSet *change) { change->emitSignals(this); } QDateTime QOrganizerEDSEngine::fromIcalTime(struct icaltimetype value, const char *tzId) { uint tmTime; if (tzId) { QByteArray tzName(tzId); // keep only the timezone name. tzName = tzName.replace("/freeassociation.sourceforge.net/Tzfile/", ""); const icaltimezone *timezone = const_cast(icaltimezone_get_builtin_timezone(tzName.constData())); tmTime = icaltime_as_timet_with_zone(value, timezone); return QDateTime::fromTime_t(tmTime, QTimeZone(tzId)); } else { tmTime = icaltime_as_timet(value); return QDateTime::fromTime_t(tmTime); } } icaltimetype QOrganizerEDSEngine::fromQDateTime(const QDateTime &dateTime, bool allDay, QByteArray *tzId) { if (dateTime.timeSpec() == Qt::TimeZone) { const icaltimezone *timezone = 0; *tzId = dateTime.timeZone().id(); timezone = const_cast(icaltimezone_get_builtin_timezone(tzId->constData())); return icaltime_from_timet_with_zone(dateTime.toTime_t(), allDay, timezone); } else { return icaltime_from_timet(dateTime.toTime_t(), allDay); } } void QOrganizerEDSEngine::parseStartTime(ECalComponent *comp, QOrganizerItem *item) { ECalComponentDateTime *dt = g_new0(ECalComponentDateTime, 1); e_cal_component_get_dtstart(comp, dt); if (dt->value) { QOrganizerEventTime etr = item->detail(QOrganizerItemDetail::TypeEventTime); etr.setStartDateTime(fromIcalTime(*dt->value, dt->tzid)); if (icaltime_is_date(*dt->value) != etr.isAllDay()) { etr.setAllDay(icaltime_is_date(*dt->value)); } item->saveDetail(&etr); } e_cal_component_free_datetime(dt); } void QOrganizerEDSEngine::parseTodoStartTime(ECalComponent *comp, QOrganizerItem *item) { ECalComponentDateTime *dt = g_new0(ECalComponentDateTime, 1); e_cal_component_get_dtstart(comp, dt); if (dt->value) { QOrganizerTodoTime etr = item->detail(QOrganizerItemDetail::TypeTodoTime); etr.setStartDateTime(fromIcalTime(*dt->value, dt->tzid)); if (icaltime_is_date(*dt->value) != etr.isAllDay()) { etr.setAllDay(icaltime_is_date(*dt->value)); } item->saveDetail(&etr); } e_cal_component_free_datetime(dt); } void QOrganizerEDSEngine::parseEndTime(ECalComponent *comp, QOrganizerItem *item) { ECalComponentDateTime *dt = g_new0(ECalComponentDateTime, 1); e_cal_component_get_dtend(comp, dt); if (dt->value) { QOrganizerEventTime etr = item->detail(QOrganizerItemDetail::TypeEventTime); etr.setEndDateTime(fromIcalTime(*dt->value, dt->tzid)); if (icaltime_is_date(*dt->value) != etr.isAllDay()) { etr.setAllDay(icaltime_is_date(*dt->value)); } item->saveDetail(&etr); } e_cal_component_free_datetime(dt); } void QOrganizerEDSEngine::parseWeekRecurrence(struct icalrecurrencetype *rule, QtOrganizer::QOrganizerRecurrenceRule *qRule) { static QMap daysOfWeekMap; if (daysOfWeekMap.isEmpty()) { daysOfWeekMap.insert(ICAL_MONDAY_WEEKDAY, Qt::Monday); daysOfWeekMap.insert(ICAL_THURSDAY_WEEKDAY, Qt::Thursday); daysOfWeekMap.insert(ICAL_WEDNESDAY_WEEKDAY, Qt::Wednesday); daysOfWeekMap.insert(ICAL_TUESDAY_WEEKDAY, Qt::Tuesday); daysOfWeekMap.insert(ICAL_FRIDAY_WEEKDAY, Qt::Friday); daysOfWeekMap.insert(ICAL_SATURDAY_WEEKDAY, Qt::Saturday); daysOfWeekMap.insert(ICAL_SUNDAY_WEEKDAY, Qt::Sunday); } qRule->setFrequency(QOrganizerRecurrenceRule::Weekly); QSet daysOfWeek; for (int d=0; d <= Qt::Sunday; d++) { short day = rule->by_day[d]; if (day != ICAL_RECURRENCE_ARRAY_MAX) { daysOfWeek.insert(daysOfWeekMap[icalrecurrencetype_day_day_of_week(rule->by_day[d])]); } } qRule->setDaysOfWeek(daysOfWeek); } void QOrganizerEDSEngine::parseMonthRecurrence(struct icalrecurrencetype *rule, QtOrganizer::QOrganizerRecurrenceRule *qRule) { qRule->setFrequency(QOrganizerRecurrenceRule::Monthly); QSet daysOfMonth; for (int d=0; d < ICAL_BY_MONTHDAY_SIZE; d++) { short day = rule->by_month_day[d]; if (day != ICAL_RECURRENCE_ARRAY_MAX) { daysOfMonth.insert(day); } } qRule->setDaysOfMonth(daysOfMonth); } void QOrganizerEDSEngine::parseYearRecurrence(struct icalrecurrencetype *rule, QtOrganizer::QOrganizerRecurrenceRule *qRule) { qRule->setFrequency(QOrganizerRecurrenceRule::Yearly); QSet daysOfYear; for (int d=0; d < ICAL_BY_YEARDAY_SIZE; d++) { short day = rule->by_year_day[d]; if (day != ICAL_RECURRENCE_ARRAY_MAX) { daysOfYear.insert(day); } } qRule->setDaysOfYear(daysOfYear); QSet monthOfYear; for (int d=0; d < ICAL_BY_MONTH_SIZE; d++) { short month = rule->by_month[d]; if (month != ICAL_RECURRENCE_ARRAY_MAX) { monthOfYear.insert(static_cast(month)); } } qRule->setMonthsOfYear(monthOfYear); } void QOrganizerEDSEngine::parseRecurrence(ECalComponent *comp, QOrganizerItem *item) { // recurence if (e_cal_component_has_rdates(comp)) { QSet dates; GSList *periodList = 0; e_cal_component_get_rdate_list(comp, &periodList); for(GSList *i = periodList; i != 0; i = i->next) { ECalComponentPeriod *period = (ECalComponentPeriod*) i->data; //TODO: get timezone info QDateTime dt = fromIcalTime(period->start, 0); dates.insert(dt.date()); //TODO: period.end, period.duration } e_cal_component_free_period_list(periodList); QOrganizerItemRecurrence rec = item->detail(QOrganizerItemDetail::TypeRecurrence); rec.setRecurrenceDates(dates); item->saveDetail(&rec); } if (e_cal_component_has_exdates(comp)) { QSet dates; GSList *exdateList = 0; e_cal_component_get_exdate_list(comp, &exdateList); for(GSList *i = exdateList; i != 0; i = i->next) { ECalComponentDateTime* dateTime = (ECalComponentDateTime*) i->data; QDateTime dt = fromIcalTime(*dateTime->value, dateTime->tzid); dates.insert(dt.date()); } e_cal_component_free_exdate_list(exdateList); QOrganizerItemRecurrence irec = item->detail(QOrganizerItemDetail::TypeRecurrence); irec.setExceptionDates(dates); item->saveDetail(&irec); } // rules GSList *ruleList = 0; e_cal_component_get_rrule_list(comp, &ruleList); if (ruleList) { QSet qRules; for(GSList *i = ruleList; i != 0; i = i->next) { struct icalrecurrencetype *rule = (struct icalrecurrencetype*) i->data; QOrganizerRecurrenceRule qRule; switch (rule->freq) { case ICAL_SECONDLY_RECURRENCE: case ICAL_MINUTELY_RECURRENCE: case ICAL_HOURLY_RECURRENCE: qWarning() << "Recurrence frequency not supported"; break; case ICAL_DAILY_RECURRENCE: qRule.setFrequency(QOrganizerRecurrenceRule::Daily); break; case ICAL_WEEKLY_RECURRENCE: parseWeekRecurrence(rule, &qRule); break; case ICAL_MONTHLY_RECURRENCE: parseMonthRecurrence(rule, &qRule); break; case ICAL_YEARLY_RECURRENCE: parseYearRecurrence(rule, &qRule); break; case ICAL_NO_RECURRENCE: break; } if (icaltime_is_date(rule->until)) { QDate dt = QDate::fromString(icaltime_as_ical_string(rule->until), "yyyyMMdd"); if (dt.isValid()) { qRule.setLimit(dt); } } else { qRule.setLimit(rule->count); } qRule.setInterval(rule->interval); QSet positions; for (int d=0; d < ICAL_BY_SETPOS_SIZE; d++) { short day = rule->by_set_pos[d]; if (day != ICAL_RECURRENCE_ARRAY_MAX) { positions.insert(day); } } qRule.setPositions(positions); qRules << qRule; } if (!qRules.isEmpty()) { QOrganizerItemRecurrence irec = item->detail(QOrganizerItemDetail::TypeRecurrence); irec.setRecurrenceRules(qRules); item->saveDetail(&irec); } e_cal_component_free_recur_list(ruleList); } // TODO: exeptions rules } void QOrganizerEDSEngine::parsePriority(ECalComponent *comp, QOrganizerItem *item) { gint *priority = 0; e_cal_component_get_priority(comp, &priority); if (priority) { QOrganizerItemPriority iPriority = item->detail(QOrganizerItemDetail::TypePriority); if ((*priority >= QOrganizerItemPriority::UnknownPriority) && (*priority <= QOrganizerItemPriority::LowPriority)) { iPriority.setPriority((QOrganizerItemPriority::Priority) *priority); } else { iPriority.setPriority(QOrganizerItemPriority::UnknownPriority); } e_cal_component_free_priority(priority); item->saveDetail(&iPriority); } } void QOrganizerEDSEngine::parseLocation(ECalComponent *comp, QOrganizerItem *item) { const gchar *location; e_cal_component_get_location(comp, &location); if (location) { QOrganizerItemLocation ld = item->detail(QOrganizerItemDetail::TypeLocation); ld.setLabel(QString::fromUtf8(location)); item->saveDetail(&ld); } } void QOrganizerEDSEngine::parseDueDate(ECalComponent *comp, QOrganizerItem *item) { ECalComponentDateTime due; e_cal_component_get_due(comp, &due); if (due.value) { QOrganizerTodoTime ttr = item->detail(QOrganizerItemDetail::TypeTodoTime); ttr.setDueDateTime(fromIcalTime(*due.value, due.tzid)); if (icaltime_is_date(*due.value) != ttr.isAllDay()) { ttr.setAllDay(icaltime_is_date(*due.value)); } item->saveDetail(&ttr); } e_cal_component_free_datetime(&due); } void QOrganizerEDSEngine::parseProgress(ECalComponent *comp, QOrganizerItem *item) { gint percentage = e_cal_component_get_percent_as_int(comp); if (percentage >= 0 && percentage <= 100) { QOrganizerTodoProgress tp = item->detail(QOrganizerItemDetail::TypeTodoProgress); tp.setPercentageComplete(percentage); item->saveDetail(&tp); } } void QOrganizerEDSEngine::parseStatus(ECalComponent *comp, QOrganizerItem *item) { icalproperty_status status; e_cal_component_get_status(comp, &status); QOrganizerTodoProgress tp; switch(status) { case ICAL_STATUS_NONE: tp.setStatus(QOrganizerTodoProgress::StatusNotStarted); break; case ICAL_STATUS_INPROCESS: tp.setStatus(QOrganizerTodoProgress::StatusInProgress); break; case ICAL_STATUS_COMPLETED: tp.setStatus(QOrganizerTodoProgress::StatusComplete); break; case ICAL_STATUS_CANCELLED: default: //TODO: not supported break; } item->saveDetail(&tp); } void QOrganizerEDSEngine::parseAttendeeList(ECalComponent *comp, QOrganizerItem *item) { GSList *attendeeList = 0; e_cal_component_get_attendee_list(comp, &attendeeList); for (GSList *attendeeIter=attendeeList; attendeeIter != 0; attendeeIter = attendeeIter->next) { ECalComponentAttendee *attendee = static_cast(attendeeIter->data); QOrganizerEventAttendee qAttendee; qAttendee.setName(QString::fromUtf8(attendee->cn)); qAttendee.setEmailAddress(QString::fromUtf8(attendee->member)); switch(attendee->role) { case ICAL_ROLE_REQPARTICIPANT: qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleRequiredParticipant); break; case ICAL_ROLE_OPTPARTICIPANT: qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleOptionalParticipant); break; case ICAL_ROLE_CHAIR: qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleChairperson); break; case ICAL_ROLE_NONE: default: qAttendee.setParticipationRole(QOrganizerEventAttendee::RoleNonParticipant); break; } switch(attendee->status) { case ICAL_PARTSTAT_ACCEPTED: qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusAccepted); break; case ICAL_PARTSTAT_DECLINED: qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusDeclined); break; case ICAL_PARTSTAT_TENTATIVE: qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusTentative); break; case ICAL_PARTSTAT_DELEGATED: qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusDelegated); break; case ICAL_PARTSTAT_COMPLETED: qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusCompleted); break; case ICAL_PARTSTAT_INPROCESS: qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusInProcess); break; case ICAL_PARTSTAT_NEEDSACTION: case ICAL_PARTSTAT_NONE: default: qAttendee.setParticipationStatus(QOrganizerEventAttendee::StatusUnknown); break; } item->saveDetail(&qAttendee); } e_cal_component_free_attendee_list(attendeeList); } QOrganizerItem *QOrganizerEDSEngine::parseEvent(ECalComponent *comp) { QOrganizerItem *event; if (hasRecurrence(comp)) { event = new QOrganizerEventOccurrence(); } else { event = new QOrganizerEvent(); } parseStartTime(comp, event); parseEndTime(comp, event); parseRecurrence(comp, event); parsePriority(comp, event); parseLocation(comp, event); return event; } QOrganizerItem *QOrganizerEDSEngine::parseToDo(ECalComponent *comp) { QOrganizerItem *todo; if (hasRecurrence(comp)) { todo = new QOrganizerTodoOccurrence(); } else { todo = new QOrganizerTodo(); } parseTodoStartTime(comp, todo); parseDueDate(comp, todo); parseRecurrence(comp, todo); parsePriority(comp, todo); parseProgress(comp, todo); parseStatus(comp, todo); return todo; } QOrganizerItem *QOrganizerEDSEngine::parseJournal(ECalComponent *comp) { QOrganizerJournal *journal = new QOrganizerJournal(); ECalComponentDateTime dt; e_cal_component_get_dtstart(comp, &dt); if (dt.value) { QOrganizerJournalTime jtime; jtime.setEntryDateTime(fromIcalTime(*dt.value, dt.tzid)); journal->saveDetail(&jtime); } e_cal_component_free_datetime(&dt); return journal; } void QOrganizerEDSEngine::parseSummary(ECalComponent *comp, QtOrganizer::QOrganizerItem *item) { ECalComponentText summary; e_cal_component_get_summary(comp, &summary); if (summary.value) { item->setDisplayLabel(QString::fromUtf8(summary.value)); } } void QOrganizerEDSEngine::parseDescription(ECalComponent *comp, QtOrganizer::QOrganizerItem *item) { GSList *descriptions = 0; e_cal_component_get_description_list(comp, &descriptions); QStringList itemDescription; for(GSList *descList = descriptions; descList != 0; descList = descList->next) { ECalComponentText *description = static_cast(descList->data); if (description && description->value) { itemDescription.append(QString::fromUtf8(description->value)); } } item->setDescription(itemDescription.join("\n")); e_cal_component_free_text_list(descriptions); } void QOrganizerEDSEngine::parseComments(ECalComponent *comp, QtOrganizer::QOrganizerItem *item) { GSList *comments = 0; e_cal_component_get_comment_list(comp, &comments); for(int ci=0, ciMax=g_slist_length(comments); ci < ciMax; ci++) { ECalComponentText *txt = static_cast(g_slist_nth_data(comments, ci)); item->addComment(QString::fromUtf8(txt->value)); } e_cal_component_free_text_list(comments); } void QOrganizerEDSEngine::parseTags(ECalComponent *comp, QtOrganizer::QOrganizerItem *item) { GSList *categories = 0; e_cal_component_get_categories_list(comp, &categories); for(GSList *tag=categories; tag != 0; tag = tag->next) { item->addTag(QString::fromUtf8(static_cast(tag->data))); } e_cal_component_free_categories_list(categories); } QUrl QOrganizerEDSEngine::dencodeAttachment(ECalComponentAlarm *alarm) { QUrl attachment; icalattach *attach = 0; e_cal_component_alarm_get_attach(alarm, &attach); if (attach) { if (icalattach_get_is_url(attach)) { const gchar *url = icalattach_get_url(attach); attachment = QUrl(QString::fromUtf8(url)); } icalattach_unref(attach); } return attachment; } void QOrganizerEDSEngine::parseVisualReminderAttachment(ECalComponentAlarm *alarm, QOrganizerItemReminder *aDetail) { QUrl attach = dencodeAttachment(alarm); if (attach.isValid()) { aDetail->setValue(QOrganizerItemVisualReminder::FieldDataUrl, attach); } ECalComponentText txt; e_cal_component_alarm_get_description(alarm, &txt); aDetail->setValue(QOrganizerItemVisualReminder::FieldMessage, QString::fromUtf8(txt.value)); } void QOrganizerEDSEngine::parseAudibleReminderAttachment(ECalComponentAlarm *alarm, QOrganizerItemReminder *aDetail) { QUrl attach = dencodeAttachment(alarm); if (attach.isValid()) { aDetail->setValue(QOrganizerItemAudibleReminder::FieldDataUrl, attach); } } void QOrganizerEDSEngine::parseReminders(ECalComponent *comp, QtOrganizer::QOrganizerItem *item) { GList *alarms = e_cal_component_get_alarm_uids(comp); for(GList *a = alarms; a != 0; a = a->next) { QOrganizerItemReminder *aDetail = 0; ECalComponentAlarm *alarm = e_cal_component_get_alarm(comp, static_cast(a->data)); if (!alarm) { continue; } ECalComponentAlarmAction aAction; e_cal_component_alarm_get_action(alarm, &aAction); switch(aAction) { case E_CAL_COMPONENT_ALARM_DISPLAY: aDetail = new QOrganizerItemVisualReminder(); parseVisualReminderAttachment(alarm, aDetail); break; case E_CAL_COMPONENT_ALARM_AUDIO: // use audio as fallback default: aDetail = new QOrganizerItemAudibleReminder(); parseAudibleReminderAttachment(alarm, aDetail); break; } ECalComponentAlarmTrigger trigger; e_cal_component_alarm_get_trigger(alarm, &trigger); if (trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START) { aDetail->setSecondsBeforeStart(icaldurationtype_as_int(trigger.u.rel_duration) * -1); } ECalComponentAlarmRepeat aRepeat; e_cal_component_alarm_get_repeat(alarm, &aRepeat); aDetail->setRepetition(aRepeat.repetitions, icaldurationtype_as_int(aRepeat.duration)); item->saveDetail(aDetail); delete aDetail; } } QList QOrganizerEDSEngine::parseEvents(const QString &collectionId, GSList *events, bool isIcalEvents) { QOrganizerEDSCollectionEngineId *collection = d->m_sourceRegistry->collectionEngineId(collectionId); QList items; for (GSList *l = events; l; l = l->next) { QOrganizerItem *item; ECalComponent *comp; if (isIcalEvents) { icalcomponent *clone = icalcomponent_new_clone(static_cast(l->data)); comp = e_cal_component_new_from_icalcomponent(clone); } else { comp = E_CAL_COMPONENT(l->data); } //type ECalComponentVType vType = e_cal_component_get_vtype(comp); switch(vType) { case E_CAL_COMPONENT_EVENT: item = parseEvent(comp); break; case E_CAL_COMPONENT_TODO: item = parseToDo(comp); break; case E_CAL_COMPONENT_JOURNAL: item = parseJournal(comp); break; case E_CAL_COMPONENT_FREEBUSY: qWarning() << "Component FREEBUSY not supported;"; continue; case E_CAL_COMPONENT_TIMEZONE: qWarning() << "Component TIMEZONE not supported;"; case E_CAL_COMPONENT_NO_TYPE: continue; } parseId(comp, item, collection); parseDescription(comp, item); parseSummary(comp, item); parseComments(comp, item); parseTags(comp, item); parseReminders(comp, item); parseAttendeeList(comp, item); items << *item; delete item; if (isIcalEvents) { g_object_unref(comp); } } return items; } void QOrganizerEDSEngine::parseStartTime(const QOrganizerItem &item, ECalComponent *comp) { QOrganizerEventTime etr = item.detail(QOrganizerItemDetail::TypeEventTime); if (!etr.isEmpty()) { QByteArray tzId; struct icaltimetype ict = fromQDateTime(etr.startDateTime(), etr.isAllDay(), &tzId); ECalComponentDateTime dt; dt.tzid = tzId.isEmpty() ? NULL : tzId.constData(); dt.value = &ict; e_cal_component_set_dtstart(comp, &dt); } } void QOrganizerEDSEngine::parseEndTime(const QOrganizerItem &item, ECalComponent *comp) { QOrganizerEventTime etr = item.detail(QOrganizerItemDetail::TypeEventTime); if (!etr.isEmpty()) { QByteArray tzId; struct icaltimetype ict = fromQDateTime(etr.endDateTime(), etr.isAllDay(), &tzId); ECalComponentDateTime dt; dt.tzid = tzId.isEmpty() ? NULL : tzId.constData(); dt.value = &ict; e_cal_component_set_dtend(comp, &dt); } } void QOrganizerEDSEngine::parseTodoStartTime(const QOrganizerItem &item, ECalComponent *comp) { QOrganizerTodoTime etr = item.detail(QOrganizerItemDetail::TypeTodoTime); if (!etr.isEmpty()) { QByteArray tzId; struct icaltimetype ict = fromQDateTime(etr.startDateTime(), etr.isAllDay(), &tzId); ECalComponentDateTime dt; dt.tzid = tzId.isEmpty() ? NULL : tzId.constData(); dt.value = &ict; e_cal_component_set_dtstart(comp, &dt);; } } void QOrganizerEDSEngine::parseWeekRecurrence(const QOrganizerRecurrenceRule &qRule, struct icalrecurrencetype *rule) { static QMap daysOfWeekMap; if (daysOfWeekMap.isEmpty()) { daysOfWeekMap.insert(Qt::Monday, ICAL_MONDAY_WEEKDAY); daysOfWeekMap.insert(Qt::Thursday, ICAL_THURSDAY_WEEKDAY); daysOfWeekMap.insert(Qt::Wednesday, ICAL_WEDNESDAY_WEEKDAY); daysOfWeekMap.insert(Qt::Tuesday, ICAL_TUESDAY_WEEKDAY); daysOfWeekMap.insert(Qt::Friday, ICAL_FRIDAY_WEEKDAY); daysOfWeekMap.insert(Qt::Saturday, ICAL_SATURDAY_WEEKDAY); daysOfWeekMap.insert(Qt::Sunday, ICAL_SUNDAY_WEEKDAY); } QList daysOfWeek = qRule.daysOfWeek().toList(); int c = 0; rule->freq = ICAL_WEEKLY_RECURRENCE; for(int d=Qt::Monday; d <= Qt::Sunday; d++) { if (daysOfWeek.contains(static_cast(d))) { rule->by_day[c++] = daysOfWeekMap[static_cast(d)]; } } for (int d = c; d < ICAL_BY_DAY_SIZE; d++) { rule->by_day[d] = ICAL_RECURRENCE_ARRAY_MAX; } } void QOrganizerEDSEngine::parseMonthRecurrence(const QOrganizerRecurrenceRule &qRule, struct icalrecurrencetype *rule) { rule->freq = ICAL_MONTHLY_RECURRENCE; QList daysOfMonth = qRule.daysOfMonth().toList(); int c = 0; for (int d=1; d < ICAL_BY_MONTHDAY_SIZE; d++) { if (daysOfMonth.contains(d)) { rule->by_month_day[c++] = d; } } for (int d = c; d < ICAL_BY_MONTHDAY_SIZE; d++) { rule->by_month_day[d] = ICAL_RECURRENCE_ARRAY_MAX; } } void QOrganizerEDSEngine::parseYearRecurrence(const QOrganizerRecurrenceRule &qRule, struct icalrecurrencetype *rule) { rule->freq = ICAL_YEARLY_RECURRENCE; QList daysOfYear = qRule.daysOfYear().toList(); int c = 0; for (int d=1; d < ICAL_BY_YEARDAY_SIZE; d++) { if (daysOfYear.contains(d)) { rule->by_year_day[c++] = d; } } for (int d = c; d < ICAL_BY_YEARDAY_SIZE; d++) { rule->by_year_day[d] = ICAL_RECURRENCE_ARRAY_MAX; } c = 0; QList monthOfYear = qRule.monthsOfYear().toList(); for (int d=1; d < ICAL_BY_MONTH_SIZE; d++) { if (monthOfYear.contains(static_cast(d))) { rule->by_month[c++] = d; } } for (int d = c; d < ICAL_BY_YEARDAY_SIZE; d++) { rule->by_month[d] = ICAL_RECURRENCE_ARRAY_MAX; } } void QOrganizerEDSEngine::parseRecurrence(const QOrganizerItem &item, ECalComponent *comp) { QOrganizerItemRecurrence rec = item.detail(QOrganizerItemDetail::TypeRecurrence); if (!rec.isEmpty()) { GSList *periodList = 0; Q_FOREACH(const QDate &dt, rec.recurrenceDates()) { ECalComponentPeriod *period = g_new0(ECalComponentPeriod, 1); period->start = icaltime_from_timet(QDateTime(dt).toTime_t(), FALSE); periodList = g_slist_append(periodList, period); //TODO: period.end, period.duration } e_cal_component_set_rdate_list(comp, periodList); e_cal_component_free_period_list(periodList); GSList *exdateList = 0; Q_FOREACH(const QDate &dt, rec.exceptionDates()) { ECalComponentDateTime *dateTime = g_new0(ECalComponentDateTime, 1); struct icaltimetype *itt = g_new0(struct icaltimetype, 1); *itt = icaltime_from_timet(QDateTime(dt).toTime_t(), FALSE); dateTime->value = itt; exdateList = g_slist_append(exdateList, dateTime); } e_cal_component_set_exdate_list(comp, exdateList); e_cal_component_free_exdate_list(exdateList); GSList *ruleList = 0; Q_FOREACH(const QOrganizerRecurrenceRule &qRule, rec.recurrenceRules()) { struct icalrecurrencetype *rule = g_new0(struct icalrecurrencetype, 1); icalrecurrencetype_clear(rule); switch(qRule.frequency()) { case QOrganizerRecurrenceRule::Daily: rule->freq = ICAL_DAILY_RECURRENCE; break; case QOrganizerRecurrenceRule::Weekly: parseWeekRecurrence(qRule, rule); break; case QOrganizerRecurrenceRule::Monthly: parseMonthRecurrence(qRule, rule); break; case QOrganizerRecurrenceRule::Yearly: parseYearRecurrence(qRule, rule); break; case QOrganizerRecurrenceRule::Invalid: rule->freq = ICAL_NO_RECURRENCE; break; } if (qRule.limitDate().isValid()) { rule->until = icaltime_from_timet(QDateTime(qRule.limitDate()).toTime_t(), TRUE); rule->count = ICAL_RECURRENCE_ARRAY_MAX; } else { rule->count = qRule.limitCount(); } QSet positions = qRule.positions(); for (int d=1; d < ICAL_BY_SETPOS_SIZE; d++) { if (positions.contains(d)) { rule->by_set_pos[d] = d; } else { rule->by_set_pos[d] = ICAL_RECURRENCE_ARRAY_MAX; } } rule->interval = qRule.interval(); ruleList = g_slist_append(ruleList, rule); } e_cal_component_set_rrule_list(comp, ruleList); g_slist_free_full(ruleList, g_free); } } void QOrganizerEDSEngine::parsePriority(const QOrganizerItem &item, ECalComponent *comp) { QOrganizerItemPriority priority = item.detail(QOrganizerItemDetail::TypePriority); if (!priority.isEmpty()) { gint iPriority = (gint) priority.priority(); e_cal_component_set_priority(comp, &iPriority); } } void QOrganizerEDSEngine::parseLocation(const QOrganizerItem &item, ECalComponent *comp) { QOrganizerItemLocation ld = item.detail(QOrganizerItemDetail::TypeLocation); if (!ld.isEmpty()) { e_cal_component_set_location(comp, ld.label().toUtf8().data()); } } void QOrganizerEDSEngine::parseDueDate(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp) { QOrganizerTodoTime ttr = item.detail(QOrganizerItemDetail::TypeTodoTime); if (!ttr.isEmpty()) { QByteArray tzId; struct icaltimetype ict = fromQDateTime(ttr.dueDateTime(), ttr.isAllDay(), &tzId); ECalComponentDateTime dt; dt.tzid = tzId.isEmpty() ? NULL : tzId.constData(); dt.value = &ict; e_cal_component_set_due(comp, &dt);; } } void QOrganizerEDSEngine::parseProgress(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp) { QOrganizerTodoProgress tp = item.detail(QOrganizerItemDetail::TypeTodoProgress); if (!tp.isEmpty()) { e_cal_component_set_percent_as_int(comp, tp.percentageComplete()); } } void QOrganizerEDSEngine::parseStatus(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp) { QOrganizerTodoProgress tp = item.detail(QOrganizerItemDetail::TypeTodoProgress); if (!tp.isEmpty()) { switch(tp.status()) { case QOrganizerTodoProgress::StatusNotStarted: e_cal_component_set_status(comp, ICAL_STATUS_NONE); break; case QOrganizerTodoProgress::StatusInProgress: e_cal_component_set_status(comp, ICAL_STATUS_INPROCESS); break; case QOrganizerTodoProgress::StatusComplete: e_cal_component_set_status(comp, ICAL_STATUS_COMPLETED); break; default: e_cal_component_set_status(comp, ICAL_STATUS_CANCELLED); break; } } } void QOrganizerEDSEngine::parseAttendeeList(const QOrganizerItem &item, ECalComponent *comp) { GSList *attendeeList = 0; Q_FOREACH(const QOrganizerEventAttendee &attendee, item.details(QOrganizerItemDetail::TypeEventAttendee)) { ECalComponentAttendee *calAttendee = g_new0(ECalComponentAttendee, 1); calAttendee->cn = g_strdup(attendee.name().toUtf8().constData()); calAttendee->value = g_strconcat("MAILTO:", attendee.emailAddress().toUtf8().constData(), NULL); switch(attendee.participationRole()) { case QOrganizerEventAttendee::RoleRequiredParticipant: calAttendee->role = ICAL_ROLE_REQPARTICIPANT; break; case QOrganizerEventAttendee::RoleOptionalParticipant: calAttendee->role = ICAL_ROLE_OPTPARTICIPANT; break; case QOrganizerEventAttendee::RoleChairperson: calAttendee->role = ICAL_ROLE_CHAIR; break; default: calAttendee->role = ICAL_ROLE_NONE; } switch(attendee.participationStatus()) { case QOrganizerEventAttendee::StatusAccepted: calAttendee->status = ICAL_PARTSTAT_ACCEPTED; break; case QOrganizerEventAttendee::StatusDeclined: calAttendee->status = ICAL_PARTSTAT_DECLINED; break; case QOrganizerEventAttendee::StatusTentative: calAttendee->status = ICAL_PARTSTAT_TENTATIVE; break; case QOrganizerEventAttendee::StatusDelegated: calAttendee->status = ICAL_PARTSTAT_DELEGATED; break; case QOrganizerEventAttendee::StatusInProcess: calAttendee->status = ICAL_PARTSTAT_INPROCESS; break; case QOrganizerEventAttendee::StatusCompleted: calAttendee->status = ICAL_PARTSTAT_COMPLETED; break; case QOrganizerEventAttendee::StatusUnknown: default: calAttendee->status = ICAL_PARTSTAT_NONE; break; } attendeeList = g_slist_append(attendeeList, calAttendee); } e_cal_component_set_attendee_list(comp, attendeeList); } bool QOrganizerEDSEngine::hasRecurrence(ECalComponent *comp) { char *rid = e_cal_component_get_recurid_as_string(comp); bool result = (rid && strcmp(rid, "0")); if (rid) { free(rid); } return result; } void QOrganizerEDSEngine::parseId(ECalComponent *comp, QOrganizerItem *item, QOrganizerEDSCollectionEngineId *edsCollectionId) { ECalComponentId *id = e_cal_component_get_id(comp); QOrganizerEDSEngineId *edsParentId = 0; QOrganizerEDSEngineId *edsId = QOrganizerEDSEngineId::fromComponentId(edsCollectionId->m_collectionId, id, &edsParentId); item->setId(QOrganizerItemId(edsId)); item->setGuid(QString::fromUtf8(id->uid)); if (edsParentId) { QOrganizerItemParent itemParent = item->detail(QOrganizerItemDetail::TypeParent); itemParent.setParentId(QOrganizerItemId(edsParentId)); item->saveDetail(&itemParent); } QOrganizerCollectionId cId = QOrganizerCollectionId(edsCollectionId); item->setCollectionId(cId); e_cal_component_free_id(id); } ECalComponent *QOrganizerEDSEngine::createDefaultComponent(ECalClient *client, icalcomponent_kind iKind, ECalComponentVType eType) { ECalComponent *comp; icalcomponent *icalcomp = 0; if (client && !e_cal_client_get_default_object_sync(client, &icalcomp, NULL, NULL)) { icalcomp = icalcomponent_new(iKind); } comp = e_cal_component_new(); if (icalcomp && !e_cal_component_set_icalcomponent(comp, icalcomp)) { icalcomponent_free(icalcomp); } e_cal_component_set_new_vtype(comp, eType); return comp; } ECalComponent *QOrganizerEDSEngine::parseEventItem(ECalClient *client, const QOrganizerItem &item) { ECalComponent *comp = createDefaultComponent(client, ICAL_VEVENT_COMPONENT, E_CAL_COMPONENT_EVENT); parseStartTime(item, comp); parseEndTime(item, comp); parseRecurrence(item, comp); parsePriority(item, comp); parseLocation(item, comp); return comp; } ECalComponent *QOrganizerEDSEngine::parseTodoItem(ECalClient *client, const QOrganizerItem &item) { ECalComponent *comp = createDefaultComponent(client, ICAL_VTODO_COMPONENT, E_CAL_COMPONENT_TODO); parseTodoStartTime(item, comp); parseDueDate(item, comp); parseRecurrence(item, comp); parsePriority(item, comp); parseProgress(item, comp); parseStatus(item, comp); return comp; } ECalComponent *QOrganizerEDSEngine::parseJournalItem(ECalClient *client, const QOrganizerItem &item) { ECalComponent *comp = createDefaultComponent(client, ICAL_VJOURNAL_COMPONENT, E_CAL_COMPONENT_JOURNAL); QOrganizerJournalTime jtime = item.detail(QOrganizerItemDetail::TypeJournalTime); if (!jtime.isEmpty()) { QByteArray tzId; struct icaltimetype ict = fromQDateTime(jtime.entryDateTime(), false, &tzId); ECalComponentDateTime dt; dt.tzid = tzId.isEmpty() ? NULL : tzId.constData(); dt.value = &ict; e_cal_component_set_dtstart(comp, &dt); } return comp; } void QOrganizerEDSEngine::parseSummary(const QOrganizerItem &item, ECalComponent *comp) { //summary if (!item.displayLabel().isEmpty()) { ECalComponentText txt; QByteArray str = item.displayLabel().toUtf8(); txt.altrep = 0; txt.value = str.constData(); e_cal_component_set_summary(comp, &txt); } } void QOrganizerEDSEngine::parseDescription(const QOrganizerItem &item, ECalComponent *comp) { //description if (!item.description().isEmpty()) { GSList *descriptions = 0; QList descList; Q_FOREACH(const QString &desc, item.description().split("\n")) { QByteArray str = desc.toUtf8(); ECalComponentText *txt = g_new0(ECalComponentText, 1); txt->value = str.constData(); descriptions = g_slist_append(descriptions, txt); // keep str alive until the property gets updated descList << str; } e_cal_component_set_description_list(comp, descriptions); e_cal_component_free_text_list(descriptions); } } void QOrganizerEDSEngine::parseComments(const QOrganizerItem &item, ECalComponent *comp) { //comments GSList *comments = 0; QList commentList; Q_FOREACH(const QString &comment, item.comments()) { QByteArray str = comment.toUtf8(); ECalComponentText *txt = g_new0(ECalComponentText, 1); txt->value = str.constData(); comments = g_slist_append(comments, txt); // keep str alive until the property gets updated commentList << str; } if (comments) { e_cal_component_set_comment_list(comp, comments); e_cal_component_free_text_list(comments); } } void QOrganizerEDSEngine::parseTags(const QOrganizerItem &item, ECalComponent *comp) { //tags GSList *categories = 0; QList tagList; Q_FOREACH(const QString &tag, item.tags()) { QByteArray str = tag.toUtf8(); ECalComponentText *txt = g_new0(ECalComponentText, 1); txt->value = str.constData(); categories = g_slist_append(categories, txt); // keep str alive until the property gets updated tagList << str; } if (categories) { e_cal_component_set_categories_list(comp, categories); e_cal_component_free_text_list(categories); } } void QOrganizerEDSEngine::encodeAttachment(const QUrl &url, ECalComponentAlarm *alarm) { icalattach *attach = icalattach_new_from_url(url.toString().toUtf8()); e_cal_component_alarm_set_attach(alarm, attach); icalattach_unref(attach); } void QOrganizerEDSEngine::parseVisualReminderAttachment(const QOrganizerItemDetail &detail, ECalComponentAlarm *alarm) { ECalComponentText txt; QByteArray str = detail.value(QOrganizerItemVisualReminder::FieldMessage).toString().toUtf8(); txt.altrep = 0; txt.value = str.constData(); e_cal_component_alarm_set_description(alarm, &txt); encodeAttachment(detail.value(QOrganizerItemVisualReminder::FieldDataUrl).toUrl(), alarm); } void QOrganizerEDSEngine::parseAudibleReminderAttachment(const QOrganizerItemDetail &detail, ECalComponentAlarm *alarm) { encodeAttachment(detail.value(QOrganizerItemAudibleReminder::FieldDataUrl).toUrl(), alarm); } void QOrganizerEDSEngine::parseReminders(const QOrganizerItem &item, ECalComponent *comp) { //reminders QList reminders = item.details(QOrganizerItemDetail::TypeAudibleReminder); reminders += item.details(QOrganizerItemDetail::TypeVisualReminder); Q_FOREACH(const QOrganizerItemDetail &detail, reminders) { const QOrganizerItemReminder *reminder = static_cast(&detail); ECalComponentAlarm *alarm = e_cal_component_alarm_new(); switch(reminder->type()) { case QOrganizerItemReminder::TypeVisualReminder: e_cal_component_alarm_set_action(alarm, E_CAL_COMPONENT_ALARM_DISPLAY); parseVisualReminderAttachment(detail, alarm); break; case QOrganizerItemReminder::TypeAudibleReminder: default: // use audio as fallback e_cal_component_alarm_set_action(alarm, E_CAL_COMPONENT_ALARM_AUDIO); parseAudibleReminderAttachment(detail, alarm); break; } if (reminder->secondsBeforeStart() > 0) { ECalComponentAlarmTrigger trigger; trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; trigger.u.rel_duration = icaldurationtype_from_int(- reminder->secondsBeforeStart()); e_cal_component_alarm_set_trigger(alarm, trigger); } ECalComponentAlarmRepeat aRepeat; // TODO: check if this is really necessary aRepeat.repetitions = reminder->repetitionCount(); //qMax(reminder->repetitionCount(), 1); aRepeat.duration = icaldurationtype_from_int(reminder->repetitionDelay()); e_cal_component_alarm_set_repeat(alarm, aRepeat); e_cal_component_add_alarm(comp, alarm); e_cal_component_alarm_free(alarm); } } GSList *QOrganizerEDSEngine::parseItems(ECalClient *client, QList items, bool *hasRecurrence) { GSList *comps = 0; Q_FOREACH(const QOrganizerItem &item, items) { ECalComponent *comp = 0; *hasRecurrence = ((item.type() == QOrganizerItemType::TypeTodoOccurrence) || (item.type() == QOrganizerItemType::TypeEventOccurrence)); switch(item.type()) { case QOrganizerItemType::TypeEvent: case QOrganizerItemType::TypeEventOccurrence: comp = parseEventItem(client, item); break; case QOrganizerItemType::TypeTodo: case QOrganizerItemType::TypeTodoOccurrence: comp = parseTodoItem(client, item); break; case QOrganizerItemType::TypeJournal: comp = parseJournalItem(client, item); break; case QOrganizerItemType::TypeNote: qWarning() << "Component TypeNote not supported;"; case QOrganizerItemType::TypeUndefined: continue; } parseId(item, comp); parseSummary(item, comp); parseDescription(item, comp); parseComments(item, comp); parseTags(item, comp); parseReminders(item, comp); parseAttendeeList(item, comp); if (!item.id().isNull()) { e_cal_component_commit_sequence(comp); } else { e_cal_component_abort_sequence(comp); } comps = g_slist_append(comps, icalcomponent_new_clone(e_cal_component_get_icalcomponent(comp))); g_object_unref(comp); } return comps; } void QOrganizerEDSEngine::parseId(const QOrganizerItem &item, ECalComponent *comp) { QOrganizerItemId itemId = item.id(); if (!itemId.isNull()) { QString rId; QString cId = QOrganizerEDSEngineId::toComponentId(itemId, &rId); e_cal_component_set_uid(comp, cId.toUtf8().data()); if (!rId.isEmpty()) { ECalComponentRange *recur_id; struct icaltimetype tt = icaltime_from_string(rId.toUtf8().data()); recur_id = g_new0 (ECalComponentRange, 1); recur_id->type = E_CAL_COMPONENT_RANGE_SINGLE; recur_id->datetime.value = &tt; e_cal_component_set_recurid(comp, recur_id); g_free (recur_id); } } } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-saverequestdata.cpp0000644000015301777760000001034412323305673030475 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-saverequestdata.h" #include "qorganizer-eds-enginedata.h" #include #include #define UPDATE_MODE_PROPRETY "update-mode" using namespace QtOrganizer; SaveRequestData::SaveRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req) : RequestData(engine, req) { // map items by collection Q_FOREACH(const QOrganizerItem &i, request()->items()) { QString collectionId = i.collectionId().toString(); if (collectionId == QStringLiteral("qtorganizer:::")) { collectionId = QStringLiteral(""); } QList li = m_items[collectionId]; li << i; m_items.insert(collectionId, li); } } SaveRequestData::~SaveRequestData() { } void SaveRequestData::finish(QtOrganizer::QOrganizerManager::Error error) { QOrganizerManagerEngine::updateItemSaveRequest(request(), m_result, error, m_erros, QOrganizerAbstractRequest::FinishedState); Q_FOREACH(const QOrganizerItem &item, m_result) { m_changeSet.insertAddedItem(item.id()); } emitChangeset(&m_changeSet); } void SaveRequestData::appendResults(QList result) { m_result += result; } QString SaveRequestData::nextCollection() { if (m_items.isEmpty()) { m_currentCollection = QString(QString::null); m_currentItems.clear(); } else { m_currentCollection = m_items.keys().first(); m_currentItems = m_items.take(m_currentCollection); } m_workingItems.clear(); return m_currentCollection; } QString SaveRequestData::currentCollection() const { return m_currentCollection; } QList SaveRequestData::takeItemsToCreate() { QList result; Q_FOREACH(const QOrganizerItem &i, m_currentItems) { if (i.id().isNull()) { result << i; m_currentItems.removeAll(i); } } return result; } QList SaveRequestData::takeItemsToUpdate() { QList result; Q_FOREACH(const QOrganizerItem &i, m_currentItems) { if (!i.id().isNull()) { result << i; m_currentItems.removeAll(i); } } return result; } bool SaveRequestData::end() const { return m_items.isEmpty(); } void SaveRequestData::appendResult(const QOrganizerItem &item, QOrganizerManager::Error error) { if (error != QOrganizerManager::NoError) { int index = request()->items().indexOf(item); if (index != -1) { m_erros.insert(index, error); } } else { m_result << item; } } void SaveRequestData::setWorkingItems(QList items) { m_workingItems = items; } QList SaveRequestData::workingItems() const { return m_workingItems; } int SaveRequestData::updateMode() const { // due the lack of API we will use the QObject proprety "update-mode" to allow specify wich kind of // update the developer want QOrganizerItemSaveRequest *req = request(); QVariant updateMode = req->property(UPDATE_MODE_PROPRETY); if (updateMode.isValid()) { return updateMode.toInt(); } else { return -1; } } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-engineid.cpp0000644000015301777760000001167312323305647027065 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-engineid.h" #include #include using namespace QtOrganizer; QOrganizerEDSEngineId::QOrganizerEDSEngineId() : QOrganizerItemEngineId() { } QOrganizerEDSEngineId::QOrganizerEDSEngineId(const QString &collectionId, const QString &id) : QOrganizerItemEngineId() { if (!collectionId.isNull() && !collectionId.isEmpty()) { m_collectionId = collectionId.contains(":") ? collectionId.mid(collectionId.lastIndexOf(":")+1) : collectionId; } if (!id.isNull() && !id.isEmpty()) { m_itemId = id.contains(":") ? id.mid(id.lastIndexOf(":")+1) : id; } } QOrganizerEDSEngineId::~QOrganizerEDSEngineId() { } QOrganizerEDSEngineId::QOrganizerEDSEngineId(const QOrganizerEDSEngineId& other) : QOrganizerItemEngineId(), m_collectionId(other.m_collectionId), m_itemId(other.m_itemId) { } QOrganizerEDSEngineId::QOrganizerEDSEngineId(const QString& idString) : QOrganizerItemEngineId() { QString edsIdPart = idString.contains(":") ? idString.mid(idString.lastIndexOf(":")+1) : idString; QStringList idParts = edsIdPart.split("/"); Q_ASSERT(idParts.count() == 2); m_collectionId = idParts.first(); m_itemId = idParts.last(); } bool QOrganizerEDSEngineId::isEqualTo(const QOrganizerItemEngineId* other) const { // note: we don't need to check the collectionId because itemIds in the memory // engine are unique regardless of which collection the item is in; also, we // don't need to check the managerUri, because this function is not called if // the managerUris don't match. if (m_itemId != static_cast(other)->m_itemId) return false; return true; } bool QOrganizerEDSEngineId::isLessThan(const QOrganizerItemEngineId* other) const { // order by collection, then by item in collection. const QOrganizerEDSEngineId* otherPtr = static_cast(other); if (m_collectionId < otherPtr->m_collectionId) return true; if (m_collectionId == otherPtr->m_collectionId) return (m_itemId < otherPtr->m_itemId); return false; } QString QOrganizerEDSEngineId::managerUri() const { return managerUriStatic(); } QString QOrganizerEDSEngineId::toString() const { return QString("%1/%2").arg(m_collectionId).arg(m_itemId); } QOrganizerItemEngineId* QOrganizerEDSEngineId::clone() const { return new QOrganizerEDSEngineId(m_collectionId, m_itemId); } uint QOrganizerEDSEngineId::hash() const { return qHash(m_itemId); } #ifndef QT_NO_DEBUG_STREAM QDebug& QOrganizerEDSEngineId::debugStreamOut(QDebug& dbg) const { dbg.nospace() << "QOrganizerEDSEngineId(" << managerNameStatic() << ", " << m_collectionId << ", " << m_itemId << ")"; return dbg.maybeSpace(); } #endif QString QOrganizerEDSEngineId::managerNameStatic() { return QStringLiteral("eds"); } QString QOrganizerEDSEngineId::managerUriStatic() { return QStringLiteral("qtorganizer:eds:"); } QString QOrganizerEDSEngineId::toComponentId(const QtOrganizer::QOrganizerItemId &itemId, QString *rid) { return toComponentId(itemId.toString(), rid); } QString QOrganizerEDSEngineId::toComponentId(const QString &itemId, QString *rid) { QStringList ids = itemId.split("/").last().split("#"); if (ids.size() == 2) { *rid = ids[1]; } return ids[0]; } ECalComponentId *QOrganizerEDSEngineId::toComponentIdObject(const QOrganizerItemId &itemId) { QString rId; QString cId = toComponentId(itemId, &rId); ECalComponentId *id = g_new0(ECalComponentId, 1); id->uid = g_strdup(cId.toUtf8().data()); if (rId.isEmpty()) { id->rid = NULL; } else { id->rid = g_strdup(rId.toUtf8().data()); } return id; } QOrganizerEDSEngineId *QOrganizerEDSEngineId::fromComponentId(const QString &cId, ECalComponentId *id, QOrganizerEDSEngineId **parentId) { QString iId = QString::fromUtf8(id->uid); QString rId = QString::fromUtf8(id->rid); if(!rId.isEmpty()) { *parentId = new QOrganizerEDSEngineId(cId, iId); iId += "#" + rId; } return new QOrganizerEDSEngineId(cId, iId); } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-removecollectionrequestdata.cpp0000644000015301777760000000576212323305647033121 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-removecollectionrequestdata.h" #include "qorganizer-eds-engineid.h" #include "qorganizer-eds-enginedata.h" #include "qorganizer-eds-source-registry.h" #include #include #include using namespace QtOrganizer; RemoveCollectionRequestData::RemoveCollectionRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req) : RequestData(engine, req), m_currentCollection(0), m_remoteDeletable(false) { m_pendingCollections = request()->collectionIds(); } RemoveCollectionRequestData::~RemoveCollectionRequestData() { } void RemoveCollectionRequestData::finish(QtOrganizer::QOrganizerManager::Error error) { QOrganizerManagerEngine::updateCollectionRemoveRequest(request(), error, m_errorMap, QOrganizerAbstractRequest::FinishedState); QList removedIds = m_pendingCollections; Q_FOREACH(int index, m_errorMap.keys()) { removedIds.removeAt(index); } QOrganizerCollectionChangeSet cs; cs.insertRemovedCollections(removedIds); emitChangeset(&cs); } void RemoveCollectionRequestData::commit(QtOrganizer::QOrganizerManager::Error error) { if (error != QOrganizerManager::NoError) { m_errorMap.insert(m_currentCollection, error); } else { QOrganizerCollectionId cId = m_pendingCollections.at(m_currentCollection); parent()->d->m_sourceRegistry->remove(cId.toString()); } m_currentCollection++; m_remoteDeletable = false; } bool RemoveCollectionRequestData::remoteDeletable() const { return m_remoteDeletable; } void RemoveCollectionRequestData::setRemoteDeletable(bool deletable) { m_remoteDeletable = deletable; } ESource *RemoveCollectionRequestData::begin() { if (m_pendingCollections.count() > m_currentCollection) { QOrganizerCollectionId cId = m_pendingCollections.at(m_currentCollection); return parent()->d->m_sourceRegistry->source(cId.toString()); } else { return 0; } } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-fetchocurrencedata.h0000644000015301777760000000242612323305647030575 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_FETCHOCURRENCEDATA_H__ #define __QORGANIZER_EDS_FETCHOCURRENCEDATA_H__ #include "qorganizer-eds-requestdata.h" #include class FetchOcurrenceData : public RequestData { public: FetchOcurrenceData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); ~FetchOcurrenceData(); time_t startDate() const; time_t endDate() const; void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); void appendResult(icalcomponent *comp); private: GSList *m_components; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-fetchrequestdata.cpp0000644000015301777760000001071712323305673030634 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-fetchrequestdata.h" #include #include #include using namespace QtOrganizer; FetchRequestData::FetchRequestData(QOrganizerEDSEngine *engine, QStringList collections, QOrganizerAbstractRequest *req) : RequestData(engine, req), m_components(0), m_collections(collections) { } FetchRequestData::~FetchRequestData() { if (m_components) { g_slist_free_full(m_components, (GDestroyNotify)icalcomponent_free); m_components = 0; } } QString FetchRequestData::nextCollection() { if (m_components) { appendResults(parent()->parseEvents(m_current, m_components, true)); g_slist_free_full(m_components, (GDestroyNotify)icalcomponent_free); m_components = 0; } m_current = ""; setClient(0); if (m_collections.size()) { m_current = m_collections.takeFirst(); return m_current; } else { return QString(); } } QString FetchRequestData::collection() const { return m_current; } time_t FetchRequestData::startDate() const { QDateTime startDate = request()->startDate(); if (!startDate.isValid()) { QDate currentDate = QDate::currentDate(); startDate.setTime(QTime(0, 0, 0)); startDate.setDate(QDate(currentDate.year(), 1, 1)); qWarning() << "Start date is invalid using " << startDate; } return startDate.toTime_t(); } time_t FetchRequestData::endDate() const { QDateTime endDate = request()->endDate(); if (!endDate.isValid()) { QDate currentDate = QDate::currentDate(); endDate.setTime(QTime(0, 0, 0)); endDate.setDate(QDate(currentDate.year()+1, 1, 1)); qWarning() << "End date is invalid using " << endDate; } return endDate.toTime_t(); } bool FetchRequestData::hasDateInterval() const { QDateTime endDate = request()->endDate(); QDateTime startDate = request()->startDate(); return (endDate.isValid() && startDate.isValid()); } void FetchRequestData::finish(QOrganizerManager::Error error) { QOrganizerManagerEngine::updateItemFetchRequest(request(), m_results, error, QOrganizerAbstractRequest::FinishedState); // TODO: emit changeset??? } void FetchRequestData::appendResult(icalcomponent *comp) { m_components = g_slist_append(m_components, comp); } int FetchRequestData::appendResults(QList results) { int count = 0; QOrganizerItemFetchRequest *req = request(); Q_FOREACH(const QOrganizerItem &item, results) { if (QOrganizerManagerEngine::testFilter(req->filter(), item)) { m_results << item; count++; } } return count; } QString FetchRequestData::dateFilter() { QDateTime startDate = request()->startDate(); QDateTime endDate = request()->endDate(); if (!startDate.isValid() || !endDate.isValid()) { return QStringLiteral("#t"); // match all } gchar *startDateStr = isodate_from_time_t(startDate.toTime_t()); gchar *endDateStr = isodate_from_time_t(endDate.toTime_t()); QString query = QString("(occur-in-time-range? " "(make-time \"%1\") (make-time \"%2\"))") .arg(startDateStr) .arg(endDateStr); g_free(startDateStr); g_free(endDateStr); return query; } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-factory.h0000644000015301777760000000306212323305647026410 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of contact-service-app. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_FACTORY_H__ #define __QORGANIZER_EDS_FACTORY_H__ #include #include #include #include class QOrganizerEDSFactory : public QtOrganizer::QOrganizerManagerEngineFactory { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QOrganizerManagerEngineFactoryInterface" FILE "eds.json") public: QtOrganizer::QOrganizerManagerEngine* engine(const QMap& parameters, QtOrganizer::QOrganizerManager::Error*); QtOrganizer::QOrganizerItemEngineId* createItemEngineId(const QMap& parameters, const QString& idString) const; QtOrganizer::QOrganizerCollectionEngineId* createCollectionEngineId(const QMap& parameters, const QString& idString) const; QString managerName() const; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-requestdata.cpp0000644000015301777760000000460012323305647027615 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-requestdata.h" #include #include using namespace QtOrganizer; RequestData::RequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req) : m_parent(engine), m_req(req), m_client(0) { QOrganizerManagerEngine::updateRequestState(req, QOrganizerAbstractRequest::ActiveState); m_cancellable = g_cancellable_new(); m_parent->m_runningRequests.insert(req, this); } RequestData::~RequestData() { Q_ASSERT(m_req->state() != QOrganizerAbstractRequest::ActiveState); if (m_cancellable) { g_clear_object(&m_cancellable); } if (m_client) { g_clear_object(&m_client); } m_parent->m_runningRequests.remove(m_req); } GCancellable* RequestData::cancellable() const { g_cancellable_reset(m_cancellable); g_object_ref(m_cancellable); return m_cancellable; } bool RequestData::isLive() const { return !m_req.isNull(); } ECalClient *RequestData::client() const { return E_CAL_CLIENT(m_client); } QOrganizerEDSEngine *RequestData::parent() const { return m_parent; } void RequestData::cancel() { if (m_cancellable) { g_cancellable_cancel(m_cancellable); m_parent->waitForRequestFinished(m_req, 0); g_object_unref(m_cancellable); m_cancellable = 0; } QOrganizerManagerEngine::updateRequestState(m_req, QOrganizerAbstractRequest::CanceledState); } void RequestData::setClient(EClient *client) { if (m_client == client) { return; } if (m_client) { g_clear_object(&m_client); } if (client) { m_client = client; g_object_ref(m_client); } } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-fetchrequestdata.h0000644000015301777760000000313612323305647030277 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_FETCHREQUESTDATA_H__ #define __QORGANIZER_EDS_FETCHREQUESTDATA_H__ #include "qorganizer-eds-requestdata.h" #include class FetchRequestData : public RequestData { public: FetchRequestData(QOrganizerEDSEngine *engine, QStringList collections, QtOrganizer::QOrganizerAbstractRequest *req); ~FetchRequestData(); QString nextCollection(); QString collection() const; time_t startDate() const; time_t endDate() const; bool hasDateInterval() const; void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); void appendResult(icalcomponent *comp); int appendResults(QList results); QString dateFilter(); private: GSList *m_components; QStringList m_collections; QString m_current; QList m_results; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-savecollectionrequestdata.h0000644000015301777760000000374012323305647032221 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_SAVECOLLECTIONREQUESTDATA_H__ #define __QORGANIZER_EDS_SAVECOLLECTIONREQUESTDATA_H__ #include "qorganizer-eds-requestdata.h" class SaveCollectionRequestData : public RequestData { public: SaveCollectionRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); ~SaveCollectionRequestData(); void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); bool isNew(int index) const; bool prepareToCreate(); bool prepareToUpdate(); void setRegistry(ESourceRegistry *registry); ESourceRegistry *registry() const; GList *sourcesToCreate() const; void commitSourceCreated(); void commitSourceUpdated(ESource *source, QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); ESource *nextSourceToUpdate(); private: GList *m_currentSources; ESourceRegistry *m_registry; QMap m_errorMap; QMap m_results; QMap m_sources; QMap m_sourcesToCreate; QMap m_sourcesToUpdate; QtOrganizer::QOrganizerCollectionChangeSet m_changeSet; void parseCollections(); }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-source-registry.h0000644000015301777760000000702012323305647030105 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_SOURCEREGISTRY_H__ #define __QORGANIZER_EDS_SOURCEREGISTRY_H__ #include #include #include #include #include "qorganizer-eds-collection-engineid.h" #define COLLECTION_CALLENDAR_TYPE_METADATA "collection-type" #define COLLECTION_SELECTED_METADATA "collection-selected" class SourceRegistry : public QObject { Q_OBJECT public: SourceRegistry(QObject *parent=0); ~SourceRegistry(); ESourceRegistry *object() const; void load(); QtOrganizer::QOrganizerCollection defaultCollection() const; QtOrganizer::QOrganizerCollection collection(const QString &collectionId) const; QList collections() const; QStringList collectionsIds() const; QList collectionsEngineIds() const; ESource *source(const QString &collectionId) const; QOrganizerEDSCollectionEngineId* collectionEngineId(const QString &collectionId) const; QtOrganizer::QOrganizerCollection collection(ESource *source) const; QtOrganizer::QOrganizerCollection insert(ESource *source); void remove(ESource *source); void remove(const QString &collectionId); EClient *client(const QString &collectionId); void clear(); static QtOrganizer::QOrganizerCollection parseSource(ESource *source, QOrganizerEDSCollectionEngineId **edsId); Q_SIGNALS: void sourceAdded(const QString &collectionId); void sourceRemoved(const QString &collectionId); void sourceUpdated(const QString &collectionId); private: ESourceRegistry *m_sourceRegistry; QtOrganizer::QOrganizerCollection m_defaultCollection; QMap m_clients; QMap m_sources; QMap m_collections; QMap m_collectionsMap; // handler id int m_sourceAddedId; int m_sourceRemovedId; int m_sourceChangedId; int m_sourceEnabledId; int m_sourceDisabledId; QString findCollection(ESource *source) const; QtOrganizer::QOrganizerCollection registerSource(ESource *source); static void updateCollection(QtOrganizer::QOrganizerCollection *collection, ESource *source); // glib callback static void onSourceAdded(ESourceRegistry *registry, ESource *source, SourceRegistry *self); static void onSourceChanged(ESourceRegistry *registry, ESource *source, SourceRegistry *self); static void onSourceRemoved(ESourceRegistry *registry, ESource *source, SourceRegistry *self); }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-viewwatcher.cpp0000644000015301777760000001347012323305711027620 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-enginedata.h" #include "qorganizer-eds-viewwatcher.h" #include "qorganizer-eds-fetchrequestdata.h" #include "qorganizer-eds-engineid.h" #include #include #include #include #include using namespace QtOrganizer; ViewWatcher::ViewWatcher(const QString &collectionId, QOrganizerEDSEngineData *data, EClient *client) : m_collectionId(collectionId), m_engineData(data), m_eClient(E_CAL_CLIENT(client)), m_eView(0), m_eventLoop(0) { g_object_ref(m_eClient); m_cancellable = g_cancellable_new(); e_cal_client_get_view(m_eClient, QStringLiteral("#t").toUtf8().constData(), // match all, m_cancellable, (GAsyncReadyCallback) ViewWatcher::viewReady, this); wait(); } ViewWatcher::~ViewWatcher() { clear(); } void ViewWatcher::viewReady(GObject *sourceObject, GAsyncResult *res, ViewWatcher *self) { Q_UNUSED(sourceObject); GError *gError = 0; ECalClientView *view = 0; e_cal_client_get_view_finish(self->m_eClient, res, &view, &gError); if (gError) { qWarning() << "Fail to open view (" << self->m_collectionId << "):" << gError->message; g_error_free(gError); gError = 0; } else { self->m_eView = view; g_signal_connect(view, "objects-added", (GCallback) ViewWatcher::onObjectsAdded, self); g_signal_connect(view, "objects-removed", (GCallback) ViewWatcher::onObjectsRemoved, self); g_signal_connect(view, "objects-modified", (GCallback) ViewWatcher::onObjectsModified, self); e_cal_client_view_set_flags(view, E_CAL_CLIENT_VIEW_FLAGS_NONE, NULL); e_cal_client_view_start(view, &gError); if (gError) { qWarning() << "Fail to start view (" << self->m_collectionId << "):" << gError->message; g_error_free(gError); gError = 0; } } g_clear_object(&self->m_cancellable); if (self->m_eventLoop) { self->m_eventLoop->quit(); } } void ViewWatcher::clear() { if (m_cancellable) { g_cancellable_cancel(m_cancellable); wait(); Q_ASSERT(m_cancellable == 0); } if (m_eView) { e_cal_client_view_stop(m_eView, 0); QCoreApplication::processEvents(); g_clear_object(&m_eView); } if (m_eClient) { g_clear_object(&m_eClient); QCoreApplication::processEvents(); } } void ViewWatcher::wait() { if (m_cancellable) { QEventLoop eventLoop; m_eventLoop = &eventLoop; eventLoop.exec(); m_eventLoop = 0; } } QList ViewWatcher::parseItemIds(GSList *objects) { QList result; for (GSList *l = objects; l; l = l->next) { const gchar *uid = 0; icalcomponent *icalcomp = static_cast(l->data); icalproperty *prop = icalcomponent_get_first_property(icalcomp, ICAL_UID_PROPERTY); if (prop) { uid = icalproperty_get_uid(prop); } else { qWarning() << "Fail to parse component ID"; } QOrganizerEDSEngineId *itemId = new QOrganizerEDSEngineId(m_collectionId, QString::fromUtf8(uid)); result << QOrganizerItemId(itemId); } return result; } void ViewWatcher::onObjectsAdded(ECalClientView *view, GSList *objects, ViewWatcher *self) { Q_UNUSED(view); QOrganizerItemChangeSet changeSet; changeSet.insertAddedItems(self->parseItemIds(objects)); self->m_engineData->emitSharedSignals(&changeSet); } void ViewWatcher::onObjectsRemoved(ECalClientView *view, GSList *objects, ViewWatcher *self) { Q_UNUSED(view); QOrganizerItemChangeSet changeSet; for (GSList *l = objects; l; l = l->next) { ECalComponentId *id = static_cast(l->data); QOrganizerEDSEngineId *itemId = new QOrganizerEDSEngineId(self->m_collectionId, QString::fromUtf8(id->uid)); changeSet.insertRemovedItem(QOrganizerItemId(itemId)); } self->m_engineData->emitSharedSignals(&changeSet); } void ViewWatcher::onObjectsModified(ECalClientView *view, GSList *objects, ViewWatcher *self) { Q_UNUSED(view); QOrganizerItemChangeSet changeSet; changeSet.insertChangedItems(self->parseItemIds(objects)); self->m_engineData->emitSharedSignals(&changeSet); } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-removerequestdata.h0000644000015301777760000000343112323305647030501 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_REMOVEQUESTDATA_H__ #define __QORGANIZER_EDS_REMOVEQUESTDATA_H__ #include "qorganizer-eds-requestdata.h" #include class RemoveRequestData : public RequestData { public: RemoveRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); ~RemoveRequestData(); QList pendingCollections() const; QtOrganizer::QOrganizerCollectionId collectionId() const; void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); GSList *compIds() const; QtOrganizer::QOrganizerCollectionId next(); void commit(); virtual void cancel(); private: QSet m_pendingCollections; QList m_pendingItems; bool m_sessionStaterd; GSList *m_currentCompIds; QList m_currentIds; QtOrganizer::QOrganizerCollectionId m_currentCollectionId; void clear(); void reset(); GSList* takeItemsIds(QtOrganizer::QOrganizerCollectionId collectionId); }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-enginedata.cpp0000644000015301777760000000340312323305647027372 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-enginedata.h" #include "qorganizer-eds-viewwatcher.h" #include "qorganizer-eds-source-registry.h" QOrganizerEDSEngineData::QOrganizerEDSEngineData() : QSharedData(), m_sourceRegistry(0) { } QOrganizerEDSEngineData::QOrganizerEDSEngineData(const QOrganizerEDSEngineData& other) : QSharedData(other) { } QOrganizerEDSEngineData::~QOrganizerEDSEngineData() { qDeleteAll(m_viewWatchers); m_viewWatchers.clear(); if (m_sourceRegistry) { delete m_sourceRegistry; m_sourceRegistry = 0; } } ViewWatcher* QOrganizerEDSEngineData::watch(const QString &collectionId) { ViewWatcher *vw = m_viewWatchers[collectionId]; if (!vw) { EClient *client = m_sourceRegistry->client(collectionId); vw = new ViewWatcher(collectionId, this, client); m_viewWatchers.insert(collectionId, vw); g_object_unref(client); } return vw; } void QOrganizerEDSEngineData::unWatch(const QString &collectionId) { ViewWatcher *viewW = m_viewWatchers.take(collectionId); if (viewW) { delete viewW; } } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-collection-engineid.cpp0000644000015301777760000000737612323305647031223 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-collection-engineid.h" #include "qorganizer-eds-engineid.h" #include QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId(ESource *source) : m_esource(source) { g_object_ref(m_esource); m_collectionId = QString::fromUtf8(e_source_get_uid(m_esource)); if (e_source_has_extension(m_esource, E_SOURCE_EXTENSION_CALENDAR)) { m_sourceType = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; } else if (e_source_has_extension(m_esource, E_SOURCE_EXTENSION_TASK_LIST)) { m_sourceType = E_CAL_CLIENT_SOURCE_TYPE_TASKS; } else if (e_source_has_extension(m_esource, E_SOURCE_EXTENSION_MEMO_LIST)) { m_sourceType = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; } else { qWarning() << "Source extension not supported"; Q_ASSERT(false); } } QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId() : QOrganizerCollectionEngineId(), m_esource(0) { } QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId(const QOrganizerEDSCollectionEngineId& other) : QOrganizerCollectionEngineId(), m_collectionId(other.m_collectionId), m_esource(other.m_esource), m_sourceType(other.m_sourceType) { if (m_esource) { g_object_ref(m_esource); } } QOrganizerEDSCollectionEngineId::QOrganizerEDSCollectionEngineId(const QString& idString) : QOrganizerCollectionEngineId(), m_esource(0) { // separate engine id part, if full id given m_collectionId = idString.contains(":") ? idString.mid(idString.lastIndexOf(":")+1) : idString; } QOrganizerEDSCollectionEngineId::~QOrganizerEDSCollectionEngineId() { if (m_esource) { g_clear_object(&m_esource); } } bool QOrganizerEDSCollectionEngineId::isEqualTo(const QOrganizerCollectionEngineId* other) const { // note: we don't need to check the managerUri because this function is not called // if the managerUris are different. if (m_collectionId != static_cast(other)->m_collectionId) return false; return true; } bool QOrganizerEDSCollectionEngineId::isLessThan(const QOrganizerCollectionEngineId* other) const { // order by collection, then by item in collection. const QOrganizerEDSCollectionEngineId* otherPtr = static_cast(other); if (m_collectionId < otherPtr->m_collectionId) return true; return false; } QString QOrganizerEDSCollectionEngineId::managerUri() const { return QOrganizerEDSEngineId::managerUriStatic(); } QString QOrganizerEDSCollectionEngineId::toString() const { return m_collectionId; } QOrganizerEDSCollectionEngineId* QOrganizerEDSCollectionEngineId::clone() const { return new QOrganizerEDSCollectionEngineId(m_esource); } uint QOrganizerEDSCollectionEngineId::hash() const { return qHash(m_collectionId); } #ifndef QT_NO_DEBUG_STREAM QDebug& QOrganizerEDSCollectionEngineId::debugStreamOut(QDebug& dbg) const { dbg.nospace() << "QOrganizerEDSCollectionEngineId(" << managerUri() << "," << m_collectionId << ")"; return dbg.maybeSpace(); } #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-collection-engineid.h0000644000015301777760000000355112323305647030657 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_COLLECTION_ENGINEID_H__ #define __QORGANIZER_EDS_COLLECTION_ENGINEID_H__ #include #include #include class QOrganizerEDSCollectionEngineId : public QtOrganizer::QOrganizerCollectionEngineId { public: QOrganizerEDSCollectionEngineId(); QOrganizerEDSCollectionEngineId(const QOrganizerEDSCollectionEngineId& other); QOrganizerEDSCollectionEngineId(const QString& idString); QOrganizerEDSCollectionEngineId(ESource *source); ~QOrganizerEDSCollectionEngineId(); bool isEqualTo(const QtOrganizer::QOrganizerCollectionEngineId* other) const; bool isLessThan(const QtOrganizer::QOrganizerCollectionEngineId* other) const; QString managerUri() const; QOrganizerEDSCollectionEngineId *clone() const; QString toString() const; uint hash() const; #ifndef QT_NO_DEBUG_STREAM QDebug& debugStreamOut(QDebug& dbg) const; #endif private: QString m_collectionId; ESource *m_esource; ECalClientSourceType m_sourceType; friend class SourceRegistry; //friend class ViewWatcher; friend class QOrganizerEDSEngine; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-removebyidrequestdata.cpp0000644000015301777760000001001612323305647031701 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-removebyidrequestdata.h" #include "qorganizer-eds-engineid.h" #include "qorganizer-eds-enginedata.h" #include #include using namespace QtOrganizer; RemoveByIdRequestData::RemoveByIdRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req) : RequestData(engine, req), m_sessionStaterd(0), m_currentCompIds(0) { Q_FOREACH(const QOrganizerItemId &id, request()->itemIds()) { QString strId = id.toString(); QString collectionId; if (strId.contains("/")) { collectionId = strId.split("/").first(); QSet ids = m_pending.value(collectionId); ids << id; m_pending.insert(collectionId, ids); } } } RemoveByIdRequestData::~RemoveByIdRequestData() { } void RemoveByIdRequestData::finish(QtOrganizer::QOrganizerManager::Error error) { QOrganizerManagerEngine::updateItemRemoveByIdRequest(request(), error, QMap(), QOrganizerAbstractRequest::FinishedState); //The signal will be fired by the view watcher. Check ViewWatcher::onObjectsRemoved //emitChangeset(&m_changeSet); } GSList *RemoveByIdRequestData::compIds() const { return m_currentCompIds; } void RemoveByIdRequestData::commit() { Q_ASSERT(m_sessionStaterd); QOrganizerManagerEngine::updateItemRemoveByIdRequest(request(), QtOrganizer::QOrganizerManager::NoError, QMap(), QOrganizerAbstractRequest::ActiveState); reset(); } GSList *RemoveByIdRequestData::parseIds(QSet iids) { GSList *ids = 0; Q_FOREACH(const QOrganizerItemId &iid, iids) { ECalComponentId *id = QOrganizerEDSEngineId::toComponentIdObject(iid); if (id) { ids = g_slist_append(ids, id); } } return ids; } QString RemoveByIdRequestData::next() { Q_ASSERT(!m_sessionStaterd); if (m_pending.count() > 0) { m_sessionStaterd = true; m_currentCollectionId = m_pending.keys().first(); m_currentIds = m_pending[m_currentCollectionId]; m_currentCompIds = parseIds(m_currentIds); m_pending.remove(m_currentCollectionId); return m_currentCollectionId; } return QString(QString::null); } void RemoveByIdRequestData::reset() { m_currentIds.clear(); m_currentCollectionId = QString(QString::null); if (m_currentCompIds) { g_slist_free_full(m_currentCompIds, (GDestroyNotify)e_cal_component_free_id); m_currentCompIds = 0; } m_sessionStaterd = false; } void RemoveByIdRequestData::cancel() { Q_ASSERT(m_sessionStaterd); RequestData::cancel(); clear(); } void RemoveByIdRequestData::clear() { reset(); m_pending.clear(); setClient(0); } QString RemoveByIdRequestData::collectionId() const { return m_currentCollectionId; } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-source-registry.cpp0000644000015301777760000002455612323305711030445 0ustar pbusernogroup00000000000000#include "qorganizer-eds-source-registry.h" #include using namespace QtOrganizer; SourceRegistry::SourceRegistry(QObject *parent) : QObject(parent), m_sourceRegistry(0), m_sourceAddedId(0), m_sourceRemovedId(0), m_sourceChangedId(0), m_sourceEnabledId(0), m_sourceDisabledId(0) { } SourceRegistry::~SourceRegistry() { clear(); if (m_sourceRegistry) { g_signal_handler_disconnect(m_sourceRegistry, m_sourceAddedId); g_signal_handler_disconnect(m_sourceRegistry, m_sourceRemovedId); g_signal_handler_disconnect(m_sourceRegistry, m_sourceChangedId); g_signal_handler_disconnect(m_sourceRegistry, m_sourceEnabledId); g_signal_handler_disconnect(m_sourceRegistry, m_sourceDisabledId); g_clear_object(&m_sourceRegistry); } } ESourceRegistry *SourceRegistry::object() const { return m_sourceRegistry; } void SourceRegistry::load() { if (m_sourceRegistry) { return; } clear(); GError *error = 0; m_sourceRegistry = e_source_registry_new_sync(0, &error); if (error) { qWarning() << "Fail to create sourge registry:" << error->message; g_error_free(error); return; } m_sourceAddedId = g_signal_connect(m_sourceRegistry, "source-added", (GCallback) SourceRegistry::onSourceAdded, this); m_sourceChangedId = g_signal_connect(m_sourceRegistry, "source-changed", (GCallback) SourceRegistry::onSourceChanged, this); m_sourceDisabledId = g_signal_connect(m_sourceRegistry, "source-disabled", (GCallback) SourceRegistry::onSourceRemoved, this); m_sourceEnabledId = g_signal_connect(m_sourceRegistry, "source-enabled", (GCallback) SourceRegistry::onSourceAdded, this); m_sourceRemovedId = g_signal_connect(m_sourceRegistry, "source-removed", (GCallback) SourceRegistry::onSourceRemoved, this); // We use calendar as default source, if you are trying to use other source type // you need to set the item source id manually ESource *defaultCalendarSource = e_source_registry_ref_default_calendar(m_sourceRegistry); GList *sources = e_source_registry_list_sources(m_sourceRegistry, 0); for(int i = 0, iMax = g_list_length(sources); i < iMax; i++) { ESource *source = E_SOURCE(g_list_nth_data(sources, i)); QOrganizerCollection collection = registerSource(source); if (e_source_equal(defaultCalendarSource, source)) { m_defaultCollection = collection; } } g_list_free_full(sources, g_object_unref); if (defaultCalendarSource) { g_object_unref(defaultCalendarSource); } } QtOrganizer::QOrganizerCollection SourceRegistry::defaultCollection() const { return m_defaultCollection; } QOrganizerCollection SourceRegistry::collection(const QString &collectionId) const { return m_collections.value(collectionId); } QList SourceRegistry::collections() const { return m_collections.values(); } QStringList SourceRegistry::collectionsIds() const { return m_collections.keys(); } QList SourceRegistry::collectionsEngineIds() const { return m_collectionsMap.values(); } QOrganizerEDSCollectionEngineId *SourceRegistry::collectionEngineId(const QString &collectionId) const { return m_collectionsMap.value(collectionId, 0); } ESource *SourceRegistry::source(const QString &collectionId) const { return m_sources[collectionId]; } QOrganizerCollection SourceRegistry::collection(ESource *source) const { QString collectionId = findCollection(source); return m_collections[collectionId]; } QOrganizerCollection SourceRegistry::insert(ESource *source) { return registerSource(source); } void SourceRegistry::remove(ESource *source) { QString collectionId = findCollection(source); remove(collectionId); } void SourceRegistry::remove(const QString &collectionId) { if (collectionId.isEmpty()) { return; } QOrganizerCollection collection = m_collections.take(collectionId); if (!collection.id().isNull()) { Q_EMIT sourceRemoved(collectionId); m_collectionsMap.remove(collectionId); g_object_unref(m_sources.take(collectionId)); EClient *client = m_clients.take(collectionId); if (client) { g_object_unref(client); } } } EClient* SourceRegistry::client(const QString &collectionId) { if (collectionId.isEmpty()) { return 0; } EClient *client = m_clients.value(collectionId, 0); if (!client) { QOrganizerEDSCollectionEngineId *eid = m_collectionsMap[collectionId]; if (eid) { GError *gError = 0; client = e_cal_client_connect_sync(eid->m_esource, eid->m_sourceType, 0, &gError); if (gError) { qWarning() << "Fail to connect with client" << gError->message; g_error_free(gError); } else { m_clients.insert(collectionId, client); } } } if (client) { g_object_ref(client); } return client; } void SourceRegistry::clear() { Q_FOREACH(ESource *source, m_sources.values()) { g_object_unref(source); } Q_FOREACH(EClient *client, m_clients.values()) { g_object_unref(client); } m_sources.clear(); m_collections.clear(); m_collectionsMap.clear(); m_clients.clear(); } QString SourceRegistry::findCollection(ESource *source) const { QMap::ConstIterator i = m_sources.constBegin(); while (i != m_sources.constEnd()) { if (e_source_equal(source, i.value())) { return i.key(); } i++; } return QString(); } QOrganizerCollection SourceRegistry::registerSource(ESource *source) { QString collectionId = findCollection(source); if (collectionId.isEmpty()) { bool isEnabled = e_source_get_enabled(source); bool isCalendar = e_source_has_extension(source, E_SOURCE_EXTENSION_CALENDAR); bool isTaskList = e_source_has_extension(source, E_SOURCE_EXTENSION_TASK_LIST); bool isMemoList = e_source_has_extension(source, E_SOURCE_EXTENSION_MEMO_LIST); bool isAlarms = e_source_has_extension(source, E_SOURCE_EXTENSION_ALARMS); if ( isEnabled && (isCalendar || isTaskList || isMemoList || isAlarms)) { QOrganizerEDSCollectionEngineId *edsId = 0; QOrganizerCollection collection = parseSource(source, &edsId); QString collectionId = collection.id().toString(); if (!m_collectionsMap.contains(collectionId)) { m_collections.insert(collectionId, collection); m_collectionsMap.insert(collectionId, edsId); m_sources.insert(collectionId, source); g_object_ref(source); Q_EMIT sourceAdded(collectionId); } else { Q_ASSERT(false); } return collection; } return QOrganizerCollection(); } else { return m_collections.value(collectionId); } } QOrganizerCollection SourceRegistry::parseSource(ESource *source, QOrganizerEDSCollectionEngineId **edsId) { *edsId = new QOrganizerEDSCollectionEngineId(source); QOrganizerCollectionId id(*edsId); QOrganizerCollection collection; collection.setId(id); updateCollection(&collection, source); return collection; } void SourceRegistry::onSourceAdded(ESourceRegistry *registry, ESource *source, SourceRegistry *self) { Q_UNUSED(registry); self->insert(source); } void SourceRegistry::onSourceChanged(ESourceRegistry *registry, ESource *source, SourceRegistry *self) { Q_UNUSED(registry); QString collectionId = self->findCollection(source); if (!collectionId.isEmpty() && self->m_collections.contains(collectionId)) { QOrganizerCollection &collection = self->m_collections[collectionId]; self->updateCollection(&collection, source); Q_EMIT self->sourceUpdated(collectionId); } else { qWarning() << "Source changed not found"; } } void SourceRegistry::onSourceRemoved(ESourceRegistry *registry, ESource *source, SourceRegistry *self) { Q_UNUSED(registry); self->remove(source); } void SourceRegistry::updateCollection(QOrganizerCollection *collection, ESource *source) { //TODO get metadata (color, etc..) collection->setMetaData(QOrganizerCollection::KeyName, QString::fromUtf8(e_source_get_display_name(source))); // name collection->setMetaData(QOrganizerCollection::KeyName, QString::fromUtf8(e_source_get_display_name(source))); // extension ESourceBackend *extCalendar; if (e_source_has_extension(source, E_SOURCE_EXTENSION_TASK_LIST)) { extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_TASK_LIST)); collection->setExtendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA, E_SOURCE_EXTENSION_TASK_LIST); } else if (e_source_has_extension(source, E_SOURCE_EXTENSION_MEMO_LIST)) { extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_MEMO_LIST)); collection->setExtendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA, E_SOURCE_EXTENSION_MEMO_LIST); } else { extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_CALENDAR)); collection->setExtendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA, E_SOURCE_EXTENSION_CALENDAR); } // color const gchar *color = e_source_selectable_get_color(E_SOURCE_SELECTABLE(extCalendar)); collection->setMetaData(QOrganizerCollection::KeyColor, QString::fromUtf8(color)); // selected bool selected = (e_source_selectable_get_selected(E_SOURCE_SELECTABLE(extCalendar)) == TRUE); collection->setExtendedMetaData(COLLECTION_SELECTED_METADATA, selected); } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-saverequestdata.h0000644000015301777760000000403712323305673030144 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_SAVEREQUESTDATA_H__ #define __QORGANIZER_EDS_SAVEREQUESTDATA_H__ #include "qorganizer-eds-requestdata.h" #include "qorganizer-eds-engine.h" class SaveRequestData : public RequestData { public: SaveRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); ~SaveRequestData(); void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); QString nextCollection(); QString currentCollection() const; QList takeItemsToCreate(); QList takeItemsToUpdate(); bool end() const; void setWorkingItems(QList items); QList workingItems() const; int updateMode() const; void appendResults(QList results); void appendResult(const QtOrganizer::QOrganizerItem &item, QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); private: QList m_result; QMap m_erros; QMap > m_items; QList m_currentItems; QList m_workingItems; QString m_currentCollection; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-engineid.h0000644000015301777760000000444612323305647026532 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_ENGINEID_H__ #define __QORGANIZER_EDS_ENGINEID_H__ #include "qorganizer-eds-collection-engineid.h" #include #include #include class QOrganizerEDSEngineId : public QtOrganizer::QOrganizerItemEngineId { public: QOrganizerEDSEngineId(); QOrganizerEDSEngineId(const QString& collectionId, const QString& id); ~QOrganizerEDSEngineId(); QOrganizerEDSEngineId(const QOrganizerEDSEngineId& other); QOrganizerEDSEngineId(const QString& idString); bool isEqualTo(const QtOrganizer::QOrganizerItemEngineId* other) const; bool isLessThan(const QtOrganizer::QOrganizerItemEngineId* other) const; QString managerUri() const; QtOrganizer::QOrganizerItemEngineId* clone() const; QString toString() const; uint hash() const; #ifndef QT_NO_DEBUG_STREAM QDebug& debugStreamOut(QDebug& dbg) const; #endif static QString managerUriStatic(); static QString managerNameStatic(); static QString toComponentId(const QtOrganizer::QOrganizerItemId &itemId, QString *rid); static QString toComponentId(const QString &itemId, QString *rid); static ECalComponentId *toComponentIdObject(const QtOrganizer::QOrganizerItemId &itemId); static QOrganizerEDSEngineId *fromComponentId(const QString &cId, ECalComponentId *id, QOrganizerEDSEngineId **parentId); private: QString m_collectionId; QString m_itemId; friend class QOrganizerEDSEngine; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-removebyidrequestdata.h0000644000015301777760000000311212323305647031345 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_REMOVEBYIDQUESTDATA_H__ #define __QORGANIZER_EDS_REMOVEBYIDQUESTDATA_H__ #include "qorganizer-eds-requestdata.h" #include class RemoveByIdRequestData : public RequestData { public: RemoveByIdRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); ~RemoveByIdRequestData(); QString collectionId() const; void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); GSList *compIds() const; QString next(); void commit(); virtual void cancel(); private: QHash > m_pending; QSet m_currentIds; QString m_currentCollectionId; bool m_sessionStaterd; GSList *m_currentCompIds; void reset(); void clear(); GSList *parseIds(QSet iids); }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-fetchocurrencedata.cpp0000644000015301777760000000557512323305647031140 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-fetchocurrencedata.h" #include #include #include using namespace QtOrganizer; FetchOcurrenceData::FetchOcurrenceData(QOrganizerEDSEngine *engine, QOrganizerAbstractRequest *req) : RequestData(engine, req), m_components(0) { } FetchOcurrenceData::~FetchOcurrenceData() { if (m_components) { g_slist_free_full(m_components, (GDestroyNotify)icalcomponent_free); m_components = 0; } } time_t FetchOcurrenceData::startDate() const { QDateTime startDate = request()->startDate(); if (!startDate.isValid()) { startDate = QDateTime::fromTime_t(0); qWarning() << "Start date is invalide using " << startDate; } return startDate.toTime_t(); } time_t FetchOcurrenceData::endDate() const { QDateTime endDate = request()->endDate(); if (!endDate.isValid()) { QDate currentDate = QDate::currentDate(); endDate.setTime(QTime(0, 0, 0)); endDate.setDate(QDate(currentDate.year()+1, 1, 1)); qWarning() << "End date is invalid using " << endDate; } return endDate.toTime_t(); } void FetchOcurrenceData::finish(QOrganizerManager::Error error) { QList results; if (m_components) { QString collectionId = request()->parentItem().collectionId().toString(); results = parent()->parseEvents(collectionId, m_components, true); g_slist_free_full(m_components, (GDestroyNotify)icalcomponent_free); m_components = 0; } QOrganizerManagerEngine::updateItemOccurrenceFetchRequest(request(), results, error, QOrganizerAbstractRequest::FinishedState); } void FetchOcurrenceData::appendResult(icalcomponent *comp) { m_components = g_slist_append(m_components, comp); } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/eds.json0000644000015301777760000000003212323305647023300 0ustar pbusernogroup00000000000000{ "Keys": [ "eds" ] } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-fetchbyidrequestdata.cpp0000644000015301777760000000504012323305647031476 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-fetchbyidrequestdata.h" #include using namespace QtOrganizer; FetchByIdRequestData::FetchByIdRequestData(QOrganizerEDSEngine *engine, QOrganizerAbstractRequest *req) : RequestData(engine, req), m_current(-1) { } FetchByIdRequestData::~FetchByIdRequestData() { } QString FetchByIdRequestData::nextId() { QString id; QList ids = request()->ids(); m_current++; if (m_current < ids.count()) { id = ids[m_current].toString(); } return id; } QString FetchByIdRequestData::currentId() const { return request()->ids()[m_current].toString(); } QString FetchByIdRequestData::currentCollectionId() const { QString itemId = currentId(); if (!itemId.isEmpty()) { return itemId.contains("/") ? itemId.split("/").first() : QString(); } return QString(); } bool FetchByIdRequestData::end() const { QList ids = request()->ids(); return (m_current >= ids.count()); } void FetchByIdRequestData::finish(QOrganizerManager::Error error) { QOrganizerManagerEngine::updateItemFetchByIdRequest(request(), m_results, error, m_errors, QOrganizerAbstractRequest::FinishedState); } int FetchByIdRequestData::appendResult(const QOrganizerItem &result) { if (result.id().isNull()) { m_errors.insert(m_current, QOrganizerManager::DoesNotExistError); } else { m_results << result; } return m_results.length(); } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-requestdata.h0000644000015301777760000000360212323305647027263 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_REQUESTDATA_H__ #define __QORGANIZER_EDS_REQUESTDATA_H__ #include "qorganizer-eds-engine.h" #include "qorganizer-eds-enginedata.h" #include #include #include #include class RequestData { public: RequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); virtual ~RequestData(); GCancellable* cancellable() const; bool isLive() const; void setClient(EClient *client); ECalClient *client() const; virtual void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError) = 0; QOrganizerEDSEngine *parent() const; virtual void cancel(); template T* request() const { return qobject_cast(m_req.data()); } template void emitChangeset(T *cs) { m_parent->d->emitSharedSignals(cs); } protected: QOrganizerEDSEngine *m_parent; QtOrganizer::QOrganizerItemChangeSet m_changeSet; private: QPointer m_req; GCancellable *m_cancellable; EClient *m_client; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/CMakeLists.txt0000644000015301777760000000435612323305647024407 0ustar pbusernogroup00000000000000project(qorganizer-eds-src) set(QORGANIZER_BACKEND qtorganizer_eds) set(QORGANIZER_BACKEND_SRCS qorganizer-eds-collection-engineid.cpp qorganizer-eds-fetchrequestdata.cpp qorganizer-eds-fetchbyidrequestdata.cpp qorganizer-eds-fetchocurrencedata.cpp qorganizer-eds-engine.cpp qorganizer-eds-enginedata.cpp qorganizer-eds-engineid.cpp qorganizer-eds-removecollectionrequestdata.cpp qorganizer-eds-removerequestdata.cpp qorganizer-eds-removebyidrequestdata.cpp qorganizer-eds-requestdata.cpp qorganizer-eds-savecollectionrequestdata.cpp qorganizer-eds-saverequestdata.cpp qorganizer-eds-viewwatcher.cpp qorganizer-eds-source-registry.cpp ) set(QORGANIZER_BACKEND_HDRS qorganizer-eds-collection-engineid.h qorganizer-eds-fetchrequestdata.h qorganizer-eds-fetchbyidrequestdata.h qorganizer-eds-fetchocurrencedata.h qorganizer-eds-engine.h qorganizer-eds-enginedata.h qorganizer-eds-engineid.h qorganizer-eds-removecollectionrequestdata.h qorganizer-eds-removerequestdata.h qorganizer-eds-removebyidrequestdata.h qorganizer-eds-requestdata.h qorganizer-eds-savecollectionrequestdata.h qorganizer-eds-saverequestdata.h qorganizer-eds-source-registry.h qorganizer-eds-viewwatcher.h ) add_library(${QORGANIZER_BACKEND}-lib STATIC ${QORGANIZER_BACKEND_SRCS} ${QORGANIZER_BACKEND_HDRS} ) add_library(${QORGANIZER_BACKEND} MODULE qorganizer-eds-factory.cpp qorganizer-eds-factory.h ) include_directories( ${CMAKE_SOURCE_DIR} ${GLIB_INCLUDE_DIRS} ${GIO_INCLUDE_DIRS} ${ECAL_INCLUDE_DIRS} ${EDATASERVER_INCLUDE_DIRS} ) target_link_libraries(${QORGANIZER_BACKEND}-lib ${GLIB_LIBRARIES} ${ECAL_LIBRARIES} ${EDATASERVER_LIBRARIES} ) target_link_libraries(${QORGANIZER_BACKEND} ${QORGANIZER_BACKEND}-lib ${GLIB_LIBRARIES} ${ECAL_LIBRARIES} ${EDATASERVER_LIBRARIES} ) qt5_use_modules(${QORGANIZER_BACKEND}-lib Core Organizer) qt5_use_modules(${QORGANIZER_BACKEND} Core Organizer) execute_process( COMMAND qmake -query QT_INSTALL_PLUGINS OUTPUT_VARIABLE QT_INSTALL_PLUGINS OUTPUT_STRIP_TRAILING_WHITESPACE ) install(TARGETS ${QORGANIZER_BACKEND} LIBRARY DESTINATION ${QT_INSTALL_PLUGINS}/organizer) qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-fetchbyidrequestdata.h0000644000015301777760000000271212323305647031146 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_FETCHBYIDREQUESTDATA_H__ #define __QORGANIZER_EDS_FETCHBYIDREQUESTDATA_H__ #include "qorganizer-eds-requestdata.h" class FetchByIdRequestData : public RequestData { public: FetchByIdRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); ~FetchByIdRequestData(); QString nextId(); QString currentId() const; QString currentCollectionId() const; bool end() const; void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); int appendResult(const QtOrganizer::QOrganizerItem &result); private: int m_current; QList m_results; QMap m_errors; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-removerequestdata.cpp0000644000015301777760000001020012323305647031024 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-removerequestdata.h" #include "qorganizer-eds-engineid.h" #include "qorganizer-eds-enginedata.h" #include #include using namespace QtOrganizer; RemoveRequestData::RemoveRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req) :RequestData(engine, req), m_sessionStaterd(0), m_currentCompIds(0) { m_pendingItems = request()->items(); Q_FOREACH(const QOrganizerItem &item, m_pendingItems) { m_pendingCollections.insert(item.collectionId()); } } RemoveRequestData::~RemoveRequestData() { } QList RemoveRequestData::pendingCollections() const { return m_pendingCollections.toList(); } GSList *RemoveRequestData::takeItemsIds(QOrganizerCollectionId collectionId) { GSList *ids = 0; QList items = m_pendingItems; Q_FOREACH(const QOrganizerItem &item, items) { if (item.collectionId() == collectionId) { m_currentIds.append(item.id()); ECalComponentId *id = QOrganizerEDSEngineId::toComponentIdObject(item.id()); if (id) { ids = g_slist_append(ids, id); } m_pendingItems.removeAll(item); } } return ids; } void RemoveRequestData::finish(QtOrganizer::QOrganizerManager::Error error) { QOrganizerManagerEngine::updateItemRemoveRequest(request(), error, QMap(), QOrganizerAbstractRequest::FinishedState); //The signal will be fired by the view watcher. Check ViewWatcher::onObjectsRemoved //emitChangeset(&m_changeSet); } GSList *RemoveRequestData::compIds() const { return m_currentCompIds; } void RemoveRequestData::commit() { Q_ASSERT(m_sessionStaterd); QOrganizerManagerEngine::updateItemRemoveRequest(request(), QtOrganizer::QOrganizerManager::NoError, QMap(), QOrganizerAbstractRequest::ActiveState); reset(); } QOrganizerCollectionId RemoveRequestData::next() { Q_ASSERT(!m_sessionStaterd); if (m_pendingCollections.count() > 0) { m_sessionStaterd = true; QSet::const_iterator i = m_pendingCollections.constBegin(); m_pendingCollections.remove(*i); m_currentCollectionId = *i; m_currentCompIds = takeItemsIds(m_currentCollectionId); return m_currentCollectionId; } return QOrganizerCollectionId(); } void RemoveRequestData::cancel() { Q_ASSERT(m_sessionStaterd); RequestData::cancel(); clear(); } void RemoveRequestData::reset() { m_currentCollectionId = QOrganizerCollectionId(); m_currentIds.clear(); if (m_currentCompIds) { g_slist_free_full(m_currentCompIds, (GDestroyNotify)e_cal_component_free_id); m_currentCompIds = 0; } m_sessionStaterd = false; } void RemoveRequestData::clear() { reset(); setClient(0); } QOrganizerCollectionId RemoveRequestData::collectionId() const { return m_currentCollectionId; } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-engine.h0000644000015301777760000003531412323305673026212 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of canonical-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef QORGANIZER_EDS_ENGINE_H #define QORGANIZER_EDS_ENGINE_H #include "qorganizer-eds-collection-engineid.h" #include #include #include #include #include #include #include #include #include #include #include #include class RequestData; class FetchRequestData; class FetchByIdRequestData; class FetchOcurrenceData; class SaveRequestData; class RemoveRequestData; class RemoveByIdRequestData; class SaveCollectionRequestData; class RemoveCollectionRequestData; class ViewWatcher; class QOrganizerEDSEngineData; class QOrganizerEDSCollectionEngineId; class QOrganizerEDSEngine : public QtOrganizer::QOrganizerManagerEngine { Q_OBJECT public: static QOrganizerEDSEngine *createEDSEngine(const QMap& parameters); ~QOrganizerEDSEngine(); // URI reporting QString managerName() const; QMap managerParameters() const; // items QList items(const QList &itemIds, const QtOrganizer::QOrganizerItemFetchHint &fetchHint, QMap *errorMap, QtOrganizer::QOrganizerManager::Error *error); QList items(const QtOrganizer::QOrganizerItemFilter &filter, const QDateTime &startDateTime, const QDateTime &endDateTime, int maxCount, const QList &sortOrders, const QtOrganizer::QOrganizerItemFetchHint &fetchHint, QtOrganizer::QOrganizerManager::Error *error); QList itemIds(const QtOrganizer::QOrganizerItemFilter &filter, const QDateTime &startDateTime, const QDateTime &endDateTime, const QList &sortOrders, QtOrganizer::QOrganizerManager::Error *error); QList itemOccurrences(const QtOrganizer::QOrganizerItem &parentItem, const QDateTime &startDateTime, const QDateTime &endDateTime, int maxCount, const QtOrganizer::QOrganizerItemFetchHint &fetchHint, QtOrganizer::QOrganizerManager::Error *error); QList itemsForExport(const QDateTime &startDateTime, const QDateTime &endDateTime, const QtOrganizer::QOrganizerItemFilter &filter, const QList &sortOrders, const QtOrganizer::QOrganizerItemFetchHint &fetchHint, QtOrganizer::QOrganizerManager::Error *error); bool saveItems(QList *items, const QList &detailMask, QMap *errorMap, QtOrganizer::QOrganizerManager::Error *error); bool removeItems(const QList &itemIds, QMap *errorMap, QtOrganizer::QOrganizerManager::Error *error); // collections QtOrganizer::QOrganizerCollection defaultCollection(QtOrganizer::QOrganizerManager::Error* error); QtOrganizer::QOrganizerCollection collection(const QtOrganizer::QOrganizerCollectionId &collectionId, QtOrganizer::QOrganizerManager::Error *error); QList collections(QtOrganizer::QOrganizerManager::Error* error); bool saveCollection(QtOrganizer::QOrganizerCollection* collection, QtOrganizer::QOrganizerManager::Error* error); bool removeCollection(const QtOrganizer::QOrganizerCollectionId& collectionId, QtOrganizer::QOrganizerManager::Error* error); // Asynchronous Request Support virtual void requestDestroyed(QtOrganizer::QOrganizerAbstractRequest* req); virtual bool startRequest(QtOrganizer::QOrganizerAbstractRequest* req); virtual bool cancelRequest(QtOrganizer::QOrganizerAbstractRequest* req); virtual bool waitForRequestFinished(QtOrganizer::QOrganizerAbstractRequest* req, int msecs); // Capabilities reporting virtual QList supportedFilters() const; virtual QList supportedItemDetails(QtOrganizer::QOrganizerItemType::ItemType itemType) const; virtual QList supportedItemTypes() const; protected Q_SLOTS: void onSourceAdded(const QString &collectionId); void onSourceRemoved(const QString &collectionId); void onViewChanged(QtOrganizer::QOrganizerItemChangeSet *change); protected: QOrganizerEDSEngine(QOrganizerEDSEngineData *data); private: static QOrganizerEDSEngineData *m_globalData; QOrganizerEDSEngineData *d; QMap m_runningRequests; QList parseEvents(const QString &collectionId, GSList *events, bool isIcalEvents); static GSList *parseItems(ECalClient *client, QList items, bool *hasRecurrence); // QOrganizerItem -> ECalComponent static void parseId(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseSummary(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseDescription(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseComments(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseTags(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseReminders(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void encodeAttachment(const QUrl &url, ECalComponentAlarm *alarm); static void parseVisualReminderAttachment(const QtOrganizer::QOrganizerItemDetail &detail, ECalComponentAlarm *alarm); static void parseAudibleReminderAttachment(const QtOrganizer::QOrganizerItemDetail &detail, ECalComponentAlarm *alarm); static void parseStartTime(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseEndTime(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseTodoStartTime(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseRecurrence(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseWeekRecurrence(const QtOrganizer::QOrganizerRecurrenceRule &qRule, struct icalrecurrencetype *rule); static void parseMonthRecurrence(const QtOrganizer::QOrganizerRecurrenceRule &qRule, struct icalrecurrencetype *rule); static void parseYearRecurrence(const QtOrganizer::QOrganizerRecurrenceRule &qRule, struct icalrecurrencetype *rule); static void parsePriority(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseLocation(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseDueDate(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseProgress(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseStatus(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); static void parseAttendeeList(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp); // ECalComponent -> QOrganizerItem static bool hasRecurrence(ECalComponent *comp); static void parseId(ECalComponent *comp, QtOrganizer::QOrganizerItem *item, QOrganizerEDSCollectionEngineId *edsCollectionId); static void parseSummary(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseDescription(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseComments(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseTags(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseReminders(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static QUrl dencodeAttachment(ECalComponentAlarm *alarm); static void parseAudibleReminderAttachment(ECalComponentAlarm *alarm, QtOrganizer::QOrganizerItemReminder *aDetail); static void parseVisualReminderAttachment(ECalComponentAlarm *alarm, QtOrganizer::QOrganizerItemReminder *aDetail); static void parseStartTime(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseTodoStartTime(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseEndTime(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseRecurrence(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseWeekRecurrence(struct icalrecurrencetype *rule, QtOrganizer::QOrganizerRecurrenceRule *qRule); static void parseMonthRecurrence(struct icalrecurrencetype *rule, QtOrganizer::QOrganizerRecurrenceRule *qRule); static void parseYearRecurrence(struct icalrecurrencetype *rule, QtOrganizer::QOrganizerRecurrenceRule *qRule); static void parsePriority(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseLocation(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseDueDate(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseProgress(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseStatus(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static void parseAttendeeList(ECalComponent *comp, QtOrganizer::QOrganizerItem *item); static QDateTime fromIcalTime(struct icaltimetype value, const char *tzId); static icaltimetype fromQDateTime(const QDateTime &dateTime, bool allDay, QByteArray *tzId); static QtOrganizer::QOrganizerItem *parseEvent(ECalComponent *comp); static QtOrganizer::QOrganizerItem *parseToDo(ECalComponent *comp); static QtOrganizer::QOrganizerItem *parseJournal(ECalComponent *comp); static ECalComponent *createDefaultComponent(ECalClient *client, icalcomponent_kind iKind, ECalComponentVType eType); static ECalComponent *parseEventItem(ECalClient *client, const QtOrganizer::QOrganizerItem &item); static ECalComponent *parseTodoItem(ECalClient *client, const QtOrganizer::QOrganizerItem &item); static ECalComponent *parseJournalItem(ECalClient *client, const QtOrganizer::QOrganizerItem &item); // glib callback void itemsAsync(QtOrganizer::QOrganizerItemFetchRequest *req); static void itemsAsyncStart(FetchRequestData *data); static void itemsAsyncListed(ECalComponent *comp, time_t instanceStart, time_t instanceEnd, FetchRequestData *data); static void itemsAsyncDone(FetchRequestData *data); static void itemsAsyncListedAsComps(GObject *source, GAsyncResult *res, FetchRequestData *data); void itemsByIdAsync(QtOrganizer::QOrganizerItemFetchByIdRequest *req); static void itemsByIdAsyncStart(FetchByIdRequestData *data); static void itemsByIdAsyncListed(GObject *client, GAsyncResult *res, FetchByIdRequestData *data); void itemOcurrenceAsync(QtOrganizer::QOrganizerItemOccurrenceFetchRequest *req); static void itemOcurrenceAsyncGetObjectDone(GObject *source, GAsyncResult *res, FetchOcurrenceData *data); static void itemOcurrenceAsyncListed(ECalComponent *comp, time_t instanceStart, time_t instanceEnd, FetchOcurrenceData *data); static void itemOcurrenceAsyncDone(FetchOcurrenceData *data); void saveItemsAsync(QtOrganizer::QOrganizerItemSaveRequest *req); static void saveItemsAsyncStart(SaveRequestData *data); static void saveItemsAsyncCreated(GObject *source_object, GAsyncResult *res, SaveRequestData *data); static void saveItemsAsyncModified(GObject *source_object, GAsyncResult *res, SaveRequestData *data); void removeItemsByIdAsync(QtOrganizer::QOrganizerItemRemoveByIdRequest *req); static void removeItemsByIdAsyncStart(RemoveByIdRequestData *data); void removeItemsAsync(QtOrganizer::QOrganizerItemRemoveRequest *req); static void removeItemsAsyncStart(RemoveRequestData *data); void saveCollectionAsync(QtOrganizer::QOrganizerCollectionSaveRequest *req); static void saveCollectionUpdateAsyncStart(SaveCollectionRequestData *data); static void saveCollectionAsyncCommited(ESourceRegistry *registry, GAsyncResult *res, SaveCollectionRequestData *data); static void saveCollectionUpdateAsynCommited(ESourceRegistry *registry, GAsyncResult *res, SaveCollectionRequestData *data); void removeCollectionAsync(QtOrganizer::QOrganizerCollectionRemoveRequest *req); static void removeCollectionAsyncStart(GObject *sourceObject, GAsyncResult *res, RemoveCollectionRequestData *data); friend class RequestData; friend class SaveCollectionRequestData; friend class RemoveCollectionRequestData; friend class ViewWatcher; friend class FetchRequestData; friend class FetchOcurrenceData; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-savecollectionrequestdata.cpp0000644000015301777760000001530112323305647032550 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "qorganizer-eds-savecollectionrequestdata.h" #include "qorganizer-eds-enginedata.h" #include "qorganizer-eds-source-registry.h" #include #include #include #include using namespace QtOrganizer; SaveCollectionRequestData::SaveCollectionRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req) : RequestData(engine, req), m_currentSources(0), m_registry(0) { parseCollections(); } SaveCollectionRequestData::~SaveCollectionRequestData() { if (m_registry) { g_object_unref(m_registry); m_registry = 0; } if (m_currentSources) { g_list_free_full(m_currentSources, g_object_unref); m_currentSources = 0; } } void SaveCollectionRequestData::finish(QtOrganizer::QOrganizerManager::Error error) { QOrganizerManagerEngine::updateCollectionSaveRequest(request(), m_results.values(), error, m_errorMap, QOrganizerAbstractRequest::FinishedState); emitChangeset(&m_changeSet); m_changeSet.clearAll(); } void SaveCollectionRequestData::commitSourceCreated() { GList *i = g_list_first(m_currentSources); for(; i != 0; i = i->next) { ESource *source = E_SOURCE(i->data); QOrganizerCollection collection = parent()->d->m_sourceRegistry->insert(source); m_results.insert(m_sources.key(source), collection); m_changeSet.insertAddedCollection(collection.id()); } } void SaveCollectionRequestData::commitSourceUpdated(ESource *source, QOrganizerManager::Error error) { int index = m_sourcesToUpdate.firstKey(); m_sourcesToUpdate.remove(index); if (error == QOrganizerManager::NoError) { QOrganizerEDSCollectionEngineId *id; QOrganizerCollection collection = SourceRegistry::parseSource(source, &id); m_results.insert(index, collection); m_changeSet.insertChangedCollection(collection.id()); } else { m_errorMap.insert(index, error); } } ESource *SaveCollectionRequestData::nextSourceToUpdate() { if (m_sourcesToUpdate.size() > 0) { return m_sourcesToUpdate.first(); } else { return 0; } } bool SaveCollectionRequestData::prepareToCreate() { Q_FOREACH(ESource *source, m_sourcesToCreate.values()) { m_currentSources = g_list_append(m_currentSources, source); } return (g_list_length(m_currentSources) > 0); } bool SaveCollectionRequestData::prepareToUpdate() { return (m_sourcesToUpdate.size() > 0); } void SaveCollectionRequestData::setRegistry(ESourceRegistry *registry) { if (m_registry) { g_object_unref(m_registry); m_registry = 0; } if (registry) { m_registry = registry; g_object_ref(m_registry); } } ESourceRegistry *SaveCollectionRequestData::registry() const { return m_registry; } GList *SaveCollectionRequestData::sourcesToCreate() const { return m_currentSources; } void SaveCollectionRequestData::parseCollections() { m_sources.clear(); m_errorMap.clear(); int index = 0; Q_FOREACH(const QOrganizerCollection &collection, request()->collections()) { ESource *source = 0; bool isNew = true; if (collection.id().isNull()) { GError *gError = 0; source = e_source_new(0, 0, &gError); if (gError) { m_errorMap.insert(index, QOrganizerManager::UnspecifiedError); qWarning() << "Fail to create source:" << gError->message; g_error_free(gError); Q_ASSERT(false); } e_source_set_parent(source, "local-stub"); } else { source = m_parent->d->m_sourceRegistry->source(collection.id().toString()); isNew = false; } QVariant callendarType = collection.extendedMetaData(COLLECTION_CALLENDAR_TYPE_METADATA); ESourceBackend *extCalendar = 0; if (callendarType.toString() == E_SOURCE_EXTENSION_TASK_LIST) { extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_TASK_LIST)); } else if (callendarType.toString() == E_SOURCE_EXTENSION_MEMO_LIST) { extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_MEMO_LIST)); } else { extCalendar = E_SOURCE_BACKEND(e_source_get_extension(source, E_SOURCE_EXTENSION_CALENDAR)); } if (source) { if (isNew) { if (extCalendar) { e_source_backend_set_backend_name(extCalendar, "local"); } else { qWarning() << "Fail to get source callendar"; } } // update name QString name = collection.metaData(QOrganizerCollection::KeyName).toString(); e_source_set_display_name(source, name.toUtf8().data()); // update color QString color = collection.metaData(QOrganizerCollection::KeyColor).toString(); e_source_selectable_set_color(E_SOURCE_SELECTABLE(extCalendar), color.toUtf8().data()); // update selected bool selected = collection.extendedMetaData(COLLECTION_SELECTED_METADATA).toBool(); e_source_selectable_set_selected(E_SOURCE_SELECTABLE(extCalendar), selected); m_sources.insert(index, source); if (isNew) { m_sourcesToCreate.insert(index, source); } else { m_sourcesToUpdate.insert(index, source); } index++; } } qDebug() << "Request with" << m_sources.size() << "sources"; } qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-viewwatcher.h0000644000015301777760000000362112323305647027272 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_VIEWWATCHER_H__ #define __QORGANIZER_EDS_VIEWWATCHER_H__ #include "qorganizer-eds-engine.h" #include #include #include #include class QOrganizerEDSEngineData; class ViewWatcher : public QObject { Q_OBJECT public: ViewWatcher(const QString &collectionId, QOrganizerEDSEngineData *data, EClient *client); virtual ~ViewWatcher(); void clear(); void wait(); private: QString m_collectionId; QOrganizerEDSEngineData *m_engineData; GCancellable *m_cancellable; ECalClient *m_eClient; ECalClientView *m_eView; QEventLoop *m_eventLoop; QList parseItemIds(GSList *objects); static void clientConnected(GObject *sourceObject, GAsyncResult *res, ViewWatcher *self); static void viewReady(GObject *sourceObject, GAsyncResult *res, ViewWatcher *self); static void onObjectsAdded(ECalClientView *view, GSList *objects, ViewWatcher *self); static void onObjectsRemoved(ECalClientView *view, GSList *objects, ViewWatcher *self); static void onObjectsModified(ECalClientView *view, GSList *objects, ViewWatcher *self); }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/qorganizer/qorganizer-eds-removecollectionrequestdata.h0000644000015301777760000000306612323305647032561 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __QORGANIZER_EDS_REMOVECOLLECTIONQUESTDATA_H__ #define __QORGANIZER_EDS_REMOVECOLLECTIONQUESTDATA_H__ #include "qorganizer-eds-requestdata.h" #include class RemoveCollectionRequestData : public RequestData { public: RemoveCollectionRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req); ~RemoveCollectionRequestData(); void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); ESource* begin(); void commit(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError); bool remoteDeletable() const; void setRemoteDeletable(bool deletable); private: QList m_pendingCollections; QMap m_errorMap; int m_currentCollection; bool m_remoteDeletable; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/0000755000015301777760000000000012323306646020620 5ustar pbusernogroup00000000000000qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/CMakeLists.txt0000644000015301777760000000003312323305647023354 0ustar pbusernogroup00000000000000add_subdirectory(unittest) qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/0000755000015301777760000000000012323306646022477 5ustar pbusernogroup00000000000000qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/eds-base-test.h0000644000015301777760000000224512323305647025313 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __EDS_BASE_TEST__ #define __EDS_BASE_TEST__ #include #include #include class QOrganizerEDSEngine; class EDSBaseTest { public: EDSBaseTest(); ~EDSBaseTest(); protected: void init(QOrganizerEDSEngine *engine); void cleanup(QOrganizerEDSEngine *engine); void appendToRemove(const QtOrganizer::QOrganizerItemId &id); private: ESourceRegistry *m_sourceRegistry; QList m_newItems; }; #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/collections-test.cpp0000644000015301777760000002332212323305647026500 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of qtorganizer5-eds. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "qorganizer-eds-engine.h" #include "eds-base-test.h" using namespace QtOrganizer; class CollectionTest : public QObject, public EDSBaseTest { Q_OBJECT private: static const QString defaultCollectionName; static const QString defaultTaskCollectionName; static const QString collectionTypePropertyName; static const QString taskListTypeName; QOrganizerEDSEngine *m_engineWrite; QOrganizerEDSEngine *m_engineRead; private Q_SLOTS: void init() { EDSBaseTest::init(0); m_engineWrite = QOrganizerEDSEngine::createEDSEngine(QMap()); m_engineRead = QOrganizerEDSEngine::createEDSEngine(QMap()); } void cleanup() { delete m_engineRead; m_engineRead = 0; EDSBaseTest::cleanup(m_engineWrite); m_engineWrite = 0; } void testCreateCollection() { QOrganizerCollection collection; QtOrganizer::QOrganizerManager::Error error; collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); collection.setMetaData(QOrganizerCollection::KeyColor, QStringLiteral("red")); QList collections = m_engineRead->collections(&error); int initalCollectionCount = collections.count(); QVERIFY(m_engineWrite->saveCollection(&collection, &error)); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(!collection.id().isNull()); collections = m_engineWrite->collections(&error); QCOMPARE(collections.count(), initalCollectionCount + 1); collections = m_engineRead->collections(&error); QCOMPARE(collections.count(), initalCollectionCount + 1); // Check if data was correct saved QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); QCOMPARE(error, QOrganizerManager::NoError); QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), defaultCollectionName); QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("red")); QCOMPARE(newCollection.extendedMetaData("collection-type").toString(), QStringLiteral("Calendar")); QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), false); } void testUpdateCollection() { QOrganizerCollection collection; QtOrganizer::QOrganizerManager::Error error; collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); collection.setMetaData(QOrganizerCollection::KeyColor, "red"); QVERIFY(m_engineWrite->saveCollection(&collection, &error)); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(!collection.id().isNull()); // update the collection QSignalSpy updateCollection(m_engineWrite, SIGNAL(collectionsChanged(QList))); collection.setMetaData(QOrganizerCollection::KeyColor, "blue"); collection.setExtendedMetaData("collection-selected", true); QVERIFY(m_engineWrite->saveCollection(&collection, &error)); QCOMPARE(error, QOrganizerManager::NoError); QTRY_COMPARE(updateCollection.count(), 1); // Check if the collection was stored correct QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); QCOMPARE(error, QOrganizerManager::NoError); QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), defaultCollectionName); QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("blue")); QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), true); } void testRemoveCollection() { static QString removableCollectionName = defaultTaskCollectionName + QStringLiteral("_REMOVABLE"); // Create a collection QOrganizerCollection collection; QtOrganizer::QOrganizerManager::Error error; collection.setMetaData(QOrganizerCollection::KeyName, removableCollectionName); QList collections = m_engineRead->collections(&error); int initalCollectionCount = collections.count(); QVERIFY(m_engineWrite->saveCollection(&collection, &error)); // remove recent created collection QVERIFY(m_engineWrite->removeCollection(collection.id(), &error)); collections = m_engineWrite->collections(&error); QCOMPARE(collections.count(), initalCollectionCount); QVERIFY(!collections.contains(collection)); collections = m_engineRead->collections(&error); QCOMPARE(collections.count(), initalCollectionCount); QVERIFY(!collections.contains(collection)); } void testCreateTaskList() { QOrganizerCollection collection; QtOrganizer::QOrganizerManager::Error error; collection.setMetaData(QOrganizerCollection::KeyName, defaultTaskCollectionName); collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); QSignalSpy createdCollection(m_engineWrite, SIGNAL(collectionsAdded(QList))); QVERIFY(m_engineWrite->saveCollection(&collection, &error)); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(!collection.id().isNull()); //verify signal QTRY_COMPARE(createdCollection.count(), 1); QList args = createdCollection.takeFirst(); QCOMPARE(args.count(), 1); QVERIFY(m_engineWrite->collections(&error).contains(collection)); QVERIFY(m_engineRead->collections(&error).contains(collection)); } void testCreateTask() { static QString displayLabelValue = QStringLiteral("Todo test"); static QString descriptionValue = QStringLiteral("Todo description"); QOrganizerCollection collection; QtOrganizer::QOrganizerManager::Error error; collection.setMetaData(QOrganizerCollection::KeyName, defaultTaskCollectionName + "2"); collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); QVERIFY(m_engineWrite->saveCollection(&collection, &error)); QVERIFY(!collection.id().isNull()); QOrganizerTodo todo; todo.setCollectionId(collection.id()); todo.setStartDateTime(QDateTime::currentDateTime()); todo.setDisplayLabel(displayLabelValue); todo.setDescription(descriptionValue); QMap errorMap; QList items; QSignalSpy createdItem(m_engineWrite, SIGNAL(itemsAdded(QList))); items << todo; bool saveResult = m_engineWrite->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); QVERIFY(!items[0].id().isNull()); appendToRemove(items[0].id()); //verify signal QTRY_COMPARE(createdItem.count(), 1); QList args = createdItem.takeFirst(); QCOMPARE(args.count(), 1); // check if the item is listead inside the correct collection QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemCollectionFilter filter; filter.setCollectionId(collection.id()); items = m_engineRead->items(filter, QDateTime(), QDateTime(), 10, sort, hint, &error); QCOMPARE(items.count(), 1); QOrganizerTodo result = static_cast(items[0]); todo = items[0]; QCOMPARE(result.id(), todo.id()); QCOMPARE(result.startDateTime(), todo.startDateTime()); QCOMPARE(result.displayLabel(), todo.displayLabel()); QCOMPARE(result.description(), todo.description()); // check if the item is listead by id QList ids; ids << todo.id(); items = m_engineRead->items(ids, hint, &errorMap, &error); QCOMPARE(items.count(), 1); result = static_cast(items[0]); todo = items[0]; QCOMPARE(result.id(), todo.id()); QCOMPARE(result.startDateTime(), todo.startDateTime()); QCOMPARE(result.displayLabel(), todo.displayLabel()); QCOMPARE(result.description(), todo.description()); } }; const QString CollectionTest::defaultCollectionName = QStringLiteral("TEST COLLECTION"); const QString CollectionTest::defaultTaskCollectionName = QStringLiteral("TEST COLLECTION TASK LIST"); const QString CollectionTest::collectionTypePropertyName = QStringLiteral("collection-type"); const QString CollectionTest::taskListTypeName = QStringLiteral("Task List"); QTEST_MAIN(CollectionTest) #include "collections-test.moc" qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/event-test.cpp0000644000015301777760000005354712323305647025317 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of qtorganizer5-eds. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "qorganizer-eds-engine.h" #include "eds-base-test.h" using namespace QtOrganizer; class EventTest : public QObject, public EDSBaseTest { Q_OBJECT private: static const QString defaultCollectionName; static const QString defaultTaskCollectionName; static const QString collectionTypePropertyName; static const QString taskListTypeName; static int signalIndex; QDateTime m_itemRemovedTime; QDateTime m_requestFinishedTime; QOrganizerEDSEngine *m_engine; QOrganizerCollection m_collection; private Q_SLOTS: void init() { EDSBaseTest::init(0); signalIndex = 0; m_itemRemovedTime = QDateTime(); m_requestFinishedTime = QDateTime(); m_engine = QOrganizerEDSEngine::createEDSEngine(QMap()); QtOrganizer::QOrganizerManager::Error error; m_collection = QOrganizerCollection(); m_collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); m_collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); bool saveResult = m_engine->saveCollection(&m_collection, &error); QVERIFY(saveResult); QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); } void cleanup() { EDSBaseTest::cleanup(m_engine); } //helper void itemRemoved() { m_itemRemovedTime = QDateTime::currentDateTime(); // avoid both signals to be fired at the same time QTest::qSleep(100); } void requestFinished(QOrganizerAbstractRequest::State state) { if (state == QOrganizerAbstractRequest::FinishedState) { m_requestFinishedTime = QDateTime::currentDateTime(); // avoid both signals to be fired at the same time QTest::qSleep(100); } } // test functions void testCreateEventWithReminder() { static QString displayLabelValue = QStringLiteral("Todo test"); static QString descriptionValue = QStringLiteral("Todo description"); QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(QDateTime::currentDateTime()); todo.setDisplayLabel(displayLabelValue); todo.setDescription(descriptionValue); QOrganizerItemVisualReminder vReminder; vReminder.setDataUrl(QUrl("http://www.alarms.com")); vReminder.setMessage("Test visual reminder"); QOrganizerItemAudibleReminder aReminder; aReminder.setSecondsBeforeStart(10); aReminder.setRepetition(10, 20); aReminder.setDataUrl(QUrl("file://home/user/My Musics/play as alarm.wav")); todo.saveDetail(&aReminder); todo.saveDetail(&vReminder); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << todo; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); // append new item to be removed after the test appendToRemove(items[0].id()); QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemIdFilter filter; QList ids; ids << items[0].id(); filter.setIds(ids); items = m_engine->items(filter, QDateTime(), QDateTime(), 10, sort, hint, &error); QCOMPARE(items.count(), 1); // audible QList reminders = items[0].details(QOrganizerItemDetail::TypeAudibleReminder); QCOMPARE(reminders.size(), 1); QOrganizerItemAudibleReminder aReminder2 = reminders[0]; QCOMPARE(aReminder2.secondsBeforeStart(), aReminder.secondsBeforeStart()); QCOMPARE(aReminder2.repetitionCount(), aReminder.repetitionCount()); QCOMPARE(aReminder2.repetitionDelay(), aReminder.repetitionDelay()); QCOMPARE(aReminder2.dataUrl(), aReminder.dataUrl()); //QCOMPARE(aReminder2, aReminder); // visual reminders = items[0].details(QOrganizerItemDetail::TypeVisualReminder); QCOMPARE(reminders.size(), 1); QOrganizerItemVisualReminder vReminder2 = reminders[0]; //vReminder.setRepetition(1, 0); QCOMPARE(vReminder2.secondsBeforeStart(), vReminder.secondsBeforeStart()); QCOMPARE(vReminder2.repetitionCount(), vReminder.repetitionCount()); QCOMPARE(vReminder2.repetitionDelay(), vReminder.repetitionDelay()); QCOMPARE(vReminder2.dataUrl(), vReminder.dataUrl()); QCOMPARE(vReminder2.message(), vReminder.message()); } void testRemoveEvent() { static QString displayLabelValue = QStringLiteral("event to be removed"); static QString descriptionValue = QStringLiteral("removable event"); QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(QDateTime::currentDateTime()); todo.setDisplayLabel(displayLabelValue); todo.setDescription(descriptionValue); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << todo; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QCOMPARE(items.size(), 1); QVERIFY(errorMap.isEmpty()); QVERIFY(!items[0].id().isNull()); // append new item to be removed after the test appendToRemove(items[0].id()); QOrganizerItemRemoveRequest req; connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); connect(m_engine, SIGNAL(itemsRemoved(QList)), this, SLOT(itemRemoved())); req.setItem(items[0]); m_engine->startRequest(&req); m_engine->waitForRequestFinished(&req, -1); // check if the signal item removed was fired after the request finish QTRY_VERIFY(m_requestFinishedTime.isValid()); QTRY_VERIFY(m_itemRemovedTime.isValid()); if (m_itemRemovedTime < m_requestFinishedTime) { qDebug() << "Item removed before request finish"; qDebug() << "Removed time" << m_itemRemovedTime; qDebug() << "RequestFinished time" << m_requestFinishedTime; } QVERIFY(m_itemRemovedTime >= m_requestFinishedTime); } void testRemoveItemById() { static QString displayLabelValue = QStringLiteral("event to be removed"); static QString descriptionValue = QStringLiteral("removable event"); QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(QDateTime::currentDateTime()); todo.setDisplayLabel(displayLabelValue); todo.setDescription(descriptionValue); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << todo; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); QOrganizerItemId id = items[0].id(); QVERIFY(!id.isNull()); // append new item to be removed after the test appendToRemove(id); QOrganizerItemRemoveByIdRequest req; connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); connect(m_engine, SIGNAL(itemsRemoved(QList)), this, SLOT(itemRemoved())); req.setItemId(id); m_engine->startRequest(&req); m_engine->waitForRequestFinished(&req, -1); // check if the signal item removed was fired after the request finish QTRY_VERIFY(m_requestFinishedTime.isValid()); QTRY_VERIFY(m_itemRemovedTime.isValid()); QVERIFY(m_itemRemovedTime > m_requestFinishedTime); // check if item was removed QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemIdFilter filter; QList ids; ids << id; filter.setIds(ids); items = m_engine->items(filter, QDateTime(), QDateTime(), 10, sort, hint, &error); QCOMPARE(items.count(), 0); } void testCreateEventWithoutCollection() { static QString displayLabelValue = QStringLiteral("event without collection"); static QString descriptionValue = QStringLiteral("event without collection"); QOrganizerEvent event; event.setStartDateTime(QDateTime::currentDateTime()); event.setDisplayLabel(displayLabelValue); event.setDescription(descriptionValue); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << event; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); QVERIFY(!items[0].id().isNull()); // append new item to be removed after the test appendToRemove(items[0].id()); // check if item was created on the default collection QOrganizerItemFetchHint hint; QList ids; ids << items[0].id(); qDebug() << "Check for item id:" << ids; items = m_engine->items(ids, hint, 0, 0); QCOMPARE(items.count(), 1); QOrganizerCollection collection = m_engine->defaultCollection(0); QCOMPARE(items[0].collectionId(), collection.id()); } void testCreateMultipleItemsWithSameCollection() { static QString displayLabelValue = QStringLiteral("Multiple Item:%1"); static QString descriptionValue = QStringLiteral("Multiple Item desc:%1"); QList evs; for(int i=0; i<10; i++) { QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(QDateTime::currentDateTime()); todo.setDisplayLabel(displayLabelValue.arg(i)); todo.setDescription(descriptionValue.arg(i)); evs << todo; } QtOrganizer::QOrganizerManager::Error error; QMap errorMap; bool saveResult = m_engine->saveItems(&evs, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); QCOMPARE(evs.count(), 10); Q_FOREACH(const QOrganizerItem &i, evs) { QVERIFY(!i.id().isNull()); appendToRemove(i.id()); } } void testCreateMultipleItemsWithDiffCollections() { static QString displayLabelValue = QStringLiteral("Multiple Item:%1"); static QString descriptionValue = QStringLiteral("Multiple Item desc:%1"); QList evs; for(int i=0; i<10; i++) { QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(QDateTime(QDate(2013, 9, 3+1), QTime(0,30,0))); todo.setDisplayLabel(displayLabelValue.arg(i)); todo.setDescription(descriptionValue.arg(i)); evs << todo; } QtOrganizer::QOrganizerManager::Error error; QOrganizerCollection eventCollection = QOrganizerCollection(); eventCollection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName + "_TEMP"); bool saveResult = m_engine->saveCollection(&eventCollection, &error); QVERIFY(saveResult); for(int i=0; i<10; i++) { QOrganizerEvent ev; ev.setCollectionId(eventCollection.id()); ev.setStartDateTime(QDateTime(QDate(2013, 10, 3+1), QTime(0,30,0))); ev.setDisplayLabel(displayLabelValue.arg(i)); ev.setDescription(descriptionValue.arg(i)); evs << ev; } QMap errorMap; saveResult = m_engine->saveItems(&evs, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); QCOMPARE(evs.count(), 20); Q_FOREACH(const QOrganizerItem &i, evs) { QVERIFY(!i.id().isNull()); appendToRemove(i.id()); } } void testCauseErrorDuringCreateMultipleItems() { static QString displayLabelValue = QStringLiteral("Multiple Item:%1"); static QString descriptionValue = QStringLiteral("Multiple Item desc:%1"); QList evs; QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(QDateTime(QDate(2013, 9, 1), QTime(0,30,0))); todo.setDisplayLabel(displayLabelValue.arg(1)); todo.setDescription(descriptionValue.arg(1)); evs << todo; // This item will cause error, because the collection ID is invalid QOrganizerEvent ev; QOrganizerEDSCollectionEngineId *edsCollectionId = new QOrganizerEDSCollectionEngineId("XXXXXX"); QOrganizerCollectionId cid(edsCollectionId); QVERIFY(!cid.isNull()); QCOMPARE(cid.toString(), QStringLiteral("qtorganizer:eds::XXXXXX")); ev.setCollectionId(cid); ev.setStartDateTime(QDateTime(QDate(2013, 10, 2), QTime(0,30,0))); ev.setDisplayLabel(displayLabelValue.arg(2)); ev.setDescription(descriptionValue.arg(2)); evs << ev; todo.setStartDateTime(QDateTime(QDate(2013, 9, 3), QTime(0,30,0))); todo.setDisplayLabel(displayLabelValue.arg(3)); todo.setDescription(descriptionValue.arg(3)); evs << todo; QtOrganizer::QOrganizerManager::Error error; QMap errorMap; bool saveResult = m_engine->saveItems(&evs, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QCOMPARE(evs.count(), 2); appendToRemove(evs[0].id()); appendToRemove(evs[1].id()); QCOMPARE(errorMap.size(), 1); QCOMPARE(errorMap[1], QOrganizerManager::InvalidCollectionError); } void testCreateAllDayEvent() { static QString displayLabelValue = QStringLiteral("All day title"); static QString descriptionValue = QStringLiteral("All day description"); QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setAllDay(true); todo.setStartDateTime(QDateTime(QDate(2013, 9, 3), QTime(0,30,0))); todo.setDisplayLabel(displayLabelValue); todo.setDescription(descriptionValue); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << todo; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); QOrganizerItemId id = items[0].id(); QVERIFY(!id.isNull()); // append new item to be removed after the test appendToRemove(id); QOrganizerItemFetchHint hint; QList ids; ids << items[0].id(); items = m_engine->items(ids, hint, &errorMap, &error); QCOMPARE(items.count(), 1); QOrganizerTodo todoResult = static_cast(items[0]); QCOMPARE(todoResult.isAllDay(), true); } void testCreateTodoEventWithStartDate() { static QString displayLabelValue = QStringLiteral("Event todo with start date"); static QString descriptionValue = QStringLiteral("Event todo with start date description"); static QDateTime startDateTime = QDateTime(QDate(2013, 9, 3), QTime(0,30,0)); // create a new item QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(startDateTime); todo.setDisplayLabel(displayLabelValue); todo.setDescription(descriptionValue); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << todo; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); // query by the new item QOrganizerItemFetchHint hint; QList ids; ids << items[0].id(); items = m_engine->items(ids, hint, &errorMap, &error); QCOMPARE(items.count(), 1); // compare start datetime QOrganizerTodo newTodo = static_cast(items[0]); QCOMPARE(newTodo.startDateTime(), startDateTime); } void testCreateWithDiffTimeZone() { static QString displayLabelValue = QStringLiteral("Event with diff timezone"); static QString descriptionValue = QStringLiteral("Event with diff timezone description"); static QDateTime startDateTime = QDateTime(QDate(2013, 9, 3), QTime(0, 30, 0), QTimeZone("Asia/Bangkok")); // create a new item QOrganizerTodo todo; todo.setCollectionId(m_collection.id()); todo.setStartDateTime(startDateTime); todo.setDisplayLabel(displayLabelValue); todo.setDescription(descriptionValue); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << todo; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); // query by the new item QOrganizerItemFetchHint hint; QList ids; ids << items[0].id(); items = m_engine->items(ids, hint, &errorMap, &error); QCOMPARE(items.count(), 1); // compare start datetime QOrganizerTodo newTodo = static_cast(items[0]); QDateTime newStartDateTime = newTodo.startDateTime(); QCOMPARE(newStartDateTime.timeSpec(), Qt::TimeZone); QCOMPARE(newStartDateTime.timeZone(), QTimeZone("Asia/Bangkok")); QCOMPARE(newTodo.startDateTime(), startDateTime); } }; const QString EventTest::defaultCollectionName = QStringLiteral("TEST_EVENT_COLLECTION"); const QString EventTest::defaultTaskCollectionName = QStringLiteral("TEST_EVENT_COLLECTION TASK LIST"); const QString EventTest::collectionTypePropertyName = QStringLiteral("collection-type"); const QString EventTest::taskListTypeName = QStringLiteral("Task List"); int EventTest::signalIndex = 0; QTEST_MAIN(EventTest) #include "event-test.moc" qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/eds-base-test.cpp0000644000015301777760000000572112323305647025650 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of ubuntu-pim-service. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "config.h" #include "eds-base-test.h" #include "qorganizer-eds-engine.h" #include #include #include using namespace QtOrganizer; EDSBaseTest::EDSBaseTest() { GError *error = 0; m_sourceRegistry = e_source_registry_new_sync(0, &error); if (error) { qWarning() << "Fail to create sourge registry:" << error->message; g_error_free(error); Q_ASSERT(false); } } EDSBaseTest::~EDSBaseTest() { g_object_unref(m_sourceRegistry); } void EDSBaseTest::init(QOrganizerEDSEngine *engine) { cleanup(engine); // wait to flush DBUS calls QTest::qWait(1000); } void EDSBaseTest::cleanup(QOrganizerEDSEngine *engine) { // remove all new items, remove item by item because they can have diff collections Q_FOREACH(const QOrganizerItemId &id, m_newItems) { QtOrganizer::QOrganizerManager::Error error; QMap errorMap; engine->removeItems(QList() << id, &errorMap, &error); } m_newItems.clear(); delete engine; // remove all collections GError *error; gboolean status; GList *sources = e_source_registry_list_sources(m_sourceRegistry, 0); for(GList *i = sources; i != 0; i = i->next) { ESource *source = E_SOURCE(i->data); error = 0; status = true; if (e_source_get_remote_deletable(source)) { status = e_source_remote_delete_sync(source, 0, &error); QTest::qWait(100); } else if (e_source_get_removable(source)) { status = e_source_remove_sync(source, 0, &error); QTest::qWait(100); // check if source was removed const gchar *uid = e_source_get_uid(source); Q_ASSERT(e_source_registry_ref_source(m_sourceRegistry, uid) == 0); } if (error) { qWarning() << "Fail to remove source:" << error->message; g_error_free(error); Q_ASSERT(false); } Q_ASSERT(status); } g_list_free_full(sources, g_object_unref); e_source_registry_debug_dump(m_sourceRegistry, 0); } void EDSBaseTest::appendToRemove(const QtOrganizer::QOrganizerItemId &id) { m_newItems << id; } qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/recurrence-test.cpp0000644000015301777760000005126012323305703026312 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of qtorganizer5-eds. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "qorganizer-eds-engine.h" #include "eds-base-test.h" using namespace QtOrganizer; class RecurrenceTest : public QObject, public EDSBaseTest { Q_OBJECT private: static const QString defaultCollectionName; QOrganizerEDSEngine *m_engine; QOrganizerCollection m_collection; QOrganizerItem createTestEvent() { static QString displayLabelValue = QStringLiteral("Recurrence event test"); static QString descriptionValue = QStringLiteral("Recucurrence event description"); QOrganizerEvent ev; ev.setCollectionId(m_collection.id()); ev.setStartDateTime(QDateTime(QDate(2013, 12, 2), QTime(0,0,0), QTimeZone("America/Recife"))); ev.setEndDateTime(QDateTime(QDate(2013, 12, 2), QTime(0,30,0), QTimeZone("America/Recife"))); ev.setDisplayLabel(displayLabelValue); ev.setDescription(descriptionValue); QOrganizerRecurrenceRule rule; rule.setFrequency(QOrganizerRecurrenceRule::Weekly); rule.setDaysOfWeek(QSet() << Qt::Monday); rule.setLimit(QDate(2013, 12, 31)); ev.setRecurrenceRule(rule); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << ev; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); Q_ASSERT(saveResult); Q_ASSERT(error == QtOrganizer::QOrganizerManager::NoError); // append new item to be removed after the test appendToRemove(items[0].id()); return items[0]; } private Q_SLOTS: void init() { EDSBaseTest::init(0); m_engine = QOrganizerEDSEngine::createEDSEngine(QMap()); QtOrganizer::QOrganizerManager::Error error; m_collection = QOrganizerCollection(); m_collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); bool saveResult = m_engine->saveCollection(&m_collection, &error); QVERIFY(saveResult); QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); } void cleanup() { EDSBaseTest::cleanup(m_engine); } void testCreateWeeklyEvent() { static QString displayLabelValue = QStringLiteral("Weekly test"); static QString descriptionValue = QStringLiteral("Weekly description"); QOrganizerEvent ev; ev.setCollectionId(m_collection.id()); ev.setStartDateTime(QDateTime(QDate(2013, 12, 2), QTime(0,0,0))); ev.setEndDateTime(QDateTime(QDate(2013, 12, 2), QTime(0,30,0))); ev.setDisplayLabel(displayLabelValue); ev.setDescription(descriptionValue); QOrganizerRecurrenceRule rule; rule.setFrequency(QOrganizerRecurrenceRule::Weekly); rule.setDaysOfWeek(QSet() << Qt::Monday); rule.setLimit(QDate(2013, 12, 31)); ev.setRecurrenceRule(rule); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << ev; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); // append new item to be removed after the test QOrganizerItemId parentId = items[0].id(); appendToRemove(parentId); QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemFilter filter; items = m_engine->items(filter, QDateTime(QDate(2013, 11, 30), QTime(0,0,0)), QDateTime(QDate(2014, 1, 1), QTime(0,0,0)), 100, sort, hint, &error); QCOMPARE(items.count(), 5); QList expectedDates; expectedDates << QDateTime(QDate(2013, 12, 2), QTime(0,0,0)) << QDateTime(QDate(2013, 12, 9), QTime(0,0,0)) << QDateTime(QDate(2013, 12, 16), QTime(0,0,0)) << QDateTime(QDate(2013, 12, 23), QTime(0,0,0)) << QDateTime(QDate(2013, 12, 30), QTime(0,0,0)); for(int i=0; i < 5; i++) { QOrganizerItemParent itemParent = items[i].detail(QOrganizerItemDetail::TypeParent); QOrganizerEventTime time = items[i].detail(QOrganizerItemDetail::TypeEventTime); QCOMPARE(itemParent.parentId(), parentId); QCOMPARE(time.startDateTime(), expectedDates[i]); } } void testCreateMonthlyEvent() { static QString displayLabelValue = QStringLiteral("Monthly test"); static QString descriptionValue = QStringLiteral("Monthly description"); static QDateTime eventStartDate = QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0), Qt::UTC); static QDateTime eventEndDate = QDateTime(QDate(2013, 1, 1), QTime(0, 30, 0), Qt::UTC); QOrganizerEvent ev; ev.setCollectionId(m_collection.id()); ev.setStartDateTime(eventStartDate); ev.setEndDateTime(eventEndDate); ev.setDisplayLabel(displayLabelValue); ev.setDescription(descriptionValue); QOrganizerRecurrenceRule rule; rule.setFrequency(QOrganizerRecurrenceRule::Monthly); rule.setDaysOfMonth(QSet() << 1 << 5); rule.setLimit(QDate(2013, 12, 31)); ev.setRecurrenceRule(rule); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << ev; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); // append new item to be removed after the test appendToRemove(items[0].id()); QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemFilter filter; items = m_engine->items(filter, eventStartDate, eventStartDate.addYears(1), 100, sort, hint, &error); QCOMPARE(items.count(), 24); for(int i=0; i < 12; i++) { QOrganizerEventTime time = items[i*2].detail(QOrganizerItemDetail::TypeEventTime); QCOMPARE(time.startDateTime(), eventStartDate.addMonths(i)); time = items[(i*2)+1].detail(QOrganizerItemDetail::TypeEventTime); QCOMPARE(time.startDateTime(), QDateTime(QDate(2013, i+1, 5), QTime(0,0,0), Qt::UTC)); } } void testModifyReccurenceEvents() { createTestEvent().id(); QtOrganizer::QOrganizerManager::Error error; QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemFilter filter; QList items; items = m_engine->items(filter, QDateTime(QDate(2013, 11, 30), QTime(0,0,0)), QDateTime(QDate(2014, 1, 1), QTime(0,0,0)), 100, sort, hint, &error); QCOMPARE(items.count(), 5); QMap errorMap; // remove only one item bool removeResult = m_engine->removeItems(QList() << items[3].id(), &errorMap, &error); QCOMPARE(removeResult, true); QCOMPARE(error, QOrganizerManager::NoError); QCOMPARE(errorMap.size(), 0); items = m_engine->items(filter, QDateTime(QDate(2013, 11, 30), QTime(0,0,0)), QDateTime(QDate(2014, 1, 1), QTime(0,0,0)), 100, sort, hint, &error); QCOMPARE(items.count(), 4); // edit only one item QList updateItems; QOrganizerItem updateItem = items[2]; QList mask; updateItem.setDisplayLabel("Updated item 2"); updateItems << updateItem; bool saveResult = m_engine->saveItems(&updateItems, mask, &errorMap, &error); QCOMPARE(saveResult, true); QCOMPARE(errorMap.size(), 0); QCOMPARE(error, QOrganizerManager::NoError); items = m_engine->items(QList() << updateItem.id(), hint, &errorMap, &error); QCOMPARE(errorMap.size(), 0); QCOMPARE(error, QOrganizerManager::NoError); QCOMPARE(items.size(), 1); QCOMPARE(items[0].displayLabel(), QStringLiteral("Updated item 2")); } void testQueryRecurrenceForAParentItem() { QOrganizerItem recurrenceEvent = createTestEvent(); QtOrganizer::QOrganizerManager::Error error; QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemFilter filter; QList items = m_engine->items(filter, QDateTime(), QDateTime(), 100, sort, hint, &error); // this should return only the parent event QCOMPARE(error, QOrganizerManager::NoError); QCOMPARE(items.count(), 1); QCOMPARE(items[0].id(), recurrenceEvent.id()); QOrganizerEvent parentEvent = static_cast(items[0]); QCOMPARE(parentEvent.recurrenceRules().size(), 1); // Check if the limit date was saved correct QOrganizerRecurrenceRule rrule = parentEvent.recurrenceRule(); QCOMPARE(rrule.limitDate(), QDate(2013, 12, 31)); // query recurrence events for the event items = m_engine->itemOccurrences(recurrenceEvent, QDateTime(QDate(2013, 11, 30), QTime(0,0,0)), QDateTime(QDate(2014, 1, 1), QTime(0,0,0)), 100, hint, &error); // check if all recurrence was returned QCOMPARE(items.count(), 5); QList expectedDates; expectedDates << QDateTime(QDate(2013, 12, 2), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2013, 12, 9), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2013, 12, 16), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2013, 12, 23), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2013, 12, 30), QTime(0,0,0), QTimeZone("America/Recife")); for(int i=0; i < 5; i++) { QCOMPARE(items[i].type(), QOrganizerItemType::TypeEventOccurrence); QOrganizerEventTime time = items[i].detail(QOrganizerItemDetail::TypeEventTime); QCOMPARE(time.startDateTime(), expectedDates[i]); } } void testCreateSunTueWedThuFriSatEvents() { static QString displayLabelValue = QStringLiteral("testCreateSunTueWedThuFriSatEvents test"); static QString descriptionValue = QStringLiteral("testCreateSunTueWedThuFriSatEvents description"); QOrganizerEvent ev; ev.setCollectionId(m_collection.id()); ev.setStartDateTime(QDateTime(QDate(2014, 03, 1), QTime(0,0,0), QTimeZone("America/Recife"))); ev.setEndDateTime(QDateTime(QDate(2014, 03, 1), QTime(0,30,0), QTimeZone("America/Recife"))); ev.setDisplayLabel(displayLabelValue); ev.setDescription(descriptionValue); QOrganizerRecurrenceRule rule; rule.setFrequency(QOrganizerRecurrenceRule::Weekly); QSet dasyOfWeek; dasyOfWeek << Qt::Sunday << Qt::Tuesday << Qt::Wednesday << Qt::Thursday << Qt::Friday << Qt::Saturday; rule.setDaysOfWeek(dasyOfWeek); ev.setRecurrenceRule(rule); QtOrganizer::QOrganizerManager::Error error; QMap errorMap; QList items; items << ev; bool saveResult = m_engine->saveItems(&items, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); // append new item to be removed after the test QOrganizerItemId parentId = items[0].id(); appendToRemove(parentId); QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemFilter filter; // check if the parent was saved correct items = m_engine->items(QList() << parentId, hint, &errorMap, &error); QCOMPARE(items.size(), 1); QOrganizerEvent result = items[0]; QCOMPARE(result.collectionId(), ev.collectionId()); QCOMPARE(result.startDateTime(), ev.startDateTime()); QCOMPARE(result.endDateTime(), ev.endDateTime()); QCOMPARE(result.displayLabel(), ev.displayLabel()); QCOMPARE(result.description(), ev.description()); QOrganizerRecurrenceRule savedRule = result.recurrenceRule(); QCOMPARE(savedRule.frequency(), rule.frequency()); QCOMPARE(savedRule.daysOfWeek(), rule.daysOfWeek()); items = m_engine->items(filter, QDateTime(QDate(2014, 03, 1), QTime(0,0,0)), QDateTime(QDate(2014, 03, 8), QTime(24,0,0)), 100, sort, hint, &error); QList expectedDates; expectedDates << QDateTime(QDate(2014, 03, 1), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2014, 03, 2), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2014, 03, 4), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2014, 03, 5), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2014, 03, 6), QTime(0,0,0), QTimeZone("America/Recife")) << QDateTime(QDate(2014, 03, 7), QTime(0,0,0), QTimeZone("America/Recife")); QCOMPARE(items.count(), expectedDates.size()); for(int i=0, iMax=expectedDates.size(); i < iMax; i++) { QOrganizerItemParent itemParent = items[i].detail(QOrganizerItemDetail::TypeParent); QOrganizerEventTime time = items[i].detail(QOrganizerItemDetail::TypeEventTime); QCOMPARE(itemParent.parentId(), parentId); QCOMPARE(time.startDateTime(), expectedDates[i]); } } void testModifyAllRecurrence() { static const QString newDisplayLabel("New Display label for all items"); QOrganizerItem item = createTestEvent(); // edit all items QMap errorMap; QtOrganizer::QOrganizerManager::Error error; QList updateItems; QList mask; item.setDisplayLabel(newDisplayLabel); updateItems << item; bool saveResult = m_engine->saveItems(&updateItems, mask, &errorMap, &error); QCOMPARE(saveResult, true); QCOMPARE(errorMap.size(), 0); QCOMPARE(error, QOrganizerManager::NoError); QOrganizerItemSortOrder sort; QOrganizerItemFetchHint hint; QOrganizerItemFilter filter; QList items = m_engine->items(filter, QDateTime(QDate(2013, 11, 30), QTime(0,0,0)), QDateTime(QDate(2014, 1, 1), QTime(0,0,0)), 100, sort, hint, &error); QCOMPARE(items.count(), 5); Q_FOREACH(const QOrganizerItem &i, items) { QCOMPARE(i.displayLabel(), newDisplayLabel); } } void testModifyPriorEvents() { static const QString newDisplayLabel("New Display label for prior items"); static const QDateTime startInteval(QDateTime(QDate(2013, 12, 2), QTime(0,0,0), QTimeZone("America/Recife"))); static const QDateTime endInteval(QDateTime(QDate(2014, 1, 1), QTime(0,0,0), QTimeZone("America/Recife"))); QOrganizerItem item = createTestEvent(); QtOrganizer::QOrganizerManager::Error error; QOrganizerItemFetchHint hint; QList items; items = m_engine->itemOccurrences(item, startInteval, endInteval, 100, hint, &error); QCOMPARE(items.count(), 5); // edit only events before 16/12/2013 QOrganizerEventOccurrence changeItem = static_cast(items[2]); QDate changeItemDate(2013, 12, 16); QCOMPARE(changeItem.startDateTime().date(), changeItemDate); // edit only one item changeItem.setDisplayLabel(newDisplayLabel); changeItem.setDescription("New Event Description"); QtOrganizer::QOrganizerItemSaveRequest req(m_engine); changeItem.setDisplayLabel(newDisplayLabel); req.setItem(changeItem); req.setProperty("update-mode", 1 << 1); m_engine->startRequest(&req); m_engine->waitForRequestFinished(&req, 0); QCOMPARE(req.error(), QtOrganizer::QOrganizerManager::NoError); QOrganizerItemSortOrder sort; QOrganizerItemFilter filter; items = m_engine->items(filter, startInteval, endInteval, 100, sort, hint, &error); QCOMPARE(items.count(), 5); //FIXME #if 0 Q_FOREACH(const QOrganizerItem &i, items) { QOrganizerEventOccurrence event = static_cast(i); qDebug() << i.displayLabel() << event.startDateTime().time() << i.description(); //if (event.startDateTime().date() <= changeItemDate) { // QCOMPARE(i.displayLabel(), newDisplayLabel); //} else { // QCOMPARE(i.displayLabel(), item.displayLabel()); //} } #endif } }; const QString RecurrenceTest::defaultCollectionName = QStringLiteral("TEST_RECURRENCE_EVENT_COLLECTION"); QTEST_MAIN(RecurrenceTest) #include "recurrence-test.moc" qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/fetchitem-test.cpp0000644000015301777760000001345312323305647026136 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of qtorganizer5-eds. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "qorganizer-eds-engine.h" #include "eds-base-test.h" using namespace QtOrganizer; class FetchItemTest : public QObject, public EDSBaseTest { Q_OBJECT private: static const QString defaultCollectionName; QOrganizerEDSEngine *m_engine; QOrganizerCollection m_collection; QList m_events; private Q_SLOTS: void initTestCase() { EDSBaseTest::init(0); m_engine = QOrganizerEDSEngine::createEDSEngine(QMap()); // create test collection m_collection = QOrganizerCollection(); QtOrganizer::QOrganizerManager::Error error; m_collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); QVERIFY(m_engine->saveCollection(&m_collection, &error)); // create test events static QString displayLabelValue = QStringLiteral("Display Label %1"); static QString descriptionValue = QStringLiteral("Description event %1"); // use this becaue EDS does not store msecs QTime currentTime = QTime::currentTime(); QDateTime date = QDateTime(QDateTime::currentDateTime().date(), QTime(currentTime.hour(), currentTime.minute(), currentTime.second())); m_events.clear(); for(int i=0; i<10; i++) { QOrganizerEvent ev; ev.setCollectionId(m_collection.id()); ev.setStartDateTime(date); ev.setEndDateTime(date.addSecs(60*30)); ev.setDisplayLabel(displayLabelValue.arg(i)); ev.setDescription(descriptionValue.arg(i)); QList evs; evs << ev; QMap errorMap; bool saveResult = m_engine->saveItems(&evs, QList(), &errorMap, &error); QVERIFY(saveResult); QCOMPARE(error, QOrganizerManager::NoError); QVERIFY(errorMap.isEmpty()); m_events << evs[0]; appendToRemove(evs[0].id()); date = date.addDays(1); } } void cleanupTestCase() { m_collection = QOrganizerCollection(); m_events.clear(); EDSBaseTest::cleanup(m_engine); m_engine = 0; } void testFetchById() { QList request; request << m_events[4].id(); QOrganizerItemFetchByIdRequest req; req.setIds(request); m_engine->startRequest(&req); m_engine->waitForRequestFinished(&req, 0); QList expected; expected << m_events[4]; QCOMPARE(expected.size(), req.items().size()); QList dr = req.items()[0].details(); Q_FOREACH(const QOrganizerItemDetail &de, m_events[4].details()) { Q_FOREACH(const QOrganizerItemDetail &d, dr) { if (de.type() == d.type()) { if (de != d) { qDebug() << "Detail not equal"; qDebug() << "\t" << de; qDebug() << "\t" << d; QFAIL("Retrieved item is not equal"); } else { qDebug() << "Detail equal"; } } } } } void testFetchWithInvalidId() { // malformated id QList request; request << QOrganizerItemId::fromString("qorganizer:eds::invalidcollection/invalidcontact"); QOrganizerItemFetchByIdRequest req; req.setIds(request); m_engine->startRequest(&req); m_engine->waitForRequestFinished(&req, 0); QCOMPARE(req.items().size(), 0); QMap errors = req.errorMap(); QCOMPARE(errors.size(), 1); QCOMPARE(errors[0], QOrganizerManager::DoesNotExistError); // id does not exists request.clear(); request << QOrganizerItemId::fromString("qtorganizer:eds::1386099272.14397.0@organizer/20131203T193432Z-14397-1000-14367-9@organizer"); QOrganizerItemFetchByIdRequest reqNotFound; reqNotFound.setIds(request); m_engine->startRequest(&reqNotFound); m_engine->waitForRequestFinished(&reqNotFound, 0); QCOMPARE(reqNotFound.items().size(), 0); errors = reqNotFound.errorMap(); QCOMPARE(errors.size(), 1); QCOMPARE(errors[0], QOrganizerManager::DoesNotExistError); } void testFetchWithoutDate() { QOrganizerItemFilter filter; QOrganizerItemFetchHint hint; QOrganizerManager::Error error; QList sort; QList result = m_engine->items(filter, QDateTime(), QDateTime(), 100, sort, hint, &error); QCOMPARE(result.size(), 10); } }; const QString FetchItemTest::defaultCollectionName = QStringLiteral("TEST_FETCH_COLLECTION"); QTEST_MAIN(FetchItemTest) #include "fetchitem-test.moc" qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/parseecal-test.cpp0000644000015301777760000003174712323305647026133 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of qtorganizer5-eds. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ //ugly hack but this allow us to test the engine without mock EDS #define private public #include "qorganizer-eds-engine.h" #undef private #include #include #include #include #include using namespace QtOrganizer; class ParseEcalTest : public QObject { Q_OBJECT private Q_SLOTS: void testParseStartTime() { QDateTime startTime = QDateTime::currentDateTime(); QDateTime endTime(startTime); endTime = endTime.addDays(2); ECalComponent *comp = e_cal_component_new(); e_cal_component_set_new_vtype(comp, E_CAL_COMPONENT_EVENT); ECalComponentDateTime dt; struct icaltimetype itt = icaltime_from_timet(startTime.toTime_t(), FALSE); dt.value = &itt; dt.tzid = ""; e_cal_component_set_dtstart(comp, &dt); QOrganizerEvent item; QOrganizerEDSEngine::parseStartTime(comp, &item); QCOMPARE(item.startDateTime().toTime_t(), startTime.toTime_t()); itt = icaltime_from_timet(endTime.toTime_t(), FALSE); dt.value = &itt; e_cal_component_set_dtend(comp, &dt); QOrganizerEDSEngine::parseEndTime(comp, &item); QCOMPARE(item.endDateTime().toTime_t(), endTime.toTime_t()); } void testParseRemindersQOrganizerEvent2ECalComponent() { QOrganizerEvent event; QOrganizerItemAudibleReminder aReminder; // Check audible reminder aReminder.setRepetition(10, 30); aReminder.setSecondsBeforeStart(10); QCOMPARE(aReminder.secondsBeforeStart(), 10); event.saveDetail(&aReminder); ECalComponent *comp = e_cal_component_new(); e_cal_component_set_new_vtype(comp, E_CAL_COMPONENT_EVENT); QOrganizerEDSEngine::parseReminders(event, comp); GList *aIds = e_cal_component_get_alarm_uids(comp); QCOMPARE(g_list_length(aIds), (guint) 1); ECalComponentAlarm *alarm = e_cal_component_get_alarm(comp, (const gchar*)aIds->data); QVERIFY(alarm); ECalComponentAlarmAction aAction; e_cal_component_alarm_get_action(alarm, &aAction); QCOMPARE(aAction, E_CAL_COMPONENT_ALARM_AUDIO); ECalComponentAlarmTrigger trigger; e_cal_component_alarm_get_trigger(alarm, &trigger); QCOMPARE(trigger.type, E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START); QCOMPARE(icaldurationtype_as_int(trigger.u.rel_duration) * -1, aReminder.secondsBeforeStart()); ECalComponentAlarmRepeat aRepeat; e_cal_component_alarm_get_repeat(alarm, &aRepeat); QCOMPARE(aRepeat.repetitions, aReminder.repetitionCount()); QCOMPARE(icaldurationtype_as_int(aRepeat.duration), aReminder.repetitionDelay()); g_object_unref(comp); } void testParseRemindersECalComponent2QOrganizerEvent() { ECalComponent *comp = e_cal_component_new(); e_cal_component_set_new_vtype(comp, E_CAL_COMPONENT_EVENT); ECalComponentAlarm *alarm = e_cal_component_alarm_new(); e_cal_component_alarm_set_action(alarm, E_CAL_COMPONENT_ALARM_DISPLAY); ECalComponentAlarmTrigger trigger; trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; trigger.u.rel_duration = icaldurationtype_from_int(-10); e_cal_component_alarm_set_trigger(alarm, trigger); ECalComponentAlarmRepeat aRepeat; aRepeat.repetitions = 5; aRepeat.duration = icaldurationtype_from_int(100); e_cal_component_alarm_set_repeat(alarm, aRepeat); e_cal_component_add_alarm(comp, alarm); e_cal_component_alarm_free(alarm); QOrganizerItem alarmItem; QOrganizerEDSEngine::parseReminders(comp, &alarmItem); QOrganizerItemVisualReminder vReminder = alarmItem.detail(QOrganizerItemDetail::TypeVisualReminder); QCOMPARE(vReminder.repetitionCount(), 5); QCOMPARE(vReminder.repetitionDelay(), 100); QCOMPARE(vReminder.secondsBeforeStart(), 10); g_object_unref(comp); } void testParseRecurenceQOrganizerEvent2ECalComponent() { // by date QOrganizerEvent event; QOrganizerItemRecurrence rec; QList rDates; rDates << QDate(2010, 1, 20) << QDate(2011, 2, 21) << QDate(2012, 3, 22); rec.setRecurrenceDates(rDates.toSet()); QList rExeptDates; rExeptDates << QDate(2013, 4, 23) << QDate(2014, 5, 24) << QDate(2015, 6, 25); rec.setExceptionDates(rExeptDates.toSet()); QOrganizerRecurrenceRule dailyRule; QList rrules; dailyRule.setFrequency(QOrganizerRecurrenceRule::Daily); dailyRule.setLimit(1000); rrules << dailyRule; QOrganizerRecurrenceRule weeklyRule; weeklyRule.setFrequency(QOrganizerRecurrenceRule::Weekly); weeklyRule.setLimit(1001); QList daysOfWeek; daysOfWeek << Qt::Monday << Qt::Tuesday << Qt::Wednesday << Qt::Thursday << Qt::Friday; weeklyRule.setDaysOfWeek(daysOfWeek.toSet()); weeklyRule.setFirstDayOfWeek(Qt::Sunday); rrules << weeklyRule; QOrganizerRecurrenceRule monthlyRule; monthlyRule.setFrequency(QOrganizerRecurrenceRule::Monthly); monthlyRule.setLimit(1002); QList daysOfMonth; daysOfMonth << 1 << 15 << 30; monthlyRule.setDaysOfMonth(daysOfMonth.toSet()); rrules << monthlyRule; QOrganizerRecurrenceRule yearlyRule; yearlyRule.setFrequency(QOrganizerRecurrenceRule::Yearly); yearlyRule.setLimit(1003); QList daysOfYear; daysOfYear << 1 << 10 << 20 << 50 << 300; yearlyRule.setDaysOfYear(daysOfYear.toSet()); QList monthsOfYear; monthsOfYear << QOrganizerRecurrenceRule::January << QOrganizerRecurrenceRule::March << QOrganizerRecurrenceRule::December; yearlyRule.setMonthsOfYear(monthsOfYear.toSet()); rrules << yearlyRule; rec.setRecurrenceRules(rrules.toSet()); // save recurrence event.saveDetail(&rec); ECalComponent *comp = e_cal_component_new(); e_cal_component_set_new_vtype(comp, E_CAL_COMPONENT_EVENT); QOrganizerEDSEngine::parseRecurrence(event, comp); // recurrence dates GSList *periodList = 0; e_cal_component_get_rdate_list(comp, &periodList); QCOMPARE(g_slist_length(periodList), (guint)3); for(GSList *pIter = periodList; pIter != 0; pIter = pIter->next) { ECalComponentPeriod *period = static_cast(pIter->data); QDate periodDate = QDateTime::fromTime_t(icaltime_as_timet(period->start)).date(); QVERIFY(rDates.contains(periodDate)); } e_cal_component_free_period_list(periodList); // exception dates GSList *exDateList = 0; e_cal_component_get_exdate_list(comp, &exDateList); for(GSList *pIter = exDateList; pIter != 0; pIter = pIter->next) { ECalComponentDateTime *exDate = static_cast(pIter->data); QDate exDateValue = QDateTime::fromTime_t(icaltime_as_timet(*exDate->value)).date(); QVERIFY(rExeptDates.contains(exDateValue)); } e_cal_component_free_exdate_list(exDateList); // rules GSList *recurList = 0; e_cal_component_get_rrule_list(comp, &recurList); QCOMPARE(g_slist_length(recurList), (guint) rrules.count()); for(GSList *recurListIter = recurList; recurListIter != 0; recurListIter = recurListIter->next) { struct icalrecurrencetype *rule = static_cast(recurListIter->data); switch(rule->freq) { case ICAL_DAILY_RECURRENCE: QCOMPARE(rule->count, dailyRule.limitCount()); break; case ICAL_WEEKLY_RECURRENCE: QCOMPARE(rule->count, weeklyRule.limitCount()); for (int d = Qt::Monday; d <= Qt::Sunday; d++) { if (daysOfWeek.contains(static_cast(d))) { QVERIFY(rule->by_day[(d-1)] != ICAL_RECURRENCE_ARRAY_MAX); } else { QVERIFY(rule->by_day[d-1] == ICAL_RECURRENCE_ARRAY_MAX); } } break; case ICAL_MONTHLY_RECURRENCE: { QCOMPARE(rule->count, monthlyRule.limitCount()); QList ruleDays; for (int d=0; d < ICAL_BY_MONTHDAY_SIZE; d++) { if (rule->by_month_day[d] != ICAL_RECURRENCE_ARRAY_MAX) { ruleDays << rule->by_month_day[d]; } } QCOMPARE(ruleDays.count(), daysOfMonth.count()); Q_FOREACH(int day, ruleDays) { QVERIFY(daysOfMonth.contains(day)); } break; } case ICAL_YEARLY_RECURRENCE: { QCOMPARE(rule->count, yearlyRule.limitCount()); QList ruleDays; for (int d=0; d < ICAL_BY_YEARDAY_SIZE; d++) { if (rule->by_year_day[d] != ICAL_RECURRENCE_ARRAY_MAX) { ruleDays << rule->by_year_day[d]; } } QCOMPARE(ruleDays.count(), daysOfYear.count()); Q_FOREACH(int day, ruleDays) { QVERIFY(daysOfYear.contains(day)); } QList ruleMonths; for (int d=0; d < ICAL_BY_MONTH_SIZE; d++) { if (rule->by_month[d] != ICAL_RECURRENCE_ARRAY_MAX) { ruleMonths << rule->by_month[d]; } } QCOMPARE(ruleMonths.count(), monthsOfYear.count()); Q_FOREACH(int month, ruleMonths) { QVERIFY(monthsOfYear.contains(static_cast(month))); } } default: break; } } // invert QOrganizerEvent event2; QOrganizerEDSEngine::parseRecurrence(comp, &event2); QCOMPARE(event2.recurrenceDates(), event.recurrenceDates()); QCOMPARE(event2.exceptionDates(), event.exceptionDates()); QList rrules2 = event2.recurrenceRules().toList(); QCOMPARE(rrules2.count(), rrules.count()); Q_FOREACH(const QOrganizerRecurrenceRule &rule2, rrules2) { switch(rule2.frequency()) { case QOrganizerRecurrenceRule::Daily: QCOMPARE(rule2.limitCount(), dailyRule.limitCount()); break; case QOrganizerRecurrenceRule::Weekly: { QCOMPARE(rule2.limitCount(), weeklyRule.limitCount()); QList daysOfWeek2 = rule2.daysOfWeek().toList(); qSort(daysOfWeek2); QCOMPARE(daysOfWeek2, daysOfWeek); break; } case QOrganizerRecurrenceRule::Monthly: { QCOMPARE(rule2.limitCount(), monthlyRule.limitCount()); QList daysOfMonth2 = rule2.daysOfMonth().toList(); qSort(daysOfMonth2); QCOMPARE(daysOfMonth2, daysOfMonth); break; } case QOrganizerRecurrenceRule::Yearly: { QCOMPARE(rule2.limitCount(), yearlyRule.limitCount()); QList daysOfYear2 = rule2.daysOfYear().toList(); qSort(daysOfYear2); QCOMPARE(daysOfYear2, daysOfYear); QList monthsOfYear2 = rule2.monthsOfYear().toList(); qSort(monthsOfYear2); QCOMPARE(monthsOfYear2, monthsOfYear); break; } default: QVERIFY(false); } } g_object_unref(comp); } }; QTEST_MAIN(ParseEcalTest) #include "parseecal-test.moc" qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/CMakeLists.txt0000644000015301777760000000601012323305647025234 0ustar pbusernogroup00000000000000macro(declare_test TESTNAME) add_executable(${TESTNAME} ${TESTNAME}.cpp eds-base-test.cpp eds-base-test.h ) qt5_use_modules(${TESTNAME} Core Organizer Test) if(TEST_XML_OUTPUT) set(TEST_ARGS -p -xunitxml -p -o -p test_${testname}.xml) else() set(TEST_ARGS "") endif() target_link_libraries(${TESTNAME} qtorganizer_eds-lib ${GLIB_LIBRARIES} ${GIO_LIBRARIES} ${ECAL_LIBRARIES} ${EDATASERVER_LIBRARIES} ) add_test(${TESTNAME} ${DBUS_RUNNER} --keep-env --task ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME} --task-name ${TESTNAME} --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Calendar4 --task ${EVOLUTION_CALENDAR_FACTORY} --task-name "evolution" -r --wait-for=${EVOLUTION_SOURCE_SERVICE_NAME} --task ${EVOLUTION_SOURCE_REGISTRY} --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r --task ${GVFSD} --task-name "gvfsd" -r) update_test_properties(${TESTNAME}) endmacro(declare_test testname) macro(update_test_properties TESTNAME) set(TEST_TMP_DIR "${TMP_DIR}/${TESTNAME}") list(APPEND ENV_VARS_LIST "QT_QPA_PLATFORM=minimal") list(APPEND ENV_VARS_LIST "HOME=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_RUNTIME_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_CACHE_HOME=${TEST_TMP_DIR}/.cache") list(APPEND ENV_VARS_LIST "XDG_CONFIG_HOME=${TEST_TMP_DIR}/.config") list(APPEND ENV_VARS_LIST "XDG_DATA_HOME=${TEST_TMP_DIR}/.local/share") list(APPEND ENV_VARS_LIST "XDG_DESKTOP_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_DOCUMENTS_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_DOWNLOAD_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_MUSIC_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_PICTURES_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_PUBLICSHARE_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_TEMPLATES_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "XDG_VIDEOS_DIR=${TEST_TMP_DIR}") list(APPEND ENV_VARS_LIST "QORGANIZER_EDS_DEBUG=On") set_tests_properties(${TESTNAME} PROPERTIES TIMEOUT ${CTEST_TESTING_TIMEOUT} ENVIRONMENT "${ENV_VARS_LIST}") endmacro(update_test_properties) include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${qorganizer-eds-src_SOURCE_DIR} ${GLIB_INCLUDE_DIRS} ${GIO_INCLUDE_DIRS} ${ECAL_INCLUDE_DIRS} ${EDATASERVER_INCLUDE_DIRS} ) add_definitions(-DTEST_SUITE) add_definitions(-std=c++11) if(NOT CTEST_TESTING_TIMEOUT) set(CTEST_TESTING_TIMEOUT 60) endif() declare_test(itemid-test) declare_test(parseecal-test) declare_test(collections-test) declare_test(event-test) declare_test(fetchitem-test) declare_test(recurrence-test) qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/itemid-test.cpp0000644000015301777760000000477312323305647025446 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This file is part of qtorganizer5-eds. * * contact-service-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * contact-service-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "qorganizer-eds-engineid.h" #include "qorganizer-eds-collection-engineid.h" using namespace QtOrganizer; class ItemIdTest : public QObject { Q_OBJECT private Q_SLOTS: void testRetriveItemId() { QString rId; QString id("qtorganizer:eds::system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu#100200023"); QCOMPARE(QOrganizerEDSEngineId::toComponentId(id, &rId), QStringLiteral("20130814T212003Z-13580-1000-1995-22@ubuntu")); QCOMPARE(rId, QStringLiteral("100200023")); } void testCreateFromString() { QOrganizerEDSEngineId id("system-calendar", "20130814T212003Z-13580-1000-1995-22@ubuntu"); QCOMPARE(id.toString(), QStringLiteral("system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); } void testCollectionIdFromString() { QOrganizerEDSCollectionEngineId id(QStringLiteral("qtorganizer:eds::system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); QOrganizerEDSCollectionEngineId id2(QStringLiteral("eds::system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); QOrganizerEDSCollectionEngineId id3(QStringLiteral("system-calendar/20130814T212003Z-13580-1000-1995-22@ubuntu")); QVERIFY(id.isEqualTo(&id2)); QVERIFY(id2.isEqualTo(&id3)); } void testCreateOrganizerId() { QOrganizerEDSEngineId id("system-calendar", "20130814T212003Z-13580-1000-1995-22@ubuntu"); QOrganizerItemId id2(new QOrganizerEDSEngineId(id)); QCOMPARE(id2.managerUri(), QStringLiteral("qtorganizer:eds:")); QString targetId = QString("qtorganizer:eds::") + id.toString(); QCOMPARE(id2.toString(), targetId); } }; QTEST_MAIN(ItemIdTest) #include "itemid-test.moc" qtorganizer5-eds-0.1.1+14.04.20140415.1/tests/unittest/parseitem-test.cpp0000644000015301777760000000000012323305647026137 0ustar pbusernogroup00000000000000qtorganizer5-eds-0.1.1+14.04.20140415.1/config.h.in0000644000015301777760000000036512323305647021505 0ustar pbusernogroup00000000000000#ifndef __CONFIG_H__ #define __CONFIG_H__ #define TMP_DIR "@TMP_DIR@" #define EVOLUTION_CALENDAR_FACTORY "@EVOLUTION_CALENDAR_FACTORY@" #define EVOLUTION_CALENDAR_SERVICE "org.gnome.evolution.dataserver.Calendar4" #endif qtorganizer5-eds-0.1.1+14.04.20140415.1/CMakeLists.txt0000644000015301777760000000572412323305647022226 0ustar pbusernogroup00000000000000project(qorganizer-eds) cmake_minimum_required(VERSION 2.8.9) include(FindPkgConfig) # Standard install paths include(GNUInstallDirs) find_package(Qt5Core REQUIRED) add_definitions(-DQT_NO_KEYWORDS) pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32) pkg_check_modules(GIO REQUIRED gio-2.0>=2.32) pkg_check_modules(EDATASERVER REQUIRED libedataserver-1.2>=3.8) pkg_check_modules(ECAL REQUIRED REQUIRED libecal-1.2>=3.8) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) # Coverage tools OPTION(ENABLE_COVERAGE "Build with coverage analysis support" OFF) if(ENABLE_COVERAGE) message(STATUS "Using coverage flags") find_program(COVERAGE_COMMAND gcov) if(NOT COVERAGE_COMMAND) message(FATAL_ERROR "gcov command not found") endif() SET(CMAKE_C_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage") SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov") include(${CMAKE_SOURCE_DIR}/cmake/lcov.cmake) endif() # Address Sanitizer OPTION(ENABLE_ADDRSANITIZER "Build with address sanitizer support" OFF) if(ENABLE_ADDRSANITIZER) message(STATUS "Using address sanitizer flags") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") #Temporary dir used by tests execute_process(COMMAND mktemp -d -t qorganizer_eds_test.XXX OUTPUT_VARIABLE TMP_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) #Create the directories file(MAKE_DIRECTORY ${TMP_DIR}/.cache) file(MAKE_DIRECTORY ${TMP_DIR}/.config) file(MAKE_DIRECTORY ${TMP_DIR}/.local/share) find_program(DBUS_RUNNER dbus-test-runner) find_program(EVOLUTION_CALENDAR_FACTORY evolution-calendar-factory PATHS /usr/lib/evolution/) find_program(EVOLUTION_SOURCE_REGISTRY evolution-source-registry PATHS /usr/lib/evolution/) find_program(GVFSD gvfsd PATHS /usr/lib/gvfs/) configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) OPTION(EVOLUTION_SOURCE_SERVICE_NAME "DBus name for source registry") if(NOT EVOLUTION_SOURCE_SERVICE_NAME) set(EVOLUTION_SOURCE_SERVICE_NAME "org.gnome.evolution.dataserver.Sources2") endif() add_subdirectory(qorganizer) if(DBUS_RUNNER) if(EVOLUTION_CALENDAR_FACTORY) enable_testing() add_subdirectory(tests) else(EVOLUTION_CALENDAR_FACTORY) message(WARNING "evolution-calendar-factory binary not found tests will be disabled") endif(EVOLUTION_CALENDAR_FACTORY) else(DBUS_RUNNER) message(WARNING "dbus-test-runner binary not found tests will be disabled") endif(DBUS_RUNNER) qtorganizer5-eds-0.1.1+14.04.20140415.1/COPYING0000644000015301777760000010451312323305647020515 0ustar pbusernogroup00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . qtorganizer5-eds-0.1.1+14.04.20140415.1/README0000644000015301777760000000002712323305647020335 0ustar pbusernogroup00000000000000canonical pim service. qtorganizer5-eds-0.1.1+14.04.20140415.1/cmake_uninstall.cmake.in0000644000015301777760000000165412323305647024244 0ustar pbusernogroup00000000000000IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) STRING(REGEX REPLACE "\n" ";" files "${files}") FOREACH(file ${files}) MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") IF(EXISTS "$ENV{DESTDIR}${file}") EXEC_PROGRAM( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) IF(NOT "${rm_retval}" STREQUAL 0) MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") ENDIF(NOT "${rm_retval}" STREQUAL 0) ELSE(EXISTS "$ENV{DESTDIR}${file}") MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") ENDIF(EXISTS "$ENV{DESTDIR}${file}") ENDFOREACH(file)