[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:05:26 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=ba80142
The following commit has been merged in the master branch:
commit ba801421013ca5ac9a1152698e53f05a0bd1250b
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Thu Aug 9 20:18:41 2012 +0100
Add convenience class to set wallet passwords
REVIEW: 105566
Reviewed-by: Daniele E. Domenichelli
---
KTp/CMakeLists.txt | 2 +
KTp/wallet-utils.cpp | 110 +++++++++++++++++++++++++++++
KTp/{error-dictionary.h => wallet-utils.h} | 22 +++---
3 files changed, 121 insertions(+), 13 deletions(-)
diff --git a/KTp/CMakeLists.txt b/KTp/CMakeLists.txt
index f0f1d5f..fa0c741 100644
--- a/KTp/CMakeLists.txt
+++ b/KTp/CMakeLists.txt
@@ -12,6 +12,7 @@ set (ktp_common_internals_private_SRCS
text-parser.cpp
pending-wallet.cpp
wallet-interface.cpp
+ wallet-utils.cpp
)
set (ktp_common_internals_private_HDRS
@@ -25,6 +26,7 @@ set (ktp_common_internals_private_HDRS
text-parser.h
pending-wallet.h
wallet-interface.h
+ wallet-utils.h
ktp-export.h
)
diff --git a/KTp/wallet-utils.cpp b/KTp/wallet-utils.cpp
new file mode 100644
index 0000000..815f4d6
--- /dev/null
+++ b/KTp/wallet-utils.cpp
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2012 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "wallet-utils.h"
+
+#include <TelepathyQt/PendingOperation>
+#include <TelepathyQt/Account>
+
+#include <KTp/wallet-interface.h>
+#include <KTp/pending-wallet.h>
+
+class SetAccountPasswordOp : public Tp::PendingOperation
+{
+ Q_OBJECT
+public:
+ explicit SetAccountPasswordOp(const Tp::AccountPtr &account, const QString &password);
+
+ static Tp::PendingOperation * setAccountPassword(const Tp::AccountPtr &account, const QString &password);
+
+private Q_SLOTS:
+ void onWalletOpened(Tp::PendingOperation *op);
+private:
+ Tp::AccountPtr m_account;
+ QString m_password;
+};
+
+class RemoveAccountPasswordOp : public Tp::PendingOperation
+{
+ Q_OBJECT
+public:
+ explicit RemoveAccountPasswordOp(const Tp::AccountPtr &account);
+
+private Q_SLOTS:
+ void onWalletOpened(Tp::PendingOperation *op);
+private:
+ Tp::AccountPtr m_account;
+};
+
+
+Tp::PendingOperation* KTp::WalletUtils::setAccountPassword(const Tp::AccountPtr &account, const QString &password)
+{
+ return new SetAccountPasswordOp(account, password);
+}
+
+Tp::PendingOperation* KTp::WalletUtils::removeAccountPassword(const Tp::AccountPtr &account)
+{
+ return new RemoveAccountPasswordOp(account);
+}
+
+SetAccountPasswordOp::SetAccountPasswordOp(const Tp::AccountPtr &account, const QString &password) :
+ Tp::PendingOperation(account),
+ m_account(account),
+ m_password(password)
+{
+ connect(KTp::WalletInterface::openWallet(),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onWalletOpened(Tp::PendingOperation*)));
+}
+
+void SetAccountPasswordOp::onWalletOpened(Tp::PendingOperation *op)
+{
+ KTp::PendingWallet *walletOp = qobject_cast<KTp::PendingWallet*>(op);
+ Q_ASSERT(walletOp);
+
+ KTp::WalletInterface *walletInterface = walletOp->walletInterface();
+
+ //note deliberate using isNull, not isEmpty, as the password could be empty which is valid
+ if (m_password.isNull()) {
+ walletInterface->removePassword(m_account);
+ } else {
+ walletInterface->setPassword(m_account, m_password);
+ }
+}
+
+
+RemoveAccountPasswordOp::RemoveAccountPasswordOp(const Tp::AccountPtr &account) :
+ Tp::PendingOperation(account),
+ m_account(account)
+{
+ connect(KTp::WalletInterface::openWallet(),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onWalletOpened(Tp::PendingOperation*)));
+}
+
+void RemoveAccountPasswordOp::onWalletOpened(Tp::PendingOperation *op)
+{
+ KTp::PendingWallet *walletOp = qobject_cast<KTp::PendingWallet*>(op);
+ Q_ASSERT(walletOp);
+
+ KTp::WalletInterface *walletInterface = walletOp->walletInterface();
+ walletInterface->removeAccount(m_account);
+ setFinished();
+}
+
+#include "wallet-utils.moc"
diff --git a/KTp/error-dictionary.h b/KTp/wallet-utils.h
similarity index 59%
copy from KTp/error-dictionary.h
copy to KTp/wallet-utils.h
index b92a43b..eeab936 100644
--- a/KTp/error-dictionary.h
+++ b/KTp/wallet-utils.h
@@ -1,6 +1,5 @@
/*
- Telepathy error dictionary - usable strings for dbus messages
- Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ Copyright (C) 2012 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
@@ -17,24 +16,21 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifndef WALLETUTILS_H
+#define WALLETUTILS_H
-#ifndef ERROR_DICTIONARY_H
-#define ERROR_DICTIONARY_H
-
-#include <QString>
+#include <TelepathyQt/PendingOperation>
+#include <TelepathyQt/Account>
#include <KTp/ktp-export.h>
namespace KTp
{
-namespace ErrorDictionary
+namespace WalletUtils
{
- ///Returns a verbose error message usable for displaying to the user
- KTP_EXPORT QString displayVerboseErrorMessage(const QString& dbusErrorName);
-
- ///Returns a short error message usable for little space
- KTP_EXPORT QString displayShortErrorMessage(const QString& dbusErrorName);
+ KTP_EXPORT Tp::PendingOperation * setAccountPassword(const Tp::AccountPtr &account, const QString &password);
+ KTP_EXPORT Tp::PendingOperation * removeAccountPassword(const Tp::AccountPtr &account);
}
}
-#endif // ERROR_DICTIONARY_H
+#endif //WALLETUTILS_H
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list