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_libpopmailconduit()
00047 {
00048         return new PopmailConduitFactory;
00049 }
00050 
00051 } ;
00052 
00053 
00054 /* static */ const char * const PopmailConduitFactory::group = "Popmail-conduit" ;
00055 const char * const PopmailConduitFactory::syncIncoming = "SyncIncoming" ;
00056 const char * const PopmailConduitFactory::syncOutgoing = "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,"ConduitConfig")==0)
00108         {
00109                 QWidget *w = dynamic_cast<QWidget *>(p);
00110 
00111                 if (w)
00112                 {
00113                         return new PopmailWidgetSetup(w,n,a);
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 
00127         if (qstrcmp(c,"SyncAction")==0)
00128         {
00129                 KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
00130 
00131                 if (d)
00132                 {
00133                         return new PopMailConduit(d,n,a);
00134                 }
00135                 else
00136                 {
00137                         kdError() << k_funcinfo
00138                                 << ": Couldn't cast to KPilotDeviceLink"
00139                                 << endl;
00140                         return 0L;
00141                 }
00142         }
00143         return 0L;
00144 }
00145 
00146 PopmailWidgetSetup::PopmailWidgetSetup(QWidget *w, const char *n,
00147         const QStringList & a) :
00148         ConduitConfig(w,n,a)
00149 {
00150         FUNCTIONSETUP;
00151 
00152         QTabWidget *t = new QTabWidget(widget());
00153         fSendPage = new PopMailSendPage(t);
00154         t->addTab(fSendPage,i18n("Send Mail"));
00155         fRecvPage = new PopMailReceivePage(t);
00156         t->addTab(fRecvPage,i18n("Retrieve Mail"));
00157 
00158         setTabWidget(t);
00159         addAboutPage(false,PopmailConduitFactory::about());
00160 
00161         t->adjustSize();
00162 }
00163 
00164 PopmailWidgetSetup::~PopmailWidgetSetup()
00165 {
00166         FUNCTIONSETUP;
00167 }
00168 
00169 /* virtual */ void PopmailWidgetSetup::commitChanges()
00170 {
00171         FUNCTIONSETUP;
00172 
00173         if (!fConfig) return;
00174 
00175         KConfigGroupSaver s(fConfig,PopmailConduitFactory::group);
00176 
00177         fSendPage->commitChanges(*fConfig);
00178         fRecvPage->commitChanges(*fConfig);
00179 }
00180 
00181 /* virtual */ void PopmailWidgetSetup::readSettings()
00182 {
00183         FUNCTIONSETUP;
00184 
00185         if (!fConfig) return;
00186 
00187         KConfigGroupSaver s(fConfig,PopmailConduitFactory::group);
00188 
00189         fSendPage->readSettings(*fConfig);
00190         fRecvPage->readSettings(*fConfig);
00191 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:15 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001