kitchensync

configguigcalendar.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2005 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (c) 2006 Eduardo Habkost <ehabkost@raisama.net>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00020     USA.
00021 */
00022 
00023 #include "configguigcalendar.h"
00024 
00025 #include <klocale.h>
00026 
00027 #include <qlayout.h>
00028 #include <qlabel.h>
00029 #include <qdom.h>
00030 #include <qlineedit.h>
00031 
00032 ConfigGuiGoogleCalendar::ConfigGuiGoogleCalendar( const QSync::Member &member, QWidget *parent )
00033   : ConfigGui( member, parent )
00034 {
00035   QBoxLayout *userLayout = new QHBoxLayout( topLayout() );
00036 
00037   QLabel *userLbl= new QLabel( i18n("Username:"), this );
00038   userLayout->addWidget(userLbl);
00039 
00040   mUsername = new QLineEdit(this);
00041   userLayout->addWidget(mUsername);
00042 
00043 
00044   QBoxLayout *passLayout = new QHBoxLayout( topLayout() );
00045 
00046   QLabel *passLbl = new QLabel( i18n("Password:"), this );
00047   passLayout->addWidget(passLbl);
00048 
00049   mPassword = new QLineEdit(this);
00050   mPassword->setEchoMode(QLineEdit::Password);
00051   passLayout->addWidget(mPassword);
00052 
00053   topLayout()->addWidget(new QLabel( i18n("Please notice that currently the password is stored as plain text in the plugin configuration file"), this ));
00054 
00055   QBoxLayout *urlLayout = new QHBoxLayout( topLayout() );
00056   QLabel *urlLbl = new QLabel( i18n("Calendar URL:"), this );
00057   urlLayout->addWidget(urlLbl);
00058 
00059   mUrl = new QLineEdit(this);
00060   urlLayout->addWidget(mUrl);
00061 
00062   topLayout()->addStretch( 1 );
00063 }
00064 
00065 void ConfigGuiGoogleCalendar::load( const QString &xml )
00066 {
00067   QDomDocument doc;
00068   doc.setContent( xml );
00069   QDomElement docElement = doc.documentElement();
00070   QDomNode n;
00071   for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
00072     QDomElement e = n.toElement();
00073     if ( e.tagName() == "username" ) {
00074       mUsername->setText(e.text());
00075     } else if ( e.tagName() == "password" ) {
00076       mPassword->setText(e.text());
00077     } else if ( e.tagName() == "url" ) {
00078       mUrl->setText(e.text());
00079     }
00080   }
00081 }
00082 
00083 QString ConfigGuiGoogleCalendar::save() const
00084 {
00085   QDomDocument doc;
00086   QDomElement root = doc.createElement("config");
00087   doc.appendChild(root);
00088 
00089   QDomElement un = doc.createElement("username");
00090   root.appendChild(un);
00091   un.appendChild(doc.createTextNode(mUsername->text()));
00092 
00093   QDomElement pass = doc.createElement("password");
00094   root.appendChild(pass);
00095   pass.appendChild(doc.createTextNode(mPassword->text()));
00096 
00097   QDomElement url = doc.createElement("url");
00098   root.appendChild(url);
00099   url.appendChild(doc.createTextNode(mUrl->text()));
00100 
00101   //TODO: Implement me!
00102   return doc.toString();
00103 }
KDE Home | KDE Accessibility Home | Description of Access Keys