accounts-qt
0.31
|
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-2010 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 #include <libaccounts-glib/ag-manager.h> 00027 #include <libaccounts-glib/ag-service-type.h> 00028 #include "manager.h" 00029 #include <QtDebug> 00030 #include <QtGlobal> 00031 00032 00033 using namespace Accounts; 00034 00035 ServiceType::ServiceType(AgServiceType *serviceType) 00036 : m_serviceType(serviceType) 00037 { 00038 TRACE(); 00039 ag_service_type_ref(m_serviceType); 00040 } 00041 00042 ServiceType::~ServiceType() 00043 { 00044 TRACE(); 00045 ag_service_type_unref(m_serviceType); 00046 m_serviceType = 0; 00047 } 00048 00049 QString ServiceType::name() const 00050 { 00051 return UTF8(ag_service_type_get_name(m_serviceType)); 00052 } 00053 00054 QString ServiceType::displayName() const 00055 { 00056 const gchar *id; 00057 00058 /* libaccounts-glib returns the display name untranslated. */ 00059 id = ag_service_type_get_display_name(m_serviceType); 00060 if (id != NULL) { 00061 return qtTrId(id); 00062 } else { 00063 return QString(); 00064 } 00065 } 00066 00067 QString ServiceType::trCatalog() const 00068 { 00069 return ASCII(ag_service_type_get_i18n_domain(m_serviceType)); 00070 } 00071 00072 QString ServiceType::iconName() const 00073 { 00074 return ASCII(ag_service_type_get_icon_name(m_serviceType)); 00075 } 00076 00077 const QDomDocument ServiceType::domDocument() const 00078 { 00079 if (doc.isNull()) { 00080 const gchar *data; 00081 gsize len; 00082 00083 ag_service_type_get_file_contents(m_serviceType, &data, &len); 00084 00085 QString errorStr; 00086 int errorLine; 00087 int errorColumn; 00088 if (!doc.setContent(QByteArray(data, len), true, 00089 &errorStr, &errorLine, &errorColumn)) { 00090 QString message(ASCII("Parse error reading serviceType file " 00091 "at line %1, column %2:\n%3")); 00092 message.arg(errorLine).arg(errorColumn).arg(errorStr); 00093 qWarning() << __PRETTY_FUNCTION__ << message; 00094 return QDomDocument(); 00095 } 00096 } 00097 00098 return doc; 00099 } 00100