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 <tqlayout.h>
00028 #include <tqlabel.h>
00029 #include <tqdom.h>
00030 #include <tqlineedit.h>
00031 
00032 ConfigGuiGoogleCalendar::ConfigGuiGoogleCalendar( const QSync::Member &member, TQWidget *parent )
00033   : ConfigGui( member, parent )
00034 {
00035   TQBoxLayout *userLayout = new TQHBoxLayout( topLayout() );
00036 
00037   TQLabel *userLbl= new TQLabel( i18n("Username:"), this );
00038   userLayout->addWidget(userLbl);
00039 
00040   mUsername = new TQLineEdit(this);
00041   userLayout->addWidget(mUsername);
00042 
00043 
00044   TQBoxLayout *passLayout = new TQHBoxLayout( topLayout() );
00045 
00046   TQLabel *passLbl = new TQLabel( i18n("Password:"), this );
00047   passLayout->addWidget(passLbl);
00048 
00049   mPassword = new TQLineEdit(this);
00050   mPassword->setEchoMode(TQLineEdit::Password);
00051   passLayout->addWidget(mPassword);
00052 
00053   topLayout()->addWidget(new TQLabel( i18n("Please notice that currently the password is stored as plain text in the plugin configuration file"), this ));
00054 
00055   TQBoxLayout *urlLayout = new TQHBoxLayout( topLayout() );
00056   TQLabel *urlLbl = new TQLabel( i18n("Calendar URL:"), this );
00057   urlLayout->addWidget(urlLbl);
00058 
00059   mUrl = new TQLineEdit(this);
00060   urlLayout->addWidget(mUrl);
00061 
00062   topLayout()->addStretch( 1 );
00063 }
00064 
00065 void ConfigGuiGoogleCalendar::load( const TQString &xml )
00066 {
00067   TQDomDocument doc;
00068   doc.setContent( xml );
00069   TQDomElement docElement = doc.documentElement();
00070   TQDomNode n;
00071   for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
00072     TQDomElement 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 TQString ConfigGuiGoogleCalendar::save() const
00084 {
00085   TQDomDocument doc;
00086   TQDomElement root = doc.createElement("config");
00087   doc.appendChild(root);
00088 
00089   TQDomElement un = doc.createElement("username");
00090   root.appendChild(un);
00091   un.appendChild(doc.createTextNode(mUsername->text()));
00092 
00093   TQDomElement pass = doc.createElement("password");
00094   root.appendChild(pass);
00095   pass.appendChild(doc.createTextNode(mPassword->text()));
00096 
00097   TQDomElement 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 }