added import backup file from outside for ios
This commit is contained in:
parent
e2aef1fc1d
commit
4ae608ed93
10 changed files with 157 additions and 111 deletions
|
|
@ -117,6 +117,11 @@ void AmneziaApplication::init()
|
||||||
&ImportController::extractConfigFromData);
|
&ImportController::extractConfigFromData);
|
||||||
connect(IosController::Instance(), &IosController::importConfigFromOutside, m_pageController.get(),
|
connect(IosController::Instance(), &IosController::importConfigFromOutside, m_pageController.get(),
|
||||||
&PageController::goToPageViewConfig);
|
&PageController::goToPageViewConfig);
|
||||||
|
|
||||||
|
connect(IosController::Instance(), &IosController::importBackupFromOutside, m_pageController.get(),
|
||||||
|
&PageController::goToPageSettingsBackup);
|
||||||
|
connect(IosController::Instance(), &IosController::importBackupFromOutside, m_settingsController.get(),
|
||||||
|
&SettingsController::importBackupFromOutside);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_notificationHandler.reset(NotificationHandler::create(nullptr));
|
m_notificationHandler.reset(NotificationHandler::create(nullptr));
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,15 @@
|
||||||
QString filePath(url.path.UTF8String);
|
QString filePath(url.path.UTF8String);
|
||||||
if (filePath.isEmpty()) return NO;
|
if (filePath.isEmpty()) return NO;
|
||||||
|
|
||||||
|
if (filePath.contains("backup")) {
|
||||||
|
IosController::Instance()->importBackupFromOutside(filePath);
|
||||||
|
} else {
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
bool isOpenFile = file.open(QIODevice::ReadOnly);
|
bool isOpenFile = file.open(QIODevice::ReadOnly);
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
|
|
||||||
IosController::Instance()->importConfigFromOutside(QString(data));
|
IosController::Instance()->importConfigFromOutside(QString(data));
|
||||||
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
using namespace amnezia;
|
using namespace amnezia;
|
||||||
|
|
||||||
struct Action {
|
struct Action
|
||||||
|
{
|
||||||
static const char *start;
|
static const char *start;
|
||||||
static const char *restart;
|
static const char *restart;
|
||||||
static const char *stop;
|
static const char *stop;
|
||||||
|
|
@ -18,7 +19,8 @@ struct Action {
|
||||||
static const char *getStatus;
|
static const char *getStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MessageKey {
|
struct MessageKey
|
||||||
|
{
|
||||||
static const char *action;
|
static const char *action;
|
||||||
static const char *tunnelId;
|
static const char *tunnelId;
|
||||||
static const char *config;
|
static const char *config;
|
||||||
|
|
@ -50,10 +52,10 @@ signals:
|
||||||
void connectionStateChanged(Vpn::ConnectionState state);
|
void connectionStateChanged(Vpn::ConnectionState state);
|
||||||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||||
void importConfigFromOutside(const QString);
|
void importConfigFromOutside(const QString);
|
||||||
|
void importBackupFromOutside(const QString);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit IosController();
|
explicit IosController();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,21 @@ QDebug operator<<(QDebug debug, const amnezia::ProtocolEnumNS::Proto &p)
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
amnezia::Proto ProtocolProps::protoFromString(QString proto){
|
amnezia::Proto ProtocolProps::protoFromString(QString proto)
|
||||||
|
{
|
||||||
QMetaEnum metaEnum = QMetaEnum::fromType<Proto>();
|
QMetaEnum metaEnum = QMetaEnum::fromType<Proto>();
|
||||||
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
||||||
Proto p = static_cast<Proto>(i);
|
Proto p = static_cast<Proto>(i);
|
||||||
if (proto == protoToString(p)) return p;
|
if (proto == protoToString(p))
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
return Proto::Any;
|
return Proto::Any;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProtocolProps::protoToString(amnezia::Proto p){
|
QString ProtocolProps::protoToString(amnezia::Proto p)
|
||||||
if (p == Proto::Any) return "";
|
{
|
||||||
|
if (p == Proto::Any)
|
||||||
|
return "";
|
||||||
|
|
||||||
QMetaEnum metaEnum = QMetaEnum::fromType<Proto>();
|
QMetaEnum metaEnum = QMetaEnum::fromType<Proto>();
|
||||||
QString protoKey = metaEnum.valueToKey(static_cast<int>(p));
|
QString protoKey = metaEnum.valueToKey(static_cast<int>(p));
|
||||||
|
|
@ -43,7 +47,8 @@ TransportProto ProtocolProps::transportProtoFromString(QString p)
|
||||||
QMetaEnum metaEnum = QMetaEnum::fromType<TransportProto>();
|
QMetaEnum metaEnum = QMetaEnum::fromType<TransportProto>();
|
||||||
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
||||||
TransportProto tp = static_cast<TransportProto>(i);
|
TransportProto tp = static_cast<TransportProto>(i);
|
||||||
if (p.toLower() == transportProtoToString(tp).toLower()) return tp;
|
if (p.toLower() == transportProtoToString(tp).toLower())
|
||||||
|
return tp;
|
||||||
}
|
}
|
||||||
return TransportProto::Udp;
|
return TransportProto::Udp;
|
||||||
}
|
}
|
||||||
|
|
@ -55,11 +60,9 @@ QString ProtocolProps::transportProtoToString(TransportProto proto, Proto p)
|
||||||
return protoKey.toLower();
|
return protoKey.toLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<amnezia::Proto, QString> ProtocolProps::protocolHumanNames()
|
QMap<amnezia::Proto, QString> ProtocolProps::protocolHumanNames()
|
||||||
{
|
{
|
||||||
return {
|
return { { Proto::OpenVpn, "OpenVPN" },
|
||||||
{Proto::OpenVpn, "OpenVPN"},
|
|
||||||
{ Proto::ShadowSocks, "ShadowSocks" },
|
{ Proto::ShadowSocks, "ShadowSocks" },
|
||||||
{ Proto::Cloak, "Cloak" },
|
{ Proto::Cloak, "Cloak" },
|
||||||
{ Proto::WireGuard, "WireGuard" },
|
{ Proto::WireGuard, "WireGuard" },
|
||||||
|
|
@ -69,8 +72,7 @@ QMap<amnezia::Proto, QString> ProtocolProps::protocolHumanNames()
|
||||||
{ Proto::TorWebSite, "Website in Tor network" },
|
{ Proto::TorWebSite, "Website in Tor network" },
|
||||||
{ Proto::Dns, "DNS Service" },
|
{ Proto::Dns, "DNS Service" },
|
||||||
{ Proto::FileShare, "File Sharing Service" },
|
{ Proto::FileShare, "File Sharing Service" },
|
||||||
{Proto::Sftp, QObject::tr("Sftp service")}
|
{ Proto::Sftp, QObject::tr("Sftp service") } };
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<amnezia::Proto, QString> ProtocolProps::protocolDescriptions()
|
QMap<amnezia::Proto, QString> ProtocolProps::protocolDescriptions()
|
||||||
|
|
@ -123,7 +125,6 @@ bool ProtocolProps::defaultPortChangeable(Proto p)
|
||||||
case Proto::Ikev2: return false;
|
case Proto::Ikev2: return false;
|
||||||
case Proto::L2tp: return false;
|
case Proto::L2tp: return false;
|
||||||
|
|
||||||
|
|
||||||
case Proto::TorWebSite: return true;
|
case Proto::TorWebSite: return true;
|
||||||
case Proto::Dns: return false;
|
case Proto::Dns: return false;
|
||||||
case Proto::FileShare: return false;
|
case Proto::FileShare: return false;
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ signals:
|
||||||
void goToPageSettings();
|
void goToPageSettings();
|
||||||
void goToPageViewConfig();
|
void goToPageViewConfig();
|
||||||
void goToPageSettingsServerServices();
|
void goToPageSettingsServerServices();
|
||||||
|
void goToPageSettingsBackup();
|
||||||
|
|
||||||
void closePage();
|
void closePage();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ signals:
|
||||||
|
|
||||||
void saveFile(const QString &fileName, const QString &data);
|
void saveFile(const QString &fileName, const QString &data);
|
||||||
|
|
||||||
|
void importBackupFromOutside(QString filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<ServersModel> m_serversModel;
|
QSharedPointer<ServersModel> m_serversModel;
|
||||||
QSharedPointer<ContainersModel> m_containersModel;
|
QSharedPointer<ContainersModel> m_containersModel;
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ DrawerType {
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
}
|
}
|
||||||
|
|
||||||
TextArea {
|
TextField {
|
||||||
id: configText
|
id: configText
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
@ -180,6 +180,8 @@ DrawerType {
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
height: 24
|
height: 24
|
||||||
|
|
||||||
|
readOnly: true
|
||||||
|
|
||||||
color: "#D7D8DB"
|
color: "#D7D8DB"
|
||||||
selectionColor: "#633303"
|
selectionColor: "#633303"
|
||||||
selectedTextColor: "#D7D8DB"
|
selectedTextColor: "#D7D8DB"
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import PageEnum 1.0
|
||||||
import "./"
|
import "./"
|
||||||
import "../Controls2"
|
import "../Controls2"
|
||||||
import "../Config"
|
import "../Config"
|
||||||
|
import "../Components"
|
||||||
import "../Controls2/TextTypes"
|
import "../Controls2/TextTypes"
|
||||||
|
|
||||||
PageType {
|
PageType {
|
||||||
|
|
@ -27,6 +28,10 @@ PageType {
|
||||||
//goToStartPage()
|
//goToStartPage()
|
||||||
PageController.goToPageHome()
|
PageController.goToPageHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onImportBackupFromOutside(filePath) {
|
||||||
|
restoreBackup(filePath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BackButtonType {
|
BackButtonType {
|
||||||
|
|
@ -116,15 +121,35 @@ PageType {
|
||||||
text: qsTr("Restore from backup")
|
text: qsTr("Restore from backup")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var fileName = SystemController.getFileName(qsTr("Open backup file"),
|
var filePath = SystemController.getFileName(qsTr("Open backup file"),
|
||||||
qsTr("Backup files (*.backup)"))
|
qsTr("Backup files (*.backup)"))
|
||||||
if (fileName !== "") {
|
if (filePath !== "") {
|
||||||
|
restoreBackup(filePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreBackup(filePath) {
|
||||||
|
questionDrawer.headerText = qsTr("Import settings from a backup file?")
|
||||||
|
questionDrawer.descriptionText = qsTr("All current settings will be reset");
|
||||||
|
questionDrawer.yesButtonText = qsTr("Continue")
|
||||||
|
questionDrawer.noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
|
questionDrawer.yesButtonFunction = function() {
|
||||||
|
questionDrawer.visible = false
|
||||||
PageController.showBusyIndicator(true)
|
PageController.showBusyIndicator(true)
|
||||||
SettingsController.restoreAppConfig(fileName)
|
SettingsController.restoreAppConfig(filePath)
|
||||||
PageController.showBusyIndicator(false)
|
PageController.showBusyIndicator(false)
|
||||||
}
|
}
|
||||||
}
|
questionDrawer.noButtonFunction = function() {
|
||||||
}
|
questionDrawer.visible = false
|
||||||
}
|
}
|
||||||
|
questionDrawer.visible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestionDrawer {
|
||||||
|
id: questionDrawer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,10 @@ Window {
|
||||||
function onShowPassphraseRequestDrawer() {
|
function onShowPassphraseRequestDrawer() {
|
||||||
privateKeyPassphraseDrawer.open()
|
privateKeyPassphraseDrawer.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onGoToPageSettingsBackup() {
|
||||||
|
PageController.goToPage(PageEnum.PageSettingsBackup)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue