File indexing completed on 2023-12-03 05:01:58
0001 /* 0002 Copyright (C) 2011 Collabora Ltd. <info@collabora.com> 0003 @author George Kiagiadakis <george.kiagiadakis@collabora.com> 0004 0005 This library is free software; you can redistribute it and/or modify 0006 it under the terms of the GNU Lesser General Public License as published 0007 by the Free Software Foundation; either version 2.1 of the License, or 0008 (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU General Public License for more details. 0014 0015 You should have received a copy of the GNU Lesser General Public License 0016 along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 */ 0018 #ifndef SERVICE_AVAILABILITY_CHECKER_H 0019 #define SERVICE_AVAILABILITY_CHECKER_H 0020 0021 #include <QtCore/QObject> 0022 0023 #include <KTp/ktpcommoninternals_export.h> 0024 0025 class QDBusPendingCallWatcher; 0026 0027 namespace KTp 0028 { 0029 0030 /** 0031 * This class watches if a given d-bus service is either 0032 * available on the bus or can be activated on demand. 0033 */ 0034 class KTPCOMMONINTERNALS_EXPORT ServiceAvailabilityChecker : public QObject 0035 { 0036 Q_OBJECT 0037 public: 0038 explicit ServiceAvailabilityChecker(const QString & serviceName, QObject *parent = nullptr); 0039 ~ServiceAvailabilityChecker() override; 0040 0041 bool isAvailable() const; 0042 0043 private Q_SLOTS: 0044 void introspect(); 0045 void onCallFinished(QDBusPendingCallWatcher *watcher); 0046 void onServiceOwnerChanged(const QString & service, 0047 const QString & oldOwner, 0048 const QString & newOwner); 0049 0050 private: 0051 struct Private; 0052 Private * const d; 0053 }; 0054 0055 } 0056 0057 #endif // SERVICE_AVAILABILITY_CHECKER_H