kpilot

doc-factory.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 2002 by Reinhold Kainhofer
00004 **
00005 ** This file defines the factory for the doc-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 #include "doc-factory.moc"
00031 #include "doc-factory.h"
00032 
00033 #include <kinstance.h>
00034 #include <kaboutdata.h>
00035 #include <kpilotlink.h>
00036 
00037 #include "doc-conduit.h"
00038 #include "doc-setup.h"
00039 
00040 
00041 extern "C" {
00042     void *init_conduit_doc() {
00043         return new DOCConduitFactory;
00044     }
00045 }
00046 
00047 
00048 
00049 // A number of static variables
00050 KAboutData * DOCConduitFactory::fAbout = 0L;
00051 
00052 const char *DOCConduitFactory::dbDOCtype = "TEXt";
00053 const char *DOCConduitFactory::dbDOCcreator = "REAd";
00054 
00055 
00056 
00057 DOCConduitFactory::DOCConduitFactory(QObject * p, const char *n):
00058 KLibFactory(p, n)
00059 {
00060     FUNCTIONSETUP;
00061     fInstance = new KInstance("docconduit");
00062     fAbout =new KAboutData("docconduit",
00063         I18N_NOOP("Palm DOC Conduit for KPilot"), KPILOT_VERSION,
00064         I18N_NOOP("Configures the DOC Conduit for KPilot"),
00065         KAboutData::License_GPL, "(C) 2002, Reinhold Kainhofer");
00066 
00067     fAbout->addAuthor("Reinhold Kainhofer",
00068         I18N_NOOP("Maintainer"), "reinhold@kainhofer.com",
00069         "http://reinhold.kainhofer.com");
00070 }
00071 
00072 DOCConduitFactory::~DOCConduitFactory()
00073 {
00074     FUNCTIONSETUP;
00075     KPILOT_DELETE(fInstance);
00076     KPILOT_DELETE(fAbout);
00077 }
00078 
00079 
00080 /* virtual */ QObject * DOCConduitFactory::createObject(QObject * p,
00081     const char *n, const char *c, const QStringList & a)
00082 {
00083     FUNCTIONSETUP;
00084 
00085 #ifdef DEBUG
00086     DEBUGKPILOT << fname <<": Creating object of class " <<c <<endl;
00087 #endif
00088     if (qstrcmp(c, "ConduitConfigBase") == 0)
00089     {
00090         QWidget *w = dynamic_cast<QWidget *>(p);
00091         if (w)
00092         {
00093             return new DOCWidgetConfig(w,n);
00094         }
00095         else
00096         {
00097             WARNINGKPILOT << "Couldn't cast parent to widget." << endl;
00098             return 0L;
00099         }
00100     }
00101     if (qstrcmp(c, "SyncAction") == 0)
00102     {
00103         KPilotLink * d = dynamic_cast < KPilotLink * >(p);
00104         if (d)
00105         {
00106             return new DOCConduit(d, n, a);
00107         }
00108         else
00109         {
00110             WARNINGKPILOT << "Couldn't cast parent to KPilotLink" <<endl;
00111             return 0L;
00112         }
00113     }
00114     return 0L;
00115 }
00116