[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:00:04 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=3f23456
The following commit has been merged in the master branch:
commit 3f23456ec6edc3b6763f2b23439c7860d73e3061
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sun Oct 2 15:11:15 2011 +0100
Add KWallet support for loading/saving passwords.
---
src/CMakeLists.txt | 1 +
src/add-account-assistant.cpp | 21 +++++-
src/edit-account-dialog.cpp | 31 ++++++---
src/wallet-interface.cpp | 85 +++++++++++++++++++++++
src/{edit-account-dialog.h => wallet-interface.h} | 41 +++++------
5 files changed, 149 insertions(+), 30 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f01cdf5..1b177e2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,6 +14,7 @@ set (telepathy_accounts_kcm_SRCS
edit-account-dialog.cpp
salut-enable-dialog.cpp
accounts-list-delegate.cpp
+ wallet-interface.cpp
)
kde4_add_ui_files (telepathy_accounts_kcm_SRCS
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 43b55b6..0ddf1ff 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -22,6 +22,8 @@
#include "add-account-assistant.h"
+#include "wallet-interface.h"
+
#include "KCMTelepathyAccounts/abstract-account-parameters-widget.h"
#include "KCMTelepathyAccounts/abstract-account-ui.h"
#include "KCMTelepathyAccounts/account-edit-widget.h"
@@ -33,6 +35,7 @@
#include <KLocale>
#include <KMessageBox>
#include <KPageWidgetItem>
+#include <KWallet/Wallet>
#include <QtCore/QList>
#include <QtGui/QHBoxLayout>
@@ -175,6 +178,11 @@ void AddAccountAssistant::accept()
displayName = d->currentProfileItem->protocolName();
}
+ //remove password values from being sent. These are stored by MC instead
+
+ //FIXME: This breaks jabber registration - see Telepathy ML thread "Storing passwords in MC and regsitering new accounts"
+ values.remove("password");
+
Tp::PendingAccount *pa = d->accountManager->createAccount(d->currentProfileItem->cmName(),
d->currentProfileItem->protocolName(),
displayName,
@@ -219,10 +227,19 @@ void AddAccountAssistant::onAccountCreated(Tp::PendingOperation *op)
return;
}
+ Tp::AccountPtr account = pendingAccount->account();
+
if(d->accountEditWidget->connectOnAdd()){
- pendingAccount->account()->setRequestedPresence(Tp::Presence::available(QString("Online")));
+ account->setRequestedPresence(Tp::Presence::available(QString("Online")));
+ }
+ account->setServiceName(d->currentProfileItem->serviceName());
+
+ //save password to KWallet if needed
+ QVariantMap values = d->accountEditWidget->parametersSet();
+ if (values.contains(QLatin1String("password"))) {
+ WalletInterface wallet(this->effectiveWinId());
+ wallet.setPassword(account, values["password"].toString());
}
- pendingAccount->account()->setServiceName(d->currentProfileItem->serviceName());
KAssistantDialog::accept();
}
diff --git a/src/edit-account-dialog.cpp b/src/edit-account-dialog.cpp
index 8e9cde8..aeca24a 100644
--- a/src/edit-account-dialog.cpp
+++ b/src/edit-account-dialog.cpp
@@ -21,6 +21,7 @@
#include "edit-account-dialog.h"
+#include "wallet-interface.h"
#include "KCMTelepathyAccounts/dictionary.h"
#include "KCMTelepathyAccounts/abstract-account-parameters-widget.h"
@@ -70,6 +71,17 @@ EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget *parent)
ParameterEditModel *parameterModel = new ParameterEditModel(this);
parameterModel->addItems(parameters, d->item->account()->profile()->parameters(), parameterValues);
+ //update the parameter model with the password from kwallet (if applicable)
+ Tp::ProtocolParameter passwordParameter = parameterModel->parameter(QLatin1String("password"));
+
+ WalletInterface wallet(this->effectiveWinId());
+ if (passwordParameter.isValid() && wallet.hasPassword(d->item->account())) {
+ QModelIndex index = parameterModel->indexForParameter(passwordParameter);
+ QString password = wallet.password(d->item->account());
+ parameterModel->setData(index, password, Qt::EditRole);
+ }
+
+
// Set up the interface
d->widget = new AccountEditWidget(d->item->account()->profile(),
parameterModel,
@@ -99,13 +111,11 @@ void EditAccountDialog::accept()
return;
}
+ //remove password from setParameters as this is now stored by kwallet instead
+ setParameters.remove(QLatin1String("password"));
+
Tp::PendingStringList *psl = d->item->account()->updateParameters(setParameters, unsetParameters);
- // We don't want to print on the screen our passwords therefore we hide it before printing
- if (setParameters.contains(QLatin1String("password")))
- {
- setParameters[QLatin1String("password")] = QLatin1String("**********");
- }
kDebug() << "Set parameters:" << setParameters;
kDebug() << "Unset parameters:" << unsetParameters;
@@ -127,8 +137,7 @@ void EditAccountDialog::onParametersUpdated(Tp::PendingOperation *op)
Tp::PendingStringList *psl = qobject_cast<Tp::PendingStringList*>(op);
Q_ASSERT(psl);
- if (!psl)
- {
+ if (!psl) {
kWarning() << "Something weird happened";
}
@@ -138,8 +147,14 @@ void EditAccountDialog::onParametersUpdated(Tp::PendingOperation *op)
}
QVariantMap values = d->widget->parametersSet();
- // FIXME: Ask the user to submit a Display Name
+ if (values.contains(QLatin1String("password"))) {
+ WalletInterface wallet(this->effectiveWinId());
+ wallet.setPassword(d->item->account(), values["password"].toString());
+ }
+
+
+ // FIXME: Ask the user to submit a Display Name
QString displayName;
if (values.contains("account")) {
displayName = values["account"].toString();
diff --git a/src/wallet-interface.cpp b/src/wallet-interface.cpp
new file mode 100644
index 0000000..9be45fc
--- /dev/null
+++ b/src/wallet-interface.cpp
@@ -0,0 +1,85 @@
+/*
+ * This file is part of telepathy-accounts-kcm
+ *
+ * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "wallet-interface.h"
+
+#include <KDebug>
+
+
+const QLatin1String WalletInterface::s_folderName = QLatin1String("kde-telepathy");
+
+
+WalletInterface::WalletInterface(WId winId):
+ m_wallet(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), winId))
+{
+}
+
+WalletInterface::~WalletInterface()
+{
+}
+
+bool WalletInterface::hasPassword(const Tp::AccountPtr &account)
+{
+ if (m_wallet.isNull()) {
+ return false;
+ }
+
+ if (m_wallet->hasFolder(s_folderName)) {
+ m_wallet->setFolder(s_folderName);
+ if (m_wallet->hasEntry(account->uniqueIdentifier())) {
+ return true;
+ }
+ }
+ return false;
+}
+
+QString WalletInterface::password(const Tp::AccountPtr &account)
+{
+ if (m_wallet.isNull()) {
+ return QString();
+ }
+
+ m_wallet->setFolder(s_folderName);
+
+ QString password;
+
+ if (m_wallet->hasEntry(account->uniqueIdentifier())) {
+ int rc = m_wallet->readPassword(account->uniqueIdentifier(), password);
+ if (rc != 0) {
+ password.clear();
+ kWarning() << "failed to read password from KWallet";
+ }
+ }
+ return password;
+}
+
+void WalletInterface::setPassword(const Tp::AccountPtr &account, const QString &password)
+{
+ if (m_wallet.isNull()) {
+ return;
+ }
+
+ if (! m_wallet->hasFolder(s_folderName)) {
+ m_wallet->createFolder(s_folderName);
+ }
+
+ m_wallet->setFolder(s_folderName);
+ m_wallet->writePassword(account->uniqueIdentifier(), password);
+}
diff --git a/src/edit-account-dialog.h b/src/wallet-interface.h
similarity index 52%
copy from src/edit-account-dialog.h
copy to src/wallet-interface.h
index e57f6f2..4807a03 100644
--- a/src/edit-account-dialog.h
+++ b/src/wallet-interface.h
@@ -1,7 +1,7 @@
/*
* This file is part of telepathy-accounts-kcm
*
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,34 +18,35 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef KCM_TELEPATHY_ACCOUNTS_EDIT_ACCOUNT_DIALOG_H
-#define KCM_TELEPATHY_ACCOUNTS_EDIT_ACCOUNT_DIALOG_H
+#ifndef WALLETINTERFACE_H
+#define WALLETINTERFACE_H
-#include "account-item.h"
+#include <TelepathyQt4/Account>
-#include <KDialog>
+#include <KWallet/Wallet>
-class EditAccountDialog : public KDialog
-{
- Q_OBJECT
+#include <QScopedPointer>
+class WalletInterface
+{
public:
- explicit EditAccountDialog(AccountItem *item, QWidget *parent = 0);
- virtual ~EditAccountDialog();
-private Q_SLOTS:
- void onParametersUpdated(Tp::PendingOperation *op);
- void onDisplayNameUpdated(Tp::PendingOperation *op);
+ WalletInterface(WId winId);
+ virtual ~WalletInterface();
-private:
- Q_DISABLE_COPY(EditAccountDialog);
+ /** Returns true if a password is stored for this acount*/
+ bool hasPassword(const Tp::AccountPtr &account);
- void accept();
+ /** Returns the stored password*/
+ QString password(const Tp::AccountPtr &account);
- class Private;
- Private * const d;
-};
+ /** Set the password entry for the given account to a new password*/
+ void setPassword(const Tp::AccountPtr &account, const QString &password);
+private:
+ static const QLatin1String s_folderName;
+ QScopedPointer<KWallet::Wallet> m_wallet;
-#endif // header guard
+};
+#endif // WALLETINTERFACE_H
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list