accounts-qt 1.10

- Main Page
- Related Pages
- Classes
- Files

- File List

application.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 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 "application.h"
25 #include "service.h"
26
27 #undef signals
28 #include <libaccounts-glib/ag-application.h>
29
30 using namespace Accounts;
31
32 namespace Accounts {
43 }; // namespace
44
45 Application::Application(AgApplication *application):
46 m_application(application)
47 {
48 }
49
54 Application::Application(const Application &other):
55 m_application(other.m_application)
56 {
57 if (m_application != 0)
58 ag_application_ref(m_application);
59 }
60
61 Application &Application::operator=(const Application &other)
62 {
63 if (m_application == other.m_application) return *this;
64 if (m_application != 0)
65 ag_application_unref(m_application);
66 m_application = other.m_application;
67 if (m_application != 0)
68 ag_application_ref(m_application);
69 return *this;
70 }
71
75 Application::~Application()
76 {
77 if (m_application != 0) {
78 ag_application_unref(m_application);
79 m_application = 0;
80 }
81 }
82
87 bool Application::isValid() const
88 {
89 return m_application != 0;
90 }
91
97 QString Application::name() const
98 {
99 if (Q_UNLIKELY(!isValid())) return QString();
100 return UTF8(ag_application_get_name(m_application));
101 }
102
107 QString Application::displayName() const
108 {
109 QString name;
110 GDesktopAppInfo *info =
111 ag_application_get_desktop_app_info(m_application);
112 if (Q_LIKELY(info)) {
113 name = UTF8(g_app_info_get_display_name(G_APP_INFO(info)));
114 g_object_unref(info);
115 }
116 return name;
117 }
118
123 QString Application::description() const
124 {
125 return UTF8(ag_application_get_description(m_application));
126 }
127
132 QString Application::iconName() const
133 {
134 QString iconName;
135 GDesktopAppInfo *info =
136 ag_application_get_desktop_app_info(m_application);
137 if (Q_LIKELY(info)) {
138 gchar *gIconName = g_desktop_app_info_get_string(info, "Icon");
139 if (Q_LIKELY(gIconName)) {
140 iconName = UTF8(gIconName);
141 g_free(gIconName);
142 }
143 g_object_unref(info);
144 }
145 return iconName;
146 }
147
152 QString Application::desktopFilePath() const
153 {
154 QString filePath;
155 GDesktopAppInfo *info =
156 ag_application_get_desktop_app_info(m_application);
157 if (Q_LIKELY(info)) {
158 filePath = UTF8(g_desktop_app_info_get_filename(info));
159 g_object_unref(info);
160 }
161 return filePath;
162 }
163
169 QString Application::trCatalog() const
170 {
171 return UTF8(ag_application_get_i18n_domain(m_application));
172 }
173
179 QString Application::serviceUsage(const Service &service) const
180 {
181 return UTF8(ag_application_get_service_usage(m_application,
182 service.service()));
183 }
Accounts::Application::iconName
QString iconName() const
Get the icon name of the application.
Definition: application.cpp:132
Accounts::Application::description
QString description() const
Get the description of the application.
Definition: application.cpp:123
Accounts::Application::desktopFilePath
QString desktopFilePath() const
Get the .desktop file associated with this application.
Definition: application.cpp:152
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:179
Accounts::Application::Application
Application(const Application &other)
Copy constructor.
Definition: application.cpp:45
Accounts::Service
Representation of an account service.
Definition: service.h:48
Accounts::Application::name
QString name() const
Get the unique ID of the application.
Definition: application.cpp:97
Accounts::Application::isValid
bool isValid() const
Check whether this object represents an Application.
Definition: application.cpp:87
Accounts::Application::displayName
QString displayName() const
Get the display name of the application.
Definition: application.cpp:107
Accounts::Application
Information on the client applications of libaccounts.
Definition: application.h:40
Accounts::Application::trCatalog
QString trCatalog() const
Get the translation catalog for the texts returned by the methods of this class.
Definition: application.cpp:169
Accounts::Application::~Application
~Application()
Destructor.
Definition: application.cpp:75