kpilot Library API Documentation

MultiDB-factory.cc

00001 /* MultiDB-factory.cc                      KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 ** Copyright (C) 2002 by Reinhold Kainhofer
00005 **
00006 ** This file defines the factory for the MultiDB-conduit plugin.
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., 59 Temple Place, Suite 330, Boston,
00023 ** MA 02111-1307, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 #include "options.h"
00031 
00032 #include <kinstance.h>
00033 #include <kaboutdata.h>
00034 #include "kpilotlink.h"
00035 #include "MultiDB-factory.h"
00036 #include "MultiDB-factory.moc"
00037 
00038 
00039 KPilotSyncType::KPilotSyncType(){
00040         ShortName="";
00041         LongName="";
00042         id=st_ask;
00043         flags=0;
00044 }
00045 KPilotSyncType::KPilotSyncType(QString sn="", QString ln="", int i=st_ask, int flg=0) {
00046         ShortName=sn;
00047         LongName=ln;
00048         id=i;
00049         flags=flg;
00050 }
00051 KPilotSyncType::KPilotSyncType(KPilotSyncType*tp) {
00052         ShortName=tp->ShortName;
00053         LongName=tp->LongName;
00054         id=tp->id;
00055         flags=tp->flags;
00056 }
00057 
00058 KAboutData *MultiDBConduitFactory::fAbout = 0L;
00059 SyncTypeList_t *MultiDBConduitFactory::synctypes = 0L;
00060 QString MultiDBConduitFactory::conflictResolution = "ConflictResolution";
00061 QString MultiDBConduitFactory::archive = "ArchiveDeletedEntries";
00062 QString MultiDBConduitFactory::fullSyncOnPCChange = "FullSyncOnPCChange";
00063 
00064 MultiDBConduitFactory::MultiDBConduitFactory(QObject *p, const char *n) :
00065         KLibFactory(p,n) {
00066         FUNCTIONSETUP;
00067 
00068         fInstance = new KInstance(n);
00069         synctypes=new SyncTypeList_t();
00070         synctypes->setAutoDelete( TRUE ); // the list owns the objects
00071 
00072 /*      fAbout = new KAboutData(n,
00073                 I18N_NOOP("MultiDB Conduit for KPilot"),
00074                 KPILOT_VERSION,
00075                 I18N_NOOP("Configures the MultiDB Conduit for KPilot"),
00076                 KAboutData::License_GPL,
00077                 "(C) 2002, Reinhold F. Kainhofer");
00078         fAbout->addAuthor("Dan Pilone", I18N_NOOP("Original Author of KPilot and the VCal conduit"));
00079         fAbout->addAuthor("Preston Brown", I18N_NOOP("Original Author of the VCal conduit"));
00080         fAbout->addAuthor("Herwin-Jan Steehouwer", I18N_NOOP("Original Author of the VCal conduit"));
00081         fAbout->addAuthor("Adriaan de Groot", I18N_NOOP("Maintainer or KPilot"), "groot@kde.org", "http://www.cs.kun.nl/~adridg/kpilot");
00082         fAbout->addAuthor("Reinhold Kainhofer", I18N_NOOP("Original author and maintainer of this conduit"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com");*/
00083 }
00084 
00085 void MultiDBConduitFactory::buildConduitInfo() {
00086         synctypes->clear();
00087 //      synctypes->append( new KPilotSyncType(i18n("ask"), i18n("Ask for an action"), st_ask, 0) );
00088         synctypes->append( new KPilotSyncType(i18n("ignore"), i18n("Completely ignore database"), st_ignore, 0) );
00089         synctypes->append( new KPilotSyncType(i18n("backup"), i18n("Only do a backup"), st_backup, 0) );
00090         synctypes->append( new KPilotSyncType(i18n("pdb"), i18n("Save as .pdb database"), st_pdb, SYNC_NEEDSFILE) );
00091         customConduitInfo();    
00092 }
00093 
00094 
00095 MultiDBConduitFactory::~MultiDBConduitFactory() {
00096         FUNCTIONSETUP;
00097 
00098         KPILOT_DELETE(fInstance);
00099         KPILOT_DELETE(fAbout);
00100 }
00101 
00102 /* virtual */ QObject *MultiDBConduitFactory::createObject( QObject *p,
00103         const char *n, const char *c, const QStringList &a) {
00104         FUNCTIONSETUP;
00105 
00106                 #ifdef DEBUG
00107         DEBUGCONDUIT << fname << ": Creating object of class "  << c << endl;
00108                 #endif
00109 
00110         if (!synctypes || synctypes->isEmpty()) { // synctypes not yet initialized
00111                 synctypes=new SyncTypeList_t();
00112                 buildConduitInfo();
00113         }
00114 
00115 
00116 
00117         if (qstrcmp(c,"ConduitConfig")==0) {
00118                 QWidget *w = dynamic_cast<QWidget *>(p);
00119 
00120                 if (w) {
00121                         return createSetupWidget(w,n,a);
00122                 } else {
00123                                 #ifdef DEBUG
00124                         DEBUGCONDUIT << fname << ": Couldn't cast parent to widget." << endl;
00125                                 #endif
00126                         return 0L;
00127                 }
00128         }
00129 
00130         if (qstrcmp(c,"SyncAction")==0) {
00131                 KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
00132 
00133                 if (d) {
00134                         return createConduit(d,n,a);
00135                 } else {
00136                         kdError() << k_funcinfo
00137                                 << ": Couldn't cast to KPilotDeviceLink."
00138                                 << endl;
00139                 }
00140         }
00141 
00142         return 0L;
00143 }
00144 
00145 // $Log: MultiDB-factory.cc,v $
00146 // Revision 1.2.4.1  2003/03/12 23:31:10  adridg
00147 // CVS_SILENT: FSF address change
00148 //
00149 // Revision 1.2  2002/07/05 00:15:22  kainhofe
00150 // Added KPilotDeviceLink::tickle(), Changelog update, compile fixes
00151 //
00152 // Revision 1.1  2002/04/07 12:09:42  kainhofe
00153 // Initial checkin of the conduit. The gui works mostly, but syncing crashes KPilot...
00154 //
00155 // Revision 1.2  2002/04/07 11:56:19  reinhold
00156 // Last version before moving to KDE CVS
00157 //
00158 // Revision 1.1  2002/04/07 01:03:52  reinhold
00159 // the list of possible actions is now created dynamically
00160 //
00161 // Revision 1.6  2002/04/05 21:17:00  reinhold
00162 // *** empty log message ***
00163 //
00164 // Revision 1.5  2002/03/28 13:47:53  reinhold
00165 // Added the list of synctypes, aboutbox is now directly passed on to the setup dlg (instead of being a static var)
00166 //
00167 // Revision 1.3  2002/03/15 20:43:17  reinhold
00168 // Fixed the crash on loading (member function not defined)...
00169 //
00170 // Revision 1.2  2002/03/10 23:58:32  reinhold
00171 // Made the conduit compile...
00172 //
00173 // Revision 1.1.1.1  2002/03/09 15:38:45  reinhold
00174 // Initial checin of the  project manager / List manager conduit.
00175 //
00176 //
00177 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:44 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001