diff --git a/CMakeLists.txt b/CMakeLists.txt index 52d54f6e..180d7977 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,193 +1,186 @@ cmake_minimum_required(VERSION 3.0) # KDE Applications Version, managed by release script set (KDE_APPLICATIONS_VERSION_MAJOR "18") set (KDE_APPLICATIONS_VERSION_MINOR "03") set (KDE_APPLICATIONS_VERSION_MICRO "70") set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") project(kio-extras VERSION ${KDE_APPLICATIONS_VERSION}) include(FeatureSummary) set(QT_MIN_VERSION "5.5.0") set(KF5_MIN_VERSION "5.40.0") find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS DBus Network Widgets Svg) find_package(Qt5Test ${QT_MIN_VERSION} CONFIG QUIET) set_package_properties(Qt5Test PROPERTIES PURPOSE "Required for tests" TYPE OPTIONAL ) add_feature_info("Qt5Test" Qt5Test_FOUND "Required for building tests") if (NOT Qt5Test_FOUND) set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.") endif() find_package(ECM 0.0.11 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Archive Config ConfigWidgets CoreAddons DBusAddons DocTools DNSSD IconThemes I18n KIO Solid Bookmarks GuiAddons ) # As this is the check used for linkage, only require it in the same location... if (UNIX) find_package(KF5Pty ${KF5_MIN_VERSION} REQUIRED) endif() include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(CMakePackageConfigHelpers) include(ECMMarkNonGuiExecutable) include(ECMMarkAsTest) include(ECMOptionalAddSubdirectory) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) find_package(KF5Activities QUIET) set_package_properties(KF5Activities PROPERTIES PURPOSE "Provides the activities:/ kioslave and fileitem plugin." 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" PURPOSE "Required for the audio preview plugin" TYPE OPTIONAL) include_directories(${CMAKE_CURRENT_BINARY_DIR}) if(NOT WIN32) # we need a version of samba which has already smbc_set_context(), Alex set(SAMBA_REQUIRE_SMBC_SET_CONTEXT TRUE) set(SAMBA_REQUIRE_SMBC_OPTION_SET TRUE) find_package(Samba) set_package_properties(Samba PROPERTIES DESCRIPTION "the SMB client library, a version with smbc_set_context() and smbc_option_set()" URL "http://www.samba.org" TYPE OPTIONAL PURPOSE "Needed to build the SMB kioslave" ) endif() find_package(LibSSH 0.6.0) set_package_properties(LibSSH PROPERTIES DESCRIPTION "the SSH library with SFTP support" URL "http://www.libssh.org/" TYPE OPTIONAL PURPOSE "Needed to build the SFTP kioslave" ) find_package(Mtp) set_package_properties(Mtp PROPERTIES DESCRIPTION "the MTP library" URL "http://libmtp.sourceforge.net/" TYPE OPTIONAL PURPOSE "Needed to build the MTP kioslave" ) # ECM's KDECompilerSettings.cmake should take care of enabling supporting on # 32bit architectures. # Thorw a fatal error if off_t isn't >=64bit to ensure that large files are working # as expected. # BUG: 165449 if(UNIX) check_cxx_source_compiles(" #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main() { return 0; } " OFFT_IS_64BIT) if(NOT OFFT_IS_64BIT) message(FATAL_ERROR "Large file support is not enabled.") endif() find_package(Gperf) set_package_properties(Gperf PROPERTIES TYPE OPTIONAL PURPOSE "Needed to build the man kioslave" ) find_package(KF5KHtml QUIET) set_package_properties(KF5KHtml PROPERTIES TYPE OPTIONAL PURPOSE "Needed to build the man kioslave" ) else() # FIXME: on windows we ignore support until trash gets integrated endif() add_subdirectory( doc ) add_subdirectory( about ) if(KF5Activities_FOUND) add_subdirectory( activities ) endif() add_subdirectory( bookmarks ) add_subdirectory( filter ) if(Phonon4Qt5_FOUND) add_subdirectory( kfileaudiopreview ) endif() add_subdirectory( info ) add_subdirectory( archive ) if(NOT WIN32) add_subdirectory( network ) endif() add_subdirectory( recentdocuments ) if (NOT WIN32) # does not compile: fish.cpp(41): fatal error C1083: Cannot open include file: 'sys/resource.h': No such file or directory # Used for getting the resource limit for closing all child process FDs. Could be completely replaced by fcloseall() if available for Unix or _fcloseall() for Windows, either conditionally on Q_OS_type or using a configure test. add_subdirectory( fish ) endif() add_subdirectory( thumbnail ) add_subdirectory( docfilter ) if (NOT WIN32 AND LIBSSH_FOUND) # does not compile on Windows: kio_sftp.cpp(28): fatal error C1083: Cannot open include file: 'utime.h': No such file or directory add_subdirectory(sftp) endif () add_subdirectory(settings) add_subdirectory( filenamesearch ) if (MTP_FOUND) add_subdirectory(mtp) endif() if(NOT WIN32) if(Gperf_FOUND AND KF5KHtml_FOUND) add_subdirectory( man ) endif() check_include_files(rpc/rpc.h HAVE_RPC_RPC_H) add_feature_info("NFS kioslave" HAVE_RPC_RPC_H "The RPC library is needed to build the NFS kioslave") if(HAVE_RPC_RPC_H) add_subdirectory( nfs ) endif() endif() if(SAMBA_FOUND) add_subdirectory(smb) endif() configure_file (config-runtime.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-runtime.h ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/cmake/FindSLP.cmake b/cmake/FindSLP.cmake deleted file mode 100644 index c52dfe7b..00000000 --- a/cmake/FindSLP.cmake +++ /dev/null @@ -1,43 +0,0 @@ -# cmake macro to test SLP LIB - -# Copyright (c) 2006, 2007 Laurent Montel, -# -# 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) diff --git a/network/README b/network/README index 555d45b1..4d5eaba1 100644 --- a/network/README +++ b/network/README @@ -1,37 +1,37 @@ networkkio ========== This is an experimental kioslave which presents the network. It also includes a library which models the network, the devices, and services, and could be reused by other code. Please contact the author Friedrich W. H. Kossebau for any further questions. Cooperation in this area is welcome :) ioslave ------- The ioslave lists the local network as represented by the The protocol name is "network", so enter "network:/" to see your local network. Currently, due to synchronisation problems, the network data is fetched from the kded network module via D-Bus, instead of using the network library directly. kded ---- A kded module to emit KDirNotify signals as needed if the network structure changes. That way all users of the network kioslave and listening to KDirNotify can update the view, e.g. Dolphin, Konqueror and the KDElibs file dialogs. It also offers the data of the network structure over D-Bus, as currently used by the ioslave. network ------- A library which models the network with all its devices and the services offered by them. 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. diff --git a/network/network/CMakeLists.txt b/network/network/CMakeLists.txt index 1e68e18a..abd31a98 100644 --- a/network/network/CMakeLists.txt +++ b/network/network/CMakeLists.txt @@ -1,67 +1,55 @@ -set(HAVE_SLP ${SLP_FOUND}) -configure_file( config-slp.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-slp.h ) + include_directories( builder ) 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 ) set( upnpnetworkbuilder_SRCS builder/upnp/cagibidevice.cpp builder/upnp/cagibidbuscodec.cpp builder/upnp/upnpnetworkbuilder.cpp ) set( networkbuilder_SRCS builder/abstractnetworkbuilder.cpp builder/abstractnetsystemfactory.cpp ) set( networkdbus_LIB_SRCS networkdbus.cpp ) set( molletnetwork5_LIB_SRCS ${netsystemdriver_SRCS} -# ${slpnetworkbuilder_SRCS} ${upnpnetworkbuilder_SRCS} ${dnssdnetworkbuilder_SRCS} ${networkbuilder_SRCS} ${networkdbus_LIB_SRCS} network_p.cpp network.cpp netdevice_p.cpp netdevice.cpp netservice_p.cpp netservice.cpp ) add_library( molletnetwork5 SHARED ${molletnetwork5_LIB_SRCS} ) target_link_libraries( molletnetwork5 PUBLIC KF5::DNSSD Qt5::Network 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 ) diff --git a/network/network/TODO b/network/network/TODO index bd770fd9..f4f5a8a5 100644 --- a/network/network/TODO +++ b/network/network/TODO @@ -1,99 +1,97 @@ Add backends for -* SLP * Jini * UPnP * SMB * manually added devices/services -> means also support for state not-present * scanning? list of dns-ds service types: http://www.dns-sd.org/ServiceTypes.html See if there could be a xdg database of products with device ontology/categories. Add a device guesser which tries to estimate the type of device by the services (or even with a dedicated protocol if there is one?) Devices: * Fileserver/-storage * Webserver * Desktop-like Computer (human-interface general purpose) * wearable * MID * Handheld * E-Book reader (is media renderer?) * Laptop * Game server * Server * Router * Internet Gateway Device (IGD) * Mediaserver * Mediarenderer * HVAC * Scanner * WLAN Access point * Digital Security camera * Wearable * Augmented-reality device (headmounted) Questions: What is a (virtual) device, what is a service? Aren't all servives virtual devices? So present as device or service? Some devices use services as interface utility (e.g. a http server for SOAP). Separate human/computer-usable services? Firstlevel service and secondlevel service? Physical objects should be represented as physical objects. Perhaps mark with flag. Which of the virtual machines in a server is the physical one if the vm host doesn't show up? How to handle unknown devices? Who might want to see them? Developers? Or users, to see it's there but not supported (=without a driver)? There could be a user editable whitelist/blacklist. Support should be plugin-based, so 3-party developers can easily try to develop their own drivers. There need to be servicetype-specific handlers which can create the service proxy object. Should be able to register to different discovery backends (collision handling by priority perhaps). For now simple listing with non-funct system items will do. { "_presence._tcp", "presence", "inode/vnd.kde.service.presence", "im-user", false, 0, 0, 0, 0 }, // presence http://www.xmpp.org/registrar/linklocal.html // "1st", firstName, "email", emailAddress, "last", lastName, "status", "avail"); // TODO: make this first non-simple item, showing addressbook entry // KDE { "_knotes._tcp", "knotes", "inode/vnd.kde.service.knotes", "knotes", false, "http", 0, 0, 0 }, // TODO: make this second non-simple item, listing notes or enable the drop of ones (forwarding to some knotes: protocol? QList& deviceList = mNetworkPrivate->deviceList(); static const char* DeviceNamen[] = { "Datensafe.local", "Schleuder.local", "Phlox.local", "buntekuh.local" }; for( int i=0; i<4; ++i ) { const QString hostName( DeviceNamen[i] ); const QString deviceName = hostName.left( hostName.indexOf('.') ); NetDevicePrivate* d = new NetDevicePrivate( deviceName, hostName ); d->setType( NetDevice::Workstation ); NetDevice device( d ); deviceList.append( device ); QList newDevices; newDevices.append( device ); mNetworkPrivate->emitDevicesAdded( newDevices ); } - diff --git a/network/network/builder/slp/slpnetworkbuilder.cpp b/network/network/builder/slp/slpnetworkbuilder.cpp deleted file mode 100644 index 2a88ba64..00000000 --- a/network/network/builder/slp/slpnetworkbuilder.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of the Mollet network library, part of the KDE project. - - Copyright 2009 Friedrich W. H. Kossebau - - 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 . -*/ - -#include "slpnetworkbuilder.h" - -// lib -#include "slpservicebrowser.h" -// Qt -#include - -#include - - -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& services ) -{ -//qDebug()<& services ) -{ -//qDebug()<& services ) -{ -//qDebug()< - - 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 . -*/ - -#ifndef SLPNETWORKBUILDER_H -#define SLPNETWORKBUILDER_H - -// lib -#include "abstractnetworkbuilder.h" - -namespace Mollet { -class NetworkPrivate; -class SlpServiceBrowser; -class SLPService; -} -template 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& services ); - void onServicesChanged( const QList& services ); - void onServicesRemoved( const QList& services ); - - private: - NetworkPrivate* mNetworkPrivate; - - SlpServiceBrowser* mSlpServiceBrowser; -}; - -} - -#endif diff --git a/network/network/builder/slp/slpservice.h b/network/network/builder/slp/slpservice.h deleted file mode 100644 index 49b29f5a..00000000 --- a/network/network/builder/slp/slpservice.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - This file is part of the Mollet network library, part of the KDE project. - - Copyright 2009 Friedrich W. H. Kossebau - - 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 . -*/ - -#ifndef SLPSERVICE_H -#define SLPSERVICE_H - -// Qt -#include -#include - - -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 diff --git a/network/network/builder/slp/slpservicebrowser.cpp b/network/network/builder/slp/slpservicebrowser.cpp deleted file mode 100644 index ffb705a2..00000000 --- a/network/network/builder/slp/slpservicebrowser.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - This file is part of the Mollet network library, part of the KDE project. - - Copyright 2009 Friedrich W. H. Kossebau - - 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 . -*/ - -#include "slpservicebrowser.h" - -// Qt -#include - -#include - -#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 newServices; - QList changedServices; - QList unknownServices; - - QHash::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()<":" -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( 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( _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("
"); - - l.remove( 0, indexOfBracket+2 ); - } - else - { - const int indexOfComma = l.indexOf( ',' ); - QString m = l.left( indexOfComma ); - - l.remove( 0, indexOfComma+1 ); - } - } - -// static_cast( builder )->reportAttributes(); -#endif - // signal no further info needed, as attributes were just asked for one service - return SLP_FALSE; -} - - -SlpServiceBrowser::~SlpServiceBrowser() -{ - SLPClose( mSLP ); -} - -} diff --git a/network/network/builder/slp/slpservicebrowser.h b/network/network/builder/slp/slpservicebrowser.h deleted file mode 100644 index 0d3779ee..00000000 --- a/network/network/builder/slp/slpservicebrowser.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - This file is part of the Mollet network library, part of the KDE project. - - Copyright 2009 Friedrich W. H. Kossebau - - 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 . -*/ - -#ifndef SLPSERVICEBROWSER_H -#define SLPSERVICEBROWSER_H - -// lib -#include "slpservicelist.h" -// SLP -#include -// Qt -#include - -class QStringList; -template 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& services ); - void servicesChanged( const QList& services ); - void servicesRemoved( const QList& 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 diff --git a/network/network/builder/slp/slpservicelist.h b/network/network/builder/slp/slpservicelist.h deleted file mode 100644 index c6bd51a3..00000000 --- a/network/network/builder/slp/slpservicelist.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is part of the Mollet network library, part of the KDE project. - - Copyright 2009 Friedrich W. H. Kossebau - - 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 . -*/ - -#ifndef SLPSERVICELIST_H -#define SLPSERVICELIST_H - -// lib -#include "slpservice.h" -// Qt -#include -#include - - -namespace Mollet -{ - -class SlpServiceList : public QHash -{ - public: - SlpServiceList(); - - public: - void resetState(); - void checkService( const QString& serviceUrl, const QString& name, const QString& attributeList ); - - private: -}; - - -inline SlpServiceList::SlpServiceList() {} - -inline void SlpServiceList::resetState() -{ - QHash::Iterator it; - const QHash::Iterator endIt = end(); - for( it = begin(); it != endIt; ++it ) - it.value().resetState(); -} - -inline void SlpServiceList::checkService( const QString& serviceUrl, const QString& name, const QString& attributeList ) -{ - QHash::Iterator it = find( serviceUrl ); - if( it != end() ) - it.value().checkForChanges( attributeList, name ); - else - insert( serviceUrl, SLPService(serviceUrl,attributeList,name) ); -} - -} - -#endif diff --git a/network/network/config-slp.h.cmake b/network/network/config-slp.h.cmake deleted file mode 100644 index 1e4ca0e9..00000000 --- a/network/network/config-slp.h.cmake +++ /dev/null @@ -1,2 +0,0 @@ -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SLP 1 diff --git a/network/network/network_p.cpp b/network/network/network_p.cpp index 9ed9b559..e4ef06a7 100644 --- a/network/network/network_p.cpp +++ b/network/network/network_p.cpp @@ -1,82 +1,74 @@ /* This file is part of the Mollet network library, part of the KDE project. Copyright 2009 Friedrich W. H. Kossebau 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 . */ #include "network_p.h" -// -#include // lib #include "builder/dnssd/dnssdnetworkbuilder.h" #include "builder/upnp/upnpnetworkbuilder.h" #include "builder/simpleitemfactory.h" -#ifdef HAVE_SLP -#include "builder/slp/slpnetworkbuilder.h" -#endif #include namespace Mollet { NetworkPrivate::NetworkPrivate( Network* parent ) : p( parent ) { } void NetworkPrivate::init() { SimpleItemFactory* simpleItemFactory = new SimpleItemFactory(); mNetSystemFactoryList.append( simpleItemFactory ); DNSSDNetworkBuilder* dnssdBuilder = new DNSSDNetworkBuilder( this ); UpnpNetworkBuilder* upnpBuilder = new UpnpNetworkBuilder( this ); -#ifdef HAVE_SLP -// mSlpBuilder = new SlpNetworkBuilder( this ); -#endif mNetworkBuilderList.append( dnssdBuilder ); mNetworkBuilderList.append( upnpBuilder ); mNoOfInitBuilders = mNetworkBuilderList.count(); foreach( AbstractNetworkBuilder* builder, mNetworkBuilderList ) { foreach( AbstractNetSystemFactory* factory, mNetSystemFactoryList ) builder->registerNetSystemFactory( factory ); p->connect( builder, SIGNAL(initDone()), SLOT(onBuilderInit()) ); builder->start(); } } void NetworkPrivate::onBuilderInit() { --mNoOfInitBuilders; //qDebug()<initDone(); } NetworkPrivate::~NetworkPrivate() { qDeleteAll( mNetworkBuilderList ); qDeleteAll( mNetSystemFactoryList ); } }