1
0
mirror of https://github.com/KDE/krfb synced 2026-07-01 07:41:17 -07:00

Move KServiceRegistry members into private class

svn path=/trunk/kdenetwork/krfb/; revision=171547
This commit is contained in:
Tim Jansen
2002-08-12 11:26:39 +00:00
parent 4574f50cda
commit 9ad9d64ca6
5 changed files with 56 additions and 47 deletions

2
TODO
View File

@@ -1,4 +1,5 @@
For 3.1:
- remove krfb from all user-visible places
- write SLP service template for remote desktop protocols
(documentation)
@@ -10,6 +11,7 @@ Todo (unscheduled features):
- NAT traversal support if I can find an acceptable implementation
(probably using TURN, as soon as there is a server and newer spec for that)
- split krfb into 2 separate programs (server and invitation)
- soundex support in SLP attributes
- look into adding an extension to xfree to improve speed (get noticed of
screen updates)
- cut & paste support

View File

@@ -6,7 +6,7 @@ noinst_LTLIBRARIES = libsrvloc.la
libsrvloc_la_SOURCES = kinetaddr.cpp kinetaddr_ipfinder.cpp \
kserviceregistry.cpp kuser.cpp
libsrvloc_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_SLP)
libsrvloc_la_LDFLAGS = $(all_libraries) -no-undefined
libsrvloc_la_LDFLAGS = $(all_libraries) -no-undefined
noinst_HEADERS = kinetaddr.h kserviceregistry.h kuser.h
# set the include path for X, qt and KDE

View File

@@ -126,7 +126,7 @@ public:
* Returns an address that can be used for communication with
* other computers on the internet.
* Note that the returned address is not always a real
* internet address, because the computer may not be able to connect
* internet address, because the computer couble be unable to connect
* to the internet or is behind a NAT gateway.
* In the worst case you will get the address of the local loopback
* interface.

View File

@@ -17,34 +17,57 @@
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* TODO: see below..
*/
#include "config.h"
#include "kserviceregistry.h"
#include <kdebug.h>
#ifdef HAVE_SLP
#include <slp.h>
class KServiceRegistryPrivate {
public:
KServiceRegistryPrivate(const QString &lang) :
m_opened(false),
m_lang(lang) {
}
bool ensureOpen();
bool m_opened;
QString m_lang;
SLPHandle m_handle;
friend void KServiceRegistryRegReport(SLPHandle slp,
SLPError errcode,
void* cookie);
bool m_cbSuccess;
};
void KServiceRegistryRegReport(SLPHandle,
SLPError errcode,
void* cookie) {
KServiceRegistry *s = (KServiceRegistry*) cookie;
KServiceRegistryPrivate *s = (KServiceRegistryPrivate*) cookie;
s->m_cbSuccess = (errcode == SLP_OK);
if (errcode < 0)
kdDebug() << "KServiceRegistry: error in callback:" << errcode <<endl;
}
KServiceRegistry::KServiceRegistry(const QString &lang) :
m_opened(false),
m_lang(lang) {
KServiceRegistry::KServiceRegistry(const QString &lang) {
d = new KServiceRegistryPrivate(lang);
}
KServiceRegistry::~KServiceRegistry() {
if (m_opened)
SLPClose(m_handle);
if (d->m_opened)
SLPClose(d->m_handle);
delete d;
}
bool KServiceRegistry::ensureOpen() {
bool KServiceRegistryPrivate::ensureOpen() {
SLPError e;
if (m_opened)
@@ -60,35 +83,35 @@ bool KServiceRegistry::ensureOpen() {
}
bool KServiceRegistry::available() {
return ensureOpen();
return d->ensureOpen();
}
bool KServiceRegistry::registerService(const QString &serviceURL,
QString attributes,
unsigned short lifetime) {
if (!ensureOpen())
if (!d->ensureOpen())
return false;
m_cbSuccess = true;
SLPError e = SLPReg(m_handle,
d->m_cbSuccess = true;
SLPError e = SLPReg(d->m_handle,
serviceURL.latin1(),
lifetime > 0 ? lifetime : SLP_LIFETIME_MAXIMUM,
0,
attributes.isNull() ? "" : attributes.latin1(),
SLP_TRUE,
KServiceRegistryRegReport,
this);
d);
if (e != SLP_OK) {
kdDebug() << "KServiceRegistry: error in registerService:" << e <<endl;
return false;
}
return m_cbSuccess;
return d->m_cbSuccess;
}
bool KServiceRegistry::registerService(const QString &serviceURL,
QMap<QString,QString> attributes,
unsigned short lifetime) {
if (!ensureOpen())
if (!d->ensureOpen())
return false;
// TODO: encode strings in map?
QString s;
@@ -103,11 +126,11 @@ bool KServiceRegistry::registerService(const QString &serviceURL,
}
void KServiceRegistry::unregisterService(const QString &serviceURL) {
if (!m_opened)
if (!d->m_opened)
return;
SLPDereg(m_handle, serviceURL.latin1(),
SLPDereg(d->m_handle, serviceURL.latin1(),
KServiceRegistryRegReport,
this);
d);
}
QString KServiceRegistry::encodeAttributeValue(const QString &value) {
@@ -123,17 +146,12 @@ QString KServiceRegistry::encodeAttributeValue(const QString &value) {
#else
KServiceRegistry::KServiceRegistry(const QString &lang) :
m_opened(false),
m_lang(lang) {
d(0) {
}
KServiceRegistry::~KServiceRegistry() {
}
bool KServiceRegistry::ensureOpen() {
return false;
}
bool KServiceRegistry::available() {
return false;
}

View File

@@ -25,18 +25,12 @@
#ifndef __KSERVICEREGISTRY_H
#define __KSERVICEREGISTRY_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_SLP
#include <slp.h>
#endif
#include <qstring.h>
#include <qstringlist.h>
#include <qmap.h>
class KServiceRegistryPrivate;
/**
* KServiceRegistry allows you to announce your service using SLP (RFC 2608).
*
@@ -80,8 +74,14 @@
* templates is described in RFC 2609, you can find the existing service
* templates at http://www.iana.org/assignments/svrloc-templates.htm .
*
*
* TODO: example of obtaining host address and registering service
* Example:
* <pre>
* KServiceRegistry ksr;
* KInetAddress kia = KInetAddress->getLocalAddress();
* ksr.registerService(QString("service:remotedesktop.kde:vnc://%1:0").arg(kia->nodeName()),
* "(type=shared)");
* delete kia;
* </pre>
*
* @version $Id$
* @author Tim Jansen, tim@tjansen.de
@@ -155,18 +155,7 @@ class KServiceRegistry {
void unregisterService(const QString &serviceURL);
private:
bool ensureOpen();
bool m_opened;
QString m_lang;
#ifdef HAVE_SLP
SLPHandle m_handle;
friend void KServiceRegistryRegReport(SLPHandle slp,
SLPError errcode,
void* cookie);
#endif
bool m_cbSuccess;
KServiceRegistryPrivate *d;
};
#endif