kitchensync

configguigcalendar.cpp
1 /*
2  This file is part of KitchenSync.
3 
4  Copyright (c) 2005 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (c) 2006 Eduardo Habkost <ehabkost@raisama.net>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20  USA.
21 */
22 
23 #include "configguigcalendar.h"
24 
25 #include <tdelocale.h>
26 
27 #include <tqlayout.h>
28 #include <tqlabel.h>
29 #include <tqdom.h>
30 #include <tqlineedit.h>
31 
32 ConfigGuiGoogleCalendar::ConfigGuiGoogleCalendar( const QSync::Member &member, TQWidget *parent )
33  : ConfigGui( member, parent )
34 {
35  TQBoxLayout *userLayout = new TQHBoxLayout( topLayout() );
36 
37  TQLabel *userLbl= new TQLabel( i18n("Username:"), this );
38  userLayout->addWidget(userLbl);
39 
40  mUsername = new TQLineEdit(this);
41  userLayout->addWidget(mUsername);
42 
43 
44  TQBoxLayout *passLayout = new TQHBoxLayout( topLayout() );
45 
46  TQLabel *passLbl = new TQLabel( i18n("Password:"), this );
47  passLayout->addWidget(passLbl);
48 
49  mPassword = new TQLineEdit(this);
50  mPassword->setEchoMode(TQLineEdit::Password);
51  passLayout->addWidget(mPassword);
52 
53  topLayout()->addWidget(new TQLabel( i18n("Please notice that currently the password is stored as plain text in the plugin configuration file"), this ));
54 
55  TQBoxLayout *urlLayout = new TQHBoxLayout( topLayout() );
56  TQLabel *urlLbl = new TQLabel( i18n("Calendar URL:"), this );
57  urlLayout->addWidget(urlLbl);
58 
59  mUrl = new TQLineEdit(this);
60  urlLayout->addWidget(mUrl);
61 
62  topLayout()->addStretch( 1 );
63 }
64 
65 void ConfigGuiGoogleCalendar::load( const TQString &xml )
66 {
67  TQDomDocument doc;
68  doc.setContent( xml );
69  TQDomElement docElement = doc.documentElement();
70  TQDomNode n;
71  for( n = docElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
72  TQDomElement e = n.toElement();
73  if ( e.tagName() == "username" ) {
74  mUsername->setText(e.text());
75  } else if ( e.tagName() == "password" ) {
76  mPassword->setText(e.text());
77  } else if ( e.tagName() == "url" ) {
78  mUrl->setText(e.text());
79  }
80  }
81 }
82 
83 TQString ConfigGuiGoogleCalendar::save() const
84 {
85  TQDomDocument doc;
86  TQDomElement root = doc.createElement("config");
87  doc.appendChild(root);
88 
89  TQDomElement un = doc.createElement("username");
90  root.appendChild(un);
91  un.appendChild(doc.createTextNode(mUsername->text()));
92 
93  TQDomElement pass = doc.createElement("password");
94  root.appendChild(pass);
95  pass.appendChild(doc.createTextNode(mPassword->text()));
96 
97  TQDomElement url = doc.createElement("url");
98  root.appendChild(url);
99  url.appendChild(doc.createTextNode(mUrl->text()));
100 
101  //TODO: Implement me!
102  return doc.toString();
103 }