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 "provider.h" 00025 #include "accountscommon.h" 00026 00027 #include <libaccounts-glib/ag-provider.h> 00028 00029 00030 using namespace Accounts; 00031 00032 Provider::Provider(AgProvider *provider) 00033 : m_provider(provider) 00034 { 00035 TRACE(); 00036 ag_provider_ref(m_provider); 00037 } 00038 00039 Provider::~Provider() 00040 { 00041 TRACE(); 00042 00043 ag_provider_unref(m_provider); 00044 m_provider = 0; 00045 } 00046 00047 QString Provider::name() const 00048 { 00049 return UTF8(ag_provider_get_name(m_provider)); 00050 } 00051 00052 QString Provider::displayName() const 00053 { 00054 return UTF8(ag_provider_get_display_name(m_provider)); 00055 } 00056 00057 const QDomDocument Provider::domDocument() const 00058 { 00059 if (doc.isNull()) 00060 { 00061 const gchar *data; 00062 00063 ag_provider_get_file_contents(m_provider, &data); 00064 00065 QString errorStr; 00066 int errorLine; 00067 int errorColumn; 00068 if (!doc.setContent(QByteArray(data), true, 00069 &errorStr, &errorLine, &errorColumn)) 00070 { 00071 QString message(ASCII("Parse error reading account provider file " 00072 "at line %1, column %2:\n%3")); 00073 message.arg(errorLine).arg(errorColumn).arg(errorStr); 00074 qWarning() << __PRETTY_FUNCTION__ << message; 00075 return QDomDocument(); 00076 } 00077 } 00078 00079 return doc; 00080 } 00081 00082 AgProvider *Provider::provider() const 00083 { 00084 return m_provider; 00085 } 00086