APIDOX and code style++, plus policykit integration.

svn path=/trunk/KDE/kdelibs/; revision=1019141
This commit is contained in:
Rob Scheepmaker 2009-09-02 23:49:46 +00:00
parent d7e35305bb
commit b809967eb3
40 changed files with 280 additions and 608 deletions

View File

@ -73,7 +73,6 @@ set(plasma_LIB_SRCS
private/desktoptoolbox.cpp
private/extenderapplet.cpp
private/extenderitemmimedata.cpp
private/getpublickey.cpp
private/getsource.cpp
private/nativetabbar.cpp
private/packages.cpp
@ -81,7 +80,6 @@ set(plasma_LIB_SRCS
private/pinpairingauthorization.cpp
private/pinpairingdialog.cpp
private/plasmoidservice.cpp
private/publickeyservice.cpp
private/remotedataengine.cpp
private/remoteservice.cpp
private/remoteservicejob.cpp

View File

@ -26,16 +26,15 @@
#include <QtCore/QMap>
#include <QtCore/QTimer>
#include <QtJolie/Message>
#include <kdebug.h>
#include <kurl.h>
#include <kglobal.h>
#include <dnssd/servicebrowser.h>
#include <dnssd/remoteservice.h>
#include <ktemporaryfile.h>
#include <dnssd/servicebrowser.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kstandarddirs.h>
#include <qhostinfo.h>
#include <ktemporaryfile.h>
#include <kurl.h>
#include <QtJolie/Message>
namespace Plasma
{
@ -46,8 +45,6 @@ class AccessManagerSingleton
AccessManager self;
};
//FIXME: AccessManagerSignleton could be removed to remove a friend.
//see kdelibs/kutils/kidletime/xsyncbasedpoller.cpp
K_GLOBAL_STATIC(AccessManagerSingleton, privateAccessManagerSelf)
AccessManager *AccessManager::self()
@ -69,14 +66,12 @@ AccessManager::~AccessManager()
AccessAppletJob *AccessManager::accessRemoteApplet(const KUrl &location) const
{
kDebug() << "unresolved location = " << location.prettyUrl();
KUrl resolvedLocation;
if (location.protocol() == "zeroconf") {
if (d->zeroconfServices.contains(location.host())) {
resolvedLocation = d->services[location.host()].remoteLocation();
} else {
kDebug() << "not in the map";
kDebug() << "There's no zeroconf service with this name.";
}
} else {
resolvedLocation = location;
@ -118,7 +113,7 @@ void AccessManagerPrivate::slotAddService(DNSSD::RemoteService::Ptr service)
{
kDebug();
if (!service->resolve()) {
kDebug() << "can't be resolved";
kDebug() << "Zeroconf service can't be resolved";
return;
}

View File

@ -20,6 +20,8 @@
#ifndef PLASMA_ACCESSMANAGER_H
#define PLASMA_ACCESSMANAGER_H
#include "accessappletjob.h"
#include "packagemetadata.h"
#include "plasma_export.h"
#include <QtCore/QList>
@ -27,8 +29,6 @@
#include <QtCore/QString>
#include <kdebug.h>
#include "accessappletjob.h"
#include "packagemetadata.h"
class QString;
class KUrl;
@ -44,9 +44,9 @@ class ServiceAccessJob;
*
* @short Allows access to remote Plasma::Applet classes.
*
* This manager provides a way to access a plasmoid that is hosted on another machine. It also
* provides a mechanism to discover services announced to the network through zeroconf or
* bluetooth.
* This manager provides a way to access an applet (either a binary or packaged one) that is hosted
* on another machine. It also provides a mechanism to discover services announced to the network
* through zeroconf.
*
* @since 4.4
*/
@ -72,23 +72,25 @@ class PLASMA_EXPORT AccessManager : public QObject
AccessAppletJob *accessRemoteApplet(const KUrl &location) const;
/**
* @returns a map mapping service names to the plasmoid's metadata.
* @returns a list of applets that are announced on the network through zeroconf. Use the
* remoteLocation() function in PackageMetadata to obtain an url to pass to
* accessRemoteApplet in AccessManager if you want to access one of these applets.
*/
QList<PackageMetadata> remoteApplets() const;
Q_SIGNALS:
/**
* fires when a AccessAppletJob is finished.
* fires when an AccessAppletJob is finished.
*/
void finished(Plasma::AccessAppletJob*);
void finished(Plasma::AccessAppletJob *);
/**
* fires when a new plasmoid is announced on the network.
* fires when a new applet is announced on the network.
*/
void remoteAppletAnnounced(Plasma::PackageMetadata metadata);
/**
* fires when an announced plasmoid disappears from the network.
* fires when an announced applet disappears from the network.
*/
void remoteAppletUnannounced(Plasma::PackageMetadata metadata);

View File

@ -1455,34 +1455,45 @@ bool Applet::hasConfigurationInterface() const
void Applet::publish(AnnouncementMethods methods)
{
if (!d->service) {
d->service = new PlasmoidService(this);
}
if (d->package) {
d->package->d->publish(methods);
} else {
if (!d->service) {
d->service = new PlasmoidService(this);
}
QString resourceName =
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on",
"%1 on %2", name(), AuthorizationManager::self()->d->myCredentials.name());
kDebug() << "publishing package under name " << resourceName;
d->service->d->publish(methods, resourceName, PackageMetadata());
QString resourceName =
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on",
"%1 on %2", name(), AuthorizationManager::self()->d->myCredentials.name());
kDebug() << "publishing package under name " << resourceName;
d->service->d->publish(methods, resourceName);
}
}
void Applet::unpublish()
{
if (d->service) {
d->service->d->unpublish();
if (d->package) {
d->package->d->unpublish();
} else {
if (d->service) {
d->service->d->unpublish();
}
}
}
bool Applet::isPublished() const
{
if (d->service) {
return d->service->d->isPublished();
if (d->package) {
d->package->d->isPublished();
} else {
return false;
if (d->service) {
return d->service->d->isPublished();
} else {
return false;
}
}
}
//it bugs me that this can get turned on and off at will. I don't see it being useful and it just
//makes more work for me and more code duplication.
void Applet::setHasConfigurationInterface(bool hasInterface)
@ -1640,15 +1651,12 @@ void Applet::showConfigurationInterface()
d->addGlobalShortcutsPage(dialog);
d->addPublishPage(dialog);
//connect(dialog, SIGNAL(applyClicked()), this, SLOT(configDialogFinished()));
//connect(dialog, SIGNAL(okClicked()), this, SLOT(configDialogFinished()));
dialog->show();
} else if (d->script) {
d->script->showConfigurationInterface();
} else {
KConfigDialog *dialog = d->generateGenericConfigDialog();
createConfigurationInterface(dialog);
d->addGlobalShortcutsPage(dialog);
//createConfigurationInterface(dialog);
dialog->show();
}
@ -1737,12 +1745,6 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
void AppletPrivate::addPublishPage(KConfigDialog *dialog)
{
/**
if (!package) {
return;
}
*/
QWidget *page = new QWidget;
publishUI.setupUi(page);
publishUI.publishCheckbox->setChecked(q->config().readEntry("Publish", false));
@ -1765,18 +1767,11 @@ void AppletPrivate::configDialogFinished()
}
q->config().writeEntry("Publish", publishUI.publishCheckbox->isChecked());
if (package) {
if (publishUI.publishCheckbox->isChecked()) {
package->d->publish(Plasma::ZeroconfAnnouncement);
} else {
package->d->unpublish();
}
if (publishUI.publishCheckbox->isChecked()) {
q->publish(Plasma::ZeroconfAnnouncement);
} else {
if (publishUI.publishCheckbox->isChecked()) {
q->publish(Plasma::ZeroconfAnnouncement);
} else {
q->unpublish();
}
q->unpublish();
}
if (!configLoader) {
@ -2423,18 +2418,9 @@ void AppletPrivate::init(const QString &packagePath)
configAction->setText(i18nc("%1 is the name of the applet", "%1 Settings", q->name()));
}
if (package) {
if (q->config().readEntry("Publish", false)) {
package->d->publish(Plasma::ZeroconfAnnouncement);
} else {
package->d->unpublish();
}
} else {
if (q->config().readEntry("Publish", false)) {
q->publish(Plasma::ZeroconfAnnouncement);
} else {
q->unpublish();
}
if (q->config().readEntry("Publish", false)) {
kDebug() << "according the the config, this applet is published, so publish it now!";
q->publish(Plasma::ZeroconfAnnouncement);
}
QObject::connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));

View File

@ -28,27 +28,29 @@
#include "private/authorizationrule_p.h"
#include "private/denyallauthorization.h"
#include "private/joliemessagehelper_p.h"
#include "private/pinpairingauthorization.h"
#include "private/trustedonlyauthorization.h"
#include "private/joliemessagehelper_p.h"
#include <QtCore/QBuffer>
#include <QtCore/QMap>
#include <QNetworkInterface>
#include <QHostInfo>
#include <QtCore/QTimer>
#include <QtCore/QMetaType>
#include <QtCore/QTimer>
#include <QtNetwork/QHostInfo>
#include <QtCrypto>
#include <QtJolie/Message>
#include <QtJolie/Server>
#include <QtCrypto>
#include <kauthaction.h>
#include <kconfiggroup.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <ktemporaryfile.h>
#include <kurl.h>
#include <kwallet.h>
#include <kconfiggroup.h>
#include <kauthaction.h>
#include <kstandarddirs.h>
namespace Plasma
{
@ -144,30 +146,11 @@ AuthorizationManagerPrivate::AuthorizationManagerPrivate(AuthorizationManager *m
//First, let's start the JOLIE server:
server = new Jolie::Server(4000);
/**
//Actually: storing identities isn't really necesarry. TODO: remove this and see if stuff
//breaks.
foreach (const QString &groupName, identitiesConfig.groupList()) {
QByteArray identityByteArray =
identitiesConfig.group(groupName).readEntry("Credentials", QByteArray());
QDataStream stream(&identityByteArray, QIODevice::ReadOnly);
Credentials storedCredentials;
stream >> storedCredentials;
//Credentials storedCredentials = identityVariant.value<Credentials>();
if (storedCredentials.isNull()) {
kDebug() << "stored identity is null";
} else {
identities[storedCredentials.id()] = storedCredentials;
}
}
*/
QTimer::singleShot(0, q, SLOT(loadRules()));
QTimer::singleShot(0, q, SLOT(slotLoadRules()));
}
AuthorizationManagerPrivate::~AuthorizationManagerPrivate()
{
delete authorizationInterface;
delete customAuthorizationInterface;
delete server;
@ -182,7 +165,7 @@ void AuthorizationManagerPrivate::saveRules()
int i = 0;
foreach (AuthorizationRule *rule, rules) {
if (rule->persistence() == AuthorizationRule::Persistence) {
if (rule->persistence() == AuthorizationRule::Persistent) {
kDebug() << "adding rule " << i;
rulesGroup.group(QString::number(i)).writeEntry("CredentialsID", rule->credentials().id());
rulesGroup.group(QString::number(i)).writeEntry("serviceName", rule->serviceName());
@ -226,10 +209,8 @@ void AuthorizationManagerPrivate::slotWalletOpened()
emit q->readyForRemoteAccess();
}
void AuthorizationManagerPrivate::loadRules()
void AuthorizationManagerPrivate::slotLoadRules()
{
//TODO: at some point we're probably going to use kauth for this stuff, by which time this will
//become kind of obsolete.
foreach (const QString &groupName, rulesConfig.groupList()) {
QString identityID = rulesConfig.group(groupName).readEntry("CredentialsID", "");
QString serviceName = rulesConfig.group(groupName).readEntry("serviceName", "");
@ -292,14 +273,6 @@ void AuthorizationManagerPrivate::addCredentials(const Credentials &identity)
} else if (identity.isValid()) {
kDebug() << "Adding a new identity for " << identity.id();
identities[identity.id()] = identity;
/**
QByteArray identityByteArray;
QDataStream stream(&identityByteArray, QIODevice::WriteOnly);
stream << identity;
identitiesConfig.group(identity.id()).writeEntry("Credentials", identityByteArray);
identitiesConfig.sync();
*/
}
}

View File

@ -40,22 +40,23 @@ class ServiceJob;
*
* @short Allows authorization of access to plasma services.
*
* This is the class where every message to or from another machine passes through.
* This is the class where every message to or from another machine passes through.
* It's responsibilities are:
* - creating/keeping a public/private key pair for message signing.
* - signing and verifying signatures.
* - creating/keeping a credentials used for message signing.
* - verifying credentials of incoming messages.
* - testing whether or not the sender is allowed to access the requested resource by testing the
* request to a set of rules.
* - allowing the shell the shell to respond to a remote request that doesn't match any of the
* rules that are in effect.
* - allowing the shell to respond to a remote request that doesn't match any of the rules that
* are in effect.
* Besides internal use in libplasma, the only moment you'll need to access this class is when you
* implement a plasma shell.
* implement a plasma shell.
*
* @since 4.4?
* @since 4.4
*/
class PLASMA_EXPORT AuthorizationManager : public QObject
{
Q_OBJECT
public:
enum AuthorizationPolicy {
DenyAll= 0, /** < Don't allow any incoming connections */
@ -71,13 +72,17 @@ class PLASMA_EXPORT AuthorizationManager : public QObject
/**
* Set a policy used for authorizing incoming connections. You can either use one of the
* included policies, Default is to deny all incoming connections.
* included policies, Default is to deny all incoming connections. This can only be set
* once to avoid that malicious plugins can change this. This means that you should ALWAYS
* call this function in any plasma shell, even if you like to use the default DenyAll
* policy.
*/
void setAuthorizationPolicy(AuthorizationPolicy policy);
/**
* Register an implementation of AuthorizationInterface. Use this to make your shell
* handle authorization requests.
* handle authorization requests. This can only be set once to avoid that malicious plugins
* can change this.
*/
void setAuthorizationInterface(AuthorizationInterface *interface);
@ -94,16 +99,16 @@ class PLASMA_EXPORT AuthorizationManager : public QObject
AuthorizationManagerPrivate *const d;
Q_PRIVATE_SLOT(d, void loadRules())
Q_PRIVATE_SLOT(d, void slotLoadRules())
Q_PRIVATE_SLOT(d, void slotWalletOpened())
friend class AuthorizationManagerPrivate;
friend class AuthorizationManagerSingleton;
friend class AuthorizationRule;
friend class Applet;
friend class Credentials;
friend class DataEngine;
friend class GetSource;
friend class Credentials;
friend class PackagePrivate;
friend class PlasmoidServiceJob;
friend class RemoteService;

View File

@ -18,23 +18,27 @@
*/
#include "authorizationrule.h"
#include "authorizationmanager.h"
#include "credentials.h"
#include "private/authorizationmanager_p.h"
#include "private/authorizationrule_p.h"
#include <QtCore/QObject>
#include <QtCore/QTimer>
#include <QtCrypto>
#include <kurl.h>
#include <klocalizedstring.h>
#include <QtCrypto>
#include "credentials.h"
namespace Plasma
{
AuthorizationRulePrivate::AuthorizationRulePrivate(const QString &serviceName, const QString &credentialID)
: serviceName(serviceName),
AuthorizationRulePrivate::AuthorizationRulePrivate(const QString &serviceName, const QString &credentialID,
AuthorizationRule *rule)
: q(rule),
serviceName(serviceName),
credentialID(credentialID),
policy(AuthorizationRule::Deny),
targets(AuthorizationRule::Default),
@ -42,7 +46,9 @@ AuthorizationRulePrivate::AuthorizationRulePrivate(const QString &serviceName, c
{
}
AuthorizationRulePrivate::~AuthorizationRulePrivate() {}
AuthorizationRulePrivate::~AuthorizationRulePrivate()
{
}
bool AuthorizationRulePrivate::matches(const QString &name, const QString &id) const
{
@ -61,9 +67,19 @@ bool AuthorizationRulePrivate::matches(const QString &name, const QString &id) c
return false;
}
void AuthorizationRulePrivate::scheduleChangedSignal()
{
QTimer::singleShot(0, q, SLOT(fireChangedSignal()));
}
void AuthorizationRulePrivate::fireChangedSignal()
{
emit q->changed(q);
}
AuthorizationRule::AuthorizationRule(const QString &serviceName, const QString &credentialID)
: QObject(AuthorizationManager::self()),
d(new AuthorizationRulePrivate(serviceName, credentialID))
d(new AuthorizationRulePrivate(serviceName, credentialID, this))
{
}
@ -96,7 +112,7 @@ QString AuthorizationRule::description() const
void AuthorizationRule::setPolicy(Policy policy)
{
d->policy = policy;
emit changed(this);
d->scheduleChangedSignal();
}
AuthorizationRule::Policy AuthorizationRule::policy()
@ -107,7 +123,7 @@ AuthorizationRule::Policy AuthorizationRule::policy()
void AuthorizationRule::setTargets(Targets targets)
{
d->targets = targets;
emit changed(this);
d->scheduleChangedSignal();
}
AuthorizationRule::Targets AuthorizationRule::targets()
@ -118,7 +134,7 @@ AuthorizationRule::Targets AuthorizationRule::targets()
void AuthorizationRule::setPersistence(Persistence persistence)
{
d->persistence = persistence;
emit changed(this);
d->scheduleChangedSignal();
}
AuthorizationRule::Persistence AuthorizationRule::persistence()
@ -129,6 +145,7 @@ AuthorizationRule::Persistence AuthorizationRule::persistence()
void AuthorizationRule::setPin(const QString &pin)
{
d->pin = pin;
d->scheduleChangedSignal();
}
QString AuthorizationRule::pin() const
@ -148,3 +165,4 @@ QString AuthorizationRule::serviceName() const
} // Plasma namespace
#include "authorizationrule.moc"

View File

@ -69,24 +69,22 @@ class PLASMA_EXPORT AuthorizationRule : public QObject
Q_OBJECT
public:
~AuthorizationRule();
/**
* Defines this rule's behavior.
*/
enum Policy {
Deny = 0, /**< access for messages matching this rule is denied. */
Allow = 1, /**< access for messages matching this rule is allowed. */
PinRequired = 2 /**< specify that the user will need to enter a pin at both sides */
PinRequired = 2 /**< specify that the user will need to enter a pin at both sides */
};
enum Persistence {
Transient = 0,
Persistent = 1
Transient = 0, /**< specify that this rule is just valid for this session. */
Persistent = 1 /**< specify that this rule will be saved between sessions. */
};
enum Target {
Default = 0,
AllUsers = 1, /**< specify that this rule is valid for all users */
AllServices = 2 /**< specify that this rule is valid for all services */
AllServices = 2 /**< specify that this rule is valid for all services */
};
Q_DECLARE_FLAGS(Targets, Target)
@ -155,11 +153,14 @@ class PLASMA_EXPORT AuthorizationRule : public QObject
AuthorizationRulePrivate * const d;
Q_PRIVATE_SLOT(d, void fireChangedSignal());
friend class AuthorizationManager;
friend class AuthorizationManagerPrivate;
friend class ServiceProvider;
friend class AuthorizationRulePrivate;
friend class GetSource;
friend class PlasmoidServiceJob;
friend class ServiceProvider;
};
} // Plasma namespace

View File

@ -19,11 +19,11 @@
#include "clientpinrequest.h"
#include <plasma/private/remoteservice_p.h>
#include <plasma/service.h>
#include "service.h"
#include "private/remoteservice_p.h"
#include <klocalizedstring.h>
#include <kdebug.h>
#include <klocalizedstring.h>
namespace Plasma
{

View File

@ -37,9 +37,10 @@ class Service;
/**
* @class ClientPinRequest plasma/clientpinrequest.h <Plasma/ClientPinRequest>
*
* describes an outgoing connection.
* describes an outgoing connection. this is just passed to AuthorizationInterface when a remote
* widget asks to do pin pairing first, so the shell can ask the user for a pin.
*
* @since 4.4?
* @since 4.4
*/
class PLASMA_EXPORT ClientPinRequest : public QObject
{

View File

@ -15,10 +15,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IDENTITY_H
#define IDENTITY_H
#ifndef CREDENTIALS_H
#define CREDENTIALS_H
#include <plasma/plasma.h>
#include "plasma.h"
#include <QtCore/QObject>
#include <QtCore/QDataStream>
@ -50,16 +50,16 @@ public:
* Copy constructor.
*/
Credentials(const Credentials &other);
~Credentials();
Credentials &operator=(const Credentials &other);
/**
* Create a new identity with a new set of random public/private keys.
*/
static Credentials createCredentials(const QString &name);
/**
* @return whether or not this identity can be trusted based on e.g. having the key signed with
* a trusted GPG key (not yet implemented) or having the key in a designated folder on disk
@ -77,7 +77,8 @@ public:
/**
* @return the name of this identity. There's however no guarantee that if the name returns e.g.
* "Santa Claus", this message is actually from Mr. Claus, except if isTrusted is true.
* "Santa Claus", this message is actually from Mr. Claus, except if trustLevel returns a
* sufficiently high trust level.
*/
QString name() const;

View File

@ -166,6 +166,9 @@ public:
*/
void setRequiredVersion(const QString &);
/**
* Set the url where this package is hosted.
*/
void setRemoteLocation(const KUrl &);
/**

View File

@ -53,24 +53,12 @@ class AuthorizationManagerPrivate
AuthorizationManagerPrivate(AuthorizationManager *manager);
~AuthorizationManagerPrivate();
void loadRules();
/**
* @returns the rule matching the parameters with the highest priority.
*/
AuthorizationRule *matchingRule(const QString &serviceName, const Credentials &key) const;
/**
* @returns the identity with @p id. Or 0 well there's no identity with that ID.
*/
Credentials getCredentials(const QString &id = QString());
/**
* @param identity the identity to be added to the identity ring.
*/
void addCredentials(const Credentials &identity);
void slotWalletOpened();
void slotLoadRules();
AuthorizationRule *matchingRule(const QString &serviceName, const Credentials &key) const;
Credentials getCredentials(const QString &id = QString());
void addCredentials(const Credentials &identity);
void saveRules();
QCA::Initializer initializer;
@ -82,8 +70,8 @@ class AuthorizationManagerPrivate
AuthorizationInterface *customAuthorizationInterface;
KWallet::Wallet *wallet;
Credentials myCredentials;
QMap<QString, Credentials> identities;
Credentials myCredentials;
QMap<QString, Credentials> identities;
QList<AuthorizationRule*> rules;
KConfigGroup identitiesConfig;
KConfigGroup rulesConfig;

View File

@ -1,21 +1,49 @@
#include <plasma/authorizationrule.h>
/*
* Copyright 2009 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef PRIVATE_AUTHORIZATIONRULE_P_H
#define PRIVATE_AUTHORIZATIONRULE_P_H
#include "../authorizationrule.h"
namespace Plasma
{
class AuthorizationRulePrivate {
public:
AuthorizationRulePrivate(const QString &serviceName, const QString &credentialID);
AuthorizationRulePrivate(const QString &serviceName, const QString &credentialID,
AuthorizationRule *rule);
~AuthorizationRulePrivate();
bool matches(const QString &serviceName, const QString &credentialID) const;
void scheduleChangedSignal();
void fireChangedSignal();
AuthorizationRule *q;
QString serviceName;
QString credentialID;
bool PINvalidated;
QString pin;
AuthorizationRule::Policy policy;
AuthorizationRule::Targets targets;
AuthorizationRule::Persistence persistence;
};
}
#endif // PRIVATE_AUTHORIZATIONRULE_P_H

View File

@ -17,8 +17,9 @@
*/
#include "dataengineservice.h"
#include "getsource.h"
#include "../dataengine.h"
#include "getsource.h"
#include <kdebug.h>

View File

@ -19,8 +19,9 @@
#ifndef PUBLICKEYSERVICE_H
#define PUBLICKEYSERVICE_H
#include <dataengine.h>
#include <QStringList>
#include "../dataengine.h"
#include "../service.h"
namespace Plasma
@ -38,7 +39,7 @@ class DataEngineService : public Plasma::Service
public Q_SLOTS:
void dataUpdated(QString source, Plasma::DataEngine::Data data);
protected:
Plasma::ServiceJob* createJob(const QString& operation,
QMap<QString,QVariant>& parameters);

View File

@ -1,35 +0,0 @@
/*
* Copyright © 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* 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 "getpublickey.h"
#include <kdebug.h>
void GetPublicKey::start()
{
kDebug() << "Trying to perform the action" << operationName();
//TODO: check with capabilities before performing actions.
if (operationName() == "GetPublicKey") {
kDebug() << "setting result: " << m_pemKey;
setResult(m_pemKey);
}
}
#include "getpublickey.moc"

View File

@ -1,44 +0,0 @@
/*
* Copyright © 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* 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 GETPUBLICKEY_H
#define GETPUBLICKEY_H
#include <plasma/servicejob.h>
class GetPublicKey : public Plasma::ServiceJob
{
Q_OBJECT
public:
GetPublicKey(const QString &pemKey,
const QString& operation,
QMap<QString,QVariant>& parameters,
QObject* parent = 0)
: ServiceJob(QString("publickey"), operation, parameters, parent),
m_pemKey(pemKey)
{
}
void start();
private:
QString m_pemKey;
};
#endif //JOBVIEW_H

View File

@ -17,12 +17,14 @@
*/
#include "getsource.h"
#include "authorizationmanager_p.h"
#include "service_p.h"
#include "../authorizationmanager.h"
#include "../authorizationrule.h"
#include "../dataengine.h"
#include <plasma/authorizationmanager.h>
#include <plasma/private/authorizationmanager_p.h>
#include <plasma/authorizationrule.h>
#include <plasma/service.h>
#include "../service.h"
#include <kdebug.h>

View File

@ -19,10 +19,11 @@
#ifndef GETSOURCE_H
#define GETSOURCE_H
#include <plasma/servicejob.h>
#include "../dataengine.h"
#include "dataengineservice.h"
#include "../dataengine.h"
#include "../servicejob.h"
namespace Plasma
{
@ -44,11 +45,12 @@ class GetSource : public Plasma::ServiceJob
}
void start();
private:
DataEngine *m_engine;
DataEngineService *m_service;
};
}
#endif //JOBVIEW_H

View File

@ -1,6 +1,24 @@
#include <plasma.h>
#include <plasma/package.h>
#include <plasma/service.h>
/*
* Copyright © 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* 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 "../plasma.h"
#include "../package.h"
#include "../service.h"
#include <QString>
@ -13,20 +31,8 @@ public:
PackagePrivate(const PackageStructure::Ptr st, const QString &p);
~PackagePrivate();
/**
* Publish this package on the network.
* @param methods the ways to announce this package on the network.
*/
void publish(AnnouncementMethods methods);
/**
* Remove this package from the network.
*/
void unpublish();
/**
* @returns whether or not this service is currently published on the network.
*/
bool isPublished() const;
PackageStructure::Ptr structure;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>362</width>
<height>150</height>
<height>151</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -18,6 +18,9 @@
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -56,9 +59,16 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="alwaysAllowCheckbox">
<widget class="QCheckBox" name="allServicesCheckbox">
<property name="text">
<string>Always allow this user access to any service.</string>
<string>Allow this user access to any service.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="persistentCheckbox">
<property name="text">
<string>Remember this user.</string>
</property>
</widget>
</item>

View File

@ -23,13 +23,14 @@
#include "clientpinrequest.h"
#include "pinpairingdialog.h"
#include "../credentials.h"
#include <kdebug.h>
#include <credentials.h>
namespace Plasma
{
PinPairingAuthorization::PinPairingAuthorization()
{
}

View File

@ -21,8 +21,9 @@
#define PLASMA_PINPAIRINGAUTHORIZATION_H
#include "plasma_export.h"
#include "pinpairingauthorization.h"
#include "authorizationinterface.h"
#include "pinpairingauthorization.h"
#include <QtCore/QObject>
@ -36,7 +37,7 @@ namespace Plasma
* pin pairing authorization (let the user type the same password at both sides) in your shell for
* every rule that doesn't match.
*
* @since 4.4?
* @since 4.4
*/
class PLASMA_EXPORT PinPairingAuthorization : public AuthorizationInterface
{

View File

@ -22,8 +22,8 @@
#include "clientpinrequest.h"
#include "ui_pinpairing.h"
#include <kdialog.h>
#include <kdebug.h>
#include <kdialog.h>
namespace Plasma
{
@ -47,7 +47,8 @@ public:
if (request) {
dialog->setCaption(i18n("Connect with remote widget"));
pairingUI.alwaysAllowCheckbox->setVisible(false);
pairingUI.persistentCheckbox->setVisible(false);
pairingUI.allServicesCheckbox->setVisible(false);
pairingUI.descriptionLabel->setText(request->description());
}
@ -67,12 +68,15 @@ public:
kDebug();
if (rule) {
rule->setPin(pairingUI.password->text());
if (pairingUI.alwaysAllowCheckbox->isChecked()) {
if (pairingUI.allServicesCheckbox->isChecked()) {
rule->setPolicy(AuthorizationRule::PinRequired);
rule->setTargets(AuthorizationRule::AllServices);
} else {
rule->setPolicy(AuthorizationRule::PinRequired);
}
if (pairingUI.persistentCheckbox->isChecked()) {
rule->setPersistence(AuthorizationRule::Persistent);
}
}
if (request) {

View File

@ -1,6 +1,5 @@
/*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
Copyright (C) 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -34,7 +33,7 @@ class PLASMA_EXPORT PinPairingDialog : public QObject
{
Q_OBJECT
public:
PinPairingDialog(AuthorizationRule &rule, QObject* parent = 0);
PinPairingDialog(ClientPinRequest &request, QObject* parent = 0);

View File

@ -59,7 +59,7 @@ void PlasmoidServiceJob::start()
kDebug() << "sending " << m_service->m_packagePath;
QFileInfo fileInfo(m_service->m_packagePath);
if (fileInfo.exists() && fileInfo.isFile() && fileInfo.isAbsolute()) {
if (fileInfo.exists() && fileInfo.isAbsolute()) {
kDebug() << "file exists, let's try and read it";
QFile file(m_service->m_packagePath);
file.open(QIODevice::ReadOnly);
@ -91,7 +91,7 @@ PlasmoidService::PlasmoidService(const QString &packageLocation)
: Plasma::Service(0)
{
setName("plasmoidservice");
QString location;
location = packageLocation;
if (!location.endsWith('/')) {
@ -107,7 +107,6 @@ PlasmoidService::PlasmoidService(const QString &packageLocation)
}
QString packagePath = m_tempFile.fileName();
m_tempFile.close();
// put everything into a zip archive
KZip creation(packagePath);
@ -120,7 +119,7 @@ PlasmoidService::PlasmoidService(const QString &packageLocation)
location.append("contents/");
creation.addLocalDirectory(location, "contents");
creation.close();
m_packagePath = packagePath;
}

View File

@ -16,14 +16,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PUBLICKEYSERVICE_H
#define PUBLICKEYSERVICE_H
#ifndef PLASMOIDSERVICE_H
#define PLASMOIDSERVICE_H
#include "dataengineconsumer_p.h"
#include <plasma/service.h>
#include <plasma/servicejob.h>
#include <plasma/packagemetadata.h>
#include <plasma/package.h>
#include "../packagemetadata.h"
#include "../package.h"
#include "../service.h"
#include "../servicejob.h"
#include <ktemporaryfile.h>
@ -63,7 +64,7 @@ class PlasmoidService : public Service, DataEngineConsumer
PlasmoidService(Applet *applet);
PackageMetadata metadata() const;
protected:
Plasma::ServiceJob* createJob(const QString& operation,
QMap<QString,QVariant>& parameters);
@ -72,7 +73,6 @@ class PlasmoidService : public Service, DataEngineConsumer
QString m_packagePath;
PackageMetadata m_metadata;
KTemporaryFile m_tempFile;
//Package m_package;
friend class PlasmoidServiceJob;
};

View File

@ -1,82 +0,0 @@
/*
* Copyright 2009 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "publickeyfetcher.h"
#include "authorizationmanager_p.h"
#include "joliemessagehelper_p.h"
#include "../authorizationmanager.h"
#include "../accessmanager.h"
#include "../servicejob.h"
#include "../serviceaccessjob.h"
#include <QtCore/QString>
#include <KDebug>
#include <KConfigGroup>
namespace Plasma
{
PublicKeyFetcher::PublicKeyFetcher(const QString &sender)
: QObject(AuthorizationManager::self()),
m_sender(sender)
{
connect(AccessManager::self(), SIGNAL(serviceAccessFinished(Plasma::ServiceAccessJob*)),
this, SLOT(slotKeyServiceReady(Plasma::ServiceAccessJob*)));
AccessManager::self()->accessService(KUrl(sender));
}
PublicKeyFetcher::~PublicKeyFetcher()
{
}
QList<Jolie::Message> & PublicKeyFetcher::pendingMessages()
{
return m_messageList;
}
void PublicKeyFetcher::slotKeyServiceReady(Plasma::ServiceAccessJob *job)
{
if (job->service()) {
KConfigGroup op = job->service()->operationDescription("GetPublicKey");
job->service()->startOperationCall(op);
connect(job->service(), SIGNAL(finished(Plasma::ServiceJob*)),
this, SLOT(slotKeyObtained(Plasma::ServiceJob*)));
}
}
void PublicKeyFetcher::slotKeyObtained(Plasma::ServiceJob *job)
{
QByteArray reply = job->result().toByteArray();
QCA::PublicKey key = QCA::PublicKey::fromPEM(reply);
AuthorizationManager::self()->d->publicKeys[m_sender] = key;
KConfig c("plasmapublickeys");
c.group(m_sender).writeEntry("PublicKey", key.toPEM());
kDebug() << "Obtained public key from: " << m_sender << ", public key: " << reply;
foreach (Jolie::Message message, m_messageList) {
kDebug() << "process pending message: " << printJolieMessage(message);
AuthorizationManager::self()->d->startAuthorization(message, "");
}
}
} // Plasma namespace
#include "publickeyfetcher.moc"

View File

@ -1,56 +0,0 @@
/*
* Copyright 2009 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef PLASMA_PUBLICKEYFETCHER_H
#define PLASMA_PUBLICKEYFETCHER_H
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtJolie/Message>
class QString;
namespace Plasma
{
class AuthorizationManager;
class ServiceAccessJob;
class ServiceJob;
class PublicKeyFetcher : public QObject
{
Q_OBJECT
public:
PublicKeyFetcher(const QString &sender);
~PublicKeyFetcher();
QList<Jolie::Message> & pendingMessages();
private Q_SLOTS:
void slotKeyServiceReady(Plasma::ServiceAccessJob *job);
void slotKeyObtained(Plasma::ServiceJob *job);
private:
QList<Jolie::Message> m_messageList;
QString m_sender;
};
} // Plasma namespace
#endif

View File

@ -1,56 +0,0 @@
/*
* Copyright 2009 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef PLASMA_PUBLICKEYFETCHER_H
#define PLASMA_PUBLICKEYFETCHER_H
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtJolie/Message>
class QString;
namespace Plasma
{
class AuthorizationManager;
class ServiceAccessJob;
class ServiceJob;
class PublicKeyFetcher : public QObject
{
Q_OBJECT
public:
PublicKeyFetcher(const QString &sender, AuthorizationManager *am);
~PublicKeyFetcher();
QList<Jolie::Message> pendingMessages();
private Q_SLOTS:
void slotKeyServiceReady(ServiceAccessJob *job);
void slotKeyServiceObtained(ServiceAccessJob *job);
private:
QList<Jolie::Message> m_messageList;
QString m_sender;
};
} // Plasma namespace
#endif

View File

@ -1,39 +0,0 @@
/*
* Copyright © 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* 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 "publickeyservice.h"
#include "getpublickey.h"
#include <kdebug.h>
PublicKeyService::PublicKeyService(const QString &pemKey, QObject* parent)
: Plasma::Service(parent),
m_pemKey(pemKey)
{
setName("publickeyservice");
}
Plasma::ServiceJob* PublicKeyService::createJob(const QString& operation,
QMap<QString,QVariant>& parameters)
{
kDebug();
return new GetPublicKey(m_pemKey, operation, parameters, this);
}
#include "publickeyservice.moc"

View File

@ -1,40 +0,0 @@
/*
* Copyright © 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
*
* 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 PUBLICKEYSERVICE_H
#define PUBLICKEYSERVICE_H
#include "../service.h"
class PublicKeyService : public Plasma::Service
{
Q_OBJECT
public:
PublicKeyService(const QString &pemKey, QObject* parent);
protected:
Plasma::ServiceJob* createJob(const QString& operation,
QMap<QString,QVariant>& parameters);
private:
QString m_pemKey;
};
#endif

View File

@ -18,14 +18,17 @@
#include "remotedataengine.h"
#include "remoteservice_p.h"
#include "../accessmanager.h"
#include "../serviceaccessjob.h"
#include "../service.h"
#include "../servicejob.h"
#include <QTimer>
#include <QUuid>
#include <kurl.h>
#include <plasma/accessmanager.h>
#include <plasma/private/remoteservice_p.h>
#include <plasma/serviceaccessjob.h>
#include <plasma/service.h>
#include <plasma/servicejob.h>
namespace Plasma
{

View File

@ -19,8 +19,8 @@
#ifndef REMOTEDATAENGINE_H
#define REMOTEDATAENGINE_H
#include <plasma/dataengine.h>
#include <plasma/private/remoteservice_p.h>
#include "../dataengine.h"
#include "remoteservice_p.h"
class JobView;
@ -39,8 +39,6 @@ public:
Plasma::Service* serviceForSource(const QString& source);
void setLocation(KUrl location);
//Plasma::Service* serviceForSource(const QString& source);
protected:
void init();
QStringList sources() const;
@ -53,12 +51,12 @@ private Q_SLOTS:
void updateSources();
private:
Service *m_service;
QStringList m_sources;
bool m_callInProgress;
Service *m_service;
QStringList m_sources;
bool m_callInProgress;
QMap<QString, RemoteService *> m_serviceForSource;
KUrl m_location;
QString m_uuid;
KUrl m_location;
QString m_uuid;
};

View File

@ -17,15 +17,15 @@
*/
#include "remoteservice_p.h"
#include "joliemessagehelper_p.h"
#include <plasma/accessmanager.h>
#include <plasma/authorizationinterface.h>
#include <plasma/authorizationmanager.h>
#include <plasma/clientpinrequest.h>
#include <plasma/service.h>
#include "../accessmanager.h"
#include "../authorizationinterface.h"
#include "../authorizationmanager.h"
#include "../clientpinrequest.h"
#include "../service.h"
#include "authorizationmanager_p.h"
#include "joliemessagehelper_p.h"
#include "remoteservicejob_p.h"
#include "service_p.h"

View File

@ -22,7 +22,7 @@
#include <QtCore/QQueue>
#include <QtJolie/Message>
#include <plasma/service.h>
#include "../service.h"
namespace Jolie
{

View File

@ -16,8 +16,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <plasma/servicejob.h>
#include <plasma/credentials.h>
#ifndef SERVICEJOB_P_H
#define SERVICEJOB_P_H
#include "../credentials.h"
#include "../servicejob.h"
#include <QString>
#include <QVariant>
@ -44,4 +47,5 @@ public:
Credentials identity;
};
}
}
#endif // SERVICEJOB_P_H

View File

@ -28,7 +28,7 @@
namespace Plasma
{
TrustedOnlyAuthorization::TrustedOnlyAuthorization()
{
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM
"http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfg>
<group name="GetPublicKey" />
</kcfg>