Skip to content

Commit

Permalink
initialize profiles in sorted order and log protocol names
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Apr 21, 2024
1 parent dc6f18f commit 47b40e9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/common/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

#pragma once

#define NCHAT_VERSION "4.70"
#define NCHAT_VERSION "4.71"
1 change: 1 addition & 0 deletions lib/duchat/src/duchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/tgchat/src/tgchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions lib/wmchat/src/wmchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,14 @@ int main(int argc, char* argv[])
bool hasProtocols = !protocols.empty();
if (hasProtocols && exportDir.empty())
{
// Sort protocols
std::map<std::string, std::shared_ptr<Protocol>> 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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/nchat.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 47b40e9

Please sign in to comment.