|
libaccounts-qt
1.1
|
00001 /* vi: set et sw=4 ts=4 cino=t0,(0: */ 00002 /* 00003 * This file is part of libaccounts-qt 00004 * 00005 * Copyright (C) 2009-2011 Nokia Corporation. 00006 * 00007 * Contact: Alberto Mardegan <alberto.mardegan@nokia.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 "service-type.h" 00025 00026 #undef signals 00027 #include <libaccounts-glib/ag-manager.h> 00028 #include <libaccounts-glib/ag-service-type.h> 00029 #include "manager.h" 00030 #include <QtDebug> 00031 #include <QtGlobal> 00032 00033 00034 using namespace Accounts; 00035 00036 namespace Accounts { 00048 }; // namespace 00049 00050 ServiceType::ServiceType(AgServiceType *serviceType) 00051 : m_serviceType(serviceType) 00052 { 00053 TRACE(); 00054 ag_service_type_ref(m_serviceType); 00055 } 00056 00057 ServiceType::~ServiceType() 00058 { 00059 TRACE(); 00060 ag_service_type_unref(m_serviceType); 00061 m_serviceType = 0; 00062 } 00063 00067 QString ServiceType::name() const 00068 { 00069 return UTF8(ag_service_type_get_name(m_serviceType)); 00070 } 00071 00080 QString ServiceType::displayName() const 00081 { 00082 const gchar *id; 00083 00084 /* libaccounts-glib returns the display name untranslated. */ 00085 id = ag_service_type_get_display_name(m_serviceType); 00086 if (id != NULL) { 00087 return qtTrId(id); 00088 } else { 00089 return QString(); 00090 } 00091 } 00092 00097 QString ServiceType::trCatalog() const 00098 { 00099 return ASCII(ag_service_type_get_i18n_domain(m_serviceType)); 00100 } 00101 00105 QString ServiceType::iconName() const 00106 { 00107 return ASCII(ag_service_type_get_icon_name(m_serviceType)); 00108 } 00109 00113 const QDomDocument ServiceType::domDocument() const 00114 { 00115 if (doc.isNull()) { 00116 const gchar *data; 00117 gsize len; 00118 00119 ag_service_type_get_file_contents(m_serviceType, &data, &len); 00120 00121 QString errorStr; 00122 int errorLine; 00123 int errorColumn; 00124 if (!doc.setContent(QByteArray(data, len), true, 00125 &errorStr, &errorLine, &errorColumn)) { 00126 QString message(ASCII("Parse error reading serviceType file " 00127 "at line %1, column %2:\n%3")); 00128 message.arg(errorLine).arg(errorColumn).arg(errorStr); 00129 qWarning() << __PRETTY_FUNCTION__ << message; 00130 return QDomDocument(); 00131 } 00132 } 00133 00134 return doc; 00135 } 00136