application.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 "application.h"
#include "service.h"
#undef signals
#include <libaccounts-glib/ag-application.h>
using namespace Accounts;
namespace Accounts {
}; // namespace
Application::Application(AgApplication *application):
m_application(application)
{
}
Application::Application():
m_application(nullptr)
{
}
Application::Application(const Application &other):
m_application(other.m_application)
{
if (m_application != nullptr)
ag_application_ref(m_application);
}
Application &Application::operator=(const Application &other)
{
if (m_application == other.m_application) return *this;
if (m_application != nullptr)
ag_application_unref(m_application);
m_application = other.m_application;
if (m_application != nullptr)
ag_application_ref(m_application);
return *this;
}
Application::~Application()
{
if (m_application != nullptr) {
ag_application_unref(m_application);
m_application = nullptr;
}
}
bool Application::isValid() const
{
return m_application != nullptr;
}
QString Application::name() const
{
if (Q_UNLIKELY(!isValid())) return QString();
return UTF8(ag_application_get_name(m_application));
}
QString Application::displayName() const
{
QString name;
GDesktopAppInfo *info =
ag_application_get_desktop_app_info(m_application);
if (Q_LIKELY(info)) {
name = UTF8(g_app_info_get_display_name(G_APP_INFO(info)));
g_object_unref(info);
}
return name;
}
QString Application::description() const
{
return UTF8(ag_application_get_description(m_application));
}
QString Application::iconName() const
{
QString iconName;
GDesktopAppInfo *info =
ag_application_get_desktop_app_info(m_application);
if (Q_LIKELY(info)) {
gchar *gIconName = g_desktop_app_info_get_string(info, "Icon");
if (Q_LIKELY(gIconName)) {
iconName = UTF8(gIconName);
g_free(gIconName);
}
g_object_unref(info);
}
return iconName;
}
QString Application::desktopFilePath() const
{
QString filePath;
GDesktopAppInfo *info =
ag_application_get_desktop_app_info(m_application);
if (Q_LIKELY(info)) {
filePath = UTF8(g_desktop_app_info_get_filename(info));
g_object_unref(info);
}
return filePath;
}
QString Application::trCatalog() const
{
return UTF8(ag_application_get_i18n_domain(m_application));
}
bool Application::supportsService(const Service &service) const
{
return ag_application_supports_service(m_application,
service.service());
}
QString Application::serviceUsage(const Service &service) const
{
return UTF8(ag_application_get_service_usage(m_application,
service.service()));
}
AgApplication *Application::application() const
{
return m_application;
}
Accounts::Application
Information on the client applications of libaccounts.
Definition application.h:42
Accounts::Application::isValid
bool isValid() const
Check whether this object represents an Application.
Definition application.cpp:95
Accounts::Application::~Application
~Application()
Destructor.
Definition application.cpp:83
Accounts::Application::name
QString name() const
Get the unique ID of the application.
Definition application.cpp:105
Accounts::Application::desktopFilePath
QString desktopFilePath() const
Get the .desktop file associated with this application.
Definition application.cpp:160
Accounts::Application::iconName
QString iconName() const
Get the icon name of the application.
Definition application.cpp:140
Accounts::Application::displayName
QString displayName() const
Get the display name of the application.
Definition application.cpp:115
Accounts::Application::description
QString description() const
Get the description of the application.
Definition application.cpp:131
Accounts::Application::supportsService
bool supportsService(const Service &service) const
Check whether the application supports the given service.
Definition application.cpp:187
Accounts::Application::serviceUsage
QString serviceUsage(const Service &service) const
Get the description from the application XML file, for the specified service; if not found,...
Definition application.cpp:198
Accounts::Application::trCatalog
QString trCatalog() const
Get the translation catalog for the texts returned by the methods of this class.
Definition application.cpp:177
Accounts::Application::Application
Application()
Construct an invalid application.
Definition application.cpp:53
Accounts::Service
Representation of an account service.
Definition service.h:49