summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSimon Rettberg2024-03-12 14:18:20 +0100
committerSimon Rettberg2024-03-12 14:18:20 +0100
commit158df84674a8a3d5cbe16af575e8c610cf1361aa (patch)
tree1ac4f2784c391389799fba3a2d64ecbecbc770db /core
parentUpdate gitignore (diff)
downloadmltk-158df84674a8a3d5cbe16af575e8c610cf1361aa.tar.gz
mltk-158df84674a8a3d5cbe16af575e8c610cf1361aa.tar.xz
mltk-158df84674a8a3d5cbe16af575e8c610cf1361aa.zip
[run-virt] openslx.exe: Delay mounting of printers
Diffstat (limited to 'core')
-rw-r--r--core/modules/run-virt/winres/src/winres.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/core/modules/run-virt/winres/src/winres.c b/core/modules/run-virt/winres/src/winres.c
index 753daad3..325c7ab6 100644
--- a/core/modules/run-virt/winres/src/winres.c
+++ b/core/modules/run-virt/winres/src/winres.c
@@ -94,7 +94,7 @@ static int optimizeForRemote();
static int muteSound(BOOL bMute);
static int setShutdownText();
static void readShareFile();
-static BOOL mountNetworkShares();
+static BOOL mountNetworkShares(int attemptNo);
static int queryPasswordDaemon();
static BOOL fileExists(wchar_t* szPath);
static BOOL folderExists(wchar_t* szPath);
@@ -175,7 +175,7 @@ static void CALLBACK tmrResolution(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD
static void CALLBACK setupNetworkDrives(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
static BOOL bInProc = FALSE;
- static int fails = 0;
+ static int attempts = 0;
if (bInProc || _mountDone)
return;
bInProc = TRUE;
@@ -188,12 +188,12 @@ static void CALLBACK setupNetworkDrives(HWND hWnd, UINT uMsg, UINT_PTR idEvent,
int ret = queryPasswordDaemon();
dalog("sND: qPD = %d", ret);
if (ret != 0) {
- if (++fails < 10)
+ if (++attempts < 10)
goto exit_func;
alog("queryPasswordDaemon returned %d", ret);
} else {
- if (!mountNetworkShares()) {
- if (GetTickCount() - _startTime < 30000 && ++fails < 15)
+ if (!mountNetworkShares(attempts)) {
+ if (GetTickCount() - _startTime < 30000 && ++attempts < 15)
goto exit_func;
}
}
@@ -1204,7 +1204,7 @@ static void udpReceived(SOCKET sock)
// Success
spass = xorString(buffer + 2, len, bkey2);
closesocket(sock);
- mountNetworkShares();
+ mountNetworkShares(0);
}
static DWORD mount(LPNETRESOURCEW share, LPWSTR pass, LPWSTR user)
@@ -1384,19 +1384,26 @@ static BOOL mountNetworkShare(const netdrive_t *d, BOOL useIp)
return FALSE;
}
-static BOOL mountNetworkShares()
+static BOOL mountNetworkShares(int attemptNo)
{
+ BOOL withPrinters = attemptNo > 4;
+ int failCount = 0;
+
if (!shareFileOk)
return TRUE;
if (spass == NULL)
return FALSE;
- int failCount = 0;
+
for (int i = 0; i < DRIVEMAX; ++i) {
if (drives[i].path == NULL)
break;
if (drives[i].success)
continue;
- if (mountNetworkShare(&drives[i], FALSE)) {
+ if (!withPrinters && drives[i].letter != NULL
+ && strcmp(drives[i].letter, "PRINTER") == 0) {
+ // Delay connecting printers a bit, might need a resource share or other setup
+ failCount++;
+ } else if (mountNetworkShare(&drives[i], FALSE)) {
drives[i].success = TRUE;
} else if (mountNetworkShare(&drives[i], TRUE)) {
drives[i].success = TRUE;
@@ -1404,9 +1411,8 @@ static BOOL mountNetworkShares()
failCount++;
}
}
- if (failCount > 0)
- return FALSE;
- return TRUE;
+
+ return failCount == 0;
}
static void remapViaSharedFolder()