Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build (log)",
"type": "shell",
"command": "./0.regen_all.sh > .build.log 2>&1; echo BUILD_EXIT:$?",
"options": {
"cwd": "${workspaceFolder}/application"
},
"presentation": {
"panel": "new"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build installation package",
"type": "shell",
"command": "./5.build_installation_package.sh",
"options": {
"cwd": "${workspaceFolder}/application"
},
"presentation": {
"panel": "new",
"focus": true
},
"problemMatcher": []
},
{
"label": "Install dependencies",
"type": "shell",
"command": "sudo apt install g++ git qtcreator libprotobuf-dev qt5-qmake qttools5-dev-tools protobuf-compiler qtbase5-dev",
"problemMatcher": []
}
]
}
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dont't comile yourself. Instead, ask for confirmation through the user if the compilation is finished.
The build output can be found at application/.build.log
2,942 changes: 2,942 additions & 0 deletions application/.build.log

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions application/Common/.qmake.stash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
QMAKE_CXX.QT_COMPILER_STDCXX = 201703L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 13
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
/usr/include/c++/13 \
/usr/include/x86_64-linux-gnu/c++/13 \
/usr/include/c++/13/backward \
/usr/lib/gcc/x86_64-linux-gnu/13/include \
/usr/local/include \
/usr/include/x86_64-linux-gnu \
/usr/include
QMAKE_CXX.LIBDIRS = \
/usr/lib/gcc/x86_64-linux-gnu/13 \
/usr/lib/x86_64-linux-gnu \
/usr/lib \
/lib/x86_64-linux-gnu \
/lib
4 changes: 2 additions & 2 deletions application/Common/Hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ Hash Hash::fromStr(const QString& str)

for (int i = 0; i < HASH_SIZE && 2*i + 1 < strLower.size(); i++)
{
char c1 = strLower[2*i].toAscii();
char c2 = strLower[2*i + 1].toAscii();
char c1 = strLower[2*i].toLatin1();
char c2 = strLower[2*i + 1].toLatin1();

char p1 = c1 <= '9' ? c1 - '0' : c1 - 'a' + 10;
char p2 = c2 <= '9' ? c2 - '0' : c2 - 'a' + 10;
Expand Down
7 changes: 4 additions & 3 deletions application/Common/LogManager/priv/QtLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using namespace LM;

#include <QtGlobal>
#include <QMessageLogContext>

#include <IEntry.h>

Expand All @@ -33,15 +34,15 @@ using namespace LM;
* will create its own handle and discard the current one.
*/

void handler(QtMsgType type, const char* msg)
void handler(QtMsgType type, const QMessageLogContext& /*context*/, const QString& msg)
{
Severity s =
type == QtDebugMsg ? SV_DEBUG :
type == QtWarningMsg ? SV_WARNING :
type == QtCriticalMsg ? SV_ERROR :
type == QtFatalMsg ? SV_FATAL_ERROR : SV_UNKNOWN;

QtLogger::me.log(msg, s);
QtLogger::me.log(qPrintable(msg), s);
}

const QtLogger QtLogger::me;
Expand All @@ -52,7 +53,7 @@ const QtLogger QtLogger::me;
*/
void QtLogger::initMsgHandler()
{
qInstallMsgHandler(handler);
qInstallMessageHandler(handler);
}

QtLogger::QtLogger() :
Expand Down
2 changes: 1 addition & 1 deletion application/Common/LogManager/priv/StdLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void StdLogger::run()
{
qint64 size;
while((size = this->stdoutIn.readLine(this->buffer, BUFFER_SIZE)) != -1)
this->log(QString::fromAscii(this->buffer, size), SV_DEBUG);
this->log(QString::fromLatin1(this->buffer, size), SV_DEBUG);
}

StdLogger::StdLogger(int channel, const QString& name) :
Expand Down
14 changes: 7 additions & 7 deletions application/Common/ProtoHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ void ProtoHelper::setLang(Protos::Common::Language& langMess, const QLocale& loc
const QStringList& langCountry = locale.name().split('_');
if (langCountry.length() == 2)
{
ProtoHelper::setStr(langMess, &Protos::Common::Language::set_lang, langCountry[0]);
ProtoHelper::setStr(langMess, &Protos::Common::Language::set_country, langCountry[1]);
langMess.set_lang(langCountry[0].toUtf8().constData());
langMess.set_country(langCountry[1].toUtf8().constData());
}
else
{
ProtoHelper::setStr(langMess, &Protos::Common::Language::set_lang, "en");
ProtoHelper::setStr(langMess, &Protos::Common::Language::set_country, "US");
langMess.set_lang("en");
langMess.set_country("US");
}
}

Expand Down Expand Up @@ -143,12 +143,12 @@ QString ProtoHelper::getDebugStr(const google::protobuf::Message& mess)
{
if (str[pos] != '\\')
{
hashHex.append(QString::number(str[pos].toAscii(), 16));
hashHex.append(QString::number(str[pos].toLatin1(), 16));
pos++;
}
else
{
switch (str[pos+1].toAscii())
switch (str[pos+1].toLatin1())
{
case 'r':
hashHex.append("0d");
Expand All @@ -165,7 +165,7 @@ QString ProtoHelper::getDebugStr(const google::protobuf::Message& mess)
case '"':
case '\'':
case '\\':
hashHex.append(QString::number(str[pos+1].toAscii(), 16));
hashHex.append(QString::number(str[pos+1].toLatin1(), 16));
pos += 2;
break;
default: // It's an octal number, for example : "\123"
Expand Down
16 changes: 8 additions & 8 deletions application/Common/ProtoHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ namespace Common
{
public:
template <typename T>
static void setStr(T& mess, void (T::*setter)(const char*), const QString& str);
static void setStr(T& mess, void (T::*setter)(const std::string&), const QString& str);

template <typename T>
static QString getStr(const T& mess, const std::string& (T::*getter)() const);

template <typename T>
static void addRepeatedStr(T& mess, void (T::*adder)(const char*), const QString& str);
static void addRepeatedStr(T& mess, void (T::*adder)(const std::string&), const QString& str);

template <typename T>
static QString getRepeatedStr(const T& mess, const std::string& (T::*getter)(int) const, int i);
Expand Down Expand Up @@ -71,10 +71,10 @@ namespace Common
using namespace Common;

template <typename T>
void ProtoHelper::setStr(T& mess, void (T::*setter)(const char*), const QString& str)
void ProtoHelper::setStr(T& mess, void (T::*setter)(const std::string&), const QString& str)
{
const QByteArray& array = str.toUtf8();
(mess.*setter)(array.constData());
const std::string utf8 = str.toUtf8().constData();
(mess.*setter)(utf8);
}

template <typename T>
Expand All @@ -85,10 +85,10 @@ QString ProtoHelper::getStr(const T& mess, const std::string& (T::*getter)() con
}

template <typename T>
void ProtoHelper::addRepeatedStr(T& mess, void (T::*adder)(const char*), const QString& str)
void ProtoHelper::addRepeatedStr(T& mess, void (T::*adder)(const std::string&), const QString& str)
{
const QByteArray& array = str.toUtf8();
(mess.*adder)(array.constData());
const std::string utf8 = str.toUtf8().constData();
(mess.*adder)(utf8);
}

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void InternalCoreConnection::disconnectFromCore()
void InternalCoreConnection::sendChatMessage(const QString& message)
{
Protos::GUI::ChatMessage chatMessage;
Common::ProtoHelper::setStr(chatMessage, &Protos::GUI::ChatMessage::set_message, message);
Common::ProtoHelper::setStr(chatMessage, static_cast<void (Protos::GUI::ChatMessage::*)(const std::string&)>(&Protos::GUI::ChatMessage::set_message), message);
this->send(Common::MessageHeader::GUI_CHAT_MESSAGE, chatMessage);
}

Expand Down Expand Up @@ -215,7 +215,7 @@ void InternalCoreConnection::download(const Common::Hash& peerID, const Protos::
downloadMessage.mutable_entry()->CopyFrom(entry);
if (!sharedFolderID.isNull())
downloadMessage.mutable_destination_directory_id()->set_hash(sharedFolderID.getData(), Common::Hash::HASH_SIZE);
Common::ProtoHelper::setStr(downloadMessage, &Protos::GUI::Download::set_destination_path, path);
Common::ProtoHelper::setStr(downloadMessage, static_cast<void (Protos::GUI::Download::*)(const std::string&)>(&Protos::GUI::Download::set_destination_path), path);
this->send(Common::MessageHeader::GUI_DOWNLOAD, downloadMessage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SearchResult::SearchResult(InternalCoreConnection* coreConnection, const QString
void SearchResult::start()
{
Protos::GUI::Search search;
Common::ProtoHelper::setStr(search, &Protos::GUI::Search::set_pattern, this->terms);
Common::ProtoHelper::setStr(search, static_cast<void (Protos::GUI::Search::*)(const std::string&)>(&Protos::GUI::Search::set_pattern), this->terms);
this->coreConnection->send(Common::MessageHeader::GUI_SEARCH, search);
this->startTimer();
}
Expand Down
6 changes: 3 additions & 3 deletions application/Common/TestsCommon/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,16 @@ void Tests::protoHelper()
Protos::Common::Entry entry;
entry.set_type(Protos::Common::Entry::FILE);
entry.set_size(0);
ProtoHelper::setStr(entry, &Protos::Common::Entry::set_path, path);
ProtoHelper::setStr(entry, &Protos::Common::Entry::set_name, name);
ProtoHelper::setStr(entry, static_cast<void (Protos::Common::Entry::*)(const std::string&)>(&Protos::Common::Entry::set_path), path);
ProtoHelper::setStr(entry, static_cast<void (Protos::Common::Entry::*)(const std::string&)>(&Protos::Common::Entry::set_name), name);

QCOMPARE(ProtoHelper::getStr(entry, &Protos::Common::Entry::path), path);
QCOMPARE(ProtoHelper::getStr(entry, &Protos::Common::Entry::name), name);

Protos::GUI::CoreSettings::SharedDirectories sharedDirs;
const QList<QString> dirs = QList<QString>() << "abc" << "def" << "ghi";
foreach (QString dir, dirs)
ProtoHelper::addRepeatedStr(sharedDirs, &Protos::GUI::CoreSettings::SharedDirectories::add_dir, dir);
ProtoHelper::addRepeatedStr(sharedDirs, static_cast<void (Protos::GUI::CoreSettings::SharedDirectories::*)(const std::string&)>(&Protos::GUI::CoreSettings::SharedDirectories::add_dir), dir);
for (int i = 0; i < dirs.size(); i++)
QCOMPARE(ProtoHelper::getRepeatedStr(sharedDirs, &Protos::GUI::CoreSettings::SharedDirectories::dir, i), dirs[i]);

Expand Down
4 changes: 2 additions & 2 deletions application/Common/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define VERSION_TAG "Beta15"

// These two values are automatically updated during the release building process. See the script 'Application/Tools/update_version.sh'
#define BUILD_TIME "2012-12-02_16-03"
#define GIT_VERSION "a6dfd850db6e42acfa88785689e5f77ad49330d5"
#define BUILD_TIME "2026-05-08_16-56"
#define GIT_VERSION "670bb4a6758d702732cf6328ecccfa876c88c549"

#endif
23 changes: 23 additions & 0 deletions application/Core/.qmake.stash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
QMAKE_CXX.QT_COMPILER_STDCXX = 201703L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 13
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
/usr/include/c++/13 \
/usr/include/x86_64-linux-gnu/c++/13 \
/usr/include/c++/13/backward \
/usr/lib/gcc/x86_64-linux-gnu/13/include \
/usr/local/include \
/usr/include/x86_64-linux-gnu \
/usr/include
QMAKE_CXX.LIBDIRS = \
/usr/lib/gcc/x86_64-linux-gnu/13 \
/usr/lib/x86_64-linux-gnu \
/usr/lib \
/lib/x86_64-linux-gnu \
/lib
2 changes: 1 addition & 1 deletion application/Core/CoreService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CoreService::CoreService(bool resetSettings, QLocale locale, int argc, char** ar
// If Core is launched from the console we read user input.
for (int i = 1; i < argc; i++)
{
QString currentArg = QString::fromAscii(argv[i]);
QString currentArg = QString::fromLocal8Bit(argv[i]);
if (currentArg == "-e" || currentArg == "--exec")
{
connect(&this->consoleReader, SIGNAL(newLine(QString)), this, SLOT(processUserInput(QString)), Qt::QueuedConnection);
Expand Down
23 changes: 23 additions & 0 deletions application/Core/DownloadManager/.qmake.stash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
QMAKE_CXX.QT_COMPILER_STDCXX = 201703L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 13
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
/usr/include/c++/13 \
/usr/include/x86_64-linux-gnu/c++/13 \
/usr/include/c++/13/backward \
/usr/lib/gcc/x86_64-linux-gnu/13/include \
/usr/local/include \
/usr/include/x86_64-linux-gnu \
/usr/include
QMAKE_CXX.LIBDIRS = \
/usr/lib/gcc/x86_64-linux-gnu/13 \
/usr/lib/x86_64-linux-gnu \
/usr/lib \
/lib/x86_64-linux-gnu \
/lib
9 changes: 7 additions & 2 deletions application/Core/DownloadManager/priv/ChunkDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ ChunkDownloader::~ChunkDownloader()
L_DEBU(QString("ChunkDownloader deleted : %1").arg(this->chunkHash.toStr()));
}

void ChunkDownloader::setSelf(const QSharedPointer<ChunkDownloader>& self)
{
this->self = self;
}

/**
* Return true if the chunk was downloading.
*/
Expand All @@ -73,7 +78,7 @@ void ChunkDownloader::stop()
this->downloading = false;
this->mutex.unlock();

this->threadPool.wait(this);
this->threadPool.wait(this->self);

this->downloadingEnded();
}
Expand Down Expand Up @@ -472,7 +477,7 @@ void ChunkDownloader::stream(const QSharedPointer<PM::ISocket>& socket)
this->socket = socket;
static const quint32 SOCKET_BUFFER_SIZE = SETTINGS.get<quint32>("socket_buffer_size");
this->socket->setReadBufferSize(SOCKET_BUFFER_SIZE);
this->threadPool.run(this);
this->threadPool.run(this->self);
}

void ChunkDownloader::getChunkTimeout()
Expand Down
3 changes: 3 additions & 0 deletions application/Core/DownloadManager/priv/ChunkDownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define DOWNLOADMANAGER_CHUNKDOWNLOADER_H

#include <QSharedPointer>
#include <QWeakPointer>
#include <QList>
#include <QThread>
#include <QElapsedTimer>
Expand Down Expand Up @@ -70,6 +71,7 @@ namespace DM
QSharedPointer<FM::IChunk> getChunk() const;

void setPeerSource(PM::IPeer* peer, bool informOccupiedPeers = true);
void setSelf(const QSharedPointer<ChunkDownloader>& self);

int isReadyToDownload();
bool isDownloading() const;
Expand Down Expand Up @@ -112,6 +114,7 @@ namespace DM

Common::Hash chunkHash;
QSharedPointer<FM::IChunk> chunk;
QWeakPointer<ChunkDownloader> self;

QList<PM::IPeer*> peers; // The peers which own this chunk.
PM::IPeer* currentDownloadingPeer;
Expand Down
2 changes: 1 addition & 1 deletion application/Core/DownloadManager/priv/Download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Download::populateQueueEntry(Protos::Queue::Queue::Entry* entry) const
entry->set_status(static_cast<Protos::Queue::Queue::Entry::Status>(this->status));

entry->mutable_peer_source_id()->set_hash(this->peerSource->getID().getData(), Common::Hash::HASH_SIZE);
Common::ProtoHelper::setStr(*entry, &Protos::Queue::Queue::Entry::set_peer_source_nick, this->peerSource->getNick());
Common::ProtoHelper::setStr(*entry, static_cast<void (Protos::Queue::Queue::Entry::*)(const std::string&)>(&Protos::Queue::Queue::Entry::set_peer_source_nick), this->peerSource->getNick());
}

quint64 Download::getID() const
Expand Down
2 changes: 1 addition & 1 deletion application/Core/DownloadManager/priv/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Download* DownloadManager::addDownload(const Protos::Common::Entry& remoteEntry,
localEntry.clear_shared_dir();
localEntry.set_exists(false);

Common::ProtoHelper::setStr(localEntry, &Protos::Common::Entry::set_path, localRelativePath);
Common::ProtoHelper::setStr(localEntry, static_cast<void (Protos::Common::Entry::*)(const std::string&)>(&Protos::Common::Entry::set_path), localRelativePath);
if (!destinationDirectoryID.isNull())
localEntry.mutable_shared_dir()->mutable_id()->set_hash(destinationDirectoryID.getData(), Common::Hash::HASH_SIZE);

Expand Down
Loading