From af20635a2bb11eefabb627a2419644d3ac78831d Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 4 Sep 2010 17:53:12 +0000 Subject: Added networkstatus service from pim to core for use in other network enabled applications git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171617 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- networkstatus/networkstatuscommon.cpp | 73 ++++++++++++----------------------- 1 file changed, 25 insertions(+), 48 deletions(-) (limited to 'networkstatus/networkstatuscommon.cpp') diff --git a/networkstatus/networkstatuscommon.cpp b/networkstatus/networkstatuscommon.cpp index fbfd4b434..574862929 100644 --- a/networkstatus/networkstatuscommon.cpp +++ b/networkstatus/networkstatuscommon.cpp @@ -1,9 +1,12 @@ -/* This file is part of kdepim. - Copyright (C) 2005,2007 Will Stephenson +/* + This file is part of kdepim. + + Copyright (c) 2005 Will Stephenson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -11,66 +14,40 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License - along with this library. If not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this library - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. */ #include "networkstatuscommon.h" +#include TQDataStream & operator<< ( TQDataStream & s, const NetworkStatus::Properties p ) { - s << p.name; + kdDebug() << k_funcinfo << "status is: " << (int)p.status << endl; s << (int)p.status; + s << (int)p.onDemandPolicy; s << p.service; + s << ( p.internet ? 1 : 0 ); + s << p.netmasks; return s; } TQDataStream & operator>> ( TQDataStream & s, NetworkStatus::Properties &p ) { - int status; - s >> p.name; + int status, onDemandPolicy, internet; s >> status; - p.status = (NetworkStatus::Status)status; + kdDebug() << k_funcinfo << "status is: " << status << endl; + p.status = ( NetworkStatus::EnumStatus )status; + s >> onDemandPolicy; + p.onDemandPolicy = ( NetworkStatus::EnumOnDemandPolicy )onDemandPolicy; s >> p.service; + s >> internet; + if ( internet ) + p.internet = true; + else + p.internet = false; + s >> p.netmasks; + kdDebug() << k_funcinfo << "enum converted status is: " << p.status << endl; return s; } - -namespace NetworkStatus -{ - TQString toString( NetworkStatus::Status st ) - { - TQString str; - switch ( st ) { - case NetworkStatus::NoNetworks: - str = "NoNetworks"; - break; - case NetworkStatus::Unreachable: - str = "Unreachable"; - break; - case NetworkStatus::OfflineDisconnected: - str = "OfflineDisconnected"; - break; - case NetworkStatus::OfflineFailed: - str = "OfflineFailed"; - break; - case NetworkStatus::ShuttingDown: - str = "ShuttingDown"; - break; - case NetworkStatus::Offline: - str = "Offline"; - break; - case NetworkStatus::Establishing: - str = "Establishing"; - break; - case NetworkStatus::Online: - str = "Online"; - break; - } - return str; - } -} // namespace NetworkStatus -- cgit v1.2.1