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