kitchensync

konnectorpair.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <kapplication.h>
00023 #include <kconfig.h>
00024 #include <kstandarddirs.h>
00025 
00026 #include "konnectorpair.h"
00027 
00028 KonnectorPair::KonnectorPair()
00029   : mManager( new KonnectorManager ), mConfig( 0 )
00030 {
00031   mUid = KApplication::randomString( 10 );
00032 }
00033 
00034 KonnectorPair::~KonnectorPair()
00035 {
00036   delete mManager;
00037   mManager = 0;
00038 
00039   delete mConfig;
00040   mConfig = 0;
00041 }
00042 
00043 QString KonnectorPair::uid() const
00044 {
00045   return mUid;
00046 }
00047 
00048 void KonnectorPair::setUid( const QString &uid )
00049 {
00050   mUid = uid;
00051 }
00052 
00053 QString KonnectorPair::name() const
00054 {
00055   return mName;
00056 }
00057 
00058 void KonnectorPair::setName( const QString &name )
00059 {
00060   mName = name;
00061 }
00062 
00063 int KonnectorPair::resolveStrategy() const
00064 {
00065   return mStrategy;
00066 }
00067 
00068 void KonnectorPair::setResolveStrategy( int strategy )
00069 {
00070   mStrategy = strategy;
00071 }
00072 
00073 void KonnectorPair::load()
00074 {
00075   if ( !mConfig )
00076     mConfig = new KConfig( configFile() );
00077 
00078   mManager->readConfig( mConfig );
00079   mManager->connectSignals();
00080 
00081   mConfig->setGroup( "General" );
00082   mName = mConfig->readEntry( "Name" );
00083   mStrategy = mConfig->readNumEntry( "ResolveStrategy", ResolveManually );
00084 }
00085 
00086 void KonnectorPair::save()
00087 {
00088   if ( !mConfig )
00089     mConfig = new KConfig( configFile() );
00090 
00091   mManager->writeConfig( mConfig );
00092 
00093   mConfig->setGroup( "General" );
00094   mConfig->writeEntry( "Name", mName );
00095   mConfig->writeEntry( "ResolveStrategy", mStrategy );
00096 }
00097 
00098 QString KonnectorPair::configFile() const
00099 {
00100   return locateLocal( "config", "multisynk/konnectorpair_" + mUid );
00101 }
00102 
00103 KonnectorManager* KonnectorPair::manager()
00104 {
00105   return mManager;
00106 }
KDE Home | KDE Accessibility Home | Description of Access Keys