comparison ui/mainwindow.cpp @ 810:ee75e236843c

Use sudo to install software in case of is_admin
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 15 Jul 2014 16:31:24 +0200
parents 1e18d4c1932a
children c4af7874250b
comparison
equal deleted inserted replaced
809:4b702f6cf9b6 810:ee75e236843c
295 setState(NewSoftwareAvailable); 295 setState(NewSoftwareAvailable);
296 return; 296 return;
297 } 297 }
298 #else /* WIN32 */ 298 #else /* WIN32 */
299 QStringList parameters; 299 QStringList parameters;
300 parameters << "/S" << "/UPDATE=1" 300 parameters << "--prefix" << installDir.path();
301 << QString::fromLatin1("/D=%1").arg(installDir.path()); 301 bool sudo_started = false;
302 302 bool use_sudo = is_admin();
303 qDebug() << "Starting process " << filePath << " args: " << parameters; 303 if (use_sudo) {
304 304 QStringList sudoPrograms;
305 if (!QProcess::startDetached(filePath, parameters)) { 305 sudoPrograms << "gksudo" << "kdesudo" << "sudo";
306 QStringList sudoParams;
307 sudoParams << filePath + " " + parameters.join(" ");
308
309 foreach (const QString &sProg, sudoPrograms) {
310 qDebug() << "Starting process " << sProg <<" params: " << sudoParams;
311 if (!QProcess::startDetached(sProg, sudoParams)) {
312 continue;
313 } else {
314 sudo_started = true;
315 break;
316 }
317 }
318 }
319 if (!sudo_started && !QProcess::startDetached(filePath, parameters)) {
306 qDebug() << "Failed to start process."; 320 qDebug() << "Failed to start process.";
307 return; 321 return;
308 } 322 }
323
309 #endif 324 #endif
310 /* Installer process should now be running. We exit */ 325 /* Installer process should now be running. We exit */
311 326
312 closeApp(); 327 closeApp();
313 } 328 }

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