/*************************************************************************** * Copyright (C) 2006 by Michael Kaufmann * * michael@enlighter.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "kovpninterface.h" kovpnInterface * kovpnInterface::self( ) { static kovpnInterface * mSelf = NULL; if ( ! mSelf ) { mSelf = new kovpnInterface(); } return mSelf; } kovpnInterface::kovpnInterface() : dcopInterface( ) { setObjId( "kovpnInterface" ); } kovpnInterface::~kovpnInterface() {} void kovpnInterface::reg( openVPNManager * manager ) { managerList.insert( manager->id(), manager ); } void kovpnInterface::dereg( openVPNManager * manager ) { managerList.remove( manager->id() ); } QCStringList kovpnInterface::connections( ) { QCStringList list; for ( QMap::iterator it = managerList.begin(); it != managerList.end(); it++ ) { list.append( it.data() ->id().utf8() ); } return list; } QCString kovpnInterface::status( const QString & id ) { if ( managerList.contains( id ) ) { switch ( managerList[ id ] ->status().state ) { case openVPNManager::EXITING: return QCString( "EXITING" ); break; case openVPNManager::DISCONNECTED: return QCString( "DISCONNECTED" ); break; case openVPNManager::CONNECTING: return QCString( "CONNECTING" ); break; case openVPNManager::WAIT: return QCString( "WAIT" ); break; case openVPNManager::AUTH: return QCString( "AUTH" ); break; case openVPNManager::GET_CONFIG: return QCString( "GET_CONFIG" ); break; case openVPNManager::ASSIGN_IP: return QCString( "ASSIGN_IP" ); break; case openVPNManager::ADD_ROUTES: return QCString( "ADD_ROUTES" ); break; case openVPNManager::RECONNECTING: return QCString( "RECONNECTING" ); break; case openVPNManager::CONNECTED: return QCString( "CONNECTED" ); break; case openVPNManager::FAILED: return QCString( "FAILED" ); break; case openVPNManager::UNKNOWN: default: return QCString( "UNKNOWN" ); break; } } else { return QCString(); } } ASYNC kovpnInterface::connect( const QString & id ) { if ( managerList.contains( id ) ) { managerList[ id ] ->connect(); } } ASYNC kovpnInterface::disconnect( const QString & id ) { if ( managerList.contains( id ) ) { managerList[ id ] ->disconnect(); } }