accounts-qt 1.17

auth-data.cpp
1/* vi: set et sw=4 ts=4 cino=t0,(0: */
2/*
3 * This file is part of libaccounts-qt
4 *
5 * Copyright (C) 2012-2016 Canonical Ltd.
6 *
7 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24#include "auth-data.h"
25#include "utils.h"
26
27#undef signals
28#include <libaccounts-glib.h>
29#include <QtDebug>
30#include <QtGlobal>
31
32
33 using namespace Accounts;
34
35 namespace Accounts {
46}; // namespace
47
48 AuthData::AuthData(AgAuthData *authData):
49 m_authData(ag_auth_data_ref(authData))
50{
51}
52
57 AuthData::AuthData(const AuthData &other):
58 m_authData(ag_auth_data_ref(other.m_authData))
59{
60}
61
65 AuthData::~AuthData()
66{
67 ag_auth_data_unref(m_authData);
68 m_authData = nullptr;
69}
70
74uint AuthData::credentialsId() const
75{
76 return ag_auth_data_get_credentials_id(m_authData);
77}
78
84QString AuthData::method() const
85{
86 return UTF8(ag_auth_data_get_method(m_authData));
87}
88
94QString AuthData::mechanism() const
95{
96 return UTF8(ag_auth_data_get_mechanism(m_authData));
97}
98
104QVariantMap AuthData::parameters() const
105{
106 GVariant *glibParameters;
107
108 glibParameters = ag_auth_data_get_login_parameters(m_authData, NULL);
109 if (glibParameters == nullptr) return QVariantMap();
110
111 QVariant variant = gVariantToQVariant(glibParameters);
112 g_variant_unref(glibParameters);
113 if (!variant.isValid()) return QVariantMap();
114
115 return variant.toMap();
116}
Accounts::AuthData
Information for account authentication.
Definition auth-data.h:50
Accounts::AuthData::method
QString method() const
Get the authentication method which must be used when logging in with this account.
Definition auth-data.cpp:84
Accounts::AuthData::~AuthData
virtual ~AuthData()
Destructor.
Definition auth-data.cpp:65
Accounts::AuthData::parameters
QVariantMap parameters() const
Get the dictionary of authentication parameters which must be used when logging in with this account.
Definition auth-data.cpp:104
Accounts::AuthData::credentialsId
uint credentialsId() const
Definition auth-data.cpp:74
Accounts::AuthData::mechanism
QString mechanism() const
Get the authentication mechanism which must be used when logging in with this account.
Definition auth-data.cpp:94
Accounts::AuthData::AuthData
AuthData(const AuthData &other)
Copy constructor.
Definition auth-data.cpp:48