| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the tools applications of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | #ifndef QDBUSVIEWER_H |
| 30 | #define QDBUSVIEWER_H |
| 31 | |
| 32 | #include <QtWidgets/QWidget> |
| 33 | #include <QtDBus/QDBusConnection> |
| 34 | #include <QtCore/QRegExp> |
| 35 | |
| 36 | class ServicesProxyModel; |
| 37 | |
| 38 | QT_FORWARD_DECLARE_CLASS(QTableView) |
| 39 | QT_FORWARD_DECLARE_CLASS(QTreeView) |
| 40 | QT_FORWARD_DECLARE_CLASS(QTreeWidget) |
| 41 | QT_FORWARD_DECLARE_CLASS(QStringListModel) |
| 42 | QT_FORWARD_DECLARE_CLASS(QLineEdit) |
| 43 | QT_FORWARD_DECLARE_CLASS(QTextBrowser) |
| 44 | QT_FORWARD_DECLARE_CLASS(QDomDocument) |
| 45 | QT_FORWARD_DECLARE_CLASS(QDomElement) |
| 46 | QT_FORWARD_DECLARE_CLASS(QSplitter) |
| 47 | QT_FORWARD_DECLARE_CLASS(QSettings) |
| 48 | |
| 49 | struct BusSignature |
| 50 | { |
| 51 | QString mService, mPath, mInterface, mName; |
| 52 | QString mTypeSig; |
| 53 | }; |
| 54 | |
| 55 | class QDBusViewer: public QWidget |
| 56 | { |
| 57 | Q_OBJECT |
| 58 | public: |
| 59 | QDBusViewer(const QDBusConnection &connection, QWidget *parent = 0); |
| 60 | |
| 61 | void saveState(QSettings *settings) const; |
| 62 | void restoreState(const QSettings *settings); |
| 63 | |
| 64 | public slots: |
| 65 | void refresh(); |
| 66 | |
| 67 | private slots: |
| 68 | void serviceChanged(const QModelIndex &index); |
| 69 | void (const QPoint &); |
| 70 | void connectionRequested(const BusSignature &sig); |
| 71 | void callMethod(const BusSignature &sig); |
| 72 | void getProperty(const BusSignature &sig); |
| 73 | void setProperty(const BusSignature &sig); |
| 74 | void dumpMessage(const QDBusMessage &msg); |
| 75 | void refreshChildren(); |
| 76 | |
| 77 | void serviceRegistered(const QString &service); |
| 78 | void serviceUnregistered(const QString &service); |
| 79 | void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); |
| 80 | |
| 81 | void serviceFilterReturnPressed(); |
| 82 | void activate(const QModelIndex &item); |
| 83 | |
| 84 | void logError(const QString &msg); |
| 85 | void anchorClicked(const QUrl &url); |
| 86 | |
| 87 | private: |
| 88 | void logMessage(const QString &msg); |
| 89 | void showEvent(QShowEvent *) override; |
| 90 | bool eventFilter(QObject *obj, QEvent *event) override; |
| 91 | |
| 92 | QDBusConnection c; |
| 93 | QString currentService; |
| 94 | QTreeView *tree; |
| 95 | QAction *refreshAction; |
| 96 | QTreeWidget *services; |
| 97 | QStringListModel *servicesModel; |
| 98 | ServicesProxyModel *servicesProxyModel; |
| 99 | QLineEdit *serviceFilterLine; |
| 100 | QTableView *servicesView; |
| 101 | QTextBrowser *log; |
| 102 | QSplitter *topSplitter; |
| 103 | QSplitter *splitter; |
| 104 | QRegExp objectPathRegExp; |
| 105 | }; |
| 106 | |
| 107 | #endif |
| 108 | |