kpilot Library API Documentation

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 **
00007 ** This file defines the base class of all KPilot conduit plugins configuration
00008 ** dialogs. This is necessary so that we have a fixed API to talk to from
00009 ** inside KPilot.
00010 **
00011 ** The factories used by KPilot plugins are also documented here.
00012 */
00013 
00014 /*
00015 ** This program is free software; you can redistribute it and/or modify
00016 ** it under the terms of the GNU Lesser General Public License as published by
00017 ** the Free Software Foundation; either version 2.1 of the License, or
00018 ** (at your option) any later version.
00019 **
00020 ** This program is distributed in the hope that it will be useful,
00021 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00023 ** GNU Lesser General Public License for more details.
00024 **
00025 ** You should have received a copy of the GNU Lesser General Public License
00026 ** along with this program in a file called COPYING; if not, write to
00027 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00028 ** MA 02111-1307, USA.
00029 */
00030 
00031 /*
00032 ** Bug reports and questions can be sent to kde-pim@kde.org
00033 */
00034 
00035 #include <qstringlist.h>
00036 
00037 #include "uiDialog.h"
00038 #include "syncAction.h"
00039 
00040 class KConfig;
00041 class PilotDatabase;
00042 
00067 class ConduitConfigBase : public QObject
00068 {
00069 Q_OBJECT
00070 public:
00071     ConduitConfigBase(QWidget *parent=0L, const char *n=0L);
00072     virtual ~ConduitConfigBase();
00073 
00080     virtual bool isModified() const { return fModified; } ;
00081     QWidget *widget() const { return fWidget; } ;
00082 
00083 public:
00090     virtual void commit(KConfig *) = 0;
00091     virtual void load(KConfig *) = 0;
00101     virtual bool maybeSave(KConfig *);
00102 protected:
00107     virtual QString maybeSaveText() const;
00108 
00109 public:
00110     QString conduitName() const { return fConduitName; } ;
00111 
00112 protected slots:
00113     void modified();
00114 
00115 protected:
00116     bool fModified;
00117     QWidget *fWidget;
00118     QString fConduitName;
00119 
00120     void unmodified() { fModified=false; } ;
00121 } ;
00122 
00131 class ConduitConfig : public UIDialog
00132 {
00133 Q_OBJECT
00134 
00135 public:
00136     ConduitConfig(QWidget *parent=0L,
00137         const char *name=0L,
00138         const QStringList &args = QStringList()) KDE_DEPRECATED;
00139     virtual ~ConduitConfig();
00140 
00141     void setConfig(KConfig *c) { fConfig=c; } ;
00142 
00143     virtual void readSettings() = 0 ;
00144     /* virtual void commit() = 0 ; --- from UIDialog */
00145 
00146     // User-readable name of the conduit. Should match
00147     // the other conduitName() methods in other classes
00148     // in this file.
00149     QString conduitName() const { return fConduitName; } ;
00150 protected:
00151     KConfig *fConfig;
00152     QString fConduitName;
00153 } ;
00154 
00161 class ConduitConfigImplementation : public ConduitConfig
00162 {
00163 public:
00164     ConduitConfigImplementation(QWidget *,
00165         const char *,
00166         const QStringList &,
00167         ConduitConfigBase *(*f)(QWidget *, const char *)) KDE_DEPRECATED;
00168     virtual ~ConduitConfigImplementation();
00169 
00170     virtual void readSettings();
00171 
00172 protected:
00173     virtual void commitChanges();
00174 
00175 protected:
00176     ConduitConfigBase *fConfigWidget;
00177 } ;
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00196 class ConduitAction : public SyncAction
00197 {
00198 Q_OBJECT
00199 public:
00200     ConduitAction(KPilotDeviceLink *,
00201         const char *name=0L,
00202         const QStringList &args = QStringList());
00203     virtual ~ConduitAction();
00204 
00205     void setConfig(KConfig *c) { fConfig=c; } ;
00206 
00207     QString conduitName() const { return fConduitName; } ;
00208 
00209 protected:
00210     bool isTest() const { return fTest; } ;
00211     bool isBackup() const { return fBackup; } ;
00212     bool isLocal() const { return fLocal; } ;
00213     
00214     int getSyncDirection() const { return fSyncDirection; };
00215     eConflictResolution getConflictResolution() const 
00216         { return fConflictResolution; };
00217 
00223     bool isFullSync() const 
00224     { 
00225         return fFirstSync || 
00226             (fSyncDirection!=SyncAction::eFastSync && 
00227             fSyncDirection!=SyncAction::eHotSync);
00228     }
00229 
00237     bool isFirstSync() const {
00238         return fFirstSync ||
00239         (fSyncDirection==SyncAction::eCopyHHToPC) ||
00240         (fSyncDirection==SyncAction::eCopyPCToHH); };
00241 
00242     KConfig *fConfig;
00243     PilotDatabase *fDatabase,*fLocalDatabase;
00244 
00250     bool openDatabases(const QString &dbName, bool*retrieved=0L);
00251 
00252 private:
00253     bool fTest; // Do some kind of test run on the pilot
00254     bool fBackup;   // Do a backup of the database
00255     bool fLocal;    // Local test without a Pilot
00256 
00257     // Make these only protected so the conduit can change the variable
00258 protected:
00259     int fSyncDirection; // Stores fast, full, PCToHH or HHToPC as sync directions.
00260     eConflictResolution fConflictResolution;
00261     bool fFirstSync;
00262     QString fConduitName;
00263 
00264 private:
00273     bool openDatabases_(const QString &dbName, bool*retrieved=0L);
00274 
00283     bool openDatabases_(const QString &dbName,const QString &localPath);
00284 } ;
00285 
00286 class PluginUtility
00287 {
00288 public:
00289     static int findHandle(const QStringList &);
00290     static bool isModal(const QStringList &a);
00291 
00300     static bool isRunning(const QCString &appName);
00301 } ;
00302 
00350 #endif
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:49 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003