GUI tools for setting up indexing schedule, initial implementation done
This commit is contained in:
parent
b9c64e8591
commit
07226fa306
@ -100,6 +100,14 @@ void RclConfig::zeroMe() {
|
|||||||
m_rmtstate.init(this, 0, "indexedmimetypes");
|
m_rmtstate.init(this, 0, "indexedmimetypes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RclConfig::isDefaultConfig()
|
||||||
|
{
|
||||||
|
string defaultconf = path_cat(path_canon(path_home()), ".recoll/");
|
||||||
|
string specifiedconf = path_canon(m_confdir);
|
||||||
|
path_catslash(specifiedconf);
|
||||||
|
return !defaultconf.compare(specifiedconf);
|
||||||
|
}
|
||||||
|
|
||||||
RclConfig::RclConfig(const string *argcnf)
|
RclConfig::RclConfig(const string *argcnf)
|
||||||
{
|
{
|
||||||
zeroMe();
|
zeroMe();
|
||||||
@ -130,18 +138,18 @@ RclConfig::RclConfig(const string *argcnf)
|
|||||||
m_confdir = cp;
|
m_confdir = cp;
|
||||||
} else {
|
} else {
|
||||||
autoconfdir = true;
|
autoconfdir = true;
|
||||||
m_confdir = path_home();
|
m_confdir = path_cat(path_home(), ".recoll/");
|
||||||
m_confdir += ".recoll/";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!autoconfdir) {
|
// Note: autoconfdir and isDefaultConfig() are normally the same. We just
|
||||||
// We want a recoll.conf file to exist in this case to avoid
|
// want to avoid the imperfect test in isDefaultConfig() if we actually know
|
||||||
// creating indexes all over the place
|
// this is the default conf
|
||||||
string conffile = path_cat(m_confdir, "recoll.conf");
|
if (!autoconfdir && !isDefaultConfig()) {
|
||||||
if (access(conffile.c_str(), 0) < 0) {
|
if (access(m_confdir.c_str(), 0) < 0) {
|
||||||
m_reason = "Explicitly specified configuration directory must exist"
|
m_reason = "Explicitly specified configuration "
|
||||||
" (won't be automatically created)";
|
"directory must exist"
|
||||||
|
" (won't be automatically created). Use mkdir first";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,8 +83,13 @@ class RclConfig {
|
|||||||
bool ok() {return m_ok;}
|
bool ok() {return m_ok;}
|
||||||
const string &getReason() {return m_reason;}
|
const string &getReason() {return m_reason;}
|
||||||
|
|
||||||
/** Return the directory where this configuration is stored */
|
/** Return the directory where this configuration is stored.
|
||||||
|
* This was possibly silently created by the rclconfig
|
||||||
|
* constructor it it is the default one (~/.recoll) and it did
|
||||||
|
* not exist yet. */
|
||||||
string getConfDir() {return m_confdir;}
|
string getConfDir() {return m_confdir;}
|
||||||
|
/** Returns true if this is ~/.recoll */
|
||||||
|
bool isDefaultConfig();
|
||||||
/** Get the local value for /usr/local/share/recoll/ */
|
/** Get the local value for /usr/local/share/recoll/ */
|
||||||
const string& getDatadir() {return m_datadir;}
|
const string& getDatadir() {return m_datadir;}
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ void CronToolW::changeCron(bool enable)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
string id = idstring(theconfig->getConfDir());
|
string id = idstring(theconfig->getConfDir());
|
||||||
string cmd("recollindex -m -w 60");
|
string cmd("recollindex");
|
||||||
|
|
||||||
string reason;
|
string reason;
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void CronToolW::changeCron(bool enable)
|
|||||||
accept();
|
accept();
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("Error installing cron entry. Bad syntax in fields ? "));
|
tr("Error installing cron entry. Bad syntax in fields ?"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,8 @@
|
|||||||
* Free Software Foundation, Inc.,
|
* Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#ifndef _CRONTAB_W_H_INCLUDED_
|
#ifndef _CRONTOOL_W_H_INCLUDED_
|
||||||
#define _CRONTAB_W_H_INCLUDED_
|
#define _CRONTOOL_W_H_INCLUDED_
|
||||||
|
|
||||||
#include "ui_crontool.h"
|
#include "ui_crontool.h"
|
||||||
|
|
||||||
@ -45,4 +45,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CRONTAB_W_H_INCLUDED_ */
|
#endif /* _CRONTOOL_W_H_INCLUDED_ */
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>465</width>
|
<width>465</width>
|
||||||
<height>365</height>
|
<height>367</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -18,6 +18,12 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
|
|||||||
@ -43,6 +43,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="description">
|
<property name="description">
|
||||||
<string>This will let you adjust the directories you want to index, and other parameters like excluded file paths or names, default character sets, etc.</string>
|
<string>This will let you adjust the directories you want to index, and other parameters like excluded file paths or names, default character sets, etc.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -53,6 +56,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Indexing schedule</string>
|
<string>Indexing schedule</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="description">
|
<property name="description">
|
||||||
<string>This will let you chose between batch and real-time indexing, and set up an automatic schedule for batch indexing (using cron).</string>
|
<string>This will let you chose between batch and real-time indexing, and set up an automatic schedule for batch indexing (using cron).</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#define _IDXSCHED_H_INCLUDED_
|
#define _IDXSCHED_H_INCLUDED_
|
||||||
|
|
||||||
#include "ui_idxsched.h"
|
#include "ui_idxsched.h"
|
||||||
|
#include "rclhelp.h"
|
||||||
|
|
||||||
class IdxSchedW : public QDialog, public Ui::IdxSchedW {
|
class IdxSchedW : public QDialog, public Ui::IdxSchedW {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -26,6 +27,9 @@ class IdxSchedW : public QDialog, public Ui::IdxSchedW {
|
|||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
(void)new HelpClient(this);
|
||||||
|
HelpClient::installMap((const char *)this->objectName().toUtf8(),
|
||||||
|
"RCL.INDEXING");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>300</height>
|
<height>352</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -24,8 +24,9 @@
|
|||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Recoll</span> indexing can run permanently, indexing files as they change, or run at discrete intervals. </p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Recoll</span> indexing can run permanently, indexing files as they change, or run at discrete intervals. </p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Reading the manual may help you to decide between these approaches. Hopefuly, F1 should get you there.</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Reading the manual may help you to decide between these approaches (press F1). </p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This tool can help you set up a schedule to automate batch indexing runs, or start real time indexing when you log in (or both actually, which may make sense in some situations). </p></body></html></string>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This tool can help you set up a schedule to automate batch indexing runs, or start real time indexing when you log in (or both, which rarely makes sense). </p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::AutoText</enum>
|
<enum>Qt::AutoText</enum>
|
||||||
@ -38,7 +39,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCommandLinkButton" name="cronCLB">
|
<widget class="QCommandLinkButton" name="cronCLB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Start cron scheduling tool</string>
|
<string>Cron scheduling</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="description">
|
<property name="description">
|
||||||
<string>The tool will let you decide at what time indexing should run and will install a crontab entry.</string>
|
<string>The tool will let you decide at what time indexing should run and will install a crontab entry.</string>
|
||||||
@ -48,10 +52,13 @@ p, li { white-space: pre-wrap; }
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCommandLinkButton" name="rtidxCLB">
|
<widget class="QCommandLinkButton" name="rtidxCLB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Real time indexing start up options</string>
|
<string>Real time indexing start up</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="description">
|
<property name="description">
|
||||||
<string>Decide if real time indexing will be started when you log in</string>
|
<string>Decide if real time indexing will be started when you log in (only for the default index).</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@ -160,6 +160,7 @@
|
|||||||
<string>&Preferences</string>
|
<string>&Preferences</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="indexConfigAction"/>
|
<addaction name="indexConfigAction"/>
|
||||||
|
<addaction name="indexScheduleAction"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="queryPrefsAction"/>
|
<addaction name="queryPrefsAction"/>
|
||||||
<addaction name="extIdxAction"/>
|
<addaction name="extIdxAction"/>
|
||||||
@ -375,6 +376,14 @@
|
|||||||
<cstring>indexConfigAction</cstring>
|
<cstring>indexConfigAction</cstring>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="indexScheduleAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Indexing schedule</string>
|
||||||
|
</property>
|
||||||
|
<property name="name" stdset="0">
|
||||||
|
<cstring>indexScheduleAction</cstring>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="queryPrefsAction">
|
<action name="queryPrefsAction">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Query configuration</string>
|
<string>&Query configuration</string>
|
||||||
|
|||||||
@ -72,6 +72,7 @@ using std::pair;
|
|||||||
#include "firstidx.h"
|
#include "firstidx.h"
|
||||||
#include "idxsched.h"
|
#include "idxsched.h"
|
||||||
#include "crontool.h"
|
#include "crontool.h"
|
||||||
|
#include "rtitool.h"
|
||||||
|
|
||||||
using namespace confgui;
|
using namespace confgui;
|
||||||
|
|
||||||
@ -235,6 +236,8 @@ void RclMain::init()
|
|||||||
this, SLOT(showSpellDialog()));
|
this, SLOT(showSpellDialog()));
|
||||||
connect(indexConfigAction, SIGNAL(activated()),
|
connect(indexConfigAction, SIGNAL(activated()),
|
||||||
this, SLOT(showIndexConfig()));
|
this, SLOT(showIndexConfig()));
|
||||||
|
connect(indexScheduleAction, SIGNAL(activated()),
|
||||||
|
this, SLOT(showIndexSched()));
|
||||||
connect(queryPrefsAction, SIGNAL(activated()),
|
connect(queryPrefsAction, SIGNAL(activated()),
|
||||||
this, SLOT(showUIPrefs()));
|
this, SLOT(showUIPrefs()));
|
||||||
connect(extIdxAction, SIGNAL(activated()),
|
connect(extIdxAction, SIGNAL(activated()),
|
||||||
@ -713,9 +716,12 @@ void RclMain::showIndexSched(bool modal)
|
|||||||
this, SLOT (fileExit()));
|
this, SLOT (fileExit()));
|
||||||
connect(indexSched->cronCLB, SIGNAL(clicked()),
|
connect(indexSched->cronCLB, SIGNAL(clicked()),
|
||||||
this, SLOT(execCronTool()));
|
this, SLOT(execCronTool()));
|
||||||
connect(indexSched->rtidxCLB, SIGNAL(clicked()),
|
if (theconfig && theconfig->isDefaultConfig()) {
|
||||||
this, SLOT(execRTITool()));
|
connect(indexSched->rtidxCLB, SIGNAL(clicked()),
|
||||||
|
this, SLOT(execRTITool()));
|
||||||
|
} else {
|
||||||
|
indexSched->rtidxCLB->setEnabled(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Close and reopen, in hope that makes us visible...
|
// Close and reopen, in hope that makes us visible...
|
||||||
indexSched->close();
|
indexSched->close();
|
||||||
@ -755,6 +761,33 @@ void RclMain::showCronTool(bool modal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RclMain::showRTITool()
|
||||||
|
{
|
||||||
|
showRTITool(false);
|
||||||
|
}
|
||||||
|
void RclMain::execRTITool()
|
||||||
|
{
|
||||||
|
showRTITool(true);
|
||||||
|
}
|
||||||
|
void RclMain::showRTITool(bool modal)
|
||||||
|
{
|
||||||
|
LOGDEB(("showRTITool()\n"));
|
||||||
|
if (rtiTool == 0) {
|
||||||
|
rtiTool = new RTIToolW(0);
|
||||||
|
connect(new QShortcut(quitKeySeq, rtiTool), SIGNAL (activated()),
|
||||||
|
this, SLOT (fileExit()));
|
||||||
|
} else {
|
||||||
|
// Close and reopen, in hope that makes us visible...
|
||||||
|
rtiTool->close();
|
||||||
|
}
|
||||||
|
if (modal) {
|
||||||
|
rtiTool->exec();
|
||||||
|
rtiTool->setModal(false);
|
||||||
|
} else {
|
||||||
|
rtiTool->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RclMain::showUIPrefs()
|
void RclMain::showUIPrefs()
|
||||||
{
|
{
|
||||||
if (uiprefs == 0) {
|
if (uiprefs == 0) {
|
||||||
|
|||||||
@ -36,6 +36,7 @@ class ExecCmd;
|
|||||||
class Preview;
|
class Preview;
|
||||||
class ResTable;
|
class ResTable;
|
||||||
class CronToolW;
|
class CronToolW;
|
||||||
|
class RTIToolW;
|
||||||
|
|
||||||
#include "ui_rclmain.h"
|
#include "ui_rclmain.h"
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ public:
|
|||||||
indexConfig(0),
|
indexConfig(0),
|
||||||
indexSched(0),
|
indexSched(0),
|
||||||
cronTool(0),
|
cronTool(0),
|
||||||
|
rtiTool(0),
|
||||||
spellform(0),
|
spellform(0),
|
||||||
periodictimer(0),
|
periodictimer(0),
|
||||||
restable(0),
|
restable(0),
|
||||||
@ -96,6 +98,8 @@ public slots:
|
|||||||
virtual void execIndexConfig();
|
virtual void execIndexConfig();
|
||||||
virtual void showCronTool();
|
virtual void showCronTool();
|
||||||
virtual void execCronTool();
|
virtual void execCronTool();
|
||||||
|
virtual void showRTITool();
|
||||||
|
virtual void execRTITool();
|
||||||
virtual void showIndexSched();
|
virtual void showIndexSched();
|
||||||
virtual void execIndexSched();
|
virtual void execIndexSched();
|
||||||
virtual void setUIPrefs();
|
virtual void setUIPrefs();
|
||||||
@ -144,6 +148,7 @@ private:
|
|||||||
ConfIndexW *indexConfig;
|
ConfIndexW *indexConfig;
|
||||||
IdxSchedW *indexSched;
|
IdxSchedW *indexSched;
|
||||||
CronToolW *cronTool;
|
CronToolW *cronTool;
|
||||||
|
RTIToolW *rtiTool;
|
||||||
SpellW *spellform;
|
SpellW *spellform;
|
||||||
QTimer *periodictimer;
|
QTimer *periodictimer;
|
||||||
ResTable *restable;
|
ResTable *restable;
|
||||||
@ -169,6 +174,7 @@ private:
|
|||||||
virtual void showIndexConfig(bool modal);
|
virtual void showIndexConfig(bool modal);
|
||||||
virtual void showIndexSched(bool modal);
|
virtual void showIndexSched(bool modal);
|
||||||
virtual void showCronTool(bool modal);
|
virtual void showCronTool(bool modal);
|
||||||
|
virtual void showRTITool(bool modal);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RCLMAIN_W_H
|
#endif // RCLMAIN_W_H
|
||||||
|
|||||||
@ -16,6 +16,7 @@ HEADERS += \
|
|||||||
rclmain_w.h \
|
rclmain_w.h \
|
||||||
reslist.h \
|
reslist.h \
|
||||||
restable.h \
|
restable.h \
|
||||||
|
rtitool.h \
|
||||||
searchclause_w.h \
|
searchclause_w.h \
|
||||||
spell_w.h \
|
spell_w.h \
|
||||||
ssearch_w.h \
|
ssearch_w.h \
|
||||||
@ -36,6 +37,7 @@ SOURCES += \
|
|||||||
rclmain_w.cpp \
|
rclmain_w.cpp \
|
||||||
reslist.cpp \
|
reslist.cpp \
|
||||||
restable.cpp \
|
restable.cpp \
|
||||||
|
rtitool.cpp \
|
||||||
searchclause_w.cpp \
|
searchclause_w.cpp \
|
||||||
spell_w.cpp \
|
spell_w.cpp \
|
||||||
ssearch_w.cpp \
|
ssearch_w.cpp \
|
||||||
@ -52,6 +54,7 @@ FORMS = \
|
|||||||
listdialog.ui \
|
listdialog.ui \
|
||||||
rclmain.ui \
|
rclmain.ui \
|
||||||
restable.ui \
|
restable.ui \
|
||||||
|
rtitool.ui \
|
||||||
spell.ui \
|
spell.ui \
|
||||||
ssearchb.ui \
|
ssearchb.ui \
|
||||||
uiprefs.ui \
|
uiprefs.ui \
|
||||||
|
|||||||
172
src/qtgui/rtitool.cpp
Normal file
172
src/qtgui/rtitool.cpp
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
/* Copyright (C) 2005 J.F.Dockes
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
#include "autoconfig.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "recoll.h"
|
||||||
|
#include "rtitool.h"
|
||||||
|
#include "smallut.h"
|
||||||
|
#include "pathut.h"
|
||||||
|
#include "copyfile.h"
|
||||||
|
#include "readfile.h"
|
||||||
|
#include "execmd.h"
|
||||||
|
|
||||||
|
static const char *rautostartfile = ".config/autostart/recollindex.desktop";
|
||||||
|
|
||||||
|
// Just in case we don't find the file in the shared dir, have a
|
||||||
|
// default text ready
|
||||||
|
static const char *desktopfiletext =
|
||||||
|
"[Desktop Entry]\n"
|
||||||
|
"Name=Recoll real time indexer\n"
|
||||||
|
"Comment=Runs in background to extract and index text from modified "
|
||||||
|
"documents\n"
|
||||||
|
"Icon=system-run\n"
|
||||||
|
"Exec=recollindex -w 60 -m\n"
|
||||||
|
"Terminal=false\n"
|
||||||
|
"TerminalOptions=\n"
|
||||||
|
"Type=Application\n"
|
||||||
|
"Categories=Utility;Filesystem;Database;\n"
|
||||||
|
"NoDisplay=true\n"
|
||||||
|
"X-GNOME-Autostart-enabled=true\n"
|
||||||
|
"X-KDE-autostart-after=panel\n"
|
||||||
|
"X-KDE-UniqueApplet=true\n"
|
||||||
|
;
|
||||||
|
|
||||||
|
void RTIToolW::init()
|
||||||
|
{
|
||||||
|
connect(this->sesCB, SIGNAL(clicked(bool)),
|
||||||
|
this, SLOT(sesclicked(bool)));
|
||||||
|
string autostartfile = path_cat(path_home(), rautostartfile);
|
||||||
|
if (access(autostartfile.c_str(), 0) == 0) {
|
||||||
|
sesCB->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RTIToolW::sesclicked(bool on)
|
||||||
|
{
|
||||||
|
nowCB->setEnabled(on);
|
||||||
|
if (!on)
|
||||||
|
nowCB->setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RTIToolW::accept()
|
||||||
|
{
|
||||||
|
bool exitdial = false;
|
||||||
|
string autostartfile = path_cat(path_home(), rautostartfile);
|
||||||
|
|
||||||
|
if (sesCB->isChecked()) {
|
||||||
|
// Setting up daemon indexing autostart
|
||||||
|
|
||||||
|
if (::access(autostartfile.c_str(), 0) == 0) {
|
||||||
|
QString msg = tr("Replacing: ") +
|
||||||
|
QString::fromLocal8Bit(autostartfile.c_str());
|
||||||
|
|
||||||
|
QMessageBox::Button rep =
|
||||||
|
QMessageBox::question(this, tr("Replacing file"), msg,
|
||||||
|
QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
|
if (rep != QMessageBox::Ok) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string text;
|
||||||
|
if (theconfig) {
|
||||||
|
string sourcefile = path_cat(theconfig->getDatadir(), "examples");
|
||||||
|
sourcefile = path_cat(sourcefile, "recollindex.desktop");
|
||||||
|
if (::access(sourcefile.c_str(), 0) == 0) {
|
||||||
|
file_to_string(sourcefile, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (text.empty())
|
||||||
|
text = desktopfiletext;
|
||||||
|
|
||||||
|
int fd = ::open(autostartfile.c_str(), O_WRONLY|O_CREAT, 0644);
|
||||||
|
if (fd < 0 || ::write(fd, text.c_str(), size_t(text.size()))
|
||||||
|
!= ssize_t(text.size()) || ::close(fd) != 0) {
|
||||||
|
if (fd >=0)
|
||||||
|
::close(fd);
|
||||||
|
QString msg = tr("Can't create: ") +
|
||||||
|
QString::fromLocal8Bit(autostartfile.c_str());
|
||||||
|
QMessageBox::warning(0, tr("Warning"), msg, QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
::close(fd);
|
||||||
|
|
||||||
|
if (nowCB->isChecked()) {
|
||||||
|
ExecCmd cmd;
|
||||||
|
list<string> args;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
args.push_back("-m");
|
||||||
|
args.push_back("-w");
|
||||||
|
args.push_back("0");
|
||||||
|
status = cmd.doexec("recollindex", args, 0, 0);
|
||||||
|
if (status) {
|
||||||
|
QMessageBox::warning(0, tr("Warning"),
|
||||||
|
tr("Could not execute recollindex"),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exitdial = true;
|
||||||
|
} else {
|
||||||
|
// Turning autostart off
|
||||||
|
if (::access(autostartfile.c_str(), 0) == 0) {
|
||||||
|
QString msg = tr("Deleting: ") +
|
||||||
|
QString::fromLocal8Bit(autostartfile.c_str());
|
||||||
|
|
||||||
|
QMessageBox::Button rep =
|
||||||
|
QMessageBox::question(this, tr("Deleting file"), msg,
|
||||||
|
QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
|
if (rep == QMessageBox::Ok) {
|
||||||
|
exitdial = true;
|
||||||
|
unlink(autostartfile.c_str());
|
||||||
|
if (theconfig) {
|
||||||
|
Pidfile pidfile(theconfig->getPidfile());
|
||||||
|
pid_t pid;
|
||||||
|
if ((pid = pidfile.open()) != 0) {
|
||||||
|
QMessageBox::Button rep =
|
||||||
|
QMessageBox::question(this,
|
||||||
|
tr("Removing autostart"),
|
||||||
|
tr("Autostart file deleted. Kill current process too ?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (rep == QMessageBox::Yes) {
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exitdial = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (exitdial)
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2005 J.F.Dockes
|
/*
|
||||||
* 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 as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -14,4 +14,28 @@
|
|||||||
* Free Software Foundation, Inc.,
|
* Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#include "autoconfig.h"
|
#ifndef _RTITOOL_W_H_INCLUDED_
|
||||||
|
#define _RTITOOL_W_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "ui_rtitool.h"
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
|
class RTIToolW : public QDialog, public Ui::RTIToolW {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RTIToolW(QWidget * parent = 0)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
public slots:
|
||||||
|
void sesclicked(bool);
|
||||||
|
void accept();
|
||||||
|
private:
|
||||||
|
void init();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _RTITOOL_W_H_INCLUDED_ */
|
||||||
123
src/qtgui/rtitool.ui
Normal file
123
src/qtgui/rtitool.ui
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>RTIToolW</class>
|
||||||
|
<widget class="QDialog" name="RTIToolW">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>409</width>
|
||||||
|
<height>182</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Real time indexing automatic start</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
|
p, li { white-space: pre-wrap; }
|
||||||
|
</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Recoll</span> indexing can be set up to run as a daemon, updating the index as files change, in real time. You gain an always up to date index, but system resources are used permanently.</p>
|
||||||
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="sesCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start indexing daemon with my desktop session.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="nowCB">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Also start indexing daemon right now.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>RTIToolW</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>204</x>
|
||||||
|
<y>159</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>204</x>
|
||||||
|
<y>90</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>RTIToolW</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>204</x>
|
||||||
|
<y>159</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>204</x>
|
||||||
|
<y>90</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
@ -111,6 +111,7 @@ ${INSTALL} -m 0755 desktop/hotrecoll.py \
|
|||||||
${datadir}/recoll/filters/ || exit 1
|
${datadir}/recoll/filters/ || exit 1
|
||||||
|
|
||||||
${INSTALL} -m 0444 \
|
${INSTALL} -m 0444 \
|
||||||
|
desktop/recollindex.desktop \
|
||||||
sampleconf/mimeconf \
|
sampleconf/mimeconf \
|
||||||
sampleconf/mimeview \
|
sampleconf/mimeview \
|
||||||
sampleconf/recoll.conf \
|
sampleconf/recoll.conf \
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
#ifndef TEST_ECRONTAB
|
#ifndef TEST_ECRONTAB
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "ecrontab.h"
|
#include "ecrontab.h"
|
||||||
#include "execmd.h"
|
#include "execmd.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
@ -126,8 +128,8 @@ bool checkCrontabUnmanaged(const string& marker, const string& data)
|
|||||||
bool getCrontabSched(const string& marker, const string& id,
|
bool getCrontabSched(const string& marker, const string& id,
|
||||||
vector<string>& sched)
|
vector<string>& sched)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "getCrontabSched: marker[%s], id[%s]\n",
|
LOGDEB0(("getCrontabSched: marker[%s], id[%s]\n",
|
||||||
marker.c_str(), id.c_str());
|
marker.c_str(), id.c_str()));
|
||||||
vector<string> lines;
|
vector<string> lines;
|
||||||
if (!eCrontabGetLines(lines)) {
|
if (!eCrontabGetLines(lines)) {
|
||||||
// No crontab, answer is no
|
// No crontab, answer is no
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user