Skip to content

Commit

Permalink
[Fix] Fix MXE char converter by switching to Qt
Browse files Browse the repository at this point in the history
[Fix] Fix cancel on error
[Improvement] Now less to compile when change version
  • Loading branch information
alphaonex86 committed Aug 1, 2019
1 parent 6bb9619 commit 30e6d62
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 26 deletions.
3 changes: 2 additions & 1 deletion DebugEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "DebugEngine.h"
#include "ExtraSocket.h"
#include "cpp11addition.h"
#include "FacilityEngine.h"

#ifdef WIN32
# define __func__ __FUNCTION__
Expand Down Expand Up @@ -59,7 +60,7 @@ DebugEngine::DebugEngine()
debugHtmlContent+="</style>";
debugHtmlContent+="<title>";
debugHtmlContent+="Ultracopier";
debugHtmlContent+=" "+std::string(ULTRACOPIER_VERSION)+" "+ULTRACOPIER_PLATFORM_NAME.toStdString()+", debug report</title>";
debugHtmlContent+=" "+FacilityEngine::version()+" "+ULTRACOPIER_PLATFORM_NAME.toStdString()+", debug report</title>";
debugHtmlContent+="</head>";
debugHtmlContent+="<body>";
debugHtmlContent+="<table>";
Expand Down
6 changes: 3 additions & 3 deletions EventDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ EventDispatcher::EventDispatcher()
#ifdef __STDC_VERSION__
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"__STDC_VERSION__: "+std::to_string(__STDC_VERSION__));
#endif
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,std::string("ULTRACOPIER_VERSION: ")+ULTRACOPIER_VERSION);
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,std::string("ULTRACOPIER_VERSION: ")+FacilityEngine::version());
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,std::string("Qt version: ")+qVersion()+" "+std::to_string(QT_VERSION));
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,std::string("ULTRACOPIER_PLATFORM_NAME: ")+ULTRACOPIER_PLATFORM_NAME.toStdString());
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,"Application path: "+QCoreApplication::applicationFilePath().toStdString()+" "+std::to_string(QCoreApplication::applicationPid()));
Expand Down Expand Up @@ -151,11 +151,11 @@ EventDispatcher::EventDispatcher()
lunchInitFunction.setSingleShot(true);
connect(&lunchInitFunction,&QTimer::timeout,this,&EventDispatcher::initFunction,Qt::QueuedConnection);
lunchInitFunction.start();
if(OptionEngine::optionEngine->getOptionValue("Ultracopier","Last_version_used")!="na" && OptionEngine::optionEngine->getOptionValue("Ultracopier","Last_version_used")!=ULTRACOPIER_VERSION)
if(OptionEngine::optionEngine->getOptionValue("Ultracopier","Last_version_used")!="na" && OptionEngine::optionEngine->getOptionValue("Ultracopier","Last_version_used")!=FacilityEngine::version())
{
//then ultracopier have been updated
}
OptionEngine::optionEngine->setOptionValue("Ultracopier","Last_version_used",ULTRACOPIER_VERSION);
OptionEngine::optionEngine->setOptionValue("Ultracopier","Last_version_used",FacilityEngine::version());
unsigned int a=stringtouint32(OptionEngine::optionEngine->getOptionValue("Ultracopier","ActionOnManualOpen"));
if(a>2)
OptionEngine::optionEngine->setOptionValue("Ultracopier","ActionOnManualOpen","1");
Expand Down
1 change: 1 addition & 0 deletions FacilityEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class FacilityEngine : public FacilityInterface
/// \brief return audio if created from opus file, nullptr if failed
void/*casted to #ifndef QAudioOutput*/* prepareOpusAudio(const std::string &file,QBuffer &buffer) const;

static std::string version();
static FacilityEngine facilityEngine;
private:
//undirect translated string
Expand Down
5 changes: 3 additions & 2 deletions HelpDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "HelpDialog.h"
#include "ProductKey.h"
#include "FacilityEngine.h"

#include <QTreeWidgetItem>
#include <QApplication>
Expand Down Expand Up @@ -69,9 +70,9 @@ void HelpDialog::reloadTextValue()
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
QString text=ui->label_ultracopier->text();
if(ProductKey::productKey->isUltimate())
text=text.replace(QStringLiteral("%1"),QStringLiteral("Ultimate %1").arg(ULTRACOPIER_VERSION));
text=text.replace(QStringLiteral("%1"),QStringLiteral("Ultimate %1").arg(QString::fromStdString(FacilityEngine::version())));
else
text=text.replace(QStringLiteral("%1"),ULTRACOPIER_VERSION);
text=text.replace(QStringLiteral("%1"),QString::fromStdString(FacilityEngine::version()));
#ifdef ULTRACOPIER_MODE_SUPERCOPIER
text=text.replace(QStringLiteral("Ultracopier"),QStringLiteral("Supercopier"),Qt::CaseInsensitive);
#endif
Expand Down
9 changes: 5 additions & 4 deletions InternetUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "OptionEngine.h"
#include "cpp11addition.h"
#include "ProductKey.h"
#include "Version.h"

#ifdef ULTRACOPIER_INTERNET_SUPPORT

Expand Down Expand Up @@ -55,9 +56,9 @@ void InternetUpdater::downloadFileInternal(const bool force)
#endif
std::string ultracopierVersion;
if(ProductKey::productKey->isUltimate())
ultracopierVersion=name+" Ultimate/"+ULTRACOPIER_VERSION;
ultracopierVersion=name+" Ultimate/"+FacilityEngine::version();
else
ultracopierVersion=name+"/"+ULTRACOPIER_VERSION;
ultracopierVersion=name+"/"+FacilityEngine::version();
#ifdef ULTRACOPIER_VERSION_PORTABLE
#ifdef ULTRACOPIER_PLUGIN_ALL_IN_ONE
ultracopierVersion+=" portable/all-in-one";
Expand Down Expand Up @@ -122,14 +123,14 @@ void InternetUpdater::httpFinished()
reply=NULL;
return;
}
if(newVersion==ULTRACOPIER_VERSION)
if(newVersion.toStdString()==FacilityEngine::version())
{
reply->deleteLater();
reply=NULL;
emit noNewUpdate();
return;
}
if(PluginsManager::compareVersion(newVersion.toStdString(),"<=",ULTRACOPIER_VERSION))
if(PluginsManager::compareVersion(newVersion.toStdString(),"<=",FacilityEngine::version()))
{
reply->deleteLater();
reply=NULL;
Expand Down
4 changes: 2 additions & 2 deletions PluginsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ std::string PluginsManager::getPluginVersion(const std::string &pluginName) cons
{
#ifdef ULTRACOPIER_MODE_SUPERCOPIER
if(pluginName=="supercopier")
return ULTRACOPIER_VERSION;
return FacilityEngine::version();
#else
if(pluginName=="ultracopier")
return ULTRACOPIER_VERSION;
return FacilityEngine::version();
#endif
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
unsigned int index=0;
Expand Down
2 changes: 1 addition & 1 deletion SystrayIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ SystrayIcon::SystrayIcon(QObject * parent) :
updateSystrayIcon();

#ifdef ULTRACOPIER_INTERNET_SUPPORT
lastVersion=ULTRACOPIER_VERSION;
lastVersion=FacilityEngine::version();
#endif

timerCheckSetTooltip.setSingleShot(true);
Expand Down
4 changes: 0 additions & 4 deletions Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#define ULTRACOPIER_DEBUG_MAX_GUI_LINE 50000 ///< \brief Max number of ligne show on the GUI
#define ULTRACOPIER_DEBUG_MAX_ALL_SIZE 128 ///< \brief Max size (in MB) after the console/file output is dropped
#define ULTRACOPIER_DEBUG_MAX_IMPORTANT_SIZE 150 ///< \brief Max size (in MB) after the console/file important output is dropped
/// \brief the version
#define ULTRACOPIER_VERSION "2.0.3.1"
/// \brief the windows version
#define ULTRACOPIER_WINDOWS_VERSION 2,0,3,1
// define if the version is portable or not
//#define ULTRACOPIER_VERSION_PORTABLE
//#define ULTRACOPIER_VERSION_PORTABLEAPPS
Expand Down
9 changes: 9 additions & 0 deletions Version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef VERSIONUC_H
#define VERSIONUC_H

/// \brief the version
#define ULTRACOPIER_VERSION "2.0.3.2"
/// \brief the windows version
#define ULTRACOPIER_WINDOWS_VERSION 2,0,3,2

#endif // VARIABLE_H
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int main(int argc, char *argv[])
{
int returnCode;
QApplication ultracopierApplication(argc, argv);
ultracopierApplication.setApplicationVersion(ULTRACOPIER_VERSION);
ultracopierApplication.setApplicationVersion(QString::fromStdString(FacilityEngine::version()));
ultracopierApplication.setQuitOnLastWindowClosed(false);
qRegisterMetaType<PluginsAvailable>("PluginsAvailable");
qRegisterMetaType<Ultracopier::DebugLevel>("Ultracopier::DebugLevel");
Expand Down
2 changes: 2 additions & 0 deletions other-pro/ultracopier-core.pro
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ HEADERS += $$PWD/../ResourcesManager.h \
$$PWD/../interface/PluginInterface_CopyEngine.h \
$$PWD/../interface/OptionInterface.h \
$$PWD/../Variable.h \
$$PWD/../Version.h \
$$PWD/../PluginLoaderCore.h \
$$PWD/../interface/PluginInterface_PluginLoader.h \
$$PWD/../OptionDialog.h \
Expand Down Expand Up @@ -152,6 +153,7 @@ SOURCES += $$PWD/../ThemesManager.cpp \
$$PWD/../LocalListener.cpp \
$$PWD/../CliParser.cpp \
$$PWD/../FacilityEngine.cpp \
$$PWD/../FacilityEngineVersion.cpp \
$$PWD/../LogThread.cpp \
$$PWD/../OSSpecific.cpp \
$$PWD/../cpp11addition.cpp \
Expand Down
2 changes: 2 additions & 0 deletions plugins/CopyEngine/Ultracopier-Spec/ListThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ void ListThread::realByteTransfered()

void ListThread::checkIfReadyToCancel()
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
if(!stopIt)
return;
int index=0;
Expand Down Expand Up @@ -1094,6 +1095,7 @@ void ListThread::createTransferThread()

void ListThread::deleteTransferThread()
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
int loop_size=transferThreadList.size();
if(loop_size>inodeThreads)
{
Expand Down
2 changes: 2 additions & 0 deletions plugins/CopyEngine/Ultracopier-Spec/ListThreadActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ bool ListThread::skipInternal(const uint64_t &id)
//executed in this thread
void ListThread::cancel()
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
if(stopIt)
{
waitCancel.release();
Expand All @@ -83,6 +84,7 @@ void ListThread::cancel()
while(index<loop_size)
{
transferThreadList.at(index)->stop();
transferThreadList.at(index)->transferId=0;
index++;
}
index=0;
Expand Down
15 changes: 12 additions & 3 deletions plugins/CopyEngine/Ultracopier-Spec/ListThreadNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ bool ListThread::newCopy(const std::vector<std::string> &sources,const std::stri
else if (std::regex_match(source, base_match, base_regex))
return false;
if(index<99)
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,sources.at(index)+" -> "+source);
{
if(sources.at(index)!=source)
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,sources.at(index)+" -> "+source);
}
index++;
sourcesClean.push_back(TransferThread::stringToInternalString(source));
}
//ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"sourcesClean: "+stringimplode(sourcesClean,";"));
scanFileOrFolderThread->addToList(sourcesClean,TransferThread::stringToInternalString(destination));
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+destination);
const INTERNALTYPEPATH &Wdest=TransferThread::stringToInternalString(destination);
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+TransferThread::internalStringTostring(Wdest));
scanFileOrFolderThread->addToList(sourcesClean,Wdest);
scanThreadHaveFinish(true);
detectDrivesOfCurrentTransfer(sourcesClean,TransferThread::stringToInternalString(destination));
return true;
Expand Down Expand Up @@ -96,7 +102,10 @@ bool ListThread::newMove(const std::vector<std::string> &sources,const std::stri
index++;
sourcesClean.push_back(TransferThread::stringToInternalString(source));
}
scanFileOrFolderThread->addToList(sourcesClean,TransferThread::stringToInternalString(destination));
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+destination);
const INTERNALTYPEPATH &Wdest=TransferThread::stringToInternalString(destination);
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+TransferThread::internalStringTostring(Wdest));
scanFileOrFolderThread->addToList(sourcesClean,Wdest);
scanThreadHaveFinish(true);
detectDrivesOfCurrentTransfer(sourcesClean,TransferThread::stringToInternalString(destination));
return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/CopyEngine/Ultracopier-Spec/ScanFileOrFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void ScanFileOrFolder::addToList(const std::vector<INTERNALTYPEPATH>& sources,co
this->destination=destination;
#ifdef WIDESTRING
QFileInfo destinationInfo(QString::fromStdWString(this->destination));
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"check symblink: "+destinationInfo.absoluteFilePath().toStdString());
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"check symblink: "+destinationInfo.absoluteFilePath().toStdString()+", destination: "+TransferThread::internalStringTostring(destination));
while(destinationInfo.isSymLink())
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"resolv destination to: "+destinationInfo.symLinkTarget().toStdString());
Expand Down
10 changes: 7 additions & 3 deletions plugins/CopyEngine/Ultracopier-Spec/TransferThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,19 @@ TransferStat TransferThread::getStat() const
#ifdef WIDESTRING
INTERNALTYPEPATH TransferThread::stringToInternalString(const std::string& utf8)
{
/* buggy on MXE
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(utf8);
return converter.from_bytes(utf8);*/
return QString::fromUtf8(utf8.data(),utf8.size()).toStdWString();
}

std::string TransferThread::internalStringTostring(const INTERNALTYPEPATH& utf16)
{

/* buggy on MXE
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv1;
return conv1.to_bytes(utf16);
return conv1.to_bytes(utf16);*/
const QByteArray &data=QString::fromStdWString(utf16).toUtf8();
return std::string(data.constData(),data.size());
}
#else
std::string TransferThread::stringToInternalString(const std::string& utf8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ void TransferThreadAsync::stop()
if(!source.empty())
if(exists(source))
unlink(TransferThread::internalStringTostring(destination).c_str());
transfer_stat=TransferStat_Idle;
resetExtraVariable();
}

//retry after error
Expand Down
2 changes: 1 addition & 1 deletion resources/resources-windows.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <windows.h>
#include "../Variable.h"
#include "../Version.h"

1 VERSIONINFO
FILEVERSION ULTRACOPIER_WINDOWS_VERSION
Expand Down

0 comments on commit 30e6d62

Please sign in to comment.