mirror of
https://github.com/NohamR/xovi-rmfakecloud.git
synced 2026-05-25 04:27:08 +00:00
Websocket support
This commit is contained in:
4
build.sh
4
build.sh
@@ -1,4 +1,6 @@
|
||||
set -euxo pipefail
|
||||
|
||||
python3 ../xovi/util/xovigen.py -o xovi.c -H xovi.h rmfakecloud.xovi
|
||||
$CC -shared -fPIC main.cpp xovi.c `pkg-config --cflags --libs Qt6Network` -o rmfakecloud.so
|
||||
python3 ../xovi/util/xovigen.py -o websocket-xovi.c -H websocket-xovi.h websocket.xovi
|
||||
$CC -shared -fPIC main.cpp xovi.c `pkg-config --cflags --libs Qt6Network` -o rmfakecloud.so
|
||||
$CC -shared -fPIC websocket.cpp websocket-xovi.c `pkg-config --cflags --libs Qt6Network Qt6WebSockets` -o rmfakecloud-websocket.so
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version 1.0.0
|
||||
|
||||
import? _ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice
|
||||
override _ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice
|
||||
override _ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice
|
||||
|
||||
92
websocket-xovi.c
Normal file
92
websocket-xovi.c
Normal file
@@ -0,0 +1,92 @@
|
||||
// This file is autogenerated. Please do not alter it manually and instead run xovigen.py.
|
||||
// XOVI extension / module base file
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef XOVI_PUBLIC_API
|
||||
#define XOVI_PUBLIC_API
|
||||
#define XOVI_VERSION "0.2.0"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define LP1_F_TYPE_EXPORT 1
|
||||
#define LP1_F_TYPE_IMPORT 2
|
||||
#define LP1_F_TYPE_OVERRIDE 3
|
||||
#define LP1_F_TYPE_CONDITION 4
|
||||
|
||||
#define METADATA_TYPE_INT 1
|
||||
#define METADATA_TYPE_BOOL 2
|
||||
#define METADATA_TYPE_STRING 3
|
||||
|
||||
typedef union {
|
||||
int i;
|
||||
bool b;
|
||||
struct {
|
||||
int sLength;
|
||||
const char *s;
|
||||
};
|
||||
} XoviMetadataValue;
|
||||
|
||||
struct XoviMetadataEntry {
|
||||
const char *name;
|
||||
char type;
|
||||
XoviMetadataValue value;
|
||||
};
|
||||
|
||||
// Public version of the metadata iterator.
|
||||
struct ExtensionMetadataIterator {
|
||||
const char *extensionName;
|
||||
const char *functionName;
|
||||
void *functionAddress;
|
||||
char OPAQUE[sizeof(void *) * 4 + sizeof(bool)];
|
||||
};
|
||||
|
||||
struct XoViEnvironment {
|
||||
char *(*getExtensionDirectory)(const char *family);
|
||||
void (*requireExtension)(const char *name, unsigned char major, unsigned char minor, unsigned char patch);
|
||||
|
||||
// 0.2.0 API - metadata:
|
||||
int (*getExtensionCount)();
|
||||
int (*getExtensionNames)(const char **table, int maxCount);
|
||||
int (*getExtensionFunctionCount)(const char *key);
|
||||
int (*getExtensionFunctionNames)(const char *extension, const char **table, int maxCount);
|
||||
|
||||
int (*getMetadataEntriesCountForFunction)(const char *extension, const char *function, int functionType);
|
||||
struct XoviMetadataEntry **(*getMetadataChainForFunction)(const char *extension, const char *function, int functionType);
|
||||
struct XoviMetadataEntry *(*getMetadataEntryForFunction)(const char *extension, const char *function, int functionType, const char *metadataEntryName);
|
||||
|
||||
void (*createMetadataSearchingIterator)(struct ExtensionMetadataIterator *iterator, const char *metadataEntryName);
|
||||
struct XoviMetadataEntry *(*nextFunctionMetadataEntry)(struct ExtensionMetadataIterator *iterator);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
// Deps
|
||||
extern void override$_ZN10QWebSocket4openERK15QNetworkRequest();
|
||||
|
||||
// XOVI metadata
|
||||
__attribute__((section(".xovi"))) const char *LINKTABLENAMES = "C_ZN10QWebSocket4openERK15QNetworkRequest\0I_ZN10QWebSocket4openERK15QNetworkRequest\0O_ZN10QWebSocket4openERK15QNetworkRequest\0\0";
|
||||
__attribute__((section(".xovi"))) const void *LINKTABLEVALUES[] = { (void *) 3, (void *) 0, (void *) 0, (void *) override$_ZN10QWebSocket4openERK15QNetworkRequest };
|
||||
__attribute__((section(".xovi"))) const void *Environment = 0;
|
||||
__attribute__((section(".xovi_info"))) const int EXTENSIONVERSION = 65536;
|
||||
|
||||
__attribute__((section(".xovi_info"))) const char __XOVIMETADATANAMES[] = "";
|
||||
|
||||
// Raw Metadata Entries
|
||||
|
||||
|
||||
// Metadata Chains
|
||||
|
||||
|
||||
// Main metadata list
|
||||
__attribute__((section(".xovi"))) const struct XoviMetadataEntry **METADATAVALUES[] = {
|
||||
(const struct XoviMetadataEntry **) 0,
|
||||
(const struct XoviMetadataEntry **) 0,
|
||||
(const struct XoviMetadataEntry **) 0,
|
||||
(const struct XoviMetadataEntry **) 0, (const struct XoviMetadataEntry **) 1
|
||||
};
|
||||
|
||||
// Resources
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
78
websocket-xovi.h
Normal file
78
websocket-xovi.h
Normal file
@@ -0,0 +1,78 @@
|
||||
// XOVI project import / resource header file. This file is autogenerated. Do not edit.
|
||||
#ifndef _XOVIGEN
|
||||
#define _XOVIGEN
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef XOVI_PUBLIC_API
|
||||
#define XOVI_PUBLIC_API
|
||||
#define XOVI_VERSION "0.2.0"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define LP1_F_TYPE_EXPORT 1
|
||||
#define LP1_F_TYPE_IMPORT 2
|
||||
#define LP1_F_TYPE_OVERRIDE 3
|
||||
#define LP1_F_TYPE_CONDITION 4
|
||||
|
||||
#define METADATA_TYPE_INT 1
|
||||
#define METADATA_TYPE_BOOL 2
|
||||
#define METADATA_TYPE_STRING 3
|
||||
|
||||
typedef union {
|
||||
int i;
|
||||
bool b;
|
||||
struct {
|
||||
int sLength;
|
||||
const char *s;
|
||||
};
|
||||
} XoviMetadataValue;
|
||||
|
||||
struct XoviMetadataEntry {
|
||||
const char *name;
|
||||
char type;
|
||||
XoviMetadataValue value;
|
||||
};
|
||||
|
||||
// Public version of the metadata iterator.
|
||||
struct ExtensionMetadataIterator {
|
||||
const char *extensionName;
|
||||
const char *functionName;
|
||||
void *functionAddress;
|
||||
char OPAQUE[sizeof(void *) * 4 + sizeof(bool)];
|
||||
};
|
||||
|
||||
struct XoViEnvironment {
|
||||
char *(*getExtensionDirectory)(const char *family);
|
||||
void (*requireExtension)(const char *name, unsigned char major, unsigned char minor, unsigned char patch);
|
||||
|
||||
// 0.2.0 API - metadata:
|
||||
int (*getExtensionCount)();
|
||||
int (*getExtensionNames)(const char **table, int maxCount);
|
||||
int (*getExtensionFunctionCount)(const char *key);
|
||||
int (*getExtensionFunctionNames)(const char *extension, const char **table, int maxCount);
|
||||
|
||||
int (*getMetadataEntriesCountForFunction)(const char *extension, const char *function, int functionType);
|
||||
struct XoviMetadataEntry **(*getMetadataChainForFunction)(const char *extension, const char *function, int functionType);
|
||||
struct XoviMetadataEntry *(*getMetadataEntryForFunction)(const char *extension, const char *function, int functionType, const char *metadataEntryName);
|
||||
|
||||
void (*createMetadataSearchingIterator)(struct ExtensionMetadataIterator *iterator, const char *metadataEntryName);
|
||||
struct XoviMetadataEntry *(*nextFunctionMetadataEntry)(struct ExtensionMetadataIterator *iterator);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
extern const void *LINKTABLEVALUES[];
|
||||
|
||||
// Imports
|
||||
#define $_ZN10QWebSocket4openERK15QNetworkRequest ((unsigned long long int (*)()) LINKTABLEVALUES[2])
|
||||
|
||||
// Resources
|
||||
|
||||
|
||||
// Environment
|
||||
extern const struct XoViEnvironment *Environment;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
42
websocket.cpp
Normal file
42
websocket.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
#include <QWebSocket>
|
||||
#include "websocket-xovi.h"
|
||||
|
||||
extern "C" void override$_ZN10QWebSocket4openERK15QNetworkRequest(
|
||||
QWebSocket* self,
|
||||
const QNetworkRequest& req
|
||||
) {
|
||||
const char* host = std::getenv("RMFAKECLOUD_HOST");
|
||||
|
||||
// set new url
|
||||
QUrl newUrl = req.url();
|
||||
newUrl.setHost(QString(host));
|
||||
|
||||
// create a new request, so we don't have to modify the original request
|
||||
QNetworkRequest newReq(req);
|
||||
newReq.setUrl(newUrl);
|
||||
|
||||
// get original function signature
|
||||
using CreateFn = void*(*)(QWebSocket*,
|
||||
const QNetworkRequest&);
|
||||
CreateFn orig = reinterpret_cast<CreateFn>(
|
||||
$_ZN10QWebSocket4openERK15QNetworkRequest
|
||||
);
|
||||
|
||||
// call original function, and return the result
|
||||
orig(self, newReq);
|
||||
}
|
||||
|
||||
extern "C" void _xovi_construct() {
|
||||
const char* host = std::getenv("RMFAKECLOUD_HOST");
|
||||
if (host == NULL) {
|
||||
qCritical() << "[rmfakecloud-websocket] Environment variable \"RMFAKECLOUD_HOST\" not set!";
|
||||
abort();
|
||||
}
|
||||
|
||||
qDebug() << "Loading rmfakecloud-websocket by Tiebe. Using host " << host;
|
||||
}
|
||||
4
websocket.xovi
Normal file
4
websocket.xovi
Normal file
@@ -0,0 +1,4 @@
|
||||
version 1.0.0
|
||||
|
||||
import? _ZN10QWebSocket4openERK15QNetworkRequest
|
||||
override _ZN10QWebSocket4openERK15QNetworkRequest
|
||||
Reference in New Issue
Block a user