summaryrefslogtreecommitdiffstats
path: root/krfb/kinetd
diff options
context:
space:
mode:
Diffstat (limited to 'krfb/kinetd')
-rw-r--r--krfb/kinetd/Makefile.am28
-rw-r--r--krfb/kinetd/README.debugging13
-rw-r--r--krfb/kinetd/eventsrc259
-rw-r--r--krfb/kinetd/kinetd.cpp658
-rw-r--r--krfb/kinetd/kinetd.desktop139
-rw-r--r--krfb/kinetd/kinetd.h200
-rw-r--r--krfb/kinetd/kinetdmodule.desktop148
7 files changed, 1445 insertions, 0 deletions
diff --git a/krfb/kinetd/Makefile.am b/krfb/kinetd/Makefile.am
new file mode 100644
index 00000000..52008d8c
--- /dev/null
+++ b/krfb/kinetd/Makefile.am
@@ -0,0 +1,28 @@
+METASOURCES = AUTO
+
+# Code
+kde_module_LTLIBRARIES = kded_kinetd.la
+
+kded_kinetd_la_SOURCES = kinetd.cpp kinetd.skel
+kded_kinetd_la_LDFLAGS = $(all_libraries) -module -avoid-version
+kded_kinetd_la_LIBADD = ../srvloc/libsrvloc.la $(LIB_KIO) $(LIB_KDNSSD)
+
+# Services
+kde_servicetypes_DATA = kinetdmodule.desktop
+kdeddir = $(kde_servicesdir)/kded
+kded_DATA = kinetd.desktop
+
+EXTRA_DIST = $(kded_kinetd_la_SOURCES)\
+ $(kded_DATA) \
+ $(kde_servicetypes_DATA) \
+ eventsrc README.debugging
+
+install-data-local:
+ $(mkinstalldirs) $(DESTDIR)$(kde_datadir)/kinetd
+ $(INSTALL_DATA) $(srcdir)/eventsrc $(DESTDIR)$(kde_datadir)/kinetd/eventsrc
+
+# set the include path for X, qt and KDE
+INCLUDES= -I$(top_srcdir)/krfb/srvloc $(all_includes)
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kinetd.pot
diff --git a/krfb/kinetd/README.debugging b/krfb/kinetd/README.debugging
new file mode 100644
index 00000000..359496b8
--- /dev/null
+++ b/krfb/kinetd/README.debugging
@@ -0,0 +1,13 @@
+Recommended practice to debug a kinetd program
+==============================================
+
+Instead of executing your program directly, start a wrapper script that
+looks like this:
+
+#!/bin/sh
+exec xterm -e gdb --args /opt/kde/bin/krfb $1 $2
+
+Note that you cannot use konsole because it closes the file descriptor. You need
+a very recent gdb version for the "--args" option (>= 5.2, only available as
+CVS snapshot at this time).
+
diff --git a/krfb/kinetd/eventsrc b/krfb/kinetd/eventsrc
new file mode 100644
index 00000000..658d2412
--- /dev/null
+++ b/krfb/kinetd/eventsrc
@@ -0,0 +1,259 @@
+[!Global!]
+IconName=kinetd
+Comment=KInetD
+Comment[bn]=কে-আইনেট-ডি
+Comment[hi]=के-इनिट-डी
+Comment[sv]=Kinetd
+
+[IncomingConnection]
+Name=IncomingConnection
+Name[ar]=اتصال وارد
+Name[bg]=Получена е входяща връзка
+Name[bn]=অন্তর্মুখী সংযোগ
+Name[br]=Kevreadenn resev
+Name[ca]=Connexió entrant
+Name[cs]=Příchozí spojení
+Name[cy]=CysylltiadCyrraedd
+Name[da]=IndkommendeForbindelse
+Name[de]=Eingehende Verbindung
+Name[el]=Εισερχόμενη σύνδεση
+Name[eo]=EnvenantaKonekto
+Name[es]=Conexión entrante
+Name[et]=Sissetulev ühendus
+Name[eu]=Sarrerako konexioa
+Name[fa]=اتصال وارد‌شده
+Name[fi]=Saapuva yhteys
+Name[fr]=Connexion entrante
+Name[ga]=CeangalIsteach
+Name[gl]=Conexión Entrante
+Name[he]=חיבור נכנס
+Name[hi]=आवक-कनेक्शन
+Name[hr]=DolaznaVeza
+Name[hu]=Bejövő kapcsolat
+Name[it]=Connessioni in entrata
+Name[ja]=外部からの接続
+Name[kk]=Кіріс қосылым
+Name[km]=ការ​តភ្ជាប់​ចូល
+Name[lt]=Gautas kvietimas ryšiui
+Name[mk]=Дојдовно поврзување
+Name[mn]=Орж ирсэн Холболт
+Name[ms]=Sambungan Masuk
+Name[mt]=KonnessjonijiDieħla
+Name[nb]=Innkommende forbindelse
+Name[nds]=RinkamenVerbinnen
+Name[ne]=आगमन जडान
+Name[nl]=Inkomende verbinding
+Name[nn]=Innkomande samband
+Name[nso]=Kopantsho yeo e Tsenago
+Name[pl]=Połączenia przychodzące
+Name[pt]=Ligação Recebida
+Name[pt_BR]=Conexões de Entrada
+Name[ro]=Conexiune de intrare
+Name[ru]=Входящее соединение
+Name[se]=Boahtti oktavuohta
+Name[sk]=Prichádzajúce spojenia
+Name[sl]=Prihajajoča povezava
+Name[sr]=Долазећа веза
+Name[sr@Latn]=Dolazeća veza
+Name[sv]=Inkommande anslutning
+Name[ta]=உள்வரும் இணைப்புகள்
+Name[tg]=Пайвастшавии Воридшаванда
+Name[th]=มีการเชื่อมต่อเข้ามา
+Name[tr]=Gelen Bağlantı
+Name[uk]=ВхіднеЗ'єднання
+Name[ven]=Vhukwamanihanga ngomu
+Name[xh]=Uxhumaniso Olungenayo
+Name[zh_CN]=进入的连接
+Name[zh_HK]=進入連線
+Name[zh_TW]=進來的連接
+Name[zu]=UkuxhumanaOkuzayo
+Comment=Received incoming connection
+Comment[af]=Ontvang inkomende verbinding
+Comment[ar]=تم استلام اتصال وارد
+Comment[be]=Атрыманы запыт злучэння
+Comment[bg]=Получена е входяща връзка
+Comment[bn]=অন্তর্মুখী সংযোগ গ্রহণ করল
+Comment[bs]=Primio dolaznu konekciju
+Comment[ca]=Rebuda connexió entrant
+Comment[cs]=Obdrženo příchozí spojení
+Comment[cy]=Derbynwyd cysylltiad a gyrhaeddodd
+Comment[da]=Modtog indkommende forbindelse
+Comment[de]=Verbindungsanfrage eingegangen
+Comment[el]=Λήψη εισερχόμενης σύνδεσης
+Comment[eo]=Ricevantaj envenantaj konektoj
+Comment[es]=Recibida conexión entrante
+Comment[et]=Saadi sissetulev ühendus
+Comment[eu]=Konexio bat jaso da
+Comment[fa]=اتصال واردشده دریافت شد
+Comment[fi]=Vastaanotettiin saapuva yhteys
+Comment[fr]=Reçu une connexion entrante
+Comment[gl]=Recibíuse unha conexión entrante
+Comment[he]=נתקבל חיבור נכנס
+Comment[hi]=आवक कनेक्शन प्राप्त
+Comment[hr]=Primio dolaznu vezu
+Comment[hu]=Csatlakozási kérés érkezett
+Comment[is]=Tók á móti uppkalli
+Comment[it]=Connessione in entrata stabilita
+Comment[ja]=着信した外部からの接続
+Comment[ka]=შემომავალი კავშირი მოვიდა
+Comment[kk]=Кіріс қосылым қабылданды
+Comment[km]=បាន​ទទួល​ការ​តភ្ជាប់​ចូល
+Comment[lt]=Gautas kvietimas ryšiui
+Comment[mk]=Примено е дојдовно поврзување
+Comment[mn]=Орж ирсэн Холболтыг хүлээн авав
+Comment[ms]=Menerima sambungan masuk
+Comment[mt]=Irċevejt konnessjoni dieħla
+Comment[nb]=Motta innkommende forbindelse
+Comment[nds]=Tokoppelanfraag kregen
+Comment[ne]=आगमन जडान प्राप्त गर्यो
+Comment[nl]=Ontving een inkomende verbinding
+Comment[nn]=Motta innkomande samband
+Comment[nso]=Kopantsho yeo e amogetswego ya tseo di tsenago
+Comment[pl]=Otrzymano połącznie przychodzące
+Comment[pt]=Foi recebida uma ligação
+Comment[pt_BR]=Recebendo conexão de entrada
+Comment[ro]=Conexiune de intrare recepţionată
+Comment[ru]=Входящее соединение завершилось успешно
+Comment[se]=Oaččui boahtti oktavuođa
+Comment[sk]=Prijaté príchodzie spojenia
+Comment[sl]=Prejeta je prihajajoča povezava
+Comment[sr]=Примљена је долазећа веза
+Comment[sr@Latn]=Primljena je dolazeća veza
+Comment[sv]=Tar emot inkommande anslutning
+Comment[tg]=Пайвастшавии воридшаванда қабул гардид
+Comment[th]=ได้รับการเชื่อมต่อเข้ามา
+Comment[tr]=Gelen bağlantı alınıyor
+Comment[uk]=Отримано вхідне з'єднання
+Comment[ven]=Vhukwamani hau dzhena ho tanganedzhwaho
+Comment[xh]=Uxhulumano olungenayo olufunyenweyo
+Comment[zh_CN]=收到进入的连接
+Comment[zh_HK]=已接收的進入連線
+Comment[zh_TW]=已接收的進來的連線
+Comment[zu]=Ukuxhumanisa okungenayo okutholakele
+default_presentation=4
+
+[ProcessFailed]
+Name=ProcessFailed
+Name[ar]=فشلت العملية
+Name[bg]=Процесът за обработка връзки не може да бъде стартиран
+Name[bn]=প্রসেস ব্যর্থ
+Name[ca]=Procés fallit
+Name[cs]=Proces selhal
+Name[cy]=MethoddProses
+Name[da]=ProcesMislykkedes
+Name[de]=Prozess fehlgeschlagen
+Name[el]=Η επεξεργασία απέτυχε
+Name[eo]=ProcezoFiaskis
+Name[es]=Proceso fallido
+Name[et]=Protsess ebaõnnestus
+Name[eu]=Prozesuak huts egin du
+Name[fa]=خرابی پردازه
+Name[fi]=Prosessi epäonnistui
+Name[fr]=Échec du processus
+Name[ga]=PróiseasTeipthe
+Name[gl]=Proceso fallido
+Name[he]=תהליך נכשל
+Name[hi]=प्रक्रिया-असफल
+Name[hr]=ProcesNeuspješan
+Name[hu]=Hibás folyamat
+Name[it]=Processo fallito
+Name[ja]=プロセス失敗
+Name[kk]=Процесс жаңылды
+Name[km]=ដំណើរ​ការ​បាន​បរាជ័យ
+Name[lt]=Procesas nepavyko
+Name[mk]=Процесот не успеа
+Name[mn]=Ажиллагаа сүйрэв
+Name[ms]=Proses Gagal
+Name[mt]=ProċessFalla
+Name[nb]=Prosess mislyktes
+Name[nds]=PerzessFehlslaan
+Name[ne]=प्रक्रिया असफल भयो
+Name[nl]=Proces mislukt
+Name[nn]=Prosess mislukkast
+Name[nso]=Tiragalo e Paletswe
+Name[pa]=ਕਾਰਜ ਫੇਲ੍ਹ ਹੋਈ
+Name[pl]=Błąd procesu
+Name[pt]=Processo Mal-Sucedido
+Name[pt_BR]=Falha de Processo
+Name[ro]=Proces eşuat
+Name[ru]=Ошибка процесса
+Name[se]=Proseassa filtii
+Name[sk]=Proces neúspešny
+Name[sl]=Proces ni uspel
+Name[sr]=Процес није успео
+Name[sr@Latn]=Proces nije uspeo
+Name[sv]=Process misslyckades
+Name[ta]=செயல் தோல்வியுற்றது
+Name[tg]=Ҷараён бо Нокомӣ анҷомид
+Name[th]=โปรเซสล้มเหลว
+Name[tr]=Başarısız İşlemler
+Name[uk]=ПомилкаПроцесу
+Name[ven]=Tshitenwa tsho bala
+Name[xh]=Inkqubo Yahlulekile
+Name[zh_CN]=处理失败
+Name[zh_HK]=程序失敗
+Name[zh_TW]=程序失敗
+Name[zu]=UkwenzekaKuhlulekile
+Comment=Could not call process to handle connection
+Comment[af]=Kon nie roep proses na handvatsel verbinding
+Comment[ar]=لم أستطع استحضار العملية لحمل المكالمة
+Comment[be]=Немагчыма выклікаць працэс для апрацоўвання злучэння
+Comment[bg]=Процесът за обработка връзки не може да бъде стартиран
+Comment[bn]=সংযোগ পরিচালনা করতে প্রসেস শুরু করতে পারল না
+Comment[bs]=Ne mogu pokrenuti proces koji upravlja konekcijom
+Comment[ca]=No es pot cridar al procés per a manejar la connexió
+Comment[cs]=Nelze spustit proces k obsluze spojení
+Comment[cy]=Methu galw proses i drin y cysylltiad
+Comment[da]=Kunne ikke kalde proces til at håndtere forbindelse
+Comment[de]=Der Prozess zur Bearbeitung der Verbindungsanfrage wurde nicht gefunden
+Comment[el]=Δεν ήταν δυνατή η κλήση της διεργασίας για τον έλεγχο της σύνδεσης
+Comment[eo]=Ne eblis lanĉi instancon por prizorgi la konekton
+Comment[es]=Imposible lanzar proceso para manejar conexión
+Comment[et]=Ei suuda käivitada protsessi ühenduse käsitsemiseks
+Comment[eu]=Ezin izan da konexioa kudeatzeko prozesua deitu
+Comment[fa]=نتوانست پردازه را برای گرداندن اتصال فراخوانی کند
+Comment[fi]=Ei voitu kutsua prosessia yhteyden hoitamiseksi
+Comment[fr]=Impossible d'appeler le processus pour gérer la connexion
+Comment[gl]=Non se puidcho chamar ó proceso para que atendese á conexión
+Comment[he]=אין אפשרות לקרוא לתהליך על מנת לטפל בחיבור
+Comment[hi]=कनेक्शन हैंडल करने के लिए प्रक्रिया काल नहीं कर सका
+Comment[hr]=Nisam mogao pozvati proces za kontrolu veze
+Comment[hu]=A kapcsolat kezelése nem sikerült
+Comment[is]=Gat ekki kallað á forrit til að höndla tengingu
+Comment[it]=Impossibile richiamare il processo per gestire la connessione
+Comment[ja]=接続を扱うプロセスを呼び出せません
+Comment[ka]=კავშირის დამმუშავებელი პროცესის გამოძახება ვერ განხორციელდა
+Comment[kk]=Қосылымды қолдайтын процесс жегілмеді
+Comment[km]=មិន​អាច​ហៅ​ដំណើរ​ការ ដើម្បីដោះស្រាយ​ការ​ត​ភ្ជាប់​បាន​ឡើយ
+Comment[lt]=Nepavyko iškviesti proceso prisijungimui apdoroti
+Comment[mk]=Не може да се повика процесот за ракување со поврзувањето
+Comment[mn]=Холболтыг заах ажиллагаагдуудаж чадаагүй
+Comment[ms]=Tidak dapat memanggil proses untuk mengendalikan sambungan
+Comment[mt]=Ma stajtx insejjaħ proċess biex jieħu ħsieb il-konnessjoni
+Comment[nb]=Kunne ikke kalle en prosess for å håndtere forbindelsen
+Comment[nds]=Perzess för't Verarbeiden vun Tokoppelanfragen lett sik nich opropen
+Comment[ne]=जडान ह्यान्डल गर्न प्रक्रिया आह्वान गर्न सकेन
+Comment[nl]=Het proces om de verbinding af te handelen kon niet worden aangeroepen
+Comment[nn]=Klarte ikkje kalla prosess for sambandshandtering
+Comment[nso]=Ebe ekase bitse tiragalo go swara kopantsho
+Comment[pl]=Nie można było uruchomić procesu obsługi połączenia
+Comment[pt]=Não foi possível invocar o processo para tratar da ligação
+Comment[pt_BR]=Não foi possível chamar o processo de controle da conexão
+Comment[ru]=Не удаётся запустить процесс обработки соединения
+Comment[sk]=Nemohol som zavolať proces pre spracovanie spojenia
+Comment[sl]=Ni možno poklicati procesa za upravljanje s povezavo
+Comment[sr]=Нисам могао да позовем процес да опслужи везу
+Comment[sr@Latn]=Nisam mogao da pozovem proces da opsluži vezu
+Comment[sv]=Kunde inte anropa process för att hantera anslutning
+Comment[ta]=இணைப்பை கையாள செயற்பாட்டை அழைக்க முடியவில்லை
+Comment[tg]=Барои даскории пайвастшавӣ ҷараён бозхонда нашуд
+Comment[th]=ไม่สามารถเรียกโปรเซสเพื่อรับการเชื่อมต่อได้
+Comment[tr]=Elle bağlantıda başarısız çağrı işlemleri
+Comment[uk]=Неможливо викликати процес для обробки з'єднання
+Comment[ven]=Ingasi vhidze tshitenwa uitela u fara vhukwamani
+Comment[xh]=Ayikwazanga ukubiza inkqubo ezakuphatha uxhulumano
+Comment[zh_CN]=无法调用进程处理连接
+Comment[zh_HK]=無法呼叫處理連線的程序
+Comment[zh_TW]=無法呼叫處理連線的程序
+Comment[zu]=Ayikwazanga ukubiza umsebenzi ukuzophatha ukuxhumanisa
+default_presentation=4
diff --git a/krfb/kinetd/kinetd.cpp b/krfb/kinetd/kinetd.cpp
new file mode 100644
index 00000000..5094712e
--- /dev/null
+++ b/krfb/kinetd/kinetd.cpp
@@ -0,0 +1,658 @@
+
+/***************************************************************************
+ kinetd.cpp
+ --------------
+ begin : Mon Feb 11 2002
+ copyright : (C) 2002 by Tim Jansen
+ email : tim@tjansen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "kinetd.h"
+#include "kinetd.moc"
+#include "kinetinterface.h"
+#include "kuser.h"
+#include "uuid.h"
+#include <qregexp.h>
+#include <kservicetype.h>
+#include <kdebug.h>
+#include <kstandarddirs.h>
+#include <kconfig.h>
+#include <knotifyclient.h>
+#include <ksockaddr.h>
+#include <kextsock.h>
+#include <klocale.h>
+#include <kglobal.h>
+
+#include <unistd.h>
+#include <fcntl.h>
+
+PortListener::PortListener(KService::Ptr s,
+ KConfig *config,
+ KServiceRegistry *srvreg) :
+ m_port(-1),
+ m_serviceRegistered(false),
+ m_socket(0),
+ m_config(config),
+ m_srvreg(srvreg),
+ m_dnssdreg(0)
+{
+ m_dnssdRegistered = false;
+
+ m_uuid = createUUID();
+ loadConfig(s);
+
+ if (m_valid && m_enabled)
+ acquirePort();
+}
+
+bool PortListener::acquirePort() {
+ if (m_socket) {
+ if ((m_port >= m_portBase) &&
+ (m_port < (m_portBase + m_autoPortRange)))
+ return true;
+ else
+ delete m_socket;
+ }
+ m_port = m_portBase;
+ m_socket = new KServerSocket(m_port, false);
+ while (!m_socket->bindAndListen()) {
+ m_port++;
+ if (m_port >= (m_portBase+m_autoPortRange)) {
+ kdDebug() << "Kinetd cannot load service "<<m_serviceName
+ <<": unable to get port" << endl;
+ m_port = -1;
+ delete m_socket;
+ m_socket = 0;
+ return false;
+ }
+ delete m_socket;
+ m_socket = new KServerSocket(m_port, false);
+ }
+ connect(m_socket, SIGNAL(accepted(KSocket*)),
+ SLOT(accepted(KSocket*)));
+
+ bool s = m_registerService;
+ bool sd =m_dnssdRegister;
+ setServiceRegistrationEnabledInternal(false);
+ dnssdRegister(false);
+ setServiceRegistrationEnabledInternal(s);
+ dnssdRegister(sd);
+ return true;
+}
+
+void PortListener::freePort() {
+ m_port = -1;
+ if (m_socket)
+ delete m_socket;
+ m_socket = 0;
+ setServiceRegistrationEnabledInternal(m_registerService);
+ dnssdRegister(false);
+}
+
+void PortListener::loadConfig(KService::Ptr s) {
+ m_valid = true;
+ m_autoPortRange = 0;
+ m_enabled = true;
+ m_argument = QString::null;
+ m_multiInstance = false;
+
+ QVariant vid, vport, vautoport, venabled, vargument, vmultiInstance, vurl,
+ vsattributes, vslifetime, vdname, vdtype, vddata;
+
+ m_execPath = s->exec().utf8();
+ vid = s->property("X-KDE-KINETD-id");
+ vport = s->property("X-KDE-KINETD-port");
+ vautoport = s->property("X-KDE-KINETD-autoPortRange");
+ venabled = s->property("X-KDE-KINETD-enabled");
+ vargument = s->property("X-KDE-KINETD-argument");
+ vmultiInstance = s->property("X-KDE-KINETD-multiInstance");
+ vurl = s->property("X-KDE-KINETD-serviceURL");
+ vsattributes = s->property("X-KDE-KINETD-serviceAttributes");
+ vslifetime = s->property("X-KDE-KINETD-serviceLifetime");
+ vdname = s->property("X-KDE-KINETD-DNSSD-Name");
+ vdtype = s->property("X-KDE-KINETD-DNSSD-Type");
+ vddata = s->property("X-KDE-KINETD-DNSSD-Properties");
+
+ if (!vid.isValid()) {
+ kdDebug() << "Kinetd cannot load service "<<m_serviceName
+ <<": no id set" << endl;
+ m_valid = false;
+ return;
+ }
+
+ if (!vport.isValid()) {
+ kdDebug() << "Kinetd cannot load service "<<m_serviceName
+ <<": invalid port" << endl;
+ m_valid = false;
+ return;
+ }
+
+ m_serviceName = vid.toString();
+ m_serviceLifetime = vslifetime.toInt();
+ if (m_serviceLifetime < 120) // never less than 120 s
+ m_serviceLifetime = 120;
+ m_portBase = vport.toInt();
+ if (vautoport.isValid())
+ m_autoPortRange = vautoport.toInt();
+ if (venabled.isValid())
+ m_enabled = venabled.toBool();
+ if (vargument.isValid())
+ m_argument = vargument.toString();
+ if (vmultiInstance.isValid())
+ m_multiInstance = vmultiInstance.toBool();
+ if (vurl.isValid()) {
+ m_serviceURL = vurl.toString();
+ m_registerService = true;
+ }
+ else {
+ m_serviceURL = QString::null;
+ m_registerService = false;
+ }
+ if (vsattributes.isValid()) {
+ m_serviceAttributes = vsattributes.toString();
+ }
+ else
+ m_serviceAttributes = "";
+ if (vddata.isValid()) {
+ QStringList attrs = vddata.toStringList();
+ for (QStringList::iterator it=attrs.begin();
+ it!=attrs.end();it++) {
+ QString key = (*it).section('=',0,0);
+ QString value = processServiceTemplate((*it).section('=',1))[0];
+ if (!key.isEmpty()) m_dnssdData[key]=value;
+ }
+ }
+ if (vdname.isValid() && vdtype.isValid()) {
+ m_dnssdName = processServiceTemplate(vdname.toString())[0];
+ m_dnssdType = vdtype.toString();
+ m_dnssdRegister = true;
+ kdDebug() << "DNS-SD register is enabled\n";
+ }
+ else
+ m_dnssdRegister = false;
+
+
+ m_slpLifetimeEnd = QDateTime::currentDateTime().addSecs(m_serviceLifetime);
+ m_defaultPortBase = m_portBase;
+ m_defaultAutoPortRange = m_autoPortRange;
+
+ m_config->setGroup("ListenerConfig");
+ m_enabled = m_config->readBoolEntry("enabled_" + m_serviceName,
+ m_enabled);
+ m_portBase = m_config->readNumEntry("port_base_" + m_serviceName,
+ m_portBase);
+ m_autoPortRange = m_config->readNumEntry("auto_port_range_" + m_serviceName,
+ m_autoPortRange);
+ QDateTime nullTime;
+ m_expirationTime = m_config->readDateTimeEntry("enabled_expiration_"+m_serviceName,
+ &nullTime);
+ if ((!m_expirationTime.isNull()) && (m_expirationTime < QDateTime::currentDateTime()))
+ m_enabled = false;
+ m_registerService = m_config->readBoolEntry("enabled_srvreg_"+m_serviceName,
+ m_registerService);
+}
+
+void PortListener::accepted(KSocket *sock) {
+ QString host, port;
+ KSocketAddress *ksa = KExtendedSocket::peerAddress(sock->socket());
+ if ((!ksa) || !ksa->address()) {
+ delete sock;
+ return;
+ }
+ KExtendedSocket::resolve(ksa, host, port);
+ KNotifyClient::event("IncomingConnection",
+ i18n("Connection from %1").arg(host));
+ delete ksa;
+
+ if ((!m_enabled) ||
+ ((!m_multiInstance) && m_process.isRunning())) {
+ delete sock;
+ return;
+ }
+
+ // disable CLOEXEC flag, fixes #77412
+ fcntl(sock->socket(), F_SETFD, fcntl(sock->socket(), F_GETFD) & ~FD_CLOEXEC);
+
+ m_process.clearArguments();
+ m_process << m_execPath << m_argument << QString::number(sock->socket());
+ if (!m_process.start(KProcess::DontCare)) {
+ KNotifyClient::event("ProcessFailed",
+ i18n("Call \"%1 %2 %3\" failed").arg(m_execPath)
+ .arg(m_argument)
+ .arg(sock->socket()));
+ }
+
+ delete sock;
+}
+
+bool PortListener::isValid() {
+ return m_valid;
+}
+
+bool PortListener::isEnabled() {
+ return m_enabled && m_valid;
+}
+
+int PortListener::port() {
+ return m_port;
+}
+
+QStringList PortListener::processServiceTemplate(const QString &a) {
+ QStringList l;
+ QValueVector<KInetInterface> v = KInetInterface::getAllInterfaces(false);
+ QValueVector<KInetInterface>::Iterator it = v.begin();
+ while (it != v.end()) {
+ KInetSocketAddress *address = (*(it++)).address();
+ if (!address)
+ continue;
+ QString hostName = address->nodeName();
+ KUser u;
+ QString x = a; // replace does not work in const QString. Why??
+ l.append(x.replace(QRegExp("%h"), KServiceRegistry::encodeAttributeValue(hostName))
+ .replace(QRegExp("%p"), QString::number(m_port))
+ .replace(QRegExp("%u"), KServiceRegistry::encodeAttributeValue(u.loginName()))
+ .replace(QRegExp("%i"), KServiceRegistry::encodeAttributeValue(m_uuid))
+ .replace(QRegExp("%f"), KServiceRegistry::encodeAttributeValue(u.fullName())));
+ }
+ return l;
+}
+
+bool PortListener::setPort(int port, int autoPortRange) {
+ if ((port == m_portBase) && (autoPortRange == m_autoPortRange))
+ return (m_port != -1);
+
+ m_config->setGroup("ListenerConfig");
+ if (port > 0) {
+ m_portBase = port;
+ m_autoPortRange = autoPortRange;
+
+ m_config->writeEntry("port_base_" + m_serviceName, m_portBase);
+ m_config->writeEntry("auto_port_range_"+m_serviceName, m_autoPortRange);
+ }
+ else {
+ m_portBase = m_defaultPortBase;
+ m_autoPortRange = m_defaultAutoPortRange;
+
+ m_config->deleteEntry("port_base_" + m_serviceName);
+ m_config->deleteEntry("auto_port_range_"+m_serviceName);
+ }
+
+ m_config->sync();
+ if (m_enabled)
+ return acquirePort();
+ else
+ return false;
+}
+
+void PortListener::setEnabled(bool e) {
+ setEnabledInternal(e, QDateTime());
+}
+
+void PortListener::setEnabledInternal(bool e, const QDateTime &ex) {
+ m_config->setGroup("ListenerConfig");
+ m_config->writeEntry("enabled_" + m_serviceName, e);
+ m_config->writeEntry("enabled_expiration_"+m_serviceName, ex);
+ m_config->sync();
+
+ m_expirationTime = ex;
+
+ if (e) {
+ if (m_port < 0)
+ acquirePort();
+ m_enabled = m_port >= 0;
+
+ }
+ else {
+ freePort();
+ m_enabled = false;
+ }
+}
+
+void PortListener::setEnabled(const QDateTime &ex) {
+ setEnabledInternal(true, ex);
+}
+
+bool PortListener::isServiceRegistrationEnabled() {
+ return m_registerService;
+}
+
+void PortListener::setServiceRegistrationEnabled(bool e) {
+ setServiceRegistrationEnabledInternal(e);
+ dnssdRegister(e && m_enabled);
+ m_config->setGroup("ListenerConfig");
+ m_config->writeEntry("enable_srvreg_" + m_serviceName, e);
+ m_config->sync();
+}
+
+void PortListener::setServiceRegistrationEnabledInternal(bool e) {
+ m_registerService = e;
+
+ if ((!m_srvreg) || m_serviceURL.isNull())
+ return;
+ if (m_serviceRegistered == (m_enabled && e))
+ return;
+
+ if (m_enabled && e) {
+ m_registeredServiceURLs = processServiceTemplate(m_serviceURL);
+ QStringList attributes = processServiceTemplate(m_serviceAttributes);
+ QStringList::Iterator it = m_registeredServiceURLs.begin();
+ QStringList::Iterator it2 = attributes.begin();
+ while ((it != m_registeredServiceURLs.end()) &&
+ (it2 != attributes.end())) {
+ if (!m_srvreg->registerService(
+ *(it++),
+ *(it2++),
+ m_serviceLifetime))
+ kdDebug(7021) << "Failure registering SLP service (no slpd running?)"<< endl;
+ }
+ m_serviceRegistered = true;
+ // make lifetime 30s shorter, because the timeout is not precise
+ m_slpLifetimeEnd = QDateTime::currentDateTime().addSecs(m_serviceLifetime-30);
+ } else {
+ QStringList::Iterator it = m_registeredServiceURLs.begin();
+ while (it != m_registeredServiceURLs.end())
+ m_srvreg->unregisterService(*(it++));
+ m_serviceRegistered = false;
+ }
+}
+
+void PortListener::dnssdRegister(bool e) {
+ if (m_dnssdName.isNull() || m_dnssdType.isNull())
+ return;
+ if (m_dnssdRegistered == e)
+ return;
+ if (e) {
+ m_dnssdRegistered=true;
+ m_dnssdreg = new DNSSD::PublicService(m_dnssdName,m_dnssdType,m_port);
+ m_dnssdreg->setTextData(m_dnssdData);
+ m_dnssdreg->publishAsync();
+ } else {
+ m_dnssdRegistered=false;
+ delete m_dnssdreg;
+ m_dnssdreg=0;
+ }
+}
+
+void PortListener::refreshRegistration() {
+ if (m_serviceRegistered && (m_slpLifetimeEnd.addSecs(-90) < QDateTime::currentDateTime())) {
+ setServiceRegistrationEnabledInternal(false);
+ setServiceRegistrationEnabledInternal(true);
+ }
+}
+
+QDateTime PortListener::expiration() {
+ return m_expirationTime;
+}
+
+QDateTime PortListener::serviceLifetimeEnd() {
+ if (m_serviceRegistered)
+ return m_slpLifetimeEnd;
+ else
+ return QDateTime();
+}
+
+QString PortListener::name() {
+ return m_serviceName;
+}
+
+PortListener::~PortListener() {
+ setServiceRegistrationEnabledInternal(false);
+ delete m_socket;
+}
+
+
+KInetD::KInetD(QCString &n) :
+ KDEDModule(n)
+{
+ m_config = new KConfig("kinetdrc");
+ m_srvreg = new KServiceRegistry();
+ if (!m_srvreg->available()) {
+ kdDebug(7021) << "SLP not available"<< endl;
+ delete m_srvreg;
+ m_srvreg = 0;
+ }
+ m_portListeners.setAutoDelete(true);
+ connect(&m_expirationTimer, SIGNAL(timeout()), SLOT(setExpirationTimer()));
+ connect(&m_portRetryTimer, SIGNAL(timeout()), SLOT(portRetryTimer()));
+ connect(&m_reregistrationTimer, SIGNAL(timeout()), SLOT(reregistrationTimer()));
+ loadServiceList();
+}
+
+void KInetD::loadServiceList()
+{
+ m_portListeners.clear();
+
+
+ KService::List kinetdModules =
+ KServiceType::offers("KInetDModule");
+ for(KService::List::ConstIterator it = kinetdModules.begin();
+ it != kinetdModules.end();
+ it++) {
+ KService::Ptr s = *it;
+ PortListener *pl = new PortListener(s, m_config, m_srvreg);
+ if (pl->isValid())
+ m_portListeners.append(pl);
+ else
+ delete pl;
+ }
+
+ setExpirationTimer();
+ setPortRetryTimer(true);
+ setReregistrationTimer();
+}
+
+void KInetD::expirationTimer() {
+ setExpirationTimer();
+ setReregistrationTimer();
+}
+
+void KInetD::setExpirationTimer() {
+ QDateTime nextEx = getNextExpirationTime(); // disables expired portlistener!
+ if (!nextEx.isNull())
+ m_expirationTimer.start(QDateTime::currentDateTime().secsTo(nextEx)*1000 + 30000,
+ false);
+ else
+ m_expirationTimer.stop();
+}
+
+void KInetD::portRetryTimer() {
+ setPortRetryTimer(true);
+ setReregistrationTimer();
+}
+
+void KInetD::setReregistrationTimer() {
+ QDateTime d;
+ PortListener *pl = m_portListeners.first();
+ while (pl) {
+ QDateTime d2 = pl->serviceLifetimeEnd();
+ if (!d2.isNull()) {
+ if (d2 < QDateTime::currentDateTime()) {
+ m_reregistrationTimer.start(0, true);
+ return;
+ }
+ else if (d.isNull() || (d2 < d))
+ d = d2;
+ }
+ pl = m_portListeners.next();
+ }
+
+ if (!d.isNull()) {
+ int s = QDateTime::currentDateTime().secsTo(d);
+ if (s < 30)
+ s = 30; // max frequency 30s
+ m_reregistrationTimer.start(s*1000, true);
+ }
+ else
+ m_reregistrationTimer.stop();
+}
+
+void KInetD::reregistrationTimer() {
+ PortListener *pl = m_portListeners.first();
+ while (pl) {
+ pl->refreshRegistration();
+ pl = m_portListeners.next();
+ }
+ setReregistrationTimer();
+}
+
+void KInetD::setPortRetryTimer(bool retry) {
+ int unmappedPorts = 0;
+
+ PortListener *pl = m_portListeners.first();
+ while (pl) {
+ if (pl->isEnabled() && (pl->port() < 0))
+ if (retry) {
+ if (!pl->acquirePort())
+ unmappedPorts++;
+ }
+ else if (pl->port() < 0)
+ unmappedPorts++;
+ pl = m_portListeners.next();
+ }
+
+ if (unmappedPorts > 0)
+ m_portRetryTimer.start(30000, false);
+ else
+ m_portRetryTimer.stop();
+}
+
+PortListener *KInetD::getListenerByName(QString name)
+{
+ PortListener *pl = m_portListeners.first();
+ while (pl) {
+ if (pl->name() == name)
+ return pl;
+ pl = m_portListeners.next();
+ }
+ return pl;
+}
+
+// gets next expiration timer, SIDEEFFECT: disables expired portlisteners while doing this
+QDateTime KInetD::getNextExpirationTime()
+{
+ PortListener *pl = m_portListeners.first();
+ QDateTime d;
+ while (pl) {
+ QDateTime d2 = pl->expiration();
+ if (!d2.isNull()) {
+ if (d2 < QDateTime::currentDateTime())
+ pl->setEnabled(false);
+ else if (d.isNull() || (d2 < d))
+ d = d2;
+ }
+ pl = m_portListeners.next();
+ }
+ return d;
+}
+
+QStringList KInetD::services()
+{
+ QStringList list;
+ PortListener *pl = m_portListeners.first();
+ while (pl) {
+ list.append(pl->name());
+ pl = m_portListeners.next();
+ }
+ return list;
+}
+
+bool KInetD::isEnabled(QString service)
+{
+ PortListener *pl = getListenerByName(service);
+ if (!pl)
+ return false;
+
+ return pl->isEnabled();
+}
+
+int KInetD::port(QString service)
+{
+ PortListener *pl = getListenerByName(service);
+ if (!pl)
+ return -1;
+
+ return pl->port();
+}
+
+bool KInetD::setPort(QString service, int port, int autoPortRange)
+{
+ PortListener *pl = getListenerByName(service);
+ if (!pl)
+ return false;
+
+ bool s = pl->setPort(port, autoPortRange);
+ setPortRetryTimer(false);
+ setReregistrationTimer();
+ return s;
+}
+
+bool KInetD::isInstalled(QString service)
+{
+ PortListener *pl = getListenerByName(service);
+ return (pl != 0);
+}
+
+void KInetD::setEnabled(QString service, bool enable)
+{
+ PortListener *pl = getListenerByName(service);
+ if (!pl)
+ return;
+
+ pl->setEnabled(enable);
+ setExpirationTimer();
+ setReregistrationTimer();
+}
+
+void KInetD::setEnabled(QString service, QDateTime expiration)
+{
+ PortListener *pl = getListenerByName(service);
+ if (!pl)
+ return;
+
+ pl->setEnabled(expiration);
+ setExpirationTimer();
+ setReregistrationTimer();
+}
+
+void KInetD::setServiceRegistrationEnabled(QString service, bool enable)
+{
+ PortListener *pl = getListenerByName(service);
+ if (!pl)
+ return;
+
+ pl->setServiceRegistrationEnabled(enable);
+ setReregistrationTimer();
+}
+
+bool KInetD::isServiceRegistrationEnabled(QString service)
+{
+ PortListener *pl = getListenerByName(service);
+ if (!pl)
+ return false;
+
+ return pl->isServiceRegistrationEnabled();
+}
+
+KInetD::~KInetD() {
+ m_portListeners.clear();
+ delete m_config;
+ if (m_srvreg)
+ delete m_srvreg;
+}
+
+extern "C" {
+ KDE_EXPORT KDEDModule *create_kinetd(QCString &name)
+ {
+ KGlobal::locale()->insertCatalogue("kinetd");
+ return new KInetD(name);
+ }
+}
diff --git a/krfb/kinetd/kinetd.desktop b/krfb/kinetd/kinetd.desktop
new file mode 100644
index 00000000..80aa3567
--- /dev/null
+++ b/krfb/kinetd/kinetd.desktop
@@ -0,0 +1,139 @@
+[Desktop Entry]
+Type=Service
+
+ServiceTypes=KDEDModule
+X-KDE-ModuleType=Library
+X-KDE-Library=kinetd
+X-KDE-FactoryName=kinetd
+X-KDE-Kded-autoload=true
+
+Name=KDE Internet Daemon
+Name[af]=Kde Internet Bediener
+Name[ar]=مراقب انترنت كيدي
+Name[be]=Сервіс Інтэрнэт KDE
+Name[bg]=Интернет демон
+Name[bn]=কে-ডি-ই ইন্টারনেট ডিমন
+Name[br]=Diaoul kenrouedad KDE
+Name[ca]=Dimoni d'Internet per al KDE
+Name[cs]=KDE Internet démon
+Name[cy]=Daemon Rhyngrwyd KDE
+Name[da]=KDE Internet-dæmon
+Name[de]=Internet-Dienst
+Name[el]=Δαίμονας διαδικτύου για το KDE
+Name[eo]=Retodemono
+Name[es]=Demonio de Internet de KDE
+Name[et]=KDE internetideemon
+Name[eu]=KDE internet deabrua
+Name[fa]=شبح اینترنتی KDE
+Name[fi]=KDE Internet-palvelin
+Name[fr]=Démon Internet de KDE
+Name[ga]=Deamhan Idirlín KDE
+Name[gl]=O demo de Internet de KDE
+Name[he]=תהליך הרקע האינטרנטי של KDE
+Name[hi]=केडीई इंटरनेट डेमन
+Name[hu]=KDE internetes szolgáltatás
+Name[is]=KDE Internetþjónn
+Name[it]=Demone internet di KDE
+Name[ja]=KDE インターネットデーモン
+Name[ka]=KDE ინტერნეტის დემონი
+Name[kk]=KDE Интернет қызметі
+Name[km]=ដេមិន​អ៊ីនធឺណិត​របស់ KDE
+Name[lt]=KDE interneto tarnyba
+Name[mk]=Даемон за Интернет на KDE
+Name[mn]=KDE Интернет-демон
+Name[ms]=Daemon Internet KDE
+Name[mt]=Daemon tal-internet KDE
+Name[nb]=KDEs internett-nisse
+Name[nds]=KDE-Internetdämoon
+Name[ne]=केडीई इन्टरनेट डेइमन
+Name[nn]=KDE-Internett-nisse
+Name[nso]=Daemon ya Internet ya KDE
+Name[pa]=KDE ਇੰਟਰਨੈੱਟ ਡੈਮਨ
+Name[pl]=Internet/sieć
+Name[pt]=Servidor de Internet do KDE
+Name[pt_BR]=Servidor Internet do KDE
+Name[ro]=Demon internet KDE
+Name[ru]=Доступ к Интернету
+Name[se]=KDE-Interneahtta-duogášprográmma
+Name[sk]=KDE Internet démon
+Name[sl]=Internetni strežnik za KDE
+Name[sr]=KDE-ов интернет демон
+Name[sr@Latn]=KDE-ov internet demon
+Name[sv]=KDE:s Internetdemon
+Name[ta]=கேடிஇ இணைய டேமொன்
+Name[tg]=KDE Азозили Интернет
+Name[th]=เดมอนอินเตอร์เน็ต KDE
+Name[tr]=KDE İnternet Programı
+Name[uk]=Демон Інтернет KDE
+Name[uz]=KDE Internet demoni
+Name[uz@cyrillic]=KDE Интернет демони
+Name[zh_CN]=KDE Internet 守护进程
+Name[zh_HK]=KDE 互聯網系統程式
+Name[zh_TW]=KDE Internet 伺服程式
+Name[zu]=KDE Internet ye-Daemon
+Comment=An Internet daemon that starts network services on demand
+Comment[ar]=مراقب انترنت يقوم ببدء خدمات الشبكة عند الطلب
+Comment[be]=Севіс Інтэрнэт, які стартуе сеткавыя сервісы па запыце
+Comment[bg]=Интернет демон, който служи за стартиране на мрежови услуги при поискване
+Comment[bn]=একটি ইন্টারনেট ডিমন যে চাহিদা ভিত্তিক নেটওয়ার্ক সার্ভিস আরম্ভ করে
+Comment[bs]=Internet daemon koji pokreće mrežne servise po potrebi
+Comment[ca]=Un dimoni d'Internet que arrenca els serveis de xarxa sota demanda
+Comment[cs]=Internetový démon spouštějící síťové služby na požádání
+Comment[cy]=Daemon Rhyngrwyd sy'n cychwyn gwasanaethau rhwydwaith ar alw
+Comment[da]=En internet-dæmon der starter netværkstjenester efter forespørgsel
+Comment[de]=Startet Netzwerkdienste bei Bedarf
+Comment[el]=Ένας δαίμονας για το διαδίκτυο ο οποίος ξεκινάει τις υπηρεσίες δικτύου όταν απαιτείται
+Comment[eo]=retdemono kiu lanĉas retajn servojn laŭ bezono
+Comment[es]=Un demonio de Internet que inicia los servicios de red a demanda
+Comment[et]=Internetideemon, mis käivitab nõudmisel võrguteenused
+Comment[eu]=Sare zerbitzuak eskatzean abiarazten dituen deabrua
+Comment[fa]=یک شبح اینترنتی که خدمات شبکه را بر اساس تقاضا آغاز می‌کند
+Comment[fi]=Internet-palvelin, joka käynnistää verkkopalveluita
+Comment[fr]=Un démon Internet qui démarre le service réseau à la demande
+Comment[ga]=Deamhan Idirlín a thosaíonn seirbhísí gréasáin ar éileamh
+Comment[gl]=Un demo de Internet que comenza servicios de rede según demanda
+Comment[he]=תהליך רקע של אינטרנט שמתחיל שירותי רשת לפי דרישה
+Comment[hi]=एक इंटरनेट डेमन जो मांग पर नेटवर्क सेवा प्रारंभ करता है
+Comment[hr]=Internet daemon koji pokreće mrežne usluge kada su zatražene
+Comment[hu]=A hálózati szolgáltatások vezérlését biztosító program
+Comment[is]=Internetþjónn sem ræsir tengingar við Internetið eftir þörfum
+Comment[it]=Un demone internet che avvia i servizi di rete a richiesta
+Comment[ja]=要求時にネットワークサービスを起動するインターネットデーモン
+Comment[ka]=ინტერნეტის დემონი, რომელიც ქსელის სერვისებს მოთხოვნით უშვებს
+Comment[kk]=Талап етілгенде керек желі қызметтерді жегетін қызмет
+Comment[km]=ដេមិន​អ៊ីនធឺណិត​ដែល​ចាប់ផ្ដើម​សេវា​បណ្ដាញ​នៅ​ពេល​ត្រូវការ
+Comment[lt]=Interneto tarnyba, paleidžianti tinklo tarnybas esant poreikiui
+Comment[mk]=Даемон за Интернет кој ги вклучува мрежните сервиси на барање
+Comment[mn]=Сүлжээ-үйлчилгээний эрэлтээр ассан Сүлжээний демон
+Comment[ms]=Daemon Internet yang memulakan servis jaringan di atas permintaan
+Comment[mt]=Proċess tal-internet li jħaddem servizzi skond il-bżonn
+Comment[nb]=internett-nisse som starter nettverkstjenester ved behov
+Comment[nds]=En Internet-Dämoon, wat Nettwarkdeensten op Anfraag start
+Comment[ne]=एउटा इन्टरनेट डेइमन जसले मागमा सञ्जाल सेवा सुरु गर्दछ
+Comment[nl]=Een internetdaemon die netwerkdiensten op afroep start
+Comment[nn]=Internett-nisse som startar nettverkstenester når dei trengst
+Comment[nso]=Daemon ya Internet yeo e thomisago ditirelo tsa kgokagano ge e nyakilwe
+Comment[pl]=Uruchamianie usług na żądanie
+Comment[pt]=Um servidor da Internet que inicia os serviços de rede a pedido
+Comment[pt_BR]=Um servidor Internet que inicia os serviços de rede por demanda
+Comment[ro]=Un demon de internet care porneşte serviciile de reţea la cerere
+Comment[ru]=Служба установления подключения при запросе сетевых ресурсов
+Comment[se]=Interneahtta-duogášprográmma mii álggaha fierpmádatbálvalusaid go dárbbašuvvo
+Comment[sk]=Internetový démon ktorý spúšťa sieťové služby na požiadanie
+Comment[sl]=Internetni strežnik, ki zažene omrežne storitve na zahtevo
+Comment[sr]=Интернет демон који покреће мрежне сервисе по захтеву
+Comment[sr@Latn]=Internet demon koji pokreće mrežne servise po zahtevu
+Comment[sv]=Internetdemon som startar nätverkstjänster vid behov
+Comment[ta]=ஒரு இணைய டேமொன், டேமொன் பிணைய சேவையை ஆரம்பிக்கிறது
+Comment[tg]=Азозили шабакавие, ки хидматрасони шабакавиро бо дархост сар медиҳад
+Comment[th]=เดมอนอินเตอร์เน็ตซึ่งจะเริ่มทำงานบริการเครือข่ายเมื่อมีความต้องการ
+Comment[tr]=Başlangıçta ağ servisleri tarafından istenen internet hayalet programı
+Comment[uk]=Демон Інтернет, що запускає служби мережі при запиті
+Comment[uz]=Talab qilinganda tarmoq xizmatlarini ishga tushuruvchi Internet demoni
+Comment[uz@cyrillic]=Талаб қилинганда тармоқ хизматларини ишга тушурувчи Интернет демони
+Comment[ven]=Internet daemon ine ya thoma tshumelo ya vhukwamani kha muthetho
+Comment[xh]=Internet daemon eqala iinkonzo zomsebenzi wonatha xa zifunwa
+Comment[zh_CN]=按需启动网络服务的守护进程
+Comment[zh_HK]=自動依需求起動網絡服務的互聯網系統程式
+Comment[zh_TW]=依要求起動網路服務的 Internet 伺服程式
+Comment[zu]=I-Internet ye-daemon eqala ama-sevisi we-network adingekayo
diff --git a/krfb/kinetd/kinetd.h b/krfb/kinetd/kinetd.h
new file mode 100644
index 00000000..e6283e83
--- /dev/null
+++ b/krfb/kinetd/kinetd.h
@@ -0,0 +1,200 @@
+
+/***************************************************************************
+ kinetd.h
+ ------------
+ begin : Mon Feb 11 2002
+ copyright : (C) 2002 by Tim Jansen
+ email : tim@tjansen.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _KINETD_H_
+#define _KINETD_H_
+
+#include <kdedmodule.h>
+#include <kservice.h>
+#include <ksock.h>
+#include <kprocess.h>
+#include <qstringlist.h>
+#include <qstring.h>
+#include <qdatetime.h>
+#include <qtimer.h>
+#include <dnssd/publicservice.h>
+
+#include "kserviceregistry.h"
+
+class PortListener : public QObject {
+ Q_OBJECT
+private:
+ bool m_valid;
+ QString m_serviceName;
+ QString m_serviceURL, m_serviceAttributes;
+ QStringList m_registeredServiceURLs;
+ QString m_dnssdName, m_dnssdType;
+ QMap<QString,QString> m_dnssdData;
+ int m_serviceLifetime;
+ int m_port;
+ int m_portBase, m_autoPortRange;
+ int m_defaultPortBase, m_defaultAutoPortRange;
+ bool m_multiInstance;
+ QString m_execPath;
+ QString m_argument;
+ bool m_enabled;
+ bool m_serviceRegistered, m_registerService;
+ bool m_dnssdRegister, m_dnssdRegistered;
+ QDateTime m_expirationTime;
+ QDateTime m_slpLifetimeEnd;
+ QString m_uuid;
+
+ KServerSocket *m_socket;
+ KProcess m_process;
+
+ KConfig *m_config;
+ KServiceRegistry *m_srvreg;
+ DNSSD::PublicService *m_dnssdreg;
+
+ void freePort();
+ void loadConfig(KService::Ptr s);
+ void setEnabledInternal(bool e, const QDateTime &ex);
+ void dnssdRegister(bool enabled);
+ void setServiceRegistrationEnabledInternal(bool enabled);
+
+public:
+ PortListener(KService::Ptr s, KConfig *c, KServiceRegistry *srvreg);
+ ~PortListener();
+
+ bool acquirePort();
+ bool isValid();
+ QString name();
+ void setEnabled(bool enabled);
+ void setEnabled(const QDateTime &expiration);
+ void setServiceRegistrationEnabled(bool enabled);
+ bool isServiceRegistrationEnabled();
+ QDateTime expiration();
+ QDateTime serviceLifetimeEnd();
+ bool isEnabled();
+ int port();
+ QStringList processServiceTemplate(const QString &a);
+ bool setPort(int port = -1, int autoProbeRange = 1);
+ void refreshRegistration();
+
+private slots:
+ void accepted(KSocket*);
+};
+
+class KInetD : public KDEDModule {
+ Q_OBJECT
+ K_DCOP
+
+k_dcop:
+ /**
+ * Returns a list of all registered services in KInetd.
+ * To add a service you need to add a .desktop file with
+ * the servicetype "KInetDModule" into the services director
+ * (see kinetdmodule.desktop in servicetypes dir).
+ * @return a list with the names of all services
+ */
+ QStringList services();
+
+ /**
+ * Returns true if the service exists and is available.
+ * @param service name of a service as specified in its .desktop file
+ * @return true if a service with the given name exists and is enabled
+ */
+ bool isEnabled(QString service);
+
+ /**
+ * Enables or disabled the given service. Ignored if the given service
+ * does not exist.
+ * @param service name of a service as specified in its .desktop file
+ * @param enable true to enable, false to disable.
+ */
+ void setEnabled(QString service, bool enable);
+
+ /**
+ * Enables the given service until the given time. Ignored if the given
+ * service does not exist.
+ * @param service name of a service as specified in its .desktop file
+ * @param expiration the time the service will be disabled at
+ */
+ void setEnabled(QString service, QDateTime expiration);
+
+ /**
+ * Returns the port of the service, or -1 if not listening.
+ * @param service name of a service as specified in its .desktop file
+ * @return the port or -1 if no port used or service does not exist
+ */
+ int port(QString service);
+
+ /**
+ * Sets the port of the service, and possibly a range of ports to try.
+ * It will return true if a port could be found. If it didnt find one but is
+ * enabled it will start a timer that probes that port every 30s.
+ * @param service name of a service as specified in its .desktop file
+ * @param port the first port number to try or -1 to restore defaults
+ * @param autoPortRange the number of ports to try
+ * @return true if a port could be found or service is disabled, false
+ * otherwise.
+ */
+ bool setPort(QString service, int port = -1, int autoPortRange = 1);
+
+ /**
+ * Tests whether the given service is installed..
+ * @param service name of a service as specified in its .desktop file
+ * @return true if installed, false otherwise
+ */
+ bool isInstalled(QString service);
+
+ /**
+ * Enables or disables the SLP registration. Ignored if the service does
+ * not have a service URL. If the service is disabled the service will
+ * registered as soon as it is enabled.
+ * @param service name of a service as specified in its .desktop file
+ * @param enable true to enable, false to disable.
+ */
+ void setServiceRegistrationEnabled(QString service, bool enabled);
+
+ /**
+ * Returns true if service registration for the given service is enabled.
+ * Note that this does not mean that the service is currently registered,
+ * because the service may be disabled.
+ * @param service name of a service as specified in its .desktop file
+ * @return true if service registration is enabled
+ */
+ bool isServiceRegistrationEnabled(QString service);
+
+ private:
+ QDateTime getNextExpirationTime();
+ void setPortRetryTimer(bool retry);
+ void setReregistrationTimer();
+
+ KConfig *m_config;
+ KServiceRegistry *m_srvreg;
+ QPtrList<PortListener> m_portListeners;
+ QTimer m_expirationTimer;
+ QTimer m_portRetryTimer;
+ QTimer m_reregistrationTimer;
+
+ private slots:
+ void setExpirationTimer();
+ void expirationTimer();
+ void portRetryTimer();
+ void reregistrationTimer();
+
+ public:
+ KInetD(QCString &n);
+ virtual ~KInetD();
+ void loadServiceList();
+ PortListener *getListenerByName(QString name);
+};
+
+
+#endif
diff --git a/krfb/kinetd/kinetdmodule.desktop b/krfb/kinetd/kinetdmodule.desktop
new file mode 100644
index 00000000..865fecf3
--- /dev/null
+++ b/krfb/kinetd/kinetdmodule.desktop
@@ -0,0 +1,148 @@
+# describes the servicetype that you need to implement in order to use
+# kinetd.
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KInetDModule
+Name=KInetD Module Type
+Name[ar]=KInetD نوع وحدة
+Name[be]=Тып модуля KInetD
+Name[bg]=Модул на KInetD
+Name[bn]=কে-আইনেট-ডি মডিউল ধরন
+Name[br]=Seurt ar mollad KInetD
+Name[bs]=KInetD tip modula
+Name[ca]=Tipus de mòdul del KInetD
+Name[cs]=Typ modulu KInetD
+Name[cy]=Math Modiwl KInetD
+Name[da]=KInetD-modultype
+Name[de]=KInetD Modultyp
+Name[el]=Τύπος αρθρώματος KInetD
+Name[eo]=KInetD-modulotipo
+Name[es]=Tipo de módulo KInetD
+Name[et]=KInetD mooduli tüüp
+Name[eu]=KInetD modulu mota
+Name[fa]=نوع پیمانۀ KInetD
+Name[fi]=KInetD-moduulityyppi
+Name[fr]=Type de module de KInetD
+Name[ga]=Cineál Modúil KInetD
+Name[gl]=Tipo de módulo KInetD
+Name[he]=סוג מודול של KInetD
+Name[hi]=के-इनिट-डी मॉड्यूल प्रकार
+Name[hr]=Tip KInetD Modula
+Name[hu]=KInetD modultípus
+Name[is]=KInetD Module tegund
+Name[it]=Tipo modulo KInetD
+Name[ja]=KInetD モジュールタイプ
+Name[ka]=KInetD მოდულის ტიპი
+Name[kk]=KInetD модулі
+Name[km]=ប្រភេទ​ម៉ូលឌុល KInetD
+Name[lt]=KInetD modulio tipas
+Name[mk]=Тип на модул за KInetD
+Name[mn]=Модуль KInetD
+Name[ms]=Jenis Modul KInetD
+Name[mt]=Tip ta' modulu KInetD
+Name[nb]=KInetd-programtillegstype
+Name[nds]=KInetD-Moduultyp
+Name[ne]=KInetD मोड्युल प्रकार
+Name[nl]=KInetD-moduletype
+Name[nn]=KInetD-programtilleggstype
+Name[nso]=Mohuta wa Seripa sa KInetD
+Name[pa]=KInetD ਮੋਡੀਊਲ ਕਿਸਮ
+Name[pl]=Typ modułu KInetD
+Name[pt]=Tipo de Módulo do KInetD
+Name[pt_BR]=Módulo KInetD
+Name[ro]=Tip modul KInetD
+Name[ru]=Модуль KInetD
+Name[se]=KInetD-moduvlašládja
+Name[sk]=Typ modulu KInetD
+Name[sl]=Vrsta modula KInetD
+Name[sr]=KInetD врста модула
+Name[sr@Latn]=KInetD vrsta modula
+Name[sv]=Kinetd-modultyp
+Name[ta]=KInetD கூறு வகை
+Name[tg]=Навъи Модули KInetD
+Name[tr]=KDED Modül Türü
+Name[uk]=Тип модулю KinetD
+Name[ven]=Lushaka lwa Modulu ya KInetD
+Name[xh]=Udidi Lomqongo womlinganiselo we KInetD
+Name[zh_CN]=KInetD 模块类型
+Name[zh_HK]=KInetD 模組類型
+Name[zh_TW]=KInetD 模組類型
+Name[zu]=KInetD Uhlobo Lokwenza
+
+# id to manipulate the service
+[PropertyDef::X-KDE-KINETD-id]
+Type=QString
+
+# describes the TCP port kinetd should listen to
+[PropertyDef::X-KDE-KINETD-port]
+Type=int
+
+# if set and >0, the number of ports kinetd should probe if the port is in use
+[PropertyDef::X-KDE-KINETD-autoPortRange]
+Type=int
+
+# if enabled, kinetd will listen on the port. Can be overridden using the
+# dcop interface.
+[PropertyDef::X-KDE-KINETD-enabled]
+Type=bool
+
+# if set, this argument is given to the app to start, followed by the number
+# of the socket's fd
+[PropertyDef::X-KDE-KINETD-argument]
+Type=QString
+
+# if true, kinetd can accepts several connections at the same time. Otherwise
+# it will block the port when a connection has been established.
+[PropertyDef::X-KDE-KINETD-multiInstance]
+Type=bool
+
+# if set, kinetd will register the given URL at the local SLP SA while
+# the port is open. It will register one URL for each IP address of the
+# host.
+# The following strings will be substituted:
+# %h with the local IP address
+# %p with the port number
+# %u with the user's login name
+# %f with the user's full name
+# %i with a UUID thats identical in all URLs of this service
+[PropertyDef::X-KDE-KINETD-serviceURL]
+Type=QString
+
+# if kinetd registers a service URL, this string will be used for its attributes.
+# The following strings will be substituted:
+# %h with the local IP address
+# %p with the port number
+# %u with the user's login name
+# %f with the user's full name
+# %i with a UUID thats identical in all URLs of this service
+[PropertyDef::X-KDE-KINETD-serviceAttributes]
+Type=QString
+
+# the lifetime of a service in seconds. kinets will renew the service
+# automatically. Max 65535, never use anything under 2 min. Something like
+# 5-20 minutes is a sane value for most desktop applications.
+[PropertyDef::X-KDE-KINETD-serviceLifetime]
+Type=int
+
+# if set, kinetd will announce service with given name on local network while
+# the port is open.
+# The following strings will be substituted:
+# %h with the local IP address
+# %f with the user's full name
+# %p with the port number
+
+[PropertyDef::X-KDE-KINETD-DNSSD-Name]
+Type=QString
+
+# if kinetd announces service on network using DNS-SD, this string will be used as service
+# type. It must be in form _yourservice._udp or _yourservice._tcp
+# it uses the same substitution rules as X-KDE-KINETD-DNSSD-Name
+
+[PropertyDef::X-KDE-KINETD-DNSSD-Type]
+Type=QString
+
+# defines list of text properties for service announced via DNS-SD
+# it uses the same substitution rules as X-KDE-KINETD-DNSSD-Name
+[PropertyDef::X-KDE-KINETD-DNSSD-Properties]
+Type=QStringList
+