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     fConduitName=i18n("MAL");
00067 }
00068 
00069 MALWidgetSetup::~MALWidgetSetup()
00070 {
00071     FUNCTIONSETUP;
00072 }
00073 
00074 /* virtual */ void MALWidgetSetup::commitChanges()
00075 {
00076     FUNCTIONSETUP;
00077 
00078     if (!fConfig) return;
00079 
00080     KConfigGroupSaver s(fConfig,MALConduitFactory::group());
00081     
00082     fConfig->writeEntry(MALConduitFactory::syncTime(),
00083         fConfigWidget->syncTime->id(fConfigWidget->syncTime->selected()));
00084     
00085     // Proxy settings
00086     fConfig->writeEntry(MALConduitFactory::proxyType(),
00087         fConfigWidget->proxyType->id(fConfigWidget->proxyType->selected()));
00088     fConfig->writeEntry(MALConduitFactory::proxyServer(), fConfigWidget->proxyServerName->currentText() );
00089 
00090     if (fConfigWidget->proxyCustomPortCheck->isChecked() ) 
00091     {
00092         fConfig->writeEntry(MALConduitFactory::proxyPort(),     fConfigWidget->proxyCustomPort->value());
00093     }
00094     else 
00095     {
00096         fConfig->writeEntry(MALConduitFactory::proxyPort(), 0);
00097     }
00098     fConfig->writeEntry(MALConduitFactory::proxyUser(),  fConfigWidget->proxyUserName->text() );
00099     fConfig->writeEntry(MALConduitFactory::proxyPassword(), fConfigWidget->proxyPassword->text() );
00100 
00101     // MAL Server settings (not yet possible!!!)
00102     fConfig->writeEntry(MALConduitFactory::malServer(), fConfigWidget->malServerName->currentText() );
00103     
00104     if (fConfigWidget->malCustomPortCheck->isChecked() ) 
00105     {
00106         fConfig->writeEntry(MALConduitFactory::malPort(), fConfigWidget->malCustomPort->value());
00107     }
00108     else 
00109     {
00110         fConfig->writeEntry(MALConduitFactory::malPort(), 0);
00111     }
00112     fConfig->writeEntry(MALConduitFactory::malUser(),  fConfigWidget->malUserName->text() );
00113     fConfig->writeEntry(MALConduitFactory::malPassword(), fConfigWidget->malPassword->text() );
00114 }
00115 
00116 
00117 
00118 /* virtual */ void MALWidgetSetup::readSettings()
00119 {
00120     FUNCTIONSETUP;
00121 
00122     if (!fConfig) return;
00123 
00124     KConfigGroupSaver s(fConfig,MALConduitFactory::group());
00125     
00126     fConfigWidget->syncTime->setButton(fConfig->readNumEntry(MALConduitFactory::syncTime(), 0));
00127     
00128     // Proxy settings
00129     fConfigWidget->proxyType->setButton(fConfig->readNumEntry(MALConduitFactory::proxyType(), 0));
00130     fConfigWidget->proxyServerName->setEditText(fConfig->readEntry(MALConduitFactory::proxyServer()));
00131     
00132     int proxyPortNr=fConfig->readNumEntry(MALConduitFactory::proxyPort(), 0);
00133     if (proxyPortNr>0 && proxyPortNr<65536) 
00134     {
00135         fConfigWidget->proxyCustomPortCheck->setChecked(true);
00136         fConfigWidget->proxyCustomPort->setEnabled(true);
00137         fConfigWidget->proxyCustomPort->setValue(proxyPortNr);
00138     }
00139     fConfigWidget->proxyUserName->setText(fConfig->readEntry(MALConduitFactory::proxyUser()));
00140     fConfigWidget->proxyPassword->setText(fConfig->readEntry(MALConduitFactory::proxyPassword()));
00141 
00142     // MAL Server settings (not yet possible!!!)
00143     fConfigWidget->malServerName->setEditText(fConfig->readEntry(MALConduitFactory::malServer(), "sync.avantgo.com"));
00144     
00145     int malPortNr=fConfig->readNumEntry(MALConduitFactory::malPort(), 0);
00146     if (malPortNr>0 && malPortNr<65536) 
00147     {
00148         fConfigWidget->malCustomPortCheck->setChecked(true);
00149         fConfigWidget->malCustomPort->setEnabled(true);
00150         fConfigWidget->malCustomPort->setValue(proxyPortNr);
00151     }
00152     fConfigWidget->malUserName->setText(fConfig->readEntry(MALConduitFactory::malUser()));
00153     fConfigWidget->malPassword->setText(fConfig->readEntry(MALConduitFactory::malPassword()));
00154 }
00155 
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:48 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003