mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user