tdenetworkdevice.cpp
00001 /* This file is part of the TDE libraries 00002 Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net> 00003 (C) 2013 Golubev Alexander <fatzer2@gmail.com> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 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 #include "tdenetworkdevice.h" 00021 00022 // Network connection manager 00023 #include "tdenetworkconnections.h" 00024 00025 #include "config.h" 00026 00027 #ifdef WITH_NETWORK_MANAGER_BACKEND 00028 #include "network-manager.h" 00029 #endif // WITH_NETWORK_MANAGER_BACKEND 00030 00031 00032 TDENetworkDevice::TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) { 00033 m_rxbytes = -1; 00034 m_txbytes = -1; 00035 m_rxpackets = -1; 00036 m_txpackets = -1; 00037 m_connectionManager = NULL; 00038 } 00039 00040 TDENetworkDevice::~TDENetworkDevice() { 00041 if (m_connectionManager) { 00042 delete m_connectionManager; 00043 } 00044 } 00045 00046 TQString TDENetworkDevice::macAddress() { 00047 return m_macAddress; 00048 } 00049 00050 void TDENetworkDevice::internalSetMacAddress(TQString ma) { 00051 m_macAddress = ma; 00052 } 00053 00054 TQString TDENetworkDevice::state() { 00055 return m_state; 00056 } 00057 00058 void TDENetworkDevice::internalSetState(TQString st) { 00059 m_state = st; 00060 } 00061 00062 bool TDENetworkDevice::carrierPresent() { 00063 return m_carrier; 00064 } 00065 00066 void TDENetworkDevice::internalSetCarrierPresent(bool cp) { 00067 m_carrier = cp; 00068 } 00069 00070 bool TDENetworkDevice::dormant() { 00071 return m_dormant; 00072 } 00073 00074 void TDENetworkDevice::internalSetDormant(bool dm) { 00075 m_dormant = dm; 00076 } 00077 00078 TQString TDENetworkDevice::ipV4Address() { 00079 return m_ipV4Address; 00080 } 00081 00082 void TDENetworkDevice::internalSetIpV4Address(TQString ad) { 00083 m_ipV4Address = ad; 00084 } 00085 00086 TQString TDENetworkDevice::ipV6Address() { 00087 return m_ipV6Address; 00088 } 00089 00090 void TDENetworkDevice::internalSetIpV6Address(TQString ad) { 00091 m_ipV6Address = ad; 00092 } 00093 00094 TQString TDENetworkDevice::ipV4Netmask() { 00095 return m_ipV4Netmask; 00096 } 00097 00098 void TDENetworkDevice::internalSetIpV4Netmask(TQString nm) { 00099 m_ipV4Netmask = nm; 00100 } 00101 00102 TQString TDENetworkDevice::ipV6Netmask() { 00103 return m_ipV6Netmask; 00104 } 00105 00106 void TDENetworkDevice::internalSetIpV6Netmask(TQString nm) { 00107 m_ipV6Netmask = nm; 00108 } 00109 00110 TQString TDENetworkDevice::ipV4Broadcast() { 00111 return m_ipV4Broadcast; 00112 } 00113 00114 void TDENetworkDevice::internalSetIpV4Broadcast(TQString br) { 00115 m_ipV4Broadcast = br; 00116 } 00117 00118 TQString TDENetworkDevice::ipV6Broadcast() { 00119 return m_ipV6Broadcast; 00120 } 00121 00122 void TDENetworkDevice::internalSetIpV6Broadcast(TQString br) { 00123 m_ipV6Broadcast = br; 00124 } 00125 00126 TQString TDENetworkDevice::ipV4Destination() { 00127 return m_ipV4Destination; 00128 } 00129 00130 void TDENetworkDevice::internalSetIpV4Destination(TQString ds) { 00131 m_ipV4Destination = ds; 00132 } 00133 00134 TQString TDENetworkDevice::ipV6Destination() { 00135 return m_ipV6Destination; 00136 } 00137 00138 void TDENetworkDevice::internalSetIpV6Destination(TQString ds) { 00139 m_ipV6Destination = ds; 00140 } 00141 00142 double TDENetworkDevice::rxBytes() { 00143 return m_rxbytes; 00144 } 00145 00146 void TDENetworkDevice::internalSetRxBytes(double rx) { 00147 m_rxbytes = rx; 00148 } 00149 00150 double TDENetworkDevice::txBytes() { 00151 return m_txbytes; 00152 } 00153 00154 void TDENetworkDevice::internalSetTxBytes(double tx) { 00155 m_txbytes = tx; 00156 } 00157 00158 double TDENetworkDevice::rxPackets() { 00159 return m_rxpackets; 00160 } 00161 00162 void TDENetworkDevice::internalSetRxPackets(double rx) { 00163 m_rxpackets = rx; 00164 } 00165 00166 double TDENetworkDevice::txPackets() { 00167 return m_txpackets; 00168 } 00169 00170 void TDENetworkDevice::internalSetTxPackets(double tx) { 00171 m_txpackets = tx; 00172 } 00173 00174 TDENetworkConnectionManager* TDENetworkDevice::connectionManager() { 00175 #ifdef WITH_NETWORK_MANAGER_BACKEND 00176 if (!m_connectionManager) { 00177 m_connectionManager = new TDENetworkConnectionManager_BackendNM(this); 00178 } 00179 #endif // WITH_NETWORK_MANAGER_BACKEND 00180 00181 return m_connectionManager; 00182 } 00183 00184 void TDENetworkDevice::internalSetConnectionManager(TDENetworkConnectionManager* mgr) { 00185 m_connectionManager = mgr; 00186 } 00187 00188 #include "tdenetworkdevice.moc"