Репозитории ALT
5.1: | 3.5.10-alt4 |
4.1: | 3.5.10-alt2.M41.1 |
4.0: | 3.5.9-alt0.M40.1 |
3.0: | 3.4.1-alt4 |
+backports: | 3.5.6-alt2.0.M30 |
Группа :: Графические оболочки/KDE
Пакет: kdenetwork
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: kpf-slp.diff
Скачать
Скачать
--- kpf/src/Makefile.am
+++ kpf/src/Makefile.am
@@ -39,7 +39,7 @@
kpf_panelapplet_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
-kpf_panelapplet_la_LIBADD = $(LIB_KIO) -lkdnssd
+kpf_panelapplet_la_LIBADD = $(LIB_KIO) $(LIB_SLP) -lkdnssd
kpfpropertiesdialog_la_SOURCES = \
PropertiesDialogPlugin.cpp \
--- kpf/src/WebServer.cpp
+++ kpf/src/WebServer.cpp
@@ -47,6 +47,11 @@
#include "Server.h"
#include "Utils.h"
+#ifdef HAVE_SLP
+#include <unistd.h>
+#include <slp.h>
+#endif
+
namespace KPF
{
static const uint SamplesPerSecond = 10;
@@ -193,10 +198,13 @@
d->portContention = !d->socket->ok();
emit(contentionChange(d->portContention));
-
if (!d->portContention)
+ {
connect(d->socket, SIGNAL(connection(int)), SLOT(slotConnection(int)));
-
+#ifdef HAVE_SLP
+ registerSLP();
+#endif
+ }
else
{
delete d->socket;
@@ -205,6 +213,77 @@
}
}
+#ifdef HAVE_SLP
+ void
+ mySLPRegReport(SLPHandle hslp, SLPError errcode, void *cookie)
+ { /* empty, but needed ... */; };
+
+ void
+ WebServer::registerSLP()
+ {
+ SLPHandle phslp;
+ SLPError result;
+
+ result = SLPOpen( NULL, SLP_FALSE, &phslp);
+ if (result != SLP_OK)
+ kpfDebug << "SLPOpen failed";
+ else {
+ static int SLPrefresh = 5 * 60; // every five minutes, no choice yet ...
+ char hostname[1024];
+ QString SLPServiceUrl;
+ gethostname( hostname, 1023 );
+ SLPServiceUrl.sprintf("service:kpf.kde:http://%s:%d", hostname, listenPort());
+
+ result = SLPReg( phslp,
+ SLPServiceUrl.ascii(),
+ SLPrefresh - 10,
+ 0,
+ "",
+ SLP_TRUE,
+ mySLPRegReport,
+ 0 );
+ if (result != SLP_OK)
+ kpfDebug << "unable to register SLP service (slpd maybe not running)" ;
+ SLPClose( phslp );
+
+ QTimer::singleShot( 1000*(SLPrefresh), this, SLOT(registerSLP()) );
+ }
+ }
+
+ void
+ WebServer::unregisterSLP()
+ {
+ SLPHandle phslp;
+ SLPError result;
+
+ result = SLPOpen( NULL, SLP_FALSE, &phslp);
+ if (result != SLP_OK)
+ kpfDebug << "SLPOpen failed";
+ else {
+ char hostname[1024];
+ QString SLPServiceUrl;
+ gethostname( hostname, 1023 );
+ SLPServiceUrl.sprintf("service:kpf.kde:http://%s:%d", hostname, listenPort());
+
+ result = SLPDereg( phslp,
+ SLPServiceUrl.ascii(),
+ mySLPRegReport,
+ 0 );
+
+ if (result != SLP_OK)
+ kpfDebug << "unable to register SLP service (slpd maybe not running)" ;
+ SLPClose( phslp );
+ }
+ }
+#else
+void
+WebServer::registerSLP() {}
+
+void
+WebServer::unregisterSLP() {}
+
+#endif
+
void
WebServer::slotConnection(int fd)
{
@@ -311,6 +390,9 @@
void
WebServer::killAllConnections()
{
+#ifdef HAVE_SLP
+ unregisterSLP();
+#endif
QPtrListIterator<Server> it(d->serverList);
for (; it.current(); ++it)
--- kpf/src/WebServer.h
+++ kpf/src/WebServer.h
@@ -31,6 +31,8 @@
#include "Request.h"
#include "Response.h"
+#include "config.h"
+
namespace KPF
{
class Server;
@@ -247,6 +249,9 @@
* error doing so.
*/
void wasPublished(bool ok);
+
+ void registerSLP ();
+ void unregisterSLP ();
protected: