From 47b40e97e21d630440e620c779fc0f6e3ae3a595 Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sun, 21 Apr 2024 14:51:38 +0800 Subject: [PATCH] initialize profiles in sorted order and log protocol names --- lib/common/src/version.h | 2 +- lib/duchat/src/duchat.cpp | 1 + lib/tgchat/src/tgchat.cpp | 2 ++ lib/wmchat/src/wmchat.cpp | 2 ++ src/main.cpp | 7 +++++-- src/nchat.1 | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/common/src/version.h b/lib/common/src/version.h index ad3d7333..cffdc8c1 100644 --- a/lib/common/src/version.h +++ b/lib/common/src/version.h @@ -7,4 +7,4 @@ #pragma once -#define NCHAT_VERSION "4.70" +#define NCHAT_VERSION "4.71" diff --git a/lib/duchat/src/duchat.cpp b/lib/duchat/src/duchat.cpp index a18da62e..adccc75f 100644 --- a/lib/duchat/src/duchat.cpp +++ b/lib/duchat/src/duchat.cpp @@ -64,6 +64,7 @@ bool DuChat::SetupProfile(const std::string& p_ProfilesDir, std::string& p_Profi bool DuChat::LoadProfile(const std::string& p_ProfilesDir, const std::string& p_ProfileId) { + LOG_INFO("load dummy profile"); (void)p_ProfilesDir; m_ProfileId = p_ProfileId; return true; diff --git a/lib/tgchat/src/tgchat.cpp b/lib/tgchat/src/tgchat.cpp index d0bf6247..238793e4 100644 --- a/lib/tgchat/src/tgchat.cpp +++ b/lib/tgchat/src/tgchat.cpp @@ -329,6 +329,8 @@ bool TgChat::Impl::SetupProfile(const std::string& p_ProfilesDir, std::string& p bool TgChat::Impl::LoadProfile(const std::string& p_ProfilesDir, const std::string& p_ProfileId) { + LOG_INFO("load telegram profile"); + m_ProfileDir = p_ProfilesDir + "/" + p_ProfileId; m_ProfileId = p_ProfileId; MessageCache::AddProfile(m_ProfileId, true, s_CacheDirVersion, false); diff --git a/lib/wmchat/src/wmchat.cpp b/lib/wmchat/src/wmchat.cpp index 5ca3b9b1..ac45e70d 100644 --- a/lib/wmchat/src/wmchat.cpp +++ b/lib/wmchat/src/wmchat.cpp @@ -115,6 +115,8 @@ bool WmChat::SetupProfile(const std::string& p_ProfilesDir, std::string& p_Profi bool WmChat::LoadProfile(const std::string& p_ProfilesDir, const std::string& p_ProfileId) { + LOG_INFO("load whatsapp profile"); + if (!p_ProfilesDir.empty() && !p_ProfileId.empty()) { m_ProfileDir = p_ProfilesDir + "/" + p_ProfileId; diff --git a/src/main.cpp b/src/main.cpp index 9805ab8a..90267db3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -365,11 +365,14 @@ int main(int argc, char* argv[]) bool hasProtocols = !protocols.empty(); if (hasProtocols && exportDir.empty()) { + // Sort protocols + std::map> protocolsSorted(protocols.begin(), protocols.end()); + // Login Status::Set(Status::FlagConnecting); std::thread loginThread([&] { - for (auto& protocol : protocols) + for (auto& protocol : protocolsSorted) { protocol.second->SetMessageHandler(messageHandler); protocol.second->Login(); @@ -386,7 +389,7 @@ int main(int argc, char* argv[]) } // Logout - for (auto& protocol : protocols) + for (auto& protocol : protocolsSorted) { protocol.second->Logout(); protocol.second->CloseProfile(); diff --git a/src/nchat.1 b/src/nchat.1 index 88819d4e..9d7fb5fe 100644 --- a/src/nchat.1 +++ b/src/nchat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NCHAT "1" "April 2024" "nchat v4.70" "User Commands" +.TH NCHAT "1" "April 2024" "nchat v4.71" "User Commands" .SH NAME nchat \- ncurses chat .SH SYNOPSIS