kpilot
initstate.cc
Go to the documentation of this file.00001 /* KPilot 00002 ** 00003 ** Copyright (C) 2006 by Bertjan Broeksema <b.broeksema@gmail.com> 00004 ** 00005 ** This file is the implementation of the InitState. 00006 */ 00007 00008 /* 00009 ** This program is free software; you can redistribute it and/or modify 00010 ** it under the terms of the GNU General Public License as published by 00011 ** the Free Software Foundation; either version 2 of the License, or 00012 ** (at your option) any later version. 00013 ** 00014 ** This program is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 ** GNU General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU General Public License 00020 ** along with this program in a file called COPYING; if not, write to 00021 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00022 ** MA 02110-1301, USA. 00023 */ 00024 00025 /* 00026 ** Bug reports and questions can be sent to kde-pim@kde.org 00027 */ 00028 00029 #include <options.h> 00030 #include <plugin.h> 00031 00032 #include "vcal-conduitbase.h" 00033 #include "initstate.h" 00034 #include "teststate.h" 00035 #include "pctohhstate.h" 00036 #include "hhtopcstate.h" 00037 00038 InitState::InitState() 00039 { 00040 fState = eInit; 00041 } 00042 00043 InitState::~InitState() 00044 { 00045 } 00046 00047 void InitState::startSync( ConduitAction *ca ) 00048 { 00049 FUNCTIONSETUP; 00050 00051 VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca); 00052 if( !vccb ) 00053 { 00054 return; 00055 } 00056 00057 DEBUGKPILOT << fname << ": Starting InitState." << endl; 00058 00059 vccb->addLogMessage( i18n( "Initializing conduit ..." ) ); 00060 vccb->preSync(); 00061 00062 if ( vccb->syncMode().isTest() ) 00063 { 00064 fNextState = new TestState(); 00065 } 00066 else 00067 { 00068 switch( vccb->syncMode().mode() ) 00069 { 00070 case ConduitAction::SyncMode::eCopyPCToHH: 00071 // TODO: Clear the palm and backup database??? Or just add the 00072 // new items ignore the Palm->PC side and leave the existing items 00073 // on the palm? 00074 fNextState = new PCToHHState(); 00075 break; 00076 case ConduitAction::SyncMode::eCopyHHToPC: 00077 // TODO: Clear the backup database and the calendar, update fP 00078 // or just add the palm items and leave the PC ones there???? 00079 fNextState = new HHToPCState(); 00080 break; 00081 default: 00082 fNextState = new HHToPCState(); 00083 break; 00084 } 00085 } 00086 00087 fStarted = true; 00088 vccb->setHasNextRecord( false ); 00089 } 00090 00091 void InitState::handleRecord( ConduitAction *vccb ) 00092 { 00093 FUNCTIONSETUP; 00094 Q_UNUSED(vccb); 00095 } 00096 00097 void InitState::finishSync( ConduitAction *ca ) 00098 { 00099 FUNCTIONSETUP; 00100 00101 VCalConduitBase *vccb = dynamic_cast<VCalConduitBase*>(ca); 00102 if( !vccb ) 00103 { 00104 return; 00105 } 00106 00107 DEBUGKPILOT << fname << ": Finished InitState." << endl; 00108 vccb->setState( fNextState ); 00109 }