kpilot/lib

plugin.h

00001 #ifndef _KPILOT_PLUGIN_H
00002 #define _KPILOT_PLUGIN_H
00003 /* plugin.h                             KPilot
00004 **
00005 ** Copyright (C) 2001 by Dan Pilone
00006 ** Copyright (C) 2002-2004 by Adriaan de Groot
00007 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00008 **
00009 ** This file defines the base class of all KPilot conduit plugins configuration
00010 ** dialogs. This is necessary so that we have a fixed API to talk to from
00011 ** inside KPilot.
00012 **
00013 ** The factories used by KPilot plugins are also documented here.
00014 */
00015 
00016 /*
00017 ** This program is free software; you can redistribute it and/or modify
00018 ** it under the terms of the GNU Lesser General Public License as published by
00019 ** the Free Software Foundation; either version 2.1 of the License, or
00020 ** (at your option) any later version.
00021 **
00022 ** This program is distributed in the hope that it will be useful,
00023 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00025 ** GNU Lesser General Public License for more details.
00026 **
00027 ** You should have received a copy of the GNU Lesser General Public License
00028 ** along with this program in a file called COPYING; if not, write to
00029 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00030 ** MA 02110-1301, USA.
00031 */
00032 
00033 /*
00034 ** Bug reports and questions can be sent to kde-pim@kde.org
00035 */
00036 
00037 #include <qstringlist.h>
00038 
00039 #include "syncAction.h"
00040 
00041 class PilotDatabase;
00042 class KLibrary;
00043 
00044 namespace Pilot
00045 {
00046     static const unsigned int PLUGIN_API = 20061118;
00047 }
00048 
00066 class KDE_EXPORT ConduitConfigBase : public QObject
00067 {
00068 Q_OBJECT
00069 public:
00070     ConduitConfigBase(QWidget *parent=0L, const char *n=0L);
00071     virtual ~ConduitConfigBase();
00072 
00079     virtual bool isModified() const { return fModified; } ;
00080     QWidget *widget() const { return fWidget; } ;
00081 
00082 public:
00089     virtual void commit() = 0;
00090     virtual void load() = 0;
00100     virtual bool maybeSave();
00101 protected:
00106     virtual QString maybeSaveText() const;
00107 
00108 public:
00109     QString conduitName() const { return fConduitName; } ;
00110 
00111 protected slots:
00112     void modified();
00113 signals:
00114     void changed(bool);
00115 
00116 protected:
00117     bool fModified;
00118     QWidget *fWidget;
00119     QString fConduitName;
00120 
00121     void unmodified() { fModified=false; } ;
00122 } ;
00123 
00124 
00125 
00126 
00137 class KDE_EXPORT ConduitAction : public SyncAction
00138 {
00139 Q_OBJECT
00140 public:
00141     ConduitAction(KPilotLink *,
00142         const char *name=0L,
00143         const QStringList &args = QStringList());
00144     virtual ~ConduitAction();
00145 
00146     QString conduitName() const { return fConduitName; } ;
00147 
00148 protected:
00150     const SyncMode &syncMode() const { return fSyncDirection; };
00152     ConflictResolution getConflictResolution() const
00153         { return fConflictResolution; };
00154 
00159     bool changeSync(SyncMode::Mode m);
00160 
00161     // Set the conflict resolution, except if the resolution
00162     // form is UseGlobalSetting, in which case nothing changes
00163     // (assumes then that the resolution form is already set
00164     // according to that global setting).
00165     //
00166     void setConflictResolution(ConflictResolution res)
00167     {
00168         if (SyncAction::eUseGlobalSetting != res)
00169             fConflictResolution=res;
00170     }
00171 
00177     bool isFullSync() const
00178     {
00179         return fFirstSync || fSyncDirection.isFullSync() ;
00180     }
00181 
00189     bool isFirstSync() const {
00190         return fFirstSync || fSyncDirection.isFirstSync() ;
00191     } ;
00192     void setFirstSync(bool first) { fFirstSync=first; } ;
00193 
00194     PilotDatabase *fDatabase;
00195     PilotDatabase *fLocalDatabase; // Guaranteed to be a PilotLocalDatabase
00196 
00209     bool openDatabases(const QString &dbName, bool*retrieved=0L);
00210 
00211 private:
00212     SyncMode fSyncDirection;
00213     ConflictResolution fConflictResolution;
00214 
00215     // Make these only protected so the conduit can change the variable
00216 protected:
00217     QString fConduitName;
00218 private:
00219     bool fFirstSync;
00220 } ;
00221 
00223 namespace PluginUtility
00224 {
00227     QString findArgument(const QStringList &a, const QString argname);
00228 
00237     bool isRunning(const QCString &appName);
00238 
00243     unsigned long pluginVersion(const KLibrary *);
00244     QString pluginVersionString(const KLibrary *);
00245 } ;
00246 
00311 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys