File indexing completed on 2024-05-05 03:50:35
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Eckhart Wörner <ewoerner@kde.org> 0004 // 0005 0006 #include "Provider_p.h" 0007 0008 0009 0010 using namespace GeoCute; 0011 0012 Provider::Private::Private(Provider& parent, const QString& service, 0013 const QString& path) 0014 : currentStatus(StatusUnavailable), 0015 interface(service, path, interfaceName), 0016 parent(parent) 0017 0018 { 0019 // Make sure the provider stays available as long as needed 0020 interface.asyncCall("AddReference"); 0021 // Get an initial status 0022 interface.callWithCallback("GetStatus", QList<QVariant>(), &parent, 0023 SLOT(statusChangedCall(int)), 0); 0024 // Stay informed about future status updates 0025 interface.connect("StatusChanged", &parent, SLOT(statusChangedCall(int))); 0026 } 0027 0028 Provider::Private::~Private() 0029 { 0030 interface.asyncCall("RemoveReference"); 0031 } 0032 0033 void Provider::Private::statusChangedCall(int status) 0034 { 0035 const Status newStatus = static_cast<Status>(status); 0036 if (newStatus != currentStatus) { 0037 currentStatus = newStatus; 0038 // FIXME: Re-enable 0039 emit parent.statusChanged(newStatus); 0040 } 0041 } 0042 0043 0044 0045 Provider::Provider(const QString& service, const QString& path, 0046 QObject* parent) 0047 : QObject(parent), d(new Private(*this, service, path)) 0048 { 0049 } 0050 0051 Provider::~Provider() 0052 { 0053 delete d; 0054 } 0055 0056 Status Provider::status() const 0057 { 0058 return d->currentStatus; 0059 } 0060 0061 0062 0063 #include "moc_Provider.cpp"