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)
{
print("Connecting to socket\n");
const char *runtime;
if (IsLinux)
runtime = native_getenv("XDG_RUNTIME_DIR");
else
runtime = native_getenv("TMPDIR");
if (runtime == NULL)
{
print("IPC directory not set\n");
if (!RunningAsService)
MessageBox(NULL, "IPC directory not set",
"Environment variable not set",
MB_OK | MB_ICONSTOP);
ExitProcess(1);
}
const char *runtime;
if (IsLinux)
runtime = native_getenv("XDG_RUNTIME_DIR");
else
runtime = native_getenv("TMPDIR");
if (runtime == NULL)
{
runtime = "/tmp/rpc-bridge/tmpdir";
print("IPC directory not set, fallback to /tmp/rpc-bridge/tmpdir\n");
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 */
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;
*btnInstallStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
if (!IsLinux)
{
*btnInstallStyle |= WS_DISABLED;
*btnRemoveStyle |= WS_DISABLED;
return;
}
// if (!IsLinux)
// {
// *btnInstallStyle |= WS_DISABLED;
// *btnRemoveStyle |= WS_DISABLED;
// return;
// }
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
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");
if (IsLinux == FALSE)
{
/* 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.",
"Unsupported", MB_OK | MB_ICONINFORMATION);
ExitProcess(1);
}
// if (IsLinux == FALSE)
// {
// /* 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.",
// "Unsupported", MB_OK | MB_ICONINFORMATION);
// ExitProcess(1);
// }
SC_HANDLE schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if (schSCManager == NULL)