app/core/ProfileActivation.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QObject> | ||
| 4 | #include <QLocalServer> | ||
| 5 | #include <functional> | ||
| 6 | #include "ProfileLease.h" | ||
| 7 | |||
| 8 | // The lease remains the sole authority to open a profile. This bounded local | ||
| 9 | // channel only forwards desktop requests to that lease's already running owner. | ||
| 10 | class ProfileActivation final : public QObject { | ||
| 11 | public: | ||
| 12 | // The token is the xdg-activation capability of the forwarding process | ||
| 13 | // (empty on X11/tokenless launches); the owner uses it for the | ||
| 14 | // compositor focus request. | ||
| 15 | using Handler = std::function<bool(const QString &mailto, bool compose, | ||
| 16 | const QString &activationToken)>; | ||
| 17 | explicit ProfileActivation(QObject *parent = nullptr); | ||
| 18 | bool listen(const ProfileLease &lease, Handler handler); | ||
| 19 | static bool forward(const QString &profile, const QString &mailto, bool compose, | ||
| 20 | QString *error, int timeoutMs = 5000, | ||
| 21 | const QString &activationToken = {}); | ||
| 22 | static QString endpoint(const QString &profile); | ||
| 23 | 1 | QString error() const { return m_error; } | |
| 24 | private: | ||
| 25 | QLocalServer m_server; | ||
| 26 | Handler m_handler; | ||
| 27 | QString m_error; | ||
| 28 | int m_clients = 0; | ||
| 29 | }; | ||
| 30 |