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   mStrategy = ResolveManually;
00033 }
00034 
00035 KonnectorPair::~KonnectorPair()
00036 {
00037   delete mManager;
00038   mManager = 0;
00039 
00040   delete mConfig;
00041   mConfig = 0;
00042 }
00043 
00044 QString KonnectorPair::uid() const
00045 {
00046   return mUid;
00047 }
00048 
00049 void KonnectorPair::setUid( const QString &uid )
00050 {
00051   mUid = uid;
00052 }
00053 
00054 QString KonnectorPair::name() const
00055 {
00056   return mName;
00057 }
00058 
00059 void KonnectorPair::setName( const QString &name )
00060 {
00061   mName = name;
00062 }
00063 
00064 int KonnectorPair::resolveStrategy() const
00065 {
00066   return mStrategy;
00067 }
00068 
00069 void KonnectorPair::setResolveStrategy( int strategy )
00070 {
00071   mStrategy = strategy;
00072 }
00073 
00074 void KonnectorPair::load()
00075 {
00076   if ( !mConfig )
00077     mConfig = new KConfig( configFile() );
00078 
00079   mManager->readConfig( mConfig );
00080   mManager->connectSignals();
00081 
00082   mConfig->setGroup( "General" );
00083   mName = mConfig->readEntry( "Name" );
00084   mStrategy = mConfig->readNumEntry( "ResolveStrategy", ResolveManually );
00085 }
00086 
00087 void KonnectorPair::save()
00088 {
00089   if ( !mConfig )
00090     mConfig = new KConfig( configFile() );
00091 
00092   mManager->writeConfig( mConfig );
00093 
00094   mConfig->setGroup( "General" );
00095   mConfig->writeEntry( "Name", mName );
00096   mConfig->writeEntry( "ResolveStrategy", mStrategy );
00097 }
00098 
00099 QString KonnectorPair::configFile() const
00100 {
00101   return locateLocal( "config", "multisynk/konnectorpair_" + mUid );
00102 }
00103 
00104 KonnectorManager* KonnectorPair::manager()
00105 {
00106   return mManager;
00107 }
KDE Home | KDE Accessibility Home | Description of Access Keys