2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program 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, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 SERVICE_P_H
|
|
|
|
#define SERVICE_P_H
|
|
|
|
|
|
|
|
#include "servicejob.h"
|
2009-09-02 04:27:16 +02:00
|
|
|
#include "service.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
#include <QMap>
|
2008-11-04 00:08:39 +01:00
|
|
|
#include <QMultiHash>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QSet>
|
|
|
|
|
2011-05-31 01:01:18 +02:00
|
|
|
#include <kplugininfo.h>
|
2012-09-17 18:56:56 +02:00
|
|
|
#include <klocalizedstring.h>
|
2011-05-31 01:01:18 +02:00
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
#include <dnssd/publicservice.h>
|
|
|
|
#include <dnssd/servicebrowser.h>
|
|
|
|
|
2009-01-16 18:16:10 +01:00
|
|
|
#include "plasma/configloader.h"
|
2009-09-02 04:27:16 +02:00
|
|
|
#include "accessmanager_p.h"
|
2009-01-16 18:16:10 +01:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class ConfigLoader;
|
2009-09-02 04:27:16 +02:00
|
|
|
class ServiceProvider;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
class NullServiceJob : public ServiceJob
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NullServiceJob(const QString &destination, const QString &operation, QObject *parent)
|
2011-05-26 19:01:44 +02:00
|
|
|
: ServiceJob(destination, operation, QHash<QString, QVariant>(), parent)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void start()
|
|
|
|
{
|
|
|
|
setErrorText(i18nc("Error message, tried to start an invalid service", "Invalid (null) service, can not perform any operations."));
|
|
|
|
emitResult();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class NullService : public Service
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NullService(const QString &target, QObject *parent)
|
|
|
|
: Service(parent)
|
|
|
|
{
|
|
|
|
setDestination(target);
|
|
|
|
setName("NullService");
|
|
|
|
}
|
|
|
|
|
2011-05-26 19:01:44 +02:00
|
|
|
ServiceJob *createJob(const QString &operation, QHash<QString, QVariant> &)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
return new NullServiceJob(destination(), operation, this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ServicePrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ServicePrivate(Service *service)
|
|
|
|
: q(service),
|
|
|
|
config(0),
|
2009-08-02 20:24:20 +02:00
|
|
|
dummyConfig(0),
|
2009-09-02 04:27:16 +02:00
|
|
|
publicService(0),
|
|
|
|
serviceProvider(0)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
}
|
2009-01-16 18:16:10 +01:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
~ServicePrivate()
|
|
|
|
{
|
2009-01-16 18:16:10 +01:00
|
|
|
delete config;
|
2009-08-02 20:24:20 +02:00
|
|
|
delete dummyConfig;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
void associatedWidgetDestroyed(QObject *obj);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-09-25 21:35:53 +02:00
|
|
|
void associatedItemDestroyed(QObject *obj);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
void publish(AnnouncementMethods methods, const QString &name,
|
2011-05-31 01:01:18 +02:00
|
|
|
const KPluginInfo &metadata = KPluginInfo());
|
2009-08-02 20:24:20 +02:00
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
void unpublish();
|
2009-08-02 20:24:20 +02:00
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
bool isPublished() const;
|
|
|
|
|
|
|
|
KConfigGroup dummyGroup();
|
2009-08-02 20:24:20 +02:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
Service *q;
|
|
|
|
QString destination;
|
|
|
|
QString name;
|
2009-09-02 04:27:16 +02:00
|
|
|
QString resourcename;
|
2008-11-04 00:08:39 +01:00
|
|
|
ConfigLoader *config;
|
2009-08-02 20:24:20 +02:00
|
|
|
KConfig *dummyConfig;
|
2009-09-02 04:27:16 +02:00
|
|
|
DNSSD::PublicService *publicService;
|
|
|
|
ServiceProvider *serviceProvider;
|
2008-11-04 00:08:39 +01:00
|
|
|
QMultiHash<QWidget *, QString> associatedWidgets;
|
2012-09-25 21:35:53 +02:00
|
|
|
QMultiHash<QGraphicsObject *, QString> associatedItems;
|
2008-11-04 00:08:39 +01:00
|
|
|
QSet<QString> disabledOperations;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|