mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-23 08:01:41 +02:00
2023-01-16 Fred Gleason <fredg@paravelsystems.com>
* Refactored rddbconfig(8) so as to apply cursor styling consistently. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
0f07e7871e
commit
634b4b5bc9
@ -23914,3 +23914,6 @@
|
|||||||
it does not exist.
|
it does not exist.
|
||||||
* Added an '--add-host-entry' option to rdadmin(1).
|
* Added an '--add-host-entry' option to rdadmin(1).
|
||||||
* Added a rdadmin(1) man page.
|
* Added a rdadmin(1) man page.
|
||||||
|
2023-01-16 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Refactored rddbconfig(8) so as to apply cursor styling
|
||||||
|
consistently.
|
||||||
|
@ -577,6 +577,10 @@ QString RDCoreApplication::exitCodeText(RDCoreApplication::ExitCode code)
|
|||||||
ret=tr("bad ticket");
|
ret=tr("bad ticket");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RDCoreApplication::ExitNoStation:
|
||||||
|
ret=tr("no such host");
|
||||||
|
break;
|
||||||
|
|
||||||
case RDCoreApplication::ExitLast:
|
case RDCoreApplication::ExitLast:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class RDCoreApplication : public QObject
|
|||||||
ExitLogLinkFailed=10,ExitNoPerms=11,ExitReportFailed=12,
|
ExitLogLinkFailed=10,ExitNoPerms=11,ExitReportFailed=12,
|
||||||
ExitImportFailed=13,ExitNoDropbox=14,ExitNoGroup=15,
|
ExitImportFailed=13,ExitNoDropbox=14,ExitNoGroup=15,
|
||||||
ExitInvalidCart=16,ExitNoSchedCode=17,
|
ExitInvalidCart=16,ExitNoSchedCode=17,
|
||||||
ExitBadTicket=18,ExitLast=19};
|
ExitBadTicket=18,ExitNoStation=19,ExitLast=20};
|
||||||
RDCoreApplication(const QString &module_name,const QString &cmdname,
|
RDCoreApplication(const QString &module_name,const QString &cmdname,
|
||||||
const QString &usage,QObject *parent=0);
|
const QString &usage,QObject *parent=0);
|
||||||
~RDCoreApplication();
|
~RDCoreApplication();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// The Administrator Utility for Rivendell.
|
// The Administrator Utility for Rivendell.
|
||||||
//
|
//
|
||||||
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2023 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License version 2 as
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -87,7 +87,7 @@ MainWidget::MainWidget(RDConfig *config,RDWidget *parent)
|
|||||||
if(!rda->open(&err_msg,&err_type,false)) {
|
if(!rda->open(&err_msg,&err_type,false)) {
|
||||||
if(err_type!=RDApplication::ErrorNoHostEntry) {
|
if(err_type!=RDApplication::ErrorNoHostEntry) {
|
||||||
QMessageBox::critical(this,"RDAdmin - "+tr("Error"),err_msg);
|
QMessageBox::critical(this,"RDAdmin - "+tr("Error"),err_msg);
|
||||||
exit(1);
|
exit(RDCoreApplication::ExitNoDb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ MainWidget::MainWidget(RDConfig *config,RDWidget *parent)
|
|||||||
else {
|
else {
|
||||||
QMessageBox::critical(this,"RDAdmin - "+tr("Error"),
|
QMessageBox::critical(this,"RDAdmin - "+tr("Error"),
|
||||||
tr("The --add-host-entry option requires root permissions."));
|
tr("The --add-host-entry option requires root permissions."));
|
||||||
exit(1);
|
exit(RDCoreApplication::ExitNoPerms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!rda->cmdSwitch()->processed(i)) {
|
if(!rda->cmdSwitch()->processed(i)) {
|
||||||
@ -108,7 +108,7 @@ MainWidget::MainWidget(RDConfig *config,RDWidget *parent)
|
|||||||
tr("Unrecognized option")+": "+
|
tr("Unrecognized option")+": "+
|
||||||
rda->cmdSwitch()->key(i)+" "+
|
rda->cmdSwitch()->key(i)+" "+
|
||||||
rda->cmdSwitch()->value(i));
|
rda->cmdSwitch()->value(i));
|
||||||
exit(1);
|
exit(RDCoreApplication::ExitInvalidOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,34 +247,31 @@ MainWidget::MainWidget(RDConfig *config,RDWidget *parent)
|
|||||||
|
|
||||||
AddStation *d=new AddStation(&hostname,this);
|
AddStation *d=new AddStation(&hostname,this);
|
||||||
if(d->exec()) {
|
if(d->exec()) {
|
||||||
QMessageBox::information(this,"RDAdmin - "+tr("Debug"),
|
exit(RDCoreApplication::ExitOk);
|
||||||
tr("Success!"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RDStation::remove(hostname);
|
RDStation::remove(hostname);
|
||||||
QMessageBox::information(this,"RDAdmin - "+tr("Debug"),
|
exit(RDCoreApplication::ExitNoStation);
|
||||||
tr("Aborted!"));
|
|
||||||
}
|
}
|
||||||
delete d;
|
delete d;
|
||||||
exit(0);
|
exit(RDCoreApplication::ExitOk);
|
||||||
}
|
}
|
||||||
Login *login=new Login(&admin_username,&admin_password,this);
|
Login *login=new Login(&admin_username,&admin_password,this);
|
||||||
if(!login->exec()) {
|
if(!login->exec()) {
|
||||||
exit(0);
|
exit(RDCoreApplication::ExitOk);
|
||||||
}
|
}
|
||||||
rda->user()->setName(admin_username);
|
rda->user()->setName(admin_username);
|
||||||
bool config_priv=rda->user()->adminConfig();
|
bool config_priv=rda->user()->adminConfig();
|
||||||
bool rss_priv=rda->user()->adminRss();
|
bool rss_priv=rda->user()->adminRss();
|
||||||
if(!rda->user()->checkPassword(admin_password,false)) {
|
if(!rda->user()->checkPassword(admin_password,false)) {
|
||||||
QMessageBox::warning(this,"Login Failed","Login Failed!.\n");
|
QMessageBox::warning(this,"Login Failed","Login Failed!.\n");
|
||||||
exit(1);
|
exit(RDCoreApplication::ExitNoPerms);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if((!config_priv)&&(!rss_priv)) {
|
if((!config_priv)&&(!rss_priv)) {
|
||||||
QMessageBox::warning(this,tr("Insufficient Privileges"),
|
QMessageBox::warning(this,tr("Insufficient Privileges"),
|
||||||
tr("This account has insufficient privileges for this operation."));
|
tr("This account has insufficient privileges for this operation."));
|
||||||
exit(1);
|
exit(RDCoreApplication::ExitNoPerms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
name_label->setText(tr("User")+": "+rda->user()->name());
|
name_label->setText(tr("User")+": "+rda->user()->name());
|
||||||
@ -391,7 +388,7 @@ void MainWidget::podcastsData()
|
|||||||
void MainWidget::quitMainWidget()
|
void MainWidget::quitMainWidget()
|
||||||
{
|
{
|
||||||
saveSettings();
|
saveSettings();
|
||||||
exit(0);
|
exit(RDCoreApplication::ExitOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// A Qt-based application to configure, backup, and restore
|
// A Qt-based application to configure, backup, and restore
|
||||||
// the Rivendell database.
|
// the Rivendell database.
|
||||||
//
|
//
|
||||||
// (C) Copyright 2009-2021 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2009-2023 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License version 2 as
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -175,28 +175,25 @@ void MainWidget::mismatchData()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QProcess modifyProcess(this);
|
int exit_code=-1;
|
||||||
|
QString err_msg;
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QString("--modify");
|
bool result=false;
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
args.push_back("--modify");
|
||||||
modifyProcess.start(QString("%1/sbin/rddbmgr").arg(RD_PREFIX), args);
|
if((result=RunProcess(&exit_code,&err_msg,QString("%1/sbin/rddbmgr").arg(RD_PREFIX),args))) {
|
||||||
bool r=modifyProcess.waitForFinished(-1);
|
if(exit_code!=0) {
|
||||||
QApplication::restoreOverrideCursor();
|
QMessageBox::critical(this,tr("RDDbConfig Error"),err_msg);
|
||||||
if(r) {
|
|
||||||
QString stderr=modifyProcess.readAllStandardError();
|
|
||||||
if (modifyProcess.exitCode()) {
|
|
||||||
QMessageBox::critical(this,tr("RDDbConfig Error"),stderr);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!stderr.isEmpty()) {
|
if(!err_msg.isEmpty()) {
|
||||||
QMessageBox::information(this,"Database Modified with Warnings",
|
QMessageBox::information(this,"RDDbConfig - "+tr("Warnings"),
|
||||||
QString::asprintf("Modified database to version %d with warnings:\n\n%s",
|
QString::asprintf("Modified database to version %d with warnings:\n\n%s",
|
||||||
RD_VERSION_DATABASE,stderr.toUtf8().constData()));
|
RD_VERSION_DATABASE,err_msg.toUtf8().constData()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this,"Database Modified Successfully",
|
QMessageBox::information(this,"RDDbConfig - "+tr("Success"),
|
||||||
QString::asprintf("Modified database to version %d",
|
QString::asprintf("Modified database to version %d",
|
||||||
RD_VERSION_DATABASE));
|
RD_VERSION_DATABASE));
|
||||||
}
|
}
|
||||||
RDApplication::syslog(rd_config,LOG_INFO,
|
RDApplication::syslog(rd_config,LOG_INFO,
|
||||||
"modified database to version %d",
|
"modified database to version %d",
|
||||||
@ -204,13 +201,15 @@ void MainWidget::mismatchData()
|
|||||||
|
|
||||||
emit dbChanged();
|
emit dbChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::critical(this,tr("Database Update Error"),
|
QMessageBox::critical(this,"RDDbConfig - "+tr("Error"),
|
||||||
QString("Error starting rddbmgr: code=%1").arg(modifyProcess.error()));
|
QString("Error starting rddbmgr: ")+" "+err_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWidget::updateLabels()
|
void MainWidget::updateLabels()
|
||||||
{
|
{
|
||||||
QString err_msg="";
|
QString err_msg="";
|
||||||
@ -273,7 +272,8 @@ void MainWidget::createData()
|
|||||||
QMessageBox::critical(this,tr("RDDbConfig Error"),err_str);
|
QMessageBox::critical(this,tr("RDDbConfig Error"),err_str);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this,tr("Success"),tr("A new database has been successfully created."));
|
QMessageBox::information(this,tr("Success"),
|
||||||
|
tr("A new database has been successfully created."));
|
||||||
}
|
}
|
||||||
|
|
||||||
startDaemons();
|
startDaemons();
|
||||||
@ -289,40 +289,44 @@ void MainWidget::backupData()
|
|||||||
QString filename;
|
QString filename;
|
||||||
|
|
||||||
if (!db->isOpen()) {
|
if (!db->isOpen()) {
|
||||||
QMessageBox::critical(this,tr("RDDbConfig Error"),
|
QMessageBox::critical(this,"RDDbConfig - "+tr("Error"),
|
||||||
QString::asprintf("Could not open %s database.",
|
QString::asprintf("Could not open %s database.",
|
||||||
rd_config->mysqlDbname().toUtf8().constData()));
|
rd_config->mysqlDbname().toUtf8().constData()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filename=QFileDialog::getSaveFileName(this,"RDDbConfig - "+
|
filename=QFileDialog::getSaveFileName(this,"RDDbConfig - "+
|
||||||
tr("Enter the MySQL Backup Filename"),
|
tr("Enter the MySQL Backup Filename"),
|
||||||
RDHomeDir(),
|
RDHomeDir(),
|
||||||
"MySQL files (*.sql);;All files (*.*)");
|
"MySQL files (*.sql);;All files (*.*)");
|
||||||
|
if(!filename.isEmpty()) {
|
||||||
if (!filename.isEmpty()) {
|
int exit_code=-1;
|
||||||
QProcess backupProcess(this);
|
QString err_msg;
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QString::asprintf("--user=%s",rd_config->mysqlUsername().toUtf8().constData())
|
|
||||||
<< QString::asprintf("--password=%s",rd_config->mysqlPassword().toUtf8().constData())
|
args.push_back(QString::asprintf("--user=%s",
|
||||||
<< QString::asprintf("--host=%s",rd_config->mysqlHostname().toUtf8().constData())
|
rd_config->mysqlUsername().toUtf8().constData()));
|
||||||
<< rd_config->mysqlDbname();
|
args.push_back(QString::asprintf("--password=%s",
|
||||||
backupProcess.setStandardOutputFile(filename);
|
rd_config->mysqlPassword().toUtf8().constData()));
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
args.push_back(QString::asprintf("--host=%s",
|
||||||
backupProcess.start("mysqldump", args);
|
rd_config->mysqlHostname().toUtf8().constData()));
|
||||||
backupProcess.waitForFinished(-1);
|
args.push_back(rd_config->mysqlDbname());
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
if (backupProcess.exitCode()) {
|
if(RunProcess(&exit_code,&err_msg,"mysqldump",args,filename)) {
|
||||||
QMessageBox::critical(this,tr("RDDbConfig Error"),
|
if(exit_code==0) {
|
||||||
QString(backupProcess.readAllStandardError()));
|
QMessageBox::information(this,"RDDbConfig - "+tr("Success"),
|
||||||
|
QString::asprintf("Backed up %s database to %s",
|
||||||
|
rd_config->mysqlDbname().toUtf8().constData(),
|
||||||
|
filename.toUtf8().constData()));
|
||||||
|
RDApplication::syslog(rd_config,LOG_INFO,"backed up %s database to %s",
|
||||||
|
rd_config->mysqlDbname().toUtf8().constData(),
|
||||||
|
filename.toUtf8().constData());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QMessageBox::critical(this,"RDDbConfig - "+tr("Error"),err_msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this,"Database Backed Up Successfully",
|
QMessageBox::critical(this,"RDDbConfig - "+tr("Error"),err_msg);
|
||||||
QString::asprintf("Backed up %s database to %s",
|
|
||||||
rd_config->mysqlDbname().toUtf8().constData(),
|
|
||||||
filename.toUtf8().constData()));
|
|
||||||
RDApplication::syslog(rd_config,LOG_INFO,"backed up %s database to %s",
|
|
||||||
rd_config->mysqlDbname().toUtf8().constData(),
|
|
||||||
filename.toUtf8().constData());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,50 +335,56 @@ void MainWidget::backupData()
|
|||||||
void MainWidget::restoreData()
|
void MainWidget::restoreData()
|
||||||
{
|
{
|
||||||
QString filename;
|
QString filename;
|
||||||
|
int exit_code=-1;
|
||||||
|
QString err_msg;
|
||||||
|
|
||||||
if (!db->isOpen()) {
|
if (!db->isOpen()) {
|
||||||
QMessageBox::critical(this,tr("RDDbConfig Error"),
|
QMessageBox::critical(this,"RDDbConfig - "+tr("Error"),
|
||||||
tr("Could not open Rivendell database."));
|
tr("Could not open Rivendell database."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(QMessageBox::question(this,"RDDbConfig - "+tr("Question"),
|
||||||
|
tr("This operation will completely overwrite the existing database, replacing it with the contents being restored.")+"\n\n"+
|
||||||
|
tr("Are you sure?"),
|
||||||
|
QMessageBox::Yes,
|
||||||
|
QMessageBox::No)!=QMessageBox::Yes) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
filename=
|
filename=
|
||||||
QFileDialog::getOpenFileName(this,"RDDbConfig - "+
|
QFileDialog::getOpenFileName(this,"RDDbConfig - "+
|
||||||
tr("Choose the MySQL Backup File to Restore"),
|
tr("Choose the MySQL Backup File to Restore"),
|
||||||
RDHomeDir(),
|
RDHomeDir(),
|
||||||
"MySQL files (*.sql);;All files (*.*)");
|
"MySQL files (*.sql);;All files (*.*)");
|
||||||
|
qApp->processEvents();
|
||||||
if(!filename.isEmpty()) {
|
if(!filename.isEmpty()) {
|
||||||
if (QMessageBox::question(this,tr("Restore Entire Database"),tr("Are you sure you want to restore your entire Rivendell database?"),(QMessageBox::No|QMessageBox::Yes)) != QMessageBox::Yes) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
db->clearDatabase(rd_config->mysqlDbname());
|
db->clearDatabase(rd_config->mysqlDbname());
|
||||||
|
|
||||||
QProcess restoreProcess(this);
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QString::asprintf("--user=%s",rd_config->mysqlUsername().toUtf8().constData())
|
args.push_back(QString::asprintf("--user=%s",rd_config->mysqlUsername().toUtf8().constData()));
|
||||||
<< QString::asprintf("--password=%s",rd_config->mysqlPassword().toUtf8().constData())
|
args.push_back(QString::asprintf("--password=%s",rd_config->mysqlPassword().toUtf8().constData()));
|
||||||
<< QString::asprintf("--host=%s",rd_config->mysqlHostname().toUtf8().constData())
|
args.push_back(QString::asprintf("--host=%s",rd_config->mysqlHostname().toUtf8().constData()));
|
||||||
<< rd_config->mysqlDbname();
|
args.push_back(rd_config->mysqlDbname());
|
||||||
restoreProcess.setStandardInputFile(filename);
|
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
|
||||||
stopDaemons();
|
stopDaemons();
|
||||||
restoreProcess.start("mysql", args);
|
if(RunProcess(&exit_code,&err_msg,"mysql",args,"",filename)) {
|
||||||
restoreProcess.waitForFinished(-1);
|
if(exit_code==0) {
|
||||||
QApplication::restoreOverrideCursor();
|
QMessageBox::information(this,"RDDbConfig - "+tr("Success"),
|
||||||
if (restoreProcess.exitCode()) {
|
QString::asprintf("Restored %s database from %s",
|
||||||
QMessageBox::critical(this,tr("RDDbConfig Error"),
|
rd_config->mysqlDbname().toUtf8().constData(),
|
||||||
QString(restoreProcess.readAllStandardError()));
|
filename.toUtf8().constData()));
|
||||||
}
|
|
||||||
else {
|
|
||||||
QMessageBox::information(this,"Database Restored Successfully",
|
|
||||||
QString::asprintf("Restored %s database from %s",
|
|
||||||
rd_config->mysqlDbname().toUtf8().constData(),
|
|
||||||
filename.toUtf8().constData()));
|
|
||||||
RDApplication::syslog(rd_config,LOG_INFO,"restored %s database from %s",
|
RDApplication::syslog(rd_config,LOG_INFO,"restored %s database from %s",
|
||||||
rd_config->mysqlDbname().toUtf8().constData(),
|
rd_config->mysqlDbname().toUtf8().constData(),
|
||||||
filename.toUtf8().constData());
|
filename.toUtf8().constData());
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QMessageBox::critical(this,"RDDbConfig - "+tr("Error"),err_msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QMessageBox::critical(this,"RDDbConfig - "+tr("Error"),err_msg);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
emit updateLabels();
|
emit updateLabels();
|
||||||
|
|
||||||
@ -405,7 +415,6 @@ void MainWidget::restoreData()
|
|||||||
}
|
}
|
||||||
delete q;
|
delete q;
|
||||||
}
|
}
|
||||||
|
|
||||||
startDaemons();
|
startDaemons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,14 +422,10 @@ void MainWidget::restoreData()
|
|||||||
|
|
||||||
void MainWidget::resizeEvent(QResizeEvent *e)
|
void MainWidget::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
db_create_button->
|
db_create_button->setGeometry(size().width()/2-80,110,160,50);
|
||||||
setGeometry(size().width()/2-80,110,160,50);
|
db_backup_button->setGeometry(size().width()/2-80,165,160,50);
|
||||||
db_backup_button->
|
db_restore_button->setGeometry(size().width()/2-80,220,160,50);
|
||||||
setGeometry(size().width()/2-80,165,160,50);
|
db_close_button->setGeometry(size().width()/2-80,275,160,50);
|
||||||
db_restore_button->
|
|
||||||
setGeometry(size().width()/2-80,220,160,50);
|
|
||||||
db_close_button->
|
|
||||||
setGeometry(size().width()/2-80,275,160,50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -465,6 +470,39 @@ void MainWidget::startDaemons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MainWidget::RunProcess(int *exit_code,QString *err_msg,const QString &cmd,
|
||||||
|
const QStringList &args,
|
||||||
|
const QString &output_filename,
|
||||||
|
const QString &input_filename)
|
||||||
|
{
|
||||||
|
bool ret=false;
|
||||||
|
*exit_code=-1;
|
||||||
|
|
||||||
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
|
QProcess *proc=new QProcess(this);
|
||||||
|
if(!output_filename.isEmpty()) {
|
||||||
|
proc->setStandardOutputFile(output_filename);
|
||||||
|
}
|
||||||
|
if(!input_filename.isEmpty()) {
|
||||||
|
proc->setStandardInputFile(input_filename);
|
||||||
|
}
|
||||||
|
proc->start(cmd,args);
|
||||||
|
proc->waitForFinished(-1);
|
||||||
|
if(proc->exitStatus()==QProcess::NormalExit) {
|
||||||
|
*exit_code=proc->exitCode();
|
||||||
|
ret=proc->exitCode()==0;
|
||||||
|
*err_msg=QString::fromUtf8(proc->readAllStandardError());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*exit_code=-1;
|
||||||
|
*err_msg="\"+cmd\ "+tr("process crashed");
|
||||||
|
}
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// A Qt-based application to configure, backup, and restore
|
// A Qt-based application to configure, backup, and restore
|
||||||
// the Rivendell database.
|
// the Rivendell database.
|
||||||
//
|
//
|
||||||
// (C) Copyright 2009-2018 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2009-2023 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License version 2 as
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -59,6 +59,10 @@ class MainWidget : public RDWidget
|
|||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool RunProcess(int *exit_code,QString *err_msg,
|
||||||
|
const QString &cmd,const QStringList &args,
|
||||||
|
const QString &output_filename="",
|
||||||
|
const QString &input_filename="");
|
||||||
RDConfig *rd_config;
|
RDConfig *rd_config;
|
||||||
bool db_manage_daemons;
|
bool db_manage_daemons;
|
||||||
bool db_daemon_start_needed;
|
bool db_daemon_start_needed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user