diff --git a/.hgignore b/.hgignore
index 3916b3cb..d9dfe0ec 100644
--- a/.hgignore
+++ b/.hgignore
@@ -84,8 +84,10 @@ src/sampleconf/rclmon.sh
src/sampleconf/recoll.conf
tests/config/aspdict.en.rws
tests/config/history
+tests/config/idxstatus.txt
tests/config/index.pid
tests/config/missing
tests/config/xapiandb
+tests/indexedmimetypes/idxstatus.txt
tests/indexedmimetypes/index.pid
website/usermanual/*
diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp
index 6dfa659a..0f5c1d1f 100644
--- a/src/qtgui/guiutils.cpp
+++ b/src/qtgui/guiutils.cpp
@@ -37,7 +37,7 @@ RclDynConf *g_dynconf;
// introducing blank space.
const char *PrefsPack::dfltResListFormat =
#if 1
- "
 | "
+ " | "
"%R %S %L %T "
"%M %D %U "
"%A %K |
"
@@ -49,10 +49,10 @@ const char *PrefsPack::dfltResListFormat =
#endif
;
-const char *v114reslistformat = "
"
- "%R %S %L %T
"
- "%M %D %U %i
"
- "%A %K";
+const char* v162reslistformat=" | "
+ "%R %S %L %T "
+ "%M %D %U "
+ "%A %K |
";
// The global preferences structure
@@ -151,7 +151,7 @@ void rwSettings(bool writing)
// If the current value of the format is the default for the
// previous version, replace it with the new default. We
// should have a flag to say if it was changed instead
- if (!prefs.creslistformat.compare(v114reslistformat)) {
+ if (!prefs.creslistformat.compare(v162reslistformat)) {
LOGDEB(("Replacing old default format\n"));
prefs.reslistformat = rlfDflt;
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp
index b8615a8e..697d2a56 100644
--- a/src/qtgui/reslist.cpp
+++ b/src/qtgui/reslist.cpp
@@ -49,6 +49,7 @@
#include "plaintorich.h"
#include "refcntr.h"
#include "internfile.h"
+#include "indexer.h"
#include "reslist.h"
#include "moc_reslist.cpp"
@@ -75,9 +76,9 @@ public:
virtual string nextUrl();
virtual string prevUrl();
virtual string pageTop();
- virtual string iconPath(const string& mt);
virtual void suggest(const vectoruterms, vector&sugg);
virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());}
+ virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
private:
ResList *m_parent;
};
@@ -161,12 +162,6 @@ string QtGuiResListPager::pageTop()
return string();
}
-string QtGuiResListPager::iconPath(const string& mtype)
-{
- string iconpath;
- theconfig->getMimeIconName(mtype, &iconpath);
- return iconpath;
-}
void QtGuiResListPager::suggest(const vectoruterms, vector&sugg)
{
@@ -200,6 +195,24 @@ void QtGuiResListPager::suggest(const vectoruterms, vector&sugg)
#endif
}
+
+string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
+{
+ if (doc.ipath.empty()) {
+ vector docs;
+ docs.push_back(doc);
+ vector paths;
+ ConfIndexer::docsToPaths(docs, paths);
+ if (!paths.empty()) {
+ string path;
+ if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) {
+ return cstr_fileu + path;
+ }
+ }
+ }
+ return ResListPager::iconUrl(config, doc);
+}
+
/////// /////// End reslistpager methods
class PlainToRichQtReslist : public PlainToRich {
diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp
index d73eb85e..e19981ec 100644
--- a/src/qtgui/restable.cpp
+++ b/src/qtgui/restable.cpp
@@ -45,6 +45,7 @@
#include "reslist.h"
#include "rclconfig.h"
#include "plaintorich.h"
+#include "indexer.h"
// Compensate for the default and somewhat bizarre vertical placement
// of text in cells
@@ -77,8 +78,8 @@ public:
virtual bool append(const string& data, int idx, const Rcl::Doc& doc);
virtual string trans(const string& in);
virtual const string &parFormat();
- virtual string iconPath(const string& mt);
virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());}
+ virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
private:
ResTable *m_parent;
};
@@ -102,11 +103,21 @@ const string& ResTablePager::parFormat()
return prefs.creslistformat;
}
-string ResTablePager::iconPath(const string& mtype)
+string ResTablePager::iconUrl(RclConfig *config, Rcl::Doc& doc)
{
- string iconpath;
- theconfig->getMimeIconName(mtype, &iconpath);
- return iconpath;
+ if (doc.ipath.empty()) {
+ vector docs;
+ docs.push_back(doc);
+ vector paths;
+ ConfIndexer::docsToPaths(docs, paths);
+ if (!paths.empty()) {
+ string path;
+ if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) {
+ return cstr_fileu + path;
+ }
+ }
+ }
+ return ResListPager::iconUrl(config, doc);
}
/////////////////////////////////////////////////////////////////////////////
diff --git a/src/query/reslistpager.cpp b/src/query/reslistpager.cpp
index 49ba253d..1c8fa9ed 100644
--- a/src/query/reslistpager.cpp
+++ b/src/query/reslistpager.cpp
@@ -138,7 +138,7 @@ void ResListPager::displayDoc(RclConfig *config,
}
// Determine icon to display if any
- string iconpath = iconPath(config, doc.mimetype);
+ string iconurl = iconUrl(config, doc);
// Printable url: either utf-8 if transcoding succeeds, or url-encoded
string url;
@@ -225,7 +225,7 @@ void ResListPager::displayDoc(RclConfig *config,
map subs;
subs["A"] = !richabst.empty() ? richabst : "";
subs["D"] = datebuf;
- subs["I"] = iconpath;
+ subs["I"] = iconurl;
subs["i"] = doc.ipath;
subs["K"] = !doc.meta[Rcl::Doc::keykw].empty() ?
string("[") + escapeHtml(doc.meta[Rcl::Doc::keykw]) + "]" : "";
@@ -379,12 +379,12 @@ string ResListPager::prevUrl()
return "p-1";
}
-string ResListPager::iconPath(RclConfig *config, const string& mtype)
+string ResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
{
- string iconpath;
- config->getMimeIconName(mtype, &iconpath);
- iconpath = cstr_fileu + iconpath;
- return iconpath;
+ string iconurl;
+ config->getMimeIconName(doc.mimetype, &iconurl);
+ iconurl = cstr_fileu + iconurl;
+ return iconurl;
}
bool ResListPager::append(const string& data)
diff --git a/src/query/reslistpager.h b/src/query/reslistpager.h
index 05a690b1..ee404181 100644
--- a/src/query/reslistpager.h
+++ b/src/query/reslistpager.h
@@ -110,7 +110,7 @@ public:
virtual string nextUrl();
virtual string prevUrl();
virtual string pageTop() {return string();}
- virtual string iconPath(RclConfig *, const string& mtype);
+ virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
virtual void suggest(const vector, vector&sugg) {
sugg.clear();
}
diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp
index 9ca90ce5..8b4c59fd 100644
--- a/src/utils/pathut.cpp
+++ b/src/utils/pathut.cpp
@@ -58,6 +58,7 @@ using std::stack;
#include "pathut.h"
#include "transcode.h"
#include "wipedir.h"
+#include "md5.h"
bool fsocc(const string &path, int *pc, long *blocks)
{
@@ -559,6 +560,47 @@ int Pidfile::remove()
return unlink(m_path.c_str());
}
+// Freedesktop standard paths for thumbnails
+
+// Place for 256x256 files
+static const string thmbdirlarge = ".thumbnails/large";
+// 128x128
+static const string thmbdirnormal = ".thumbnails/normal";
+
+static void thumbname(const string& url, string& name)
+{
+ string digest;
+ MD5String(url, digest);
+ MD5HexPrint(digest, name);
+ name += ".png";
+}
+
+bool thumbPathForUrl(const string& url, int size, string& path)
+{
+ string name;
+ thumbname(url, name);
+ if (size <= 128) {
+ path = path_cat(path_home(), thmbdirnormal);
+ path = path_cat(path, name);
+ if (access(path.c_str(), R_OK) == 0) {
+ return true;
+ }
+ }
+ path = path_cat(path_home(), thmbdirlarge);
+ path = path_cat(path, name);
+ if (access(path.c_str(), R_OK) == 0) {
+ return true;
+ }
+
+ // File does not exist. Path corresponds to the large version at this point,
+ // fix it if needed.
+ if (size <= 128) {
+ path = path_cat(path_home(), thmbdirnormal);
+ path = path_cat(path, name);
+ }
+ return false;
+}
+
#else // TEST_PATHUT
#include
#include
@@ -645,7 +687,7 @@ int main(int argc, const char **argv)
printf("pc %d, megabytes %ld\n", pc, blocks);
#endif
-#if 1
+#if 0
Pidfile pidfile("/tmp/pathutpidfile");
pid_t pid;
if ((pid = pidfile.open()) != 0) {
@@ -659,6 +701,35 @@ int main(int argc, const char **argv)
pidfile.remove();
#endif
+#if 1
+ if (argc != 2) {
+ fprintf(stderr, "Usage: thumbpath \n");
+ exit(1);
+ }
+
+ string input = *argv++;
+ int size = atoi(*argv++);
+
+ if (input.empty()) {
+ fprintf(stderr, "Usage: thumbpath \n");
+ exit(1);
+ }
+
+ // Make absolute path if needed
+ if (input[0] != '/') {
+ input = path_absolute(input);
+ }
+ input = string("file://") + path_canon(input);
+ string path;
+ if (thumbPathForUrl(input, size, path)) {
+ cout << "Thumbnail for [" << input << "] [" << path << "]" << endl;
+ } else {
+ cout << "No thumbnail for [" << input << "] path [" << path << "]" <