| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | extern const QLoggingCategory &qLcMenu(); | - | ||||||||||||
| 7 | - | |||||||||||||
| 8 | const QString StatusNotifierWatcherService = QLatin1String("org.kde.StatusNotifierWatcher"); | - | ||||||||||||
| 9 | const QString StatusNotifierWatcherPath = QLatin1String("/StatusNotifierWatcher"); | - | ||||||||||||
| 10 | const QString StatusNotifierItemPath = QLatin1String("/StatusNotifierItem"); | - | ||||||||||||
| 11 | const QString MenuBarPath = QLatin1String("/MenuBar"); | - | ||||||||||||
| 12 | - | |||||||||||||
| 13 | - | |||||||||||||
| 14 | - | |||||||||||||
| 15 | - | |||||||||||||
| 16 | - | |||||||||||||
| 17 | - | |||||||||||||
| 18 | - | |||||||||||||
| 19 | QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName) | - | ||||||||||||
| 20 | : QObject(parent) | - | ||||||||||||
| 21 | , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus() | - | ||||||||||||
| 22 | : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName)) | - | ||||||||||||
| 23 | , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this)) | - | ||||||||||||
| 24 | , m_statusNotifierHostRegistered(false) | - | ||||||||||||
| 25 | { | - | ||||||||||||
| 26 | - | |||||||||||||
| 27 | QDBusInterface systrayHost(StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService, m_connection); | - | ||||||||||||
| 28 | if (systrayHost.isValid()
| 0-1 | ||||||||||||
| 29 | m_statusNotifierHostRegistered = true; never executed: m_statusNotifierHostRegistered = true; | 0 | ||||||||||||
| 30 | else | - | ||||||||||||
| 31 | for (bool qt_category_enabled = qLcMenu().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 74, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << "StatusNotifierHost is not registered"; | 0-1 | ||||||||||||
| 32 | - | |||||||||||||
| 33 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 34 | - | |||||||||||||
| 35 | void QDBusMenuConnection::dbusError(const QDBusError &error) | - | ||||||||||||
| 36 | { | - | ||||||||||||
| 37 | QMessageLogger(__FILE__, 80, __PRETTY_FUNCTION__).warning() << "QDBusTrayIcon encountered a D-Bus error:" << error; | - | ||||||||||||
| 38 | } never executed: end of block | 0 | ||||||||||||
| 39 | - | |||||||||||||
| 40 | - | |||||||||||||
| 41 | bool QDBusMenuConnection::registerTrayIconMenu(QDBusTrayIcon *item) | - | ||||||||||||
| 42 | { | - | ||||||||||||
| 43 | bool success = connection().registerObject(MenuBarPath, item->menu()); | - | ||||||||||||
| 44 | if (!success
| 0 | ||||||||||||
| 45 | for (bool qt_category_enabled = qLcMenu().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 88, __PRETTY_FUNCTION__, qLcMenu().categoryName()).debug() << "failed to register" << item->instanceId() << MenuBarPath; | 0 | ||||||||||||
| 46 | return never executed: success;return success;never executed: return success; | 0 | ||||||||||||
| 47 | } | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item) | - | ||||||||||||
| 50 | { | - | ||||||||||||
| 51 | if (item->menu()
| 0 | ||||||||||||
| 52 | connection().unregisterObject(MenuBarPath); never executed: connection().unregisterObject(MenuBarPath); | 0 | ||||||||||||
| 53 | } never executed: end of block | 0 | ||||||||||||
| 54 | - | |||||||||||||
| 55 | bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item) | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | bool success = connection().registerService(item->instanceId()); | - | ||||||||||||
| 58 | if (!success
| 0 | ||||||||||||
| 59 | QMessageLogger(__FILE__, 102, __PRETTY_FUNCTION__).warning() << "failed to register service" << item->instanceId(); | - | ||||||||||||
| 60 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 61 | } | - | ||||||||||||
| 62 | - | |||||||||||||
| 63 | success = connection().registerObject(StatusNotifierItemPath, item); | - | ||||||||||||
| 64 | if (!success
| 0 | ||||||||||||
| 65 | unregisterTrayIcon(item); | - | ||||||||||||
| 66 | QMessageLogger(__FILE__, 109, __PRETTY_FUNCTION__).warning() << "failed to register" << item->instanceId() << StatusNotifierItemPath; | - | ||||||||||||
| 67 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 68 | } | - | ||||||||||||
| 69 | - | |||||||||||||
| 70 | if (item->menu()
| 0 | ||||||||||||
| 71 | registerTrayIconMenu(item); never executed: registerTrayIconMenu(item); | 0 | ||||||||||||
| 72 | - | |||||||||||||
| 73 | QDBusMessage registerMethod = QDBusMessage::createMethodCall( | - | ||||||||||||
| 74 | StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService, | - | ||||||||||||
| 75 | QLatin1String("RegisterStatusNotifierItem")); | - | ||||||||||||
| 76 | registerMethod.setArguments(QVariantList() << item->instanceId()); | - | ||||||||||||
| 77 | success = m_connection.callWithCallback(registerMethod, this, qFlagLocation("2""trayIconRegistered()" "\0" __FILE__ ":" "120"), qFlagLocation("1""dbusError(QDBusError)" "\0" __FILE__ ":" "120")); | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | return never executed: success;return success;never executed: return success; | 0 | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | unregisterTrayIconMenu(item); | - | ||||||||||||
| 85 | connection().unregisterObject(StatusNotifierItemPath); | - | ||||||||||||
| 86 | bool success = connection().unregisterService(item->instanceId()); | - | ||||||||||||
| 87 | if (!success
| 0 | ||||||||||||
| 88 | QMessageLogger(__FILE__, 131, __PRETTY_FUNCTION__).warning() << "failed to unregister service" << item->instanceId(); never executed: QMessageLogger(__FILE__, 131, __PRETTY_FUNCTION__).warning() << "failed to unregister service" << item->instanceId(); | 0 | ||||||||||||
| 89 | return never executed: success;return success;never executed: return success; | 0 | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | - | |||||||||||||
| 92 | - | |||||||||||||
| 93 | - | |||||||||||||
| Switch to Source code | Preprocessed file |