From 3f58c930e38ae129af806e7661993cb83014b1dd Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 22 Nov 2018 17:15:52 +0400 Subject: [PATCH] Use separate download folder for support. --- Telegram/SourceFiles/core/file_utilities.cpp | 10 ++++++++++ Telegram/SourceFiles/core/file_utilities.h | 2 ++ Telegram/SourceFiles/data/data_document.cpp | 2 +- .../export/view/export_view_panel_controller.cpp | 6 +++--- Telegram/SourceFiles/mediaview.cpp | 2 +- Telegram/SourceFiles/platform/linux/specific_linux.cpp | 4 ---- Telegram/SourceFiles/platform/linux/specific_linux.h | 1 - Telegram/SourceFiles/platform/mac/specific_mac.h | 1 - Telegram/SourceFiles/platform/mac/specific_mac.mm | 4 ---- Telegram/SourceFiles/platform/mac/specific_mac_p.h | 1 - Telegram/SourceFiles/platform/mac/specific_mac_p.mm | 8 -------- Telegram/SourceFiles/platform/win/specific_win.cpp | 4 ---- Telegram/SourceFiles/platform/win/specific_win.h | 1 - 13 files changed, 17 insertions(+), 29 deletions(-) diff --git a/Telegram/SourceFiles/core/file_utilities.cpp b/Telegram/SourceFiles/core/file_utilities.cpp index 91b64cc92..5783dcda3 100644 --- a/Telegram/SourceFiles/core/file_utilities.cpp +++ b/Telegram/SourceFiles/core/file_utilities.cpp @@ -138,6 +138,16 @@ void ShowInFolder(const QString &filepath) { }); } +QString DefaultDownloadPath() { + return QStandardPaths::writableLocation( + QStandardPaths::DownloadLocation) + + '/' + + (AuthSession::Exists() && Auth().supportMode() + ? "Tsupport Desktop" + : str_const_toString(AppName)) + + '/'; +} + namespace internal { void UnsafeOpenEmailLinkDefault(const QString &email) { diff --git a/Telegram/SourceFiles/core/file_utilities.h b/Telegram/SourceFiles/core/file_utilities.h index d7a186a78..b99852b20 100644 --- a/Telegram/SourceFiles/core/file_utilities.h +++ b/Telegram/SourceFiles/core/file_utilities.h @@ -35,6 +35,8 @@ void OpenWith(const QString &filepath, QPoint menuPosition); void Launch(const QString &filepath); void ShowInFolder(const QString &filepath); +QString DefaultDownloadPath(); + namespace internal { inline QString UrlToLocalDefault(const QUrl &url) { diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 4c9a0bbef..2f2ae4887 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -146,7 +146,7 @@ QString FileNameUnsafe( QString path; if (Global::DownloadPath().isEmpty()) { - path = psDownloadPath(); + path = File::DefaultDownloadPath(); } else if (Global::DownloadPath() == qsl("tmp")) { path = cTempDir(); } else { diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index 74630a794..736ef843e 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -109,12 +109,12 @@ bool IsDefaultPath(const QString &path) { : value; return (cPlatform() == dbipWindows) ? result.toLower() : result; }; - return (check(path) == check(psDownloadPath())); + return (check(path) == check(File::DefaultDownloadPath())); } void ResolveSettings(Settings &settings) { if (settings.path.isEmpty()) { - settings.path = psDownloadPath(); + settings.path = File::DefaultDownloadPath(); settings.forceSubPath = true; } else { settings.forceSubPath = IsDefaultPath(settings.path); @@ -381,7 +381,7 @@ void PanelController::saveSettings() const { return (cPlatform() == dbipWindows) ? result.toLower() : result; }; auto settings = *_settings; - if (check(settings.path) == check(psDownloadPath())) { + if (check(settings.path) == check(File::DefaultDownloadPath())) { settings.path = QString(); } Local::WriteExportSettings(settings); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index fe1d8b607..18d7eeed8 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -979,7 +979,7 @@ void MediaView::onDownload() { QString path; if (Global::DownloadPath().isEmpty()) { - path = psDownloadPath(); + path = File::DefaultDownloadPath(); } else if (Global::DownloadPath() == qsl("tmp")) { path = cTempDir(); } else { diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 996f5f039..c6c23e6f7 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -306,10 +306,6 @@ QString psAppDataPath() { return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/'; } -QString psDownloadPath() { - return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + str_const_toString(AppName) + '/'; -} - void psDoCleanup() { try { psAutoStart(false, true); diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.h b/Telegram/SourceFiles/platform/linux/specific_linux.h index a55aedc9f..ef9fd2086 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.h +++ b/Telegram/SourceFiles/platform/linux/specific_linux.h @@ -59,7 +59,6 @@ void psClearInitLogs(); void psActivateProcess(uint64 pid = 0); QString psLocalServerPrefix(); QString psAppDataPath(); -QString psDownloadPath(); void psAutoStart(bool start, bool silent = false); void psSendToMenu(bool send, bool silent = false); diff --git a/Telegram/SourceFiles/platform/mac/specific_mac.h b/Telegram/SourceFiles/platform/mac/specific_mac.h index 5d24e5b38..3f56c1f28 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac.h +++ b/Telegram/SourceFiles/platform/mac/specific_mac.h @@ -58,7 +58,6 @@ void psClearInitLogs(); void psActivateProcess(uint64 pid = 0); QString psLocalServerPrefix(); QString psAppDataPath(); -QString psDownloadPath(); void psAutoStart(bool start, bool silent = false); void psSendToMenu(bool send, bool silent = false); diff --git a/Telegram/SourceFiles/platform/mac/specific_mac.mm b/Telegram/SourceFiles/platform/mac/specific_mac.mm index 67b98cf84..c0726628b 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac.mm @@ -206,10 +206,6 @@ QString psAppDataPath() { return objc_appDataPath(); } -QString psDownloadPath() { - return objc_downloadPath(); -} - void psDoCleanup() { try { psAutoStart(false, true); diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.h b/Telegram/SourceFiles/platform/mac/specific_mac_p.h index ccf7dc0c4..649591689 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.h +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.h @@ -31,7 +31,6 @@ double objc_appkitVersion(); QString objc_documentsPath(); QString objc_appDataPath(); -QString objc_downloadPath(); QByteArray objc_downloadPathBookmark(const QString &path); QByteArray objc_pathBookmark(const QString &path); void objc_downloadPathEnableAccess(const QByteArray &bookmark); diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index 370390009..b69d6a6b8 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -489,14 +489,6 @@ QString objc_appDataPath() { return QString(); } -QString objc_downloadPath() { - NSURL *url = [[NSFileManager defaultManager] URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil]; - if (url) { - return QString::fromUtf8([[url path] fileSystemRepresentation]) + '/' + str_const_toString(AppName) + '/'; - } - return QString(); -} - QByteArray objc_downloadPathBookmark(const QString &path) { #ifndef OS_MAC_STORE return QByteArray(); diff --git a/Telegram/SourceFiles/platform/win/specific_win.cpp b/Telegram/SourceFiles/platform/win/specific_win.cpp index 2e8b933cc..82f435fce 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.cpp +++ b/Telegram/SourceFiles/platform/win/specific_win.cpp @@ -193,10 +193,6 @@ QString psAppDataPathOld() { return QString(); } -QString psDownloadPath() { - return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + str_const_toString(AppName) + '/'; -} - void psDoCleanup() { try { psAutoStart(false, true); diff --git a/Telegram/SourceFiles/platform/win/specific_win.h b/Telegram/SourceFiles/platform/win/specific_win.h index 3c4657cd6..255a8cb5a 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.h +++ b/Telegram/SourceFiles/platform/win/specific_win.h @@ -68,7 +68,6 @@ void psActivateProcess(uint64 pid = 0); QString psLocalServerPrefix(); QString psAppDataPath(); QString psAppDataPathOld(); -QString psDownloadPath(); void psAutoStart(bool start, bool silent = false); void psSendToMenu(bool send, bool silent = false);