diff --git a/CMakeLists.txt b/CMakeLists.txt index a2e8e5baf..02aefd4e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,10 @@ if(NOT DEFINED VENDOR) set(VENDOR "FreeRDP" CACHE STRING "FreeRDP package vendor") endif() +if(NOT DEFINED PRODUCT) + set(PRODUCT "FreeRDP" CACHE STRING "FreeRDP package name") +endif() + if(NOT DEFINED FREERDP_VENDOR) set(FREERDP_VENDOR 1) endif() @@ -284,8 +288,8 @@ if(WIN32) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN") # Set product and vendor for dll and exe version information. - set(RC_VERSION_VENDOR "FreeRDP") - set(RC_VERSION_PRODUCT "FreeRDP") + set(RC_VERSION_VENDOR ${VENDOR}) + set(RC_VERSION_PRODUCT ${PRODUCT}) set(RC_VERSION_PATCH ${BUILD_NUMBER}) set(RC_VERSION_DESCRIPTION ${GIT_REVISION}) diff --git a/config.h.in b/config.h.in index 528804066..ce212dd59 100644 --- a/config.h.in +++ b/config.h.in @@ -14,6 +14,9 @@ #define CMAKE_SHARED_LIBRARY_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}" #define CMAKE_SHARED_LIBRARY_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}" +#define FREERDP_VENDOR_STRING "${VENDOR}" +#define FREERDP_PRODUCT_STRING "${PRODUCT}" + /* Include files */ #cmakedefine HAVE_FCNTL_H #cmakedefine HAVE_UNISTD_H diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 8015a4118..806d9bf03 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -195,13 +195,14 @@ void settings_get_computer_name(rdpSettings* settings) GetComputerNameExA(ComputerNameNetBIOS, NULL, &nSize); settings->ComputerName = (char*) malloc(nSize); - if (!settings->ComputerName) - return; + if (!settings->ComputerName) + return; GetComputerNameExA(ComputerNameNetBIOS, settings->ComputerName, &nSize); } rdpSettings* freerdp_settings_new(DWORD flags) { + char* base; rdpSettings* settings; settings = (rdpSettings*) calloc(1, sizeof(rdpSettings)); @@ -471,7 +472,37 @@ rdpSettings* freerdp_settings_new(DWORD flags) settings->HomePath = GetKnownPath(KNOWN_PATH_HOME); if (!settings->HomePath) goto out_fail; - settings->ConfigPath = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, "freerdp"); + + /* For default FreeRDP continue using same config directory + * as in old releases. + * Custom builds use / as config folder. */ + if (_stricmp(FREERDP_VENDOR_STRING, FREERDP_PRODUCT_STRING)) + { + base = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, + FREERDP_VENDOR_STRING); + if (base) + { + settings->ConfigPath = GetCombinedPath( + base, + FREERDP_PRODUCT_STRING); + if (!PathFileExistsA(base)) + if (!CreateDirectoryA(base, NULL)) + settings->ConfigPath = NULL; + } + free (base); + } else { + int i; + char product[sizeof(FREERDP_PRODUCT_STRING)]; + + memset(product, 0, sizeof(product)); + for (i=0; iConfigPath = GetKnownSubPath( + KNOWN_PATH_XDG_CONFIG_HOME, + product); + } + if (!settings->ConfigPath) goto out_fail; @@ -778,7 +809,7 @@ out_fail: void freerdp_settings_free(rdpSettings* settings) { if (!settings) - return; + return; free(settings->ServerHostname); free(settings->Username); free(settings->Password); diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index 2cfa4466e..fe913db7e 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -33,6 +33,13 @@ #include +#if defined(WIN32) +#include +#endif + +static char* GetPath_XDG_CONFIG_HOME(void); +static char* GetPath_XDG_RUNTIME_DIR(void); + /** * SHGetKnownFolderPath function: * http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188/ @@ -43,7 +50,7 @@ * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */ -char* GetEnvAlloc(LPCSTR lpName) +static char* GetEnvAlloc(LPCSTR lpName) { DWORD length; char* env = NULL; @@ -62,7 +69,7 @@ char* GetEnvAlloc(LPCSTR lpName) return env; } -char* GetPath_HOME() +static char* GetPath_HOME(void) { char* path = NULL; @@ -80,7 +87,7 @@ char* GetPath_HOME() return path; } -char* GetPath_TEMP() +static char* GetPath_TEMP(void) { char* path = NULL; @@ -96,11 +103,14 @@ char* GetPath_TEMP() return path; } -char* GetPath_XDG_DATA_HOME() +static char* GetPath_XDG_DATA_HOME(void) { char* path = NULL; - char* home = NULL; +#if defined(WIN32) + path = GetPath_XDG_CONFIG_HOME(); +#else + char* home = NULL; /** * There is a single base directory relative to which user-specific data files should be written. * This directory is defined by the environment variable $XDG_DATA_HOME. @@ -127,15 +137,28 @@ char* GetPath_XDG_DATA_HOME() sprintf(path, "%s%s", home, "/.local/share"); free(home); +#endif return path; } -char* GetPath_XDG_CONFIG_HOME() +static char* GetPath_XDG_CONFIG_HOME(void) { char* path = NULL; - char* home = NULL; +#if defined(WIN32) + path = calloc(MAX_PATH, sizeof(char)); + if (!path) + return NULL; + + if (SHGetFolderPathA(0, CSIDL_APPDATA, NULL, + SHGFP_TYPE_CURRENT, path) != S_OK) + { + free(path); + return NULL; + } +#else + char* home = NULL; /** * There is a single base directory relative to which user-specific configuration files should be written. * This directory is defined by the environment variable $XDG_CONFIG_HOME. @@ -166,15 +189,27 @@ char* GetPath_XDG_CONFIG_HOME() sprintf(path, "%s%s", home, "/.config"); free(home); +#endif return path; } -char* GetPath_XDG_CACHE_HOME() +static char* GetPath_XDG_CACHE_HOME(void) { char* path = NULL; char* home = NULL; +#if defined(WIN32) + home = GetPath_XDG_RUNTIME_DIR(); + if (home) + { + path = GetCombinedPath(home, "cache"); + if (!PathFileExistsA(path)) + if (!CreateDirectoryA(path, NULL)) + path = NULL; + } + free(home); +#else /** * There is a single base directory relative to which user-specific non-essential (cached) data should be written. * This directory is defined by the environment variable $XDG_CACHE_HOME. @@ -201,14 +236,26 @@ char* GetPath_XDG_CACHE_HOME() sprintf(path, "%s%s", home, "/.cache"); free(home); +#endif return path; } -char* GetPath_XDG_RUNTIME_DIR() +char* GetPath_XDG_RUNTIME_DIR(void) { char* path = NULL; +#if defined(WIN32) + path = calloc(MAX_PATH, sizeof(char)); + if (!path) + return NULL; + if (SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA, NULL, + SHGFP_TYPE_CURRENT, path) != S_OK) + { + free(path); + return NULL; + } +#else /** * There is a single base directory relative to which user-specific runtime files and other file objects should be placed. * This directory is defined by the environment variable $XDG_RUNTIME_DIR. @@ -237,6 +284,7 @@ char* GetPath_XDG_RUNTIME_DIR() */ path = GetEnvAlloc("XDG_RUNTIME_DIR"); +#endif if (path) return path;