diff options
Diffstat (limited to 'kcontrol/dnssd')
-rw-r--r-- | kcontrol/dnssd/CMakeLists.txt | 36 | ||||
-rw-r--r-- | kcontrol/dnssd/Makefile.am | 12 | ||||
-rw-r--r-- | kcontrol/dnssd/configdialog.ui | 330 | ||||
-rw-r--r-- | kcontrol/dnssd/kcm_tdednssd.desktop | 156 | ||||
-rw-r--r-- | kcontrol/dnssd/kcmdnssd.cpp | 208 | ||||
-rw-r--r-- | kcontrol/dnssd/kcmdnssd.h | 52 |
6 files changed, 794 insertions, 0 deletions
diff --git a/kcontrol/dnssd/CMakeLists.txt b/kcontrol/dnssd/CMakeLists.txt new file mode 100644 index 000000000..e0036ba24 --- /dev/null +++ b/kcontrol/dnssd/CMakeLists.txt @@ -0,0 +1,36 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### other data ################################ + +install( FILES kcm_tdednssd.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) + + +##### kcm_tdednssd (module) ####################### + +set_source_files_properties( kcmdnssd.cpp PROPERTIES COMPILE_FLAGS -DKDE_CONFDIR=\\"${TDE_CONFIG_DIR}\\" ) + +tde_add_kpart( kcm_tdednssd AUTOMOC + SOURCES configdialog.ui kcmdnssd.cpp + LINK tdednssd-shared tdeui-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/kcontrol/dnssd/Makefile.am b/kcontrol/dnssd/Makefile.am new file mode 100644 index 000000000..79c1698c2 --- /dev/null +++ b/kcontrol/dnssd/Makefile.am @@ -0,0 +1,12 @@ +INCLUDES = $(all_includes) +METASOURCES = AUTO +kde_module_LTLIBRARIES = kcm_tdednssd.la +kcm_tdednssd_la_LDFLAGS = -avoid-version -module -no-undefined $(all_libraries) +kcm_tdednssd_la_SOURCES = configdialog.ui kcmdnssd.cpp kcmdnssd.h + +xdg_apps_DATA = kcm_tdednssd.desktop +kcm_tdednssd_la_LIBADD = $(LIB_TDEDNSSD) $(LIB_TDEUI) + +messages: rc.cpp + $(EXTRACTRC) *.ui *.rc >> rc.cpp + $(XGETTEXT) $(kcm_tdednssd_la_SOURCES) rc.cpp -o $(podir)/kcmtdednssd.pot diff --git a/kcontrol/dnssd/configdialog.ui b/kcontrol/dnssd/configdialog.ui new file mode 100644 index 000000000..0066f7d90 --- /dev/null +++ b/kcontrol/dnssd/configdialog.ui @@ -0,0 +1,330 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>ConfigDialog</class> +<widget class="TDECModule"> + <property name="name"> + <cstring>ConfigDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>571</width> + <height>486</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="caption"> + <string>MyDialog1</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>tabs</cstring> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>&General</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQButtonGroup" 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> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Publishing Mode</string> + </property> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>WANButton</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>11</x> + <y>51</y> + <width>618</width> + <height>22</height> + </rect> + </property> + <property name="text"> + <string>&Wide area network</string> + </property> + <property name="accel"> + <string>Alt+W</string> + </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> + </property> + </widget> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>LANButtor</cstring> + </property> + <property name="geometry"> + <rect> + <x>11</x> + <y>23</y> + <width>618</width> + <height>22</height> + </rect> + </property> + <property name="text"> + <string>Loc&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 local network (in domain .local) using multicast DNS.</string> + </property> + </widget> + </widget> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>kcfg_BrowseLocal</cstring> + </property> + <property name="text"> + <string>Browse local networ&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="TQCheckBox" row="0" column="0"> + <property name="name"> + <cstring>enableZeroconf</cstring> + </property> + <property name="text"> + <string>Enable &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="TQWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>W&ide area</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Shared secret:</string> + </property> + </widget> + <spacer row="1" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>130</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="KLineEdit" row="1" column="3"> + <property name="name"> + <cstring>hostedit</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Name of this machine. Must be in fully qualified form (host.domain)</string> + </property> + </widget> + <widget class="KPasswordEdit" row="2" column="3"> + <property name="name"> + <cstring>secretedit</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>Optional shared secret used for authorization of DNS dynamic updates.</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>domainLabel</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Domain:</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Hostname:</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="3"> + <property name="name"> + <cstring>domainedit</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + <spacer row="0" column="2"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>90</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="2"> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>90</width> + <height>21</height> + </size> + </property> + </spacer> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>50</width> + <height>110</height> + </size> + </property> + </spacer> + </vbox> + </widget> + </widget> + </grid> +</widget> +<Q_SLOTS> + <slot>radioButton2_2_toggled(bool)</slot> +</Q_SLOTS> +<includes> + <include location="global" impldecl="in declaration">tdecmodule.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>tdecmodule.h</includehint> + <includehint>keditlistbox.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kpassdlg.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> diff --git a/kcontrol/dnssd/kcm_tdednssd.desktop b/kcontrol/dnssd/kcm_tdednssd.desktop new file mode 100644 index 000000000..bf7e627bb --- /dev/null +++ b/kcontrol/dnssd/kcm_tdednssd.desktop @@ -0,0 +1,156 @@ +[Desktop Entry] +Exec=tdecmshell kcm_tdednssd +Icon=network_local +MimeType= +X-DocPath=kcontrol/dnssd/index.html +StartupNotify=true +Terminal=false +Type=Application +X-DCOP-ServiceType= +X-TDE-HasReadOnlyMode=false +X-TDE-Library=tdednssd +X-TDE-ModuleType=Library +X-TDE-ParentApp=kcontrol +#root parts unused with Avahi +#X-TDE-SubstituteUID=false +#X-TDE-RootOnly=true +Categories=Qt;TDE;X-TDE-settings-network; + +GenericName= +GenericName[ko]=일반 +Name=Zeroconf Service Discovery +Name[af]=Dienste ontdekker +Name[ar]=إكتشاف الخدمات +Name[be]=Пошук сервісаў +Name[bg]=Откриване на услуги +Name[bn]=সার্ভিস উদ্ঘাটন +Name[bs]=Otkrivanje servisa +Name[ca]=Descobriment de serveis +Name[cs]=Hledání služeb +Name[csb]=Wëkrëwanié ùsłëżnotów +Name[da]=Opdagelse af tjenester +Name[de]=Dienste-Suche +Name[el]=Εύρεση υπηρεσιών +Name[eo]=Servo-Serĉado +Name[es]=Buscador de servicios +Name[et]=Teenuste tuvastamine +Name[eu]=Igartze zerbitzua +Name[fa]=کشف خدمت +Name[fi]=Palvelut +Name[fr]=Découverte de service +Name[fy]=Tsjinst warskôging +Name[ga]=Fionnachtain Seirbhísí +Name[gl]=Descubremento de Servizos +Name[he]=זיהוי שירותים +Name[hi]=सेवा डिस्कवरी +Name[hr]=Usluga Discovery +Name[hu]=Zeroconf-beállítások +Name[is]=Uppgötvun þjónustu +Name[it]=Scoperta servizi +Name[ja]=サービスディスカバリ +Name[ka]=სერვისის აღმოჩენა +Name[kk]=Қызметтерді байқау +Name[km]=ការរកឃើញសេវា +Name[ko]=서비스 발견 +Name[lt]=Tarnybų radimas +Name[lv]=Servisu atklāšana +Name[mk]=Откривање сервиси +Name[ms]=Penemuan Servis +Name[nb]=Oppdaging av tjenester +Name[nds]=Deensten finnen +Name[ne]=पत्ता लगाउने कार्य +Name[nl]=Dienstwaarneming +Name[nn]=Oppdaging av tenester +Name[pa]=ਸੇਵਾ ਖੋਜ +Name[pl]=Wykrywanie usług +Name[pt]=Descoberta de Serviços +Name[pt_BR]=Serviço Discovery +Name[ro]=Descoperire servicii +Name[ru]=Обнаружение служб +Name[rw]=Ivumbura rya Serivisi +Name[se]=Bálvalusáican +Name[sk]=Služba Discovery +Name[sl]=Odkrivanje storitev +Name[sr]=Откривање сервиса +Name[sr@Latn]=Otkrivanje servisa +Name[sv]=Tjänstupptäckt +Name[ta]=சர்வீஸ் டிஸ்கவரி +Name[tg]=Хизмати ихтироъ +Name[th]=การค้นพบบริการ +Name[tr]=Hizmet Araştırması +Name[tt]=Xezmätlär Tabu +Name[uk]=Знаходження служб +Name[uz]=Tarmoqdagi xizmatlarni qidirish +Name[uz@cyrillic]=Тармоқдаги хизматларни қидириш +Name[vi]=Dịch vụ Khám phá +Name[wa]=Discovraedje di siervices +Name[zh_CN]=服务探索 +Name[zh_TW]=服務偵測 +Comment=Configure service discovery +Comment[af]=Stel dienste ontdekker op +Comment[ar]=إعداد إكتشاف الخدمات +Comment[be]=Настаўленні пошуку сервісаў +Comment[bg]=Настройване откриването на услуги +Comment[bn]=সার্ভিস উদ্ঘাটন কনফিগার করুন +Comment[bs]=Podesite otkrivanje servisa +Comment[ca]=Configura el descobriment de serveis +Comment[cs]=Nastavení hledání služeb +Comment[csb]=Kòfigùracëjô wëkrëwaniô ùsłëżnotów +Comment[da]=Indstil opdagelse af tjeneste +Comment[de]=Diensteerkennung einrichten +Comment[el]=Ρύθμιση εύρεσης υπηρεσιών +Comment[eo]=Agordu servo-seĉadon +Comment[es]=Configura el buscador de servicios +Comment[et]=Teenuste tuvastamise seadistamine +Comment[eu]=Konfiguratu igartze zerbitzua +Comment[fa]=پیکربندی کشف خدمت +Comment[fi]=Asetuspalvelimen löytäminen +Comment[fr]=Configuration de la découverte de service +Comment[fy]=Tsjinst waarnimming ynstellen +Comment[ga]=Cumraigh fionnachtain seirbhísí +Comment[gl]=Configurar o descubremento de servizos +Comment[he]=הגדרת זיהוי השירותים +Comment[hi]=सेवा डिस्कवरी कॉन्फ़िगर करें +Comment[hr]=Konfiguriranje usluge discovery +Comment[hu]=A szolgáltatásdetektálás beállításai +Comment[is]=Stilla uppgötvun þjónustna +Comment[it]=Configura scoperta servizi +Comment[ja]=サービスディスカバリの設定 +Comment[ka]=სერვისის არმოჩენის კონფიგურირება +Comment[kk]=Қызыметтерді байқауды баптау +Comment[km]=កំណត់រចនាសម្ព័ន្ធការរកឃើញសេវា +Comment[ko]=서비스 발견 설정 +Comment[lt]=Konfigūruoti tarnybų radimą +Comment[lv]=Konfigurē servisu atrašanu +Comment[mk]=Конфигурирајте го откривањето сервиси +Comment[ms]=Konfigur penemuan servis +Comment[nb]=Sett opp oppdagingstjenesten +Comment[nds]=Dat Finnen vun Deensten inrichten +Comment[ne]=पत्ता लगाउने कार्य कन्फिगर गर्नुहोस् +Comment[nl]=Dienstwaarneming instellen +Comment[nn]=Set opp oppdagingstenesta +Comment[pa]=ਸੇਵਾ ਖੋਜ ਸੰਰਚਨਾ +Comment[pl]=Konfiguracja wykrywania usług +Comment[pt]=Configurar a descoberta de serviços +Comment[pt_BR]=Configurar o serviço discovery +Comment[ro]=Configurează serviciul de descoperire +Comment[ru]=Настройка обнаружения сервисов +Comment[rw]=Kuboneza ivumbura serivisi +Comment[se]=Heivet bálvalusáicama +Comment[sk]=Nastavenie služby Discovery +Comment[sl]=Nastavi odkrivanje storitev +Comment[sr]=Подешавање откривања сервиса +Comment[sr@Latn]=Podešavanje otkrivanja servisa +Comment[sv]=Anpassa tjänstupptäckt +Comment[ta]=சர்வீஸ் டிஸ்கவரியை வடிவமை +Comment[tg]=Танзими хизмати ихтироъ +Comment[th]=ปรับแต่งการค้นพบบริการ +Comment[tr]=Hizmet araştırmasını yapılandır +Comment[tt]=Xezmätlär tabu caylawı +Comment[uk]=Налаштування знаходження служб +Comment[uz]=Tarmoqdagi xizmatlarni qidirishni moslash +Comment[uz@cyrillic]=Тармоқдаги хизматларни қидиришни мослаш +Comment[vi]=Cấu hình dịch vụ khám phá +Comment[wa]=Apontiaedjes do discovraedje do siervice +Comment[zh_CN]=配置探索服务 +Comment[zh_TW]=設定服務偵測 diff --git a/kcontrol/dnssd/kcmdnssd.cpp b/kcontrol/dnssd/kcmdnssd.cpp new file mode 100644 index 000000000..65992bb09 --- /dev/null +++ b/kcontrol/dnssd/kcmdnssd.cpp @@ -0,0 +1,208 @@ +/*************************************************************************** + * Copyright (C) 2004,2005 by Jakub Stachowski * + * qbast@go2.pl * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, 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 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 <sys/stat.h> +#include <config.h> + +#include <tqlayout.h> +#include <tqfile.h> +#include <tqgroupbox.h> +#include <tqradiobutton.h> +#include <tqtimer.h> +#include <tqtabwidget.h> +#include <tqcheckbox.h> +#include <tqprocess.h> +#include <tqcursor.h> +#include <tqbuttongroup.h> + +#include <tdelocale.h> +#include <tdeglobal.h> +#include <tdeparts/genericfactory.h> +#include <kprocess.h> +#include <klineedit.h> +#include <kpassdlg.h> +#include <ksimpleconfig.h> +#include <tdeapplication.h> +#include <tdemessagebox.h> + +#include "kcmdnssd.h" +#include <dnssd/settings.h> +#include <dnssd/domainbrowser.h> +#include <kipc.h> + +#define MDNSD_CONF "/etc/mdnsd.conf" +#define MDNSD_PID "/var/run/mdnsd.pid" + +typedef KGenericFactory<KCMDnssd, TQWidget> KCMDnssdFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_tdednssd, KCMDnssdFactory("kcmtdednssd")) + +KCMDnssd::KCMDnssd(TQWidget *parent, const char *name, const TQStringList&) + : ConfigDialog(parent, name), m_wdchanged(false) +{ + setAboutData(new TDEAboutData(I18N_NOOP("kcm_tdednssd"), + I18N_NOOP("ZeroConf configuration"),0,0,TDEAboutData::License_GPL, + I18N_NOOP("(C) 2004,2005 Jakub Stachowski"))); + setQuickHelp(i18n("Setup services browsing with ZeroConf")); + if (geteuid()!=0) tabs->removePage(tab_2); // normal user cannot change wide-area settings + // show only global things in 'administrator mode' to prevent confusion + else if (getenv("TDESU_USER")!=0) tabs->removePage(tab); + addConfig(DNSSD::Configuration::self(),this); + // it is host-wide setting so it has to be in global config file + domain = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdednssdrc" )); + domain->setGroup("publishing"); + load(); + connect(hostedit,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(wdchanged())); + connect(secretedit,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(wdchanged())); + connect(domainedit,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(wdchanged())); + connect(enableZeroconf,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(enableZeroconfChanged(bool))); + m_enableZeroconfChanged=false; + if (DNSSD::Configuration::self()->publishDomain().isEmpty()) WANButton->setEnabled(false); + kcfg_PublishType->hide(); //unused with Avahi +} + +KCMDnssd::~KCMDnssd() +{ + delete domain; +} + +void KCMDnssd::save() +{ + setCursor(TQCursor(Qt::BusyCursor)); + TDECModule::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) { + + TQString 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."); + + TDEProcess *proc = new TDEProcess; + + *proc << "tdesu"; + + 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(TDEProcess::Block); + } else { + enableZeroconf->setChecked(false); + } + } else { + *proc << "/usr/share/avahi/enable_avahi 0"; + proc->start(TDEProcess::Block); + } + } + setCursor(TQCursor(Qt::ArrowCursor)); +} + +void KCMDnssd::load() +{ + if (geteuid()==0) loadMdnsd(); + enableZeroconf->setChecked(false); + TQProcess avahiStatus(TQString("/usr/share/avahi/avahi_status"), TQT_TQOBJECT(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); + } + TDECModule::load(); +} + +// hack to work around not working isModified() for KPasswordEdit +void KCMDnssd::wdchanged() +{ + WANButton->setEnabled(!domainedit->text().isEmpty() && !hostedit->text().isEmpty()); + changed(); + m_wdchanged=true; +} + +void KCMDnssd::enableZeroconfChanged(bool) +{ + changed(); + m_enableZeroconfChanged=true; +} + +void KCMDnssd::loadMdnsd() +{ + TQFile f(MDNSD_CONF); + if (!f.open(IO_ReadWrite)) return; + TQTextStream stream(&f); + TQString line; + while (!stream.atEnd()) { + line = stream.readLine(); + mdnsdLines.insert(line.section(' ',0,0,TQString::SectionSkipEmpty), + line.section(' ',1,-1,TQString::SectionSkipEmpty)); + } + if (!mdnsdLines["zone"].isNull()) domainedit->setText(mdnsdLines["zone"]); + if (!mdnsdLines["hostname"].isNull()) hostedit->setText(mdnsdLines["hostname"]); + if (!mdnsdLines["secret-64"].isNull()) secretedit->setText(mdnsdLines["secret-64"]); +} + +bool KCMDnssd::saveMdnsd() +{ + mdnsdLines["zone"]=domainedit->text(); + mdnsdLines["hostname"]=hostedit->text(); + if (!secretedit->text().isEmpty()) mdnsdLines["secret-64"]=TQString(secretedit->password()); + else mdnsdLines.remove("secret-64"); + TQFile f(MDNSD_CONF); + bool newfile=!f.exists(); + if (!f.open(IO_WriteOnly)) return false; + TQTextStream stream(&f); + for (TQMap<TQString,TQString>::ConstIterator it=mdnsdLines.begin();it!=mdnsdLines.end(); + ++it) stream << it.key() << " " << (*it) << "\n"; + f.close(); + // if it is new file, then make it only accessible for root as it can contain shared + // secret for dns server. + if (newfile) chmod(MDNSD_CONF,0600); + f.setName(MDNSD_PID); + if (!f.open(IO_ReadOnly)) return true; // it is not running so no need to signal + TQString line; + if (f.readLine(line,16)<1) return true; + unsigned int pid = line.toUInt(); + if (pid==0) return true; // not a pid + kill(pid,SIGHUP); + return true; +} + +TQString KCMDnssd::handbookSection() const +{ + // FIXME + // No context-sensitive help documentation currently exists for this module! + int index = tabs->currentPageIndex(); + if (index == 0) { + //return ""; + return TQString::null; + } + else { + return TQString::null; + } +} + +#include "kcmdnssd.moc" diff --git a/kcontrol/dnssd/kcmdnssd.h b/kcontrol/dnssd/kcmdnssd.h new file mode 100644 index 000000000..b408ca3f6 --- /dev/null +++ b/kcontrol/dnssd/kcmdnssd.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2004,2005 by Jakub Stachowski * + * qbast@go2.pl * + * * + * 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 * + * the Free Software Foundation; either version 2 of the License, 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 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 _KCMDNSSD_H_ +#define _KCMDNSSD_H_ + +#include <tqmap.h> + +#include <configdialog.h> +#include <tdeaboutdata.h> + +class KSimpleConfig; +class KCMDnssd: public ConfigDialog +{ + Q_OBJECT + +public: + KCMDnssd( TQWidget *parent=0, const char *name=0, const TQStringList& = TQStringList() ); + ~KCMDnssd(); + virtual void save(); + virtual void load(); + virtual TQString handbookSection() const; +private slots: + void wdchanged(); + void enableZeroconfChanged(bool); +private: + void loadMdnsd(); + bool saveMdnsd(); + TQMap<TQString,TQString> mdnsdLines; + bool m_wdchanged; + KSimpleConfig* domain; + bool m_enableZeroconfChanged; +}; + +#endif |