kpilot Library API Documentation

null-conduit.cc

00001 /* null-conduit.cc                      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., 59 Temple Place, Suite 330, Boston,
00026 ** MA 02111-1307, 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 // Something to allow us to check what revision
00037 // the modules are that make up a binary distribution.
00038 //
00039 //
00040 static const char *null_conduit_id=
00041         "$Id: null-conduit.cc,v 1.28.4.4 2003/03/12 23:31:11 adridg Exp $";
00042 
00043 // Only include what we really need:
00044 // First UNIX system stuff, then std C++,
00045 // then Qt, then KDE, then local includes.
00046 //
00047 //
00048 #include <time.h>
00049 
00050 #include <kconfig.h>
00051 #include <kdebug.h>
00052 
00053 #include "pilotSerialDatabase.h"
00054 #include "null-factory.h"
00055 #include "null-conduit.h"
00056 
00057 
00058 // A conduit that does nothing has a very
00059 // simple constructor and destructor.
00060 //
00061 //
00062 NullConduit::NullConduit(KPilotDeviceLink *d,
00063         const char *n,
00064         const QStringList &l) :
00065         ConduitAction(d,n,l),
00066         fDatabase(0L)
00067 {
00068         FUNCTIONSETUP;
00069 #ifdef DEBUG
00070         DEBUGCONDUIT<<null_conduit_id<<endl;
00071 #endif
00072 }
00073 
00074 NullConduit::~NullConduit()
00075 {
00076         FUNCTIONSETUP;
00077         KPILOT_DELETE(fDatabase);
00078 }
00079 
00080 /* virtual */ bool NullConduit::exec()
00081 {
00082         FUNCTIONSETUP;
00083         DEBUGCONDUIT<<null_conduit_id<<endl;
00084 
00085         if (!fConfig)
00086         {
00087                 kdWarning() << k_funcinfo
00088                         << ": No configuration set for NULL conduit."
00089                         << endl;
00090                 return false;
00091         }
00092 
00093         fConfig->setGroup(NullConduitFactory::group);
00094         
00095         bool r = fConfig->readBoolEntry(NullConduitFactory::failImmediately);
00096         if (r)
00097         {
00098 #ifdef DEBUG
00099                 DEBUGCONDUIT << fname << ": Config says to fail now." << endl;
00100 #endif
00101                 return false;
00102         }
00103 
00104         QString m=fConfig->readEntry(NullConduitFactory::message);
00105         addSyncLogEntry(m);
00106         emit logMessage(m);
00107 
00108 #ifdef DEBUG
00109         DEBUGCONDUIT << fname
00110                 << ": Message from null-conduit: "
00111                 << m
00112                 << endl;
00113 #endif
00114 
00115         emit syncDone(this);
00116         return true;
00117 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:14 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001