| 1 | #include "AccountServiceClient.h" |
| 2 | #include <QDBusConnection> |
| 3 | #include "serviceutils.h" |
| 4 | |
| 5 | #define ACCOUNTS_SERVICE "org.dekkoproject.Service" |
| 6 | #define ACCOUNTS_PATH "/accounts" |
| 7 | |
| 8 | AccountServiceClient::AccountServiceClient(QObject *parent) : QObject(parent), |
| 9 | m_service(0) |
| 10 | { |
| 11 | m_service = new AccountServiceInterface(ACCOUNTS_SERVICE, ACCOUNTS_PATH, QDBusConnection::sessionBus()); |
| 12 | connect(m_service, &AccountServiceInterface::accountRemoved, this, &AccountServiceClient::handleRemoved); |
| 13 | } |
| 14 | |
| 15 | void AccountServiceClient::removeAccount(const QMailAccountId &id) |
| 16 | { |
| 17 | m_service->removeAccount(id.toULongLong()); |
| 18 | } |
| 19 | |
| 20 | IdReply AccountServiceClient::queryAccounts(const QMailAccountKey &accountKey, const QMailAccountSortKey &sortKey, const int &limit) |
| 21 | { |
| 22 | return m_service->queryAccounts(account_key_bytes(accountKey), account_sort_key_bytes(sortKey), limit); |
| 23 | } |
| 24 | |
| 25 | void AccountServiceClient::handleRemoved(const quint64 &id) |
| 26 | { |
| 27 | QMailAccountId aId(id); |
| 28 | emit accountRemoved(aId); |
| 29 | } |