kpilot

knotes-factory.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 2001,2003 by Dan Pilone
00004 **
00005 ** This file defines the factory for the knotes-conduit plugin.
00006 */
00007 
00008 /*
00009 ** This program is free software; you can redistribute it and/or modify
00010 ** it under the terms of the GNU General Public License as published by
00011 ** the Free Software Foundation; either version 2 of the License, or
00012 ** (at your option) any later version.
00013 **
00014 ** This program is distributed in the hope that it will be useful,
00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 ** GNU General Public License for more details.
00018 **
00019 ** You should have received a copy of the GNU General Public License
00020 ** along with this program in a file called COPYING; if not, write to
00021 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022 ** MA 02110-1301, USA.
00023 */
00024 
00025 /*
00026 ** Bug reports and questions can be sent to kde-pim@kde.org
00027 */
00028 
00029 #include "options.h"
00030 
00031 #include <kapplication.h>
00032 #include <kinstance.h>
00033 #include <kaboutdata.h>
00034 
00035 #include <dcopclient.h>
00036 
00037 #include <time.h> // Needed by pilot-link include
00038 
00039 #include <pi-memo.h>
00040 
00041 #include "knotes-action.h"
00042 #include "knotes-setup.h"
00043 
00044 #include "knotes-factory.moc"
00045 
00046 
00047 extern "C"
00048 {
00049 
00050 void *init_conduit_knotes()
00051 {
00052     return new KNotesConduitFactory;
00053 }
00054 
00055 }
00056 
00057 
00058 /* static */ KAboutData *KNotesConduitFactory::fAbout = 0L;
00059 
00060 KNotesConduitFactory::KNotesConduitFactory(QObject *p, const char *n) :
00061     KLibFactory(p,n)
00062 {
00063     FUNCTIONSETUP;
00064 
00065     fInstance = new KInstance("knotesconduit");
00066     fAbout = new KAboutData("knotesconduit",
00067         I18N_NOOP("KNotes Conduit for KPilot"),
00068         KPILOT_VERSION,
00069         I18N_NOOP("Configures the KNotes Conduit for KPilot"),
00070         KAboutData::License_GPL,
00071         "(C) 2001, Adriaan de Groot");
00072     fAbout->addAuthor("Adriaan de Groot",
00073         I18N_NOOP("Primary Author"),
00074         "groot@kde.org",
00075         "http://www.cs.kun.nl/~adridg/kpilot");
00076     fAbout->addCredit("David Bishop",
00077         I18N_NOOP("UI"));
00078 }
00079 
00080 KNotesConduitFactory::~KNotesConduitFactory()
00081 {
00082     FUNCTIONSETUP;
00083 
00084     KPILOT_DELETE(fInstance);
00085     KPILOT_DELETE(fAbout);
00086 }
00087 
00088 /* virtual */ QObject *KNotesConduitFactory::createObject( QObject *p,
00089     const char *n,
00090     const char *c,
00091     const QStringList &a)
00092 {
00093     FUNCTIONSETUP;
00094 
00095 #ifdef DEBUG
00096     DEBUGKPILOT << fname
00097         << ": Creating object of class "
00098         << c
00099         << endl;
00100 #endif
00101 
00102     if (qstrcmp(c,"ConduitConfigBase")==0)
00103     {
00104         QWidget *w = dynamic_cast<QWidget *>(p);
00105         if (w)
00106         {
00107             return new KNotesConfigBase(w,0L);
00108         }
00109         else
00110         {
00111             return 0L;
00112         }
00113     }
00114     else
00115     if (qstrcmp(c,"SyncAction")==0)
00116     {
00117         KPilotLink *d = dynamic_cast<KPilotLink *>(p);
00118 
00119         if (d)
00120         {
00121             return new KNotesAction(d,n,a);
00122         }
00123         else
00124         {
00125             WARNINGKPILOT
00126                 << "Couldn't cast parent to KPilotDeviceLink"
00127                 << endl;
00128             return 0L;
00129         }
00130     }
00131 
00132     return 0L;
00133 }