Commit Graph

23 Commits

Author SHA1 Message Date
Ophestra Umiker 0693bffa4a
rpcfetch: ui: show version in interface
release / release (push) Successful in 15m20s Details
Default fallback value of "impure", the flake build script sets it to "flake", and the gitea action sets it to the tag.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 15:37:16 +09:00
Ophestra Umiker 44ba51184b
workflows: add release workflow
release / release (push) Successful in 14m38s Details
2024-06-30 14:56:17 +09:00
Ophestra Umiker 0a1213edd5
rpcfetch: implement Windows system stats fetching
Unfortunately I could not find any loadavg equivalent on Windows, so it returns a fixed value for now.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 03:01:21 +09:00
Ophestra Umiker 1d28743f31
library: io: implement Windows platform support
Discord on Windows makes use of Windows named pipes for the socket instead of UNIX domain sockets.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 03:00:02 +09:00
Ophestra Umiker 50e3f3a03f
library: rpc: do not validate nonce of initial response
Yet another inconsistency between arRPC and Discord RPC, Discord RPC does not send a nonce at all. Now we internally treat "initial-ready" as a magic string to bypass nonce validation.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 02:57:42 +09:00
Ophestra Umiker 5bb6f9f1a8
library: io: move ErrAgain to shared and errPipe value to platform-specific
ErrAgain is not platform specific however EPIPE equivalent is different on Windows.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 02:56:15 +09:00
Ophestra Umiker c23e6120c8
rpcfetch: fix profile activity label pending text
Typo, instead of setting profileStatusT the second statement was supposed to set profileActT.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 02:54:31 +09:00
Ophestra Umiker 34304119ca
rpcfetch: retry nonce errors
Nonce errors shouldn't be fatal, sometimes weird stuff happens and retrying could fix it.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 02:52:48 +09:00
Ophestra Umiker f0e6395a3e
library: rpc: fix SET_ACTIVITY response type
Had a bad response type, did not affect usage with arRPC, however did not work with proper Discord RPC.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-30 02:51:40 +09:00
Ophestra Umiker 7951106bee
nix: initialise flake with Fyne native dependencies
Fyne has various cgo dependencies, the flake provides their dependencies as well as a build script in a dev shell.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-29 18:01:40 +09:00
Ophestra Umiker 4ba3abc185
rpcfetch: config profiles and graphical user interface
The configuration struct now stores a slice of profiles identified by a UUID and with a friendly name each. A UI was added so configuration changes can happen without an external tool.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-29 17:58:23 +09:00
Ophestra Umiker b3938173ae
library: io: expose ID, User and Config via methods
These fields can be copied safely and is useful information outside the library, so they are exposed via methods that copy their value.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-29 17:48:32 +09:00
Ophestra Umiker 8a975f9a31
rpc: handle response with Identify opcode as retryable
Sometimes arRPC would just send a response with the Identify opcode and `{"cmd":""}`. It is unclear what causes this and the easiest way to recover that I'm aware of is to close the connection and start a fresh one.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-21 21:55:04 +09:00
Ophestra Umiker 72d6a8e95c
rpcfetch: config: add config mutex
The GUI will need to update configuration, so now conf is thread safe.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-21 12:33:18 +09:00
Ophestra Umiker 101b997771
rpcfetch: placeholder: add %hostname placeholder
The variable should be assigned a value in the init function of platform-specific apply implementations.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-21 12:09:50 +09:00
Ophestra Umiker 2c859c1a46
rpcfetch: add template program
Since documentation does not yet exist a template program is added showcasing the intended usage of this library. A configuration interface will be added in a future commit.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-20 22:19:38 +09:00
Ophestra Umiker 802ad250ca
library: rpc: return nonce in SetActivity function
There's currently no way to obtain that value, so it is returned here to help with tinkering with the RPC server in the Discord client.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-20 20:24:13 +09:00
Ophestra Umiker b3325f56b1
library: io: handle retryable errors
Discord client being absent/disconnecting is not fatal to the RPC sender, in cases like that we return ErrAgain and in the case of broken pipe (Discord client going away) also reset the Client state so the caller can choose to retry the operation and therefore initiate a new connection attempt.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-20 01:14:04 +09:00
Ophestra Umiker a985e2b9df
library: io: make connection private and implement Close method
Since some of the state of the connection is tracked by the Client struct and the Raw method is sufficient for any low-level interaction with the Discord RPC, users of the API should not and does not have any reason to interact with the underlying connection.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-19 23:32:51 +09:00
Ophestra Umiker a8dc09e90c
library: rpc: activity data types and set method
Activity data types come from Discord documentation examples as the documented field optionality is inaccurate.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-19 23:21:52 +09:00
Ophestra Umiker 7074a1a950
library: rpc: many RPC data types and client handshake activation
Add a few internal validation functions to make validation cleaner, activation function is called as needed so explicit client activation is not required.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-19 23:16:43 +09:00
Ophestra Umiker 4e1e343081
library: io: implement client type and I/O methods
Path discovery is ported directly from Discord's C++ example, Windows has a crazy looking socket path that needs special syscall magic to dial, so we'll put that off for the time being.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-19 23:11:44 +09:00
Ophestra Umiker 078092bc4c
go: initialise go module
Add github.com/google/uuid as a dependency as well since it will be required for nonce generation. Exclude files based on template from GitHub.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
2024-06-19 23:07:05 +09:00