generic: ajdust to kdnssd library changes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-05-05 18:59:55 +03:00
parent 1b786143e5
commit 37c3c8e323
4 changed files with 21 additions and 26 deletions

View file

@ -42,9 +42,9 @@ RemoteDesktopsModel::RemoteDesktopsModel(QObject *parent)
// Add RDP and NX if they start announcing via Zeroconf: // Add RDP and NX if they start announcing via Zeroconf:
m_protocols["_rfb._tcp"] = "vnc"; m_protocols["_rfb._tcp"] = "vnc";
zeroconfBrowser = new DNSSD::ServiceBrowser("_rfb._tcp", true); zeroconfBrowser = new KDNSSD();
connect(zeroconfBrowser, SIGNAL(finished()), this, SLOT(servicesChanged())); connect(zeroconfBrowser, SIGNAL(finished()), this, SLOT(servicesChanged()));
zeroconfBrowser->startBrowse(); zeroconfBrowser->startBrowse("_rfb._tcp");
kDebug(5010) << "Browsing for zeroconf hosts."; kDebug(5010) << "Browsing for zeroconf hosts.";
#endif #endif
} }
@ -276,19 +276,18 @@ void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &grou
void RemoteDesktopsModel::servicesChanged() void RemoteDesktopsModel::servicesChanged()
{ {
//redo list because it is easier than finding and removing one that disappeared //redo list because it is easier than finding and removing one that disappeared
QList<DNSSD::RemoteService::Ptr> services = zeroconfBrowser->services();
KUrl url; KUrl url;
removeAllItemsFromSources(RemoteDesktop::Zeroconf); removeAllItemsFromSources(RemoteDesktop::Zeroconf);
foreach(DNSSD::RemoteService::Ptr service, services) { foreach(const KDNSSDService &service, zeroconfBrowser->services()) {
url.setProtocol(m_protocols[service->type()].toLower()); url.setProtocol(m_protocols[service.type].toLower());
url.setHost(service->hostName()); url.setHost(service.hostname);
url.setPort(service->port()); url.setPort(service.port);
RemoteDesktop item; RemoteDesktop item;
item.url = url.url(); item.url = url.url();
if (!remoteDesktops.contains(item)) { if (!remoteDesktops.contains(item)) {
item.title = service->serviceName(); item.title = service.name;
item.source = RemoteDesktop::Zeroconf; item.source = RemoteDesktop::Zeroconf;
item.created = KDateTime::currentLocalDateTime(); item.created = KDateTime::currentLocalDateTime();
item.favorite = false; item.favorite = false;

View file

@ -29,7 +29,7 @@
#include <KDateTime> #include <KDateTime>
#ifdef BUILD_ZEROCONF #ifdef BUILD_ZEROCONF
#include <dnssd/servicebrowser.h> #include <kdnssd.h>
#endif #endif
class KBookmarkGroup; class KBookmarkGroup;
@ -81,7 +81,7 @@ private:
KBookmarkManager *m_manager; KBookmarkManager *m_manager;
#ifdef BUILD_ZEROCONF #ifdef BUILD_ZEROCONF
DNSSD::ServiceBrowser *zeroconfBrowser; KDNSSD *zeroconfBrowser;
QHash<QString, QString> m_protocols; QHash<QString, QString> m_protocols;
#endif #endif

View file

@ -32,7 +32,6 @@
#include <KUser> #include <KUser>
#include <KRandom> #include <KRandom>
#include <KStringHandler> #include <KStringHandler>
#include <DNSSD/PublicService>
//static //static
InvitationsRfbServer *InvitationsRfbServer::instance; InvitationsRfbServer *InvitationsRfbServer::instance;
@ -41,12 +40,7 @@ InvitationsRfbServer *InvitationsRfbServer::instance;
void InvitationsRfbServer::init() void InvitationsRfbServer::init()
{ {
instance = new InvitationsRfbServer; instance = new InvitationsRfbServer;
instance->m_publicService = new DNSSD::PublicService( instance->m_publicService = new KDNSSD();
i18n("%1@%2 (shared desktop)",
KUser().loginName(),
QHostInfo::localHostName()),
"_rfb._tcp",
KrfbConfig::port());
instance->setListeningAddress("0.0.0.0"); instance->setListeningAddress("0.0.0.0");
instance->setListeningPort(KrfbConfig::port()); instance->setListeningPort(KrfbConfig::port());
instance->setPasswordRequired(true); instance->setPasswordRequired(true);
@ -114,8 +108,13 @@ bool InvitationsRfbServer::allowUnattendedAccess() const
bool InvitationsRfbServer::start() bool InvitationsRfbServer::start()
{ {
if(RfbServer::start()) { if(RfbServer::start()) {
if(KrfbConfig::publishService()) if(KrfbConfig::publishService()) {
m_publicService->publishAsync(); m_publicService->publishService(
"_rfb._tcp",
KrfbConfig::port(),
i18n("%1@%2 (shared desktop)", KUser().loginName(), QHostInfo::localHostName())
);
}
return true; return true;
} }
return false; return false;
@ -123,8 +122,8 @@ bool InvitationsRfbServer::start()
void InvitationsRfbServer::stop(bool disconnectClients) void InvitationsRfbServer::stop(bool disconnectClients)
{ {
if(m_publicService->isPublished()) if(m_publicService)
m_publicService->stop(); m_publicService->unpublishService();
RfbServer::stop(disconnectClients); RfbServer::stop(disconnectClients);
} }

View file

@ -23,10 +23,7 @@
#include "rfbserver.h" #include "rfbserver.h"
#include <kpasswdstore.h> #include <kpasswdstore.h>
#include <kdnssd.h>
namespace DNSSD {
class PublicService;
}
class InvitationsRfbServer : public RfbServer class InvitationsRfbServer : public RfbServer
{ {
@ -55,7 +52,7 @@ protected:
virtual PendingRfbClient* newClient(rfbClientPtr client); virtual PendingRfbClient* newClient(rfbClientPtr client);
private: private:
DNSSD::PublicService *m_publicService; KDNSSD *m_publicService;
bool m_allowUnattendedAccess; bool m_allowUnattendedAccess;
QString m_desktopPassword; QString m_desktopPassword;
QString m_unattendedPassword; QString m_unattendedPassword;