kpilot

setupDialog.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 1998-2001 Dan Pilone
00004 **
00005 ** This file is part of the popmail conduit, a conduit for KPilot that
00006 ** synchronises the Pilot's email application with the outside world,
00007 ** which currently means:
00008 **  -- sendmail or SMTP for outgoing mail
00009 **  -- POP or mbox for incoming mail
00010 */
00011 
00012 /*
00013 ** This program is free software; you can redistribute it and/or modify
00014 ** it under the terms of the GNU General Public License as published by
00015 ** the Free Software Foundation; either version 2 of the License, or
00016 ** (at your option) any later version.
00017 **
00018 ** This program is distributed in the hope that it will be useful,
00019 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021 ** GNU General Public License for more details.
00022 **
00023 ** You should have received a copy of the GNU General Public License
00024 ** along with this program in a file called COPYING; if not, write to
00025 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00026 ** MA 02110-1301, USA.
00027 */
00028 
00029 /*
00030 ** Bug reports and questions can be sent to kde-pim@kde.org
00031 */
00032 
00033 #include "options.h"
00034 
00035 
00036 #include <sys/types.h>
00037 #include <sys/stat.h>
00038 #include <stdlib.h>
00039 
00040 #include <kconfig.h>
00041 #include <kstandarddirs.h>
00042 #include <klineedit.h>
00043 #include <kaboutdata.h>
00044 
00045 #include <qcheckbox.h>
00046 #include <qdir.h>
00047 #include <qcombobox.h>
00048 
00049 #include "kfiledialog.h"
00050 
00051 #include <kurlrequester.h>
00052 
00053 
00054 #include "popmail-factory.h"
00055 #include "setup-dialog.h"
00056 #include "setupDialog.moc"
00057 #include "popmailSettings.h"
00058 
00059 
00060 
00061 PopMailWidgetConfig::PopMailWidgetConfig(QWidget *p,const char *n) :
00062     ConduitConfigBase(p,n),
00063     fConfigWidget(new PopMailWidget(p,"PopMailWidget"))
00064 {
00065     FUNCTIONSETUP;
00066     fConduitName = i18n("KMail");
00067     KAboutData *fAbout = new KAboutData("popmailConduit",
00068         I18N_NOOP("Mail Conduit for KPilot"),
00069         KPILOT_VERSION,
00070         I18N_NOOP("Configures the Mail Conduit for KPilot"),
00071         KAboutData::License_GPL,
00072         "(C) 2001, Dan Pilone, Michael Kropfberger, Adriaan de Groot");
00073     fAbout->addAuthor("Adriaan de Groot",
00074         I18N_NOOP("Maintainer"),
00075         "groot@kde.org",
00076         "http://www.kpilot.org/");
00077     fAbout->addAuthor("Dan Pilone",
00078         I18N_NOOP("Original Author"));
00079     fAbout->addCredit("Michael Kropfberger",
00080         I18N_NOOP("POP3 code"));
00081     fAbout->addCredit("Marko Gr&ouml;nroos",
00082         I18N_NOOP("SMTP support and redesign"),
00083         "magi@iki.fi",
00084         "http://www.iki.fi/magi/");
00085 
00086     ConduitConfigBase::addAboutPage(fConfigWidget->fTabWidget,fAbout);
00087     fWidget=fConfigWidget;
00088 
00089 #define CM(a,b) connect(fConfigWidget->a,b,this,SLOT(modified()));
00090     CM(fSendMode,SIGNAL(activated(int)));
00091     CM(fEmailFrom,SIGNAL(textChanged(const QString &)));
00092     CM(fSignature,SIGNAL(textChanged(const QString &)));
00093 #undef CM
00094 
00095     connect(fConfigWidget->fSendMode,SIGNAL(activated(int)),
00096         this,SLOT(toggleSendMode(int)));
00097 
00098 }
00099 
00100 void PopMailWidgetConfig::commit()
00101 {
00102     FUNCTIONSETUP;
00103 
00104     MailConduitSettings::self()->readConfig();
00105 #define WR(a,b,c) MailConduitSettings::set##a(fConfigWidget->b->c);
00106     WR(SyncOutgoing,fSendMode,currentItem());
00107     WR(EmailAddress,fEmailFrom,text());
00108     WR(Signature,fSignature,url());
00109 #undef WR
00110 
00111     MailConduitSettings::self()->writeConfig();
00112     unmodified();
00113 }
00114 
00115 void PopMailWidgetConfig::load()
00116 {
00117     FUNCTIONSETUP;
00118     MailConduitSettings::self()->config()->sync();
00119     MailConduitSettings::self()->readConfig();
00120 
00121 #define RD(a,b,c) fConfigWidget->a->b(MailConduitSettings::c())
00122     RD(fSendMode,setCurrentItem,syncOutgoing);
00123     RD(fEmailFrom,setText,emailAddress);
00124     RD(fSignature,setURL,signature);
00125 #undef RD
00126 
00127     toggleSendMode(fConfigWidget->fSendMode->currentItem());
00128 
00129     MailConduitSettings::self()->writeConfig();
00130     unmodified();
00131 }
00132 
00133 
00134 /* slot */ void PopMailWidgetConfig::toggleSendMode(int i)
00135 {
00136     FUNCTIONSETUP;
00137 #ifdef DEBUG
00138     DEBUGKPILOT << fname << ": Got mode " << i << endl;
00139 #endif
00140 
00141 #define E(a,b) fConfigWidget->a->setEnabled(b)
00142     switch(i)
00143     {
00144     case SendKMail :
00145         E(fEmailFrom,true);
00146         E(fSignature,true);
00147         break;
00148     case NoSend : /* FALLTHRU */
00149     default :
00150         E(fEmailFrom,false);
00151         E(fSignature,false);
00152         break;
00153     }
00154 #undef E
00155 }
00156 
00157 
00158