diff --git a/client/client.pro b/client/client.pro index 1ec8cf1f..dd75d958 100644 --- a/client/client.pro +++ b/client/client.pro @@ -38,6 +38,7 @@ HEADERS += \ debug.h \ defines.h \ managementserver.h \ + platforms/ios/MobileUtils.h \ platforms/linux/leakdetector.h \ protocols/protocols_defs.h \ secureformat.h \ @@ -78,7 +79,7 @@ HEADERS += \ loghandler.h \ loglevel.h \ constants.h \ - platforms/ios/QRCodeReader.h + platforms/ios/QRCodeReaderBase.h SOURCES += \ configurators/cloak_configurator.cpp \ @@ -96,6 +97,7 @@ SOURCES += \ debug.cpp \ main.cpp \ managementserver.cpp \ + platforms/ios/MobileUtils.cpp \ platforms/linux/leakdetector.cpp \ protocols/protocols_defs.cpp \ secureformat.cpp \ @@ -132,7 +134,7 @@ SOURCES += \ protocols/vpnprotocol.cpp \ logger.cpp \ loghandler.cpp \ - platforms/ios/QRCodeReader.cpp + platforms/ios/QRCodeReaderBase.cpp RESOURCES += \ resources.qrc @@ -302,10 +304,13 @@ ios { platforms/ios/bigint.h \ platforms/ios/bigintipv6addr.h \ platforms/ios/ipaddress.h \ - platforms/ios/ipaddressrange.h + platforms/ios/ipaddressrange.h \ + platforms/ios/QtAppDelegate.h \ + platforms/ios/QtAppDelegate-C-Interface.h SOURCES -= \ - platforms/ios/QRCodeReader.cpp + platforms/ios/QRCodeReader.cpp \ + platforms/ios/MobileUtils.cpp SOURCES += \ protocols/ios_vpnprotocol.mm \ @@ -314,7 +319,9 @@ ios { platforms/ios/iosglue.mm \ platforms/ios/ipaddress.cpp \ platforms/ios/ipaddressrange.cpp \ - platforms/ios/QRCodeReader.mm + platforms/ios/QRCodeReaderBase.mm + platforms/ios/QtAppDelegate.mm \ + platforms/ios/MobileUtils.mm Q_ENABLE_BITCODE.value = NO Q_ENABLE_BITCODE.name = ENABLE_BITCODE diff --git a/client/configurators/vpn_configurator.cpp b/client/configurators/vpn_configurator.cpp index 28669168..c2b128f0 100644 --- a/client/configurators/vpn_configurator.cpp +++ b/client/configurators/vpn_configurator.cpp @@ -109,12 +109,9 @@ void VpnConfigurator::updateContainerConfigAfterInstallation(DockerContainer con qDebug() << "amnezia-tor onions" << stdOut; - QStringList l = stdOut.split(","); - for (QString s : l) { - if (s.contains(":80")) { - protocol.insert(config_key::site, s); - } - } + QString onion = stdOut; + onion.replace("\n", ""); + protocol.insert(config_key::site, onion); containerConfig.insert(ProtocolProps::protoToString(mainProto), protocol); } diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index ab665fbb..54721a2e 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -77,7 +77,7 @@ QMap ContainerProps::containerHumanNames() {DockerContainer::WireGuard, "WireGuard"}, {DockerContainer::Ipsec, QObject::tr("IPsec")}, - {DockerContainer::TorWebSite, QObject::tr("Web site in TOR network")}, + {DockerContainer::TorWebSite, QObject::tr("Web site in Tor network")}, {DockerContainer::Dns, QObject::tr("DNS Service")}, //{DockerContainer::FileShare, QObject::tr("SMB file sharing service")}, {DockerContainer::Sftp, QObject::tr("Sftp file sharing service")} @@ -94,7 +94,7 @@ QMap ContainerProps::containerDescriptions() {DockerContainer::WireGuard, QObject::tr("WireGuard container")}, {DockerContainer::Ipsec, QObject::tr("IPsec container")}, - {DockerContainer::TorWebSite, QObject::tr("Web site in TOR network")}, + {DockerContainer::TorWebSite, QObject::tr("Web site in Tor network")}, {DockerContainer::Dns, QObject::tr("DNS Service")}, //{DockerContainer::FileShare, QObject::tr("SMB file sharing service - is Window file sharing protocol")}, {DockerContainer::Sftp, QObject::tr("Sftp file sharing service - is secure FTP service")} diff --git a/client/ios/app/Info.plist b/client/ios/app/Info.plist index 38aec45e..20a28b2a 100644 --- a/client/ios/app/Info.plist +++ b/client/ios/app/Info.plist @@ -8,6 +8,19 @@ $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName AmneziaVPN + CFBundleDocumentTypes + + + CFBundleTypeName + Amnezia VPN config + LSHandlerRank + Alternate + LSItemContentTypes + + org.amnezia.AmneziaVPN.amnezia-config + + + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIcons @@ -47,5 +60,31 @@ UIUserInterfaceStyle Light + UTImportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeDescription + Amnezia VPN config + UTTypeIconFiles + + UTTypeIdentifier + org.amnezia.AmneziaVPN.amnezia-config + UTTypeTagSpecification + + public.filename-extension + + vpn + + public.mime-type + + text/plain + + + + diff --git a/client/main.cpp b/client/main.cpp index aae9a7e3..0991144e 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -37,7 +37,7 @@ #include "QZXing.h" -#include "platforms/ios/QRCodeReader.h" +#include "platforms/ios/QRCodeReaderBase.h" #include "debug.h" #include "defines.h" @@ -57,6 +57,10 @@ #include "native.h" #endif +#if defined(Q_OS_IOS) +#include "QtAppDelegate-C-Interface.h" +#endif + static void loadTranslator() { QTranslator* translator = new QTranslator; @@ -88,7 +92,6 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); #endif - #ifdef Q_OS_WIN AllowSetForegroundWindow(0); #endif @@ -97,6 +100,10 @@ int main(int argc, char *argv[]) NativeHelpers::registerApplicationInstance(&app); #endif +#if defined(Q_OS_IOS) + QtAppDelegateInitialize(); +#endif + loadTranslator(); QFontDatabase::addApplicationFont(":/fonts/Lato-Black.ttf"); @@ -220,6 +227,10 @@ int main(int argc, char *argv[]) engine->rootContext()->setContextProperty("VpnLogic", uiLogic->vpnLogic()); engine->rootContext()->setContextProperty("WizardLogic", uiLogic->wizardLogic()); +#if defined(Q_OS_IOS) + setStartPageLogic(uiLogic->startPageLogic()); +#endif + engine->load(url); QObject::connect(&app, &QCoreApplication::aboutToQuit, uiLogic, [&engine, uiLogic](){ diff --git a/client/platforms/ios/MobileUtils.cpp b/client/platforms/ios/MobileUtils.cpp new file mode 100644 index 00000000..31b58c94 --- /dev/null +++ b/client/platforms/ios/MobileUtils.cpp @@ -0,0 +1,10 @@ +#include "MobileUtils.h" + +MobileUtils::MobileUtils() +{ + +} + +void MobileUtils::shareText(const QStringList& filesToSend) { + +} diff --git a/client/platforms/ios/MobileUtils.h b/client/platforms/ios/MobileUtils.h new file mode 100644 index 00000000..42aa4031 --- /dev/null +++ b/client/platforms/ios/MobileUtils.h @@ -0,0 +1,17 @@ +#ifndef MOBILEUTILS_H +#define MOBILEUTILS_H + +#include +#include + +class MobileUtils : public QObject { + Q_OBJECT + +public: + MobileUtils() = delete; + +public slots: + static void shareText(const QStringList& filesToSend); +}; + +#endif // MOBILEUTILS_H diff --git a/client/platforms/ios/MobileUtils.mm b/client/platforms/ios/MobileUtils.mm new file mode 100644 index 00000000..94c7c775 --- /dev/null +++ b/client/platforms/ios/MobileUtils.mm @@ -0,0 +1,33 @@ +#include "MobileUtils.h" + +#include + +static UIViewController* getViewController() { + NSArray *windows = [[UIApplication sharedApplication]windows]; + for (UIWindow *window in windows) { + if (window.isKeyWindow) { + return window.rootViewController; + } + } + return nil; +} + +void MobileUtils::shareText(const QStringList& filesToSend) { + NSMutableArray *sharingItems = [NSMutableArray new]; + + for (int i = 0; i < filesToSend.size(); i++) { + NSURL *logFileUrl = [[NSURL alloc] initFileURLWithPath:filesToSend[i].toNSString()]; + [sharingItems addObject:logFileUrl]; + } + + UIViewController *qtController = getViewController(); + if (!qtController) return; + + UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil]; + + [qtController presentViewController:activityController animated:YES completion:nil]; + UIPopoverPresentationController *popController = activityController.popoverPresentationController; + if (popController) { + popController.sourceView = qtController.view; + } +} diff --git a/client/platforms/ios/QRCodeReader.cpp b/client/platforms/ios/QRCodeReaderBase.cpp similarity index 69% rename from client/platforms/ios/QRCodeReader.cpp rename to client/platforms/ios/QRCodeReaderBase.cpp index c422a0e7..c3148a85 100644 --- a/client/platforms/ios/QRCodeReader.cpp +++ b/client/platforms/ios/QRCodeReaderBase.cpp @@ -1,4 +1,4 @@ -#include "QRCodeReader.h" +#include "QRCodeReaderBase.h" QRCodeReader::QRCodeReader() { @@ -11,4 +11,4 @@ QRect QRCodeReader::cameraSize() { void QRCodeReader::startReading() {} void QRCodeReader::stopReading() {} -void QRCodeReader::setCameraSize(QRect) {}; +void QRCodeReader::setCameraSize(QRect) {} diff --git a/client/platforms/ios/QRCodeReader.h b/client/platforms/ios/QRCodeReaderBase.h similarity index 81% rename from client/platforms/ios/QRCodeReader.h rename to client/platforms/ios/QRCodeReaderBase.h index bc8c9925..29a4946d 100644 --- a/client/platforms/ios/QRCodeReader.h +++ b/client/platforms/ios/QRCodeReaderBase.h @@ -1,5 +1,5 @@ -#ifndef QRCODEREADER_H -#define QRCODEREADER_H +#ifndef QRCODEREADERBASE_H +#define QRCODEREADERBASE_H #include #include @@ -25,4 +25,4 @@ private: QRect m_cameraSize; }; -#endif // QRCODEREADER_H +#endif // QRCODEREADERBASE_H diff --git a/client/platforms/ios/QRCodeReader.mm b/client/platforms/ios/QRCodeReaderBase.mm similarity index 99% rename from client/platforms/ios/QRCodeReader.mm rename to client/platforms/ios/QRCodeReaderBase.mm index 85f71ba6..bd0dbac3 100644 --- a/client/platforms/ios/QRCodeReader.mm +++ b/client/platforms/ios/QRCodeReaderBase.mm @@ -1,4 +1,4 @@ -#include "QRCodeReader.h" +#include "QRCodeReaderBase.h" #import #import diff --git a/client/platforms/ios/QtAppDelegate-C-Interface.h b/client/platforms/ios/QtAppDelegate-C-Interface.h new file mode 100644 index 00000000..afd31e7d --- /dev/null +++ b/client/platforms/ios/QtAppDelegate-C-Interface.h @@ -0,0 +1,9 @@ +#ifndef QTAPPDELEGATECINTERFACE_H +#define QTAPPDELEGATECINTERFACE_H + +#include "ui/pages_logic/StartPageLogic.h" + +void QtAppDelegateInitialize(); +void setStartPageLogic(StartPageLogic*); + +#endif // QTAPPDELEGATECINTERFACE_H diff --git a/client/platforms/ios/QtAppDelegate.h b/client/platforms/ios/QtAppDelegate.h new file mode 100644 index 00000000..1e0dc412 --- /dev/null +++ b/client/platforms/ios/QtAppDelegate.h @@ -0,0 +1,9 @@ +#import +#import "QtAppDelegate-C-Interface.h" + +#include "ui/pages_logic/StartPageLogic.h" + +@interface QtAppDelegate : UIResponder ++(QtAppDelegate *)sharedQtAppDelegate; +@property (nonatomic) StartPageLogic* startPageLogic; +@end diff --git a/client/platforms/ios/QtAppDelegate.mm b/client/platforms/ios/QtAppDelegate.mm new file mode 100644 index 00000000..f63bea35 --- /dev/null +++ b/client/platforms/ios/QtAppDelegate.mm @@ -0,0 +1,91 @@ +#import "QtAppDelegate.h" + +#include + +@implementation QtAppDelegate + ++(QtAppDelegate *)sharedQtAppDelegate { + static dispatch_once_t pred; + static QtAppDelegate *shared = nil; + dispatch_once(&pred, ^{ + shared = [[super alloc] init]; + }); + return shared; +} + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + [application setMinimumBackgroundFetchInterval: UIApplicationBackgroundFetchIntervalMinimum]; + // Override point for customization after application launch. + NSLog(@"Did this launch option happen"); + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + NSLog(@"In the background"); +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + NSLog(@"In the foreground"); +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { + // We will add content here soon. + NSLog(@"In the completionHandler"); +} + +- (BOOL)application:(UIApplication *)app + openURL:(NSURL *)url + options:(NSDictionary *)options { + + NSLog(@"Application openURL: %@", url); + if (url.fileURL) { + QString filePath(url.path.UTF8String); + qDebug() << "filePath:" << filePath; + if (filePath.isEmpty()) return NO; + + QFile file(filePath); + bool isOpenFile = file.open(QIODevice::ReadOnly); + qDebug() << "isOpenFile:" << isOpenFile; + QByteArray data = file.readAll(); + + [QtAppDelegate sharedQtAppDelegate].startPageLogic->importConnectionFromCode(QString(data)); + return YES; + } + return NO; +} + + +void QtAppDelegateInitialize() +{ + [[UIApplication sharedApplication] setDelegate: [QtAppDelegate sharedQtAppDelegate]]; + NSLog(@"Created a new AppDelegate"); +} + +void setStartPageLogic(StartPageLogic* startPage) { + [QtAppDelegate sharedQtAppDelegate].startPageLogic = startPage; +} + +@end diff --git a/client/protocols/protocols_defs.cpp b/client/protocols/protocols_defs.cpp index 93578d12..549c3774 100644 --- a/client/protocols/protocols_defs.cpp +++ b/client/protocols/protocols_defs.cpp @@ -76,7 +76,7 @@ QMap ProtocolProps::protocolHumanNames() {Proto::Ikev2, "IKEv2"}, {Proto::L2tp, "L2TP"}, - {Proto::TorWebSite, "Web site in TOR network"}, + {Proto::TorWebSite, "Web site in Tor network"}, {Proto::Dns, "DNS Service"}, {Proto::FileShare, "File Sharing Service"}, {Proto::Sftp, QObject::tr("Sftp service")} diff --git a/client/resources.qrc b/client/resources.qrc index db61db33..a48a98f7 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -158,5 +158,6 @@ images/svg/settings_suggest_black_24dp.svg ui/qml/Controls/SvgButtonType.qml ui/qml/Pages/PageQrDecoderIos.qml + server_scripts/website_tor/Dockerfile diff --git a/client/scripts/xcode_patcher.rb b/client/scripts/xcode_patcher.rb index 983ec0c7..0a0550ca 100644 --- a/client/scripts/xcode_patcher.rb +++ b/client/scripts/xcode_patcher.rb @@ -271,7 +271,11 @@ class XCodeprojPatcher @target_extension.build_configurations.each do |config| config.base_configuration_reference = @configFile - config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= '"$(inherited) @executable_path/../Frameworks @executable_path/../../Frameworks"' + config.build_settings['LD_RUNPATH_SEARCH_PATHS'] ||= [ + '$(inherited)', + '@executable_path/../Frameworks', + '@executable_path/../../Frameworks' + ] config.build_settings['SWIFT_VERSION'] ||= '5.0' config.build_settings['CLANG_ENABLE_MODULES'] ||= 'YES' config.build_settings['SWIFT_OBJC_BRIDGING_HEADER'] ||= 'macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h' diff --git a/client/server_scripts/dns/run_container.sh b/client/server_scripts/dns/run_container.sh index b3be2c22..f8ff0380 100644 --- a/client/server_scripts/dns/run_container.sh +++ b/client/server_scripts/dns/run_container.sh @@ -1,2 +1,7 @@ # Run container -sudo docker run -d --restart always --network amnezia-dns-net --ip=172.29.172.254 --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--log-driver none \ +--restart always \ +--network amnezia-dns-net \ +--ip=172.29.172.254 \ +--name $CONTAINER_NAME $CONTAINER_NAME diff --git a/client/server_scripts/ipsec/run_container.sh b/client/server_scripts/ipsec/run_container.sh index adb02353..a2fbbd34 100644 --- a/client/server_scripts/ipsec/run_container.sh +++ b/client/server_scripts/ipsec/run_container.sh @@ -1,8 +1,9 @@ -sudo docker run \ - --restart=always \ - -p 500:500/udp \ - -p 4500:4500/udp \ - -d --privileged \ - --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--privileged \ +--log-driver none \ +--restart=always \ +-p 500:500/udp \ +-p 4500:4500/udp \ +--name $CONTAINER_NAME $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME diff --git a/client/server_scripts/openvpn/run_container.sh b/client/server_scripts/openvpn/run_container.sh index 9012a386..5649dd21 100644 --- a/client/server_scripts/openvpn/run_container.sh +++ b/client/server_scripts/openvpn/run_container.sh @@ -1,9 +1,10 @@ # Run container -sudo docker run \ - -d --restart always \ - --cap-add=NET_ADMIN \ - -p $OPENVPN_PORT:$OPENVPN_PORT/$OPENVPN_TRANSPORT_PROTO \ - --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--log-driver none \ +--restart always \ +--cap-add=NET_ADMIN \ +-p $OPENVPN_PORT:$OPENVPN_PORT/$OPENVPN_TRANSPORT_PROTO \ +--name $CONTAINER_NAME $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME diff --git a/client/server_scripts/openvpn_cloak/run_container.sh b/client/server_scripts/openvpn_cloak/run_container.sh index c3ee3a15..bec8e889 100644 --- a/client/server_scripts/openvpn_cloak/run_container.sh +++ b/client/server_scripts/openvpn_cloak/run_container.sh @@ -1,9 +1,10 @@ # Run container -sudo docker run \ - -d --restart always \ - --cap-add=NET_ADMIN \ - -p $CLOAK_SERVER_PORT:443/tcp \ - --name $CONTAINER_NAME $CONTAINER_NAME +sudo docker run -d \ +--log-driver none \ +--restart always \ +--cap-add=NET_ADMIN \ +-p $CLOAK_SERVER_PORT:443/tcp \ +--name $CONTAINER_NAME $CONTAINER_NAME sudo docker network connect amnezia-dns-net $CONTAINER_NAME diff --git a/client/server_scripts/openvpn_shadowsocks/run_container.sh b/client/server_scripts/openvpn_shadowsocks/run_container.sh index 4d529b15..3714aa62 100644 --- a/client/server_scripts/openvpn_shadowsocks/run_container.sh +++ b/client/server_scripts/openvpn_shadowsocks/run_container.sh @@ -1,5 +1,6 @@ # Run container sudo docker run \ +--log-driver none \ -d --restart always \ --cap-add=NET_ADMIN \ -p $SHADOWSOCKS_SERVER_PORT:$SHADOWSOCKS_SERVER_PORT/tcp \ diff --git a/client/server_scripts/sftp/run_container.sh b/client/server_scripts/sftp/run_container.sh index 7184d0be..03944eb8 100644 --- a/client/server_scripts/sftp/run_container.sh +++ b/client/server_scripts/sftp/run_container.sh @@ -1 +1,7 @@ -sudo docker run -d --restart always -p $SFTP_PORT:22/tcp --name $CONTAINER_NAME $CONTAINER_NAME $SFTP_USER:$SFTP_PASSWORD:::upload +sudo docker run -d \ +--log-driver none \ +--restart always \ +-p $SFTP_PORT:22/tcp \ +--name $CONTAINER_NAME \ +$CONTAINER_NAME \ +$SFTP_USER:$SFTP_PASSWORD:::upload diff --git a/client/server_scripts/website_tor/Dockerfile b/client/server_scripts/website_tor/Dockerfile new file mode 100644 index 00000000..ba408716 --- /dev/null +++ b/client/server_scripts/website_tor/Dockerfile @@ -0,0 +1,3 @@ +FROM amneziavpn/torpress:latest + +LABEL maintainer="AmneziaVPN" diff --git a/client/server_scripts/website_tor/configure_container.sh b/client/server_scripts/website_tor/configure_container.sh index 31c9eb93..70fc8c37 100644 --- a/client/server_scripts/website_tor/configure_container.sh +++ b/client/server_scripts/website_tor/configure_container.sh @@ -1,3 +1,3 @@ sleep 5 # get onions list -onions +cat /var/lib/tor/hidden_service/hostname diff --git a/client/server_scripts/website_tor/run_container.sh b/client/server_scripts/website_tor/run_container.sh index e5dfce98..df62f865 100644 --- a/client/server_scripts/website_tor/run_container.sh +++ b/client/server_scripts/website_tor/run_container.sh @@ -1,6 +1,5 @@ -# Run container -sudo docker stop amnezia-tor -sudo docker rm amnezia-tor -sudo docker run -d -p 80:80 --restart always --name $CONTAINER_NAME tutum/wordpress -sudo docker run -d --link $CONTAINER_NAME --name amnezia-tor goldy/tor-hidden-service -sudo docker exec -i amnezia-tor apk add bash +sudo docker run -d \ +--log-driver none \ +--restart always \ +--name $CONTAINER_NAME \ +$CONTAINER_NAME diff --git a/client/server_scripts/wireguard/run_container.sh b/client/server_scripts/wireguard/run_container.sh index 0fdac541..2520525a 100644 --- a/client/server_scripts/wireguard/run_container.sh +++ b/client/server_scripts/wireguard/run_container.sh @@ -1,5 +1,6 @@ # Run container sudo docker run -d \ +--log-driver none \ --restart always \ --privileged \ --cap-add=NET_ADMIN \ diff --git a/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml b/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml index 9959e5fa..1285e8bb 100644 --- a/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml +++ b/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml @@ -1,5 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.15 import ProtocolEnum 1.0 import "../" import "../../Controls" @@ -16,43 +17,54 @@ PageProtocolBase { Caption { id: caption - text: qsTr("TOR Web site settings") + text: qsTr("Tor Web Site settings") } - Rectangle { - id: frame_settings - width: parent.width + + ColumnLayout { + id: content + enabled: logic.pageEnabled anchors.top: caption.bottom + anchors.left: root.left + anchors.right: root.right + anchors.bottom: pb_save.top + anchors.margins: 20 anchors.topMargin: 10 - border.width: 1 - border.color: "lightgray" - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - radius: 2 - Grid { - id: grid - anchors.fill: parent - columns: 2 - horizontalItemAlignment: Grid.AlignHCenter - verticalItemAlignment: Grid.AlignVCenter - topPadding: 5 - leftPadding: 30 - rightPadding: 30 - spacing: 5 + RowLayout { + Layout.fillWidth: true + LabelType { - width: 130 + id: lbl_onion + Layout.preferredWidth: 0.3 * root.width - 10 text: qsTr("Web site onion address") } TextFieldType { id: tf_site_address - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 + Layout.fillWidth: true text: logic.labelTorWebSiteAddressText readOnly: true } + } + ShareConnectionButtonCopyType { + Layout.fillWidth: true + Layout.topMargin: 5 + copyText: tf_site_address.text + } + + RichLabelType { + Layout.fillWidth: true + Layout.topMargin: 15 + text: qsTr("Notes:
    +
  • Use Tor Browser to open this url.
  • +
  • After installation it takes several minutes while your onion site will become available in the Tor Network.
  • +
  • When configuring WordPress set the domain as this onion address.
  • +
+") } } + } diff --git a/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml b/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml index 59a96345..35caf05b 100644 --- a/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml +++ b/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml @@ -15,6 +15,6 @@ PageShareProtocolBase { Caption { id: caption - text: qsTr("Share TOR Web site") + text: qsTr("Share Tor Web site") } } diff --git a/client/ui/uilogic.cpp b/client/ui/uilogic.cpp index 878facb7..fe2d541d 100644 --- a/client/ui/uilogic.cpp +++ b/client/ui/uilogic.cpp @@ -48,6 +48,8 @@ #include "platforms/android/android_controller.h" #endif +#include "platforms/ios/MobileUtils.h" + #include "pages_logic/AppSettingsLogic.h" #include "pages_logic/GeneralSettingsLogic.h" #include "pages_logic/NetworkSettingsLogic.h" @@ -612,21 +614,10 @@ PageEnumNS::Page UiLogic::currentPage() void UiLogic::saveTextFile(const QString& desc, const QString& suggestedName, QString ext, const QString& data) { -// ext.replace("*", ""); -// QString fileName = QFileDialog::getSaveFileName(nullptr, desc, -// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*" + ext); - -// if (fileName.isEmpty()) return; -// if (!fileName.endsWith(ext)) fileName.append(ext); - -// QFile save(fileName); -// save.open(QIODevice::WriteOnly); -// save.write(data.toUtf8()); -// save.close(); - -// QFileInfo fi(fileName); -// QDesktopServices::openUrl(fi.absoluteDir().absolutePath()); - +#ifdef Q_OS_IOS + shareTempFile(suggestedName, ext, data); + return; +#endif ext.replace("*", ""); QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); @@ -681,3 +672,23 @@ void UiLogic::copyToClipboard(const QString &text) { qApp->clipboard()->setText(text); } + +void UiLogic::shareTempFile(const QString &suggestedName, QString ext, const QString& data) { + ext.replace("*", ""); + QString fileName = QDir::tempPath() + "/" + suggestedName; + + if (fileName.isEmpty()) return; + if (!fileName.endsWith(ext)) fileName.append(ext); + + QFile::remove(fileName); + qDebug() << "UiLogic::shareTempFile" << fileName; + + QFile save(fileName); + save.open(QIODevice::WriteOnly); + save.write(data.toUtf8()); + save.close(); + + QStringList filesToSend; + filesToSend.append(fileName); + MobileUtils::shareText(filesToSend); +} diff --git a/client/ui/uilogic.h b/client/ui/uilogic.h index ff7d7406..4e818bcc 100644 --- a/client/ui/uilogic.h +++ b/client/ui/uilogic.h @@ -104,6 +104,8 @@ public: Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data); Q_INVOKABLE void copyToClipboard(const QString& text); + void shareTempFile(const QString &suggestedName, QString ext, const QString& data); + QString getDialogConnectErrorText() const; void setDialogConnectErrorText(const QString &dialogConnectErrorText);