| 313 | } |
| 314 | |
| 315 | bool PipeWireScreencap::open() |
| 316 | { |
| 317 | if (connected_) { |
| 318 | return true; |
| 319 | } |
| 320 | |
| 321 | // Clean up any stale state from a previous failed session |
| 322 | close_internal(); |
| 323 | |
| 324 | // Step 1: D-Bus handshake with xdg-desktop-portal. |
| 325 | // This includes CreateSession, SelectSources, and Start (which shows |
| 326 | // the KDE authorization dialog). Timeout is kStartResponseTimeoutSec. |
| 327 | if (!dbus_create_session() || !dbus_select_sources() || !dbus_start_stream()) { |
| 328 | // dbus_* methods already logged errors |
| 329 | close_internal(); |
| 330 | return false; |
| 331 | } |
| 332 | |
| 333 | // Step 2: Initialize PipeWire (connect core, create stream, connect) |
| 334 | if (!pw_init()) { |
| 335 | close_internal(); |
| 336 | return false; |
| 337 | } |
| 338 | |
| 339 | if (!pw_create_stream()) { |
| 340 | close_internal(); |
| 341 | return false; |
| 342 | } |
| 343 | |
| 344 | if (!pw_connect_stream(pipewire_node_id_)) { |
| 345 | close_internal(); |
| 346 | return false; |
| 347 | } |
| 348 | |
| 349 | connected_ = true; |
| 350 | return true; |
| 351 | } |
| 352 | |
| 353 | void PipeWireScreencap::close() |
| 354 | { |
nothing calls this directly
no outgoing calls
no test coverage detected