2
* This file is part of libOnlineAccounts
4
* Copyright (C) 2015 Canonical Ltd.
6
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8
* This program is free software: you can redistribute it and/or modify it
9
* under the terms of the GNU Lesser General Public License version 3, as
10
* published by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranties of
14
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
* PURPOSE. See the GNU Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
#include "dbus_constants.h"
26
namespace OnlineAccounts {
28
Error errorFromDBus(const QDBusError &dbusError)
30
Error::Code code = Error::PermissionDenied;
31
QString name = dbusError.name();
32
if (name == ONLINE_ACCOUNTS_ERROR_NO_ACCOUNT) {
33
code = Error::NoAccount;
34
} else if (name == ONLINE_ACCOUNTS_ERROR_USER_CANCELED) {
35
code = Error::UserCanceled;
36
} else if (name == ONLINE_ACCOUNTS_ERROR_INTERACTION_REQUIRED) {
37
code = Error::InteractionRequired;
39
return Error(code, dbusError.message());