Add connection to device lookup routines

pull/16/head
Timothy Pearson 12 years ago
parent 50a9b042ee
commit 86febbf351

@ -3965,6 +3965,41 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
}
}
TQStringList TDENetworkConnectionManager_BackendNM::connectionPhysicalDeviceUUIDs(TQString uuid) {
if (deviceType() == TDENetworkDeviceType::BackendOnly) {
return TQStringList();
}
TQT_DBusObjectPath existingConnection;
TQT_DBusError error;
if (d->m_networkManagerProxy) {
TQT_DBusObjectPathList activeConnections = d->m_networkManagerProxy->getActiveConnections(error);
TQT_DBusObjectPathList::iterator it;
TQStringList ret;
for (it = activeConnections.begin(); it != activeConnections.end(); ++it) {
DBus::ActiveConnectionProxy activeConnection(NM_DBUS_SERVICE, (*it));
activeConnection.setConnection(TQT_DBusConnection::systemBus());
if (activeConnection.getUuid(error) == uuid) {
TQValueList<TQT_DBusObjectPath> deviceList = activeConnection.getDevices(error);
TQT_DBusObjectPathList::iterator it2;
for (it2 = deviceList.begin(); it2 != deviceList.end(); ++it2) {
DBus::DeviceProxy underlyingNetworkDeviceProxy(NM_DBUS_SERVICE, *it2);
underlyingNetworkDeviceProxy.setConnection(TQT_DBusConnection::systemBus());
TQString devUUID = underlyingNetworkDeviceProxy.getUdi(error);
if (devUUID != "") {
ret.append(devUUID);
}
}
}
}
return ret;
}
else {
PRINT_ERROR(TQString("invalid internal network-manager settings proxy object").arg(uuid));
return TQStringList();
}
}
TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManager_BackendNM::deactivateConnection(TQString uuid) {
TQT_DBusObjectPath existingConnection;
TQT_DBusError error;

@ -139,6 +139,7 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid);
virtual TDENetworkHWNeighborList* siteSurvey();
virtual TQStringList connectionPhysicalDeviceUUIDs(TQString uuid);
virtual bool networkingEnabled();
virtual bool wiFiHardwareEnabled();

@ -635,6 +635,27 @@ TDENetworkConnection* TDENetworkConnectionManager::findConnectionByUUID(TQString
return NULL;
}
TDENetworkDevice* TDENetworkConnectionManager::findDeviceByUUID(TQString uuid) {
TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
if (!hwdevices) return NULL;
TDEGenericHardwareList devices = hwdevices->listByDeviceClass(TDEGenericDeviceType::Network);
for (TDEGenericHardwareList::iterator it = devices.begin(); it != devices.end(); ++it)
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(*it);
if (dev) {
TDENetworkConnectionManager* deviceConnectionManager = dev->connectionManager();
if (deviceConnectionManager) {
if (deviceConnectionManager->deviceInformation().UUID == uuid) {
return dev;
}
}
}
}
return NULL;
}
void TDENetworkConnectionManager::clearTDENetworkConnectionList() {
TDENetworkConnection *connection;
for (connection = m_connectionList->first(); connection; connection = m_connectionList->next()) {
@ -724,6 +745,11 @@ TDENetworkHWNeighborList* TDEGlobalNetworkManager::siteSurvey() {
return m_internalConnectionManager->siteSurvey();
}
TQStringList TDEGlobalNetworkManager::connectionPhysicalDeviceUUIDs(TQString uuid) {
if (!m_internalConnectionManager) return TQStringList();
return m_internalConnectionManager->connectionPhysicalDeviceUUIDs(uuid);
}
bool TDEGlobalNetworkManager::networkingEnabled() {
if (!m_internalConnectionManager) return false;
return m_internalConnectionManager->networkingEnabled();
@ -759,6 +785,11 @@ TDENetworkConnection* TDEGlobalNetworkManager::findConnectionByUUID(TQString uui
return m_internalConnectionManager->findConnectionByUUID(uuid);
}
TDENetworkDevice* TDEGlobalNetworkManager::findDeviceByUUID(TQString uuid) {
if (!m_internalConnectionManager) return NULL;
return m_internalConnectionManager->findDeviceByUUID(uuid);
}
/*================================================================================================*/
/* End */
/*================================================================================================*/

@ -56,6 +56,8 @@
return a; \
}
class TDENetworkDevice;
typedef TQValueList<TQ_UINT8> TDENetworkByteList;
typedef TQValueList<TQHostAddress> TDENetworkAddressList;
typedef TQMap<TQString, TQString> TDENetworkSettingsMap;
@ -989,6 +991,13 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/
virtual TDENetworkHWNeighborList* siteSurvey() = 0;
/**
* @return a TQStringList containing the UUIDs of all physical devices used by this connection
* This function may return an empty list if the connection is inactive, this behaviour is
* dependend on the specific network backend in use.
*/
virtual TQStringList connectionPhysicalDeviceUUIDs(TQString uuid) = 0;
/**
* @return true if networking is enabled, false if not.
*/
@ -1055,6 +1064,14 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/
TDENetworkConnection* findConnectionByUUID(TQString uuid);
/**
* @return a pointer to a TDENetworkDevice object with the specified @param uuid,
* or a NULL pointer if no such connection exists.
*
* Note that the returned object is internally managed and must not be deleted!
*/
TDENetworkDevice* findDeviceByUUID(TQString uuid);
protected:
void clearTDENetworkConnectionList();
void clearTDENetworkHWNeighborList();
@ -1149,6 +1166,13 @@ class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject
*/
virtual TDENetworkHWNeighborList* siteSurvey();
/**
* @return a TQStringList containing the UUIDs of all physical devices used by this connection
* This function may return an empty list if the connection is inactive, this behaviour is
* dependend on the specific network backend in use.
*/
virtual TQStringList connectionPhysicalDeviceUUIDs(TQString uuid);
/**
* @return true if networking is enabled, false if not.
*/
@ -1215,6 +1239,14 @@ class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject
*/
TDENetworkConnection* findConnectionByUUID(TQString uuid);
/**
* @return a pointer to a TDENetworkDevice object with the specified @param uuid,
* or a NULL pointer if no such connection exists.
*
* Note that the returned object is internally managed and must not be deleted!
*/
TDENetworkDevice* findDeviceByUUID(TQString uuid);
private:
TDENetworkConnectionManager* m_internalConnectionManager;
};

Loading…
Cancel
Save