accounts-qt
1.13
|
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 "application.h" 00025 #include "service.h" 00026 00027 #undef signals 00028 #include <libaccounts-glib/ag-application.h> 00029 00030 using namespace Accounts; 00031 00032 namespace Accounts { 00043 }; // namespace 00044 00045 Application::Application(AgApplication *application): 00046 m_application(application) 00047 { 00048 } 00049 00053 Application::Application(): 00054 m_application(0) 00055 { 00056 } 00057 00062 Application::Application(const Application &other): 00063 m_application(other.m_application) 00064 { 00065 if (m_application != 0) 00066 ag_application_ref(m_application); 00067 } 00068 00069 Application &Application::operator=(const Application &other) 00070 { 00071 if (m_application == other.m_application) return *this; 00072 if (m_application != 0) 00073 ag_application_unref(m_application); 00074 m_application = other.m_application; 00075 if (m_application != 0) 00076 ag_application_ref(m_application); 00077 return *this; 00078 } 00079 00083 Application::~Application() 00084 { 00085 if (m_application != 0) { 00086 ag_application_unref(m_application); 00087 m_application = 0; 00088 } 00089 } 00090 00095 bool Application::isValid() const 00096 { 00097 return m_application != 0; 00098 } 00099 00105 QString Application::name() const 00106 { 00107 if (Q_UNLIKELY(!isValid())) return QString(); 00108 return UTF8(ag_application_get_name(m_application)); 00109 } 00110 00115 QString Application::displayName() const 00116 { 00117 QString name; 00118 GDesktopAppInfo *info = 00119 ag_application_get_desktop_app_info(m_application); 00120 if (Q_LIKELY(info)) { 00121 name = UTF8(g_app_info_get_display_name(G_APP_INFO(info))); 00122 g_object_unref(info); 00123 } 00124 return name; 00125 } 00126 00131 QString Application::description() const 00132 { 00133 return UTF8(ag_application_get_description(m_application)); 00134 } 00135 00140 QString Application::iconName() const 00141 { 00142 QString iconName; 00143 GDesktopAppInfo *info = 00144 ag_application_get_desktop_app_info(m_application); 00145 if (Q_LIKELY(info)) { 00146 gchar *gIconName = g_desktop_app_info_get_string(info, "Icon"); 00147 if (Q_LIKELY(gIconName)) { 00148 iconName = UTF8(gIconName); 00149 g_free(gIconName); 00150 } 00151 g_object_unref(info); 00152 } 00153 return iconName; 00154 } 00155 00160 QString Application::desktopFilePath() const 00161 { 00162 QString filePath; 00163 GDesktopAppInfo *info = 00164 ag_application_get_desktop_app_info(m_application); 00165 if (Q_LIKELY(info)) { 00166 filePath = UTF8(g_desktop_app_info_get_filename(info)); 00167 g_object_unref(info); 00168 } 00169 return filePath; 00170 } 00171 00177 QString Application::trCatalog() const 00178 { 00179 return UTF8(ag_application_get_i18n_domain(m_application)); 00180 } 00181 00187 QString Application::serviceUsage(const Service &service) const 00188 { 00189 return UTF8(ag_application_get_service_usage(m_application, 00190 service.service())); 00191 }