378aee7ab1
* refactor: move ipc queue into its own class * refactor: move windows.h related functions to AW * refactor: make NM-Client methods static * refactor: json access * refactor: use struct initializer * refactor: move `handleMessage` to anon-namespace * refactor: clean-up includes * refactor: move action handler to functions * refactor: cleanup `handleSelect` * fix: cleanup clang-tidy warnings * chore: simplify json * revert: keep handlers as methods This is more readable and extensible. * fix: typo * fix: namespace * fix: rename define * refactor: `IpcQueue` to be simpler * fix: rename cmake option * fix: use variant when constructing * fix: make it a ref * fix: its a pair now
47 lines
843 B
C++
47 lines
843 B
C++
#pragma once
|
|
|
|
#include "common/Atomic.hpp"
|
|
|
|
#include <boost/optional.hpp>
|
|
#include <QString>
|
|
#include <QThread>
|
|
|
|
namespace chatterino {
|
|
|
|
class Application;
|
|
class Paths;
|
|
|
|
void registerNmHost(Paths &paths);
|
|
std::string &getNmQueueName(Paths &paths);
|
|
|
|
Atomic<boost::optional<QString>> &nmIpcError();
|
|
|
|
namespace nm::client {
|
|
|
|
void sendMessage(const QByteArray &array);
|
|
void writeToCout(const QByteArray &array);
|
|
|
|
} // namespace nm::client
|
|
|
|
class NativeMessagingServer final
|
|
{
|
|
public:
|
|
void start();
|
|
|
|
private:
|
|
class ReceiverThread : public QThread
|
|
{
|
|
public:
|
|
void run() override;
|
|
|
|
private:
|
|
void handleMessage(const QJsonObject &root);
|
|
void handleSelect(const QJsonObject &root);
|
|
void handleDetach(const QJsonObject &root);
|
|
};
|
|
|
|
ReceiverThread thread;
|
|
};
|
|
|
|
} // namespace chatterino
|