mirror of
https://github.com/NohamR/xovi-rmfakecloud.git
synced 2026-05-26 13:52:44 +00:00
Code
This commit is contained in:
6
build.sh
Executable file
6
build.sh
Executable file
@@ -0,0 +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
|
||||||
|
|
||||||
|
scp rmfakecloud.so rm:xovi/extensions.d/
|
||||||
45
main.cpp
Normal file
45
main.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QIODevice>
|
||||||
|
#include "xovi.h"
|
||||||
|
|
||||||
|
extern "C" QNetworkReply* override$_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice(
|
||||||
|
QNetworkAccessManager* self,
|
||||||
|
QNetworkAccessManager::Operation op,
|
||||||
|
const QNetworkRequest& req,
|
||||||
|
QIODevice* outgoingData
|
||||||
|
) {
|
||||||
|
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 = QNetworkReply*(*)(QNetworkAccessManager*,
|
||||||
|
QNetworkAccessManager::Operation,
|
||||||
|
const QNetworkRequest&,
|
||||||
|
QIODevice*);
|
||||||
|
CreateFn orig = reinterpret_cast<CreateFn>(
|
||||||
|
$_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice
|
||||||
|
);
|
||||||
|
|
||||||
|
// call original function, and return the result
|
||||||
|
return orig(self, op, newReq, outgoingData);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void _xovi_construct() {
|
||||||
|
const char* host = std::getenv("RMFAKECLOUD_HOST");
|
||||||
|
if (host == NULL) {
|
||||||
|
qCritical() << "[rmfakecloud] Environment variable \"RMFAKECLOUD_HOST\" not set!";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Loading rmfakecloud by Tiebe. Using host " <<
|
||||||
|
}
|
||||||
4
rmfakecloud.xovi
Normal file
4
rmfakecloud.xovi
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
version 1.0.0
|
||||||
|
|
||||||
|
import? _ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice
|
||||||
|
override _ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice
|
||||||
92
xovi.c
Normal file
92
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$_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice();
|
||||||
|
|
||||||
|
// XOVI metadata
|
||||||
|
__attribute__((section(".xovi"))) const char *LINKTABLENAMES = "C_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice\0I_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice\0O_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice\0\0";
|
||||||
|
__attribute__((section(".xovi"))) const void *LINKTABLEVALUES[] = { (void *) 3, (void *) 0, (void *) 0, (void *) override$_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice };
|
||||||
|
__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
xovi.h
Normal file
78
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 $_ZN21QNetworkAccessManager13createRequestENS_9OperationERK15QNetworkRequestP9QIODevice ((unsigned long long int (*)()) LINKTABLEVALUES[2])
|
||||||
|
|
||||||
|
// Resources
|
||||||
|
|
||||||
|
|
||||||
|
// Environment
|
||||||
|
extern const struct XoViEnvironment *Environment;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user