diff options
Diffstat (limited to '')
-rw-r--r-- | src/gpg/GpgConstants.cpp | 49 | ||||
-rw-r--r-- | src/gpg/result_analyse/DecryptResultAnalyse.cpp | 3 | ||||
-rw-r--r-- | src/ui/widgets/FilePage.cpp | 24 |
3 files changed, 17 insertions, 59 deletions
diff --git a/src/gpg/GpgConstants.cpp b/src/gpg/GpgConstants.cpp index 4a34ca34..2454daa2 100644 --- a/src/gpg/GpgConstants.cpp +++ b/src/gpg/GpgConstants.cpp @@ -28,9 +28,6 @@ #include <boost/algorithm/string/predicate.hpp> #include <boost/filesystem.hpp> -#include <codecvt> -#include <iostream> -#include <locale> #include <string> const char* GpgFrontend::GpgConstants::PGP_CRYPT_BEGIN = @@ -114,20 +111,16 @@ static inline std::string trim(std::string& s) { return s; } -std::string GpgFrontend::read_all_data_in_file(const std::string& path) { +std::string GpgFrontend::read_all_data_in_file(const std::string& utf8_path) { using namespace boost::filesystem; -#ifdef WINDOWS - std::wstring_convert<std::codecvt_utf8_utf16<char16_t>> converter; - std::wstring w_path = converter.from_bytes(path); - class path file_info(w_path.c_str()); + class path file_info(utf8_path.c_str()); + if (!exists(file_info) || !is_regular_file(file_info)) return {}; + std::ifstream in_file; +#ifndef WINDOWS + in_file.open(file_info.string(), std::ios::in); #else - class path file_info(path.c_str()); + in_file.open(file_info.wstring().c_str(), std::ios::in); #endif - - if (!exists(file_info) || !is_regular_file(path)) return {}; - - std::ifstream in_file; - in_file.open(path, std::ios::in); if (!in_file.good()) return {}; std::istreambuf_iterator<char> begin(in_file); std::istreambuf_iterator<char> end; @@ -136,18 +129,16 @@ std::string GpgFrontend::read_all_data_in_file(const std::string& path) { return in_buffer; } -bool GpgFrontend::write_buffer_to_file(const std::string& path, +bool GpgFrontend::write_buffer_to_file(const std::string& utf8_path, const std::string& out_buffer) { -#ifdef WINDOWS - std::wstring_convert<std::codecvt_utf8_utf16<char16_t>> converter; - std::wstring w_path = converter.from_bytes(path); - std::ofstream out_file(boost::filesystem::path(w_path).string(), - std::ios::out); + using namespace boost::filesystem; + class path file_info(utf8_path.c_str()); +#ifndef WINDOWS + std::ofstream out_file(file_info.string(), std::ios::out | std::ios::trunc); #else - std::ofstream out_file(boost::filesystem::path(path).string(), + std::ofstream out_file(file_info.wstring().c_str(), std::ios::out | std::ios::trunc); #endif - if (!out_file.good()) return false; out_file.write(out_buffer.c_str(), out_buffer.size()); out_file.close(); @@ -155,15 +146,8 @@ bool GpgFrontend::write_buffer_to_file(const std::string& path, } std::string GpgFrontend::get_file_extension(const std::string& path) { -#ifdef WINDOWS - std::wstring_convert<std::codecvt_utf8_utf16<char16_t>> converter; - std::wstring w_path = converter.from_bytes(path); - // Create a path object from given string - boost::filesystem::path path_obj(w_path); -#else // Create a path object from given string boost::filesystem::path path_obj(path); -#endif // Check if file name in the path object has extension if (path_obj.has_extension()) { @@ -175,15 +159,8 @@ std::string GpgFrontend::get_file_extension(const std::string& path) { } std::string GpgFrontend::get_only_file_name_with_path(const std::string& path) { -#ifdef WINDOWS - std::wstring_convert<std::codecvt_utf8_utf16<char16_t>> converter; - std::wstring w_path = converter.from_bytes(path); - // Create a path object from given string - boost::filesystem::path path_obj(w_path); -#else // Create a path object from given string boost::filesystem::path path_obj(path); -#endif // Check if file name in the path object has extension if (path_obj.has_filename()) { // Fetch the extension from path object and return diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.cpp b/src/gpg/result_analyse/DecryptResultAnalyse.cpp index 4ff32c59..f7fc70fe 100644 --- a/src/gpg/result_analyse/DecryptResultAnalyse.cpp +++ b/src/gpg/result_analyse/DecryptResultAnalyse.cpp @@ -51,6 +51,9 @@ void GpgFrontend::DecryptResultAnalyse::do_analyse() { stream << _("File Name") << ": " << result->file_name << std::endl; stream << std::endl; } + if (result->is_mime) { + stream << _("MIME") << ": " << _("true") << std::endl; + } auto reci = result->recipients; if (reci != nullptr) stream << _("Recipient(s)") << ": " << std::endl; diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index 0cd7c1a8..ca6dedc1 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -25,9 +25,6 @@ #include "ui/widgets/FilePage.h" #include <boost/filesystem.hpp> -#include <codecvt> -#include <iostream> -#include <locale> #include <string> #include "ui/MainWindow.h" @@ -107,14 +104,7 @@ void FilePage::slotUpLevel() { auto utf8_path = dirModel->fileInfo(currentRoot).absoluteFilePath().toStdString(); - -#ifdef WINDOWS - std::wstring_convert<std::codecvt_utf8_utf16<char16_t>> converter; - std::wstring w_path = converter.from_bytes(utf8_path); - boost::filesystem::path path_obj(w_path); -#else boost::filesystem::path path_obj(utf8_path); -#endif mPath = path_obj; LOG(INFO) << "get path" << mPath; @@ -142,14 +132,7 @@ QString FilePage::getSelected() const { void FilePage::slotGoPath() { const auto path_edit = ui->pathEdit->text().toStdString(); - -#ifdef WINDOWS - std::wstring_convert<std::codecvt_utf8_utf16<char16_t>> converter; - std::wstring w_path = converter.from_bytes(path_edit); - boost::filesystem::path path_obj(w_path); -#else boost::filesystem::path path_obj(path_edit); -#endif if (mPath.string() != path_edit) mPath = path_obj; auto fileInfo = QFileInfo(mPath.string().c_str()); @@ -430,13 +413,8 @@ void FilePage::slotMkdir() { void FilePage::slotCreateEmptyFile() { auto root_path_str = dirModel->rootPath().toStdString(); -#ifdef WINDOWS - std::wstring_convert<std::codecvt_utf8_utf16<char16_t>> converter; - std::wstring w_path = converter.from_bytes(root_path_str); - boost::filesystem::path root_path(w_path); -#else boost::filesystem::path root_path(root_path_str); -#endif + QString new_file_name; bool ok; new_file_name = QInputDialog::getText(this, _("Create Empty File"), |