1
/***************************************************************************
2
* Copyright (C) 2010 by Kai Dombrowe <just89@gmx.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18
***************************************************************************/
21
#include "accountpage.h"
22
#include <recorditnow.h>
30
AccountPage::AccountPage(QWidget *parent)
31
: QWizardPage(parent), m_wallet(0)
36
registerField("Account*", accountEdit);
37
registerField("Password*", passwordEdit);
42
AccountPage::~AccountPage()
52
void AccountPage::initializePage()
55
wallCheck->setChecked(Settings::uploadPassword());
56
if (wallCheck->isChecked()) {
57
KConfigGroup cfg(Settings::self()->config(), "Upload");
58
accountEdit->setText(cfg.readEntry("RecordItNow-"+field("Provider").toString(), QString()));
66
void AccountPage::writeWallet(bool success)
69
kDebug() << "success:" << success;
70
if (success && enterWalletFolder("RecordItNow-"+field("Provider").toString())) {
71
if (m_wallet->writePassword(accountEdit->text(), passwordEdit->text()) == 0) {
72
kDebug() << "successfully put password in wallet";
83
void AccountPage::readWallet(bool success)
86
kDebug() << "success:" << success;
87
if (success && enterWalletFolder("RecordItNow-"+field("Provider").toString())) {
89
if (m_wallet->readPassword(accountEdit->text(), password) == 0) {
90
kDebug() << "successfully retrieved password from wallet";
91
passwordEdit->setText(password);
102
void AccountPage::getWallet()
109
kDebug() << "opening wallet";
110
m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), winId(),
111
KWallet::Wallet::Asynchronous);
113
if (m_walletWait == Write) {
114
connect(m_wallet, SIGNAL(walletOpened(bool)), SLOT(writeWallet(bool)));
116
connect(m_wallet, SIGNAL(walletOpened(bool)), SLOT(readWallet(bool)));
122
bool AccountPage::enterWalletFolder(const QString &folder)
129
m_wallet->createFolder(folder);
130
if (!m_wallet->setFolder(folder)) {
131
kDebug() << "failed to open folder" << folder;
134
kDebug() << "wallet now on folder" << folder;
140
bool AccountPage::validatePage()
143
Settings::self()->setUploadPassword(wallCheck->isChecked());
144
if (wallCheck->isChecked()) {
145
KConfigGroup cfg(Settings::self()->config(), "Upload");
146
cfg.writeEntry("RecordItNow-"+field("Provider").toString(), accountEdit->text());
154
void AccountPage::getPassword()
157
if (accountEdit->text().isEmpty()) {
166
void AccountPage::setPassword()
169
if (accountEdit->text().isEmpty() || passwordEdit->text().isEmpty()) {
172
m_walletWait = Write;
178
#include "accountpage.moc"