kpilot
null-conduit.cc
Go to the documentation of this file.00001 /* KPilot 00002 ** 00003 ** Copyright (C) 2000-2001 by Adriaan de Groot 00004 ** 00005 ** This file is part of the NULL conduit, a conduit for KPilot that 00006 ** does nothing except add a log message to the Pilot's HotSync log. 00007 ** It is also intended as a programming example. 00008 ** 00009 ** This file does the actual conduit work. 00010 */ 00011 00012 /* 00013 ** This program is free software; you can redistribute it and/or modify 00014 ** it under the terms of the GNU Lesser General Public License as published by 00015 ** the Free Software Foundation; either version 2.1 of the License, or 00016 ** (at your option) any later version. 00017 ** 00018 ** This program is distributed in the hope that it will be useful, 00019 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 ** GNU Lesser General Public License for more details. 00022 ** 00023 ** You should have received a copy of the GNU Lesser General Public License 00024 ** along with this program in a file called COPYING; if not, write to 00025 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00026 ** MA 02110-1301, USA. 00027 */ 00028 00029 /* 00030 ** Bug reports and questions can be sent to kde-pim@kde.org 00031 */ 00032 00033 00034 #include "options.h" 00035 00036 // Only include what we really need: 00037 // First UNIX system stuff, then std C++, 00038 // then Qt, then KDE, then local includes. 00039 // 00040 // 00041 #include <time.h> 00042 00043 #include <kconfig.h> 00044 #include <kdebug.h> 00045 00046 #include "pilotSerialDatabase.h" 00047 #include "null-factory.h" 00048 #include "null-conduit.h" 00049 #include "nullSettings.h" 00050 00051 // A conduit that does nothing has a very 00052 // simple constructor and destructor. 00053 // 00054 // 00055 NullConduit::NullConduit(KPilotLink *d, 00056 const char *n, 00057 const QStringList &l) : 00058 ConduitAction(d,n,l), 00059 fDatabase(0L), 00060 fFailImmediately( l.contains( CSL1("--fail") )) 00061 { 00062 FUNCTIONSETUP; 00063 fConduitName=i18n("Null"); 00064 } 00065 00066 NullConduit::~NullConduit() 00067 { 00068 FUNCTIONSETUP; 00069 KPILOT_DELETE(fDatabase); 00070 } 00071 00072 /* virtual */ bool NullConduit::exec() 00073 { 00074 FUNCTIONSETUP; 00075 00076 DEBUGKPILOT << fname << ": Mode " << syncMode().name() << endl; 00077 00078 if ( fFailImmediately ) 00079 { 00080 DEBUGKPILOT << fname << ": Config says to fail now." << endl; 00081 emit logError(i18n("NULL conduit is programmed to fail.")); 00082 return false; 00083 } 00084 00085 QString m(NullConduitSettings::logMessage()); 00086 if (!m.isEmpty()) 00087 { 00088 addSyncLogEntry(m); 00089 } 00090 00091 DEBUGKPILOT << fname 00092 << ": Message from null-conduit: " 00093 << m 00094 << endl; 00095 00096 emit syncDone(this); 00097 return true; 00098 }