Commit ea7ebab3 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove unused resources

parent d3efe0df
......@@ -79,14 +79,11 @@ add_subdirectory( contacts )
add_subdirectory( dav )
add_subdirectory( ical )
add_subdirectory( imap )
add_subdirectory( kdeaccounts )
if (KF5Kolab_FOUND AND Libkolabxml_FOUND)
add_subdirectory( kolabproxy )
add_subdirectory( kolab )
endif()
add_subdirectory( localbookmarks )
add_subdirectory( maildir )
add_subdirectory( openxchange )
......
########### next target ###############
add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_kdeaccounts_resource\")
set( kdeaccountsresource_SRCS
kdeaccountsresource.cpp
)
install( FILES kdeaccountsresource.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents" )
kconfig_add_kcfg_files(kdeaccountsresource_SRCS settings.kcfgc)
kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/kdeaccountsresource.kcfg org.kde.Akonadi.KDEAccounts.Settings)
qt5_add_dbus_adaptor(kdeaccountsresource_SRCS
${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.KDEAccounts.Settings.xml settings.h Settings
)
add_executable(akonadi_kdeaccounts_resource ${kdeaccountsresource_SRCS})
if( APPLE )
set_target_properties(akonadi_kdeaccounts_resource PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../Info.plist.template)
set_target_properties(akonadi_kdeaccounts_resource PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Akonadi.KDEAccounts")
set_target_properties(akonadi_kdeaccounts_resource PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "KDE Akonadi KDEAccounts Resource")
endif ()
target_link_libraries(akonadi_kdeaccounts_resource KF5::AkonadiCore KF5::Contacts KF5::KIOCore KF5::AkonadiAgentBase akonadi-singlefileresource)
install(TARGETS akonadi_kdeaccounts_resource ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
#! /usr/bin/env bash
$EXTRACTRC `find . -name \*.ui` `find . -name \*.kcfg` >> rc.cpp || exit 11
$XGETTEXT *.cpp -o $podir/akonadi_kdeaccounts_resource.pot
/*
Copyright (c) 2010 Tobias Koenig <tokoe@kde.org>
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 "kdeaccountsresource.h"
#include "settingsadaptor.h"
#include "singlefileresourceconfigdialog.h"
#include <kdbusconnectionpool.h>
#include <KLocalizedString>
#include <QIcon>
using namespace Akonadi;
KDEAccountsResource::KDEAccountsResource(const QString &id)
: SingleFileResource<Settings>(id)
{
setSupportedMimetypes(QStringList() << KContacts::Addressee::mimeType(), QLatin1String("kde"));
setName(i18n("KDE Accounts"));
new SettingsAdaptor(mSettings);
KDBusConnectionPool::threadConnection().registerObject(QLatin1String("/Settings"),
mSettings, QDBusConnection::ExportAdaptors);
}
KDEAccountsResource::~KDEAccountsResource()
{
mContacts.clear();
}
bool KDEAccountsResource::retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &)
{
const QString remoteId = item.remoteId();
if (!mContacts.contains(remoteId)) {
cancelTask(i18n("Contact with uid '%1' not found.", remoteId));
return false;
}
Item newItem(item);
newItem.setPayload<KContacts::Addressee>(mContacts.value(remoteId));
itemRetrieved(newItem);
return true;
}
void KDEAccountsResource::customizeConfigDialog(SingleFileResourceConfigDialog<Settings> *dlg)
{
dlg->setWindowIcon(QIcon::fromTheme(QLatin1String("kde")));
dlg->setWindowTitle(i18n("Select KDE Accounts File"));
}
void KDEAccountsResource::configDialogAcceptedActions(SingleFileResourceConfigDialog<Settings> *)
{
// We can't hide the GUI element but we can enforce that the
// resource is read-only
mSettings->setReadOnly(true);
mSettings->save();
}
void KDEAccountsResource::itemAdded(const Akonadi::Item &, const Akonadi::Collection &)
{
cancelTask(i18n("KDE Accounts file is read-only"));
}
void KDEAccountsResource::itemChanged(const Akonadi::Item &, const QSet<QByteArray> &)
{
cancelTask(i18n("KDE Accounts file is read-only"));
}
void KDEAccountsResource::itemRemoved(const Akonadi::Item &)
{
cancelTask(i18n("KDE Accounts file is read-only"));
}
void KDEAccountsResource::retrieveItems(const Akonadi::Collection &collection)
{
// KDEAccounts does not support folders so we can safely ignore the collection
Q_UNUSED(collection);
Akonadi::Item::List items;
ContactsMap::const_iterator end(mContacts.constEnd());
for (ContactsMap::const_iterator it = mContacts.constBegin(); it != end; ++it) {
Item item;
item.setRemoteId(it.key());
item.setMimeType(KContacts::Addressee::mimeType());
item.setPayload(it.value());
items.append(item);
}
itemsRetrieved(items);
}
bool KDEAccountsResource::readFromFile(const QString &fileName)
{
mContacts.clear();
QFile file(QUrl::fromLocalFile(fileName).toLocalFile());
if (!file.open(QIODevice::ReadOnly)) {
emit status(Broken, i18n("Unable to open KDE accounts file '%1'.", fileName));
return false;
}
while (!file.atEnd()) {
QString line = QString::fromUtf8(file.readLine());
// We have a line like the following now, which consists of a nickname,
// the full name and an email address
// 'tokoe Tobias Koenig tokoe@kde.org'
// remove all leading, trailing and duplicated white spaces
line = line.trimmed().simplified();
if (line.isEmpty()) {
continue;
}
QStringList parts = line.split(QLatin1Char(' '));
if (parts.count() < 3) {
qWarning() << "Failed to parse line \"" << line << "\", invalid format";
continue;
}
// The first part is the nick name, the last one the email address and
// everything else in between the full name
const QString nickName = parts.takeFirst();
const QString email = parts.takeLast();
const QString fullName = parts.join(QLatin1String(" "));
KContacts::Addressee contact;
contact.setNickName(nickName);
contact.setNameFromString(fullName);
contact.setOrganization(i18n("KDE Project"));
contact.insertCategory(i18n("KDE Developer"));
contact.insertEmail(email);
mContacts.insert(nickName, contact);
}
return true;
}
bool KDEAccountsResource::writeToFile(const QString &)
{
Q_ASSERT(false); // this method should never be called
return false;
}
AKONADI_RESOURCE_MAIN(KDEAccountsResource)
[Desktop Entry]
Name=KDE Accounts
Name[bs]=KDE nalozi
Name[ca]=Comptes del KDE
Name[ca@valencia]=Comptes del KDE
Name[cs]=Účty KDE
Name[da]=KDE-konti
Name[de]=KDE-Zugänge
Name[el]=Λογαριασμοί KDE
Name[en_GB]=KDE Accounts
Name[es]=Cuentas de KDE
Name[et]=KDE kontod
Name[fi]=KDE-tilit
Name[fr]=Comptes KDE
Name[ga]=Cuntais KDE
Name[gl]=Contas do KDE
Name[hu]=KDE azonosítók
Name[ia]=Contos KDE
Name[it]=Account KDE
Name[ja]=KDE アカウント
Name[kk]=KDE тіркелгілері
Name[km]=គណនី KDE
Name[ko]=KDE 연락처
Name[lt]=KDE paskyros
Name[lv]=KDE konti
Name[nb]=KDE-kontoer
Name[nds]=KDE-Kontos
Name[nl]=KDE-accounts
Name[nn]=KDE-kontoar
Name[pa]=KDE ਅਕਾਊਂਟ
Name[pl]=Konta KDE
Name[pt]=Contas do KDE
Name[pt_BR]=Contas do KDE
Name[ro]=Conturi KDE
Name[ru]=Учётные записи KDE
Name[sk]=KDE účty
Name[sl]=KDE-jevi računi
Name[sr]=КДЕ налози
Name[sr@ijekavian]=КДЕ налози
Name[sr@ijekavianlatin]=KDE nalozi
Name[sr@latin]=KDE nalozi
Name[sv]=KDE-konton
Name[tr]=KDE Hesapları
Name[ug]=KDE ھېساباتى
Name[uk]=Облікові записи KDE
Name[x-test]=xxKDE Accountsxx
Name[zh_CN]=KDE 账户
Name[zh_TW]=KDE 帳號
Comment=Loads contacts from the KDE accounts file
Comment[bs]=Učitava kontakte s KDE datoteke naloga
Comment[ca]=Carrega contactes des d'un fitxer de comptes del KDE
Comment[ca@valencia]=Carrega contactes des d'un fitxer de comptes del KDE
Comment[da]=Indlæser kontakter fra KDE-konti-filen
Comment[de]=Lädt Kontakte aus der KDE-Zugangsdatei
Comment[el]=Φόρτωση επαφών από ένα αρχείο λογαριασμών KDE
Comment[en_GB]=Loads contacts from the KDE accounts file
Comment[es]=Cargar contactos desde el archivo de cuentas de KDE
Comment[et]=Kontaktide laadimine KDE kontode failist
Comment[fi]=Lataa yhteystiedot KDE:n tilitiedostosta
Comment[fr]=Charge les contacts depuis le fichier de comptes KDE
Comment[ga]=Luchtaíonn sé seo teagmhálacha ón chomhad cuntas KDE
Comment[gl]=Carga contactos desde un ficheiro de contas do KDE
Comment[hu]=Adatok betöltése a KDE azonosítófájlból
Comment[ia]=Lege contactos de un file de un conto KDE
Comment[it]=Carica contatti dal file degli account KDE
Comment[ja]=KDE アカウントファイルから連絡先を読み込みます
Comment[kk]=KDE тіркелгілер файлынан контакттарды алып береді
Comment[km]=ផ្ទុក​ទំនាក់ទំនង​ពី​ឯកសារគណនី​របស់ KDE
Comment[ko]=KDE 연락처 파일에서 데이터를 가져옵니다
Comment[lt]=Įkelia kontaktus iš KDE paskyros failo
Comment[lv]=Ielādē datus no KDE kontu faila
Comment[nb]=Laster kontakter fra KDE-kontofila
Comment[nds]=Laadt Kontakten ut de KDE-Kontendatei
Comment[nl]=Laadt contactpersonen uit het bestand met KDE-accounts
Comment[nn]=Lastar inn kontaktar frå ei KDE-kontofil
Comment[pl]=Wczytuje kontakty z pliku kontaktów KDE
Comment[pt]=Carrega os dados do ficheiro de contas do KDE
Comment[pt_BR]=Carrega os contatos a partir do arquivo de contas do KDE
Comment[ro]=Încarcă date din fișierul cu conturi KDE
Comment[ru]=Загрузка контактов из файла контактов KDE
Comment[sk]=Načíta kontakty zo súboru KDE účtov
Comment[sl]=Naloži stike iz datoteke KDE-jevih računov
Comment[sr]=Учитава контакте из фајла КДЕ налога
Comment[sr@ijekavian]=Учитава контакте из фајла КДЕ налога
Comment[sr@ijekavianlatin]=Učitava kontakte iz fajla KDE naloga
Comment[sr@latin]=Učitava kontakte iz fajla KDE naloga
Comment[sv]=Laddar kontakter från KDE:s kontofil
Comment[tr]=KDE hesap dosyasından kişileri yükler
Comment[uk]=Завантаження контактів з файла облікових записів KDE
Comment[x-test]=xxLoads contacts from the KDE accounts filexx
Comment[zh_CN]=从 KDE 账户文件中装入联系人
Comment[zh_TW]=從 KDE 帳號檔載入聯絡人
Type=AkonadiResource
Exec=akonadi_kdeaccounts_resource
Icon=kde
X-Akonadi-MimeTypes=text/directory
X-Akonadi-Capabilities=Resource
X-Akonadi-Identifier=akonadi_kdeaccounts_resource
/*
Copyright (c) 2010 Tobias Koenig <tokoe@kde.org>
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 KDEACCOUNTSRESOURCE_H
#define KDEACCOUNTSRESOURCE_H
#include "singlefileresource.h"
#include "settings.h"
#include <kcontacts/addressee.h>
class KDEAccountsResource : public Akonadi::SingleFileResource<Settings>
{
Q_OBJECT
public:
KDEAccountsResource(const QString &id);
~KDEAccountsResource();
protected Q_SLOTS:
bool retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &parts) Q_DECL_OVERRIDE;
void retrieveItems(const Akonadi::Collection &collection) Q_DECL_OVERRIDE;
protected:
/**
* Customize the configuration dialog before it is displayed.
*/
void customizeConfigDialog(Akonadi::SingleFileResourceConfigDialog<Settings> *dlg) Q_DECL_OVERRIDE;
/*
* Do stuff when the configuration dialog has been accepted, before
* reloadFile() is called.
*/
void configDialogAcceptedActions(Akonadi::SingleFileResourceConfigDialog<Settings> *dlg) Q_DECL_OVERRIDE;
bool readFromFile(const QString &fileName) Q_DECL_OVERRIDE;
bool writeToFile(const QString &fileName) Q_DECL_OVERRIDE;
void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) Q_DECL_OVERRIDE;
void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) Q_DECL_OVERRIDE;
void itemRemoved(const Akonadi::Item &item) Q_DECL_OVERRIDE;
private:
typedef QMap<QString, KContacts::Addressee> ContactsMap;
ContactsMap mContacts;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:kcfg="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true" />
<group name="General">
<entry name="Path" type="Path">
<label>Path to KDE accounts file.</label>
<default></default>
</entry>
<entry name="DisplayName" type="String">
<label>Display name.</label>
<default></default>
</entry>
<entry name="ReadOnly" type="Bool">
<label>Do not change the actual backend data.</label>
<default>true</default>
</entry>
<entry name="MonitorFile" type="Bool">
<label>Monitor file for changes.</label>
<default>true</default>
</entry>
</group>
</kcfg>
File=kdeaccountsresource.kcfg
ClassName=Settings
Mutators=true
ItemAccessors=true
SetUserTexts=true
Singleton=false
GlobalEnums=true
########### next target ###############
add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_localbookmarks_resource\")
set( localbookmarksresource_SRCS
localbookmarksresource.cpp
)
install( FILES localbookmarksresource.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents" )
kconfig_add_kcfg_files(localbookmarksresource_SRCS settings.kcfgc)
kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/localbookmarksresource.kcfg org.kde.Akonadi.LocalBookmarks.Settings)
qt5_add_dbus_adaptor(localbookmarksresource_SRCS
${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.LocalBookmarks.Settings.xml settings.h Settings
)
add_executable(akonadi_localbookmarks_resource ${localbookmarksresource_SRCS})
if( APPLE )
set_target_properties(akonadi_localbookmarks_resource PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../Info.plist.template)
set_target_properties(akonadi_localbookmarks_resource PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Akonadi.LocalBookmarks")
set_target_properties(akonadi_localbookmarks_resource PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "KDE Akonadi LocalBookmarks Resource")
endif ()
target_link_libraries(akonadi_localbookmarks_resource KF5::AkonadiCore KF5::KIOCore KF5::AkonadiAgentBase)
install(TARGETS akonadi_localbookmarks_resource ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
#! /usr/bin/env bash
$EXTRACTRC `find . -name \*.ui` `find . -name \*.kcfg` >> rc.cpp || exit 11
$XGETTEXT *.cpp -o $podir/akonadi_localbookmarks_resource.pot
rm -f rc.cpp
/*
Copyright (c) 2006 Till Adam <adam@kde.org>
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 "localbookmarksresource.h"
#include "settings.h"
#include "settingsadaptor.h"
#include <kbookmark.h>
#include <kbookmarkmanager.h>
#include <kfiledialog.h>
#include <KLocalizedString>
using namespace Akonadi;
LocalBookmarksResource::LocalBookmarksResource(const QString &id)
: ResourceBase(id), mBookmarkManager(Q_NULLPTR)
{
new SettingsAdaptor(Settings::self());
QDBusConnection::sessionBus().registerObject(QLatin1String("/Settings"),
Settings::self(), QDBusConnection::ExportAdaptors);
const QString fileName = Settings::self()->path();
if (!fileName.isEmpty()) {
mBookmarkManager = KBookmarkManager::managerForFile(fileName, name());
}
}
LocalBookmarksResource::~LocalBookmarksResource()
{
}
bool LocalBookmarksResource::retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &)
{
itemRetrieved(item);
return true;
}
void LocalBookmarksResource::configure(WId windowId)
{
const QString oldFile = Settings::self()->path();
QUrl url;
if (!oldFile.isEmpty()) {
url = QUrl::fromLocalFile(oldFile);
} else {
url = QUrl::fromLocalFile(QDir::homePath());
}
const QString newFile = KFileDialog::getOpenFileNameWId(url, QLatin1String("*.xml |") + i18nc("Filedialog filter for *.xml",
"XML Bookmark file"),
windowId, i18n("Select Bookmarks File"));
if (newFile.isEmpty()) {
emit configurationDialogRejected();
return;
}
if (oldFile == newFile) {
emit configurationDialogAccepted();
return;
}
Settings::self()->setPath(newFile);
mBookmarkManager = KBookmarkManager::managerForFile(newFile, name());
Settings::self()->save();
synchronize();
emit configurationDialogAccepted();
}
void LocalBookmarksResource::itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection)
{
if (item.mimeType() != QLatin1String("application/x-xbel")) {
cancelTask(i18n("Item is not a bookmark"));
return;
}
KBookmark bookmark = item.payload<KBookmark>();
KBookmark bookmarkGroup = mBookmarkManager->findByAddress(collection.remoteId());
if (!bookmarkGroup.isGroup()) {
cancelTask(i18n("Bookmark group not found"));
return;
}
KBookmarkGroup group = bookmarkGroup.toGroup();
group.addBookmark(bookmark);
// saves the file
mBookmarkManager->emitChanged(group);
changeCommitted(item);
}
void LocalBookmarksResource::itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &)
{
KBookmark bookmark = item.payload<KBookmark>();
// saves the file
mBookmarkManager->emitChanged(bookmark.parentGroup());
changeCommitted(item);
}
void LocalBookmarksResource::itemRemoved(const Akonadi::Item &item)
{
const KBookmark bookmark = mBookmarkManager->findByAddress(item.remoteId());
KBookmarkGroup bookmarkGroup = bookmark.parentGroup();
bookmarkGroup.deleteBookmark(bookmark);
// saves the file
mBookmarkManager->emitChanged(bookmarkGroup);
changeCommitted(item);
}
static Collection::List listRecursive(const KBookmarkGroup &parentGroup, const Collection &parentCollection)
{
const QStringList mimeTypes = QStringList() << QLatin1String("application/x-xbel") << Collection::mimeType();
Collection::List collections;
for (KBookmark it = parentGroup.first(); !it.isNull(); it = parentGroup.next(it)) {
if (!it.isGroup()) {
continue;
}