Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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