testing arrpc server
This commit is contained in:
parent
b5435acdd8
commit
3540774c82
8 changed files with 5696 additions and 4 deletions
5635
assets/arrpc.js
Normal file
5635
assets/arrpc.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,8 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource>
|
<qresource>
|
||||||
<file>assets/userscript.js</file>
|
<file>assets/userscript.js</file>
|
||||||
<file>assets/bridge_mod.js</file>
|
<file>assets/arrpc_bridge_mod.js</file>
|
||||||
|
<file>assets/arrpc.js</file>
|
||||||
<file>assets/de.shorsh.discord-screenaudio.png</file>
|
<file>assets/de.shorsh.discord-screenaudio.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
36
scripts/build_arrpc.sh
Executable file
36
scripts/build_arrpc.sh
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "$0")/../submodules"
|
||||||
|
|
||||||
|
echo_status() {
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "-> $1..."
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -d "arrpc" ]; then
|
||||||
|
echo_status "Cloning arRPC"
|
||||||
|
git clone https://github.com/OpenAsar/arrpc.git
|
||||||
|
cd arrpc
|
||||||
|
else
|
||||||
|
echo_status "Fetching arRPC changes"
|
||||||
|
cd arrpc
|
||||||
|
git fetch
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo_status "Checking out latest commit"
|
||||||
|
git reset --hard HEAD
|
||||||
|
git checkout main
|
||||||
|
|
||||||
|
echo_status "Installing dependencies"
|
||||||
|
pnpm i -D @vercel/ncc
|
||||||
|
|
||||||
|
echo_status "Patching arRPC"
|
||||||
|
sed -i 's/"type": "module",//' package.json
|
||||||
|
|
||||||
|
echo_status "Building arRPC"
|
||||||
|
pnpm exec ncc build src/index.js
|
||||||
|
|
||||||
|
echo_status "Copying built file"
|
||||||
|
cp -v ./dist/index.js ../../assets/arrpc.js
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
#include <QTemporaryFile>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWebChannel>
|
#include <QWebChannel>
|
||||||
#include <QWebEngineScript>
|
#include <QWebEngineScript>
|
||||||
|
@ -35,11 +36,9 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
|
||||||
|
|
||||||
injectFile(&DiscordPage::injectScript, "userscript.js",
|
injectFile(&DiscordPage::injectScript, "userscript.js",
|
||||||
":/assets/userscript.js");
|
":/assets/userscript.js");
|
||||||
|
|
||||||
injectFile(&DiscordPage::injectScript, "bridge_mod.js",
|
|
||||||
":/assets/bridge_mod.js");
|
|
||||||
|
|
||||||
setupUserStyles();
|
setupUserStyles();
|
||||||
|
setupArrpc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiscordPage::setupPermissions() {
|
void DiscordPage::setupPermissions() {
|
||||||
|
@ -294,3 +293,19 @@ void DiscordPage::javaScriptConsoleMessage(
|
||||||
}
|
}
|
||||||
|
|
||||||
UserScript *DiscordPage::userScript() { return &m_userScript; }
|
UserScript *DiscordPage::userScript() { return &m_userScript; }
|
||||||
|
|
||||||
|
void DiscordPage::setupArrpc() {
|
||||||
|
QFile nodejs("/usr/bin/node");
|
||||||
|
if (nodejs.exists()) {
|
||||||
|
auto arrpcSource = QTemporaryFile::createNativeFile(":/assets/arrpc.js");
|
||||||
|
qDebug(mainLog).noquote()
|
||||||
|
<< "NodeJS found, starting arRPC located at" << arrpcSource->fileName();
|
||||||
|
m_arrpcProcess.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
|
m_arrpcProcess.setProgram(nodejs.fileName());
|
||||||
|
m_arrpcProcess.setArguments(QStringList{arrpcSource->fileName()});
|
||||||
|
m_arrpcProcess.start();
|
||||||
|
|
||||||
|
injectFile(&DiscordPage::injectScript, "arrpc_bridge_mod.js",
|
||||||
|
":/assets/arrpc_bridge_mod.js");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QProcess>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QWebEngineFullScreenRequest>
|
#include <QWebEngineFullScreenRequest>
|
||||||
#include <QWebEnginePage>
|
#include <QWebEnginePage>
|
||||||
|
@ -22,10 +23,12 @@ private:
|
||||||
QFile *m_userStylesFile;
|
QFile *m_userStylesFile;
|
||||||
QString m_userStylesContent;
|
QString m_userStylesContent;
|
||||||
QNetworkAccessManager m_networkAccessManager;
|
QNetworkAccessManager m_networkAccessManager;
|
||||||
|
QProcess m_arrpcProcess;
|
||||||
const QDir m_configLocation =
|
const QDir m_configLocation =
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||||
void setupPermissions();
|
void setupPermissions();
|
||||||
void setupUserStyles();
|
void setupUserStyles();
|
||||||
|
void setupArrpc();
|
||||||
void fetchUserStyles();
|
void fetchUserStyles();
|
||||||
bool acceptNavigationRequest(const QUrl &url,
|
bool acceptNavigationRequest(const QUrl &url,
|
||||||
QWebEnginePage::NavigationType type,
|
QWebEnginePage::NavigationType type,
|
||||||
|
|
1
submodules/arrpc
Submodule
1
submodules/arrpc
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 32b20feb2c994942a9de72b183ab0f4881c725c3
|
1
submodules/channel
Submodule
1
submodules/channel
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6977815409b4c3c02d74a7aee3fc29f01d632feb
|
Loading…
Reference in a new issue