summaryrefslogblamecommitdiffstats
path: root/README.md
blob: 3d4d023694b2b94bb099d9cac3c489019509d4ba (plain) (tree)
1
2
3
4
5
6
7
8
9

           
                                                                                      
 
                                                                                                                                                                                                                                                                                                                                                              
 

              
                                                                                   
 

               


                           



                          

                                                              
                                                                                                                    

   
                                 



                         

    
           
   
 

                          
                                                                                                        
                                                                                      
                                                                                                      
                                                            



                                                          
                                                                                                        
 










                                                                                                                       







                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                   


                                                                                                                                                                                                                              








                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 


                                                                                                                                                                                      



                     
                  
 


                                                                                                       
                                                                              


                                                                                                    
                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                     
# discord.c

an alternative client for a messaging platform, written in the C programming language.

code rewrite in 0.0.4 brings a lot of new features and marks the 0.0.3 release obsolete, though it still kind of works for terminal users, although it is very bad. rewritten version is better because it does not reach ratelimits due to using a socket connection and not polling for messages via HTTP. it also has ~~voice support and~~ a GUI frontend.

## screenshots

![screenshot in fullscreen](https://cdn.sijanec.eu/img/2021/09/discord.c_prtsc.png)

## instructions

### debian (ubuntu as well)

```
sudo apt update
sudo apt install discord.c
```

you need to add [my apt repository](https://prog.sijanec.eu/).

built packages only exist for `amd64`, `arm64` and `i386` (`i686`). for other architectures grab the source package:

```
apt-get --install build discord.c
```

### caveman style install

```
make
./discord.c
```

#### building requirements

* a POSIX build system - app is cross platform and should also be able to be compiled for all major OSes
* a C compiler, `tcc` (fast), `gcc` (10), and `clang` (better warnings) tested working
* `make`, with support for `.NOTPARALLEL:` or without executing in parallel, GNU `make` tested working
* `libwebsockets-dev` for http and ws client and json parser
* GTK+, `libgtk-3-dev` tested working
* ~~`libsoundio-dev` for crossplatform sound io~~
* ~~`libopus-dev` for sound encoding~~
* ~~`libsodium-dev` for encrypting UDP packets to server~~
* `xxd` for embedding files inside binary (via C unsigned char arrays without messing with object files)

## automatic building

automatic building is done on two servers, one for `arm64` and the other for `amd64`.

check the build badge before downloading:

[![Build Status](https://jenkins.sijanec.eu/buildStatus/icon?job=discord.c)](https://jenkins.sijanec.eu/job/discord.c/)

* `amd64`: [https://cargova.sijanec.eu/prog/discord.c/](https://cargova.sijanec.eu/prog/discord.c/)
* `arm64`: [https://of.sijanec.eu/prog/discord.c/](https://of.sijanec.eu/prog/discord.c/)

there are deb packages and binaries.

## using discord.c as a library (libdiscord.c/discord.c-dev)

discord.c is programmed in two separate sections, the ui section, that was previously made in ncurses, and the API section, that can, as of the code rewrite, be used independently in other applications. It is useful to write alternative frontends for accessing content available using discord.c by using the discord.c library, since that allows breaking API changes to be fixed in one place instead of fixing it for each individual program. There is no documentation provided for the library, but reading discord.c source code you will get the idea. Expect a Doxygen soon.

to your surprise, you can use the ui section, as of the code rewrite, as a library as well and integrate other platforms into it. No docs yet here either.

~~The package for Debian comes with include header files and compiled shared objects so it can be used as a dependency, but beware, this dependency will depend on GTK+3.0, which would be, in case you are doing a GUI with a different widget toolkit, useless.~~

the program is, as of the code rewrite, single threaded, for increased stability and performance. it used to have separated network and ui threads, but now the threading model is abstracted with an event-based programming.

## todo

### discord.c interface for the blind

a must-have feature is an alternative `ui.c` that would simply print messages to the console and be controllable fully from the keyboard, similar to the way pre-0.0.4 `discord.c` was created, but without `ncurses`. blind people can't interact with the messaging platform's official client at the time of writing, and I assume that users of `espeakup` and similar services mostly use their computer from the console and advanced GUI features are only a burden to them. I got an idea that if a piece of software is usable via the old-style printer terminals, only then it's usable for the blind.

completing this task would make `discord.c` the first and the only alternative client with an easy to use interface for the blind.

### android port

it would be useful to have an android port, and luckily this is possible with little effort due to the GTK broadway backend that interfaces with a HTML renderer, WebView for example.

### misc

* message attachments

## developer notes

* use an `i386` compatible machine with `debian` `bullseye` (I use a Dell Latitude D620)
* debugging with valgrind: `make valgrind-prepare` once and `make valgrind` for profiling `./discord.c`
* generating valgrind suppressions: `make gensupp`, running `make valgrind` afterwards will ignore all
* `make cc` to compile code under `tcc`, `gcc` and `clang` (with `scan-build`)
* optimization is always 0, binaries always have debug symbols
* `make -e CC=gcc` to choose a compiler instead of `cc`.
* `make -e CC="clang -fsanitize=address" && ASAN_OPTIONS=detect_leaks=1` to use `clang` leak checker
* `scan-build make` to staticly analyze build with `clang` (`clang-tools` package required). `gcc`'s `-fanalyze` can't be used without many false positives, because the code is not written so pedantically (without `__attribute__`s on function arguments, return values, ...).
* `make -e CC="cc -pg"` can be used to generate a gprof binary (gcc/clang only, tcc has no support). After running the produced executable, run `gprof discord.c gmon.out > analysis.txt` for report.