From 8f1c4aeaf060a5c1bcb72d8eeca245fadab54a16 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 24 Jun 2013 01:15:24 +0200 Subject: [PATCH] Yo dawg (teo-), I put a plugin in your plugin, so I can load another plugin for showing an in-application KDE config widget --- CMakeLists.txt | 2 +- .../configstorage/telepathy/CMakeLists.txt | 15 ++++++++ .../telepathy/KdeTelepathyConfigWidget.cpp | 35 +++++++++++++++++ .../telepathy/KdeTelepathyConfigWidget.h | 36 ++++++++++++++++++ .../telepathy/TelepathyConfigStorage.cpp | 24 ++++++++++++ .../telepathy/TelepathyConfigStorage.h | 6 +++ ...lepathyConfigStorageConfigWidgetDllMacro.h | 32 ++++++++++++++++ ...lepathyConfigStorageConfigWidgetPlugin.cpp | 23 +++++++++++ ...TelepathyConfigStorageConfigWidgetPlugin.h | 38 +++++++++++++++++++ 9 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.cpp create mode 100644 src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.h create mode 100644 src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetDllMacro.h create mode 100644 src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.cpp create mode 100644 src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 19ec4c4ac..9b196ed30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,8 +311,8 @@ if (WITH_KDE4) endif(WITH_KDE4) # this was used before we had FindKDE4Installed, just leaving it here to keep the flags # for future kde integration +macro_log_feature(KDE4_FOUND "KDE4" "Provides support for configuring Telepathy Accounts from inside Tomahawk" "https://www.kde.org" FALSE "" "") -# macro_optional_find_package(KDE4) IF( KDE4_FOUND ) IF( CMAKE_C_FLAGS ) # KDE4 adds and removes some compiler flags that we don't like diff --git a/src/libtomahawk/accounts/configstorage/telepathy/CMakeLists.txt b/src/libtomahawk/accounts/configstorage/telepathy/CMakeLists.txt index 25f64f7ea..c303b9c4e 100644 --- a/src/libtomahawk/accounts/configstorage/telepathy/CMakeLists.txt +++ b/src/libtomahawk/accounts/configstorage/telepathy/CMakeLists.txt @@ -5,7 +5,22 @@ tomahawk_add_plugin(telepathy EXPORT_MACRO CONFIGSTORAGEDLLEXPORT_PRO SOURCES TelepathyConfigStorage.cpp + TelepathyConfigStorageConfigWidgetPlugin.cpp LINK_LIBRARIES ${TOMAHAWK_LIBRARIES} ${TELEPATHY_QT_LIBRARIES} + SHARED_LIB ) + +if( KDE4_FOUND ) + include_directories( ${KDE4_INCLUDES} ) + tomahawk_add_plugin(kde + TYPE configstorage_telepathy + EXPORT_MACRO CONFIGSTORAGETELEPATHYDLLEXPORT_PRO + SOURCES + KdeTelepathyConfigWidget.cpp + LINK_LIBRARIES + tomahawk_configstorage_telepathy + ${KDE4_KCMUTILS_LIBS} + ) +endif() diff --git a/src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.cpp b/src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.cpp new file mode 100644 index 000000000..516760501 --- /dev/null +++ b/src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.cpp @@ -0,0 +1,35 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2013, Dominik Schmidt + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "KdeTelepathyConfigWidget.h" + +#include "utils/Logger.h" + +#include + +#include + +QWidget* +KdeTelepathyConfigWidget::configWidget() +{ + return new KCModuleProxy( "kcm_ktp_accounts" ); +} + +Q_EXPORT_PLUGIN2( TelepathyConfigStorageConfigWidgetPlugin, KdeTelepathyConfigWidget ) + + diff --git a/src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.h b/src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.h new file mode 100644 index 000000000..61acdbbf2 --- /dev/null +++ b/src/libtomahawk/accounts/configstorage/telepathy/KdeTelepathyConfigWidget.h @@ -0,0 +1,36 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2013, Dominik Schmidt + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef KDETELEPATHYCONFIGWIDGET_H +#define KDETELEPATHYCONFIGWIDGET_H + +#include "TelepathyConfigStorageConfigWidgetPlugin.h" + +#include "TelepathyConfigStorageConfigWidgetDllMacro.h" + +class CONFIGSTORAGETELEPATHYDLLEXPORT KdeTelepathyConfigWidget : public TelepathyConfigStorageConfigWidgetPlugin +{ + Q_OBJECT + Q_INTERFACES( TelepathyConfigStorageConfigWidgetPlugin ) + +public: + virtual QWidget* configWidget(); +}; + + +#endif // KDETELEPATHYCONFIGWIDGET_H diff --git a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp index 87b9241b9..c8ef9b5b0 100644 --- a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp +++ b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2013, Teo Mrnjavac + * Copyright 2013, Dominik Schmidt * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +19,14 @@ #include "TelepathyConfigStorage.h" +#include "TelepathyConfigStorageConfigWidgetPlugin.h" + + #include "accounts/Account.h" #include "accounts/AccountManager.h" #include "accounts/CredentialsManager.h" #include "utils/Logger.h" +#include "utils/PluginLoader.h" #include #include @@ -41,6 +46,7 @@ Tomahawk::Accounts::TelepathyConfigStorage::TelepathyConfigStorage( QObject* par , m_credentialsServiceName( "telepathy-kde" ) { tDebug() << Q_FUNC_INFO; + loadConfigWidgetPlugins(); } @@ -137,6 +143,24 @@ Tomahawk::Accounts::TelepathyConfigStorage::onCredentialsManagerReady( const QSt } +void +Tomahawk::Accounts::TelepathyConfigStorage::loadConfigWidgetPlugins() +{ + tDebug() << Q_FUNC_INFO; + foreach( QObject* plugin, Tomahawk::Utils::PluginLoader( "configstorage_telepathy" ).loadPlugins().values() ) + { + TelepathyConfigStorageConfigWidgetPlugin* configWidgetPlugin = qobject_cast< TelepathyConfigStorageConfigWidgetPlugin* >( plugin ); + if( !configWidgetPlugin ) + { + tLog() << "Tried to load invalid TelepathyConfigStorageConfigWidgetPlugin"; + continue; + } + + m_configWidgetPlugins << configWidgetPlugin; + } +} + + QString Tomahawk::Accounts::TelepathyConfigStorage::telepathyPathToAccountId( const QString& objectPath, const QString& telepathyServiceName ) { diff --git a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h index d88d65176..530d28bc9 100644 --- a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h +++ b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h @@ -1,6 +1,7 @@ /* === This file is part of Tomahawk Player - === * * Copyright 2013, Teo Mrnjavac + * Copyright 2013, Dominik Schmidt * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +30,8 @@ namespace Tp class PendingOperation; } +class TelepathyConfigStorageConfigWidgetPlugin; + namespace Tomahawk { @@ -61,12 +64,15 @@ private slots: void onCredentialsManagerReady( const QString& service ); private: + void loadConfigWidgetPlugins(); + QString telepathyPathToAccountId( const QString& objectPath, const QString& telepathyServiceName ); QString accountIdToTelepathyPath( const QString& accountId ); const QString m_credentialsServiceName; QStringList m_accountIds; Tp::AccountManagerPtr m_tpam; + QList< TelepathyConfigStorageConfigWidgetPlugin* > m_configWidgetPlugins; static TelepathyConfigStorage* s_instance; }; diff --git a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetDllMacro.h b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetDllMacro.h new file mode 100644 index 000000000..5e72f192f --- /dev/null +++ b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetDllMacro.h @@ -0,0 +1,32 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2013, Teo Mrnjavac + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef TELEPATHYCONFIGSTORAGECONFIGWIDGETDLLMACRO_H +#define TELEPATHYCONFIGSTORAGECONFIGWIDGETDLLMACRO_H + +#include + +#ifndef CONFIGSTORAGETELEPATHYDLLEXPORT +# if defined (CONFIGSTORAGETELEPATHYDLLEXPORT_PRO) +# define CONFIGSTORAGETELEPATHYDLLEXPORT Q_DECL_EXPORT +# else +# define CONFIGSTORAGETELEPATHYDLLEXPORT Q_DECL_IMPORT +# endif +#endif + +#endif // TELEPATHYCONFIGSTORAGECONFIGWIDGETDLLMACRO_H diff --git a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.cpp b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.cpp new file mode 100644 index 000000000..860632542 --- /dev/null +++ b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.cpp @@ -0,0 +1,23 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2013, Dominik Schmidt + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "TelepathyConfigStorageConfigWidgetPlugin.h" + +TelepathyConfigStorageConfigWidgetPlugin::~TelepathyConfigStorageConfigWidgetPlugin() +{ +} diff --git a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.h b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.h new file mode 100644 index 000000000..06a665da8 --- /dev/null +++ b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorageConfigWidgetPlugin.h @@ -0,0 +1,38 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2013, Teo Mrnjavac + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef TELEPATHYCONFIGSTORAGECONFIGWIDGETPLUGIN_H +#define TELEPATHYCONFIGSTORAGECONFIGWIDGETPLUGIN_H + +#include + +#include "accounts/ConfigStorageDllMacro.h" + +class CONFIGSTORAGEDLLEXPORT TelepathyConfigStorageConfigWidgetPlugin : public QObject +{ +Q_OBJECT + +public: + virtual ~TelepathyConfigStorageConfigWidgetPlugin(); + + virtual QWidget* configWidget() = 0; +}; + +Q_DECLARE_INTERFACE( TelepathyConfigStorageConfigWidgetPlugin, "tomahawk.TelepathyConfigStorageConfigWidget/1.0" ) + +#endif // TELEPATHYCONFIGSTORAGE_H