27 #include "service-type.h"
30 #include <libaccounts-glib/ag-service-type.h>
32 #if QT_VERSION < QT_VERSION_CHECK(5 ,0 ,0)
33 #define QStringLiteral QString::fromUtf8
53 m_serviceType(serviceType),
56 if (m_serviceType != 0 && mode == AddReference)
57 ag_service_type_ref(m_serviceType);
74 m_serviceType(other.m_serviceType),
77 if (m_serviceType != 0)
78 ag_service_type_ref(m_serviceType);
83 if (m_serviceType == other.m_serviceType)
return *
this;
84 if (m_serviceType != 0)
85 ag_service_type_unref(m_serviceType);
86 m_serviceType = other.m_serviceType;
87 if (m_serviceType != 0)
88 ag_service_type_ref(m_serviceType);
92 ServiceType::~ServiceType()
94 if (m_serviceType != 0) {
95 ag_service_type_unref(m_serviceType);
110 return m_serviceType != 0;
118 if (Q_UNLIKELY(!
isValid()))
return QString();
119 return UTF8(ag_service_type_get_name(m_serviceType));
135 id = ag_service_type_get_display_name(m_serviceType);
149 return ASCII(ag_service_type_get_i18n_domain(m_serviceType));
157 return ASCII(ag_service_type_get_icon_name(m_serviceType));
169 return ag_service_type_has_tag(m_serviceType, tag.toUtf8().constData());
182 m_tags =
new QSet<QString>;
183 GList *list = ag_service_type_get_tags(m_serviceType);
185 while (iter != NULL) {
186 m_tags->insert(UTF8(reinterpret_cast<const gchar *> (iter->data)));
187 iter = g_list_next(iter);
201 ag_service_type_get_file_contents(m_serviceType, &data, &len);
207 if (!doc.setContent(QByteArray(data, len),
true,
208 &errorStr, &errorLine, &errorColumn)) {
209 QString message(QStringLiteral(
"Parse error reading serviceType file "
210 "at line %1, column %2:\n%3"));
211 message = message.arg(errorLine).arg(errorColumn).arg(errorStr);
212 qWarning() << __PRETTY_FUNCTION__ << message;
QString trCatalog() const
Representation of an account service type.
ServiceType()
Construct an invalid serviceType.
bool hasTag(const QString &tag) const
Check if this service type has a tag.
const QDomDocument domDocument() const
QString displayName() const
bool isValid() const
Check whether this object represents a ServiceType.
QSet< QString > tags() const
Return all tags of the service type as a set.
QString name() const
Returns the name (ID) of the service type.