MacOS Fix

This commit is contained in:
OrigamingWasTaken 2024-05-21 23:39:51 +02:00
parent 81aa5d8d18
commit 8dd5952a64
3 changed files with 38 additions and 28 deletions

View File

@ -248,22 +248,32 @@ char *native_getenv(const char *name)
void ConnectToSocket(int fd) void ConnectToSocket(int fd)
{ {
print("Connecting to socket\n"); print("Connecting to socket\n");
const char *runtime; const char *runtime;
if (IsLinux) if (IsLinux)
runtime = native_getenv("XDG_RUNTIME_DIR"); runtime = native_getenv("XDG_RUNTIME_DIR");
else else
runtime = native_getenv("TMPDIR"); runtime = native_getenv("TMPDIR");
if (runtime == NULL) if (runtime == NULL)
{ {
print("IPC directory not set\n"); runtime = "/tmp/rpc-bridge/tmpdir";
if (!RunningAsService) print("IPC directory not set, fallback to /tmp/rpc-bridge/tmpdir\n");
MessageBox(NULL, "IPC directory not set",
"Environment variable not set",
MB_OK | MB_ICONSTOP);
ExitProcess(1);
}
print("IPC directory: %s\n", runtime); // Check if the directory exists
DWORD dwAttrib = GetFileAttributes(runtime);
if (dwAttrib == INVALID_FILE_ATTRIBUTES || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
{
print("IPC directory does not exist: %s\n", runtime);
// Handle the case where the directory doesn't exist
// For example, create the directory
if (!RunningAsService)
MessageBox(NULL, "IPC directory does not exist",
"Directory not found",
MB_OK | MB_ICONSTOP);
ExitProcess(1);
}
}
print("IPC directory: %s\n", runtime);
/* TODO: check for multiple discord instances and create a pipe for each */ /* TODO: check for multiple discord instances and create a pipe for each */
const char *discordUnixPipes[] = { const char *discordUnixPipes[] = {

12
gui.c
View File

@ -182,12 +182,12 @@ VOID SetButtonStyles(INT *btnStartStyle, INT *btnRemoveStyle, INT *btnInstallSty
*btnRemoveStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; *btnRemoveStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
*btnInstallStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; *btnInstallStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
if (!IsLinux) // if (!IsLinux)
{ // {
*btnInstallStyle |= WS_DISABLED; // *btnInstallStyle |= WS_DISABLED;
*btnRemoveStyle |= WS_DISABLED; // *btnRemoveStyle |= WS_DISABLED;
return; // return;
} // }
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE schService = OpenService(hSCManager, "rpc-bridge", SERVICE_START | SERVICE_QUERY_STATUS); SC_HANDLE schService = OpenService(hSCManager, "rpc-bridge", SERVICE_START | SERVICE_QUERY_STATUS);

View File

@ -88,13 +88,13 @@ void InstallService(int ServiceStartType, LPCSTR Path)
{ {
print("Registering service\n"); print("Registering service\n");
if (IsLinux == FALSE) // if (IsLinux == FALSE)
{ // {
/* FIXME: I don't know how to get the TMPDIR without getenv */ // /* FIXME: I don't know how to get the TMPDIR without getenv */
MessageBox(NULL, "Registering as a service is not supported on macOS at the moment.", // MessageBox(NULL, "Registering as a service is not supported on macOS at the moment.",
"Unsupported", MB_OK | MB_ICONINFORMATION); // "Unsupported", MB_OK | MB_ICONINFORMATION);
ExitProcess(1); // ExitProcess(1);
} // }
SC_HANDLE schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE); SC_HANDLE schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if (schSCManager == NULL) if (schSCManager == NULL)