mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
disabled default native messaging registry key installation
This commit is contained in:
parent
444242f3fe
commit
0d2f0b3890
37
src/main.cpp
37
src/main.cpp
|
@ -1,5 +1,7 @@
|
|||
#include "application.hpp"
|
||||
#include "singletons/nativemessagingmanager.hpp"
|
||||
#include "singletons/pathmanager.hpp"
|
||||
#include "util/networkmanager.hpp"
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QApplication>
|
||||
|
@ -7,20 +9,17 @@
|
|||
#include <QLibrary>
|
||||
#include <QStringList>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "util/networkmanager.hpp"
|
||||
|
||||
#ifdef USEWINSDK
|
||||
#include "util/nativeeventhelper.hpp"
|
||||
#endif
|
||||
|
||||
#include "fstream"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "fcntl.h"
|
||||
#include "io.h"
|
||||
#include "stdio.h"
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
void runNativeMessagingHost();
|
||||
|
@ -90,15 +89,6 @@ int runGui(int argc, char *argv[])
|
|||
_exit(0);
|
||||
}
|
||||
|
||||
void writeByteArray(QByteArray a)
|
||||
{
|
||||
char *data = a.data();
|
||||
uint32_t size;
|
||||
size = a.size();
|
||||
std::cout.write(reinterpret_cast<char *>(&size), 4);
|
||||
std::cout.write(data, a.size());
|
||||
}
|
||||
|
||||
void runNativeMessagingHost()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -106,7 +96,9 @@ void runNativeMessagingHost()
|
|||
_setmode(_fileno(stdout), _O_BINARY);
|
||||
#endif
|
||||
|
||||
// std::ofstream xd("C:\\users\\daniel\\desktop\\xd.lmao");
|
||||
std::ofstream xD("C:\Users\daniel\Desktop\1");
|
||||
|
||||
auto &nmm = chatterino::singletons::NativeMessagingManager::getInstance();
|
||||
|
||||
while (true) {
|
||||
char size_c[4];
|
||||
|
@ -122,11 +114,12 @@ void runNativeMessagingHost()
|
|||
std::cin.read(b, size);
|
||||
*(b + size) = '\0';
|
||||
|
||||
// xd << b;
|
||||
// xd.flush();
|
||||
nmm.writeByteArray("{\"a\":1}");
|
||||
|
||||
nmm.sendToGuiProcess(QByteArray(b, size));
|
||||
|
||||
nmm.writeByteArray("{\"a\":2}");
|
||||
|
||||
free(b);
|
||||
|
||||
// writeByteArray(QString("{\"xd\":1}").toUtf8());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,14 @@
|
|||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
//#ifdef USEWINSDK
|
||||
//#include <windows.h>
|
||||
//#pragma comment(lib, "Advapi32.lib")
|
||||
//#endif
|
||||
|
||||
#include <boost/interprocess/ipc/message_queue.hpp>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QProcess>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define EXTENSION_ID "aeicjepmjkgmbeohnchmpfjbpchogmjn"
|
||||
#define MESSAGE_SIZE 1024
|
||||
|
||||
|
@ -37,6 +34,16 @@ NativeMessagingManager &NativeMessagingManager::getInstance()
|
|||
return manager;
|
||||
}
|
||||
|
||||
void NativeMessagingManager::writeByteArray(QByteArray a)
|
||||
{
|
||||
char *data = a.data();
|
||||
uint32_t size;
|
||||
size = a.size();
|
||||
std::cout.write(reinterpret_cast<char *>(&size), 4);
|
||||
std::cout.write(data, a.size());
|
||||
std::cout.flush();
|
||||
}
|
||||
|
||||
void NativeMessagingManager::registerHost()
|
||||
{
|
||||
// create manifest
|
||||
|
@ -61,11 +68,13 @@ void NativeMessagingManager::registerHost()
|
|||
file.write(document.toJson());
|
||||
file.flush();
|
||||
|
||||
#ifdef XD
|
||||
#ifdef Q_OS_WIN
|
||||
// clang-format off
|
||||
QProcess::execute("REG ADD \"HKCU\\Software\\Google\\Chrome\\NativeMessagingHosts\\com.chatterino.chatterino\" /ve /t REG_SZ /d \"" + manifestPath + "\" /f");
|
||||
// clang-format on
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeMessagingManager::openGuiMessageQueue()
|
||||
|
@ -86,7 +95,7 @@ void NativeMessagingManager::sendToGuiProcess(const QByteArray &array)
|
|||
try {
|
||||
messageQueue.try_send(array.data(), array.size(), 1);
|
||||
} catch (ipc::interprocess_exception &ex) {
|
||||
// rip
|
||||
qDebug() << "send to gui process:" << ex.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +116,7 @@ void NativeMessagingManager::ReceiverThread::run()
|
|||
QString text = QString::fromUtf8(buf, retSize);
|
||||
qDebug() << text;
|
||||
} catch (ipc::interprocess_exception &ex) {
|
||||
// rip
|
||||
qDebug() << "received from gui process:" << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
void run() override;
|
||||
};
|
||||
|
||||
void writeByteArray(QByteArray a);
|
||||
void registerHost();
|
||||
void openGuiMessageQueue();
|
||||
void sendToGuiProcess(const QByteArray &array);
|
||||
|
|
Loading…
Reference in a new issue