kpilot Library API Documentation

mal-setup.cc

00001 /* MAL-setup.cc                      KPilot
00002 **
00003 ** Copyright (C) 2002 by Reinhold Kainhofer
00004 **
00005 ** This file defines the setup dialog 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., 59 Temple Place, Suite 330, Boston,
00022 ** MA 02111-1307, 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 <qtabwidget.h> 
00036 #include <qradiobutton.h>
00037 #include <qbuttongroup.h>
00038 #include <qlineedit.h>
00039 #include <qcheckbox.h>
00040 
00041 #include <kcombobox.h>
00042 #include <knuminput.h>
00043 #include <kpassdlg.h>
00044 
00045 #include <kapplication.h>
00046 #include <kconfig.h>
00047 
00048 #include "mal-setup_dialog.h"
00049 
00050 #include "mal-factory.h"
00051 #include "mal-setup.moc"
00052 
00053 
00054 MALWidgetSetup::MALWidgetSetup(QWidget *w, const char *n,
00055         const QStringList & a) :
00056         ConduitConfig(w,n,a)
00057 {
00058         FUNCTIONSETUP;
00059 
00060         fConfigWidget = new MALWidget(widget());
00061         setTabWidget(fConfigWidget->tabWidget);
00062         addAboutPage(false,MALConduitFactory::about());
00063 
00064         fConfigWidget->tabWidget->adjustSize();
00065         fConfigWidget->resize(fConfigWidget->tabWidget->size());
00066 }
00067 
00068 MALWidgetSetup::~MALWidgetSetup()
00069 {
00070         FUNCTIONSETUP;
00071 }
00072 
00073 /* virtual */ void MALWidgetSetup::commitChanges()
00074 {
00075         FUNCTIONSETUP;
00076 
00077         if (!fConfig) return;
00078 
00079         KConfigGroupSaver s(fConfig,MALConduitFactory::group());
00080         
00081         fConfig->writeEntry(MALConduitFactory::syncTime(),
00082                 fConfigWidget->syncTime->id(fConfigWidget->syncTime->selected()));
00083         
00084         // Proxy settings
00085         fConfig->writeEntry(MALConduitFactory::proxyType(),
00086                 fConfigWidget->proxyType->id(fConfigWidget->proxyType->selected()));
00087         fConfig->writeEntry(MALConduitFactory::proxyServer(), fConfigWidget->proxyServerName->currentText() );
00088 
00089         if (fConfigWidget->proxyCustomPortCheck->isChecked() ) 
00090         {
00091                 fConfig->writeEntry(MALConduitFactory::proxyPort(),     fConfigWidget->proxyCustomPort->value());
00092         }
00093         else 
00094         {
00095                 fConfig->writeEntry(MALConduitFactory::proxyPort(), 0);
00096         }
00097         fConfig->writeEntry(MALConduitFactory::proxyUser(),  fConfigWidget->proxyUserName->text() );
00098         fConfig->writeEntry(MALConduitFactory::proxyPassword(), fConfigWidget->proxyPassword->text() );
00099 
00100         // MAL Server settings (not yet possible!!!)
00101         fConfig->writeEntry(MALConduitFactory::malServer(), fConfigWidget->malServerName->currentText() );
00102         
00103         if (fConfigWidget->malCustomPortCheck->isChecked() ) 
00104         {
00105                 fConfig->writeEntry(MALConduitFactory::malPort(), fConfigWidget->malCustomPort->value());
00106         }
00107         else 
00108         {
00109                 fConfig->writeEntry(MALConduitFactory::malPort(), 0);
00110         }
00111         fConfig->writeEntry(MALConduitFactory::malUser(),  fConfigWidget->malUserName->text() );
00112         fConfig->writeEntry(MALConduitFactory::malPassword(), fConfigWidget->malPassword->text() );
00113 }
00114 
00115 
00116 
00117 /* virtual */ void MALWidgetSetup::readSettings()
00118 {
00119         FUNCTIONSETUP;
00120 
00121         if (!fConfig) return;
00122 
00123         KConfigGroupSaver s(fConfig,MALConduitFactory::group());
00124         
00125         fConfigWidget->syncTime->setButton(fConfig->readNumEntry(MALConduitFactory::syncTime(), 0));
00126         
00127         // Proxy settings
00128         fConfigWidget->proxyType->setButton(fConfig->readNumEntry(MALConduitFactory::proxyType(), 0));
00129         fConfigWidget->proxyServerName->setEditText(fConfig->readEntry(MALConduitFactory::proxyServer(), QString()));
00130         
00131         int proxyPortNr=fConfig->readNumEntry(MALConduitFactory::proxyPort(), 0);
00132         if (proxyPortNr>0 && proxyPortNr<65536) 
00133         {
00134                 fConfigWidget->proxyCustomPortCheck->setChecked(true);
00135                 fConfigWidget->proxyCustomPort->setEnabled(true);
00136                 fConfigWidget->proxyCustomPort->setValue(proxyPortNr);
00137         }
00138         fConfigWidget->proxyUserName->setText(fConfig->readEntry(MALConduitFactory::proxyUser(), QString()));
00139         fConfigWidget->proxyPassword->setText(fConfig->readEntry(MALConduitFactory::proxyPassword(), QString()));
00140 
00141         // MAL Server settings (not yet possible!!!)
00142         fConfigWidget->malServerName->setEditText(fConfig->readEntry(MALConduitFactory::malServer(), "sync.avantgo.com"));
00143         
00144         int malPortNr=fConfig->readNumEntry(MALConduitFactory::malPort(), 0);
00145         if (malPortNr>0 && malPortNr<65536) 
00146         {
00147                 fConfigWidget->malCustomPortCheck->setChecked(true);
00148                 fConfigWidget->malCustomPort->setEnabled(true);
00149                 fConfigWidget->malCustomPort->setValue(proxyPortNr);
00150         }
00151         fConfigWidget->malUserName->setText(fConfig->readEntry(MALConduitFactory::malUser(), QString()));
00152         fConfigWidget->malPassword->setText(fConfig->readEntry(MALConduitFactory::malPassword(), QString()));
00153 }
00154 
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:14 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001