kpilot

mal-factory.cc

Go to the documentation of this file.
00001 /* Time-factory.cc                      KPilot
00002 **
00003 ** Copyright (C) 2002 by Reinhold Kainhofer
00004 **
00005 ** This file defines the factory for the MAL-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 ** Specific permission is granted for this code to be linked to libmal
00026 ** (this is necessary because the libmal license is not GPL-compatible).
00027 */
00028  
00029 /*
00030 ** Bug reports and questions can be sent to kde-pim@kde.org
00031 */
00032 
00033 #include "options.h" 
00034 
00035 #include <kapplication.h>
00036 #include <kinstance.h>
00037 #include <kaboutdata.h>
00038 
00039 #include <time.h> // Needed by pilot-link include
00040 #include "mal-conduit.h"
00041 #include "mal-setup.h"
00042 
00043 #include "mal-factory.moc"
00044 
00045 
00046 extern "C"
00047 {
00048 
00049 void *init_conduit_mal()
00050 {
00051     return new MALConduitFactory;
00052 }
00053 
00054 unsigned long version_conduit_mal = Pilot::PLUGIN_API;
00055 
00056 }
00057 
00058 
00059 // A number of static variables
00060 //
00061 KAboutData *MALConduitFactory::fAbout = 0L;
00062 
00063 MALConduitFactory::MALConduitFactory(QObject *p, const char *n) :
00064     KLibFactory(p,n)
00065 {
00066     FUNCTIONSETUP;
00067 
00068     fInstance = new KInstance("MALconduit");
00069     fAbout = new KAboutData("MALconduit",
00070         I18N_NOOP("MAL Synchronization Conduit for KPilot"),
00071         KPILOT_VERSION,
00072         I18N_NOOP("Synchronizes the content from MAL Servers like AvantGo to the Handheld"),
00073         KAboutData::License_GPL,
00074         "(C) 2002, Reinhold Kainhofer");
00075     fAbout->addAuthor("Reinhold Kainhofer",
00076         I18N_NOOP("Primary Author"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com/");
00077     fAbout->addCredit("Jason Day",
00078         I18N_NOOP("Author of libmal and the JPilot AvantGo conduit"), "jasonday@worldnet.att.net");
00079     fAbout->addCredit("Tom Whittaker",
00080         I18N_NOOP("Author of syncmal"), "tom@tomw.org", "http://www.tomw.org/");
00081     fAbout->addCredit("AvantGo, Inc.",
00082         I18N_NOOP("Authors of the malsync library (c) 1997-1999"), "", "http://www.avantgo.com/");
00083 }
00084 
00085 MALConduitFactory::~MALConduitFactory()
00086 {
00087     FUNCTIONSETUP;
00088 
00089     KPILOT_DELETE(fInstance);
00090     KPILOT_DELETE(fAbout);
00091 }
00092 
00093 /* virtual */ QObject *MALConduitFactory::createObject( QObject *p,
00094     const char *n,
00095     const char *c,
00096     const QStringList &a)
00097 {
00098     FUNCTIONSETUP;
00099 
00100 #ifdef DEBUG
00101     DEBUGKPILOT << fname
00102         << ": Creating object of class "
00103         << c
00104         << endl;
00105 #endif
00106 
00107     if (qstrcmp(c,"ConduitConfigBase")==0)
00108     {
00109         QWidget *w = dynamic_cast<QWidget *>(p);
00110 
00111         if (w)
00112         {
00113             return new MALWidgetSetup(w,n);
00114         }
00115         else 
00116         {
00117             WARNINGKPILOT
00118                 << "Couldn't cast parent to widget."
00119                 << endl;
00120             return 0L;
00121         }
00122     }
00123 
00124     if (qstrcmp(c,"SyncAction")==0)
00125     { 
00126         KPilotLink *d = dynamic_cast<KPilotLink *>(p);
00127 
00128         if (d)
00129         {
00130             return new MALConduit(d,n,a);
00131         }
00132         else
00133         {
00134             WARNINGKPILOT
00135                 << "Couldn't cast parent to KPilotLink"
00136                 << endl;
00137             return 0L;
00138         }
00139     }
00140 
00141     return 0L;
00142 }
00143