kpilot
actions.cc
Go to the documentation of this file.00001 /* KPilot 00002 ** 00003 ** Copyright (C) 1998-2001 by Dan Pilone 00004 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00005 ** Copyright (C) 2006 Adriaan de Groot <groot@kde.org> 00006 ** 00007 */ 00008 00009 /* 00010 ** This program is free software; you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation; either version 2 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 ** GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program in a file called COPYING; if not, write to 00022 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00023 ** MA 02110-1301, USA. 00024 */ 00025 00026 /* 00027 ** Bug reports and questions can be sent to kde-pim@kde.org 00028 */ 00029 #include "options.h" 00030 00031 #include <qapplication.h> 00032 #include <qdir.h> 00033 #include <qfile.h> 00034 00035 #include <ksavefile.h> 00036 00037 #include "pilot.h" 00038 #include "pilotUser.h" 00039 00040 #include "actions.h" 00041 00042 00043 00044 WelcomeAction::WelcomeAction(KPilotLink *p) : 00045 SyncAction(p,"welcomeAction") 00046 { 00047 FUNCTIONSETUP; 00048 } 00049 00050 /* virtual */ bool WelcomeAction::exec() 00051 { 00052 FUNCTIONSETUP; 00053 00054 addSyncLogEntry(i18n("KPilot %1 HotSync starting...\n") 00055 .arg(QString::fromLatin1(KPILOT_VERSION))); 00056 emit logMessage( i18n("Using encoding %1 on the handheld.").arg(Pilot::codecName()) ); 00057 emit syncDone(this); 00058 return true; 00059 } 00060 00061 SorryAction::SorryAction(KPilotLink *p, const QString &s) : 00062 SyncAction(p,"sorryAction"), 00063 fMessage(s) 00064 { 00065 if (fMessage.isEmpty()) 00066 { 00067 fMessage = i18n("KPilot is busy and cannot process the " 00068 "HotSync right now."); 00069 } 00070 } 00071 00072 bool SorryAction::exec() 00073 { 00074 FUNCTIONSETUP; 00075 00076 addSyncLogEntry(fMessage); 00077 return delayDone(); 00078 } 00079 00080 CleanupAction::CleanupAction(KPilotLink *p) : SyncAction(p,"cleanupAction") 00081 { 00082 FUNCTIONSETUP; 00083 } 00084 00085 /* virtual */ bool CleanupAction::exec() 00086 { 00087 FUNCTIONSETUP; 00088 00089 if (deviceLink()) 00090 { 00091 deviceLink()->endSync( KPilotLink::UpdateUserInfo ); 00092 } 00093 emit syncDone(this); 00094 return true; 00095 } 00096 00097 00098 TestLink::TestLink(KPilotLink * p) : 00099 SyncAction(p, "testLink") 00100 { 00101 FUNCTIONSETUP; 00102 00103 } 00104 00105 /* virtual */ bool TestLink::exec() 00106 { 00107 FUNCTIONSETUP; 00108 00109 int i; 00110 int dbindex = 0; 00111 int count = 0; 00112 struct DBInfo db; 00113 00114 addSyncLogEntry(i18n("Testing.\n")); 00115 00116 while ((i = deviceLink()->getNextDatabase(dbindex,&db)) > 0) 00117 { 00118 count++; 00119 dbindex = db.index + 1; 00120 00121 DEBUGKPILOT << fname 00122 << ": Read database " << db.name 00123 << " with index " << db.index 00124 << endl; 00125 00126 // Let the Pilot User know what's happening 00127 openConduit(); 00128 // Let the KDE User know what's happening 00129 // Pretty sure all database names are in latin1. 00130 emit logMessage(i18n("Syncing database %1...") 00131 .arg(Pilot::fromPilot(db.name))); 00132 } 00133 00134 emit logMessage(i18n("HotSync finished.")); 00135 emit syncDone(this); 00136 return true; 00137 }