From 7fadebe239b3d84134787ea90069ca43bb86752b Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sun, 24 Mar 2024 15:47:15 +0800 Subject: [PATCH] fixes #204 - add warning for unsupported platforms during whatsapp setup --- lib/common/src/version.h | 2 +- lib/duchat/src/duchat.h | 3 ++- lib/tgchat/src/tgchat.h | 3 ++- lib/wmchat/src/wmchat.h | 12 +++++++++++- src/main.cpp | 14 ++++++++++++++ src/nchat.1 | 2 +- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/common/src/version.h b/lib/common/src/version.h index a5902d68..aa34a608 100644 --- a/lib/common/src/version.h +++ b/lib/common/src/version.h @@ -7,4 +7,4 @@ #pragma once -#define NCHAT_VERSION "4.45" +#define NCHAT_VERSION "4.46" diff --git a/lib/duchat/src/duchat.h b/lib/duchat/src/duchat.h index dfaa71fc..beedc90c 100644 --- a/lib/duchat/src/duchat.h +++ b/lib/duchat/src/duchat.h @@ -1,6 +1,6 @@ // duchat.h // -// Copyright (c) 2020-2022 Kristofer Berggren +// Copyright (c) 2020-2024 Kristofer Berggren // All rights reserved. // // nchat is distributed under the MIT license, see LICENSE for details. @@ -21,6 +21,7 @@ class DuChat : public Protocol static std::string GetName() { return "Dummy"; } static std::string GetLibName() { return "libduchat"; } static std::string GetCreateFunc() { return "CreateDuChat"; } + static std::string GetSetupMessage() { return ""; } std::string GetProfileId() const; std::string GetProfileDisplayName() const; bool HasFeature(ProtocolFeature p_ProtocolFeature) const; diff --git a/lib/tgchat/src/tgchat.h b/lib/tgchat/src/tgchat.h index d74561d5..9d1583b0 100644 --- a/lib/tgchat/src/tgchat.h +++ b/lib/tgchat/src/tgchat.h @@ -1,6 +1,6 @@ // tgchat.h // -// Copyright (c) 2020-2022 Kristofer Berggren +// Copyright (c) 2020-2024 Kristofer Berggren // All rights reserved. // // nchat is distributed under the MIT license, see LICENSE for details. @@ -27,6 +27,7 @@ class TgChat : public Protocol static std::string GetName() { return "Telegram"; } static std::string GetLibName() { return "libtgchat"; } static std::string GetCreateFunc() { return "CreateTgChat"; } + static std::string GetSetupMessage() { return ""; } std::string GetProfileId() const; std::string GetProfileDisplayName() const; bool HasFeature(ProtocolFeature p_ProtocolFeature) const; diff --git a/lib/wmchat/src/wmchat.h b/lib/wmchat/src/wmchat.h index d35bbbef..8add61be 100644 --- a/lib/wmchat/src/wmchat.h +++ b/lib/wmchat/src/wmchat.h @@ -1,6 +1,6 @@ // wmchat.h // -// Copyright (c) 2020-2023 Kristofer Berggren +// Copyright (c) 2020-2024 Kristofer Berggren // All rights reserved. // // nchat is distributed under the MIT license, see LICENSE for details. @@ -23,6 +23,16 @@ class WmChat : public Protocol static std::string GetName() { return "WhatsAppMd"; } static std::string GetLibName() { return "libwmchat"; } static std::string GetCreateFunc() { return "CreateWmChat"; } + static std::string GetSetupMessage() + { +#if defined(__APPLE__) || defined(__GLIBC__) + return ""; +#else + return "\nUNSUPPORTED PLATFORM:\nThe WhatsApp protocol implementation officially only supports glibc on Linux.\n" + "For details, refer to https://github.com/d99kris/nchat/issues/204\n"; +#endif + } + std::string GetProfileId() const; std::string GetProfileDisplayName() const; bool HasFeature(ProtocolFeature p_ProtocolFeature) const; diff --git a/src/main.cpp b/src/main.cpp index 5756e41b..ac638300 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,7 @@ class ProtocolBaseFactory ProtocolBaseFactory() { } virtual ~ProtocolBaseFactory() { } virtual std::string GetName() const = 0; + virtual std::string GetSetupMessage() const = 0; virtual std::shared_ptr Create() const = 0; }; @@ -61,6 +62,11 @@ class ProtocolFactory : public ProtocolBaseFactory return T::GetName(); } + virtual std::string GetSetupMessage() const + { + return T::GetSetupMessage(); + } + virtual std::shared_ptr Create() const { std::shared_ptr protocol; @@ -495,6 +501,14 @@ std::shared_ptr SetupProfile() Profiles::Init(); #endif + std::string setupMessage = protocolFactorys.at(selectidx)->GetSetupMessage(); + if (!setupMessage.empty()) + { + LOG_WARNING("%s", setupMessage.c_str()); + std::cout << setupMessage; + sleep(3); + } + std::shared_ptr protocol = protocolFactorys.at(selectidx)->Create(); bool setupResult = protocol && protocol->SetupProfile(profilesDir, profileId); if (setupResult) diff --git a/src/nchat.1 b/src/nchat.1 index 1722f17a..2f962e7f 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" "March 2024" "nchat v4.45" "User Commands" +.TH NCHAT "1" "March 2024" "nchat v4.46" "User Commands" .SH NAME nchat \- ncurses chat .SH SYNOPSIS