diff --git a/src/qtgui/rclm_view.cpp b/src/qtgui/rclm_view.cpp index b34696b6..20f55344 100644 --- a/src/qtgui/rclm_view.cpp +++ b/src/qtgui/rclm_view.cpp @@ -399,7 +399,9 @@ void RclMain::execViewer(const map& subs, bool istempfile, // Also substitute inside the unsplitted command line and display // in status bar pcSubst(cmd, ncmd, subs); +#ifndef _WIN32 ncmd += " &"; +#endif QStatusBar *stb = statusBar(); if (stb) { string fcharset = theconfig->getDefCharset(true); @@ -417,7 +419,7 @@ void RclMain::execViewer(const map& subs, bool istempfile, zg_send_event(ZGSEND_OPEN, doc); // We keep pushing back and never deleting. This can't be good... - ExecCmd *ecmd = new ExecCmd; + ExecCmd *ecmd = new ExecCmd(ExecCmd::EXF_SHOWWINDOW); m_viewers.push_back(ecmd); ecmd->startExec(execpath, lcmd, false, false); } diff --git a/src/qtgui/recoll.pro b/src/qtgui/recoll.pro index 02448379..4febacec 100644 --- a/src/qtgui/recoll.pro +++ b/src/qtgui/recoll.pro @@ -6,8 +6,11 @@ LANGUAGE = C++ QT += webkit -# QT += dbus -# QMAKE_CXXFLAGS += -DUSE_ZEITGEIST +DEFINES += BUILDING_RECOLL +DEFINES -= UNICODE +DEFINES -= _UNICODE +DEFINES += _MBCS +DEFINES += PSAPI_VERSION=1 QT += xml greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webkitwidgets printsupport @@ -106,7 +109,7 @@ windows { contains(QMAKE_CC, cl){ # Visual Studio } - LIBS += C:/recoll/src/build-librecoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/librecoll.dll + LIBS += C:/recoll/src/windows/build-librecoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/librecoll.dll } TRANSLATIONS = \ diff --git a/src/utils/execmd.cpp b/src/utils/execmd.cpp index 4f37e769..0f60c7a6 100644 --- a/src/utils/execmd.cpp +++ b/src/utils/execmd.cpp @@ -153,7 +153,7 @@ public: }; bool ExecCmd::Internal::o_useVfork = false; -ExecCmd::ExecCmd() +ExecCmd::ExecCmd(int) { m = new Internal(); if (m) diff --git a/src/utils/execmd.h b/src/utils/execmd.h index 68d7e87a..331f52fc 100644 --- a/src/utils/execmd.h +++ b/src/utils/execmd.h @@ -176,7 +176,14 @@ class ExecCmd { */ bool requestChildExit(); - ExecCmd(); + enum ExFlags {EXF_NONE, + // Only does anything on windows. Used when starting + // a viewer. The default is to hide the window, + // because it avoids windows appearing and + // disappearing when executing stuff for previewing + EXF_SHOWWINDOW = 1, + }; + ExecCmd(int flags = 0); ~ExecCmd(); /** diff --git a/src/utils/fstreewalk.cpp b/src/utils/fstreewalk.cpp index 6e97c678..dd6d6c25 100644 --- a/src/utils/fstreewalk.cpp +++ b/src/utils/fstreewalk.cpp @@ -361,6 +361,10 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top, case EPERM: case EACCES: case ENOENT: +#ifdef _WIN32 + // We get this quite a lot, don't know why. To be checked. + case EINVAL: +#endif goto out; default: status = FtwError; diff --git a/src/windows/execmd_w.cpp b/src/windows/execmd_w.cpp index 8dbc7df6..b8319283 100644 --- a/src/windows/execmd_w.cpp +++ b/src/windows/execmd_w.cpp @@ -255,8 +255,9 @@ static int getVMMBytes(HANDLE hProcess) class ExecCmd::Internal { public: - Internal() - : m_advise(0), m_provide(0), m_timeoutMs(1000), m_rlimit_as_mbytes(0) { + Internal(int flags) + : m_advise(0), m_provide(0), m_timeoutMs(1000), m_rlimit_as_mbytes(0), + m_flags(flags) { reset(); } @@ -265,7 +266,8 @@ public: ExecCmdProvide *m_provide; int m_timeoutMs; int m_rlimit_as_mbytes; - + int m_flags; + // We need buffered I/O for getline. The Unix version uses netcon's string m_buf; // Buffer. Only used when doing getline()s size_t m_bufoffs; // Pointer to current 1st byte of useful data @@ -360,9 +362,9 @@ private: bool m_active; }; -ExecCmd::ExecCmd() +ExecCmd::ExecCmd(int flags) { - m = new Internal(); + m = new Internal(flags); if (m) { m->reset(); } @@ -703,7 +705,11 @@ int ExecCmd::startExec(const string &cmd, const vector& args, // This structure specifies the STDIN and STDOUT handles for redirection. ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); siStartInfo.cb = sizeof(STARTUPINFO); - siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + if (m->m_flags & EXF_SHOWWINDOW) { + siStartInfo.dwFlags |= STARTF_USESTDHANDLES; + } else { + siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + } siStartInfo.hStdOutput = hOutputWrite; siStartInfo.hStdInput = hInputRead; siStartInfo.hStdError = hErrorWrite; diff --git a/src/windows/mimeview b/src/windows/mimeview index 21180286..50726ee3 100644 --- a/src/windows/mimeview +++ b/src/windows/mimeview @@ -22,7 +22,10 @@ xallexcepts = \ [view] # Pseudo entry used if the 'use desktop' preference is set in the GUI -application/x-all = cmd /c start %u +# Could not get the cmd-based ones to work (tried quoting "start %u" too) +#application/x-all = c:/Windows/System32/cmd /c start %u +#application/x-all = cmd /c start %u +application/x-all = rclstartw %f ####### Special ones # Open the parent epub document for epub parts instead of opening them as @@ -53,7 +56,10 @@ application/x-dvi = evince --page-index=%p --find=%s %f application/x-lyx = lyx %f application/x-scribus = scribus %f -application/msword = libreoffice %f +#application/msword = libreoffice %f +application/msword = \ + "C:/Program Files (x86)/LibreOffice 5/program/soffice.exe" %f + application/vnd.ms-excel = libreoffice %f application/vnd.ms-powerpoint = libreoffice %f diff --git a/src/windows/mkinstdir.sh b/src/windows/mkinstdir.sh index aa4d4966..3b8f2db8 100644 --- a/src/windows/mkinstdir.sh +++ b/src/windows/mkinstdir.sh @@ -22,7 +22,7 @@ LIBR=C:/recoll/src/windows/build-librecoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/de GUIBIN=C:/Users/Bill/recoll/src/build-recoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recoll.exe RCLIDX=C:/recoll/src/windows/build-recollindex-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recollindex.exe RCLQ=C:/recoll/src/windows/build-recollq-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recollq.exe - +RCLS=C:/recoll/src/windows/build-rclstartw-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/rclstartw.exe ################ # Script: @@ -56,6 +56,7 @@ copyrecoll() cc $GUIBIN $DESTDIR cc $RCLIDX $DESTDIR cc $RCLQ $DESTDIR + cc $RCLS $DESTDIR cc $RECOLL/sampleconf/fields $DESTDIR/Share/examples cc $RECOLL/sampleconf/fragbuts.xml $DESTDIR/Share/examples diff --git a/src/windows/qmkrecoll/rclstartw.pro b/src/windows/qmkrecoll/rclstartw.pro new file mode 100644 index 00000000..5af52100 --- /dev/null +++ b/src/windows/qmkrecoll/rclstartw.pro @@ -0,0 +1,33 @@ + +QT -= core gui + +TARGET = rclstartw +TEMPLATE = app + +DEFINES += BUILDING_RECOLL +DEFINES -= UNICODE +DEFINES -= _UNICODE +DEFINES += _MBCS +DEFINES += PSAPI_VERSION=1 + + +SOURCES += \ +../rclstartw.cpp + +INCLUDEPATH += ../../common ../../index ../../internfile ../../query \ + ../../unac ../../utils ../../aspell ../../rcldb ../../qtgui \ + ../../xaposix ../../confgui ../../bincimapmime + +windows { + contains(QMAKE_CC, gcc){ + # MingW + QMAKE_CXXFLAGS += -std=c++11 -Wno-unused-parameter + } + contains(QMAKE_CC, cl){ + # Visual Studio + } + LIBS += \ + -liconv -lshlwapi -lpsapi -lkernel32 + + INCLUDEPATH += ../../windows +} diff --git a/src/windows/rclstartw.cpp b/src/windows/rclstartw.cpp new file mode 100644 index 00000000..92d549de --- /dev/null +++ b/src/windows/rclstartw.cpp @@ -0,0 +1,58 @@ +/* Copyright (C) 2015 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 +#include +#include + +using namespace std; + +// This exists only because I could not find any way to get "cmd /c +// start fn" to work when executed from the recoll GUI. Otoh, +// cygstart, which uses ShellExecute() did work... So this is just a +// simpler cygstart +static char *thisprog; +static char usage [] ="rclstartw \n" + " Will use ShellExecute to open the arg with the default app\n"; + +static void Usage(FILE *fp = stderr) +{ + fprintf(fp, "%s: usage:\n%s", thisprog, usage); + exit(1); +} + +int main(int argc, char *argv[]) +{ + thisprog = argv[0]; + argc--; argv++; + + if (argc != 1) { + Usage(); + } + char *fn = strdup(argv[0]); + + // Do we need this ? + //https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx + //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + + int ret = (int)ShellExecute(NULL, "open", fn, NULL, NULL, SW_SHOWNORMAL); + if (ret) { + fprintf(stderr, "ShellExecute returned %d\n", ret); + } + return ret; +}