|
libaccounts-qt
1.1
|
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-2011 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 #undef signals 00028 #include <libaccounts-glib/ag-provider.h> 00029 00030 00031 using namespace Accounts; 00032 00033 namespace Accounts { 00044 }; // namespace 00045 00046 Provider::Provider(AgProvider *provider) 00047 : m_provider(provider) 00048 { 00049 TRACE(); 00050 ag_provider_ref(m_provider); 00051 } 00052 00053 Provider::~Provider() 00054 { 00055 TRACE(); 00056 00057 ag_provider_unref(m_provider); 00058 m_provider = 0; 00059 } 00060 00061 QString Provider::name() const 00062 { 00063 return UTF8(ag_provider_get_name(m_provider)); 00064 } 00065 00066 QString Provider::displayName() const 00067 { 00068 return UTF8(ag_provider_get_display_name(m_provider)); 00069 } 00070 00075 QString Provider::trCatalog() const 00076 { 00077 return ASCII(ag_provider_get_i18n_domain(m_provider)); 00078 } 00079 00083 QString Provider::iconName() const 00084 { 00085 return ASCII(ag_provider_get_icon_name(m_provider)); 00086 } 00087 00091 const QDomDocument Provider::domDocument() const 00092 { 00093 if (doc.isNull()) 00094 { 00095 const gchar *data; 00096 00097 ag_provider_get_file_contents(m_provider, &data); 00098 00099 QString errorStr; 00100 int errorLine; 00101 int errorColumn; 00102 if (!doc.setContent(QByteArray(data), true, 00103 &errorStr, &errorLine, &errorColumn)) 00104 { 00105 QString message(ASCII("Parse error reading account provider file " 00106 "at line %1, column %2:\n%3")); 00107 message.arg(errorLine).arg(errorColumn).arg(errorStr); 00108 qWarning() << __PRETTY_FUNCTION__ << message; 00109 return QDomDocument(); 00110 } 00111 } 00112 00113 return doc; 00114 } 00115 00116 AgProvider *Provider::provider() const 00117 { 00118 return m_provider; 00119 } 00120