mirror of
https://github.com/NohamR/xovi-rmfakecloud.git
synced 2026-08-01 18:39:39 +00:00
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
#define NAME "rmfakecloud"
|
|
#include <QSettings>
|
|
#include <QFile>
|
|
#include <QVariant>
|
|
#include <iostream>
|
|
#include "../xovi-tokenstore.h"
|
|
|
|
extern "C" {
|
|
static QSettings *tokenStorage;
|
|
void _xovi_construct() {
|
|
char *configRoot = Environment->getExtensionDirectory(NAME);
|
|
|
|
// Prepare the token storage (leak object)
|
|
QString tokenFile(configRoot);
|
|
tokenFile += "tokens.conf";
|
|
tokenStorage = new QSettings(tokenFile, QSettings::IniFormat);
|
|
|
|
free(configRoot);
|
|
}
|
|
|
|
static inline bool checkKey(void **that, QAnyStringView &key) {
|
|
if(key == "devicetoken" || key == "UserToken") {
|
|
*that = tokenStorage;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
QVariant override$_ZNK9QSettings5valueE14QAnyStringView(void *that, QAnyStringView key) {
|
|
checkKey(&that, key);
|
|
return $_ZNK9QSettings5valueE14QAnyStringView(that, key);
|
|
}
|
|
|
|
QVariant override$_ZNK9QSettings5valueE14QAnyStringViewRK8QVariant(void *that, QAnyStringView key, const QVariant &defaultValue) {
|
|
checkKey(&that, key);
|
|
return $_ZNK9QSettings5valueE14QAnyStringViewRK8QVariant(that, key, defaultValue);
|
|
}
|
|
|
|
void override$_ZN9QSettings8setValueE14QAnyStringViewRK8QVariant(void *that, QAnyStringView key, const QVariant &value) {
|
|
bool sync = checkKey(&that, key);
|
|
$_ZN9QSettings8setValueE14QAnyStringViewRK8QVariant(that, key, value);
|
|
if(sync) {
|
|
tokenStorage->sync();
|
|
}
|
|
}
|
|
}
|