File indexing completed on 2024-04-21 14:56:10
0001 /* 0002 Copyright 2006-2007 Will Stephenson <wstephenson@kde.org> 0003 Copyright 2006-2007 Kevin Ottens <ervin@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Lesser General Public 0007 License as published by the Free Software Foundation; either 0008 version 2.1 of the License, or (at your option) version 3, or any 0009 later version accepted by the membership of KDE e.V. (or its 0010 successor approved by the membership of KDE e.V.), which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 */ 0021 0022 #ifndef SOLID_NETWORKING 0023 #define SOLID_NETWORKING 0024 0025 #include <QObject> 0026 0027 #include <kdelibs4support_export.h> 0028 0029 namespace Solid 0030 { 0031 /** 0032 * This namespace contains all the network-related high-level methods: 0033 * querying the underlying system for network availability, 0034 * being notified when network availability changes 0035 * (e.g. due to interfaces appearing or disappearing). 0036 * 0037 * It also allows application to specify the connection and disconnection policies 0038 * that it would like to use, for the network. 0039 * 0040 * @deprecated since 5.0, use QNetworkConfiguration instead 0041 */ 0042 namespace Networking 0043 { 0044 /** 0045 * Describes the state of the networking system 0046 */ 0047 enum Status { 0048 Unknown, /**< the networking system is not active or unable to report its status - proceed with caution */ 0049 Unconnected,/**< the system is not connected to any network */ 0050 Disconnecting, /**< the system is breaking the connection */ 0051 Connecting, /**< the system is not connected to any network */ 0052 Connected /**< the system is currently connected to a network */ 0053 }; 0054 0055 /** 0056 * This defines application policy in response to networking connect/disconnect events 0057 */ 0058 enum ManagementPolicy { 0059 Manual, /**< Manual - the app should only disconnect when the user does so manually */ 0060 OnNextStatusChange, /**< the app should connect or disconnect the next time the network changes status, thereafter Manual */ 0061 Managed /**< the app should connect or disconnect whenever the KConnectionManager reports a state change */ 0062 }; 0063 0064 /** 0065 * Get the current networking status 0066 * If the result is Unknown, the backend may be unconfigured or otherwise in a state where 0067 * it cannot report useful networking status @ref Solid::Networking::Status. 0068 */ 0069 KDELIBS4SUPPORT_DEPRECATED_EXPORT Status status(); 0070 0071 /** 0072 * Set a policy to manage the application's connect behaviour 0073 * @param policy the new connection policy 0074 */ 0075 KDELIBS4SUPPORT_DEPRECATED_EXPORT void setConnectPolicy(ManagementPolicy policy); 0076 0077 /** 0078 * Retrieve a policy managing the application's connect behaviour 0079 * @return the connection policy in use 0080 */ 0081 KDELIBS4SUPPORT_DEPRECATED_EXPORT ManagementPolicy connectPolicy(); 0082 0083 /** 0084 * Set a policy to manage the application's disconnect behaviour 0085 * @param policy the new disconnection policy 0086 */ 0087 KDELIBS4SUPPORT_DEPRECATED_EXPORT void setDisconnectPolicy(ManagementPolicy policy); 0088 0089 /** 0090 * Retrieve a policy managing the application's disconnect behaviour 0091 * @return the disconnection policy in use 0092 */ 0093 KDELIBS4SUPPORT_DEPRECATED_EXPORT ManagementPolicy disconnectPolicy(); 0094 0095 /** 0096 * This object emits signals, for use if your application requires notification 0097 * of changes to networking. 0098 */ 0099 class KDELIBS4SUPPORT_DEPRECATED_EXPORT Notifier : public QObject 0100 { 0101 Q_OBJECT 0102 Q_SIGNALS: 0103 /** 0104 * Signals that the network status has changed 0105 * @param status the new status of the network status service 0106 */ 0107 void statusChanged(Solid::Networking::Status status); 0108 /** 0109 * Signals that the system's network has become connected, so receivers 0110 * should connect their sockets, ioslaves etc. 0111 * 0112 * This signal is emitted according to the active connectPolicy. 0113 */ 0114 void shouldConnect(); 0115 /** 0116 * Signals that the system's network has become disconnected, 0117 * so receivers should adjust application state appropriately. 0118 * 0119 * This signal is emitted according to the active disconnectPolicy. 0120 */ 0121 void shouldDisconnect(); 0122 0123 protected: 0124 Notifier(); 0125 }; 0126 0127 KDELIBS4SUPPORT_DEPRECATED_EXPORT Notifier *notifier(); 0128 } 0129 0130 } // Solid 0131 0132 #endif