Skip to content

Commit

Permalink
fixes #204 - add warning for unsupported platforms during whatsapp setup
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Mar 24, 2024
1 parent 25bdd09 commit 7fadebe
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 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.45"
#define NCHAT_VERSION "4.46"
3 changes: 2 additions & 1 deletion lib/duchat/src/duchat.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/tgchat/src/tgchat.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down
12 changes: 11 additions & 1 deletion lib/wmchat/src/wmchat.h
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Protocol> Create() const = 0;
};

Expand All @@ -61,6 +62,11 @@ class ProtocolFactory : public ProtocolBaseFactory
return T::GetName();
}

virtual std::string GetSetupMessage() const
{
return T::GetSetupMessage();
}

virtual std::shared_ptr<Protocol> Create() const
{
std::shared_ptr<T> protocol;
Expand Down Expand Up @@ -495,6 +501,14 @@ std::shared_ptr<Protocol> 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> protocol = protocolFactorys.at(selectidx)->Create();
bool setupResult = protocol && protocol->SetupProfile(profilesDir, profileId);
if (setupResult)
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" "March 2024" "nchat v4.45" "User Commands"
.TH NCHAT "1" "March 2024" "nchat v4.46" "User Commands"
.SH NAME
nchat \- ncurses chat
.SH SYNOPSIS
Expand Down

0 comments on commit 7fadebe

Please sign in to comment.