1
/* Copyright (C) 2005 J.F.Dockes
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the
14
* Free Software Foundation, Inc.,
15
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
#include "autoconfig.h"
21
#include <QPushButton>
22
#include <QMessageBox>
32
static string idstring(const string& confdir)
34
// Quote conf dir, there may be spaces and whatelse in there
35
return string("RECOLL_CONFDIR=") + escapeShell(confdir);
38
void CronToolW::init()
40
marker = "RCLCRON_RCLINDEX=";
42
enableButton = new QPushButton(tr("Enable"));
43
disableButton = new QPushButton(tr("Disable"));
44
buttonBox->addButton(enableButton, QDialogButtonBox::ActionRole);
45
buttonBox->addButton(disableButton, QDialogButtonBox::ActionRole);
46
connect(enableButton, SIGNAL(clicked()), this, SLOT(enableCron()));
47
connect(disableButton, SIGNAL(clicked()), this, SLOT(disableCron()));
49
// Try to read the current values
53
if (checkCrontabUnmanaged(marker, "recollindex")) {
54
QMessageBox::warning(0, "Recoll",
55
tr("It seems that manually edited entries exist for recollindex, cannot edit crontab"));
56
QTimer::singleShot(0, this, SLOT(close()));
59
string id = idstring(theconfig->getConfDir());
61
if (getCrontabSched(marker, id, sched)) {
62
minsLE->setText(QString::fromAscii(sched[0].c_str()));
63
hoursLE->setText(QString::fromAscii(sched[1].c_str()));
64
daysLE->setText(QString::fromAscii(sched[4].c_str()));
68
void CronToolW::enableCron()
72
void CronToolW::disableCron()
77
void CronToolW::changeCron(bool enable)
82
string id = idstring(theconfig->getConfDir());
83
string cmd("recollindex");
88
editCrontab(marker, id, "", "", reason);
91
string mins((const char *)minsLE->text().toAscii());
92
string hours((const char *)hoursLE->text().toAscii());
93
string days((const char *)daysLE->text().toAscii());
94
string sched = mins + " " + hours + " * * " + days;
95
if (editCrontab(marker, id, sched, cmd, reason)) {
98
QMessageBox::warning(0, "Recoll",
99
tr("Error installing cron entry. Bad syntax in fields ?"));