File indexing completed on 2024-04-14 14:20:35
0001 /* 0002 Copyright (c) 2010 Sune Vuorela <sune@debian.org> 0003 0004 Permission is hereby granted, free of charge, to any person 0005 obtaining a copy of this software and associated documentation 0006 files (the "Software"), to deal in the Software without 0007 restriction, including without limitation the rights to use, 0008 copy, modify, merge, publish, distribute, sublicense, and/or sell 0009 copies of the Software, and to permit persons to whom the 0010 Software is furnished to do so, subject to the following 0011 conditions: 0012 0013 The above copyright notice and this permission notice shall be 0014 included in all copies or substantial portions of the Software. 0015 0016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0017 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 0018 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 0019 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 0020 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 0021 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0022 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 0023 OTHER DEALINGS IN THE SOFTWARE. 0024 0025 */ 0026 0027 #include "ntracknetworkstate.h" 0028 0029 #include "networkstatus.h" 0030 0031 #include <Solid/Networking> 0032 0033 #include <KDebug> 0034 0035 Solid::Networking::Status ntrackstate2solidstatus(QNTrackState state) 0036 { 0037 kDebug( 1222 ) << "ntrackstate2solidstatus changed status: " << state; 0038 switch(state) { 0039 case NTRACK_STATE_UNKNOWN: 0040 case NTRACK_STATE_UNSET: { 0041 return Solid::Networking::Unknown; 0042 } 0043 case NTRACK_STATE_ONLINE: { 0044 return Solid::Networking::Connected; 0045 } 0046 case NTRACK_STATE_BLOCKED: 0047 case NTRACK_STATE_OFFLINE: { 0048 return Solid::Networking::Unconnected; 0049 } 0050 } 0051 //FAILSAFE 0052 return Solid::Networking::Unknown; 0053 } 0054 0055 NtrackNetworkState::NtrackNetworkState( NetworkStatusModule* statusmodule ) : QObject(statusmodule),m_statusmodule(statusmodule) 0056 { 0057 m_statusmodule->registerNetwork("ntrack", ntrackstate2solidstatus(QNtrack::instance()->networkState()),"ntrack backend"); 0058 connect(QNtrack::instance(),SIGNAL(stateChanged(QNTrackState,QNTrackState)),this,SLOT(ntrackStateChangedSlot(QNTrackState,QNTrackState))); 0059 } 0060 0061 NtrackNetworkState::~NtrackNetworkState() 0062 { 0063 } 0064 0065 0066 0067 void NtrackNetworkState::ntrackStateChangedSlot(QNTrackState /*oldstate*/ , QNTrackState newstate ) 0068 { 0069 kDebug( 1222 ) << "ntrack changed status: " << newstate; 0070 m_statusmodule->setNetworkStatus("ntrack",ntrackstate2solidstatus(newstate)); 0071 } 0072 0073 #include "moc_ntracknetworkstate.cpp"