auth-data.cpp
/* vi: set et sw=4 ts=4 cino=t0,(0: */
/*
* This file is part of libaccounts-qt
*
* Copyright (C) 2012-2016 Canonical Ltd.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 "auth-data.h"
#include "utils.h"
#undef signals
#include <libaccounts-glib.h>
#include <QtDebug>
#include <QtGlobal>
using namespace Accounts;
namespace Accounts {
}; // namespace
AuthData::AuthData(AgAuthData *authData):
m_authData(ag_auth_data_ref(authData))
{
}
AuthData::AuthData(const AuthData &other):
m_authData(ag_auth_data_ref(other.m_authData))
{
}
AuthData::~AuthData()
{
ag_auth_data_unref(m_authData);
m_authData = nullptr;
}
uint AuthData::credentialsId() const
{
return ag_auth_data_get_credentials_id(m_authData);
}
QString AuthData::method() const
{
return UTF8(ag_auth_data_get_method(m_authData));
}
QString AuthData::mechanism() const
{
return UTF8(ag_auth_data_get_mechanism(m_authData));
}
QVariantMap AuthData::parameters() const
{
GVariant *glibParameters;
glibParameters = ag_auth_data_get_login_parameters(m_authData, NULL);
if (glibParameters == nullptr) return QVariantMap();
QVariant variant = gVariantToQVariant(glibParameters);
g_variant_unref(glibParameters);
if (!variant.isValid()) return QVariantMap();
return variant.toMap();
}
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