Make QCA2 an optional dependency for libplasma, so QCA2 can remain optional for all of kdelibs. Just disable remote widgets functionality if QCA2 is missing.
svn path=/trunk/KDE/kdelibs/; revision=1021543
This commit is contained in:
parent
020c8b65c6
commit
34b9e01ac4
@ -15,10 +15,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
)
|
||||
|
||||
find_package(QCA2 REQUIRED)
|
||||
|
||||
|
||||
include_directories(${QCA2_INCLUDE_DIR})
|
||||
if(QCA2_FOUND)
|
||||
include_directories(${QCA2_INCLUDE_DIR})
|
||||
set(ENABLE_REMOTE_WIDGETS TRUE)
|
||||
endif(QCA2_FOUND)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
if(QT_QTOPENGL_FOUND AND OPENGL_FOUND)
|
||||
# libGL needs dlopen() and friends from the dl library
|
||||
|
@ -100,6 +100,8 @@
|
||||
#include "private/toolbox_p.h"
|
||||
#include "ui_publish.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -1649,7 +1651,9 @@ void Applet::showConfigurationInterface()
|
||||
}
|
||||
|
||||
d->addGlobalShortcutsPage(dialog);
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
d->addPublishPage(dialog);
|
||||
#endif
|
||||
dialog->show();
|
||||
} else if (d->script) {
|
||||
d->script->showConfigurationInterface();
|
||||
@ -1708,7 +1712,9 @@ KConfigDialog *AppletPrivate::generateGenericConfigDialog()
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
q->createConfigurationInterface(dialog);
|
||||
addGlobalShortcutsPage(dialog);
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
addPublishPage(dialog);
|
||||
#endif
|
||||
//TODO: Apply button does not correctly work for now, so do not show it
|
||||
dialog->showButton(KDialog::Apply, false);
|
||||
QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
|
||||
|
2
config.h.in
Normal file
2
config.h.in
Normal file
@ -0,0 +1,2 @@
|
||||
#cmakedefine ENABLE_REMOTE_WIDGETS
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "servicejob.h"
|
||||
#include "applet.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <kzip.h>
|
||||
#include <kdebug.h>
|
||||
#include <ktempdir.h>
|
||||
@ -147,10 +149,17 @@ Applet *AccessAppletJob::applet() const
|
||||
|
||||
void AccessAppletJob::start()
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
kDebug() << "fetching a plasmoid from location = " << d->location.prettyUrl();
|
||||
Service *service = Service::access(d->location);
|
||||
connect(service, SIGNAL(serviceReady(Plasma::Service*)),
|
||||
this, SLOT(slotServiceReady(Plasma::Service*)));
|
||||
#else
|
||||
kWarning() << "libplasma was compiled without support for remote services. Accessing remote applet failed because of that.";
|
||||
setError(-1);
|
||||
setErrorText(i18n("Your system doesn't provide support for the 'remote widgets' feature. Access Failed."));
|
||||
emitResult();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "serviceaccessjob.h"
|
||||
#include "private/authorizationmanager_p.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
@ -96,11 +98,15 @@ AccessManagerPrivate::AccessManagerPrivate(AccessManager *manager)
|
||||
: q(manager),
|
||||
browser(new DNSSD::ServiceBrowser("_plasma._tcp"))
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
q->connect(browser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)),
|
||||
q, SLOT(slotAddService(DNSSD::RemoteService::Ptr)));
|
||||
q->connect(browser, SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)),
|
||||
q, SLOT(slotRemoveService(DNSSD::RemoteService::Ptr)));
|
||||
browser->startBrowse();
|
||||
#else
|
||||
kWarning() << "libplasma is compiled without support for remote widgets. not monitoring remote widgets on the network";
|
||||
#endif
|
||||
}
|
||||
|
||||
AccessManagerPrivate::~AccessManagerPrivate()
|
||||
|
@ -162,9 +162,6 @@ void AuthorizationManagerPrivate::prepareForServiceAccess()
|
||||
void AuthorizationManagerPrivate::prepareForServicePublication()
|
||||
{
|
||||
if (!server) {
|
||||
//Let's set up plasma for remote service support. Since most of the set up involves crypto,
|
||||
//AuthorizationManager seems the sensible place.
|
||||
//First, let's start the JOLIE server:
|
||||
server = new Jolie::Server(4000);
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,16 @@
|
||||
|
||||
#include "credentials.h"
|
||||
|
||||
#include "authorizationmanager.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
#include <QtCrypto>
|
||||
#endif
|
||||
|
||||
#include <kdebug.h>
|
||||
#include "authorizationmanager.h"
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
namespace Plasma {
|
||||
@ -37,12 +42,14 @@ public:
|
||||
: id(id),
|
||||
name(name)
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
if (isPrivateKey) {
|
||||
privateKey = QCA::PrivateKey::fromPEM(pemKey);
|
||||
publicKey = privateKey.toPublicKey();
|
||||
} else {
|
||||
publicKey = QCA::PublicKey::fromPEM(pemKey);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
~CredentialsPrivate()
|
||||
@ -51,8 +58,11 @@ public:
|
||||
|
||||
QString id;
|
||||
QString name;
|
||||
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
QCA::PublicKey publicKey;
|
||||
QCA::PrivateKey privateKey;
|
||||
#endif
|
||||
};
|
||||
|
||||
Credentials::Credentials(const QString &id, const QString &name,
|
||||
@ -85,12 +95,16 @@ Credentials &Credentials::operator=(const Credentials &other)
|
||||
|
||||
Credentials Credentials::createCredentials(const QString &name)
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
QCA::KeyGenerator generator;
|
||||
QCA::PrivateKey key = generator.createRSA(2048);
|
||||
QString pemKey(key.toPublicKey().toPEM());
|
||||
//TODO: is using a md5 hash for the id a good idea?
|
||||
QString id = QCA::Hash("sha1").hashToString(pemKey.toAscii());
|
||||
return Credentials(id, name, key.toPEM(), true);
|
||||
#else
|
||||
kDebug() << "libplasma is compiled without support for remote widgets. Creating an empty identity.";
|
||||
return Credentials();
|
||||
#endif
|
||||
}
|
||||
|
||||
TrustLevel Credentials::trustLevel() const
|
||||
@ -111,12 +125,17 @@ TrustLevel Credentials::trustLevel() const
|
||||
|
||||
bool Credentials::isValid() const
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
if (d->publicKey.isNull()) {
|
||||
return false;
|
||||
} else {
|
||||
QString id = QCA::Hash("sha1").hashToString(d->publicKey.toPEM().toAscii());
|
||||
return (id == d->id);
|
||||
}
|
||||
#else
|
||||
kDebug() << "libplasma is compiled without support for remote widgets. Key invalid.";
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Credentials::name() const
|
||||
@ -131,6 +150,7 @@ QString Credentials::id() const
|
||||
|
||||
bool Credentials::isValidSignature(const QByteArray &signature, const QByteArray &payload)
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
if (d->publicKey.canVerify()) {
|
||||
if (!isValid()) {
|
||||
kDebug() << "Key is null?";
|
||||
@ -143,15 +163,23 @@ bool Credentials::isValidSignature(const QByteArray &signature, const QByteArray
|
||||
kDebug() << "Can't verify?";
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Credentials::canSign() const
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
return d->privateKey.canSign();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Credentials::signMessage(const QByteArray &message)
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
if(!QCA::isSupported("pkey") ||
|
||||
!QCA::PKey::supportedIOTypes().contains(QCA::PKey::RSA)) {
|
||||
kDebug() << "RSA not supported";
|
||||
@ -163,21 +191,27 @@ QByteArray Credentials::signMessage(const QByteArray &message)
|
||||
QByteArray signature = d->privateKey.signature();
|
||||
return signature;
|
||||
} else {
|
||||
kDebug() << "can't sign?";
|
||||
return QByteArray();
|
||||
}
|
||||
#else
|
||||
return QByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
Credentials Credentials::toPublicCredentials() const
|
||||
{
|
||||
kDebug();
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
Credentials result(*this);
|
||||
result.d->privateKey = QCA::PrivateKey();
|
||||
return result;
|
||||
#else
|
||||
return Credentials();
|
||||
#endif
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const Credentials &myObj)
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
QString privateKeyPem;
|
||||
QString publicKeyPem;
|
||||
|
||||
@ -189,12 +223,14 @@ QDataStream &operator<<(QDataStream &out, const Credentials &myObj)
|
||||
}
|
||||
|
||||
out << 1 << myObj.d->id << myObj.d->name << privateKeyPem << publicKeyPem;
|
||||
#endif
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, Credentials &myObj)
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
QString privateKeyString;
|
||||
QString publicKeyString;
|
||||
uint version;
|
||||
@ -213,6 +249,7 @@ QDataStream &operator>>(QDataStream &in, Credentials &myObj)
|
||||
if (conversionResult != QCA::ConvertGood) {
|
||||
kDebug() << "Unsuccessfull conversion of key?";
|
||||
}
|
||||
#endif
|
||||
|
||||
return in;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "private/service_p.h"
|
||||
#include "private/serviceprovider_p.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
|
||||
@ -120,6 +122,7 @@ void ServicePrivate::jobFinished(KJob *job)
|
||||
|
||||
void ServicePrivate::publish(AnnouncementMethods methods, const QString &name, PackageMetadata metadata)
|
||||
{
|
||||
#ifdef ENABLE_REMOTE_WIDGETS
|
||||
if (!serviceProvider) {
|
||||
AuthorizationManager::self()->d->prepareForServicePublication();
|
||||
|
||||
@ -145,6 +148,9 @@ void ServicePrivate::jobFinished(KJob *job)
|
||||
} else {
|
||||
kDebug() << "already published!";
|
||||
}
|
||||
#else
|
||||
kWarning() << "libplasma is compiled without support for remote widgets. not publishing.";
|
||||
#endif
|
||||
}
|
||||
|
||||
void ServicePrivate::unpublish()
|
||||
|
Loading…
x
Reference in New Issue
Block a user