Skip to content

Commit

Permalink
Added ability to repeate waiting for no pending device
Browse files Browse the repository at this point in the history
installation activities
  • Loading branch information
vfrolov committed Jan 10, 2012
1 parent 77f307d commit 5066a42
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
31 changes: 26 additions & 5 deletions setup/devutils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (c) 2006-2011 Vyacheslav Frolov
* Copyright (c) 2006-2012 Vyacheslav Frolov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,6 +19,10 @@
*
*
* $Log$
* Revision 1.21 2012/01/10 11:24:27 vfrolov
* Added ability to repeate waiting for no pending device
* installation activities
*
* Revision 1.20 2011/12/15 15:51:48 vfrolov
* Fixed types
*
Expand Down Expand Up @@ -945,7 +949,7 @@ bool InstallDevice(
return res == IDCONTINUE;
}
///////////////////////////////////////////////////////////////
bool WaitNoPendingInstallEvents(int timeLimit)
bool WaitNoPendingInstallEvents(int timeLimit, bool repeate)
{
typedef DWORD (WINAPI *PWAITNOPENDINGINSTALLEVENTS)(IN DWORD);
static PWAITNOPENDINGINSTALLEVENTS pWaitNoPendingInstallEvents = NULL;
Expand Down Expand Up @@ -980,6 +984,7 @@ bool WaitNoPendingInstallEvents(int timeLimit)

if (inTrace)
Trace(" OK\n");

SetLastError(ERROR_SUCCESS);
break;
}
Expand All @@ -996,17 +1001,33 @@ bool WaitNoPendingInstallEvents(int timeLimit)
DWORD timeElapsed = GetTickCount() - startTime;

if (timeLimit != -1 && timeElapsed >= DWORD(timeLimit * 1000)) {
if (inTrace)
if (inTrace) {
Trace(" timeout\n");
inTrace = FALSE;
}

if (!Silent() && repeate) {
if (ShowMsg(MB_YESNO,
"The device installation activities are still pending.\n"
"Continue to wait?\n") == IDYES)
{
startTime = GetTickCount();
} else {
repeate = FALSE;
}

continue;
}

SetLastError(ERROR_TIMEOUT);
break;
}

if (!inTrace) {
if (timeLimit != -1)
Trace("Wating for no pending device installation activities (%u secs) ", (unsigned)timeLimit);
Trace("Waiting for no pending device installation activities (%u secs) ", (unsigned)timeLimit);
else
Trace("Wating for no pending device installation activities (perpetually) ");
Trace("Waiting for no pending device installation activities (perpetually) ");

inTrace = TRUE;
}
Expand Down
9 changes: 7 additions & 2 deletions setup/devutils.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (c) 2006-2011 Vyacheslav Frolov
* Copyright (c) 2006-2012 Vyacheslav Frolov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,6 +19,10 @@
*
*
* $Log$
* Revision 1.14 2012/01/10 11:24:27 vfrolov
* Added ability to repeate waiting for no pending device
* installation activities
*
* Revision 1.13 2011/12/15 15:51:48 vfrolov
* Fixed types
*
Expand Down Expand Up @@ -170,7 +174,8 @@ bool InstallDevice(
BOOL *pRebootRequired);

bool WaitNoPendingInstallEvents(
int timeLimit);
int timeLimit,
bool repeate = FALSE);
///////////////////////////////////////////////////////////////

#endif /* _C0C_DEVUTILS_H_ */
25 changes: 20 additions & 5 deletions setup/setup.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (c) 2006-2011 Vyacheslav Frolov
* Copyright (c) 2006-2012 Vyacheslav Frolov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,6 +19,10 @@
*
*
* $Log$
* Revision 1.54 2012/01/10 11:24:27 vfrolov
* Added ability to repeate waiting for no pending device
* installation activities
*
* Revision 1.53 2011/12/29 14:34:23 vfrolov
* Implemented RealPortName=COM<n> for PortName=COM#
*
Expand Down Expand Up @@ -289,6 +293,7 @@ static const InfFile::InfFileUninstall infFileUnnstallList[] = {
};
///////////////////////////////////////////////////////////////
static int timeout = 0;
static bool repeate_timeout = FALSE;
static bool detailPrms = FALSE;
static bool no_update = FALSE;
static bool no_update_fnames = FALSE;
Expand Down Expand Up @@ -1852,7 +1857,9 @@ void Help(const char *pProgName)
"\n"
"Options:\n"
" --output <file> - file for output, default is console\n"
" --wait <to> - wait <to> seconds for install completion\n"
" --wait [+]<to> - wait <to> seconds for install completion. If\n"
" <to> has '+' prefix then ask user to continue\n"
" waiting after <to> seconds elapsing\n"
" (by default <to> is 0 - no wait)\n"
" --detail-prms - show detailed parameters\n"
" --silent - suppress dialogs if possible\n"
Expand Down Expand Up @@ -1966,7 +1973,7 @@ static int Complete(bool ok)
{
if (ok) {
if (timeout > 0)
WaitNoPendingInstallEvents(timeout);
WaitNoPendingInstallEvents(timeout, repeate_timeout);

return 0;
}
Expand All @@ -1981,6 +1988,7 @@ int Main(int argc, const char* argv[])

Silent(FALSE);
timeout = 0;
repeate_timeout = FALSE;
detailPrms = FALSE;
no_update = FALSE;
no_update_fnames = FALSE;
Expand All @@ -2001,8 +2009,15 @@ int Main(int argc, const char* argv[])
if (!strcmp(argv[1], "--wait") && argc > 2) {
int num;

if (StrToInt(argv[2], &num) && num >= 0)
timeout = num;
if (!StrToInt(argv[2], &num) || num < 0) {
ConsoleWrite("Invalid option %s %s\n", argv[1], argv[2]);
return 1;
}

timeout = num;

if (argv[2][0] == '+')
repeate_timeout = TRUE;

argv[2] = argv[0];
argv += 2;
Expand Down

0 comments on commit 5066a42

Please sign in to comment.