| 142 | } |
| 143 | |
| 144 | void MIDebuggerPlugin::setupDBus() |
| 145 | { |
| 146 | auto serviceRegistered = [this](const QString& service) { |
| 147 | if (m_drkonqis.contains(service)) |
| 148 | return; |
| 149 | // New registration |
| 150 | const QString name = i18n("KDevelop (%1) - %2", m_displayName, core()->activeSession()->name()); |
| 151 | auto drkonqiProxy = new DBusProxy(service, name, this); |
| 152 | m_drkonqis.insert(service, drkonqiProxy); |
| 153 | connect(drkonqiProxy->interface(), SIGNAL(acceptDebuggingApplication(QString)), |
| 154 | drkonqiProxy, SLOT(debuggerAccepted(QString))); |
| 155 | connect(drkonqiProxy, &DBusProxy::debugProcess, |
| 156 | this, &MIDebuggerPlugin::slotDebugExternalProcess); |
| 157 | |
| 158 | drkonqiProxy->interface()->call(QStringLiteral("registerDebuggingApplication"), name, QCoreApplication::applicationPid()); |
| 159 | }; |
| 160 | auto serviceUnregistered = [this](const QString& service) { |
| 161 | // Deregistration |
| 162 | if (auto* proxy = m_drkonqis.take(service)) { |
| 163 | proxy->Invalidate(); |
| 164 | delete proxy; |
| 165 | } |
| 166 | }; |
| 167 | |
| 168 | m_watcher = new QDBusServiceWatcher(QStringLiteral("org.kde.drkonqi*"), QDBusConnection::sessionBus(), |
| 169 | QDBusServiceWatcher::WatchForOwnerChange, this); |
| 170 | connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, serviceRegistered); |
| 171 | connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, serviceUnregistered); |
| 172 | |
| 173 | auto registeredServiceNames = QDBusConnection::sessionBus().interface()->registeredServiceNames(); |
| 174 | if (!registeredServiceNames.isValid()) { |
| 175 | return; |
| 176 | } |
| 177 | for (const auto &serviceName : registeredServiceNames.value()) { |
| 178 | if (serviceName.startsWith(QStringLiteral("org.kde.drkonqi."))) { |
| 179 | serviceRegistered(serviceName); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | void MIDebuggerPlugin::unload() |
| 185 | { |
nothing calls this directly
no test coverage detected