mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
Merge pull request #12285 from akallabeth/pulse-name
Use application details for names
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/codec/audio.h>
|
||||
#include <freerdp/client/audin.h>
|
||||
#include <freerdp/utils/helpers.h>
|
||||
|
||||
#include "audin_main.h"
|
||||
|
||||
@@ -493,9 +494,9 @@ static UINT audin_pulse_parse_addin_args(AudinPulseDevice* pulse, const ADDIN_AR
|
||||
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
|
||||
if (!client_name)
|
||||
client_name = "freerdp";
|
||||
client_name = freerdp_getApplicationDetailsString();
|
||||
if (!stream_name)
|
||||
stream_name = "freerdp_audin";
|
||||
stream_name = freerdp_getApplicationDetailsString();
|
||||
|
||||
pulse->client_name = _strdup(client_name);
|
||||
pulse->stream_name = _strdup(stream_name);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/utils/helpers.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -460,7 +461,6 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
DWORD lpNumberOfFreeClusters = 0;
|
||||
DWORD lpTotalNumberOfClusters = 0;
|
||||
WIN32_FILE_ATTRIBUTE_DATA wfad = { 0 };
|
||||
WCHAR LabelBuffer[32] = { 0 };
|
||||
|
||||
if (!drive || !irp)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
@@ -479,8 +479,7 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
case FileFsVolumeInformation:
|
||||
{
|
||||
/* http://msdn.microsoft.com/en-us/library/cc232108.aspx */
|
||||
const WCHAR* volumeLabel =
|
||||
InitializeConstWCharFromUtf8("FREERDP", LabelBuffer, ARRAYSIZE(LabelBuffer));
|
||||
const WCHAR* volumeLabel = freerdp_getApplicationDetailsStringW();
|
||||
const size_t volumeLabelLen = (_wcslen(volumeLabel) + 1) * sizeof(WCHAR);
|
||||
const size_t length = 17ul + volumeLabelLen;
|
||||
|
||||
@@ -525,6 +524,7 @@ static UINT drive_process_irp_query_volume_information(DRIVE_DEVICE* drive, IRP*
|
||||
|
||||
case FileFsAttributeInformation:
|
||||
{
|
||||
WCHAR LabelBuffer[32] = { 0 };
|
||||
/* http://msdn.microsoft.com/en-us/library/cc232101.aspx */
|
||||
const WCHAR* diskType =
|
||||
InitializeConstWCharFromUtf8("FAT32", LabelBuffer, ARRAYSIZE(LabelBuffer));
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <winpr/assert.h>
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/utils/helpers.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -103,18 +104,26 @@ typedef struct
|
||||
rdpCupsPrintJob* printjob;
|
||||
} rdpCupsPrinter;
|
||||
|
||||
static void printer_cups_get_printjob_name(char* buf, size_t size, size_t id)
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
static char* printer_cups_get_printjob_name(size_t id)
|
||||
{
|
||||
struct tm tres = { 0 };
|
||||
const time_t tt = time(NULL);
|
||||
const struct tm* t = localtime_r(&tt, &tres);
|
||||
|
||||
WINPR_ASSERT(buf);
|
||||
WINPR_ASSERT(size > 0);
|
||||
char* str = NULL;
|
||||
size_t len = 0;
|
||||
const int rc =
|
||||
winpr_asprintf(&str, &len, "%s Print %04d-%02d-%02d %02d-%02d-%02d - Job %" PRIuz,
|
||||
freerdp_getApplicationDetailsString(), t->tm_year + 1900, t->tm_mon + 1,
|
||||
t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, id);
|
||||
if (rc <= 0)
|
||||
{
|
||||
free(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
(void)sprintf_s(buf, size - 1, "FreeRDP Print %04d-%02d-%02d %02d-%02d-%02d - Job %" PRIuz,
|
||||
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec,
|
||||
id);
|
||||
return str;
|
||||
}
|
||||
|
||||
static bool http_status_ok(http_status_t status)
|
||||
@@ -197,8 +206,6 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
cups_printjob->printjob.Close = printer_cups_close_printjob;
|
||||
|
||||
{
|
||||
char buf[100] = { 0 };
|
||||
|
||||
cups_printjob->printjob_object = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
|
||||
HTTP_ENCRYPT_IF_REQUESTED, 1, 10000, NULL);
|
||||
|
||||
@@ -209,10 +216,16 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
printer_cups_get_printjob_name(buf, sizeof(buf), cups_printjob->printjob.id);
|
||||
char* jobTitle = printer_cups_get_printjob_name(cups_printjob->printjob.id);
|
||||
if (!jobTitle)
|
||||
{
|
||||
httpClose(cups_printjob->printjob_object);
|
||||
free(cups_printjob);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cups_printjob->printjob_id =
|
||||
cupsCreateJob(cups_printjob->printjob_object, printer->name, buf, 0, NULL);
|
||||
cupsCreateJob(cups_printjob->printjob_object, printer->name, jobTitle, 0, NULL);
|
||||
|
||||
if (!cups_printjob->printjob_id)
|
||||
{
|
||||
@@ -220,11 +233,14 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
printer->driver);
|
||||
httpClose(cups_printjob->printjob_object);
|
||||
free(cups_printjob);
|
||||
free(jobTitle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
http_status_t rc = cupsStartDocument(cups_printjob->printjob_object, printer->name,
|
||||
cups_printjob->printjob_id, buf, CUPS_FORMAT_AUTO, 1);
|
||||
http_status_t rc =
|
||||
cupsStartDocument(cups_printjob->printjob_object, printer->name,
|
||||
cups_printjob->printjob_id, jobTitle, CUPS_FORMAT_AUTO, 1);
|
||||
free(jobTitle);
|
||||
if (!http_status_ok(rc))
|
||||
WLog_WARN(TAG, "cupsStartDocument [printer '%s', driver '%s'] returned %s",
|
||||
printer->name, printer->driver, httpStatus(rc));
|
||||
|
||||
@@ -72,27 +72,37 @@ typedef struct
|
||||
rdpWinPrintJob* printjob;
|
||||
} rdpWinPrinter;
|
||||
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
static WCHAR* printer_win_get_printjob_name(size_t id)
|
||||
{
|
||||
time_t tt;
|
||||
struct tm tres;
|
||||
errno_t err;
|
||||
WCHAR* str;
|
||||
size_t len = 1024;
|
||||
int rc;
|
||||
WCHAR* str = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
tt = time(NULL);
|
||||
err = localtime_s(&tres, &tt);
|
||||
const time_t tt = time(NULL);
|
||||
const errno_t err = localtime_s(&tres, &tt);
|
||||
|
||||
str = calloc(len, sizeof(WCHAR));
|
||||
if (!str)
|
||||
return NULL;
|
||||
do
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
str = calloc(len + 1, sizeof(WCHAR));
|
||||
if (!str)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = swprintf_s(str, len,
|
||||
WIDEN("FreeRDP Print %04d-%02d-%02d% 02d-%02d-%02d - Job %") WIDEN(PRIuz)
|
||||
WIDEN("\0"),
|
||||
tres.tm_year + 1900, tres.tm_mon + 1, tres.tm_mday, tres.tm_hour, tres.tm_min,
|
||||
tres.tm_sec, id);
|
||||
const int rc = swprintf_s(
|
||||
str, len,
|
||||
WIDEN("%s Print %04d-%02d-%02d% 02d-%02d-%02d - Job %") WIDEN(PRIuz) WIDEN("\0"),
|
||||
freerdp_getApplicationDetailsStringW(), tres.tm_year + 1900, tres.tm_mon + 1,
|
||||
tres.tm_mday, tres.tm_hour, tres.tm_min, tres.tm_sec, id);
|
||||
if (rc <= 0)
|
||||
{
|
||||
free(str);
|
||||
return NULL;
|
||||
}
|
||||
len = WINPR_ASSERTING_INT_CAST(size_t, rc) + 1ull;
|
||||
} while (!str);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/utils/helpers.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
@@ -722,9 +723,9 @@ static UINT rdpsnd_pulse_parse_addin_args(rdpsndPulsePlugin* pulse, const ADDIN_
|
||||
} while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
|
||||
if (!client_name)
|
||||
client_name = "freerdp";
|
||||
client_name = freerdp_getApplicationDetailsString();
|
||||
if (!stream_name)
|
||||
stream_name = "freerdp";
|
||||
stream_name = freerdp_getApplicationDetailsString();
|
||||
|
||||
pulse->client_name = _strdup(client_name);
|
||||
pulse->stream_name = _strdup(stream_name);
|
||||
|
||||
@@ -134,7 +134,8 @@ static BOOL tsmf_pulse_open(ITSMFAudioDevice* audio, const char* device)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pulse->context = pa_context_new(pa_threaded_mainloop_get_api(pulse->mainloop), "freerdp");
|
||||
pulse->context = pa_context_new(pa_threaded_mainloop_get_api(pulse->mainloop),
|
||||
freerdp_getApplicationDetailsString());
|
||||
|
||||
if (!pulse->context)
|
||||
{
|
||||
@@ -233,7 +234,8 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice* pulse)
|
||||
|
||||
DEBUG_TSMF("");
|
||||
pa_threaded_mainloop_lock(pulse->mainloop);
|
||||
pulse->stream = pa_stream_new(pulse->context, "freerdp", &pulse->sample_spec, NULL);
|
||||
pulse->stream = pa_stream_new(pulse->context, freerdp_ApplicationDetailsString(),
|
||||
&pulse->sample_spec, NULL);
|
||||
|
||||
if (!pulse->stream)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/utils/helpers.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@@ -617,7 +618,7 @@ static COMMAND_LINE_ARGUMENT_A* create_merged_args(const COMMAND_LINE_ARGUMENT_A
|
||||
BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
|
||||
const COMMAND_LINE_ARGUMENT_A* custom)
|
||||
{
|
||||
const char* name = "FreeRDP";
|
||||
const char* name = freerdp_getApplicationDetailsString();
|
||||
|
||||
/* allocate a merged copy of implementation defined and default arguments */
|
||||
size_t lcount = 0;
|
||||
@@ -629,7 +630,7 @@ BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
|
||||
name = argv[0];
|
||||
|
||||
printf("\n");
|
||||
printf("FreeRDP - A Free Remote Desktop Protocol Implementation\n");
|
||||
printf("%s - A Free Remote Desktop Protocol Implementation\n", name);
|
||||
printf("See www.freerdp.com for more information\n");
|
||||
printf("\n");
|
||||
printf("Usage: %s [file] [options] [/v:<server>[:port]]\n", argv[0]);
|
||||
@@ -5574,7 +5575,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int(
|
||||
if (compatibility)
|
||||
{
|
||||
WLog_WARN(TAG, "Unsupported command line syntax!");
|
||||
WLog_WARN(TAG, "FreeRDP 1.0 style syntax was dropped with version 3!");
|
||||
WLog_WARN(TAG, "%s 1.0 style syntax was dropped with version 3!",
|
||||
freerdp_getApplicationDetailsString());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,23 @@ extern "C"
|
||||
*/
|
||||
FREERDP_API WINPR_ATTR_NODISCARD SSIZE_T freerdp_getApplicationDetailsVersion(void);
|
||||
|
||||
/** @brief Get the current details of the application.
|
||||
* Defaults to \b <Vendor>-<Product><Version> if \b WITH_RESOURCE_VERSIONING is defined,
|
||||
* \b <Vendor>-<Product> if <Vendor> does not equal <Product> and <Product> otherwise.
|
||||
*
|
||||
* @return The current application details as string.
|
||||
* @since version 3.23.0
|
||||
*/
|
||||
FREERDP_API WINPR_ATTR_NODISCARD const char* freerdp_getApplicationDetailsString(void);
|
||||
|
||||
/** @brief Get the current details of the application. Wide character version.
|
||||
* See \ref freerdp_getApplicationDetailsString for details.
|
||||
*
|
||||
* @return The current application details as string.
|
||||
* @since version 3.23.0
|
||||
*/
|
||||
FREERDP_API WINPR_ATTR_NODISCARD const WCHAR* freerdp_getApplicationDetailsStringW(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -812,7 +812,6 @@ char* freerdp_settings_get_config_path(void)
|
||||
|
||||
rdpSettings* freerdp_settings_new(DWORD flags)
|
||||
{
|
||||
char* issuers[] = { "FreeRDP", "FreeRDP-licenser" };
|
||||
const BOOL server = (flags & FREERDP_SETTINGS_SERVER_MODE) != 0 ? TRUE : FALSE;
|
||||
const BOOL remote = (flags & FREERDP_SETTINGS_REMOTE_MODE) != 0 ? TRUE : FALSE;
|
||||
rdpSettings* settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
|
||||
@@ -820,6 +819,32 @@ rdpSettings* freerdp_settings_new(DWORD flags)
|
||||
if (!settings)
|
||||
return NULL;
|
||||
|
||||
{
|
||||
const char* vendor = freerdp_getApplicationDetailsVendor();
|
||||
const char* product = freerdp_getApplicationDetailsProduct();
|
||||
const char* details = freerdp_getApplicationDetailsString();
|
||||
char* issuer1 = NULL;
|
||||
char* issuer2 = NULL;
|
||||
char* issuer3 = NULL;
|
||||
size_t len = 0;
|
||||
(void)winpr_asprintf(&issuer1, &len, "%s-licenser", freerdp_getApplicationDetailsString());
|
||||
(void)winpr_asprintf(&issuer2, &len, "%s-licenser", freerdp_getApplicationDetailsVendor());
|
||||
(void)winpr_asprintf(&issuer3, &len, "%s-licenser", freerdp_getApplicationDetailsProduct());
|
||||
|
||||
char* issuers[] = { WINPR_CAST_CONST_PTR_AWAY(vendor, char*),
|
||||
WINPR_CAST_CONST_PTR_AWAY(product, char*),
|
||||
WINPR_CAST_CONST_PTR_AWAY(details, char*),
|
||||
issuer1,
|
||||
issuer2,
|
||||
issuer3 };
|
||||
|
||||
const BOOL res = freerdp_server_license_issuers_copy(settings, issuers, ARRAYSIZE(issuers));
|
||||
free(issuer1);
|
||||
free(issuer2);
|
||||
free(issuer3);
|
||||
if (!res)
|
||||
goto out_fail;
|
||||
}
|
||||
if (!server && !remote)
|
||||
{
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayHttpUserAgent,
|
||||
@@ -879,15 +904,27 @@ rdpSettings* freerdp_settings_new(DWORD flags)
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_ClipboardFeatureMask,
|
||||
CLIPRDR_FLAG_DEFAULT_MASK))
|
||||
goto out_fail;
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerLicenseCompanyName, "FreeRDP"))
|
||||
goto out_fail;
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerLicenseProductName,
|
||||
"FreeRDP-licensing-server"))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerLicenseCompanyName,
|
||||
freerdp_getApplicationDetailsVendor()))
|
||||
goto out_fail;
|
||||
|
||||
{
|
||||
size_t len = 0;
|
||||
char* val = NULL;
|
||||
(void)winpr_asprintf(&val, &len, "%s-licensing-server",
|
||||
freerdp_getApplicationDetailsProduct());
|
||||
if (!val)
|
||||
goto out_fail;
|
||||
|
||||
const BOOL rc =
|
||||
freerdp_settings_set_string(settings, FreeRDP_ServerLicenseProductName, val);
|
||||
free(val);
|
||||
if (!rc)
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerLicenseProductVersion, 1))
|
||||
goto out_fail;
|
||||
if (!freerdp_server_license_issuers_copy(settings, issuers, ARRAYSIZE(issuers)))
|
||||
goto out_fail;
|
||||
|
||||
if (!freerdp_settings_set_uint16(settings, FreeRDP_SupportedColorDepths,
|
||||
RNS_UD_32BPP_SUPPORT | RNS_UD_24BPP_SUPPORT |
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <freerdp/utils/smartcardlogon.h>
|
||||
#include <freerdp/crypto/crypto.h>
|
||||
#include <freerdp/utils/helpers.h>
|
||||
|
||||
#include <openssl/obj_mac.h>
|
||||
|
||||
@@ -747,7 +748,14 @@ static SmartcardCertInfo* smartcardCertInfo_New(const char* privKeyPEM, const ch
|
||||
goto fail;
|
||||
}
|
||||
|
||||
cert->reader = ConvertUtf8ToWCharAlloc("FreeRDP Emulator", NULL);
|
||||
{
|
||||
char* str = NULL;
|
||||
size_t len = 0;
|
||||
(void)winpr_asprintf(&str, &len, "%s Emulator", freerdp_getApplicationDetailsString());
|
||||
if (str)
|
||||
cert->reader = ConvertUtf8NToWCharAlloc(str, len, NULL);
|
||||
free(str);
|
||||
}
|
||||
if (!cert->reader)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -33,9 +33,41 @@
|
||||
static INIT_ONCE s_freerdp_app_details_once = INIT_ONCE_STATIC_INIT;
|
||||
static char s_freerdp_vendor_string[MAX_PATH] = { 0 };
|
||||
static char s_freerdp_product_string[MAX_PATH] = { 0 };
|
||||
static char s_freerdp_details_string[3ull * MAX_PATH] = { 0 };
|
||||
static WCHAR s_freerdp_details_string_w[3ull * MAX_PATH] = { 0 };
|
||||
static SSIZE_T s_freerdp_version = -1;
|
||||
static BOOL s_freerdp_app_details_are_custom = FALSE;
|
||||
|
||||
static void updateDetailsString(void)
|
||||
{
|
||||
const char* vendor = s_freerdp_vendor_string;
|
||||
const char* product = s_freerdp_product_string;
|
||||
const SSIZE_T version = s_freerdp_version;
|
||||
|
||||
WINPR_ASSERT(vendor);
|
||||
WINPR_ASSERT(product);
|
||||
if (s_freerdp_app_details_are_custom)
|
||||
{
|
||||
if (version < 0)
|
||||
(void)_snprintf(s_freerdp_details_string, sizeof(s_freerdp_details_string) - 1, "%s-%s",
|
||||
vendor, product);
|
||||
else
|
||||
(void)_snprintf(s_freerdp_details_string, sizeof(s_freerdp_details_string) - 1,
|
||||
"%s-%s%" PRIdz, vendor, product, version);
|
||||
}
|
||||
else if (version < 0)
|
||||
{
|
||||
(void)_snprintf(s_freerdp_details_string, sizeof(s_freerdp_details_string) - 1, "%s",
|
||||
product);
|
||||
}
|
||||
else
|
||||
(void)_snprintf(s_freerdp_details_string, sizeof(s_freerdp_details_string) - 1, "%s%" PRIdz,
|
||||
product, version);
|
||||
|
||||
(void)ConvertUtf8NToWChar(s_freerdp_details_string, sizeof(s_freerdp_details_string),
|
||||
s_freerdp_details_string_w, sizeof(s_freerdp_details_string_w) - 1);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK init_app_details(WINPR_ATTR_UNUSED PINIT_ONCE once,
|
||||
WINPR_ATTR_UNUSED PVOID param,
|
||||
WINPR_ATTR_UNUSED PVOID* context)
|
||||
@@ -52,6 +84,7 @@ static BOOL CALLBACK init_app_details(WINPR_ATTR_UNUSED PINIT_ONCE once,
|
||||
#else
|
||||
s_freerdp_version = -1;
|
||||
#endif
|
||||
updateDetailsString();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -89,6 +122,7 @@ BOOL freerdp_setApplicationDetails(const char* vendor, const char* product, SSIZ
|
||||
|
||||
const BOOL rc = winpr_setApplicationDetails(str, "WinPR", -1);
|
||||
free(str);
|
||||
updateDetailsString();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -146,6 +180,16 @@ SSIZE_T freerdp_getApplicationDetailsVersion(void)
|
||||
return s_freerdp_version;
|
||||
}
|
||||
|
||||
const char* freerdp_getApplicationDetailsString(void)
|
||||
{
|
||||
return s_freerdp_details_string;
|
||||
}
|
||||
|
||||
const WCHAR* freerdp_getApplicationDetailsStringW(void)
|
||||
{
|
||||
return s_freerdp_details_string_w;
|
||||
}
|
||||
|
||||
BOOL freerdp_areApplicationDetailsCustomized(void)
|
||||
{
|
||||
return s_freerdp_app_details_are_custom;
|
||||
|
||||
Reference in New Issue
Block a user