Refactor import config
Remove the path filter, as the content path may not contain a filename. Disable import when viewing files. Config can be imported from: - shared file - shared text - vpn:// link
This commit is contained in:
parent
1576aed1ea
commit
195bdb947e
7 changed files with 109 additions and 171 deletions
|
@ -77,14 +77,9 @@ AndroidController::AndroidController() : QObject()
|
|||
|
||||
connect(
|
||||
this, &AndroidController::configImported, this,
|
||||
[]() {
|
||||
// todo: not yet implemented
|
||||
qDebug() << "Transact: config import";
|
||||
/*auto doc = QJsonDocument::fromJson(parcelBody.toUtf8());
|
||||
|
||||
QString buffer = doc.object()["config"].toString();
|
||||
qDebug() << "Transact: config string" << buffer;
|
||||
importConfigFromOutside(buffer);*/
|
||||
[this](const QString& config) {
|
||||
qDebug() << "Android event: config import";
|
||||
emit importConfigFromOutside(config);
|
||||
},
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
@ -111,7 +106,7 @@ bool AndroidController::initialize()
|
|||
{"onVpnDisconnected", "()V", reinterpret_cast<void *>(onVpnDisconnected)},
|
||||
{"onVpnReconnecting", "()V", reinterpret_cast<void *>(onVpnReconnecting)},
|
||||
{"onStatisticsUpdate", "(JJ)V", reinterpret_cast<void *>(onStatisticsUpdate)},
|
||||
{"onConfigImported", "()V", reinterpret_cast<void *>(onConfigImported)},
|
||||
{"onConfigImported", "(Ljava/lang/String;)V", reinterpret_cast<void *>(onConfigImported)},
|
||||
{"decodeQrCode", "(Ljava/lang/String;)Z", reinterpret_cast<bool *>(decodeQrCode)}
|
||||
};
|
||||
|
||||
|
@ -290,12 +285,20 @@ void AndroidController::onStatisticsUpdate(JNIEnv *env, jobject thiz, jlong rxBy
|
|||
}
|
||||
|
||||
// static
|
||||
void AndroidController::onConfigImported(JNIEnv *env, jobject thiz)
|
||||
void AndroidController::onConfigImported(JNIEnv *env, jobject thiz, jstring data)
|
||||
{
|
||||
Q_UNUSED(env);
|
||||
Q_UNUSED(thiz);
|
||||
|
||||
emit AndroidController::instance()->configImported();
|
||||
const char *buffer = env->GetStringUTFChars(data, nullptr);
|
||||
if (!buffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString config(buffer);
|
||||
env->ReleaseStringUTFChars(data, buffer);
|
||||
|
||||
emit AndroidController::instance()->configImported(config);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -43,8 +43,8 @@ signals:
|
|||
void vpnDisconnected();
|
||||
void vpnReconnecting();
|
||||
void statisticsUpdated(quint64 rxBytes, quint64 txBytes);
|
||||
void configImported();
|
||||
void importConfigFromOutside(QString &data);
|
||||
void configImported(QString config);
|
||||
void importConfigFromOutside(QString config);
|
||||
void initConnectionState(Vpn::ConnectionState state);
|
||||
|
||||
private:
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
static void onVpnDisconnected(JNIEnv *env, jobject thiz);
|
||||
static void onVpnReconnecting(JNIEnv *env, jobject thiz);
|
||||
static void onStatisticsUpdate(JNIEnv *env, jobject thiz, jlong rxBytes, jlong txBytes);
|
||||
static void onConfigImported(JNIEnv *env, jobject thiz);
|
||||
static void onConfigImported(JNIEnv *env, jobject thiz, jstring data);
|
||||
static bool decodeQrCode(JNIEnv *env, jobject thiz, jstring data);
|
||||
|
||||
template <typename Ret, typename ...Args>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue