accounts-qt  1.13
auth-data.cpp
00001 /* vi: set et sw=4 ts=4 cino=t0,(0: */
00002 /*
00003  * This file is part of libaccounts-qt
00004  *
00005  * Copyright (C) 2012 Canonical Ltd.
00006  *
00007  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * version 2.1 as published by the Free Software Foundation.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  */
00023 
00024 #include "auth-data.h"
00025 #include "utils.h"
00026 
00027 #undef signals
00028 #include <libaccounts-glib/ag-auth-data.h>
00029 #include <QtDebug>
00030 #include <QtGlobal>
00031 
00032 
00033 using namespace Accounts;
00034 
00035 namespace Accounts {
00046 }; // namespace
00047 
00048 AuthData::AuthData(AgAuthData *authData):
00049     m_authData(ag_auth_data_ref(authData))
00050 {
00051 }
00052 
00057 AuthData::AuthData(const AuthData &other):
00058     m_authData(ag_auth_data_ref(other.m_authData))
00059 {
00060 }
00061 
00065 AuthData::~AuthData()
00066 {
00067     ag_auth_data_unref(m_authData);
00068     m_authData = 0;
00069 }
00070 
00074 uint AuthData::credentialsId() const
00075 {
00076     return ag_auth_data_get_credentials_id(m_authData);
00077 }
00078 
00084 QString AuthData::method() const
00085 {
00086     return UTF8(ag_auth_data_get_method(m_authData));
00087 }
00088 
00094 QString AuthData::mechanism() const
00095 {
00096     return UTF8(ag_auth_data_get_mechanism(m_authData));
00097 }
00098 
00104 QVariantMap AuthData::parameters() const
00105 {
00106     GVariant *glibParameters;
00107 
00108     glibParameters = ag_auth_data_get_login_parameters(m_authData, NULL);
00109     if (glibParameters == 0) return QVariantMap();
00110 
00111     QVariant variant = gVariantToQVariant(glibParameters);
00112     g_variant_unref(glibParameters);
00113     if (!variant.isValid()) return QVariantMap();
00114 
00115     return variant.toMap();
00116 }