diff --git a/dataengines/CMakeLists.txt b/dataengines/CMakeLists.txt --- a/dataengines/CMakeLists.txt +++ b/dataengines/CMakeLists.txt @@ -15,7 +15,6 @@ add_subdirectory(hotplug) add_subdirectory(keystate) add_subdirectory(mpris2) -#add_subdirectory(network) add_subdirectory(notifications) add_subdirectory(packagekit) add_subdirectory(places) @@ -27,14 +26,6 @@ add_subdirectory(statusnotifieritem) add_subdirectory(share) -if(Boost_FOUND AND KdepimLibs_FOUND) - if(Akonadi_FOUND) - # add_subdirectory(akonadi) - endif() - # add_subdirectory(calendar) - # add_subdirectory(rss) -endif() - if(NOT WIN32) add_subdirectory(mouse) add_subdirectory(systemmonitor) diff --git a/dataengines/akonadi/CMakeLists.txt b/dataengines/akonadi/CMakeLists.txt deleted file mode 100644 --- a/dataengines/akonadi/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -include_directories( - ${Boost_INCLUDE_DIR} - ${KDEPIMLIBS_INCLUDE_DIRS} -) - -kde_enable_exceptions() - -set(akonadi_engine_srcs - akonadiengine.cpp -) - -add_library(plasma_engine_akonadi MODULE ${akonadi_engine_srcs}) - -target_link_libraries( - plasma_engine_akonadi - ${KDE4_KPIMUTILS_LIBS} - KF5::CoreAddons - ${KDE4_AKONADI_LIBS} - KF5::Plasma - ${KDE4_KMIME_LIBS} - ${KDE4_AKONADI_KMIME_LIBS} - ${KDE4_KABC_LIBS} - Qt5::Xml -) - -install(TARGETS plasma_engine_akonadi DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) -install(FILES plasma-engine-akonadi.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) - diff --git a/dataengines/akonadi/akonadiengine.h b/dataengines/akonadi/akonadiengine.h deleted file mode 100644 --- a/dataengines/akonadi/akonadiengine.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (c) 2007 Volker Krause - Copyright (c) 2009 Sebastian Kügler - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -#ifndef AKONADIENGINE_H -#define AKONADIENGINE_H - -#include - -#include -#include - -#include -#include - -#include -typedef boost::shared_ptr MessagePtr; - -class KJob; - -class AkonadiEngine : public Plasma::DataEngine -{ - Q_OBJECT - - public: - AkonadiEngine( QObject* parent, const QVariantList& args ); - ~AkonadiEngine(); - QStringList sources() const; - - protected: - bool sourceRequestEvent(const QString &name); - - private Q_SLOTS: - - void stopMonitor(const QString &name); - - void fetchEmailCollectionDone(KJob* job); // done retrieving whole collection - void fetchContactCollectionDone(KJob* job); // done retrieving a whole contact collection - - void emailItemsReceived(const Akonadi::Item::List &items); - - void fetchEmailCollectionsDone(KJob* job); // got list of collections - void fetchContactCollectionsDone(KJob* job); - - void emailItemAdded(const Akonadi::Item &item, const QString &collection = QString()); - void contactItemAdded(const Akonadi::Item & item); - - private: - void initEmailMonitor(); - void initContactMonitor(); - // useful for debugging - void printMessage(MessagePtr msg); - void printContact(const QString &source, const KABC::Addressee &a); - - Akonadi::Monitor* m_emailMonitor; - Akonadi::Monitor* m_contactMonitor; - - QHash m_jobCollections; -}; - -K_EXPORT_PLASMA_DATAENGINE(akonadi, AkonadiEngine) - -#endif diff --git a/dataengines/akonadi/akonadiengine.cpp b/dataengines/akonadi/akonadiengine.cpp deleted file mode 100644 --- a/dataengines/akonadi/akonadiengine.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* - Copyright (c) 2007 Volker Krause - Copyright (c) 2009 Sebastian Kügler - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -#include "akonadiengine.h" - - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace Akonadi; - -AkonadiEngine::AkonadiEngine(QObject* parent, const QVariantList& args) - : Plasma::DataEngine(parent), - m_emailMonitor(0), - m_contactMonitor(0) -{ - Q_UNUSED(args); - setMaxSourceCount( 512 ); // Guard against loading thousands of emails -} - -void AkonadiEngine::initEmailMonitor() -{ - m_emailMonitor = new Monitor( this ); - m_emailMonitor->setMimeTypeMonitored("message/rfc822"); - //m_emailMonitor->setCollectionMonitored(Collection::root(), false); - m_emailMonitor->itemFetchScope().fetchFullPayload( true ); - connect(m_emailMonitor, SIGNAL(itemAdded(Akonadi::Item,Akonadi::Collection)), - SLOT(emailItemAdded(Akonadi::Item)) ); - connect(m_emailMonitor, SIGNAL(itemChanged(Akonadi::Item,QSet)), - SLOT(emailItemAdded(Akonadi::Item)) ); - // remove the monitor on a source that's not used - connect(this, SIGNAL(sourceRemoved(QString)), SLOT(stopMonitor(QString))); -} - -void AkonadiEngine::initContactMonitor() -{ - m_contactMonitor = new Monitor( this ); - m_contactMonitor->setMimeTypeMonitored("text/directory"); - m_contactMonitor->setCollectionMonitored(Collection::root(), false); - m_contactMonitor->itemFetchScope().fetchFullPayload(); - connect(m_contactMonitor, SIGNAL(itemAdded(Akonadi::Item,Akonadi::Collection)), - SLOT(contactItemAdded(Akonadi::Item)) ); - connect(m_contactMonitor, SIGNAL(itemChanged(Akonadi::Item,QSet)), - SLOT(contactItemAdded(Akonadi::Item)) ); - // remove the monitor on a source that's not used - connect(this, SIGNAL(sourceRemoved(QString)), SLOT(stopMonitor(QString))); -} - - -AkonadiEngine::~AkonadiEngine() -{ -} - -QStringList AkonadiEngine::sources() const -{ - return QStringList() << "EmailCollections" << "ContactCollections"; -} - -void AkonadiEngine::fetchEmailCollectionsDone(KJob* job) -{ - // called when the job fetching email collections from Akonadi emits result() - if ( job->error() ) { - qDebug() << "Job Error:" << job->errorString(); - } else { - CollectionFetchJob* cjob = static_cast( job ); - int i = 0; - foreach( const Collection &collection, cjob->collections() ) { - if (collection.contentMimeTypes().contains("message/rfc822")) { - //qDebug() << "EmailCollection setting data:" << collection.name() << collection.url() << collection.contentMimeTypes(); - i++; - setData("EmailCollections", QString("EmailCollection-%1").arg(collection.id()), collection.name()); - } - } - qDebug() << i << "Email collections are in now"; - scheduleSourcesUpdated(); - } -} - -void AkonadiEngine::fetchContactCollectionsDone(KJob* job) -{ - // called when the job fetching contact collections from Akonadi emits result() - if ( job->error() ) { - qDebug() << "Job Error:" << job->errorString(); - } else { - CollectionFetchJob* cjob = static_cast( job ); - int i = 0; - foreach( const Collection &collection, cjob->collections() ) { - if (collection.contentMimeTypes().contains("text/directory")) { - //qDebug() << "ContactCollection setting data:" << collection.name() << collection.url() << collection.contentMimeTypes(); - i++; - setData("ContactCollections", QString("ContactCollection-%1").arg(collection.id()), collection.name()); - } - } - qDebug() << i << "Contact collections are in now"; - scheduleSourcesUpdated(); - } -} - -bool AkonadiEngine::sourceRequestEvent(const QString &name) -{ - qDebug() << "Source requested:" << name << sources(); - - if (name == "EmailCollections") { - Collection emailCollection(Collection::root()); - emailCollection.setContentMimeTypes(QStringList() << "message/rfc822"); - CollectionFetchJob *fetch = new CollectionFetchJob( emailCollection, CollectionFetchJob::Recursive); - connect( fetch, SIGNAL(result(KJob*)), SLOT(fetchEmailCollectionsDone(KJob*)) ); - // For async data fetching, it's mandatory to set the data source to empty before returning true - setData(name, DataEngine::Data()); - return true; - - } else if (name.startsWith(QString("EmailCollection-"))) { - qlonglong id = name.split('-')[1].toLongLong(); - ItemFetchJob* fetch = new ItemFetchJob( Collection( id ), this ); - if (!m_emailMonitor) { - initEmailMonitor(); - } - m_emailMonitor->setCollectionMonitored(Collection( id ), true); - fetch->fetchScope().fetchPayloadPart( MessagePart::Envelope ); - connect( fetch, SIGNAL(result(KJob*)), SLOT(fetchEmailCollectionDone(KJob*)) ); - connect( fetch, SIGNAL(itemsReceived(Akonadi::Item::List)), SLOT(emailItemsReceived(Akonadi::Item::List)) ); - m_jobCollections[fetch] = name; - setData(name, DataEngine::Data()); - return true; - - } else if (name.startsWith(QString("Email-"))) { - qlonglong id = name.split('-')[1].toLongLong(); - ItemFetchJob* fetch = new ItemFetchJob( Item( id ), this ); - if (!m_emailMonitor) { - initEmailMonitor(); - } - m_emailMonitor->setItemMonitored(Item( id ), true); - fetch->fetchScope().fetchFullPayload( true ); - connect( fetch, SIGNAL(result(KJob*)), SLOT(fetchEmailCollectionDone(KJob*)) ); - connect( fetch, SIGNAL(itemsReceived(Akonadi::Item::List)), SLOT(emailItemsReceived(Akonadi::Item::List)) ); - m_jobCollections[fetch] = name; - setData(name, DataEngine::Data()); - return true; - - } else if (name == "ContactCollections") { - Collection contactCollection(Collection::root()); - contactCollection.setContentMimeTypes(QStringList() << "text/directory"); - - CollectionFetchJob* fetch = new CollectionFetchJob( contactCollection, CollectionFetchJob::Recursive); - connect( fetch, SIGNAL(result(KJob*)), SLOT(fetchContactCollectionsDone(KJob*)) ); - setData(name, DataEngine::Data()); - return true; - - } else if (name.startsWith(QString("ContactCollection-"))) { - qlonglong id = name.split('-')[1].toLongLong(); - ItemFetchJob *fetch = new ItemFetchJob( Collection( id ), this ); - if (!m_contactMonitor) { - initContactMonitor(); - } - m_contactMonitor->setCollectionMonitored(Collection( id ), true); // FIXME: should be contacts monitor - fetch->fetchScope().fetchFullPayload(); - connect( fetch, SIGNAL(result(KJob*)), SLOT(fetchContactCollectionDone(KJob*)) ); - setData(name, DataEngine::Data()); - return true; - - } else if (name.startsWith(QString("Contact-"))) { - qDebug() << "Fetching contact" << name; - qlonglong id = name.split('-')[1].toLongLong(); - ItemFetchJob *fetch = new ItemFetchJob( Item( id ), this ); - if (!m_contactMonitor) { - initContactMonitor(); - } - m_contactMonitor->setItemMonitored(Item( id ), true); // FIXME: should be contacts monitor - fetch->fetchScope().fetchFullPayload(); - connect( fetch, SIGNAL(result(KJob*)), SLOT(fetchContactCollectionDone(KJob*)) ); - setData(name, DataEngine::Data()); - return true; - - // We don't understand the request. - qDebug() << "Don't know what to do with:" << name; - return false; -} - -void AkonadiEngine::stopMonitor(const QString &name) -{ - if (name.startsWith(QString("EmailCollection-"))) { - // Stop monitoring this one - qlonglong id = name.split('-')[1].toLongLong(); - m_emailMonitor->setCollectionMonitored( Collection( id ), false); - qDebug() << "Removed monitor from:" << name << id; - } -} - -void AkonadiEngine::emailItemsReceived(const Akonadi::Item::List &items) -{ - foreach (const Akonadi::Item &item, items) { - emailItemAdded(item); - } -} - -void AkonadiEngine::emailItemAdded(const Akonadi::Item &item, const QString &collection) -{ - if ( !item.hasPayload() ) { - return; - } - MessagePtr msg = item.payload(); - if (msg) { - QString source = QString::number( item.id() ); - source = "Email-" + source; - //qDebug() << "new source adding:" << source << item.url() << msg->subject()->asUnicodeString(); - - setData( source, "Id", item.id() ); - setData( source, "Collection", collection); - setData( source, "Url", item.url().url() ); - setData( source, "Subject", msg->subject()->asUnicodeString() ); - setData( source, "From", msg->from()->asUnicodeString() ); - setData( source, "DateTime", msg->date()->dateTime().date() ); - setData( source, "To", msg->to()->asUnicodeString() ); - setData( source, "Cc", msg->cc()->asUnicodeString() ); - setData( source, "Bcc", msg->bcc()->asUnicodeString() ); - setData( source, "Body", QString(msg->mainBodyPart()->body())); - // Flags - //qDebug() << item.flags(); - setData( source, "Flag-New", !item.hasFlag("\\Seen") ); - setData( source, "Flag-Task", item.hasFlag("\\Task") ); // not in Akonadi! - setData( source, "Flag-Important", item.hasFlag("important") ); - setData( source, "Flag-Attachment", item.hasFlag("has_attachment") ); - setData( source, "Flag-Spam", item.hasFlag("spam") ); - setData( source, "Flag-Draft", item.hasFlag("\\Draft") ); - setData( source, "Flag-Answered", item.hasFlag("\\Answered") ); - setData( source, "Flag-Deleted", item.hasFlag("\\Deleted") ); - setData( source, "Flag-Flagged", item.hasFlag("\\Flagged") ); - - if (!collection.isEmpty()) { - setData( collection, source, msg->subject()->asUnicodeString()); - } - printMessage(msg); - scheduleSourcesUpdated(); - } -} - -void AkonadiEngine::printMessage(const MessagePtr msg) -{ - return; - qDebug() << "sub" << msg->subject()->asUnicodeString(); - return; - qDebug() << "=============== New Item" << msg->from()->asUnicodeString() << msg->subject()->asUnicodeString(); - qDebug() << "sub" << msg->subject()->asUnicodeString(); - qDebug() << "from" << msg->from()->asUnicodeString(); - qDebug() << "date" << msg->date()->dateTime().date(); - qDebug() << "to" << msg->to()->asUnicodeString(); - qDebug() << "cc" << msg->cc()->asUnicodeString(); - qDebug() << "bcc" << msg->bcc()->asUnicodeString(); - qDebug() << "body" << msg->mainBodyPart()->body(); -} - -void AkonadiEngine::fetchEmailCollectionDone(KJob* job) -{ - if ( job->error() ) { - qDebug() << "Job Error:" << job->errorString(); - return; - } - const QString col = m_jobCollections[job]; - Item::List items = static_cast( job )->items(); - foreach ( const Item &item, items ) { - emailItemAdded(item, col); - } - m_jobCollections.remove(job); - scheduleSourcesUpdated(); -} - -void AkonadiEngine::fetchContactCollectionDone(KJob* job) -{ - if ( job->error() ) { - return; - } - Item::List items = static_cast( job )->items(); - foreach ( const Item &item, items ) { - contactItemAdded( item ); - } -} - - -void AkonadiEngine::printContact(const QString &source, const KABC::Addressee &a) -{ - qDebug() << "-----------------------------------"; - qDebug() << source; - qDebug() << "name" << a.name(); - qDebug() << "formattedName" << a.formattedName(); - qDebug() << "nameLabel" << a.nameLabel(); - qDebug() << "given" << a.givenName(); - qDebug() << "familyName" << a.familyName(); - qDebug() << "realName" << a.realName(); - qDebug() << "organization" << a.organization(); - qDebug() << "department" << a.department(); - qDebug() << "role" << a.role(); - qDebug() << "emails" << a.emails(); - qDebug() << "fullEmail" << a.fullEmail(); - qDebug() << "photoUrl" << a.photo().url(); - qDebug() << "note" << a.note(); - - QStringList phoneNumbers; - foreach (const KABC::PhoneNumber &pn, a.phoneNumbers()) { - const QString key = QString("Phone-%1").arg(pn.typeLabel()); - qDebug() << key << a.phoneNumber(pn.type()).number(); - phoneNumbers << a.phoneNumber(pn.type()).number(); - } - qDebug() << "phoneNumbers" << phoneNumbers; - - qDebug() << "additionalName" << a.additionalName(); - -} - -void AkonadiEngine::contactItemAdded( const Akonadi::Item &item ) -{ - if (item.hasPayload()) { - //qDebug() << item.id() << "item has payload ..."; - KABC::Addressee a = item.payload(); - if (!a.isEmpty()) { - const QString source = QString("Contact-%1").arg(item.id()); - setData(source, "Id", item.id()); - setData(source, "Url", item.url().url()); - - // Name and related - setData(source, "Name", a.formattedName()); - setData(source, "GivenName", a.givenName()); - setData(source, "FamilyName", a.familyName()); - setData(source, "NickName", a.nickName()); - setData(source, "RealName", a.realName()); - setData(source, "AdditionalName", a.additionalName()); - - // Organization and related - setData(source, "Organization", a.organization()); - setData(source, "Department", a.department()); - setData(source, "Role", a.role()); - - // EMail and related - setData(source, "Emails", a.emails()); - setData(source, "FullEmail", a.fullEmail()); - - // Phone and related - QStringList phoneNumbers; - foreach (const KABC::PhoneNumber &pn, a.phoneNumbers()) { - const QString key = QString("Phone-%1").arg(pn.typeLabel()); - setData(source, key, a.phoneNumber(pn.type()).number()); - phoneNumbers << a.phoneNumber(pn.type()).number(); - } - setData(source, "PhoneNumbers", phoneNumbers); - - // Personal - setData(source, "Birthday", a.birthday()); - setData(source, "Photo", a.photo().data()); - setData(source, "PhotoUrl", a.photo().url()); - setData(source, "Latitude", a.geo().latitude()); - setData(source, "Longitude", a.geo().longitude()); - - // addresses - - // categories - - // note, - setData(source, "Note", a.note()); - // prefix - - // ... - //printContact(source, a); - - scheduleSourcesUpdated(); - } - } -} - - diff --git a/dataengines/akonadi/plasma-engine-akonadi.desktop b/dataengines/akonadi/plasma-engine-akonadi.desktop deleted file mode 100644 --- a/dataengines/akonadi/plasma-engine-akonadi.desktop +++ /dev/null @@ -1,149 +0,0 @@ -[Desktop Entry] -Name=Akonadi -Name[ar]=أكونادي -Name[bg]=Akonadi -Name[bs]=Akonadi -Name[ca]=Akonadi -Name[ca@valencia]=Akonadi -Name[cs]=Akonadi -Name[da]=Akonadi -Name[de]=Akonadi -Name[el]=Akonadi -Name[en_GB]=Akonadi -Name[eo]=Akonadi -Name[es]=Akonadi -Name[et]=Akonadi -Name[eu]=Akonadi -Name[fi]=Akonadi -Name[fr]=Akonadi -Name[fy]=Akonadi -Name[ga]=Akonadi -Name[gl]=Akonadi -Name[gu]=Akonadi -Name[he]=Akonadi -Name[hi]=अकोनादी -Name[hr]=Akonadi -Name[hu]=Akonadi -Name[ia]=Akonadi -Name[id]=Akonadi -Name[is]=Akonadi -Name[it]=Akonadi -Name[ja]=Akonadi -Name[ka]=Akonadi -Name[kk]=Akonadi -Name[km]=Akonadi -Name[kn]=Akonadi -Name[ko]=Akonadi -Name[lt]=Akonadi -Name[lv]=Akonadi -Name[mai]=Akonadi -Name[mk]=Akonadi -Name[ml]=അകോനാഡി -Name[mr]=आकोनाडी -Name[nb]=Akonadi -Name[nds]=Akonadi -Name[nl]=Akonadi -Name[nn]=Akonadi -Name[pa]=ਅਕੌਂਡੀ -Name[pl]=Akonadi -Name[pt]=Akonadi -Name[pt_BR]=Akonadi -Name[ro]=Akonadi -Name[ru]=Akonadi -Name[si]=Akonadi -Name[sk]=Akonadi -Name[sl]=Akonadi -Name[sr]=Аконади -Name[sr@ijekavian]=Аконади -Name[sr@ijekavianlatin]=Akonadi -Name[sr@latin]=Akonadi -Name[sv]=Akonadi -Name[tg]=Akonadi -Name[th]=Akonadi -Name[tr]=Akonadi -Name[ug]=Akonadi -Name[uk]=Akonadi -Name[vi]=Akonadi -Name[wa]=Akonadi -Name[x-test]=xxAkonadixx -Name[zh_CN]=Akonadi -Name[zh_TW]=Akonadi -Comment=Akonadi PIM data engine -Comment[bg]=Ядро за данни Akonadi PIM -Comment[bs]=PIM datomotor Akonadija -Comment[ca]=Motor de dades PIM de l'Akonadi -Comment[ca@valencia]=Motor de dades PIM de l'Akonadi -Comment[cs]=Datový nástroj Akonadi PIM -Comment[csb]=Czérownik pòdôwków Akonadi PIM -Comment[da]=Akonadi datamotor til PIM -Comment[de]=PIM-Datentreiber für Akonadi -Comment[el]=Μηχανή δεδομένων Akonadi PIM -Comment[en_GB]=Akonadi PIM data engine -Comment[eo]=Datuma Motoro de Akonadi PIM -Comment[es]=Motor de datos Akonadi PIM -Comment[et]=Akonadi PIM-i andmete mootor -Comment[eu]=Akonadi PIM datuen motorra -Comment[fi]=Akonadi PIM -tietomoottori -Comment[fr]=Moteur de données PIM d'Akonadi -Comment[fy]=Akonadi PIM gegevensmotor -Comment[ga]=Inneall sonraí PIM Akonadi -Comment[gl]=Motor de datos PIM de Akonadi -Comment[he]=מנוע תוכן של Akonadi PIM -Comment[hi]=अकोनाडी PIM डाटा इंजिन -Comment[hr]=Akonadi mehanizam za upravljanje osobnim informacijama -Comment[hu]=Akonadi adatkezelő modul -Comment[ia]=Motor de datos de Akonadi PIM -Comment[id]=Mesin data PIM Akonadi -Comment[is]=Akonadi gagnavél fyrir persónuupplýsingar (PIM) -Comment[it]=Motore dei dati PIM di Akonadi -Comment[ja]=Akonadi PIM データエンジン -Comment[kk]=Akonadi PIM деректер тетігі -Comment[km]=ម៉ាស៊ីន​ទិន្នន័យ Akonadi PIM -Comment[kn]=Akonadi PIM ದತ್ತ ಸಾಧನ -Comment[ko]=Akonadi PIM 데이터 엔진 -Comment[lt]=Akonadi PIM duomenų variklis -Comment[lv]=Akonadi PIM datu dzinējs -Comment[mk]=Податочна машина Akonadi PIM -Comment[ml]=അകോനാഡി പിം ഡേറ്റാ എഞ്ചിന്‍ -Comment[mr]=आकोनाडी PIM डेटा इन्जीन -Comment[nb]=Akonadi PIM datamotor -Comment[nds]=De PIM-Datenkarn Akonadi -Comment[nl]=Akonadi PIM gegevensengine -Comment[nn]=Akonadi PIM-datamotor -Comment[pa]=ਅਕੌਂਡੀ PIM ਡਾਟਾ ਇੰਜਣ -Comment[pl]=Silnik danych PIM Akonadi -Comment[pt]=Motor de dados PIM do Akonadi -Comment[pt_BR]=Mecanismo de dados PIM do Akonadi -Comment[ro]=Motor de date Akonadi PIM -Comment[ru]=Источник данных Plasma для работы с личными данными, хранящимися в Akonadi -Comment[si]=Akonadi PIM දත්ත එන්ජිම -Comment[sk]=Dátový nástroj Akonadi PIM -Comment[sl]=Podatkovni pogon za upravljanje z osebnimi podatki -Comment[sr]=ПИМ датомотор Аконадија -Comment[sr@ijekavian]=ПИМ датомотор Аконадија -Comment[sr@ijekavianlatin]=PIM datomotor Akonadija -Comment[sr@latin]=PIM datomotor Akonadija -Comment[sv]=Akonadi datagränssnitt för personlig information -Comment[tg]=Системаи санаи Python -Comment[th]=กลไกข้อมูล Akonadi PIM -Comment[tr]=Akonadi PIM veri motoru -Comment[ug]=Akonadi PIM سانلىق-مەلۇمات ماتورى -Comment[uk]=Рушій даних Akonadi PIM -Comment[vi]=Cơ chế dữ liệu Akonadi PIM -Comment[wa]=Éndjin d' dinêyes PIM Akonadi -Comment[x-test]=xxAkonadi PIM data enginexx -Comment[zh_CN]=Akonadi 个人信息管理数据引擎 -Comment[zh_TW]=Akonadi PIM 資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=akonadi -X-KDE-Library=plasma_engine_akonadi - -X-KDE-PluginInfo-Author= -X-KDE-PluginInfo-Email= -X-KDE-PluginInfo-Name=akonadi -X-KDE-PluginInfo-Version= -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category= -X-KDE-PluginInfo-Depends= - diff --git a/dataengines/calendar/CMakeLists.txt b/dataengines/calendar/CMakeLists.txt deleted file mode 100644 --- a/dataengines/calendar/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -include_directories( - ${KDEPIMLIBS_INCLUDE_DIRS} - ${Boost_INCLUDE_DIR} -) - -kde_enable_exceptions() - -set(calendar_engine_srcs - calendarengine.cpp -) - -if(Akonadi_FOUND) - add_definitions(-DAKONADI_FOUND) - set(calendar_engine_srcs ${calendar_engine_srcs} - eventdatacontainer.cpp - ) -endif() - -add_library(plasma_engine_calendar MODULE ${calendar_engine_srcs}) - -target_link_libraries( - plasma_engine_calendar - ${KDEPIMLIBS_KHOLIDAYS_LIBRARY} - KF5::CoreAddons - KF5::Plasma - ${KDE4_KMIME_LIBS} - KF5::CalendarCore - ${KDE4_KCALUTILS_LIBS} -) - -if(Akonadi_FOUND) - target_link_libraries( - plasma_engine_calendar - akonadi-calendar - ${KDE4_AKONADI_LIBS} - ${KDEPIMLIBS_AKONADI_KCAL_LIBS} - ) -endif() - -install(TARGETS plasma_engine_calendar DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) -install(FILES plasma-dataengine-calendar.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) - diff --git a/dataengines/calendar/Messages.sh b/dataengines/calendar/Messages.sh deleted file mode 100755 --- a/dataengines/calendar/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /usr/bin/env bash -$XGETTEXT `find . -name \*.cpp` -o $podir/plasma_engine_calendar.pot diff --git a/dataengines/calendar/calendar.operations b/dataengines/calendar/calendar.operations deleted file mode 100644 --- a/dataengines/calendar/calendar.operations +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dataengines/calendar/calendarengine.h b/dataengines/calendar/calendarengine.h deleted file mode 100644 --- a/dataengines/calendar/calendarengine.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright (c) 2009 Davide Bettio - Copyright (c) 2010 Frederik Gladhorn - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -#ifndef CALENDARENGINE_H -#define CALENDARENGINE_H - -#include - -#ifdef AKONADI_FOUND -# include -#endif - -namespace KHolidays -{ - class HolidayRegion; -} // namespace KHolidays - -/** - The calendar data engine delivers calendar events. - It can be queried for holidays or the akonadi calendar. - - Supported Holiday requests are: - - holidaysRegions - * Returns a list of available Holiday Region Codes - holidaysDefaultRegion - * Returns a QString of a sensible default Holiday Region - holdaysIsValidRegion:[regionCode] - * Returns a bool if given Holiday Region is valid - holdaysRegion:[regionCode(s)] - * Returns the details of the Holiday Regions - holidays:[regionCode(s)]:[YYYY-MM-DD]:[YYYY-MM-DD] - * Returns a QList of all holidays in a Holiday Region(s) between two given dates. - holidays:[regionCode(s)]:[YYYY-MM-DD] - * Returns a QList of all holidays in a Holiday Region(s) on a given day - holidaysInMonth:[regionCode(s)]:[YYYY-MM-DD] - * Returns a QList of all holidays in a Holiday Region(s) in a given month - isHoliday:[regionCode(s)]:[YYYY-MM-DD] - * Returns a bool if a given date is a Holiday in the given Holiday Region(s) - description:[regionCode(s)]:[YYYY-MM-DD] - * Returns a QString of all holiday names in a given Holiday Region(s) on a given date - - Where valid, regionCode(s) are a comma separated list of one or more valid Holiday Regions - - Each Holiday Region is a pair of a QString containing the regionCode and a Data containing value - pairs for: - "Name" Name of the Holiday Region String - "Description" The description of the Region String - "CountryCode" The country code of the Region String, ISO 3166-2 format - "Location" The location of the Region String, ISO 3166-1 format - "LanguageCode" The language of the Region String, ISO 639-1 format - - Each Holiday is a Data containing QString value pairs for: - "Name" Name of holiday String - "RegionCode" The Holiday Region code String - "ObservanceStartDate" The start date of the holiday ISO format Gregorian date - "ObservanceEndDate" The end date of the holiday ISO format Gregorian date - "ObservanceDuration" How many days the holiday lasts Integer - "ObservanceType" If the holiday is a day off "PublicHoliday", "Other" - - Note that multiple holidays can be returned for each date. - - Supported Akonadi requests are: - - eventsInMonth:[YYYY-MM-DD] - events:[YYYY-MM-DD]:[YYYY-MM-DD] - events:[YYYY-MM-DD] - - The returned data contains (not all fields guaranteed to be populated): - - "UID" QString - "Type" QString "Event", "Todo", Journal" - "Summary" QString - "Comments" QStringList - "Location" QString - "OrganizerName" QString - "OrganizerEmail" QString - "Priority" int - "StartDate" KDateTime - "EndDate" KDateTime - "RecurrenceDates" QList(QVariant(KDateTime)) - "Recurs" bool - "AllDay" bool - "Categories" QStringList - "Resources" QStringList - "DurationDays" int - "DurationSeconds" int - "Status" QString "None", "Tentative", "Confirmed", "Draft", - "Final", "Completed", "InProcess", - "Cancelled", "NeedsAction", "NonStandard", - "Unknown" - "StatusName" QString translated Status - "Secrecy" QString "Public", "Private", "Confidential", "Unknown" - "SecrecyName" QString translated Secrecy - "Occurrences" QList(QVariant(Plasma::DataEngine::Data)) - where each Data contains details of an occurence of the event: - "OccurrenceUid" QString for convenience, same as UID - "OccurrenceStartDate" KDateTime - "OccurrenceEndDate" KDateTime - - Event type specific data keys: - "EventMultiDay" bool - "EventHasEndDate" bool - "EventTransparency" QString "Opaque", "Transparent", "Unknown" - - Todo type specific data keys: - "TodoHasStartDate" bool - "TodoIsOpenEnded" bool - "TodoHasDueDate" bool - "TodoDueDate" KDateTime - "TodoIsCompleted" bool - "TodoIsInProgress" bool - "TodoIsNotStarted" bool - "TodoPercentComplete" int - "TodoHasCompletedDate" bool - "TodoCompletedDate" bool - - Fields still to be done: - Attendees - Attachments - Relations - Alarms - Custom Properties - Lat/Lon - Collection/Source - -*/ -class CalendarEngine : public Plasma::DataEngine -{ - Q_OBJECT - - public: - CalendarEngine( QObject* parent, const QVariantList& args ); - ~CalendarEngine(); - - protected: - /// general request for data from this data engine - bool sourceRequestEvent(const QString &name); - - private: - /// a request for holidays data - bool holidayCalendarSourceRequest(const QString& key, const QStringList& args, const QString& request); - - /// a request for data that comes from akonadi - /// creates EventDataContainers as needed - bool akonadiCalendarSourceRequest(const QString& key, const QStringList& args, const QString& request); - -#ifdef AKONADI_FOUND - /// this is the representation of the root calendar itself. it contains everything (calendars, incidences) - Akonadi::ETMCalendar::Ptr m_calendar; -#endif - - /// holiday calendar - QHash m_regions; - QString m_defaultHolidayRegion; // Cached value of default holiday region - QString m_defaultHolidayRegionCountry; // The locale country when the cached default calculated - QString m_defaultHolidayRegionLanguage; // The locale language when the cached default calculated -}; - -K_EXPORT_PLASMA_DATAENGINE(calendar, CalendarEngine) - -#endif diff --git a/dataengines/calendar/calendarengine.cpp b/dataengines/calendar/calendarengine.cpp deleted file mode 100644 --- a/dataengines/calendar/calendarengine.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* - Copyright (c) 2009 Davide Bettio - Copyright (c) 2010 Frederik Gladhorn - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - - -#include "calendarengine.h" - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#ifdef AKONADI_FOUND -#include "eventdatacontainer.h" -#endif - -CalendarEngine::CalendarEngine(QObject* parent, const QVariantList& args) - : Plasma::DataEngine(parent, args) -{ -} - -CalendarEngine::~CalendarEngine() -{ - qDeleteAll(m_regions); -} - -bool CalendarEngine::sourceRequestEvent(const QString &request) -{ - qDebug() << "Request = " << request << '\n'; - - if (request.isEmpty()) { - return false; - } - - QStringList requestTokens = request.split(':'); - QString requestKey = requestTokens.takeFirst(); - - if (requestKey == "holidaysRegions" || - requestKey == "holidaysRegion" || - requestKey == "holidaysDefaultRegion" || - requestKey == "holidaysIsValidRegion" || - requestKey == "holidays" || - requestKey == "holidaysInMonth") { - return holidayCalendarSourceRequest(requestKey, requestTokens, request); - } - -#ifdef AKONADI_FOUND - if (requestKey == "events" || requestKey == "eventsInMonth") { - return akonadiCalendarSourceRequest(requestKey, requestTokens, request); - } -#endif - - return false; -} - -bool CalendarEngine::holidayCalendarSourceRequest(const QString& key, const QStringList& args, const QString& request) -{ - if (key == "holidaysRegions") { - QStringList regionList = KHolidays::HolidayRegion::regionCodes(); - Plasma::DataEngine::Data data; - foreach (const QString ®ionCode, regionList) { - Plasma::DataEngine::Data regionData; - KHolidays::HolidayRegion region(regionCode); - regionData.insert("Name", region.name()); - regionData.insert("Description", region.description()); - regionData.insert("CountryCode", region.countryCode()); - regionData.insert("Location", region.location()); - regionData.insert("LanguageCode", region.languageCode()); - data.insert(regionCode, regionData); - } - setData(request, data); - return true; - } - - if (key == "holidaysDefaultRegion") { - // If not set or the locale has changed since last set, then try determine a default region. - if(m_defaultHolidayRegion.isEmpty() || - m_defaultHolidayRegionCountry != KLocale::global()->country() || - m_defaultHolidayRegionLanguage != KLocale::global()->language()) { - - m_defaultHolidayRegion = QString(); - m_defaultHolidayRegionCountry = KLocale::global()->country(); - m_defaultHolidayRegionLanguage = KLocale::global()->language(); - - m_defaultHolidayRegion = KHolidays::HolidayRegion::defaultRegionCode( - m_defaultHolidayRegionCountry.toLower(), - m_defaultHolidayRegionLanguage.toLower() ); - if (m_defaultHolidayRegion.isEmpty()) { - m_defaultHolidayRegion = "NoDefault"; - } - } - - if (m_defaultHolidayRegion == "NoDefault") { - setData(request, QString()); - } else { - setData(request, m_defaultHolidayRegion); - } - return true; - } - - - int argsCount = args.count(); - if (argsCount < 1) { - return false; - } - - const QStringList regionCodeList = args.at(0).split(','); - if (regionCodeList.count() < 1) { - return false; - } - - foreach ( const QString ®ionCode, regionCodeList ) { - KHolidays::HolidayRegion *region = m_regions.value(regionCode); - if (!region || !region->isValid()) { - region = new KHolidays::HolidayRegion(regionCode); - if (region->isValid()) { - m_regions.insert(regionCode, region); - } else { - delete region; - return false; - } - } - } - - if (key == "holidaysIsValidRegion") { - if (regionCodeList.count() > 1) { - return false; - } - QString regionCode = regionCodeList.at(0); - if (m_regions.contains(regionCode)) { - setData(request, m_regions.value(regionCode)->isValid()); - } else { - setData(request, KHolidays::HolidayRegion::isValid(regionCode)); - } - return true; - } - - if (key == "holidaysRegion") { - Plasma::DataEngine::Data data; - foreach (const QString ®ionCode, regionCodeList) { - Plasma::DataEngine::Data regionData; - KHolidays::HolidayRegion *region = m_regions.value(regionCode); - regionData.insert("Name", region->name()); - regionData.insert("Description", region->description()); - regionData.insert("CountryCode", region->countryCode()); - regionData.insert("Location", region->location()); - regionData.insert("LanguageCode", region->languageCode()); - data.insert(regionCode, regionData); - } - setData(request, data); - return true; - } - - if (argsCount < 2) { - return false; - } - - QDate dateArg = QDate::fromString(args.at(1), Qt::ISODate); - if (!dateArg.isValid()) { - return false; - } - - if (key == "holidaysInMonth" || key == "holidays") { - QDate startDate, endDate; - if (key == "holidaysInMonth") { - int requestYear, requestMonth; - KLocale::global()->calendar()->getDate(dateArg, &requestYear, &requestMonth, 0); - int lastDay = KLocale::global()->calendar()->daysInMonth(dateArg); - KLocale::global()->calendar()->setDate(startDate, requestYear, requestMonth, 1); - KLocale::global()->calendar()->setDate(endDate, requestYear, requestMonth, lastDay); - } else if (argsCount == 2) { - startDate = dateArg; - endDate = dateArg; - } else if (argsCount < 3) { - return false; - } else { - startDate = dateArg; - endDate = QDate::fromString(args.at(2), Qt::ISODate); - } - - if (!startDate.isValid() || !endDate.isValid()) { - return false; - } - - QList holidayList; - foreach ( const QString ®ionCode, regionCodeList ) { - KHolidays::HolidayRegion *region = m_regions.value(regionCode); - KHolidays::Holiday::List holidays; - holidays = region->holidays(startDate, endDate, KHolidays::Holiday::MultidayHolidaysAsSingleEvents); - - foreach (const KHolidays::Holiday &holiday, holidays) { - if (!holiday.text().isEmpty()) { - Plasma::DataEngine::Data holidayData; - holidayData.insert("Name", holiday.text()); - holidayData.insert("RegionCode", regionCode); - holidayData.insert("ObservanceStartDate", holiday.observedStartDate().toString(Qt::ISODate)); - holidayData.insert("ObservanceEndDate", holiday.observedEndDate().toString(Qt::ISODate)); - holidayData.insert("ObservanceDuration", holiday.duration()); - // It's a blunt tool for now, we only know if it's a full public holiday or not - if ( holiday.dayType() == KHolidays::Holiday::NonWorkday ) { - holidayData.insert("ObservanceType", "PublicHoliday"); - } else { - holidayData.insert("ObservanceType", "Other"); - } - holidayList.append(QVariant(holidayData)); - } - } - } - - setData(request, QVariant(holidayList)); - return true; - } - - if (key == "isHoliday") { - bool isHoliday = false; - foreach ( const QString ®ionCode, regionCodeList ) { - KHolidays::HolidayRegion *region = m_regions.value(regionCode); - if (region->isHoliday(dateArg)) { - isHoliday = true; - } - } - setData(request, isHoliday); - return true; - } - - if (key == "description") { - QString summary; - foreach ( const QString ®ionCode, regionCodeList ) { - KHolidays::HolidayRegion *region = m_regions.value(regionCode); - KHolidays::Holiday::List holidays; - holidays = region->holidays(dateArg, KHolidays::Holiday::MultidayHolidaysAsSingleEvents); - foreach (const KHolidays::Holiday &holiday, holidays) { - if (!summary.isEmpty()) { - summary.append("\n"); - } - summary.append(holiday.text()); - } - } - - setData(request, summary); - return true; - } - - return false; -} - -#ifdef AKONADI_FOUND -bool CalendarEngine::akonadiCalendarSourceRequest(const QString& key, const QStringList& args, const QString& request) -{ - // figure out what time range was requested from the source string - QDate start; - QDate end; - if (key == "eventsInMonth") { - if (args.count() < 1) { - return false; - } - start = QDate::fromString(args.at(0), Qt::ISODate); - start.setDate(start.year(), start.month(), 1); - end = QDate(start.year(), start.month(), start.daysInMonth()); - } else if (key == "events") { - if (args.count() == 1) { - start = QDate::fromString(args.at(0), Qt::ISODate); - end = start.addDays(1); - } else { - if (args.count() < 2) { - return false; - } - start = QDate::fromString(args.at(0), Qt::ISODate); - end = QDate::fromString(args.at(1), Qt::ISODate); - } - } else { - return false; - } - - if (!start.isValid() || !end.isValid()) { - return false; - } - - if (!m_calendar) { - m_calendar = Akonadi::ETMCalendar::Ptr(new Akonadi::ETMCalendar()); - m_calendar->setCollectionFilteringEnabled(false); - } - - // create the corresponding EventDataContainer - addSource(new EventDataContainer(m_calendar, request, KDateTime(start, QTime(0, 0, 0)), KDateTime(end, QTime(23, 59, 59)))); - return true; -} - -#endif // AKONADI_FOUND - - diff --git a/dataengines/calendar/eventdatacontainer.h b/dataengines/calendar/eventdatacontainer.h deleted file mode 100644 --- a/dataengines/calendar/eventdatacontainer.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (c) 2010 Frederik Gladhorn - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef EVENTDATACONTAINER_H -#define EVENTDATACONTAINER_H - -#include -#include -#include -#include - -class EventDataContainer : public Plasma::DataContainer -{ - Q_OBJECT -public: - EventDataContainer(const Akonadi::ETMCalendar::Ptr &calendar, const QString& name, const KDateTime& start, const KDateTime& end, QObject* parent = 0); - -public Q_SLOTS: - // update the list of incidents - void updateData(); - -private: - void updateEventData(); - void updateTodoData(); - void updateJournalData(); - void populateIncidenceData(const KCalCore::Incidence::Ptr &incidence, Plasma::DataEngine::Data &incidenceData); - - Akonadi::ETMCalendar::Ptr m_calendar; - QString m_name; - KDateTime m_startDate; - KDateTime m_endDate; -}; - -#endif diff --git a/dataengines/calendar/eventdatacontainer.cpp b/dataengines/calendar/eventdatacontainer.cpp deleted file mode 100644 --- a/dataengines/calendar/eventdatacontainer.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - Copyright (c) 2010 Frederik Gladhorn - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "eventdatacontainer.h" - -#include - -#include -#include -#include -#include - -using namespace Akonadi; - -EventDataContainer::EventDataContainer(const Akonadi::ETMCalendar::Ptr &calendar, const QString& name, const KDateTime& start, const KDateTime& end, QObject* parent) - : Plasma::DataContainer(parent), - m_calendar(calendar), - m_name(name), - m_startDate(start), - m_endDate(end) -{ - // name under which this dataEngine source appears - setObjectName(name); - - // Connect directly to the calendar for now - connect(calendar.data(), SIGNAL(calendarChanged()), this, SLOT(updateData())); - - // create the initial data - updateData(); -} - -void EventDataContainer::updateData() -{ - removeAllData(); - updateEventData(); - updateTodoData(); - updateJournalData(); - checkForUpdate(); -} - -void EventDataContainer::updateEventData() -{ - KCalCore::Event::List events = m_calendar->events(m_startDate.date(), m_endDate.date(), m_calendar->timeSpec()); - - foreach (const KCalCore::Event::Ptr &event, events) { - Plasma::DataEngine::Data eventData; - populateIncidenceData(event, eventData); - - // Event specific fields - eventData["EventMultiDay"] = event->allDay(); - eventData["EventHasEndDate"] = event->hasEndDate(); - if (event->transparency() == KCalCore::Event::Opaque) { - eventData["EventTransparency"] = "Opaque"; - } else if (event->transparency() == KCalCore::Event::Transparent) { - eventData["EventTransparency"] = "Transparent"; - } else { - eventData["EventTransparency"] = "Unknown"; - } - - setData(event->uid(), eventData); - } -} - -void EventDataContainer::updateTodoData() -{ - QDate todoDate = m_startDate.date(); - while(todoDate <= m_endDate.date()) { - KCalCore::Todo::List todos = m_calendar->todos(todoDate); - - foreach (const KCalCore::Todo::Ptr &todo, todos) { - Plasma::DataEngine::Data todoData; - populateIncidenceData(todo, todoData); - - QVariant var; - // Todo specific fields - todoData["TodoHasStartDate"] = todo->hasStartDate(); - todoData["TodoIsOpenEnded"] = todo->isOpenEnded(); - todoData["TodoHasDueDate"] = todo->hasDueDate(); - var.setValue(todo->dtDue().toTimeSpec(m_calendar->timeSpec())); - todoData["TodoDueDate"] = var; - todoData["TodoIsCompleted"] = todo->isCompleted(); - todoData["TodoIsInProgress"] = todo->isInProgress(false); // ??? - todoData["TodoIsNotStarted"] = todo->isNotStarted(false); // ??? - todoData["TodoPercentComplete"] = todo->percentComplete(); - todoData["TodoHasCompletedDate"] = todo->hasCompletedDate(); - var.setValue(todo->completed().toTimeSpec(m_calendar->timeSpec())); - todoData["TodoCompletedDate"] = var; - - setData(todo->uid(), todoData); - } - - todoDate = todoDate.addDays(1); - } -} - -void EventDataContainer::updateJournalData() -{ - QDate journalDate = m_startDate.date(); - while(journalDate <= m_endDate.date()) { - KCalCore::Journal::List journals = m_calendar->journals(journalDate); - - foreach (const KCalCore::Journal::Ptr &journal, journals) { - Plasma::DataEngine::Data journalData; - populateIncidenceData(journal, journalData); - - // No Journal specific fields - setData(journal->uid(), journalData); - } - - journalDate = journalDate.addDays(1); - } -} - -void EventDataContainer::populateIncidenceData(const KCalCore::Incidence::Ptr &incidence, Plasma::DataEngine::Data &incidenceData) -{ - QVariant var; - incidenceData["UID"] = incidence->uid(); - incidenceData["Type"] = incidence->typeStr(); - incidenceData["Summary"] = incidence->summary(); - incidenceData["Description"] = incidence->description(); - incidenceData["Comments"] = incidence->comments(); - incidenceData["Location"] = incidence->location(); - incidenceData["OrganizerName"] = incidence->organizer()->name(); - incidenceData["OrganizerEmail"] = incidence->organizer()->email(); - incidenceData["Priority"] = incidence->priority(); - var.setValue(incidence->dtStart().toTimeSpec(m_calendar->timeSpec())); - incidenceData["StartDate"] = var; - - KCalCore::Event* event = dynamic_cast(incidence.data()); - if (event) { - var.setValue(event->dtEnd().toTimeSpec(m_calendar->timeSpec())); - incidenceData["EndDate"] = var; - } - // Build the Occurance Index, this lists all occurences of the Incidence in the required range - // Single occurance events just repeat the standard start/end dates - // Recurring Events use each recurrence start/end date - // The OccurenceUid is redundant, but it makes it easy for clients to just take() the data structure intact as a separate index - QList occurences; - // Build the recurrence list of start dates for recurring incidences only - QList recurrences; - if (incidence->recurs()) { - KCalCore::DateTimeList recurList = incidence->recurrence()->timesInInterval(m_startDate.toTimeSpec(m_calendar->timeSpec()), m_endDate.toTimeSpec(m_calendar->timeSpec())); - foreach(const KDateTime &recurDateTime, recurList) { - var.setValue(recurDateTime.toTimeSpec(m_calendar->timeSpec())); - recurrences.append(var); - Plasma::DataEngine::Data occurence; - occurence.insert("OccurrenceUid", incidence->uid()); - occurence.insert("OccurrenceStartDate", var); - var.setValue(incidence->endDateForStart(recurDateTime).toTimeSpec(m_calendar->timeSpec())); - occurence.insert("OccurrenceEndDate", var); - occurences.append(QVariant(occurence)); - } - } else { - Plasma::DataEngine::Data occurence; - occurence.insert("OccurrenceUid", incidence->uid()); - var.setValue(incidence->dtStart().toTimeSpec(m_calendar->timeSpec())); - occurence.insert("OccurrenceStartDate", var); - if (event) { - var.setValue(event->dtEnd().toTimeSpec(m_calendar->timeSpec())); - occurence.insert("OccurrenceEndDate", var); - } - occurences.append(QVariant(occurence)); - } - incidenceData["RecurrenceDates"] = QVariant(recurrences); - incidenceData["Occurrences"] = QVariant(occurences); - if (incidence->status() == KCalCore::Incidence::StatusNone) { - incidenceData["Status"] = "None"; - } else if (incidence->status() == KCalCore::Incidence::StatusTentative) { - incidenceData["Status"] = "Tentative"; - } else if (incidence->status() == KCalCore::Incidence::StatusConfirmed) { - incidenceData["Status"] = "Confirmed"; - } else if (incidence->status() == KCalCore::Incidence::StatusDraft) { - incidenceData["Status"] = "Draft"; - } else if (incidence->status() == KCalCore::Incidence::StatusFinal) { - incidenceData["Status"] = "Final"; - } else if (incidence->status() == KCalCore::Incidence::StatusCompleted) { - incidenceData["Status"] = "Completed"; - } else if (incidence->status() == KCalCore::Incidence::StatusInProcess) { - incidenceData["Status"] = "InProcess"; - } else if (incidence->status() == KCalCore::Incidence::StatusCanceled) { - incidenceData["Status"] = "Cancelled"; - } else if (incidence->status() == KCalCore::Incidence::StatusNeedsAction) { - incidenceData["Status"] = "NeedsAction"; - } else if (incidence->status() == KCalCore::Incidence::StatusX) { - incidenceData["Status"] = "NonStandard"; - } else { - incidenceData["Status"] = "Unknown"; - } - incidenceData["StatusName"] = KCalUtils::Stringify::incidenceStatus( incidence->status() ); - - if (incidence->secrecy() == KCalCore::Incidence::SecrecyPublic) { - incidenceData["Secrecy"] = "Public"; - } else if (incidence->secrecy() == KCalCore::Incidence::SecrecyPrivate) { - incidenceData["Secrecy"] = "Private"; - } else if (incidence->secrecy() == KCalCore::Incidence::SecrecyConfidential) { - incidenceData["Secrecy"] = "Confidential"; - } else { - incidenceData["Secrecy"] = "Unknown"; - } - incidenceData["SecrecyName"] = KCalUtils::Stringify::secrecyName( incidence->secrecy() ); - incidenceData["Recurs"] = incidence->recurs(); - incidenceData["AllDay"] = incidence->allDay(); - incidenceData["Categories"] = incidence->categories(); - incidenceData["Resources"] = incidence->resources(); - incidenceData["DurationDays"] = incidence->duration().asDays(); - incidenceData["DurationSeconds"] = incidence->duration().asSeconds(); - - //TODO Attendees - //TODO Attachments - //TODO Relations - //TODO Alarms - //TODO Custom Properties - //TODO Lat/Lon - //TODO Collection/Source -} - - diff --git a/dataengines/calendar/plasma-dataengine-calendar.desktop b/dataengines/calendar/plasma-dataengine-calendar.desktop deleted file mode 100644 --- a/dataengines/calendar/plasma-dataengine-calendar.desktop +++ /dev/null @@ -1,159 +0,0 @@ -[Desktop Entry] -Name=Calendar -Name[ar]=التقويم -Name[be@latin]=Kalandar -Name[bg]=Календар -Name[bn]=ক্যালেণ্ডার -Name[bn_IN]=বর্ষপঞ্জি -Name[bs]=Kalendar -Name[ca]=Calendari -Name[ca@valencia]=Calendari -Name[cs]=Kalendář -Name[csb]=Kalãdôrz -Name[da]=Kalender -Name[de]=Kalender -Name[el]=Ημερολόγιο -Name[en_GB]=Calendar -Name[eo]=Kalendaro -Name[es]=Calendario -Name[et]=Kalender -Name[eu]=Egutegia -Name[fa]=تقویم -Name[fi]=Kalenteri -Name[fr]=Calendrier -Name[fy]=Aginda -Name[ga]=Féilire -Name[gl]=Calendario -Name[gu]=કેલેન્ડર -Name[he]=לוח שנה -Name[hi]=कैलेन्डर -Name[hne]=कलेन्डर -Name[hr]=Kalendar -Name[hsb]=Protyka -Name[hu]=Naptár -Name[ia]=Calendario -Name[id]=Kalender -Name[is]=Dagatal -Name[it]=Calendario -Name[ja]=カレンダー -Name[kk]=Күнтізбе -Name[km]=ប្រតិទិន -Name[kn]=ದಿನಸೂಚಿ -Name[ko]=달력 -Name[ku]=Salname -Name[lt]=Kalendorius -Name[lv]=Kalendārs -Name[mai]=कैलेंडर -Name[mk]=Календар -Name[ml]=കലണ്ടര്‍ -Name[mr]=दिनदर्शिका -Name[nb]=Kalender -Name[nds]=Kalenner -Name[nl]=Kalender -Name[nn]=Kalender -Name[pa]=ਕੈਲੰਡਰ -Name[pl]=Kalendarz -Name[pt]=Calendário -Name[pt_BR]=Calendário -Name[ro]=Calendar -Name[ru]=Календарь -Name[si]=දිනදර්ශනය -Name[sk]=Kalendár -Name[sl]=Koledar -Name[sr]=календар -Name[sr@ijekavian]=календар -Name[sr@ijekavianlatin]=kalendar -Name[sr@latin]=kalendar -Name[sv]=Kalender -Name[ta]=நாட்காட்டி -Name[tg]=Тақвим -Name[th]=ปฏิทิน -Name[tr]=Takvim -Name[ug]=يىلنامە -Name[uk]=Календар -Name[vi]=Lịch -Name[wa]=Calindrî -Name[x-test]=xxCalendarxx -Name[zh_CN]=日历 -Name[zh_TW]=行事曆 -Comment=Calendar data engine -Comment[ar]=محرّك بيانات التقويم -Comment[bg]=Ядро на календара -Comment[bs]=Kalendarski datomotor -Comment[ca]=Motor de dades de calendari -Comment[ca@valencia]=Motor de dades de calendari -Comment[cs]=Datový nástroj kalendáře -Comment[csb]=Kalãdôrz czérownika pòdôwków -Comment[da]=Datamtor til kalender -Comment[de]=Kalender-Datentreiber -Comment[el]=Μηχανή δεδομένων ημερολογίου -Comment[en_GB]=Calendar data engine -Comment[eo]=Kalendara datuma motoro -Comment[es]=Motor de datos del calendario -Comment[et]=Kalendri andmete mootor -Comment[eu]=Egutegiko datuen motorra -Comment[fi]=Kalenteritietomoottori -Comment[fr]=Moteur de données du calendrier -Comment[fy]=Kalinder gegevens motor -Comment[ga]=Inneall sonraí féilire -Comment[gl]=Motor de datos de calendario -Comment[gu]=કેલેન્ડર માહિતી એન્જિન -Comment[he]=מנוע תוכן לוחות שנה -Comment[hi]=कैलेन्डर डॉटा इंजन -Comment[hr]=Podatkovni mehanizam za kalendar -Comment[hu]=Naptárkezelő modul -Comment[ia]=Motor de datos de calendario -Comment[id]=Mesin data kalender -Comment[is]=Gagnavél fyrir dagatal -Comment[it]=Motore dei dati del calendario -Comment[ja]=カレンダー用データエンジン -Comment[kk]=Күнтізбе деректер тетігі -Comment[km]=ម៉ាស៊ីន​ទិន្នន័យ​ប្រតិទិន -Comment[kn]=ದಿನಸೂಚಿ ದತ್ತಾಂಶ ಸಾಧನ -Comment[ko]=달력 데이터 엔진 -Comment[lt]=Kalendoriaus duomenų variklis -Comment[lv]=Kalendāra datu dzinējs -Comment[mk]=Податочна машина за календари -Comment[ml]=കലണ്ടര്‍ ഡാറ്റ എഞ്ചിന്‍ -Comment[mr]=दिनदर्शिका डेटा इंजिन -Comment[nb]=Kalenderdata-motor -Comment[nds]=Kalenner-Datenkarn -Comment[nl]=Agendagegevensengine -Comment[nn]=Kalenderdatamotor -Comment[pa]=ਕੈਲੰਡਰ ਡਾਟਾ ਇੰਜਣ -Comment[pl]=Silnik danych kalendarza -Comment[pt]=Motor de dados do calendário -Comment[pt_BR]=Mecanismo de dados de calendário -Comment[ro]=Motor de date pentru calendar -Comment[ru]=Источник данных для календаря -Comment[si]=දිනදසුන් දත්ත එන්ජිම -Comment[sk]=Dátový nástroj kalendára -Comment[sl]=Podatkovni pogon s koledarskimi podatki -Comment[sr]=Календарски датомотор -Comment[sr@ijekavian]=Календарски датомотор -Comment[sr@ijekavianlatin]=Kalendarski datomotor -Comment[sr@latin]=Kalendarski datomotor -Comment[sv]=Datagränssnitt för kalendrar -Comment[tg]=Мудири тақвим -Comment[th]=ข้อมูลปฏิทินและกลไกจัดการ -Comment[tr]=Takvim veri motoru -Comment[ug]=يىلنامە سانلىق-مەلۇمات ماتورى -Comment[uk]=Рушій даних календаря -Comment[vi]=Cơ chế dữ liệu lịch biểu -Comment[wa]=Moteur di dnêyes do calindrî -Comment[x-test]=xxCalendar data enginexx -Comment[zh_CN]=日历数据引擎 -Comment[zh_TW]=行事曆資料引擎 -X-KDE-ServiceTypes=Plasma/DataEngine -Type=Service -Icon=office-calendar -X-KDE-Library=plasma_engine_calendar - -X-KDE-PluginInfo-Author=Davide Bettio -X-KDE-PluginInfo-Email=davide.bettio@kdemail.net -X-KDE-PluginInfo-Name=calendar -X-KDE-PluginInfo-Version=0.1 -X-KDE-PluginInfo-Website=http://plasma.kde.org/ -X-KDE-PluginInfo-Category= -X-KDE-PluginInfo-Depends= - diff --git a/dataengines/network/CMakeLists.txt b/dataengines/network/CMakeLists.txt deleted file mode 100644 --- a/dataengines/network/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_definitions(-DTRANSLATION_DOMAIN=\"plasma_engine_network\") - -set(network_engine_SRCS - networkengine.cpp -) - -add_library(plasma_engine_network MODULE ${network_engine_SRCS}) -target_link_libraries(plasma_engine_network KF5::CoreAddons KF5::Plasma solidcontrol) - -install(TARGETS plasma_engine_network DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) -install(FILES plasma-dataengine-network.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) - diff --git a/dataengines/network/Messages.sh b/dataengines/network/Messages.sh deleted file mode 100755 --- a/dataengines/network/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /usr/bin/env bash -$XGETTEXT *.cpp -o $podir/plasma_engine_network.pot diff --git a/dataengines/network/networkengine.h b/dataengines/network/networkengine.h deleted file mode 100644 --- a/dataengines/network/networkengine.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2007 Percy Leonhardt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef NETWORKENGINE_H -#define NETWORKENGINE_H - -#include - -namespace Solid -{ - namespace Control - { - class NetworkInterface; - class WirelessNetworkInterface; - } // namespace Control -} // namespace Solid - -class NetworkEngine : public Plasma::DataEngine -{ - Q_OBJECT - -public: - NetworkEngine(QObject* parent, const QVariantList& args); - ~NetworkEngine(); - - QStringList sources() const; - -protected: - bool sourceRequestEvent(const QString &name); - bool updateSourceEvent(const QString& source); - -private: - void updateWirelessData(const QString &source, const Solid::Control::WirelessNetworkInterface *iface); - void updateInterfaceData(const QString &source, const Solid::Control::NetworkInterface *iface); - - int m_secondsSinceLastUpdate; -}; - -K_EXPORT_PLASMA_DATAENGINE(network, NetworkEngine) - -#endif diff --git a/dataengines/network/networkengine.cpp b/dataengines/network/networkengine.cpp deleted file mode 100644 --- a/dataengines/network/networkengine.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2007 Percy Leonhardt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "networkengine.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -//#define SYSPATH "/sys/class/net/" - -NetworkEngine::NetworkEngine(QObject* parent, const QVariantList& args) - : Plasma::DataEngine(parent, args), - m_secondsSinceLastUpdate(0) -{ - Q_UNUSED(args) - setMinimumPollingInterval(1000); -} - -NetworkEngine::~NetworkEngine() -{ -} - -QStringList NetworkEngine::sources() const -{ - Solid::Control::NetworkInterfaceList iflist = Solid::Control::NetworkManager::networkInterfaces(); - - QStringList availableInterfaces; - foreach (Solid::Control::NetworkInterface *iface, iflist) { - availableInterfaces.append(iface->uni().section('/', -1)); - } - return availableInterfaces; -} - -bool NetworkEngine::sourceRequestEvent(const QString &name) -{ - Solid::Control::NetworkInterfaceList iflist = Solid::Control::NetworkManager::networkInterfaces(); - - foreach(Solid::Control::NetworkInterface *iface, iflist) { - if (name == iface->uni().section('/', -1)) { - setData(name, DataEngine::Data()); - setData(name, I18N_NOOP("UNI"), iface->uni()); - updateSourceEvent(name); - return true; - } - } - return false; -} - -bool NetworkEngine::updateSourceEvent(const QString &source) -{ - const QString uni = query(source)[I18N_NOOP("UNI")].toString(); - Solid::Control::NetworkInterface *iface = Solid::Control::NetworkManager::findNetworkInterface(uni); - if (!iface) { - // remove the source as the interface is no longer available - removeSource(source); - return false; - } - - // Check if it is a wireless interface. - bool isWireless = iface->type() == Solid::Control::NetworkInterface::Ieee80211; - setData(source, I18N_NOOP("Wireless"), isWireless); - Solid::Control::WirelessNetworkInterface *wlan = 0; - - if (isWireless) { - wlan = static_cast(iface); - - QStringList availableNetworks; - Solid::Control::AccessPointList apList = wlan->accessPoints(); - foreach (const QString &apId, apList) { - Solid::Control::AccessPoint *ap = wlan->findAccessPoint(apId); - availableNetworks += ap->ssid(); - } - setData(source, I18N_NOOP("Available networks"), availableNetworks); - } - - Solid::Control::NetworkInterface::ConnectionState connectionState = iface->connectionState(); - if (connectionState == Solid::Control::NetworkInterface::Activated) { - // update the interface - updateInterfaceData(source, iface); - if (isWireless) { - updateWirelessData(source, wlan); - } - } else if (connectionState != Solid::Control::NetworkInterface::Activated && - query(source)[I18N_NOOP("ConnectionState")].toString() == I18N_NOOP("Activated")) { - // the interface was disconnected - removeAllData(source); - setData(source, I18N_NOOP("UNI"), uni); - } - - switch (connectionState) { - case Solid::Control::NetworkInterface::Preparing: - setData(source, I18N_NOOP("ConnectionState"), "Preparing"); - break; - case Solid::Control::NetworkInterface::Configuring: - setData(source, I18N_NOOP("ConnectionState"), "Configuring"); - break; - case Solid::Control::NetworkInterface::NeedAuth: - setData(source, I18N_NOOP("ConnectionState"), "NeedAuth"); - break; - case Solid::Control::NetworkInterface::IPConfig: - setData(source, I18N_NOOP("ConnectionState"), "IPConfig"); - break; - case Solid::Control::NetworkInterface::Activated: - setData(source, I18N_NOOP("ConnectionState"), "Activated"); - break; - case Solid::Control::NetworkInterface::Failed: - setData(source, I18N_NOOP("ConnectionState"), "Failed"); - break; - case Solid::Control::NetworkInterface::Unmanaged: - setData(source, I18N_NOOP("ConnectionState"), "Unmanaged"); - break; - case Solid::Control::NetworkInterface::Unavailable: - setData(source, I18N_NOOP("ConnectionState"), "Unavailable"); - break; - default: - setData(source, I18N_NOOP("ConnectionState"), "UnknownState"); - break; - } - return true; -} - -void NetworkEngine::updateInterfaceData(const QString &source, const Solid::Control::NetworkInterface *iface) -{ - Q_ASSERT(iface); - Solid::Control::IPv4Config network = iface->ipV4Config(); - -#if 0 - if (network.isValid()) { - setData(source, I18N_NOOP("Broadcast"), network.broadcast()); - } else { - removeData(source, I18N_NOOP("Broadcast")); - } -#endif - - QList addresses = network.addresses(); - if (addresses.isEmpty()) { - removeData(source, I18N_NOOP("Gateway")); - removeData(source, I18N_NOOP("IP")); - removeData(source, I18N_NOOP("Subnet mask")); - } else { - // FIXME: assumes there is only one network for ethernet - Solid::Control::IPv4Address address = addresses[0]; - setData(source, I18N_NOOP("Gateway"), address.gateway()); - setData(source, I18N_NOOP("IP"), address.address()); - setData(source, I18N_NOOP("Subnet mask"), address.netMask()); - } -} - -void NetworkEngine::updateWirelessData(const QString &source, const Solid::Control::WirelessNetworkInterface *iface) -{ - Q_ASSERT(iface); - const QString currentAP = iface->activeAccessPoint(); - - using namespace Solid::Control; - AccessPoint *ap = iface->findAccessPoint(currentAP); - WirelessNetworkInterface::OperationMode mode(WirelessNetworkInterface::Unassociated); - WirelessNetworkInterface::Capabilities capabilities(WirelessNetworkInterface::NoCapability); - - if (ap) { - setData(source, I18N_NOOP("Link quality"), ap->signalStrength()); - setData(source, I18N_NOOP("Frequency"), ap->frequency()); - setData(source, I18N_NOOP("ESSID"), ap->ssid()); - setData(source, I18N_NOOP("Bitrate"), ap->maxBitRate()); - setData(source, I18N_NOOP("Accesspoint"), ap->hardwareAddress()); - mode = ap->mode(); - } else { - setData(source, I18N_NOOP("Accesspoint"), i18n("None")); - removeData(source, I18N_NOOP("Link quality")); - removeData(source, I18N_NOOP("Frequency")); - removeData(source, I18N_NOOP("ESSID")); - removeData(source, I18N_NOOP("Bitrate")); - } - - switch (mode) { - case WirelessNetworkInterface::Unassociated: - setData(source, I18N_NOOP("Mode"), "Unassociated"); - break; - case WirelessNetworkInterface::Adhoc: - setData(source, I18N_NOOP("Mode"), "Adhoc"); - break; - case WirelessNetworkInterface::Managed: - setData(source, I18N_NOOP("Mode"), "Managed"); - break; - case WirelessNetworkInterface::Master: - setData(source, I18N_NOOP("Mode"), "Master"); - break; - case WirelessNetworkInterface::Repeater: - setData(source, I18N_NOOP("Mode"), "Repeater"); - break; - default: - setData(source, I18N_NOOP("Mode"), i18n("Unknown")); - break; - } - - setData(source, I18N_NOOP("Encryption"), - (capabilities & Solid::Control::AccessPoint::Privacy) != 0); -} - - diff --git a/dataengines/network/plasma-dataengine-network.desktop b/dataengines/network/plasma-dataengine-network.desktop deleted file mode 100644 --- a/dataengines/network/plasma-dataengine-network.desktop +++ /dev/null @@ -1,181 +0,0 @@ -[Desktop Entry] -Name=Networking -Name[ar]=الشبكة -Name[be@latin]=Sietka -Name[bg]=Мрежа -Name[bn]=নেটওয়ার্কিং -Name[bn_IN]=নেটওয়ার্ক ব্যবস্থা -Name[bs]=Umrežavanje -Name[ca]=Treball en xarxa -Name[ca@valencia]=Treball en xarxa -Name[cs]=Síťové nástroje -Name[csb]=Séc -Name[da]=Netværk -Name[de]=Netzwerk -Name[el]=Δίκτυο -Name[en_GB]=Networking -Name[eo]=Reto -Name[es]=Red -Name[et]=Võrk -Name[eu]=Sarea -Name[fi]=Verkkotyöskentely -Name[fr]=Réseau -Name[fy]=netwurkjen -Name[ga]=Líonrú -Name[gl]=Rede -Name[gu]=નેટવર્કિંગ -Name[he]=רשת -Name[hi]=नेटवर्किंग -Name[hne]=नेटवर्किंग -Name[hr]=Mreža -Name[hu]=Hálózatkezelő -Name[ia]=Networking (A proposito del rete) -Name[id]=Jaringan -Name[is]=Netvinnsla -Name[it]=Rete -Name[ja]=ネットワーキング -Name[kk]=Желі -Name[km]=ការ​តបណ្ដាញ -Name[kn]=ಜಾಲಬಂಧ -Name[ko]=네트워킹 -Name[ku]=Têketina Torê -Name[lt]=Tinklas -Name[lv]=Tīkls -Name[mai]=नेटवर्किंग -Name[mk]=Мрежа -Name[ml]=ശൃംഖല -Name[mr]=नेटवर्कींग -Name[nb]=Nettverk -Name[nds]=Nettwark -Name[nl]=Netwerken -Name[nn]=Nettverk -Name[or]=ନେଟୱର୍କିଙ୍ଗ -Name[pa]=ਨੈੱਟਵਰਕਿੰਗ -Name[pl]=Sieć -Name[pt]=Rede -Name[pt_BR]=Rede -Name[ro]=Rețea -Name[ru]=Сеть -Name[si]=ජාලය -Name[sk]=Sieť -Name[sl]=Povezovanje -Name[sr]=умрежавање -Name[sr@ijekavian]=умрежавање -Name[sr@ijekavianlatin]=umrežavanje -Name[sr@latin]=umrežavanje -Name[sv]=Nätverk -Name[ta]=பிணையம் -Name[tg]=Шабака -Name[th]=ระบบเครือข่าย -Name[tr]=Ağ -Name[ug]=تور -Name[uk]=Робота у мережі -Name[wa]=Rantoelaedje -Name[x-test]=xxNetworkingxx -Name[zh_CN]=网络 -Name[zh_TW]=網路 -Comment=Network interface information -Comment[af]=Netwerk koppelvlak informasie -Comment[ar]=معلومات واجهة الشبكة -Comment[as]=নে'টৱৰ্ক সংযোগমাধ্যমৰ তথ্য -Comment[be]=Звесткі пра сеткавы інтэрфейс -Comment[be@latin]=Źviestki pra sietkavyja interfejsy -Comment[bg]=Данни за мрежовите интерфейси -Comment[bn]=নেটওয়ার্ক ইন্টারফেস সংক্রান্ত তথ্য -Comment[bn_IN]=নেটওয়ার্ক ইন্টারফেস সংক্রান্ত তথ্য -Comment[br]=Titouroù diwar-benn an etrefasoù rouedad -Comment[bs]=Podaci o mrežnom sučelju -Comment[ca]=Informació de la interfície de xarxa -Comment[ca@valencia]=Informació de la interfície de xarxa -Comment[cs]=Informace o síťových rozhraních -Comment[csb]=Wëdowiédzô ò sécowim interfejse -Comment[cy]=Gwybodaeth rhyngwynebau rhwydwaith -Comment[da]=Information om netværksgrænseflade -Comment[de]=Informationen zu Netzwerkschnittstellen -Comment[el]=Πληροφορίες διεπαφών δικτύου -Comment[en_GB]=Network interface information -Comment[eo]=Informoj pri retinterfaco -Comment[es]=Información sobre la interfaz de red -Comment[et]=Võrguliideste info -Comment[eu]=Sare-interfazeari buruzko informazioa -Comment[fa]=اطلاعات واسط شبکه -Comment[fi]=Verkkoliityntöjen tiedot -Comment[fr]=Informations sur les interfaces réseau -Comment[fy]=Netwurkynterface-ynformaasje -Comment[ga]=Eolas faoin gcomhéadan líonra -Comment[gl]=Información da interface de rede -Comment[gu]=નેટવર્ક ઇન્ટરફેસ માહિતી -Comment[he]=מידע על ממשקי רשת -Comment[hi]=नेटवर्क इंटरफेस जानकारी -Comment[hne]=नेटवर्क इंटरफेस जानकारी -Comment[hr]=Podaci o mrežnom sučelju -Comment[hsb]=Informacija wo syćowych interfejsach -Comment[hu]=A hálózati kártyák jellemzői -Comment[ia]=Information de interfacie de rete -Comment[id]=Informasi antarmuka jaringan -Comment[is]=Upplýsingar um netkort -Comment[it]=Informazioni sulle interfacce di rete -Comment[ja]=ネットワークインターフェースの情報 -Comment[ka]=ცნობები ქსელური ინტერფეისების შესახებ -Comment[kk]=Желі интерфейсінің мәліметі -Comment[km]=ព័ត៌មាន​ចំណុច​ប្រទាក់​បណ្ដាញ -Comment[kn]=ಜಾಲ ಸಂಪರ್ಕತಟಗಳ (ಇಂಟರ್ಫೇಸ್) ಮಾಹಿತಿ -Comment[ko]=네트워크 인터페이스 정보 -Comment[ku]=Agahiyên navrûyên torê -Comment[lt]=Tinklo sąsajos informacija -Comment[lv]=Tīkla ierīču informācija -Comment[mai]=नेटवर्क इंटरफेस सूचना -Comment[mk]=Информации за мрежните интерфејси -Comment[ml]=ശൃഖലാ വിനിമയതലങ്ങളെക്കുറിച്ചുള്ള വിവരം -Comment[mr]=संजाळ दुवा माहिती -Comment[ms]=Maklumat antara muka rangkaian -Comment[nb]=Informasjon om nettverksgrensesnitt -Comment[nds]=Informatschoon över de Nettwark-Koppelsteden -Comment[ne]=सञ्जाल इन्टरफेस सूचना -Comment[nl]=Netwerkinterface-informatie -Comment[nn]=Informasjon om nettverksgrensesnitt -Comment[or]=ନେଟୱର୍କ ଅନ୍ତାରାପୃଷ୍ଠ ସୂଚନା -Comment[pa]=ਨੈੱਟਵਰਕ ਇੰਟਰਫੇਸ ਜਾਣਕਾਰੀ -Comment[pl]=Wyświetla informacje o interfejsach sieciowych -Comment[pt]=Informações sobre as interfaces de rede -Comment[pt_BR]=Informações da interface de rede -Comment[ro]=Afișează informații despre interfețele de rețea -Comment[ru]=Сведения о сетевых интерфейсах -Comment[se]=Fierbmalaktadiehtu -Comment[si]=ජාල මුහුණත් තොරතුරු -Comment[sk]=Informácie o sieťových rozhraniach -Comment[sl]=Podatki o omrežnih vmesnikih -Comment[sr]=Подаци о мрежним сучељима -Comment[sr@ijekavian]=Подаци о мрежним сучељима -Comment[sr@ijekavianlatin]=Podaci o mrežnim sučeljima -Comment[sr@latin]=Podaci o mrežnim sučeljima -Comment[sv]=Information om nätverksgränssnitt -Comment[ta]=பிணைய இடைமுகப்பு தகவல் -Comment[te]=నెట్వర్క్ ఇంటర్ ఫెస్ సమాచారం -Comment[tg]=Иттилооти воситаҳои шабака -Comment[th]=ข้อมูลแผงวงจรเครือข่าย -Comment[tr]=Ağ arayüz bilgisi -Comment[ug]=تور ئارايۈز ئۇچۇرلىرى -Comment[uk]=Інформація щодо інтерфейсів мережі -Comment[uz]=Tarmoq interfeyslari haqida maʼlumot -Comment[uz@cyrillic]=Тармоқ интерфейслари ҳақида маълумот -Comment[vi]=Thông tin giao diện mạng -Comment[wa]=Informåcion so l' eterface rantoele -Comment[xh]=Ulwazi lojongano lomsebenzi womnatha -Comment[x-test]=xxNetwork interface informationxx -Comment[zh_CN]=网络接口信息 -Comment[zh_TW]=網路界面資訊 -Icon=network-workgroup - -Type=Service -X-KDE-ServiceTypes=Plasma/DataEngine -X-KDE-Library=plasma_engine_network - -X-KDE-PluginInfo-Author= -X-KDE-PluginInfo-Email= -X-KDE-PluginInfo-Name=network -X-KDE-PluginInfo-Version= -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category= -X-KDE-PluginInfo-Depends= - diff --git a/dataengines/rss/CMakeLists.txt b/dataengines/rss/CMakeLists.txt deleted file mode 100644 --- a/dataengines/rss/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -add_definitions(-DTRANSLATION_DOMAIN=\"plasma_engine_rss\") - -include_directories(${Boost_INCLUDE_DIR} ${KDEPIMLIBS_INCLUDE_DIR}) - -set(rss_engine_SRCS - rss.cpp -) - -add_library(plasma_engine_rss MODULE ${rss_engine_SRCS}) -target_link_libraries(plasma_engine_rss KF5::Plasma KF5::CoreAddons ${KDE4_SYNDICATION_LIBS} KF5::Solid) - -install(TARGETS plasma_engine_rss DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) -install(FILES plasma-dataengine-rss.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) - diff --git a/dataengines/rss/Messages.sh b/dataengines/rss/Messages.sh deleted file mode 100755 --- a/dataengines/rss/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /usr/bin/env bash -$XGETTEXT *.cpp -o $podir/plasma_engine_rss.pot diff --git a/dataengines/rss/plasma-dataengine-rss.desktop b/dataengines/rss/plasma-dataengine-rss.desktop deleted file mode 100644 --- a/dataengines/rss/plasma-dataengine-rss.desktop +++ /dev/null @@ -1,162 +0,0 @@ -[Desktop Entry] -Name=RSS -Name[be@latin]=RSS -Name[bg]=RSS -Name[bn]=RSS -Name[bn_IN]=RSS -Name[bs]=RSS -Name[ca]=RSS -Name[ca@valencia]=RSS -Name[cs]=RSS -Name[da]=RSS -Name[de]=RSS -Name[el]=RSS -Name[en_GB]=RSS -Name[eo]=RSS -Name[es]=RSS -Name[et]=RSS -Name[eu]=RSS -Name[fi]=RSS -Name[fr]=RSS -Name[fy]=RSS -Name[ga]=RSS -Name[gl]=RSS -Name[gu]=RSS -Name[he]=RSS -Name[hi]=आरएसएस -Name[hne]=आरएसएस -Name[hr]=RSS -Name[hu]=RSS-hírek -Name[ia]=RSS -Name[id]=RSS -Name[is]=RSS -Name[it]=RSS -Name[ja]=RSS -Name[ka]=RSS -Name[kk]=RSS -Name[km]=RSS -Name[kn]=RSS -Name[ko]=RSS -Name[ku]=RSS -Name[lt]=RSS -Name[lv]=RSS -Name[mai]=RSS -Name[mk]=RSS -Name[ml]=ആര്‍എസ്എസ് -Name[mr]=RSS -Name[nb]=RSS -Name[nds]=RSS -Name[nl]=RSS -Name[nn]=RSS -Name[or]=RSS -Name[pa]=RSS -Name[pl]=RSS -Name[pt]=RSS -Name[pt_BR]=RSS -Name[ro]=RSS -Name[ru]=Ленты новостей RSS -Name[si]=RSS -Name[sk]=RSS -Name[sl]=RSS -Name[sr]=РСС -Name[sr@ijekavian]=РСС -Name[sr@ijekavianlatin]=RSS -Name[sr@latin]=RSS -Name[sv]=RSS -Name[ta]=RSS -Name[te]=RSS -Name[tg]=Наворҳои RSS -Name[th]=หัวข้อข่าว (RSS) -Name[tr]=RSS -Name[ug]=RSS -Name[uk]=RSS -Name[wa]=RSS -Name[x-test]=xxRSSxx -Name[zh_CN]=RSS -Name[zh_TW]=RSS -Comment=RSS News Data Engine -Comment[ar]=محرّك بيانات أخبار RSS -Comment[be@latin]=Systema navinaŭ z žarołaŭ „RSS” -Comment[bg]=Зареждане на RSS емисии -Comment[bn_IN]=RSS খবরের ডাটা ইঞ্জিন -Comment[bs]=Datomotor RSS vesti -Comment[ca]=Motor de dades de notícies RSS -Comment[ca@valencia]=Motor de dades de notícies RSS -Comment[cs]=Služba RSS novinek -Comment[csb]=Mòtór pòdôwków dlô pòwrózków RSS -Comment[da]=Datamotor til RSS-nyheder -Comment[de]=Datentreiber für RSS-News -Comment[el]=Μηχανή δεδομένων ειδήσεων RSS -Comment[en_GB]=RSS News Data Engine -Comment[eo]=Datuma Motoro de RSS novaĵoj -Comment[es]=Motor de RSS -Comment[et]=RSS-voogude andmete mootor -Comment[eu]=RSS berrien datu-motorra -Comment[fi]=RSS-syötetietomoottori -Comment[fr]=Moteur de données des flux RSS -Comment[fy]=RSS nijs gegevens motor -Comment[ga]=Inneall Sonraí Nuachta RSS -Comment[gl]=Motor de datos de novas RSS -Comment[gu]=RSS સમાચાર માહિતી એન્જિન -Comment[he]=מנוע תוכן חדשות RSS -Comment[hi]=आरएसएस समाचार डाटा इंजिन -Comment[hne]=आरएसएस समाचार डाटा इंजन -Comment[hr]=Podatkovni mehanizam za vijesti preko RSS-a -Comment[hu]=RSS-hírkezelő -Comment[ia]=Motor de datos de novitates RSS -Comment[id]=Mesin Data Berita RSS -Comment[is]=RSS fréttagagnavél -Comment[it]=Motore di dati delle notizie RSS -Comment[ja]=RSS ニュースデータエンジン -Comment[kk]=RSS ақпарлар тетігі -Comment[km]=ម៉ាស៊ីន​ទិន្នន័យព័ត៌មាន RSS -Comment[kn]=RSS ಸುದ್ದಿ ದತ್ತಾಂಶ ಎಂಜಿನ್ -Comment[ko]=RSS 뉴스 데이터 엔진 -Comment[ku]=Motora Dane yên Nûçe yên RSS -Comment[lt]=RSS naujienų duomenų variklis -Comment[lv]=RSS ziņu datu dzinējs -Comment[ml]=ആര്‍എസ്എസ് ന്യൂസ് ഡേറ്റാ എഞ്ചിന്‍ -Comment[mr]=RSS समाचार डेटा इंजिन -Comment[nb]=RSS nyhets-datamotor -Comment[nds]=RSS-Stroom-Datenkarn -Comment[nl]=RSS-nieuws (gegevensengine) -Comment[nn]=Nyheitsmotor for RSS -Comment[or]=RSS ଖବର ତଥ୍ୟ ଯନ୍ତ୍ର -Comment[pa]=RSS ਖ਼ਬਰਾਂ ਡਾਟਾ ਇੰਜਣ -Comment[pl]=Silnik danych wiadomości RSS -Comment[pt]=Motor de Dados de Notícias RSS -Comment[pt_BR]=Mecanismo de dados de notícias RSS -Comment[ro]=Motor de date pentru știri RSS -Comment[ru]=Показ новостей из лент RSS -Comment[si]=RSS ප්‍රවෘත්ති දත්ත එන්ජිම -Comment[sk]=Dátový nástroj RSS noviniek -Comment[sl]=Podatkovni pogon za novice RSS -Comment[sr]=Датомотор РСС вести -Comment[sr@ijekavian]=Датомотор РСС вести -Comment[sr@ijekavianlatin]=Datomotor RSS vesti -Comment[sr@latin]=Datomotor RSS vesti -Comment[sv]=Datagränssnitt för RSS-nyheter -Comment[ta]=RSS News Data Engine -Comment[tg]=Поставщик лент RSS -Comment[th]=กลไกข้อมูล รับหัวข้อข่าว (RSS) -Comment[tr]=RSS Haber Veri Motoru -Comment[ug]=RSS خەۋەر سانلىق-مەلۇمات ماتورى -Comment[uk]=Рушій даних новин RSS -Comment[wa]=Moteur di dnêyes des noveles RSS -Comment[x-test]=xxRSS News Data Enginexx -Comment[zh_CN]=RSS 新闻数据引擎 -Comment[zh_TW]=RSS 新聞資料引擎 -Icon=application-rss+xml - -Type=Service -X-KDE-ServiceTypes=Plasma/DataEngine -X-KDE-Library=plasma_engine_rss - -X-KDE-PluginInfo-Author= -X-KDE-PluginInfo-Email= -X-KDE-PluginInfo-Name=rss -X-KDE-PluginInfo-Version= -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category= -X-KDE-PluginInfo-Depends= - diff --git a/dataengines/rss/rss.h b/dataengines/rss/rss.h deleted file mode 100644 --- a/dataengines/rss/rss.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2007 Aaron Seigo - * Copyright (C) 2007 Petri Damsten - * Copyright (C) 2008 Rob Scheepmaker - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RSS_DATAENGINE_H -#define RSS_DATAENGINE_H - -#include -#include -#include -#include -#include -#include - -class QDBusInterface; -class QSignalMapper; - -/** - * This class can be used to fetch one or more rss feeds. By - * requesting a datasource with the url's of one or more rss - * feeds separated by " ", you will receive a merged list - * containing the items of all feeds requested. This list is - * sorted by timestamp. - * This class also fetches the favicons from all requested - * feeds. - */ -class RssEngine : public Plasma::DataEngine -{ - Q_OBJECT - - public: - RssEngine(QObject* parent, const QVariantList& args); - ~RssEngine() override; - - protected: - bool sourceRequestEvent(const QString &name); - bool updateSourceEvent(const QString& name); - - protected Q_SLOTS: - void processRss(Syndication::Loader* loader, - Syndication::FeedPtr feed, - Syndication::ErrorCode error); - void slotFavIconResult(KJob *job); - void timeout(const QString & source); - void networkStatusChanged(Solid::Networking::Status status); - - private: - QVariantList mergeFeeds(QString source) const; - void updateFeeds(const QString & source, - const QString & title); - bool cachesUpToDate(const QString & source) const; - - QHash m_feedMap; - QHash m_sourceMap; - QHash m_timerMap; - QHash m_feedItems; - QHash m_feedIcons; - QHash m_feedTitles; - QHash m_feedTimes; - bool m_forceUpdate; - - QVariantList m_rssSources; - QSet m_rssSourceNames; - - QSignalMapper * m_signalMapper; -}; - -K_EXPORT_PLASMA_DATAENGINE(rss, RssEngine) - -#endif - diff --git a/dataengines/rss/rss.cpp b/dataengines/rss/rss.cpp deleted file mode 100644 --- a/dataengines/rss/rss.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (C) 2007 Aaron Seigo - * Copyright (C) 2007 Petri Damsten - * Copyright (C) 2008 Rob Scheepmaker - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -//Own -#include "rss.h" - -//KDE -#include -#include -#include -#include -#include -#include -#include -#include - -//Plasma -#include - -//Qt -#include -#include -#include -#include -#include - -#define TIMEOUT 15000 //timeout before updating the source if not all feeds - //are fetched. -#define CACHE_TIMEOUT 60 //time in seconds before the cached feeds are marked - //as out of date. -#define MINIMUM_INTERVAL 60000 - -RssEngine::RssEngine(QObject* parent, const QVariantList& args) - : Plasma::DataEngine(parent, args), - m_forceUpdate(false) -{ - Q_UNUSED(args) - setMinimumPollingInterval(MINIMUM_INTERVAL); - m_signalMapper = new QSignalMapper(this); - connect(m_signalMapper, SIGNAL(mapped(QString)), - this, SLOT(timeout(QString))); - connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)), - SLOT(networkStatusChanged(Solid::Networking::Status))); - -} - -RssEngine::~RssEngine() -{ -} - -void RssEngine::networkStatusChanged(Solid::Networking::Status status) -{ - if (status == Solid::Networking::Connected || status == Solid::Networking::Unknown) { - qDebug() << "network connected, force refreshing feeds in 3 seconds"; - // The forced update needs to happen after the new feeds are in, - // so remember to force the update in processRss() - m_forceUpdate = true; - // start updating the feeds - foreach(const QString &feedUrl, sources()) { - updateSourceEvent(feedUrl); - } - } -} - -bool RssEngine::updateSourceEvent(const QString &name) -{ - /* Plasmoids using this engine should be able to retrieve - * multiple feeds at the same time, so we allow a comma - * separated list of url's - */ - // NOTE: A comma separated list of feeds is not url compliant. Urls - // may and do contain commas see http://www.spiegel.de/schlagzeilen/rss/0,5291,,00.xml - // I have changed it to something more not url compliant " " three dots - // Otherwise take a list instead - const QStringList sources = name.split(' ', QString::SkipEmptyParts); - - foreach (const QString& source, sources) { - setStorageEnabled(source, true); - // Let's first see if we've got a recent cached version of - // the feed. This avoids 'large' amounts of unnecessary network - // traffic. - if (QDateTime::currentDateTime() > - m_feedTimes[source.toLower()].addSecs(CACHE_TIMEOUT)){ - qDebug() << "Cache from " << source << - " older than 60 seconds, refreshing..."; - - Syndication::Loader * loader = Syndication::Loader::create(); - connect(loader, SIGNAL(loadingComplete(Syndication::Loader*, - Syndication::FeedPtr, - Syndication::ErrorCode)), - this, SLOT(processRss(Syndication::Loader*, - Syndication::FeedPtr, - Syndication::ErrorCode))); - - m_feedMap.insert(loader, source); - m_sourceMap.insert(loader, name); - loader->loadFrom(source); - } else { - qDebug() << "Recent cached version of " << source << - " found. Skipping..."; - - // We might want to update the source: - if (cachesUpToDate(name)) { - updateFeeds(name, m_feedTitles[ source ] ); - } - } - } - - QTimer *timer = new QTimer(this); - m_timerMap[name] = timer; - timer->setSingleShot(true); - m_signalMapper->setMapping(timer, name); - - connect(timer, SIGNAL(timeout()), m_signalMapper, SLOT(map())); - - timer->start(TIMEOUT); - return true; -} - -void RssEngine::slotFavIconResult(KJob *kjob) -{ - KIO::FavIconRequestJob *job = static_cast(kjob); - const QString iconFile = job->iconFile(); - const QString url = job->hostUrl().toLower(); - - m_feedIcons[url] = iconFile; - QMap map; - - for (int i = 0; i < m_feedItems[url].size(); i++) { - map = m_feedItems[url].at(i).toMap(); - map["icon"] = iconFile; - m_feedItems[url].replace(i, map); - } - - //Are there sources ready to get updated now? - foreach (const QString& source, m_sourceMap) { - if (source.contains(url, Qt::CaseInsensitive) && - cachesUpToDate(source)) { - qDebug() << "all caches from source " << source << - " up to date, updating..."; - updateFeeds(source, m_feedTitles[ source ] ); - } - } -} - -void RssEngine::timeout(const QString & source) -{ - qDebug() << "timout fired, updating source"; - updateFeeds(source, m_feedTitles[ source ] ); - m_signalMapper->removeMappings(m_timerMap[source]); -} - -bool RssEngine::sourceRequestEvent(const QString &name) -{ - setData(name, DataEngine::Data()); - updateSourceEvent(name); - return true; -} - -void RssEngine::processRss(Syndication::Loader* loader, - Syndication::FeedPtr feed, - Syndication::ErrorCode error) -{ - const QString url = m_feedMap.take(loader); - const QString source = m_sourceMap.take(loader); - QString title; - bool iconRequested = false; - KUrl u(url); - - if (error != Syndication::Success) { - qDebug() << "Syndication did not work out... url = " << url; - title = i18n("Syndication did not work out"); - setData(source, "title", i18n("Fetching feed failed.")); - setData(source, "link", url); - } else { - title = feed->title(); - QVariantList items; - QString location; - - foreach (const Syndication::ItemPtr& item, feed->items()) { - QMap dataItem; - - //some malformed rss feeds can have empty entries - if (item->title().isNull() && item->description().isNull() && dataItem["content"].isNull()) { - continue; - } - - dataItem["title"] = item->title(); - dataItem["feed_title"] = feed->title(); - dataItem["link"] = item->link(); - dataItem["feed_url"] = url; - dataItem["description"] = item->description(); - dataItem["content"] = item->content(); - dataItem["time"] = (uint)item->dateUpdated(); - if (!m_feedIcons.contains(url.toLower()) && !iconRequested) { - //lets request an icon, and only do this once per feed. - KIO::FavIconRequestJob *job = new KIO::FavIconRequestJob(u); - connect(job, &KIO::FavIconRequestJob::result, this, &RssEngine::slotFavIconResult); - iconRequested = true; - } - dataItem["icon"] = m_feedIcons[url.toLower()]; - QStringList authors; - foreach (const boost::shared_ptr a, item->authors()) { - authors << a->name(); - } - dataItem["author"] = authors; - - items.append(dataItem); - - - if (!m_rssSourceNames.contains(url)) { - QMap sourceItem; - - sourceItem["feed_title"] = feed->title(); - sourceItem["feed_url"] = url; - sourceItem["icon"] = m_feedIcons[url.toLower()]; - - m_rssSources.append(sourceItem); - m_rssSourceNames.insert(url); - } - } - m_feedItems[url.toLower()] = items; - m_feedTimes[url.toLower()] = QDateTime::currentDateTime(); - m_feedTitles[url.toLower()] = title; - - // If we update the feeds every time a feed is fetched, - // only the first update will actually update a connected - // applet, which is actually sane, since plasma updates - // only one time each interval. This means, however, that - // we maybe want to delay updating the feeds untill either - // timeout, or all feeds are up to date. - if (cachesUpToDate(source)) { - qDebug() << "all caches from source " << source - << " up to date, updating..."; - updateFeeds(source, title); - if (m_forceUpdate) { - // Should be used with care ... - forceImmediateUpdateOfAllVisualizations(); - m_forceUpdate = false; - // and skip scheduleSourcesUpdated(), since we - // force a repaint anyway already - return; - } - } else { - qDebug() << "not all caches from source " << source - << ", delaying update."; - } - scheduleSourcesUpdated(); - } -} - -void RssEngine::updateFeeds(const QString & source, const QString & title) -{ - /** - * TODO: can this be improved? I'm calling mergeFeeds way too - * often here... - */ - const QVariantList list = mergeFeeds(source); - setData(source, "items", list); - - setData(source, "sources", m_rssSources); - const QStringList sourceNames = source.split(' ', QString::SkipEmptyParts); - if (sourceNames.size() > 1) { - setData(source, "title", i18np("1 RSS feed fetched", - "%1 RSS feeds fetched", sourceNames.size())); - } else { - setData(source, "title", title); - } -} - -bool RssEngine::cachesUpToDate(const QString & source) const -{ - const QStringList sources = source.split(' ', QString::SkipEmptyParts); - bool outOfDate = false; - foreach (const QString &url, sources) { - if (QDateTime::currentDateTime() > - m_feedTimes[url.toLower()].addSecs(CACHE_TIMEOUT)){ - outOfDate = true; - } - if (!m_feedIcons.contains(url.toLower())) { - outOfDate = true; - } - } - return (!outOfDate); -} - -bool compare(const QVariant &v1, const QVariant &v2) -{ - return v1.toMap()["time"].toUInt() > v2.toMap()["time"].toUInt(); -} - -QVariantList RssEngine::mergeFeeds(QString source) const -{ - QVariantList result; - const QStringList sources = source.split(' ', QString::SkipEmptyParts); - - foreach (const QString& feed, sources) { - result += m_feedItems[feed.toLower()]; - } - - qSort(result.begin(), result.end(), compare); - return result; -} - -