2018-08-08 23:54:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include "ipc.hpp"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IPC response including type of IPC response, size of payload and the json
|
|
|
|
* encoded payload string.
|
|
|
|
*/
|
|
|
|
struct ipc_response {
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t type;
|
|
|
|
std::string payload;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the path to the IPC socket from sway.
|
|
|
|
*/
|
2018-08-16 14:29:41 +02:00
|
|
|
std::string getSocketPath(void);
|
2018-08-08 23:54:58 +02:00
|
|
|
/**
|
|
|
|
* Opens the sway socket.
|
|
|
|
*/
|
2018-08-16 14:29:41 +02:00
|
|
|
int ipcOpenSocket(const std::string &socketPath);
|
2018-08-08 23:54:58 +02:00
|
|
|
/**
|
|
|
|
* Issues a single IPC command and returns the buffer. len will be updated with
|
|
|
|
* the length of the buffer returned from sway.
|
|
|
|
*/
|
2018-08-16 14:29:41 +02:00
|
|
|
std::string ipcSingleCommand(int socketfd, uint32_t type, const char *payload, uint32_t *len);
|
2018-08-08 23:54:58 +02:00
|
|
|
/**
|
|
|
|
* Receives a single IPC response and returns an ipc_response.
|
|
|
|
*/
|
2018-08-16 14:29:41 +02:00
|
|
|
struct ipc_response ipcRecvResponse(int socketfd);
|