diff --git a/CMakeLists.txt b/CMakeLists.txt index 1187626d..1e0fad3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,93 +1,93 @@ project(baloo) set(BALOO_VERSION_MAJOR 4) set(BALOO_VERSION_MINOR 14) set(BALOO_VERSION_RELEASE 3) set(BALOO_VERSION_KOLAB 0) set(BALOO_VERSION "${BALOO_VERSION_MAJOR}.${BALOO_VERSION_MINOR}.${BALOO_VERSION_RELEASE}.${BALOO_VERSION_KOLAB}") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) find_package(KDE4 REQUIRED) include(KDE4Defaults) -find_package(KdepimLibs 4.14.0 CONFIG) +find_package(KdepimLibs 4.13.0 CONFIG) set_package_properties(KdepimLibs PROPERTIES DESCRIPTION "The KDEPIM libraries" URL "http://www.kde.org" TYPE REQUIRED ) find_package(Xapian CONFIG) set_package_properties(Xapian PROPERTIES DESCRIPTION "The Xapian search engine library" URL "http://xapian.org" TYPE REQUIRED ) find_package(KFileMetaData CONFIG) set_package_properties(KFileMetaData PROPERTIES DESCRIPTION "A library for extracting file metadata" URL "https://projects.kde.org/kfilemetadata" TYPE REQUIRED ) find_package(QJSON) set_package_properties(QJSON PROPERTIES DESCRIPTION "Qt library for handling JSON data" URL "http://qjson.sourceforge.net/" TYPE REQUIRED ) -find_package(Akonadi 1.12.90 CONFIG) +find_package(Akonadi 1.12.0 CONFIG) set_package_properties(Akonadi PROPERTIES URL "http://akonadi-project.org" TYPE REQUIRED ) include(ConfigureChecks.cmake) configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h) add_definitions(-DQT_NO_KEYWORDS) add_definitions(${KDE4_ENABLE_EXCEPTIONS}) add_definitions(-DQT_USE_QSTRINGBUILDER) add_definitions( -DQT_NO_CAST_FROM_ASCII ) add_definitions( -DQT_NO_CAST_TO_ASCII ) include_directories( ${CMAKE_BINARY_DIR} ${QT_INCLUDES} ${QJSON_INCLUDE_DIR} ${KFILEMETADATA_INCLUDE_DIR} ${XAPIAN_INCLUDE_DIR} ${KDEPIMLIBS_INCLUDE_DIRS} ${AKONADI_INCLUDE_DIR} ${KDE4_INCLUDES} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/file/lib ${CMAKE_SOURCE_DIR}/src/xapian ) add_subdirectory(src) add_subdirectory(icons) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/BalooConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/BalooConfig.cmake @ONLY) # this file is used by to check if the installed version can be used. macro_write_basic_cmake_version_file(${CMAKE_CURRENT_BINARY_DIR}/BalooConfigVersion.cmake ${BALOO_VERSION_MAJOR} ${BALOO_VERSION_MINOR} ${BALOO_VERSION_RELEASE}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BalooConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/BalooConfigVersion.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/Baloo) install(EXPORT BalooLibraryTargets DESTINATION ${LIB_INSTALL_DIR}/cmake/Baloo FILE BalooTargetsWithPrefix.cmake) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES ) diff --git a/src/pim/agent/calendarindexer.cpp b/src/pim/agent/calendarindexer.cpp index 6efa340f..c521ae1d 100644 --- a/src/pim/agent/calendarindexer.cpp +++ b/src/pim/agent/calendarindexer.cpp @@ -1,176 +1,176 @@ /* * This file is part of the KDE Baloo Project * Copyright (C) 2014 Laurent Montel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . * */ #include "calendarindexer.h" #include #include "xapiandocument.h" #include #include #include CalendarIndexer::CalendarIndexer(const QString& path) : AbstractIndexer(), m_db( 0 ), m_termGen( 0 ) { try { m_db = new Baloo::XapianDatabase(path, true); } catch (const Xapian::DatabaseCorruptError& err) { kError() << "Database Corrupted - What did you do?"; kError() << err.get_error_string(); m_db = 0; } catch (const Xapian::Error &e) { kError() << QString::fromStdString(e.get_type()) << QString::fromStdString(e.get_description()); m_db = 0; } } CalendarIndexer::~CalendarIndexer() { if (m_db) { m_db->commit(); delete m_db; } } QStringList CalendarIndexer::mimeTypes() const { return QStringList() << QString::fromLatin1("application/x-vnd.akonadi.calendar.event") << QString::fromLatin1("application/x-vnd.akonadi.calendar.todo") << QString::fromLatin1("application/x-vnd.akonadi.calendar.journal") << QString::fromLatin1("application/x-vnd.akonadi.calendar.freebusy"); } void CalendarIndexer::index(const Akonadi::Item &item) { if ( item.hasPayload() ) { indexEventItem( item, item.payload() ); } else if ( item.hasPayload() ) { indexJournalItem( item, item.payload() ); } else if ( item.hasPayload() ) { indexTodoItem( item, item.payload() ); } else { return; } } void CalendarIndexer::commit() { if (m_db) m_db->commit(); } void CalendarIndexer::remove(const Akonadi::Item &item) { if (!m_db) return; try { m_db->deleteDocument(item.id()); } catch (const Xapian::DocNotFoundError&) { return; } } void CalendarIndexer::remove(const Akonadi::Collection& collection) { if (!m_db) return; try { Xapian::Query query('C'+ QString::number(collection.id()).toStdString()); Xapian::Enquire enquire(*(m_db->db())); enquire.set_query(query); Xapian::MSet mset = enquire.get_mset(0, m_db->db()->get_doccount()); Xapian::MSetIterator end(mset.end()); for (Xapian::MSetIterator it = mset.begin(); it != end; ++it) { const qint64 id = *it; remove(Akonadi::Item(id)); } } catch (const Xapian::DocNotFoundError&) { return; } } void CalendarIndexer::move(const Akonadi::Item::Id& itemId, const Akonadi::Entity::Id& from, const Akonadi::Entity::Id& to) { if (!m_db) return; Xapian::Document doc; try { doc = m_db->db()->get_document(itemId); } catch (const Xapian::DocNotFoundError&) { return; } const QByteArray ft = 'C' + QByteArray::number(from); const QByteArray tt = 'C' + QByteArray::number(to); doc.remove_term(ft.data()); doc.add_boolean_term(tt.data()); m_db->replaceDocument(doc.get_docid(), doc); } void CalendarIndexer::indexEventItem(const Akonadi::Item &item, const KCalCore::Event::Ptr &event) { Baloo::XapianDocument doc; - doc.indexText(event->organizer()->email(), "O"); - doc.indexText(event->summary(), "S"); - doc.indexText(event->location(), "L"); + doc.indexText(event->organizer()->email(), QLatin1String("O")); + doc.indexText(event->summary(), QLatin1String("S")); + doc.indexText(event->location(), QLatin1String("L")); KCalCore::Attendee::List attendees = event->attendees(); KCalCore::Attendee::List::ConstIterator it; for ( it = attendees.constBegin(); it != attendees.constEnd(); ++it ) { - doc.addBoolTerm((*it)->email()+QString::number((*it)->status()), "PS"); + doc.addBoolTerm((*it)->email()+QString::number((*it)->status()), QLatin1String("PS")); } // Parent collection Q_ASSERT_X(item.parentCollection().isValid(), "Baloo::CalenderIndexer::index", "Item does not have a valid parent collection"); const Akonadi::Entity::Id colId = item.parentCollection().id(); - doc.addBoolTerm(colId, "C"); + doc.addBoolTerm(colId, QLatin1String("C")); m_db->replaceDocument(item.id(), doc); } void CalendarIndexer::indexJournalItem(const Akonadi::Item &item, const KCalCore::Journal::Ptr &journal) { //TODO } void CalendarIndexer::indexTodoItem(const Akonadi::Item &item, const KCalCore::Todo::Ptr &todo) { //TODO } void CalendarIndexer::updateIncidenceItem( const KCalCore::Incidence::Ptr &calInc ) { //TODO }