Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 3829bf3b authored by Scarlett Clark's avatar Scarlett Clark

Remove SLP from kio-extras. No longer maintained upstream.

Closes: https://phabricator.kde.org/D9413
parent 5e6c6fe0
......@@ -62,13 +62,6 @@ set_package_properties(KF5Activities PROPERTIES
TYPE OPTIONAL
)
find_package(SLP)
set_package_properties(SLP PROPERTIES DESCRIPTION "SLP (Service Location Protocol) implementation"
URL "http://www.openslp.org/"
TYPE OPTIONAL
PURPOSE "Provides SLP support in the network:/ kioslave."
)
find_package(Phonon4Qt5 4.6.60 NO_MODULE)
set_package_properties(Phonon4Qt5 PROPERTIES
DESCRIPTION "Qt-based audio library"
......
# cmake macro to test SLP LIB
# Copyright (c) 2006, 2007 Laurent Montel, <montel@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
if (SLP_INCLUDE_DIR AND SLP_LIBRARIES)
# Already in cache, be silent
set(SLP_FIND_QUIETLY TRUE)
endif (SLP_INCLUDE_DIR AND SLP_LIBRARIES)
FIND_PATH(SLP_INCLUDE_DIR slp.h)
FIND_LIBRARY(SLP_LIBRARIES NAMES slp libslp)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SLP DEFAULT_MSG SLP_LIBRARIES SLP_INCLUDE_DIR )
MARK_AS_ADVANCED(SLP_INCLUDE_DIR SLP_LIBRARIES)
......@@ -32,6 +32,6 @@ A library which models the network with all its devices and the services offered
Currently it uses KDNSSD, the KDElibs interface to the zeroconf service discovery system,
as the engine to find about the content of network structure. Later on this library should
support different backends concurrently (also SLP, UPnP, Windows related stuff like smb,
support different backends concurrently (also UPnP, Windows related stuff like smb,
including undiscoverable/hidden but user/admin entered ones).
If this works out this library might end in KDElibs solid module.
set(HAVE_SLP ${SLP_FOUND})
configure_file( config-slp.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-slp.h )
include_directories(
builder
......@@ -9,14 +8,6 @@ set( netsystemdriver_SRCS
builder/simpleitemfactory.cpp
)
# TODO: find best-practice to do such dependant inclusion of files to compile, this is unreadable
if(SLP_FOUND)
set( slpnetworkbuilder_SRCS
builder/slp/slpservicebrowser.cpp
builder/slp/slpnetworkbuilder.cpp
)
endif()
set( dnssdnetworkbuilder_SRCS
builder/dnssd/dnssdnetworkbuilder.cpp
)
......@@ -38,7 +29,6 @@ set( networkdbus_LIB_SRCS
set( molletnetwork5_LIB_SRCS
${netsystemdriver_SRCS}
# ${slpnetworkbuilder_SRCS}
${upnpnetworkbuilder_SRCS}
${dnssdnetworkbuilder_SRCS}
${networkbuilder_SRCS}
......@@ -59,9 +49,7 @@ target_link_libraries( molletnetwork5
Qt5::Gui
Qt5::DBus
)
if(SLP_FOUND)
target_link_libraries( molletnetwork5 PRIVATE ${SLP_LIBRARIES} )
endif()
set_target_properties( molletnetwork5 PROPERTIES VERSION ${KDE_APPLICATIONS_VERSION} SOVERSION ${KDE_APPLICATIONS_VERSION_MAJOR} )
install( TARGETS molletnetwork5 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP )
Add backends for
* SLP
* Jini
* UPnP
* SMB
......@@ -96,4 +95,3 @@ For now simple listing with non-funct system items will do.
newDevices.append( device );
mNetworkPrivate->emitDevicesAdded( newDevices );
}
/*
This file is part of the Mollet network library, part of the KDE project.
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "slpnetworkbuilder.h"
// lib
#include "slpservicebrowser.h"
// Qt
#include <QtCore/QList>
#include <QDebug>
namespace Mollet
{
SlpNetworkBuilder::SlpNetworkBuilder( NetworkPrivate* networkPrivate )
: mNetworkPrivate( networkPrivate )
{
mSlpServiceBrowser = new SlpServiceBrowser();
connect(mSlpServiceBrowser, &SlpServiceBrowser::servicesAdded, this, &SlpNetworkBuilder::onServicesAdded);
connect(mSlpServiceBrowser, &SlpServiceBrowser::servicesChanged, this, &SlpNetworkBuilder::onServicesChanged);
connect(mSlpServiceBrowser, &SlpServiceBrowser::servicesRemoved, this, &SlpNetworkBuilder::onServicesRemoved);
}
void SlpNetworkBuilder::onServicesAdded( const QList<SLPService>& services )
{
//qDebug()<<services.count()<<services[0].serviceUrl();
}
void SlpNetworkBuilder::onServicesChanged( const QList<SLPService>& services )
{
//qDebug()<<services.count()<<services[0].serviceUrl();
}
void SlpNetworkBuilder::onServicesRemoved( const QList<SLPService>& services )
{
//qDebug()<<services.count()<<services[0].serviceUrl();
}
SlpNetworkBuilder::~SlpNetworkBuilder()
{
delete mSlpServiceBrowser;
}
}
/*
This file is part of the Mollet network library, part of the KDE project.
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SLPNETWORKBUILDER_H
#define SLPNETWORKBUILDER_H
// lib
#include "abstractnetworkbuilder.h"
namespace Mollet {
class NetworkPrivate;
class SlpServiceBrowser;
class SLPService;
}
template <class T> class QList;
namespace Mollet
{
class SlpNetworkBuilder : public AbstractNetworkBuilder
{
Q_OBJECT
public:
explicit SlpNetworkBuilder( NetworkPrivate* networkPrivate );
virtual ~SlpNetworkBuilder();
public:
private Q_SLOTS:
void onServicesAdded( const QList<SLPService>& services );
void onServicesChanged( const QList<SLPService>& services );
void onServicesRemoved( const QList<SLPService>& services );
private:
NetworkPrivate* mNetworkPrivate;
SlpServiceBrowser* mSlpServiceBrowser;
};
}
#endif
/*
This file is part of the Mollet network library, part of the KDE project.
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SLPSERVICE_H
#define SLPSERVICE_H
// Qt
#include <QtCore/QString>
#include <QtCore/QHash>
namespace Mollet
{
class SLPService
{
public:
enum State { New, Changed, Unchanged, Unknown };
public:
explicit SLPService( const QString& serviceUrl, const QString& attributesString, const QString& name );
public:
SLPService::State state() const;
const QString& serviceUrl() const;
const QString& attributesString() const;
const QString& name() const;
public:
void resetState();
void checkForChanges( const QString& attributesString, const QString& name );
private:
State mState;
QString mServiceUrl;
QString mAttributesString; // TODO make QByteArray
QString mName; // by mdns
};
inline SLPService::SLPService( const QString& serviceUrl, const QString& attributesString, const QString& name )
: mState( New ), mServiceUrl( serviceUrl ), mAttributesString( attributesString ), mName( name ) {}
inline SLPService::State SLPService::state() const { return mState; }
inline const QString& SLPService::serviceUrl() const { return mServiceUrl; }
inline const QString& SLPService::attributesString() const { return mAttributesString; }
inline const QString& SLPService::name() const { return mName; }
inline void SLPService::resetState() { mState = Unknown; }
inline void SLPService::checkForChanges( const QString& attributesString, const QString& name )
{
State newState = Unchanged;
if( mAttributesString != attributesString )
{
mAttributesString = attributesString;
newState = Changed;
}
if( mName != name )
{
mName = name;
newState = Changed;
}
mState = newState;
}
inline uint qHash( const SLPService& service ) { return qHash( service.attributesString() ); }
}
#endif
/*
This file is part of the Mollet network library, part of the KDE project.
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "slpservicebrowser.h"
// Qt
#include <QtCore/QStringList>
#include <QDebug>
#ifndef Q_OS_WIN
extern "C"
{
/* let it still work, even someone installed a non-SuSE openslp */
SLPEXP const char* SLPAPI SLPGetMDNSName( SLPHandle hSLP, const char* pcURL ) __attribute__ ((weak));
}
#endif
namespace Mollet
{
static const char DefaultScope[] = "";
static const char AllNamingAuthorities[] = '*';
static const char AllServiceFilter[] = "";
static const char AllAttributesFilter[] = "";
static const int updateIntervalMSecs = 7000;
// crasht
// zum einen darf man eine slphandle nur für einen api call nutzen, idee unten geht also nicht.
SlpServiceBrowser::SlpServiceBrowser()
{
SLPError result = SLPOpen( 0, SLP_FALSE, &mSLP );
if( result != SLP_OK )
// TODO: emit error somewhere
return;
scan();
startTimer( updateIntervalMSecs );
}
void SlpServiceBrowser::scan()
{
mCurrentServiceList.resetState();
// list services
SLPFindSrvTypes( mSLP, AllNamingAuthorities, DefaultScope, onServiceTypesFound, this );
// detect changes
QList<SLPService> newServices;
QList<SLPService> changedServices;
QList<SLPService> unknownServices;
QHash<QString,SLPService>::Iterator it = mCurrentServiceList.begin();
while( it != mCurrentServiceList.end() )
{
const SLPService::State state = it->state();
switch( state )
{
case SLPService::New:
newServices.append( *it );
++it;
break;
case SLPService::Changed:
changedServices.append( *it );
++it;
break;
case SLPService::Unknown:
unknownServices.append( *it );
it = mCurrentServiceList.erase( it );
break;
case SLPService::Unchanged:
default:
++it;
}
}
if( ! newServices.isEmpty() )
emit servicesAdded( newServices );
if( ! changedServices.isEmpty() )
emit servicesChanged( changedServices );
if( ! unknownServices.isEmpty() )
emit servicesRemoved( unknownServices );
}
void SlpServiceBrowser::timerEvent( QTimerEvent* event )
{
Q_UNUSED( event )
scan();
}
inline bool splitSlpServiceUrl( QString* serviceType, QString* siteNParameter, const char* serviceUrl )
{
Q_UNUSED( serviceType )
Q_UNUSED( siteNParameter )
bool result;
QString url( serviceUrl );
if( url.startsWith(QLatin1String("service:")) )
url.remove( 0, 8 );
result = false;//( matcher->indexIn(url) >= 0 );
// TODO: when can a service url not match?
if ( result )
{
// *serviceType = matcher->cap( 1 );
// *siteNParameter = matcher->cap( 2 );
}
return result;
}
SLPBoolean SlpServiceBrowser::onServiceTypesFound( SLPHandle hslp, const char* serviceTypes, SLPError errorCode, void* builder )
{
//qDebug();
if( errorCode == SLP_LAST_CALL )
return SLP_FALSE;
// problems to ignore for now
if ( !serviceTypes || !*serviceTypes || errorCode != SLP_OK )
return SLP_TRUE;
// optimize by operating on original data as much as possible
const QStringList serviceTypeList = QString::fromLatin1( serviceTypes ).split( QLatin1Char(',') );
foreach( const QString& serviceType, serviceTypeList )
{
//qDebug()<<serviceType;
// "service:"<abstract-type.naming-authority>":"<concrete-type>
continue;
SLPFindSrvs( hslp, serviceType.toLatin1(), DefaultScope, AllServiceFilter, onServiceFound, builder );
}
return SLP_TRUE;
}
SLPBoolean SlpServiceBrowser::onServiceFound( SLPHandle hslp, const char* serviceUrl, unsigned short lifetime, SLPError errorCode, void* builder )
{
Q_UNUSED( lifetime )
if( errorCode == SLP_LAST_CALL )
return SLP_FALSE;
// problems to ignore for now
if ( !serviceUrl || !*serviceUrl || errorCode != SLP_OK )
return SLP_TRUE;
QString serviceType;
QString siteNParameter;
// const bool success = ::splitSlpServiceUrl( &serviceType, &siteNParameter, serviceUrl );
// if( success )
{
// #ifndef Q_OS_WIN
// const QString mdnsName = ( SLPGetMDNSName ) ? QString::fromUtf8(SLPGetMDNSName(hslp, serviceUrl)) : QString();
// #endif
QString attributeList;
SLPFindAttrs( hslp, serviceUrl, DefaultScope, AllAttributesFilter, onAttributesFound, &attributeList );
const QLatin1String name( serviceUrl );
static_cast<SlpServiceBrowser*>( builder )->mCurrentServiceList.checkService( serviceUrl, name, attributeList );
}
return SLP_TRUE;
}
SLPBoolean SlpServiceBrowser::onAttributesFound( SLPHandle hslp, const char* attributeList, SLPError errorCode, void* _attributeList )
{
Q_UNUSED( hslp )
if( errorCode != SLP_OK )
return SLP_FALSE;
// TODO: find out how long attrlist is valid and if we could not just use a const char* pointer until onServiceFound
*static_cast<QString*>( _attributeList ) = QString::fromUtf8( attributeList ); //right for mdns at least
#if 0
parse only on change in scan()
// TODO: speed up by not resetting l but tracking the current index
while ( !l.isEmpty() )
{
if ( l[0] == '(' )
{
const int indexOfBracket = l.indexOf( ')' );
QString m = l.mid( 1, indexOfBracket-1 );
const int indexOfEquals = m.indexOf( '=' );
// attributeHtml += m.left( indexOfEquals );
m.remove( 0, indexOfEquals+1 );
// attributeHtml += m.split( ',' ).join("<br>");
l.remove( 0, indexOfBracket+2 );
}
else
{
const int indexOfComma = l.indexOf( ',' );
QString m = l.left( indexOfComma );
l.remove( 0, indexOfComma+1 );
}
}
// static_cast<SlpServiceBrowser*>( builder )->reportAttributes();
#endif
// signal no further info needed, as attributes were just asked for one service
return SLP_FALSE;
}
SlpServiceBrowser::~SlpServiceBrowser()
{
SLPClose( mSLP );
}
}
/*
This file is part of the Mollet network library, part of the KDE project.
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SLPSERVICEBROWSER_H
#define SLPSERVICEBROWSER_H
// lib
#include "slpservicelist.h"
// SLP
#include <slp.h>
// Qt
#include <QtCore/QObject>
class QStringList;
template <class T> class QList;
namespace Mollet
{
class SlpServiceBrowser : public QObject
{
Q_OBJECT
private:
static SLPBoolean onAttributesFound( SLPHandle hslp, const char* attributeList, SLPError errorCode, void* builder );
static SLPBoolean onServiceFound( SLPHandle hslp, const char* serviceUrl, unsigned short lifetime, SLPError errorCode, void* builder );
static SLPBoolean onServiceTypesFound( SLPHandle hslp, const char* serviceTypes, SLPError errorCode, void* _attributeList );
public:
explicit SlpServiceBrowser();
virtual ~SlpServiceBrowser();
Q_SIGNALS:
void servicesAdded( const QList<SLPService>& services );
void servicesChanged( const QList<SLPService>& services );
void servicesRemoved( const QList<SLPService>& services );
protected Q_SLOTS: // Object API
virtual void timerEvent( QTimerEvent* event );
private Q_SLOTS:
void scan();
private:
SlpServiceList mCurrentServiceList;
SLPHandle mSLP;
// used to store the attributelist from the onAttributesFound call
QString mAttributeList;
};
}
#endif
/*
This file is part of the Mollet network library, part of the KDE project.
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SLPSERVICELIST_H
#define SLPSERVICELIST_H
// lib
#include "slpservice.h"