mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kutils: new knetworkmanager library
to replace the status notifier (in the kde-workspace repo) and eventually manage network connections aswell as move network status notifier out of solid Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
3521d07234
commit
355bca1289
13 changed files with 201 additions and 311 deletions
|
@ -198,6 +198,7 @@ install(
|
||||||
KMultiTabBarButton
|
KMultiTabBarButton
|
||||||
KMultiTabBarTab
|
KMultiTabBarTab
|
||||||
KNameAndUrlInputDialog
|
KNameAndUrlInputDialog
|
||||||
|
KNetworkManager
|
||||||
KNewFileMenu
|
KNewFileMenu
|
||||||
KNewPasswordDialog
|
KNewPasswordDialog
|
||||||
KNotification
|
KNotification
|
||||||
|
@ -472,7 +473,6 @@ install(
|
||||||
Solid/DeviceNotifier
|
Solid/DeviceNotifier
|
||||||
Solid/GenericInterface
|
Solid/GenericInterface
|
||||||
Solid/NetworkInterface
|
Solid/NetworkInterface
|
||||||
Solid/Networking
|
|
||||||
Solid/OpticalDisc
|
Solid/OpticalDisc
|
||||||
Solid/OpticalDrive
|
Solid/OpticalDrive
|
||||||
Solid/PortableMediaPlayer
|
Solid/PortableMediaPlayer
|
||||||
|
|
1
includes/KNetworkManager
Normal file
1
includes/KNetworkManager
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "../knetworkmanager.h"
|
|
@ -1 +0,0 @@
|
||||||
#include "../../solid/networking.h"
|
|
|
@ -39,7 +39,6 @@
|
||||||
711 kutils (KCModuleProxy)
|
711 kutils (KCModuleProxy)
|
||||||
712 kutils (KCModuleInfo)
|
712 kutils (KCModuleInfo)
|
||||||
713 kutils (KCModuleContainer)
|
713 kutils (KCModuleContainer)
|
||||||
921 Solid Networking
|
|
||||||
930 KUnitConversion
|
930 KUnitConversion
|
||||||
940 kmediaplayer
|
940 kmediaplayer
|
||||||
1000 kparts
|
1000 kparts
|
||||||
|
@ -74,6 +73,7 @@
|
||||||
51006 kdnssd
|
51006 kdnssd
|
||||||
51009 karchive
|
51009 karchive
|
||||||
51010 kemail
|
51010 kemail
|
||||||
|
51011 knetworkmanager
|
||||||
|
|
||||||
# kde-workspace
|
# kde-workspace
|
||||||
101 kioclient
|
101 kioclient
|
||||||
|
|
|
@ -14,6 +14,7 @@ add_subdirectory(kpowermanager)
|
||||||
add_subdirectory(kdnssd)
|
add_subdirectory(kdnssd)
|
||||||
add_subdirectory(karchive)
|
add_subdirectory(karchive)
|
||||||
add_subdirectory(kemail)
|
add_subdirectory(kemail)
|
||||||
|
add_subdirectory(knetworkmanager)
|
||||||
|
|
||||||
######## kidletime ####################
|
######## kidletime ####################
|
||||||
|
|
||||||
|
|
40
kutils/knetworkmanager/CMakeLists.txt
Normal file
40
kutils/knetworkmanager/CMakeLists.txt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# for the kded module
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=51011)
|
||||||
|
|
||||||
|
set(knetworkmanager_LIB_SRCS
|
||||||
|
knetworkmanager.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(knetworkmanager SHARED ${knetworkmanager_LIB_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(knetworkmanager PUBLIC
|
||||||
|
${QT_QTDBUS_LIBRARY}
|
||||||
|
kdecore
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(knetworkmanager PROPERTIES
|
||||||
|
VERSION ${GENERIC_LIB_VERSION}
|
||||||
|
SOVERSION ${GENERIC_LIB_SOVERSION}
|
||||||
|
)
|
||||||
|
|
||||||
|
generate_export_header(knetworkmanager)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/knetworkmanager_export.h
|
||||||
|
knetworkmanager.h
|
||||||
|
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS knetworkmanager
|
||||||
|
EXPORT kdelibsTargets
|
||||||
|
DESTINATION ${KDE4_LIB_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# add_subdirectory(kded)
|
82
kutils/knetworkmanager/knetworkmanager.cpp
Normal file
82
kutils/knetworkmanager/knetworkmanager.cpp
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/* This file is part of the KDE libraries
|
||||||
|
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License version 2, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "knetworkmanager.h"
|
||||||
|
#include "kdebug.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QNetworkInterface>
|
||||||
|
|
||||||
|
class KNetworkManagerPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KNetworkManagerPrivate();
|
||||||
|
|
||||||
|
KNetworkManager::KNetworkStatus status;
|
||||||
|
QTimer* statustimer;
|
||||||
|
};
|
||||||
|
|
||||||
|
KNetworkManagerPrivate::KNetworkManagerPrivate()
|
||||||
|
: status(KNetworkManager::UnknownStatus),
|
||||||
|
statustimer(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KNetworkManager::KNetworkManager(QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
d(new KNetworkManagerPrivate())
|
||||||
|
{
|
||||||
|
d->statustimer = new QTimer(this);
|
||||||
|
connect(d->statustimer, SIGNAL(timeout()), this, SLOT(_checkStatus()));
|
||||||
|
d->statustimer->start(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
KNetworkManager::~KNetworkManager()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
KNetworkManager::KNetworkStatus KNetworkManager::status() const
|
||||||
|
{
|
||||||
|
return d->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KNetworkManager::isSupported()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KNetworkManager::_checkStatus()
|
||||||
|
{
|
||||||
|
KNetworkManager::KNetworkStatus newstatus = KNetworkManager::DisconnectedStatus;
|
||||||
|
foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
|
||||||
|
const QNetworkInterface::InterfaceFlags iflags = iface.flags();
|
||||||
|
if (iflags & QNetworkInterface::CanBroadcast && iflags & QNetworkInterface::IsRunning) {
|
||||||
|
newstatus = KNetworkManager::ConnectedStatus;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->status != newstatus) {
|
||||||
|
d->status = newstatus;
|
||||||
|
kDebug() << "Status changed to" << newstatus;
|
||||||
|
emit statusChanged(newstatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_knetworkmanager.cpp"
|
75
kutils/knetworkmanager/knetworkmanager.h
Normal file
75
kutils/knetworkmanager/knetworkmanager.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/* This file is part of the KDE libraries
|
||||||
|
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License version 2, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KNETWORKMANAGER_H
|
||||||
|
#define KNETWORKMANAGER_H
|
||||||
|
|
||||||
|
#include "knetworkmanager_export.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class KNetworkManagerPrivate;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Class to query, manage and watch the system network state.
|
||||||
|
|
||||||
|
@since 4.23
|
||||||
|
@warning the API is subject to change
|
||||||
|
*/
|
||||||
|
class KNETWORKMANAGER_EXPORT KNetworkManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum KNetworkStatus {
|
||||||
|
UnknownStatus = 0,
|
||||||
|
ConnectedStatus = 1,
|
||||||
|
DisconnectedStatus = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Contructs object with @p parent
|
||||||
|
*/
|
||||||
|
KNetworkManager(QObject *parent = nullptr);
|
||||||
|
~KNetworkManager();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Returns the current network manager status
|
||||||
|
*/
|
||||||
|
KNetworkStatus status() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Returns @p true if network management is supported on this host,
|
||||||
|
@p false otherwise
|
||||||
|
*/
|
||||||
|
static bool isSupported();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
/*!
|
||||||
|
@brief Signals that the current status has changed to @p status
|
||||||
|
*/
|
||||||
|
void statusChanged(const KNetworkStatus status);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void _checkStatus();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(KNetworkManager);
|
||||||
|
KNetworkManagerPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KNETWORKMANAGER_H
|
|
@ -20,7 +20,6 @@ set_source_files_properties(
|
||||||
)
|
)
|
||||||
|
|
||||||
set(solid_LIB_SRCS
|
set(solid_LIB_SRCS
|
||||||
networking.cpp
|
|
||||||
solidnamespace.cpp
|
solidnamespace.cpp
|
||||||
managerbase.cpp
|
managerbase.cpp
|
||||||
device.cpp
|
device.cpp
|
||||||
|
@ -185,11 +184,6 @@ if(DEVINFO_FOUND)
|
||||||
set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${DEVINFO_LIBRARIES})
|
set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${DEVINFO_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt4_add_dbus_interface(solid_LIB_SRCS
|
|
||||||
org.kde.Solid.Networking.Client.xml
|
|
||||||
org_kde_solid_networking_client
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(solid SHARED ${solid_LIB_SRCS})
|
add_library(solid SHARED ${solid_LIB_SRCS})
|
||||||
|
|
||||||
target_link_libraries(solid PRIVATE
|
target_link_libraries(solid PRIVATE
|
||||||
|
@ -213,12 +207,6 @@ install(
|
||||||
DESTINATION ${KDE4_LIB_INSTALL_DIR}
|
DESTINATION ${KDE4_LIB_INSTALL_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
|
||||||
FILES
|
|
||||||
org.kde.Solid.Networking.Client.xml
|
|
||||||
DESTINATION ${KDE4_DBUS_INTERFACES_INSTALL_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
########### install files ###############
|
########### install files ###############
|
||||||
|
|
||||||
generate_export_header(solid)
|
generate_export_header(solid)
|
||||||
|
@ -246,7 +234,6 @@ install(
|
||||||
audiointerface.h
|
audiointerface.h
|
||||||
predicate.h
|
predicate.h
|
||||||
powermanagement.h
|
powermanagement.h
|
||||||
networking.h
|
|
||||||
video.h
|
video.h
|
||||||
graphic.h
|
graphic.h
|
||||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/solid
|
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/solid
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2006-2007 Will Stephenson <wstephenson@kde.org>
|
|
||||||
Copyright 2006-2007 Kevin Ottens <ervin@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 <KDebug>
|
|
||||||
|
|
||||||
#include "networking.h"
|
|
||||||
#include "networking_p.h"
|
|
||||||
|
|
||||||
#include "soliddefs_p.h"
|
|
||||||
#include "org_kde_solid_networking_client.h"
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(Solid::NetworkingPrivate, globalNetworkManager)
|
|
||||||
|
|
||||||
Solid::NetworkingPrivate::NetworkingPrivate()
|
|
||||||
: netStatus(Solid::Networking::Unknown),
|
|
||||||
iface(nullptr)
|
|
||||||
{
|
|
||||||
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(
|
|
||||||
"org.kde.kded", QDBusConnection::sessionBus(),
|
|
||||||
QDBusServiceWatcher::WatchForOwnerChange, this
|
|
||||||
);
|
|
||||||
connect(
|
|
||||||
watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
|
|
||||||
this, SLOT(serviceOwnerChanged(QString,QString,QString))
|
|
||||||
);
|
|
||||||
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
Solid::Networking::Notifier::Notifier()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Solid::NetworkingPrivate::initialize()
|
|
||||||
{
|
|
||||||
delete iface;
|
|
||||||
iface = new OrgKdeSolidNetworkingClientInterface(
|
|
||||||
"org.kde.kded",
|
|
||||||
"/modules/networkstatus",
|
|
||||||
QDBusConnection::sessionBus(),
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
// connect(iface, SIGNAL(statusChanged(uint)), globalNetworkManager(), SIGNAL(statusChanged(Networking::Status)));
|
|
||||||
connect(iface, SIGNAL(statusChanged(uint)), this, SLOT(serviceStatusChanged(uint)));
|
|
||||||
|
|
||||||
QDBusReply<uint> reply = iface->status();
|
|
||||||
if (reply.isValid()) {
|
|
||||||
netStatus = static_cast<Solid::Networking::Status>(reply.value());
|
|
||||||
} else {
|
|
||||||
netStatus = Solid::Networking::Unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint Solid::NetworkingPrivate::status() const
|
|
||||||
{
|
|
||||||
return netStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=========================================================================*/
|
|
||||||
|
|
||||||
Solid::Networking::Status Solid::Networking::status()
|
|
||||||
{
|
|
||||||
return static_cast<Solid::Networking::Status>(globalNetworkManager()->status());
|
|
||||||
}
|
|
||||||
|
|
||||||
Solid::Networking::Notifier *Solid::Networking::notifier()
|
|
||||||
{
|
|
||||||
return globalNetworkManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Solid::NetworkingPrivate::serviceStatusChanged(uint status)
|
|
||||||
{
|
|
||||||
// kDebug(921) ;
|
|
||||||
netStatus = static_cast<Solid::Networking::Status>(status);
|
|
||||||
switch (netStatus) {
|
|
||||||
case Solid::Networking::Unknown:
|
|
||||||
break;
|
|
||||||
case Solid::Networking::Unconnected:
|
|
||||||
case Solid::Networking::Disconnecting:
|
|
||||||
case Solid::Networking::Connecting:
|
|
||||||
emit globalNetworkManager()->shouldDisconnect();
|
|
||||||
break;
|
|
||||||
case Solid::Networking::Connected:
|
|
||||||
emit globalNetworkManager()->shouldConnect();
|
|
||||||
break;
|
|
||||||
// default:
|
|
||||||
// kDebug(921) << "Unrecognised status code!";
|
|
||||||
}
|
|
||||||
emit globalNetworkManager()->statusChanged(netStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Solid::NetworkingPrivate::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner)
|
|
||||||
{
|
|
||||||
Q_UNUSED(name)
|
|
||||||
Q_UNUSED(oldOwner)
|
|
||||||
if (newOwner.isEmpty()) {
|
|
||||||
// kded quit on us
|
|
||||||
netStatus = Solid::Networking::Unknown;
|
|
||||||
emit globalNetworkManager()->statusChanged(netStatus);
|
|
||||||
} else {
|
|
||||||
// kded was replaced or started
|
|
||||||
initialize();
|
|
||||||
emit globalNetworkManager()->statusChanged(netStatus);
|
|
||||||
serviceStatusChanged(netStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_networking_p.cpp"
|
|
||||||
#include "moc_networking.cpp"
|
|
|
@ -1,93 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2006-2007 Will Stephenson <wstephenson@kde.org>
|
|
||||||
Copyright 2006-2007 Kevin Ottens <ervin@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 SOLID_NETWORKING
|
|
||||||
#define SOLID_NETWORKING
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
|
|
||||||
#include <solid/solid_export.h>
|
|
||||||
|
|
||||||
namespace Solid
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* This namespace contains all the network-related high-level methods:
|
|
||||||
* querying the underlying system for network availability,
|
|
||||||
* being notified when network availability changes
|
|
||||||
* (e.g. due to interfaces appearing or disappearing).
|
|
||||||
*
|
|
||||||
* It also allows application to specify the connection and disconnection policies
|
|
||||||
* that it would like to use, for the network.
|
|
||||||
*/
|
|
||||||
namespace Networking
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Describes the state of the networking system
|
|
||||||
*/
|
|
||||||
enum Status {
|
|
||||||
Unknown, /**< the networking system is not active or unable to report its status - proceed with caution */
|
|
||||||
Unconnected,/**< the system is not connected to any network */
|
|
||||||
Disconnecting, /**< the system is breaking the connection */
|
|
||||||
Connecting, /**< the system is not connected to any network */
|
|
||||||
Connected /**< the system is currently connected to a network */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current networking status
|
|
||||||
* If the result is Unknown, the backend may be unconfigured or otherwise in a state where
|
|
||||||
* it cannot report useful networking status @ref Solid::Networking::Status.
|
|
||||||
*/
|
|
||||||
SOLID_EXPORT Status status();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This object emits signals, for use if your application requires notification
|
|
||||||
* of changes to networking.
|
|
||||||
*/
|
|
||||||
class SOLID_EXPORT Notifier : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_SIGNALS:
|
|
||||||
/**
|
|
||||||
* Signals that the network status has changed
|
|
||||||
* @param status the new status of the network status service
|
|
||||||
*/
|
|
||||||
void statusChanged(Solid::Networking::Status status);
|
|
||||||
/**
|
|
||||||
* Signals that the system's network has become connected, so receivers
|
|
||||||
* should connect their sockets, ioslaves etc.
|
|
||||||
*/
|
|
||||||
void shouldConnect();
|
|
||||||
/**
|
|
||||||
* Signals that the system's network has become disconnected,
|
|
||||||
* so receivers should adjust application state appropriately.
|
|
||||||
*/
|
|
||||||
void shouldDisconnect();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Notifier();
|
|
||||||
};
|
|
||||||
|
|
||||||
SOLID_EXPORT Notifier *notifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Solid
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2006-2007 Will Stephenson <wstephenson@kde.org>
|
|
||||||
Copyright 2006-2007 Kevin Ottens <ervin@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 SOLID_NETWORKING_P_H
|
|
||||||
#define SOLID_NETWORKING_P_H
|
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include "networking.h"
|
|
||||||
|
|
||||||
class OrgKdeSolidNetworkingClientInterface;
|
|
||||||
|
|
||||||
namespace Solid
|
|
||||||
{
|
|
||||||
class NetworkingPrivate : public Networking::Notifier
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(uint Status READ status)
|
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.Solid.Networking.Client")
|
|
||||||
public:
|
|
||||||
NetworkingPrivate();
|
|
||||||
|
|
||||||
void shouldConnect() { Networking::Notifier::shouldConnect(); }
|
|
||||||
void shouldDisconnect() { Networking::Notifier::shouldDisconnect(); }
|
|
||||||
|
|
||||||
Networking::Status netStatus;
|
|
||||||
public Q_SLOTS:
|
|
||||||
uint status() const;
|
|
||||||
/**
|
|
||||||
* Called on DBus signal from the network status service
|
|
||||||
*/
|
|
||||||
void serviceStatusChanged(uint status);
|
|
||||||
/**
|
|
||||||
* Detects when kded restarts, and sets status to NoNetworks so that apps
|
|
||||||
* may proceed
|
|
||||||
*/
|
|
||||||
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize();
|
|
||||||
OrgKdeSolidNetworkingClientInterface* iface;
|
|
||||||
};
|
|
||||||
} // namespace Solid
|
|
||||||
#endif
|
|
|
@ -1,12 +0,0 @@
|
||||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
|
||||||
<node>
|
|
||||||
<interface name="org.kde.Solid.Networking.Client">
|
|
||||||
<property name="Status" type="u" access="read"/>
|
|
||||||
<signal name="statusChanged">
|
|
||||||
<arg type="u" direction="out"/>
|
|
||||||
</signal>
|
|
||||||
<method name="status">
|
|
||||||
<arg type="u" direction="out"/>
|
|
||||||
</method>
|
|
||||||
</interface>
|
|
||||||
</node>
|
|
Loading…
Add table
Reference in a new issue