Formatting the code.

This commit is contained in:
Louis-Bertrand Varin 2018-03-31 16:01:30 -04:00
parent 74efc57369
commit 8324d03f0a
294 changed files with 3796 additions and 3740 deletions

17
src/proxy/NativeMessagingHost.cpp Executable file → Normal file
View file

@ -15,20 +15,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QCoreApplication>
#include "NativeMessagingHost.h"
#include <QCoreApplication>
NativeMessagingHost::NativeMessagingHost() : NativeMessagingBase()
NativeMessagingHost::NativeMessagingHost()
: NativeMessagingBase()
{
m_localSocket = new QLocalSocket();
m_localSocket->connectToServer(getLocalServerPath());
#ifdef Q_OS_WIN
m_running.store(true);
m_future = QtConcurrent::run(this, static_cast<void(NativeMessagingHost::*)()>(&NativeMessagingHost::readNativeMessages));
m_future =
QtConcurrent::run(this, static_cast<void (NativeMessagingHost::*)()>(&NativeMessagingHost::readNativeMessages));
#endif
connect(m_localSocket, SIGNAL(readyRead()), this, SLOT(newLocalMessage()));
connect(m_localSocket, SIGNAL(disconnected()), this, SLOT(deleteSocket()));
connect(m_localSocket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)), this, SLOT(socketStateChanged(QLocalSocket::LocalSocketState)));
connect(m_localSocket,
SIGNAL(stateChanged(QLocalSocket::LocalSocketState)),
this,
SLOT(socketStateChanged(QLocalSocket::LocalSocketState)));
}
NativeMessagingHost::~NativeMessagingHost()
@ -45,7 +50,7 @@ void NativeMessagingHost::readLength()
if (!std::cin.eof() && length > 0) {
readStdIn(length);
} else {
QCoreApplication::quit();
QCoreApplication::quit();
}
}
@ -81,7 +86,7 @@ void NativeMessagingHost::newLocalMessage()
QByteArray arr = m_localSocket->readAll();
if (!arr.isEmpty()) {
sendReply(arr);
sendReply(arr);
}
}

2
src/proxy/NativeMessagingHost.h Executable file → Normal file
View file

@ -37,7 +37,7 @@ private:
void readStdIn(const quint32 length);
private:
QLocalSocket* m_localSocket;
QLocalSocket* m_localSocket;
};
#endif // NATIVEMESSAGINGHOST_H

View file

@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "NativeMessagingHost.h"
#include <QCoreApplication>
#include <iostream>
#include "NativeMessagingHost.h"
#ifndef Q_OS_WIN
#include <initializer_list>
@ -26,13 +26,15 @@
#include <unistd.h>
// (C) Gist: https://gist.github.com/azadkuh/a2ac6869661ebd3f8588
void ignoreUnixSignals(std::initializer_list<int> ignoreSignals) {
void ignoreUnixSignals(std::initializer_list<int> ignoreSignals)
{
for (int sig : ignoreSignals) {
signal(sig, SIG_IGN);
}
}
void catchUnixSignals(std::initializer_list<int> quitSignals) {
void catchUnixSignals(std::initializer_list<int> quitSignals)
{
auto handler = [](int sig) -> void {
std::cerr << sig;
QCoreApplication::quit();
@ -46,8 +48,8 @@ void catchUnixSignals(std::initializer_list<int> quitSignals) {
struct sigaction sa;
sa.sa_handler = handler;
sa.sa_mask = blocking_mask;
sa.sa_flags = 0;
sa.sa_mask = blocking_mask;
sa.sa_flags = 0;
for (auto sig : quitSignals) {
sigaction(sig, &sa, nullptr);
@ -55,7 +57,7 @@ void catchUnixSignals(std::initializer_list<int> quitSignals) {
}
#endif
int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX)