[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:04:37 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=4c72b4a
The following commit has been merged in the master branch:
commit 4c72b4a32094fe87e054ebc77a95d74945d10816
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sun Oct 2 15:11:15 2011 +0100
Add KWallet support for loading/saving passwords.
---
wallet-interface.cpp | 85 +++++++++++++++++++++++++++++++++++++++
kpresence.h => wallet-interface.h | 37 +++++++++++------
2 files changed, 109 insertions(+), 13 deletions(-)
diff --git a/wallet-interface.cpp b/wallet-interface.cpp
new file mode 100644
index 0000000..9be45fc
--- /dev/null
+++ b/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/kpresence.h b/wallet-interface.h
similarity index 52%
copy from kpresence.h
copy to wallet-interface.h
index 2321816..4807a03 100644
--- a/kpresence.h
+++ b/wallet-interface.h
@@ -1,5 +1,5 @@
/*
- * Global Presence - wrap Tp::Presence with KDE functionality
+ * This file is part of telepathy-accounts-kcm
*
* Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
*
@@ -18,24 +18,35 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef KPRESENCE_H
-#define KPRESENCE_H
+#ifndef WALLETINTERFACE_H
+#define WALLETINTERFACE_H
-#include <TelepathyQt4/Presence>
+#include <TelepathyQt4/Account>
-#include <KIcon>
+#include <KWallet/Wallet>
-class KPresence : public Tp::Presence
+#include <QScopedPointer>
+
+class WalletInterface
{
public:
- KPresence();
- KPresence(const Tp::Presence &presence);
- KIcon icon() const;
- /** Returns which presence is "more available" */
- bool operator <(const KPresence &other) const;
+ WalletInterface(WId winId);
+ virtual ~WalletInterface();
+
+ /** Returns true if a password is stored for this acount*/
+ bool hasPassword(const Tp::AccountPtr &account);
+
+ /** Returns the stored password*/
+ QString password(const Tp::AccountPtr &account);
+
+ /** 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;
- QString displayString() const;
};
-#endif // KPRESENCE_H
+#endif // WALLETINTERFACE_H
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list