Thanks to that UI doesn't display connections that cannot be used on specified interface.
BUG: 298974 Signed-off-by: Sebastian Krzyszkowiak <d...@dosowisko.net> --- .../service/networkinterfaceactivatableprovider.cpp | 19 +++++++++++++++---- libs/service/networkinterfaceactivatableprovider.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libs/service/networkinterfaceactivatableprovider.cpp b/libs/service/networkinterfaceactivatableprovider.cpp index 1d41432..fd33930 100644 --- a/libs/service/networkinterfaceactivatableprovider.cpp +++ b/libs/service/networkinterfaceactivatableprovider.cpp @@ -148,6 +148,19 @@ bool NetworkInterfaceActivatableProvider::matches(Knm::Connection::Type connType ); /* TODO: implement Bluetooth Cdma, Wimax, LTE */ } +QString NetworkInterfaceActivatableProvider::macByteArrayToString(QByteArray array) { + QString mac = ""; + for (int i=0; i<array.length(); i++) { + unsigned char num = array[i]; + if (num<16) mac.append("0"); + mac.append(QString::number(num, 16).toUpper()); + if (i<array.length()-1) { + mac.append(':'); + } + } + return mac; +} + bool NetworkInterfaceActivatableProvider::hardwareAddressMatches(Knm::Connection * connection, Solid::Control::NetworkInterfaceNm09 * iface) { bool matches = true; @@ -156,7 +169,6 @@ bool NetworkInterfaceActivatableProvider::hardwareAddressMatches(Knm::Connection // todo figure out how to convert from the struct ether_addr.ether_addr_octet contained in the // hardware address from system-provided connections. This probably also means the encoding // used in the connections we put on the bus is wrong. -#if 0 if (connection->type() == Knm::Connection::Wired) { Knm::WiredSetting * wiredSetting = dynamic_cast<Knm::WiredSetting *>(connection->setting(Knm::Setting::Wired)); Solid::Control::WiredNetworkInterfaceNm09 * wiredIface = dynamic_cast<Solid::Control::WiredNetworkInterfaceNm09 *>(iface); @@ -165,7 +177,7 @@ bool NetworkInterfaceActivatableProvider::hardwareAddressMatches(Knm::Connection // only settings which contain a valid macaddress are interesting if (!wiredSetting->macaddress().isEmpty()) { - matches = (QString(wiredSetting->macaddress()) == wiredIface->hardwareAddress()); + matches = (macByteArrayToString(wiredSetting->macaddress()) == wiredIface->hardwareAddress()); } } } else if (connection->type() == Knm::Connection::Wireless) { @@ -176,11 +188,10 @@ bool NetworkInterfaceActivatableProvider::hardwareAddressMatches(Knm::Connection // only settings which contain a valid macaddress are interesting if (!wirelessSetting->macaddress().isEmpty()) { - matches = (QString(wirelessSetting->macaddress()) == wirelessIface->hardwareAddress()); + matches = (macByteArrayToString(wirelessSetting->macaddress()) == wirelessIface->hardwareAddress()); } } } -#endif return matches; } diff --git a/libs/service/networkinterfaceactivatableprovider.h b/libs/service/networkinterfaceactivatableprovider.h index 9dc995f..d11a006 100644 --- a/libs/service/networkinterfaceactivatableprovider.h +++ b/libs/service/networkinterfaceactivatableprovider.h @@ -62,6 +62,7 @@ class KNM_EXPORT NetworkInterfaceActivatableProvider : public QObject, virtual p { Q_OBJECT public: + static QString macByteArrayToString(QByteArray array); static bool hardwareAddressMatches(Knm::Connection * connection, Solid::Control::NetworkInterfaceNm09 * iface); static bool matches(Knm::Connection::Type connType, Solid::Control::NetworkInterfaceNm09::Type ifaceType, Solid::Control::ModemNetworkInterfaceNm09::ModemCapabilities modemCaps = Solid::Control::ModemNetworkInterfaceNm09::None); -- 1.7.10.4 >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<