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 "account.h"
00025 #include "manager.h"
00026
00027 #include <libaccounts-glib/ag-manager.h>
00028 #include <libaccounts-glib/ag-account.h>
00029 #include <libaccounts-glib/ag-service.h>
00030 #include <QtDebug>
00031
00032
00033 using namespace Accounts;
00034
00035 Service::Service(AgService *service)
00036 : m_service(service)
00037 {
00038 TRACE();
00039 ag_service_ref(m_service);
00040 }
00041
00042 Service::~Service()
00043 {
00044 TRACE();
00045
00046 ag_service_unref(m_service);
00047 m_service = 0;
00048 }
00049
00050 QString Service::name() const
00051 {
00052 return UTF8(ag_service_get_name(m_service));
00053 }
00054
00055 QString Service::displayName() const
00056 {
00057 return UTF8(ag_service_get_display_name(m_service));
00058 }
00059
00060 QString Service::serviceType() const
00061 {
00062 return ASCII(ag_service_get_service_type(m_service));
00063 }
00064
00065 QString Service::provider() const
00066 {
00067 return UTF8(ag_service_get_provider(m_service));
00068 }
00069
00070 QString Service::iconName() const
00071 {
00072 return ASCII(ag_service_get_icon_name(m_service));
00073 }
00074
00075 QXmlStreamReader *Service::xmlStreamReader() const
00076 {
00077 const gchar *data;
00078 gsize offset;
00079
00080 ag_service_get_file_contents(m_service, &data, &offset);
00081 if (data)
00082 data += offset;
00083
00084 QXmlStreamReader *reader = new QXmlStreamReader(QByteArray(data));
00085
00086
00087 if (reader->readNext() != QXmlStreamReader::StartDocument)
00088 {
00089 delete reader;
00090 return NULL;
00091 }
00092
00093 return reader;
00094 }
00095
00096 const QDomDocument Service::domDocument() const
00097 {
00098 if (doc.isNull())
00099 {
00100 const gchar *data;
00101
00102 ag_service_get_file_contents(m_service, &data, NULL);
00103
00104 QString errorStr;
00105 int errorLine;
00106 int errorColumn;
00107 if (!doc.setContent(QByteArray(data), true,
00108 &errorStr, &errorLine, &errorColumn))
00109 {
00110 QString message(ASCII("Parse error reading account service file "
00111 "at line %1, column %2:\n%3"));
00112 message.arg(errorLine).arg(errorColumn).arg(errorStr);
00113 qWarning() << __PRETTY_FUNCTION__ << message;
00114 return QDomDocument();
00115 }
00116 }
00117
00118 return doc;
00119 }
00120
00121 AgService *Service::service() const
00122 {
00123 return m_service;
00124 }
00125