summaryrefslogtreecommitdiffstats
path: root/kcontrol/dnssd
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/dnssd')
-rw-r--r--kcontrol/dnssd/configdialog.ui120
-rw-r--r--kcontrol/dnssd/kcm_kdnssd.desktop9
-rw-r--r--kcontrol/dnssd/kcmdnssd.cpp54
-rw-r--r--kcontrol/dnssd/kcmdnssd.h2
4 files changed, 133 insertions, 52 deletions
diff --git a/kcontrol/dnssd/configdialog.ui b/kcontrol/dnssd/configdialog.ui
index 83808d1bb..848457a44 100644
--- a/kcontrol/dnssd/configdialog.ui
+++ b/kcontrol/dnssd/configdialog.ui
@@ -44,45 +44,17 @@
<attribute name="title">
<string>&amp;General</string>
</attribute>
- <vbox>
+ <grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
- <widget class="QCheckBox">
- <property name="name">
- <cstring>kcfg_BrowseLocal</cstring>
- </property>
- <property name="text">
- <string>Browse local networ&amp;k</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Browse local network (domain .local) using multicast DNS.</string>
- </property>
- </widget>
- <widget class="KEditListBox">
- <property name="name">
- <cstring>kcfg_DomainList</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>7</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Additional Domains</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>List of Internet domains that will be browsed for services. Do not put .local here - it
-is configured with 'Browse local network' option above.</string>
- </property>
- </widget>
- <widget class="QButtonGroup">
+ <widget class="QButtonGroup" row="3" column="0">
<property name="name">
<cstring>kcfg_PublishType</cstring>
</property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
@@ -96,50 +68,104 @@ is configured with 'Browse local network' option above.</string>
</property>
<widget class="QRadioButton">
<property name="name">
- <cstring>LANButtor</cstring>
+ <cstring>WANButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>11</x>
- <y>23</y>
+ <y>51</y>
<width>618</width>
<height>22</height>
</rect>
</property>
<property name="text">
- <string>Loc&amp;al network</string>
+ <string>&amp;Wide area network</string>
</property>
- <property name="checked">
- <bool>false</bool>
+ <property name="accel">
+ <string>Alt+W</string>
</property>
<property name="whatsThis" stdset="0">
- <string>Advertise services on local network (in domain .local) using multicast DNS.</string>
+ <string>Advertise services on Internet domain using public IP. To have this option working you need to configure wide area operation in using administrator mode</string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
- <cstring>WANButton</cstring>
- </property>
- <property name="enabled">
- <bool>true</bool>
+ <cstring>LANButtor</cstring>
</property>
<property name="geometry">
<rect>
<x>11</x>
- <y>51</y>
+ <y>23</y>
<width>618</width>
<height>22</height>
</rect>
</property>
<property name="text">
- <string>&amp;Wide area network</string>
+ <string>Loc&amp;al network</string>
+ </property>
+ <property name="accel">
+ <string>Alt+A</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
</property>
<property name="whatsThis" stdset="0">
- <string>Advertise services on Internet domain using public IP. To have this option working you need to configure wide area operation in using administrator mode</string>
+ <string>Advertise services on local network (in domain .local) using multicast DNS.</string>
</property>
</widget>
</widget>
- </vbox>
+ <widget class="QCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>kcfg_BrowseLocal</cstring>
+ </property>
+ <property name="text">
+ <string>Browse local networ&amp;k</string>
+ </property>
+ <property name="accel">
+ <string>Alt+K</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Browse local network (domain .local) using multicast DNS.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>enableZeroconf</cstring>
+ </property>
+ <property name="text">
+ <string>Enable &amp;Zeroconf network browsing</string>
+ </property>
+ <property name="accel">
+ <string>Alt+Z</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Browse local network (domain .local) using multicast DNS.</string>
+ </property>
+ </widget>
+ <widget class="KEditListBox" row="2" column="0">
+ <property name="name">
+ <cstring>kcfg_DomainList</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Additional Domains</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>List of Internet domains that will be browsed for services. Do not put .local here - it
+is configured with 'Browse local network' option above.</string>
+ </property>
+ </widget>
+ </grid>
</widget>
<widget class="QWidget">
<property name="name">
diff --git a/kcontrol/dnssd/kcm_kdnssd.desktop b/kcontrol/dnssd/kcm_kdnssd.desktop
index 8b949e370..b0d731098 100644
--- a/kcontrol/dnssd/kcm_kdnssd.desktop
+++ b/kcontrol/dnssd/kcm_kdnssd.desktop
@@ -70,9 +70,9 @@ Comment[zh_TW]=設定服務偵測
Exec=kcmshell kcm_kdnssd
GenericName=
GenericName[ko]=일반
-Icon=blockdevice
+Icon=network_local
MimeType=
-Name=Service Discovery
+Name=Zeroconf Service Discovery
Name[af]=Dienste ontdekker
Name[ar]=إكتشاف الخدمات
Name[be]=Пошук сервісаў
@@ -149,6 +149,7 @@ X-KDE-HasReadOnlyMode=false
X-KDE-Library=kdnssd
X-KDE-ModuleType=Library
X-KDE-ParentApp=kcontrol
-X-KDE-SubstituteUID=false
-X-KDE-RootOnly=true
+#root parts unused with Avahi
+#X-KDE-SubstituteUID=false
+#X-KDE-RootOnly=true
Categories=Qt;KDE;X-KDE-settings-network;
diff --git a/kcontrol/dnssd/kcmdnssd.cpp b/kcontrol/dnssd/kcmdnssd.cpp
index d86cc2897..d754f0025 100644
--- a/kcontrol/dnssd/kcmdnssd.cpp
+++ b/kcontrol/dnssd/kcmdnssd.cpp
@@ -27,6 +27,10 @@
#include <qradiobutton.h>
#include <qtimer.h>
#include <qtabwidget.h>
+#include <qcheckbox.h>
+#include <qprocess.h>
+#include <qcursor.h>
+#include <qbuttongroup.h>
#include <klocale.h>
#include <kglobal.h>
@@ -35,6 +39,8 @@
#include <klineedit.h>
#include <kpassdlg.h>
#include <ksimpleconfig.h>
+#include <kapplication.h>
+#include <kmessagebox.h>
#include "kcmdnssd.h"
#include <dnssd/settings.h>
@@ -65,7 +71,10 @@ KCMDnssd::KCMDnssd(QWidget *parent, const char *name, const QStringList&)
connect(hostedit,SIGNAL(textChanged(const QString&)),this,SLOT(wdchanged()));
connect(secretedit,SIGNAL(textChanged(const QString&)),this,SLOT(wdchanged()));
connect(domainedit,SIGNAL(textChanged(const QString&)),this,SLOT(wdchanged()));
+ connect(enableZeroconf,SIGNAL(toggled(bool)),this,SLOT(enableZeroconfChanged(bool)));
+ m_enableZeroconfChanged=false;
if (DNSSD::Configuration::self()->publishDomain().isEmpty()) WANButton->setEnabled(false);
+ kcfg_PublishType->hide(); //unused with Avahi
}
KCMDnssd::~KCMDnssd()
@@ -75,18 +84,55 @@ KCMDnssd::~KCMDnssd()
void KCMDnssd::save()
{
+ setCursor(QCursor(Qt::BusyCursor));
KCModule::save();
if (geteuid()==0 && m_wdchanged) saveMdnsd();
domain->setFileWriteMode(0644); // this should be readable for everyone
domain->writeEntry("PublishDomain",domainedit->text());
domain->sync();
KIPC::sendMessageAll((KIPC::Message)KIPCDomainsChanged);
+ if (m_enableZeroconfChanged) {
+
+ QString scaryMessage = i18n("Enabling local network browsing will open a network port (5353) on your computer. If security problems are discovered in the zeroconf server, remote attackers could access your computer as the \"avahi\" user.");
+
+ KProcess *proc = new KProcess;
+
+ *proc << "kdesu";
+
+ if (enableZeroconf->isChecked()) {
+ if (KMessageBox::warningYesNo( this, scaryMessage, i18n("Enable Zeroconf Network Browsing"), KGuiItem(i18n("Enable Browsing")), KGuiItem(i18n("Don't Enable Browsing")) ) == KMessageBox::Yes) {
+
+ *proc << "/usr/share/avahi/enable_avahi 1";
+ proc->start(KProcess::Block);
+ } else {
+ enableZeroconf->setChecked(false);
+ }
+ } else {
+ *proc << "/usr/share/avahi/enable_avahi 0";
+ proc->start(KProcess::Block);
+ }
+ }
+ setCursor(QCursor(Qt::ArrowCursor));
}
void KCMDnssd::load()
{
- KCModule::load();
if (geteuid()==0) loadMdnsd();
+ enableZeroconf->setChecked(false);
+ QProcess avahiStatus(QString("/usr/share/avahi/avahi_status"), this, "avahiStatus");
+ avahiStatus.start();
+ while (avahiStatus.isRunning()) {
+ kapp->processEvents();
+ }
+ int exitStatus = avahiStatus.exitStatus();
+ if (exitStatus == 0) { // disabled
+ enableZeroconf->setChecked(false);
+ } else if (exitStatus == 1) { // enabled
+ enableZeroconf->setChecked(true);
+ } else if (exitStatus == 2) { // custom setup
+ enableZeroconf->setEnabled(false);
+ }
+ KCModule::load();
}
// hack to work around not working isModified() for KPasswordEdit
@@ -97,6 +143,12 @@ void KCMDnssd::wdchanged()
m_wdchanged=true;
}
+void KCMDnssd::enableZeroconfChanged(bool)
+{
+ changed();
+ m_enableZeroconfChanged=true;
+}
+
void KCMDnssd::loadMdnsd()
{
QFile f(MDNSD_CONF);
diff --git a/kcontrol/dnssd/kcmdnssd.h b/kcontrol/dnssd/kcmdnssd.h
index 2e66f6a8f..384f7b625 100644
--- a/kcontrol/dnssd/kcmdnssd.h
+++ b/kcontrol/dnssd/kcmdnssd.h
@@ -38,12 +38,14 @@ public:
virtual void load();
private slots:
void wdchanged();
+ void enableZeroconfChanged(bool);
private:
void loadMdnsd();
bool saveMdnsd();
QMap<QString,QString> mdnsdLines;
bool m_wdchanged;
KSimpleConfig* domain;
+ bool m_enableZeroconfChanged;
};
#endif