libaccounts-qt  1.6
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 
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 
76 {
77  if (m_application != 0) {
78  ag_application_unref(m_application);
79  m_application = 0;
80  }
81 }
82 
88 {
89  return m_application != 0;
90 }
91 
96 QString Application::name() const
97 {
98  return UTF8(ag_application_get_name(m_application));
99 }
100 
106 {
107  return UTF8(ag_application_get_description(m_application));
108 }
109 
115 QString Application::trCatalog() const
116 {
117  return UTF8(ag_application_get_i18n_domain(m_application));
118 }
119 
125 QString Application::serviceUsage(const Service &service) const
126 {
127  return UTF8(ag_application_get_service_usage(m_application,
128  service.service()));
129 }