Skip to content

Commit

Permalink
Merge pull request #38 from d99kris/fixes
Browse files Browse the repository at this point in the history
v2.04 fixes
  • Loading branch information
d99kris authored Aug 7, 2021
2 parents 8ec85a6 + 5672c30 commit b5a665b
Show file tree
Hide file tree
Showing 595 changed files with 133,979 additions and 64,149 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project
cmake_minimum_required(VERSION 3.16 FATAL_ERROR) # 3.1 is ok, but is 3.16 needed for proper version string
project(nchat VERSION 2.03 LANGUAGES CXX)
project(nchat VERSION 2.04 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
include(CheckCXXSourceCompiles)
set(NCHAT_PROJECT_VERSION ${PROJECT_VERSION})
Expand Down Expand Up @@ -39,6 +39,8 @@ message(STATUS "WhatsApp: ${HAS_WHATSAPP}")
# Application
add_executable(nchat
ext/apathy/path.hpp
src/appconfig.cpp
src/appconfig.h
src/main.cpp
src/ui.cpp
src/ui.h
Expand Down Expand Up @@ -70,6 +72,8 @@ add_executable(nchat
src/uilistdialog.h
src/uilistview.cpp
src/uilistview.h
src/uimessagedialog.cpp
src/uimessagedialog.h
src/uimodel.cpp
src/uimodel.h
src/uiscreen.cpp
Expand Down
83 changes: 72 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ Telegram.

![screenshot nchat](/doc/screenshot-nchat.png)

Features
--------
- Message history cache (sqlite db backed)
- View/save media files: documents, photos
- Show user status (online, away, typing)
- Message read receipt
- List dialogs (with text filter) for selecting files, emojis, contacts
- Reply / delete / send messages
- Jump to unread chat
- Toggle to view textized emojis vs. graphical (default)
- Toggle to hide/show UI elements (top bar, status bar, help bar, contact list)
- Receive / send markdown formatted messages
- Customizable color schemes and key bindings


Usage
=====
Usage:
Expand Down Expand Up @@ -50,6 +65,7 @@ Interactive Commands for Selected Message:
Ctrl-v open/view attached file
Ctrl-x reply to selected message


Supported Platforms
===================
nchat is developed and tested on Linux and macOS. Current version has been
Expand All @@ -58,6 +74,7 @@ tested on:
- macOS Big Sur 11.5
- Ubuntu 20.04 LTS


Build / Install
===============
Nchat consists of a large code-base (mainly the Telegram client library), so be
Expand All @@ -66,7 +83,6 @@ faster.

Linux / Ubuntu
--------------

**Dependencies**

sudo apt install ccache cmake build-essential gperf help2man libreadline-dev libssl-dev libncurses-dev libncursesw5-dev ncurses-doc zlib1g-dev libsqlite3-dev libmagic-dev
Expand All @@ -85,7 +101,6 @@ Linux / Ubuntu

macOS
-----

**Dependencies**

brew install gperf cmake openssl ncurses ccache readline help2man sqlite libmagic
Expand All @@ -104,7 +119,6 @@ macOS

Arch Linux
----------

**Source**

git clone https://aur.archlinux.org/nchat-git.git && cd nchat-git
Expand Down Expand Up @@ -147,7 +161,6 @@ Steps to build nchat on a low memory system:

Arch Linux
----------

**Source**

git clone https://aur.archlinux.org/nchat-git.git && cd nchat-git
Expand All @@ -166,6 +179,7 @@ Arch Linux

makepkg -i


Getting Started
===============
In order to configure / setup an account one needs to run nchat in setup mode:
Expand Down Expand Up @@ -195,6 +209,7 @@ in normal mode:

nchat


Troubleshooting
===============
If any issues are observed, try running nchat with verbose logging
Expand All @@ -205,6 +220,7 @@ and provide a copy of ~/.nchat/main.log when reporting the issue. The
preferred way of reporting issues and asking questions is by opening
[a Github issue](https://github.com/d99kris/nchat/issues/new).


Telegram Group
==============
A Telegram group [https://t.me/nchatusers](https://t.me/nchatusers) is
Expand All @@ -215,6 +231,7 @@ maintainer(s) should however be reported using
[Github issues](https://github.com/d99kris/nchat/issues/new) to ensure they
are properly tracked and get addressed.


Security
========
User data is stored locally in `~/.nchat`. Default file permissions
Expand All @@ -223,15 +240,23 @@ files can also access the user's personal Telegram data. To protect against
the most simple attack vectors it may be suitable to use disk encryption and
to ensure `~/.nchat` is not backed up unencrypted.


Configuration
=============
The following configuration files (listed with current default values) can be
used to configure nchat.

~/.nchat/app.conf
-----------------
This configuration file holds general application settings. Default content:

cache_enabled=1

~/.nchat/ui.conf
----------------
This configuration file holds general user interface settings. Default content:

confirm_deletion=1
emoji_enabled=1
help_enabled=1
list_enabled=1
Expand Down Expand Up @@ -350,25 +375,61 @@ General
Deleting a configuration entry line (while nchat is not running) and starting
nchat will populate the configuration file with the default entry.


Limitations
===========
Known limitations:

- Messages deleted using other devices/clients will not be deleted in nchat
history if local cache is enabled.


Technical Details
=================
nchat is implemented in C++. Its source tree includes the source code of the
following third-party libraries:

- [apathy](https://github.com/dlecocq/apathy) - MIT License
- [emojicpp](https://github.com/shalithasuranga/emojicpp) - MIT License
- [TDLib](https://github.com/tdlib/td) - Boost Software License
Third-party Libraries
---------------------
nmail is primarily implemented in C++ with some parts in Go. Its source tree
includes the source code of the following third-party libraries:

- [apathy](https://github.com/dlecocq/apathy) -
Copyright 2013 Dan Lecocq - [MIT License](/ext/apathy/LICENSE)

- [emojicpp](https://github.com/99x/emojicpp) -
Copyright 2018 Shalitha Suranga - [MIT License](/ext/emojicpp/LICENSE)

- [go-qrcode](https://github.com/skip2/go-qrcode) -
Copyright 2014 Tom Harwood -
[MIT License](/lib/wachat/go/ext/go-qrcode/LICENSE)

- [go-whatsapp](https://github.com/Rhymen/go-whatsapp) -
Copyright 2018 Lucas Engelke -
[MIT License](/lib/wachat/go/ext/go-whatsapp/LICENSE)

- [sqlite_modern_cpp](https://github.com/SqliteModernCpp/sqlite_modern_cpp) -
Copyright 2017 aminroosta - [MIT License](/ext/sqlite_modern_cpp/License.txt)

- [tdlib](https://github.com/tdlib/td) -
Copyright 2014 Aliaksei Levin, Arseny Smirnov -
[Boost License](/lib/tgchat/ext/td/LICENSE_1_0.txt)

Code Formatting
---------------
Uncrustify is used to maintain consistent source code formatting, example:

./make.sh src


License
=======
nchat is distributed under the MIT license. See LICENSE file.


Alternatives
============
Other terminal/console-based Telegram clients:

- [TelegramTUI](https://github.com/vtr0n/TelegramTUI)
- [Termgram](https://github.com/AndreiRegiani/termgram)
- [tg](https://github.com/paul-nameless/tg)


Keywords
Expand Down
10 changes: 9 additions & 1 deletion lib/duchat/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
dummy chat protocol
Duchat
======
Duchat provides implementation of a dummy chat protocol, used for
development testing of nchat.

Duchat is disabled by default in standard nchat builds. It can be enabled with:

mkdir -p build && cd build && cmake -DHAS_DUMMY=ON .. && make -s

12 changes: 12 additions & 0 deletions lib/ncutil/src/apputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "apputil.h"

bool AppUtil::m_DeveloperMode = false;

std::string AppUtil::GetAppNameVersion()
{
static std::string nameVersion = "nchat v" + GetAppVersion();
Expand All @@ -22,3 +24,13 @@ std::string AppUtil::GetAppVersion()
#endif
return version;
}

void AppUtil::SetDeveloperMode(bool p_DeveloperMode)
{
m_DeveloperMode = p_DeveloperMode;
}

bool AppUtil::GetDeveloperMode()
{
return m_DeveloperMode;
}
5 changes: 5 additions & 0 deletions lib/ncutil/src/apputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ class AppUtil
public:
static std::string GetAppNameVersion();
static std::string GetAppVersion();
static void SetDeveloperMode(bool p_DeveloperMode);
static bool GetDeveloperMode();

private:
static bool m_DeveloperMode;
};
8 changes: 4 additions & 4 deletions lib/ncutil/src/emojilist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ std::unique_ptr<sqlite::database> EmojiList::m_Db;

void EmojiList::Init()
{
std::lock_guard<std::mutex> lock(m_Mutex);
std::unique_lock<std::mutex> lock(m_Mutex);

static const int dirVersion = 1;
const std::string& emojisDir = FileUtil::GetApplicationDir() + "/emojis";
Expand Down Expand Up @@ -53,7 +53,7 @@ void EmojiList::Init()

void EmojiList::Cleanup()
{
std::lock_guard<std::mutex> lock(m_Mutex);
std::unique_lock<std::mutex> lock(m_Mutex);

if (!m_Db) return;

Expand All @@ -62,7 +62,7 @@ void EmojiList::Cleanup()

std::vector<std::pair<std::string, std::string>> EmojiList::Get(const std::string& p_Filter)
{
std::lock_guard<std::mutex> lock(m_Mutex);
std::unique_lock<std::mutex> lock(m_Mutex);

if (!m_Db) return std::vector<std::pair<std::string, std::string>>();

Expand All @@ -84,7 +84,7 @@ std::vector<std::pair<std::string, std::string>> EmojiList::Get(const std::strin

void EmojiList::AddUsage(const std::string& p_Name)
{
std::lock_guard<std::mutex> lock(m_Mutex);
std::unique_lock<std::mutex> lock(m_Mutex);

if (!m_Db) return;

Expand Down
4 changes: 2 additions & 2 deletions lib/ncutil/src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void Log::Error(const char* p_Filename, int p_LineNo, const char* p_Format, ...)

void Log::Dump(const char* p_Str)
{
std::lock_guard<std::mutex> lock(m_Mutex);
std::unique_lock<std::mutex> lock(m_Mutex);
if (m_Path.empty()) return;

FILE* file = fopen(m_Path.c_str(), "a");
Expand All @@ -86,7 +86,7 @@ void Log::Dump(const char* p_Str)

void Log::Write(const char* p_Filename, int p_LineNo, const char* p_Level, const char* p_Format, va_list p_VaList)
{
std::lock_guard<std::mutex> lock(m_Mutex);
std::unique_lock<std::mutex> lock(m_Mutex);
if (m_Path.empty()) return;

FILE* file = fopen(m_Path.c_str(), "a");
Expand Down
Loading

0 comments on commit b5a665b

Please sign in to comment.