SolidModules
NetworkManager-wirednetwork.cpp
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 Copyright (C) 2008 Pino Toscano <pino@kde.org> 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 00019 */ 00020 00021 #include "NetworkManager-wirednetwork.h" 00022 00023 #include "NetworkManager-networkinterface_p.h" 00024 00025 #include <kdebug.h> 00026 00027 #include <QtDBus/QDBusReply> 00028 00029 class NMWiredNetworkPrivate : public NMNetworkInterfacePrivate 00030 { 00031 public: 00032 NMWiredNetworkPrivate(const QString & netPath); 00033 Q_DECLARE_PUBLIC(NMWiredNetwork) 00034 /* reimp */ void applyProperties(const NMDBusDeviceProperties & props); 00035 QString hwAddr; 00036 int rate; 00037 bool carrier; 00038 }; 00039 00040 NMWiredNetworkPrivate::NMWiredNetworkPrivate(const QString & netPath) 00041 : NMNetworkInterfacePrivate(netPath) 00042 , rate(0) 00043 , carrier(false) 00044 { 00045 } 00046 00047 void NMWiredNetworkPrivate::applyProperties(const NMDBusDeviceProperties & props) 00048 { 00049 NMNetworkInterfacePrivate::applyProperties(props); 00050 00051 hwAddr = props.hardwareAddress; 00052 carrier = props.linkActive; 00053 } 00054 00055 00056 NMWiredNetwork::NMWiredNetwork(const QString & networkPath) 00057 : NMNetworkInterface(*new NMWiredNetworkPrivate(networkPath)) 00058 { 00059 } 00060 00061 NMWiredNetwork::~NMWiredNetwork() 00062 { 00063 } 00064 00065 QString NMWiredNetwork::hardwareAddress() const 00066 { 00067 Q_D(const NMWiredNetwork); 00068 return d->hwAddr; 00069 } 00070 00071 int NMWiredNetwork::bitRate() const 00072 { 00073 Q_D(const NMWiredNetwork); 00074 return d->rate; 00075 } 00076 00077 bool NMWiredNetwork::carrier() const 00078 { 00079 Q_D(const NMWiredNetwork); 00080 return d->carrier; 00081 } 00082 00083 void NMWiredNetwork::setBitrate(int rate) 00084 { 00085 Q_D(NMWiredNetwork); 00086 if (d->rate == rate) 00087 return; 00088 00089 d->rate = rate; 00090 emit bitRateChanged(rate); 00091 } 00092 00093 void NMWiredNetwork::setCarrier(bool carrier) 00094 { 00095 Q_D(NMWiredNetwork); 00096 if (d->carrier == carrier) 00097 return; 00098 00099 d->carrier = carrier; 00100 emit carrierChanged(d->carrier); 00101 } 00102 00103 bool NMWiredNetwork::activateConnection(const QString & connectionUni, const QVariantMap & connectionParameters) 00104 { 00105 Q_D(NMWiredNetwork); 00106 Q_UNUSED(connectionUni) 00107 Q_UNUSED(connectionParameters) 00108 if (d->manager) 00109 { 00110 const QDBusReply<void> reply = d->manager->call(QDBus::NoBlock, "setActiveDevice", uni()); 00111 Q_UNUSED(reply) 00112 return true; 00113 } 00114 return false; 00115 } 00116 00117 bool NMWiredNetwork::deactivateConnection() 00118 { 00119 return false; 00120 } 00121 00122 #include "NetworkManager-wirednetwork.moc"