summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/UpdaterDialog.cpp6
-rw-r--r--src/UpdaterDialog.h6
-rw-r--r--src/main.cpp23
3 files changed, 28 insertions, 7 deletions
diff --git a/src/UpdaterDialog.cpp b/src/UpdaterDialog.cpp
index d0ceeb0..fe41cbb 100644
--- a/src/UpdaterDialog.cpp
+++ b/src/UpdaterDialog.cpp
@@ -9,8 +9,8 @@
# include <Carbon/Carbon.h>
#endif
-UpdaterDialog::UpdaterDialog(ThandyWrapper *th, QWidget *parent)
- : QDialog(parent), thandy(th), updating(false), lastLabel(0)
+UpdaterDialog::UpdaterDialog(ThandyWrapper *th, const QString &_restartCmd, QWidget *parent)
+ : QDialog(parent), thandy(th), updating(false), lastLabel(0), restartCmd(_restartCmd)
{
ui.setupUi(this);
@@ -46,6 +46,8 @@ UpdaterDialog::UpdaterDialog(ThandyWrapper *th, QWidget *parent)
UpdaterDialog::~UpdaterDialog()
{
+ if(!restartCmd.isEmpty())
+ QProcess::startDetached(restartCmd);
delete thandy;
}
diff --git a/src/UpdaterDialog.h b/src/UpdaterDialog.h
index 89fb3d1..45822bd 100644
--- a/src/UpdaterDialog.h
+++ b/src/UpdaterDialog.h
@@ -23,7 +23,9 @@ class UpdaterDialog : public QDialog
WANTFILE, WAIT, ALREADY };
/** Default constructor */
- UpdaterDialog(ThandyWrapper *th, QWidget *parent = 0);
+ UpdaterDialog(ThandyWrapper *th,
+ const QString &restartCmd = QString(),
+ QWidget *parent = 0);
/** Destructor */
~UpdaterDialog();
@@ -47,6 +49,8 @@ class UpdaterDialog : public QDialog
QHash<QString, DownloadWidget *> downloadHash;
/** Pointer to the last message added */
QLabel *lastLabel;
+ /** Command to be executed after everything has finished */
+ QString restartCmd;
/** Returns true if there is at least one of the main process
running (Tor, Vidalia or Firefox) */
diff --git a/src/main.cpp b/src/main.cpp
index d939c4b..e46a48c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,18 +12,25 @@
void usage()
{
- printf("Error: unrecognize option.\n");
+ QString usage("");
+
+ qDebug() << "Valid arguments::";
+ qDebug() << " --wait 5";
+ qDebug() << " --no-download";
+ qDebug() << " --check";
+ qDebug() << " --datadir /path/to/datadir/";
+ qDebug() << " --restartcmd \"app arg1 arg2 ...\"";
}
int main(int argc, char **argv)
{
QApplication app(argc, argv);
- bool wait, nextwait, check, download, error, hasdatadir;
+ bool wait, nextwait, check, download, error, hasdatadir, restart;
wait = nextwait = hasdatadir = error = check = false;
download = true;
int sec = 0;
- QString datadir = ".";
+ QString datadir = ".", restartCmd = "";
QStringList args = app.arguments();
@@ -42,6 +49,12 @@ int main(int argc, char **argv)
continue;
}
+ if(restart) {
+ restart = false;
+ restartCmd = arg;
+ continue;
+ }
+
if(arg == "--wait") {
wait = true;
nextwait = true;
@@ -51,6 +64,8 @@ int main(int argc, char **argv)
check = true;
} else if(arg == "--datadir") {
hasdatadir = true;
+ } else if(arg == "--restartcmd") {
+ restart = true;
} else
error = true;
}
@@ -75,7 +90,7 @@ int main(int argc, char **argv)
QObject::connect(thandy, SIGNAL(done()), thandy, SLOT(deleteLater()));
QObject::connect(thandy, SIGNAL(done()), QCoreApplication::instance(), SLOT(quit()));
} else {
- dialog = new UpdaterDialog(thandy);
+ dialog = new UpdaterDialog(thandy, restartCmd);
dialog->show();
}