summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-02-28 15:06:37 +0100
committerSimon Rettberg2019-02-28 15:06:37 +0100
commit8ee36a9ad3b38d9c6d7db73dc5c408b7b7047e9a (patch)
tree92c8f5af053026a0dfdbf8feec31be44930e825d
parent[run-virt] Fix PRINTER handling (diff)
downloadmltk-8ee36a9ad3b38d9c6d7db73dc5c408b7b7047e9a.tar.gz
mltk-8ee36a9ad3b38d9c6d7db73dc5c408b7b7047e9a.tar.xz
mltk-8ee36a9ad3b38d9c6d7db73dc5c408b7b7047e9a.zip
[run-virt] Add printer to UI
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exebin56832 -> 57344 bytes
-rw-r--r--core/modules/run-virt/winres/src/winres.c40
2 files changed, 30 insertions, 10 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe
index 7581b355..2e0aff80 100755
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe
Binary files differ
diff --git a/core/modules/run-virt/winres/src/winres.c b/core/modules/run-virt/winres/src/winres.c
index 90dc1385..ca968cda 100644
--- a/core/modules/run-virt/winres/src/winres.c
+++ b/core/modules/run-virt/winres/src/winres.c
@@ -955,21 +955,25 @@ static DWORD mount(LPNETRESOURCEW share, LPWSTR pass, LPWSTR user)
static void postSuccessfulMount(const netdrive_t *d, wchar_t *letter)
{
+ wchar_t wShortcut[MAX_PATH] = L"", wUncPath[MAX_PATH];
+ BOOL isPrinter = d->letter != NULL && strcmp(d->letter, "PRINTER") == 0;
+ MultiByteToWideChar(CP_UTF8, 0, d->path, -1, wUncPath, MAX_PATH);
if (d->shortcut != NULL && strlen(d->shortcut) != 0) {
- wchar_t tmp[MAX_PATH], wShortcut[MAX_PATH], wTarget[MAX_PATH];
- MultiByteToWideChar(CP_UTF8, 0, d->shortcut, -1, tmp, MAX_PATH);
- StringCchPrintfW(wShortcut, MAX_PATH, L"%s\\%s.lnk", desktopPath, tmp);
- MultiByteToWideChar(CP_UTF8, 0, d->path, -1, tmp, MAX_PATH);
- StringCchPrintfW(wTarget, MAX_PATH, L"\"%s\"", tmp);
- DeleteFileW(wShortcut);
+ MultiByteToWideChar(CP_UTF8, 0, d->shortcut, -1, wShortcut, MAX_PATH);
+ }
+ if (wShortcut[0] != '\0' && !isPrinter) {
+ wchar_t wLinkName[MAX_PATH], wTarget[MAX_PATH];
+ StringCchPrintfW(wLinkName, MAX_PATH, L"%s\\%s.lnk", desktopPath, wShortcut);
+ StringCchPrintfW(wTarget, MAX_PATH, L"\"%s\"", wUncPath); // Quote
+ DeleteFileW(wLinkName);
if (letter == NULL || *letter == '\0') {
- createFolderShortcut(wTarget, wShortcut, letter);
+ createFolderShortcut(wTarget, wLinkName, letter);
} else if (strstr(d->path, "@SSL") != NULL || strstr(d->path, "webdav") != NULL
|| strstr(d->path, "WebDav") != NULL || strstr(d->path, "WebDAV") != NULL
|| strstr(d->path, "@ssl") != NULL || strncmp(d->path, "http", 4) == 0) {
- createFolderShortcut(letter, wShortcut, letter);
+ createFolderShortcut(letter, wLinkName, letter);
} else {
- createFolderShortcut(wTarget, wShortcut, letter);
+ createFolderShortcut(wTarget, wLinkName, letter);
}
// Fix paths and kill explorer if it's the home directory
if (_folderStatus != FS_OK && strncmp(d->shortcut, "Home-", 5) == 0) {
@@ -981,6 +985,18 @@ static void postSuccessfulMount(const netdrive_t *d, wchar_t *letter)
}
}
}
+ if (isPrinter) {
+ wchar_t cmdline[MAX_PATH];
+ BOOL def = FALSE;
+ if (wShortcut[0] != '\0') {
+ def = d->shortcut[0] == '@';
+ //int offs = (def ? 1 : 0); TODO
+ }
+ StringCchPrintfW(cmdline, MAX_PATH, L"printui.dll PrintUIEntry /q /in /n \"%s\"", wUncPath);
+ // TODO: Make sure COM is initialized
+ ShellExecuteW(NULL, L"open", L"rundll32", cmdline, NULL, SW_HIDE);
+ // TODO: Set default; need to wait for install to finish
+ }
}
static BOOL mountNetworkShare(const netdrive_t *d, BOOL useIp)
@@ -1021,16 +1037,20 @@ static BOOL mountNetworkShare(const netdrive_t *d, BOOL useIp)
// Printer
letter[0] = 0;
share.dwType = RESOURCETYPE_PRINT;
+ dlog("Is a printer");
} else if (letter[0] == '-') {
// No letter, just use as resource
letter[0] = 0;
+ dlog("Is a resource");
} else {
letter[1] = ':';
letter[2] = 0;
+ dlog("Is a share with letter");
}
// Connect defined share
retval = mount(&share, pass, user);
- if (retval == NO_ERROR) {
+ if (retval == NO_ERROR
+ || (share.dwType == RESOURCETYPE_PRINT && retval == ERROR_SESSION_CREDENTIAL_CONFLICT)) {
postSuccessfulMount(d, letter);
return TRUE;
}