comparison ui/installwrapper.cpp @ 385:72487438a180

More user visible errors. Correct parameters for installation.
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 15 Apr 2014 17:48:06 +0200
parents dc4efb0a70cb
children 32309299bec9
comparison
equal deleted inserted replaced
384:638db75f0fdf 385:72487438a180
67 if (!writeChoices(&choicesFile)) { 67 if (!writeChoices(&choicesFile)) {
68 emit error(tr("Failed to write temporary file.")); 68 emit error(tr("Failed to write temporary file."));
69 return; 69 return;
70 } 70 }
71 71
72 QString parameters = "\"list=" + mCertListFile +
73 "\" \"choices=" + choicesFile.fileName() + "\"";
74
75 #ifdef WIN32 72 #ifdef WIN32
76 /* QProcess on Windows uses CreateProcess but we have to 73 /* QProcess on Windows uses CreateProcess but we have to
77 * use the runas shell command to get the UAC prompt if necessary. 74 * use the runas shell command to get the UAC prompt if necessary.
78 * So we have to handle the process ourself. Starting with 75 * So we have to handle the process ourself. Starting with
79 * shell execute also means that we can not have stdout and stderr 76 * shell execute also means that we can not have stdout and stderr
82 * also makes use of output debug string. */ 79 * also makes use of output debug string. */
83 DWORD retval = 0; 80 DWORD retval = 0;
84 SHELLEXECUTEINFOW shExecInfo; 81 SHELLEXECUTEINFOW shExecInfo;
85 82
86 memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW)); 83 memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW));
84
85 /* Windows needs each parameter packed in " */
86 QString parameters = "\"list=" + mCertListFile +
87 "\" \"choices=" + choicesFile.fileName() + "\"";
87 88
88 shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW); 89 shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
89 shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 90 shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
90 shExecInfo.lpVerb = L"runas"; 91 shExecInfo.lpVerb = L"runas";
91 shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (cinstFileName.utf16()); 92 shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (cinstFileName.utf16());
134 } 135 }
135 return; 136 return;
136 #else /* WIN32 */ 137 #else /* WIN32 */
137 QProcess installerProcess; 138 QProcess installerProcess;
138 installerProcess.setProgram(cinstProcInfo.absoluteFilePath()); 139 installerProcess.setProgram(cinstProcInfo.absoluteFilePath());
139 installerProcess.waitForStarted(); 140 QStringList parameters;
140 if (installerProcess.state() == QProcess::NotRunning) { 141
142 choicesFile.setAutoRemove(false);
143 parameters << "list=" + mCertListFile << "choices=" + choicesFile.fileName();
144 installerProcess.setArguments(parameters);
145
146
147 qDebug() << "Starting process " << cinstFileName <<" params: " << parameters;
148 installerProcess.start();
149 if (!installerProcess.waitForStarted() ||
150 installerProcess.state() == QProcess::NotRunning) {
141 emit error (tr("Failed to start installer process.")); 151 emit error (tr("Failed to start installer process."));
142 return; 152 return;
143 } 153 }
144 154
145 installerProcess.waitForFinished(); 155 installerProcess.waitForFinished();
146 156
147 if (installerProcess.exitStatus() == QProcess::CrashExit) { 157 if (installerProcess.exitStatus() == QProcess::CrashExit) {
148 /* Woops */ 158 /* Woops */
149 qWarning() << "Installer process crashed"; 159 emit error (tr("Failed to complete installation."));
160 return;
150 } else if (installerProcess.exitStatus() != QProcess::NormalExit) { 161 } else if (installerProcess.exitStatus() != QProcess::NormalExit) {
151 /* Can not Happen. there are only those two values but maybe 162 /* Can not Happen. there are only those two values but maybe
152 * qt changed.. */ 163 * qt changed.. */
153 qWarning() << "Exit status neither normal nor crash."; 164 emit error (tr("Failed to complete installation."));
154 return; 165 return;
155 } 166 }
156 167
157 if (installerProcess.exitCode() == 0) { 168 if (installerProcess.exitCode() == 0) {
158 qDebug() << "output: " << installerProcess.readAllStandardOutput(); 169 qDebug() << "output: " << installerProcess.readAllStandardOutput();

http://wald.intevation.org/projects/trustbridge/