mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
solid: remove unused connect/disconnect policy API
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e4345f58ed
commit
2344fa495f
3 changed files with 66 additions and 136 deletions
|
@ -31,22 +31,20 @@ Q_GLOBAL_STATIC(Solid::NetworkingPrivate, globalNetworkManager)
|
|||
|
||||
Solid::NetworkingPrivate::NetworkingPrivate()
|
||||
: netStatus(Solid::Networking::Unknown),
|
||||
connectPolicy(Solid::Networking::Managed),
|
||||
disconnectPolicy(Solid::Networking::Managed),
|
||||
iface(0)
|
||||
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)));
|
||||
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::NetworkingPrivate::~NetworkingPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
Solid::Networking::Notifier::Notifier()
|
||||
{
|
||||
}
|
||||
|
@ -54,17 +52,19 @@ Solid::Networking::Notifier::Notifier()
|
|||
void Solid::NetworkingPrivate::initialize()
|
||||
{
|
||||
delete iface;
|
||||
iface = new OrgKdeSolidNetworkingClientInterface( "org.kde.kded",
|
||||
iface = new OrgKdeSolidNetworkingClientInterface(
|
||||
"org.kde.kded",
|
||||
"/modules/networkstatus",
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
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 = ( Solid::Networking::Status )reply.value();
|
||||
netStatus = static_cast<Solid::Networking::Status>(reply.value());
|
||||
} else {
|
||||
netStatus = Solid::Networking::Unknown;
|
||||
}
|
||||
|
@ -90,27 +90,17 @@ Solid::Networking::Notifier *Solid::Networking::notifier()
|
|||
void Solid::NetworkingPrivate::serviceStatusChanged(uint status)
|
||||
{
|
||||
// kDebug(921) ;
|
||||
netStatus = ( Solid::Networking::Status )status;
|
||||
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:
|
||||
if ( disconnectPolicy == Solid::Networking::Managed ) {
|
||||
emit globalNetworkManager()->shouldDisconnect();
|
||||
} else if ( disconnectPolicy == Solid::Networking::OnNextStatusChange ) {
|
||||
setDisconnectPolicy( Solid::Networking::Manual );
|
||||
emit globalNetworkManager()->shouldDisconnect();
|
||||
}
|
||||
break;
|
||||
case Solid::Networking::Connected:
|
||||
if ( disconnectPolicy == Solid::Networking::Managed ) {
|
||||
emit globalNetworkManager()->shouldConnect();
|
||||
} else if ( disconnectPolicy == Solid::Networking::OnNextStatusChange ) {
|
||||
setConnectPolicy( Solid::Networking::Manual );
|
||||
emit globalNetworkManager()->shouldConnect();
|
||||
}
|
||||
break;
|
||||
// default:
|
||||
// kDebug(921) << "Unrecognised status code!";
|
||||
|
@ -126,7 +116,6 @@ void Solid::NetworkingPrivate::serviceOwnerChanged( const QString & name, const
|
|||
// kded quit on us
|
||||
netStatus = Solid::Networking::Unknown;
|
||||
emit globalNetworkManager()->statusChanged(netStatus);
|
||||
|
||||
} else {
|
||||
// kded was replaced or started
|
||||
initialize();
|
||||
|
@ -135,25 +124,5 @@ void Solid::NetworkingPrivate::serviceOwnerChanged( const QString & name, const
|
|||
}
|
||||
}
|
||||
|
||||
Solid::Networking::ManagementPolicy Solid::Networking::connectPolicy()
|
||||
{
|
||||
return globalNetworkManager()->connectPolicy;
|
||||
}
|
||||
|
||||
void Solid::Networking::setConnectPolicy( Solid::Networking::ManagementPolicy policy )
|
||||
{
|
||||
globalNetworkManager()->connectPolicy = policy;
|
||||
}
|
||||
|
||||
Solid::Networking::ManagementPolicy Solid::Networking::disconnectPolicy()
|
||||
{
|
||||
return globalNetworkManager()->disconnectPolicy;
|
||||
}
|
||||
|
||||
void Solid::Networking::setDisconnectPolicy( Solid::Networking::ManagementPolicy policy )
|
||||
{
|
||||
globalNetworkManager()->disconnectPolicy = policy;
|
||||
}
|
||||
|
||||
#include "moc_networking_p.cpp"
|
||||
#include "moc_networking.cpp"
|
||||
|
|
|
@ -50,15 +50,6 @@ namespace Solid
|
|||
Connected /**< the system is currently connected to a network */
|
||||
};
|
||||
|
||||
/**
|
||||
* This defines application policy in response to networking connect/disconnect events
|
||||
*/
|
||||
enum ManagementPolicy {
|
||||
Manual, /**< Manual - the app should only disconnect when the user does so manually */
|
||||
OnNextStatusChange, /**< the app should connect or disconnect the next time the network changes status, thereafter Manual */
|
||||
Managed /**< the app should connect or disconnect whenever the KConnectionManager reports a state change */
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current networking status
|
||||
* If the result is Unknown, the backend may be unconfigured or otherwise in a state where
|
||||
|
@ -66,30 +57,6 @@ namespace Solid
|
|||
*/
|
||||
SOLID_EXPORT Status status();
|
||||
|
||||
/**
|
||||
* Set a policy to manage the application's connect behaviour
|
||||
* @param policy the new connection policy
|
||||
*/
|
||||
SOLID_EXPORT void setConnectPolicy( ManagementPolicy policy );
|
||||
|
||||
/**
|
||||
* Retrieve a policy managing the application's connect behaviour
|
||||
* @return the connection policy in use
|
||||
*/
|
||||
SOLID_EXPORT ManagementPolicy connectPolicy();
|
||||
|
||||
/**
|
||||
* Set a policy to manage the application's disconnect behaviour
|
||||
* @param policy the new disconnection policy
|
||||
*/
|
||||
SOLID_EXPORT void setDisconnectPolicy( ManagementPolicy policy );
|
||||
|
||||
/**
|
||||
* Retrieve a policy managing the application's disconnect behaviour
|
||||
* @return the disconnection policy in use
|
||||
*/
|
||||
SOLID_EXPORT ManagementPolicy disconnectPolicy();
|
||||
|
||||
/**
|
||||
* This object emits signals, for use if your application requires notification
|
||||
* of changes to networking.
|
||||
|
@ -106,15 +73,11 @@ namespace Solid
|
|||
/**
|
||||
* Signals that the system's network has become connected, so receivers
|
||||
* should connect their sockets, ioslaves etc.
|
||||
*
|
||||
* This signal is emitted according to the active connectPolicy.
|
||||
*/
|
||||
void shouldConnect();
|
||||
/**
|
||||
* Signals that the system's network has become disconnected,
|
||||
* so receivers should adjust application state appropriately.
|
||||
*
|
||||
* This signal is emitted according to the active disconnectPolicy.
|
||||
*/
|
||||
void shouldDisconnect();
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ class OrgKdeSolidNetworkingClientInterface;
|
|||
|
||||
namespace Solid
|
||||
{
|
||||
class ManagedSocketContainer;
|
||||
|
||||
class NetworkingPrivate : public Networking::Notifier
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -39,12 +37,11 @@ namespace Solid
|
|||
Q_CLASSINFO("D-Bus Interface", "org.kde.Solid.Networking.Client")
|
||||
public:
|
||||
NetworkingPrivate();
|
||||
~NetworkingPrivate();
|
||||
|
||||
void shouldConnect() { Networking::Notifier::shouldConnect(); }
|
||||
void shouldDisconnect() { Networking::Notifier::shouldDisconnect(); }
|
||||
|
||||
Networking::Status netStatus;
|
||||
Networking::ManagementPolicy connectPolicy;
|
||||
Networking::ManagementPolicy disconnectPolicy;
|
||||
public Q_SLOTS:
|
||||
uint status() const;
|
||||
/**
|
||||
|
@ -55,7 +52,8 @@ namespace Solid
|
|||
* Detects when kded restarts, and sets status to NoNetworks so that apps
|
||||
* may proceed
|
||||
*/
|
||||
void serviceOwnerChanged( const QString &, const QString &, const QString & );
|
||||
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
OrgKdeSolidNetworkingClientInterface* iface;
|
||||
|
|
Loading…
Add table
Reference in a new issue