| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbusservicewatcher.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | - | |||||||
| 8 | class QDBusServiceWatcherPrivate: public QObjectPrivate | - | ||||||
| 9 | { | - | ||||||
| 10 | inline QDBusServiceWatcher* q_func() { return static_cast<QDBusServiceWatcher *>(q_ptr); } inline const QDBusServiceWatcher* q_func() const { return static_cast<const QDBusServiceWatcher *>(q_ptr); } friend class QDBusServiceWatcher; | - | ||||||
| 11 | public: | - | ||||||
| 12 | QDBusServiceWatcherPrivate(const QDBusConnection &c, QDBusServiceWatcher::WatchMode wm) | - | ||||||
| 13 | : connection(c), watchMode(wm) | - | ||||||
| 14 | { | - | ||||||
| 15 | } | - | ||||||
| 16 | - | |||||||
| 17 | QStringList servicesWatched; | - | ||||||
| 18 | QDBusConnection connection; | - | ||||||
| 19 | QDBusServiceWatcher::WatchMode watchMode; | - | ||||||
| 20 | - | |||||||
| 21 | void _q_serviceOwnerChanged(const QString &, const QString &, const QString &); | - | ||||||
| 22 | void setConnection(const QStringList &services, const QDBusConnection &c, QDBusServiceWatcher::WatchMode watchMode); | - | ||||||
| 23 | - | |||||||
| 24 | void addService(const QString &service); | - | ||||||
| 25 | void removeService(const QString &service); | - | ||||||
| 26 | }; | - | ||||||
| 27 | - | |||||||
| 28 | void QDBusServiceWatcherPrivate::_q_serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner) | - | ||||||
| 29 | { | - | ||||||
| 30 | QDBusServiceWatcher * const q = q_func(); | - | ||||||
| 31 | q->serviceOwnerChanged(service, oldOwner, newOwner); | - | ||||||
| 32 | if (oldOwner.isEmpty()) | - | ||||||
| 33 | q->serviceRegistered(service); | - | ||||||
| 34 | else if (newOwner.isEmpty()) | - | ||||||
| 35 | q->serviceUnregistered(service); | - | ||||||
| 36 | } | - | ||||||
| 37 | - | |||||||
| 38 | void QDBusServiceWatcherPrivate::setConnection(const QStringList &s, const QDBusConnection &c, QDBusServiceWatcher::WatchMode wm) | - | ||||||
| 39 | { | - | ||||||
| 40 | if (connection.isConnected()
| 6-818 | ||||||
| 41 | - | |||||||
| 42 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(servicesWatched)>::type> _container_((servicesWatched)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &s = *_container_.i; _container_.control; _container_.control = 0): qAsConst(servicesWatched)) | - | ||||||
| 43 | removeService(s); executed 4 times by 1 test: removeService(s);Executed by:
| 4 | ||||||
| 44 | } executed 818 times by 155 tests: end of blockExecuted by:
| 818 | ||||||
| 45 | - | |||||||
| 46 | connection = c; | - | ||||||
| 47 | watchMode = wm; | - | ||||||
| 48 | servicesWatched = s; | - | ||||||
| 49 | - | |||||||
| 50 | if (connection.isConnected()
| 5-819 | ||||||
| 51 | - | |||||||
| 52 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(servicesWatched)>::type> _container_((servicesWatched)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QString &s = *_container_.i; _container_.control; _container_.control = 0): qAsConst(servicesWatched)) | - | ||||||
| 53 | addService(s); executed 819 times by 155 tests: addService(s);Executed by:
| 819 | ||||||
| 54 | } executed 819 times by 155 tests: end of blockExecuted by:
| 819 | ||||||
| 55 | } executed 824 times by 155 tests: end of blockExecuted by:
| 824 | ||||||
| 56 | - | |||||||
| 57 | void QDBusServiceWatcherPrivate::addService(const QString &service) | - | ||||||
| 58 | { | - | ||||||
| 59 | QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection); | - | ||||||
| 60 | if (d && d->shouldWatchService(service)) | - | ||||||
| 61 | d->watchService(service, watchMode, q_func(), qFlagLocation("1""_q_serviceOwnerChanged(QString,QString,QString)" "\0" __FILE__ ":" "100""106")); | - | ||||||
| 62 | } | - | ||||||
| 63 | - | |||||||
| 64 | void QDBusServiceWatcherPrivate::removeService(const QString &service) | - | ||||||
| 65 | { | - | ||||||
| 66 | QDBusConnectionPrivate *d = QDBusConnectionPrivate::d(connection); | - | ||||||
| 67 | if (d && d->shouldWatchService(service)) | - | ||||||
| 68 | d->unwatchService(service, watchMode, q_func(), qFlagLocation("1""_q_serviceOwnerChanged(QString,QString,QString)" "\0" __FILE__ ":" "107""113")); | - | ||||||
| 69 | } | - | ||||||
| 70 | QDBusServiceWatcher::QDBusServiceWatcher(QObject *parent) | - | ||||||
| 71 | : QObject(*new QDBusServiceWatcherPrivate(QDBusConnection(QString()), WatchForOwnerChange), parent) | - | ||||||
| 72 | { | - | ||||||
| 73 | } | - | ||||||
| 74 | QDBusServiceWatcher::QDBusServiceWatcher(const QString &service, const QDBusConnection &connection, WatchMode watchMode, QObject *parent) | - | ||||||
| 75 | : QObject(*new QDBusServiceWatcherPrivate(connection, watchMode), parent) | - | ||||||
| 76 | { | - | ||||||
| 77 | d_func()->setConnection(QStringList() << service, connection, watchMode); | - | ||||||
| 78 | } | - | ||||||
| 79 | - | |||||||
| 80 | - | |||||||
| 81 | - | |||||||
| 82 | - | |||||||
| 83 | - | |||||||
| 84 | QDBusServiceWatcher::~QDBusServiceWatcher() | - | ||||||
| 85 | { | - | ||||||
| 86 | } | - | ||||||
| 87 | - | |||||||
| 88 | - | |||||||
| 89 | - | |||||||
| 90 | - | |||||||
| 91 | - | |||||||
| 92 | - | |||||||
| 93 | QStringList QDBusServiceWatcher::watchedServices() const | - | ||||||
| 94 | { | - | ||||||
| 95 | return d_func()->servicesWatched; | - | ||||||
| 96 | } | - | ||||||
| 97 | void QDBusServiceWatcher::setWatchedServices(const QStringList &services) | - | ||||||
| 98 | { | - | ||||||
| 99 | QDBusServiceWatcherPrivate * const d = d_func(); | - | ||||||
| 100 | if (services == d->servicesWatched) | - | ||||||
| 101 | return; | - | ||||||
| 102 | d->setConnection(services, d->connection, d->watchMode); | - | ||||||
| 103 | } | - | ||||||
| 104 | - | |||||||
| 105 | - | |||||||
| 106 | - | |||||||
| 107 | - | |||||||
| 108 | - | |||||||
| 109 | - | |||||||
| 110 | void QDBusServiceWatcher::addWatchedService(const QString &newService) | - | ||||||
| 111 | { | - | ||||||
| 112 | QDBusServiceWatcherPrivate * const d = d_func(); | - | ||||||
| 113 | if (d->servicesWatched.contains(newService)) | - | ||||||
| 114 | return; | - | ||||||
| 115 | d->addService(newService); | - | ||||||
| 116 | d->servicesWatched << newService; | - | ||||||
| 117 | } | - | ||||||
| 118 | bool QDBusServiceWatcher::removeWatchedService(const QString &service) | - | ||||||
| 119 | { | - | ||||||
| 120 | QDBusServiceWatcherPrivate * const d = d_func(); | - | ||||||
| 121 | d->removeService(service); | - | ||||||
| 122 | return d->servicesWatched.removeOne(service); | - | ||||||
| 123 | } | - | ||||||
| 124 | - | |||||||
| 125 | QDBusServiceWatcher::WatchMode QDBusServiceWatcher::watchMode() const | - | ||||||
| 126 | { | - | ||||||
| 127 | return d_func()->watchMode; | - | ||||||
| 128 | } | - | ||||||
| 129 | - | |||||||
| 130 | void QDBusServiceWatcher::setWatchMode(WatchMode mode) | - | ||||||
| 131 | { | - | ||||||
| 132 | QDBusServiceWatcherPrivate * const d = d_func(); | - | ||||||
| 133 | if (mode == d->watchMode) | - | ||||||
| 134 | return; | - | ||||||
| 135 | d->setConnection(d->servicesWatched, d->connection, mode); | - | ||||||
| 136 | } | - | ||||||
| 137 | - | |||||||
| 138 | - | |||||||
| 139 | - | |||||||
| 140 | - | |||||||
| 141 | - | |||||||
| 142 | - | |||||||
| 143 | QDBusConnection QDBusServiceWatcher::connection() const | - | ||||||
| 144 | { | - | ||||||
| 145 | return d_func()->connection; | - | ||||||
| 146 | } | - | ||||||
| 147 | void QDBusServiceWatcher::setConnection(const QDBusConnection &connection) | - | ||||||
| 148 | { | - | ||||||
| 149 | QDBusServiceWatcherPrivate * const d = d_func(); | - | ||||||
| 150 | if (connection.name() == d->connection.name()) | - | ||||||
| 151 | return; | - | ||||||
| 152 | d->setConnection(d->servicesWatched, connection, d->watchMode); | - | ||||||
| 153 | } | - | ||||||
| 154 | - | |||||||
| 155 | - | |||||||
| 156 | - | |||||||
| 157 | - | |||||||
| 158 | - | |||||||
| Switch to Source code | Preprocessed file |