Skip to content

Commit e1b5bf8

Browse files
committed
2 parents 1dbc2f6 + dedadbf commit e1b5bf8

11 files changed

+233
-102
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
2+
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
3+
name: CMake on Linux x86_64
4+
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Configure Packages
18+
run: |
19+
sudo apt update -y
20+
sudo apt upgrade -y
21+
sudo apt install gcc build-essential cmake libfreetype-dev
22+
- name: Configure CMake
23+
run: |
24+
cd Client
25+
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=MinSizeRel
26+
- name: Build
27+
run: cmake --build ${{github.workspace}}/build --config MinSizeRel
28+
29+
- name: Upload a Build Artifact
30+
uses: actions/[email protected]
31+
with:
32+
name: NexusShell
33+
path: ./build/NexusShell
34+
if-no-files-found: error

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
## Help Wanted:
1818
#### Any contributions implementing following features will most likely be approved
1919
### Top Priority:
20-
- Github Actions and artifact uploading -- The Linux build works on Arch Linux, but not on Ubuntu
2120
- Code stability, reliability, efficiency, rigidity and robustness
2221
- include SDL for aarch64
2322
### High Priority:
@@ -40,14 +39,17 @@ The client only supports Linux.
4039
##### 1.1 Install git if not installed:
4140
- Arch & based: `sudo pacman -Syu git`
4241
- Debian & based: `sudo apt update && sudo apt install git`
42+
- Fedora: `sudo dnf upgrade --refresh && sudo dnf install git`
4343
##### 1.2 Clone
4444
`git clone https://github.com/Tetrapak0/NexusShell`
4545
#### 2. Install FreeType
4646
- Arch & based: `sudo pacman -Syu freetype2`
4747
- Debian & based: `sudo apt update && sudo apt install libfreetype-dev`
48+
- Fedora: `sudo dnf upgrade --refresh && sudo dnf install freetype-dev`
4849
#### 3. Install CMake
4950
- Arch & based: `sudo pacman -Syu cmake`
5051
- Debian & based: `sudo apt update && sudo apt install cmake`
52+
- Fedora: `sudo dnf upgrade --refresh && sudo dnf install cmake`
5153
#### 4. Configure CMake
5254
##### 4.1 Build directory
5355
```console
@@ -59,6 +61,7 @@ mkdir build
5961
###### 4.2.1 Install gcc for aarch64
6062
- Arch & based: `sudo pacman -Syu aarch64-linux-gnu-gcc`
6163
- Debian & based: `sudo apt update && sudo apt install gcc-aarch64-linux-gnu`
64+
- Fedora: `gcc-aarch64-linux-gnu`
6265
###### 4.2.2 Configure CMake for cross-compilation
6366
```console
6467
cmake .. -DCMAKE_BUILD_TYPE=Release -DCROSS_COMPILE

Server/Server.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
<ClInclude Include="include\Config.h" />
208208
<ClInclude Include="include\GUI.h" />
209209
<ClInclude Include="include\Header.h" />
210+
<ClInclude Include="include\Server.h" />
210211
<ClInclude Include="resource.h" />
211212
</ItemGroup>
212213
<ItemGroup>

Server/Server.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@
203203
<ClInclude Include="include\Config.h">
204204
<Filter>Header Files</Filter>
205205
</ClInclude>
206+
<ClInclude Include="include\Server.h">
207+
<Filter>Header Files</Filter>
208+
</ClInclude>
206209
</ItemGroup>
207210
<ItemGroup>
208211
<Image Include="..\icon.png">

Server/include/Config.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class profile {
4040

4141
class id {
4242
public:
43+
bool reconfigure = false;
44+
bool has_commsock = false;
45+
bool has_confsock = false;
46+
int belongs_to_comm_thread_no;
47+
int belongs_to_conf_thread_no;
4348
string ID;
4449
vector<profile> profiles;
4550
id(string in_ID);
@@ -50,8 +55,6 @@ extern vector<id> ids;
5055

5156
using json = nlohmann::ordered_json;
5257

53-
extern bool send_config;
54-
5558
extern void clear_button(int profile, int page, int button);
5659
extern void configure_id(id* id);
57-
extern void write_config(vector<string> args, int arg_size);
60+
extern void write_config(vector<string> args, size_t arg_size);

Server/include/Header.h

-13
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <Windows.h>
1616
#include <WinUser.h>
1717
#include <shellapi.h>
18-
#include <winsock2.h>
19-
#include <ws2tcpip.h>
2018

2119
#include "../../json.hpp"
2220

@@ -38,14 +36,3 @@ extern bool button_cleared;
3836

3937
extern int selected_id;
4038
extern int connected_devices;
41-
42-
extern int server_init();
43-
44-
extern int setup_sock(int& iResult,
45-
WSADATA& wsaData,
46-
SOCKET& ListenSocket,
47-
SOCKET& ClientSocket,
48-
struct addrinfo hints,
49-
struct addrinfo* result);
50-
51-
extern void parse_message(string message);

Server/include/Server.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#pragma once
2+
3+
#include <winsock2.h>
4+
#include <ws2tcpip.h>
5+
#include "Config.h"
6+
7+
using std::string;
8+
using std::vector;
9+
10+
struct sockinfo {
11+
WSADATA wsaData;
12+
int iResult = 1;
13+
int iSendResult = 1;
14+
SOCKET ClientSocket = INVALID_SOCKET;
15+
SOCKET ListenSocket = INVALID_SOCKET;
16+
struct addrinfo hints;
17+
struct addrinfo* result = NULL;
18+
};
19+
20+
extern int server_init();
21+
22+
extern int setup_sock(int& iResult,
23+
WSADATA& wsaData,
24+
SOCKET& ListenSocket,
25+
SOCKET& ClientSocket,
26+
struct addrinfo hints,
27+
struct addrinfo* result,
28+
int socktype);
29+
extern int accept_socket(sockinfo& sock, char* idbuf, char* sock_id, bool& is_valid);
30+
31+
extern sockinfo sock_init(int type);
32+
33+
extern bool is_id(string message);
34+
35+
extern void parse_message(string message);
36+
extern void comm_comm(sockinfo commsock);
37+
extern void conf_comm(sockinfo confsock);
38+
extern void reconfigure(id& id, sockinfo& sockinfo);
39+
extern void begin_accept_cycle(sockinfo& commsock, sockinfo& confsock);

Server/src/Config.cpp

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#include "../include/Header.h"
22
#include "../include/Config.h"
33

4+
bool button_cleared = false;
5+
6+
id::id(string in_ID) : ID(in_ID) {}
7+
bool id::operator==(const id& other) const { return ID == other.ID; }
8+
vector<id> ids;
9+
410
void read_config(json& config, id* ID) {
511
if (config[config.begin().key()].contains("profiles")) {
612
ID->profiles.clear();
@@ -12,6 +18,8 @@ void read_config(json& config, id* ID) {
1218
button button1;
1319
profile1.buttons.push_back(button1);
1420
}
21+
ID->profiles.push_back(profile1);
22+
return;
1523
}
1624
for (int i = 0; i < profile_count; i++) {
1725
profile profile1;
@@ -21,11 +29,13 @@ void read_config(json& config, id* ID) {
2129
if (profile_store.contains("pages")) {
2230
int page_count = 0;
2331
for (auto& page : profile_store["pages"]) if (page.is_object()) page_count++;
24-
if (page_count == 0)
32+
if (page_count == 0) {
2533
for (int a = 0; i < profile1.columns * profile1.rows; i++) {
2634
button button1;
2735
profile1.buttons.push_back(button1);
2836
}
37+
continue;
38+
}
2939
for (int j = 0; j < page_count; j++) {
3040
json page_store = profile_store["pages"][to_string(j)];
3141
if (page_store.contains("buttons")) {
@@ -81,7 +91,7 @@ void configure_id(id* id) {
8191
read_config(config, id);
8292
reader.close();
8393
cerr << "configured\n";
84-
send_config = true;
94+
id->reconfigure = true;
8595
return;
8696
} catch (...) {
8797
cerr << "invalid config!\nclearing...\n";
@@ -90,7 +100,7 @@ void configure_id(id* id) {
90100
ofstream writer(nxsh_config);
91101
writer << empty_config.dump(4);
92102
writer.close();
93-
send_config = true;
103+
id->reconfigure = true;
94104
}
95105
}
96106
reader.close();
@@ -106,7 +116,7 @@ void configure_id(id* id) {
106116
ofstream writer(nxsh_config);
107117
writer << empty_config.dump(4);
108118
writer.close();
109-
send_config = true;
119+
id->reconfigure = true;
110120
}
111121

112122
void clear_button(int profile, int page, int button) {
@@ -129,10 +139,10 @@ void clear_button(int profile, int page, int button) {
129139
writer.close();
130140
read_config(to_remove, &ids[selected_id]);
131141
button_cleared = true;
132-
send_config = true;
142+
ids[selected_id].reconfigure = true;
133143
}
134144

135-
void write_config(vector<string> args, int arg_size) {
145+
void write_config(vector<string> args, size_t arg_size) {
136146
string nxsh_config(getenv("USERPROFILE"));
137147
nxsh_config += "\\AppData\\Roaming\\NexusShell";
138148
if (!exists(nxsh_config)) create_directory(nxsh_config);

Server/src/GUI.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ ImGuiStyle& set_style(/*style parameters*/) {
143143
}
144144

145145
int tray_init() {
146-
#ifdef _WIN32
147-
Tray::Tray tray("NexusShell", "..\\..\\icon.ico");
148-
#else
149-
Tray::Tray tray("NexusShell", "../../icon.ico");
150-
#endif
146+
Tray::Tray tray("NexusShell", "icon.ico");
151147
tray.addEntry(Tray::Button("Show Window\0", [&] { ShowWindow(FindWindow(NULL, L"NexusShell"), SW_NORMAL);
152148
SetFocus(FindWindow(NULL, L"NexusShell")); }));
153149
tray.addEntry(Tray::Separator());
@@ -253,7 +249,7 @@ void draw_properties(int index) {
253249
write_config(to_write, to_write.size());
254250
to_write = { CURRENT_ID.ID, "profiles", to_string(0), "pages", to_string(CURRENT_ID.profiles[0].current_page), "buttons", to_string(properties_to_draw), "action", CURRENT_ID_AND_BUTTON.action };
255251
write_config(to_write, to_write.size());
256-
send_config = true;
252+
ids[selected_id].reconfigure = true;
257253
}
258254
ImGui::EndDisabled();
259255
ImGui::SameLine();

0 commit comments

Comments
 (0)