Add "freely accessable for everybody" checkbox to the publish page in
the applet config. svn path=/trunk/KDE/kdelibs/; revision=1019593
This commit is contained in:
parent
fb14be1caa
commit
c69e570b68
54
applet.cpp
54
applet.cpp
@ -64,6 +64,7 @@
|
|||||||
#include <solid/powermanagement.h>
|
#include <solid/powermanagement.h>
|
||||||
|
|
||||||
#include "authorizationmanager.h"
|
#include "authorizationmanager.h"
|
||||||
|
#include "authorizationrule.h"
|
||||||
#include "configloader.h"
|
#include "configloader.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
@ -1454,7 +1455,7 @@ bool Applet::hasConfigurationInterface() const
|
|||||||
return d->hasConfigurationInterface;
|
return d->hasConfigurationInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::publish(AnnouncementMethods methods)
|
void Applet::publish(AnnouncementMethods methods, const QString &resourceName)
|
||||||
{
|
{
|
||||||
if (d->package) {
|
if (d->package) {
|
||||||
d->package->d->publish(methods);
|
d->package->d->publish(methods);
|
||||||
@ -1463,9 +1464,6 @@ void Applet::publish(AnnouncementMethods methods)
|
|||||||
d->service = new PlasmoidService(this);
|
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(), QHostInfo::localHostName());
|
|
||||||
kDebug() << "publishing package under name " << resourceName;
|
kDebug() << "publishing package under name " << resourceName;
|
||||||
d->service->d->publish(methods, resourceName);
|
d->service->d->publish(methods, resourceName);
|
||||||
}
|
}
|
||||||
@ -1748,10 +1746,32 @@ void AppletPrivate::addPublishPage(KConfigDialog *dialog)
|
|||||||
{
|
{
|
||||||
QWidget *page = new QWidget;
|
QWidget *page = new QWidget;
|
||||||
publishUI.setupUi(page);
|
publishUI.setupUi(page);
|
||||||
publishUI.publishCheckbox->setChecked(q->config().readEntry("Publish", false));
|
publishUI.publishCheckbox->setChecked(q->isPublished());
|
||||||
|
publishUI.allUsersCheckbox->setEnabled(q->isPublished());
|
||||||
|
|
||||||
|
QString resourceName =
|
||||||
|
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on",
|
||||||
|
"%1 on %2", q->name(), QHostInfo::localHostName());
|
||||||
|
if (AuthorizationManager::self()->d->matchingRule(resourceName, Credentials())) {
|
||||||
|
publishUI.allUsersCheckbox->setChecked(true);
|
||||||
|
} else {
|
||||||
|
publishUI.allUsersCheckbox->setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
q->connect(publishUI.publishCheckbox, SIGNAL(stateChanged(int)),
|
||||||
|
q, SLOT(publishCheckboxStateChanged(int)));
|
||||||
dialog->addPage(page, i18n("Publish"), "applications-internet");
|
dialog->addPage(page, i18n("Publish"), "applications-internet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppletPrivate::publishCheckboxStateChanged(int state)
|
||||||
|
{
|
||||||
|
if (state == Qt::Checked) {
|
||||||
|
publishUI.allUsersCheckbox->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
publishUI.allUsersCheckbox->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AppletPrivate::clearShortcutEditorPtr()
|
void AppletPrivate::clearShortcutEditorPtr()
|
||||||
{
|
{
|
||||||
shortcutEditor = 0;
|
shortcutEditor = 0;
|
||||||
@ -1770,7 +1790,24 @@ void AppletPrivate::configDialogFinished()
|
|||||||
q->config().writeEntry("Publish", publishUI.publishCheckbox->isChecked());
|
q->config().writeEntry("Publish", publishUI.publishCheckbox->isChecked());
|
||||||
|
|
||||||
if (publishUI.publishCheckbox->isChecked()) {
|
if (publishUI.publishCheckbox->isChecked()) {
|
||||||
q->publish(Plasma::ZeroconfAnnouncement);
|
QString resourceName =
|
||||||
|
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on",
|
||||||
|
"%1 on %2", q->name(), QHostInfo::localHostName());
|
||||||
|
q->publish(Plasma::ZeroconfAnnouncement, resourceName);
|
||||||
|
if (publishUI.allUsersCheckbox->isChecked()) {
|
||||||
|
if (!AuthorizationManager::self()->d->matchingRule(resourceName, Credentials())) {
|
||||||
|
AuthorizationRule *rule = new AuthorizationRule(resourceName, "");
|
||||||
|
rule->setPolicy(AuthorizationRule::Allow);
|
||||||
|
rule->setTargets(AuthorizationRule::AllUsers);
|
||||||
|
AuthorizationManager::self()->d->rules.append(rule);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AuthorizationRule *matchingRule =
|
||||||
|
AuthorizationManager::self()->d->matchingRule(resourceName, Credentials());
|
||||||
|
if (matchingRule) {
|
||||||
|
AuthorizationManager::self()->d->rules.removeAll(matchingRule);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
q->unpublish();
|
q->unpublish();
|
||||||
}
|
}
|
||||||
@ -2406,11 +2443,6 @@ void AppletPrivate::init(const QString &packagePath)
|
|||||||
configAction->setText(i18nc("%1 is the name of the applet", "%1 Settings", q->name()));
|
configAction->setText(i18nc("%1 is the name of the applet", "%1 Settings", q->name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
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()));
|
QObject::connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
|
||||||
QObject::connect(q, SIGNAL(activate()), q, SLOT(setFocus()));
|
QObject::connect(q, SIGNAL(activate()), q, SLOT(setFocus()));
|
||||||
}
|
}
|
||||||
|
9
applet.h
9
applet.h
@ -788,7 +788,13 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
|||||||
*/
|
*/
|
||||||
void setStatus(const ItemStatus stat);
|
void setStatus(const ItemStatus stat);
|
||||||
|
|
||||||
void publish(Plasma::AnnouncementMethods method);
|
/**
|
||||||
|
* Publishes and optionally announces this applet on the network for remote access.
|
||||||
|
* @param methods the methods to use for announcing this applet.
|
||||||
|
* @param resourceName the name under which this applet will be published (has to be unique
|
||||||
|
* for each machine)
|
||||||
|
*/
|
||||||
|
void publish(Plasma::AnnouncementMethods methods, const QString &resourceName);
|
||||||
|
|
||||||
void unpublish();
|
void unpublish();
|
||||||
|
|
||||||
@ -992,6 +998,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
|||||||
Q_PRIVATE_SLOT(d, void clearShortcutEditorPtr())
|
Q_PRIVATE_SLOT(d, void clearShortcutEditorPtr())
|
||||||
Q_PRIVATE_SLOT(d, void configDialogFinished())
|
Q_PRIVATE_SLOT(d, void configDialogFinished())
|
||||||
Q_PRIVATE_SLOT(d, void updateShortcuts())
|
Q_PRIVATE_SLOT(d, void updateShortcuts())
|
||||||
|
Q_PRIVATE_SLOT(d, void publishCheckboxStateChanged(int state))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplemented from QGraphicsItem
|
* Reimplemented from QGraphicsItem
|
||||||
|
@ -99,6 +99,7 @@ public:
|
|||||||
QString configDialogId() const;
|
QString configDialogId() const;
|
||||||
QString configWindowTitle() const;
|
QString configWindowTitle() const;
|
||||||
void updateShortcuts();
|
void updateShortcuts();
|
||||||
|
void publishCheckboxStateChanged(int state);
|
||||||
|
|
||||||
static KActionCollection* defaultActions(QObject *parent);
|
static KActionCollection* defaultActions(QObject *parent);
|
||||||
static QSet<QString> knownCategories();
|
static QSet<QString> knownCategories();
|
||||||
|
@ -56,6 +56,7 @@ void GetSource::start()
|
|||||||
service->d->publish(Plasma::NoAnnouncement, serviceName);
|
service->d->publish(Plasma::NoAnnouncement, serviceName);
|
||||||
if (!AuthorizationManager::self()->d->matchingRule(serviceName, identity())) {
|
if (!AuthorizationManager::self()->d->matchingRule(serviceName, identity())) {
|
||||||
AuthorizationRule *rule = new AuthorizationRule(serviceName, identity().id());
|
AuthorizationRule *rule = new AuthorizationRule(serviceName, identity().id());
|
||||||
|
rule->setPolicy(AuthorizationRule::Allow);
|
||||||
AuthorizationManager::self()->d->rules.append(rule);
|
AuthorizationManager::self()->d->rules.append(rule);
|
||||||
}
|
}
|
||||||
setResult(serviceName);
|
setResult(serviceName);
|
||||||
|
@ -108,6 +108,7 @@ class PLASMA_EXPORT AuthorizationManager : public QObject
|
|||||||
friend class AuthorizationRule;
|
friend class AuthorizationRule;
|
||||||
friend class AuthorizationRulePrivate;
|
friend class AuthorizationRulePrivate;
|
||||||
friend class Applet;
|
friend class Applet;
|
||||||
|
friend class AppletPrivate;
|
||||||
friend class Credentials;
|
friend class Credentials;
|
||||||
friend class DataEngine;
|
friend class DataEngine;
|
||||||
friend class GetSource;
|
friend class GetSource;
|
||||||
|
@ -155,6 +155,7 @@ class PLASMA_EXPORT AuthorizationRule : public QObject
|
|||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void fireChangedSignal())
|
Q_PRIVATE_SLOT(d, void fireChangedSignal())
|
||||||
|
|
||||||
|
friend class AppletPrivate;
|
||||||
friend class AuthorizationManager;
|
friend class AuthorizationManager;
|
||||||
friend class AuthorizationManagerPrivate;
|
friend class AuthorizationManagerPrivate;
|
||||||
friend class AuthorizationRulePrivate;
|
friend class AuthorizationRulePrivate;
|
||||||
|
Loading…
Reference in New Issue
Block a user