kpilot Library API Documentation

popmail-factory.cc

00001 /* popmail-factory.cc                      KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 **
00005 ** This file defines the factory for the popmail-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., 59 Temple Place, Suite 330, Boston,
00022 ** MA 02111-1307, 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 <qtabwidget.h>
00032 #include <qlineedit.h>
00033 
00034 #include <kconfig.h>
00035 #include <kinstance.h>
00036 #include <kaboutdata.h>
00037 
00038 #include "setupDialog.h"
00039 #include "popmail-conduit.h"
00040 #include "popmail-factory.moc"
00041 
00042 
00043 extern "C"
00044 {
00045 
00046 void *init_conduit_popmail()
00047 {
00048     return new PopMailConduitFactory;
00049 }
00050 
00051 }
00052 
00053 
00054 /* static */ const char * const PopMailConduitFactory::fGroup = "Popmail-conduit" ;
00055 const char * const PopMailConduitFactory::fSyncIncoming = "SyncIncoming" ;
00056 const char * const PopMailConduitFactory::fSyncOutgoing = "SyncOutgoing" ;
00057 
00058 KAboutData *PopMailConduitFactory::fAbout = 0L;
00059 PopMailConduitFactory::PopMailConduitFactory(QObject *p, const char *n) :
00060     KLibFactory(p,n)
00061 {
00062     FUNCTIONSETUP;
00063 
00064     fInstance = new KInstance("popmailconduit");
00065     fAbout = new KAboutData("popmailConduit",
00066         I18N_NOOP("Mail Conduit for KPilot"),
00067         KPILOT_VERSION,
00068         I18N_NOOP("Configures the Mail Conduit for KPilot"),
00069         KAboutData::License_GPL,
00070         "(C) 2001, Dan Pilone, Michael Kropfberger, Adriaan de Groot");
00071     fAbout->addAuthor("Adriaan de Groot",
00072         I18N_NOOP("Maintainer"),
00073         "groot@kde.org",
00074         "http://www.cs.kun.nl/~adridg/kpilot");
00075     fAbout->addAuthor("Dan Pilone",
00076         I18N_NOOP("Original Author"));
00077     fAbout->addCredit("Michael Kropfberger",
00078         I18N_NOOP("POP3 code"));
00079     fAbout->addCredit("Marko Gr&ouml;nroos",
00080         I18N_NOOP("SMTP support and redesign"),
00081         "magi@iki.fi",
00082         "http://www/iki.fi/magi/");
00083 }
00084 
00085 PopMailConduitFactory::~PopMailConduitFactory()
00086 {
00087     FUNCTIONSETUP;
00088 
00089     KPILOT_DELETE(fInstance);
00090     KPILOT_DELETE(fAbout);
00091 }
00092 
00093 /* virtual */ QObject *PopMailConduitFactory::createObject( QObject *p,
00094     const char *n,
00095     const char *c,
00096     const QStringList &a)
00097 {
00098     FUNCTIONSETUP;
00099 
00100 #ifdef DEBUG
00101     DEBUGCONDUIT << 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 PopMailWidgetConfig(w,n);
00114         }
00115         else
00116         {
00117 #ifdef DEBUG
00118             DEBUGCONDUIT << fname
00119                 << ": Couldn't cast parent to widget."
00120                 << endl;
00121 #endif
00122             return 0L;
00123         }
00124     }
00125     
00126     if (qstrcmp(c,"ConduitConfig")==0)
00127     {
00128         QWidget *w = dynamic_cast<QWidget *>(p);
00129 
00130         if (w)
00131         {
00132             return new ConduitConfigImplementation(w,n,a,
00133                 PopMailWidgetConfig::create);
00134         }
00135         else
00136         {
00137 #ifdef DEBUG
00138             DEBUGCONDUIT << fname
00139                 << ": Couldn't cast parent to widget."
00140                 << endl;
00141 #endif
00142             return 0L;
00143         }
00144     }
00145 
00146 
00147     if (qstrcmp(c,"SyncAction")==0)
00148     {
00149         KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
00150 
00151         if (d)
00152         {
00153             return new PopMailConduit(d,n,a);
00154         }
00155         else
00156         {
00157             kdError() << k_funcinfo
00158                 << ": Couldn't cast to KPilotDeviceLink"
00159                 << endl;
00160             return 0L;
00161         }
00162     }
00163     return 0L;
00164 }
00165 
00166 #if 0
00167 PopmailWidgetSetup::PopmailWidgetSetup(QWidget *w, const char *n,
00168     const QStringList & a) :
00169     ConduitConfig(w,n,a)
00170 {
00171     FUNCTIONSETUP;
00172 
00173     QTabWidget *t = new QTabWidget(widget());
00174     fSendPage = new PopMailSendPage(t);
00175     t->addTab(fSendPage,i18n("Send Mail"));
00176     fRecvPage = new PopMailReceivePage(t);
00177     t->addTab(fRecvPage,i18n("Retrieve Mail"));
00178 
00179     setTabWidget(t);
00180     addAboutPage(false,PopMailConduitFactory::about());
00181 
00182     t->adjustSize();
00183     fConduitName=i18n("POP/Mail");
00184 }
00185 
00186 PopmailWidgetSetup::~PopmailWidgetSetup()
00187 {
00188     FUNCTIONSETUP;
00189 }
00190 
00191 /* virtual */ void PopmailWidgetSetup::commitChanges()
00192 {
00193     FUNCTIONSETUP;
00194 
00195     if (!fConfig) return;
00196 
00197     KConfigGroupSaver s(fConfig,PopMailConduitFactory::group);
00198 
00199     fSendPage->commitChanges(*fConfig);
00200     fRecvPage->commitChanges(*fConfig);
00201 }
00202 
00203 /* virtual */ void PopmailWidgetSetup::readSettings()
00204 {
00205     FUNCTIONSETUP;
00206 
00207     if (!fConfig) return;
00208 
00209     KConfigGroupSaver s(fConfig,PopMailConduitFactory::group);
00210 
00211     fSendPage->readSettings(*fConfig);
00212     fRecvPage->readSettings(*fConfig);
00213 }
00214 
00215 #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