1 /* Copyright (C) 2005-2019 Jean-Francois 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.
6  *
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.
11  *
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  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 #include "autoconfig.h"
18 
19 #include <algorithm>
20 #include <cstdio>
21 
22 #include "recoll.h"
23 #include "log.h"
24 #include "smallut.h"
25 #include "guiutils.h"
26 #include "pathut.h"
27 #include "base64.h"
28 #include "advshist.h"
29 #include "readfile.h"
30 
31 #include <QSettings>
32 #include <QStringList>
33 #ifdef BUILDING_RECOLLGUI
34 #include <QFont>
35 #endif
36 
37 RclDynConf *g_dynconf;
38 AdvSearchHist *g_advshistory;
39 RclConfig *theconfig;
40 
41 // The table should not be necessary, but I found no css way to get
42 // qt 4.6 qtextedit to clear the margins after the float img without
43 // introducing blank space.
44 const char *PrefsPack::dfltResListFormat =
45     "<table class=\"respar\">\n"
46     "<tr>\n"
47     "<td><a href='%U'><img src='%I' width='64'></a></td>\n"
48     "<td>%L &nbsp;<i>%S</i> &nbsp;&nbsp;<b>%T</b><br>\n"
49     "<span style='white-space:nowrap'><i>%M</i>&nbsp;%D</span>&nbsp;&nbsp;&nbsp; <i>%U</i>&nbsp;%i<br>\n"
50     "%A %K</td>\n"
51     "</tr></table>\n"
52     ;
53 
54 // The global preferences structure
55 PrefsPack prefs;
56 
57 // Using the same macro to read/write a setting. insurance against typing
58 // mistakes
59 #define SETTING_RW(var, nm, tp, def)            \
60     if (writing) {                              \
61         settings.setValue(nm , var);            \
62     } else {                                    \
63         var = settings.value(nm, def).to##tp    \
64             ();                                 \
65     }
66 
67 /**
68  * Saving and restoring user preferences. These are stored in a global
69  * structure during program execution and saved to disk using the QT
70  * settings mechanism
71  */
72 /* Remember if settings were actually read (to avoid writing them if
73  * we stopped before reading them (else some kinds of errors would reset
74  * the qt/recoll settings to defaults) */
75 static bool havereadsettings;
76 
77 #ifdef _WIN32
78 static void maybeCopyFromRegistry();
79 #else /* ! _WIN32 */
80 static void maybeRenameGUISettings();
81 #endif /* ! _WIN32 */
82 
rwSettings(bool writing)83 void rwSettings(bool writing)
84 {
85 #ifdef _WIN32
86     {
87         static int once = 1;
88         // Once conversion registry -> file. Only happens once ever, and
89         // also we only call the function at program startup (the once
90         // above).
91         if (once) {
92             maybeCopyFromRegistry();
93             once = 0;
94         }
95     }
96 #else
97     maybeRenameGUISettings();
98 #endif /* !_WIN32 */
99     // Keep this AFTER maybecopy...()
100     QSettings::setDefaultFormat(QSettings::IniFormat);
101 
102     LOGDEB1("rwSettings: write " << writing << "\n");
103     if (writing && !havereadsettings)
104         return;
105     QSettings settings;
106     SETTING_RW(prefs.showmode, "/Recoll/geometry/showmode", Int, 0);
107     SETTING_RW(prefs.pvwidth, "/Recoll/geometry/pvwidth", Int, 0);
108     SETTING_RW(prefs.pvheight, "/Recoll/geometry/pvheight", Int, 0);
109     SETTING_RW(prefs.ssearchTypSav, "/Recoll/prefs/ssearchTypSav", Bool, 0);
110     SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Int, 3);
111     SETTING_RW(prefs.startWithAdvSearchOpen,
112                "/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
113     SETTING_RW(prefs.previewHtml, "/Recoll/prefs/previewHtml", Bool, true);
114     SETTING_RW(prefs.previewActiveLinks,
115                "/Recoll/prefs/previewActiveLinks", Bool, false);
116 
117     QString advSearchClauses;
118     const int maxclauselistsize = 20;
119     if (writing) {
120         // Limit clause list size to non-absurd size
121         if (prefs.advSearchClauses.size() > maxclauselistsize) {
122             prefs.advSearchClauses.resize(maxclauselistsize);
123         }
124         for (auto clause : prefs.advSearchClauses) {
125             char buf[20];
126             sprintf(buf, "%d ", clause);
127             advSearchClauses += QString::fromUtf8(buf);
128         }
129     }
130     QString ascdflt;
131     SETTING_RW(advSearchClauses,"/Recoll/prefs/adv/clauseList", String, ascdflt);
132     if (!writing) {
133         vector<string> clauses;
134         stringToStrings(qs2utf8s(advSearchClauses), clauses);
135         // There was a long-lurking bug where the clause list was
136         // growing to absurd sizes. The prefs.advSearchClauses clear()
137         // call was missing (ok with the now false initial assumption
138         // that the prefs were read once per session), which was
139         // causing a doubling of the size each time the prefs were
140         // read. Should be fixed, but in any case, limit the clause
141         // list to a non-absurd size.
142         if (clauses.size() > maxclauselistsize) {
143             clauses.resize(maxclauselistsize);
144         }
145         prefs.advSearchClauses.clear();
146         prefs.advSearchClauses.reserve(clauses.size());
147         for (auto clause : clauses) {
148             prefs.advSearchClauses.push_back(atoi(clause.c_str()));
149         }
150     }
151 
152     SETTING_RW(prefs.ssearchNoComplete,
153                "/Recoll/prefs/ssearch/noComplete", Bool, false);
154     SETTING_RW(prefs.ssearchStartOnComplete,
155                "/Recoll/prefs/ssearch/startOnComplete", Bool, true);
156     SETTING_RW(prefs.filterCtlStyle, "/Recoll/prefs/filterCtlStyle", Int, 0);
157     SETTING_RW(prefs.ssearchAutoPhrase,
158                "/Recoll/prefs/ssearchAutoPhrase", Bool, true);
159     SETTING_RW(prefs.ssearchAutoPhraseThreshPC,
160                "/Recoll/prefs/ssearchAutoPhraseThreshPC", Double, 2.0);
161     SETTING_RW(prefs.respagesize, "/Recoll/prefs/reslist/pagelen", Int, 8);
162     SETTING_RW(prefs.historysize, "/Recoll/prefs/historysize", Int, -1);
163     SETTING_RW(prefs.collapseDuplicates,
164                "/Recoll/prefs/reslist/collapseDuplicates", Bool, false);
165     SETTING_RW(prefs.showResultsAsTable,
166                "/Recoll/prefs/showResultsAsTable", Bool, false);
167 
168     SETTING_RW(prefs.maxhltextkbs, "/Recoll/prefs/preview/maxhltextkbs", Int,
169                3000);
170     // Compat: if maxhltextkbs is not set but old maxhltextmbs is set use it
171     if (!writing && !settings.contains("/Recoll/prefs/preview/maxhltextkbs") &&
172         settings.contains("/Recoll/prefs/preview/maxhltextmbs")) {
173         prefs.maxhltextkbs = settings.value(
174             "/Recoll/prefs/preview/maxhltextmbs").toInt() * 1024;
175     }
176 
177     SETTING_RW(prefs.previewPlainPre,
178                "/Recoll/prefs/preview/plainPre", Int, PrefsPack::PP_PREWRAP);
179 
180     // History: used to be able to only set a bare color name. Can now
181     // set any CSS style. Hack on ':' presence to keep compat with old
182     // values
183     SETTING_RW(prefs.qtermstyle, "/Recoll/prefs/qtermcolor", String,
184                "color: blue");
185     if (!writing && prefs.qtermstyle == "")
186         prefs.qtermstyle = "color: blue";
187     { // histo compatibility hack
188         int colon = prefs.qtermstyle.indexOf(":");
189         int semi = prefs.qtermstyle.indexOf(";");
190         // The 2nd part of the test is to keep compat with the
191         // injection hack of the 1st user who suggested this (had
192         // #ff5000;font-size:110%;... in 'qtermcolor')
193         if (colon == -1 || (colon != -1 && semi != -1 && semi < colon)) {
194             prefs.qtermstyle = QString::fromUtf8("color: ") + prefs.qtermstyle;
195         }
196     }
197 
198     SETTING_RW(u8s2qs(prefs.reslistdateformat), "/Recoll/prefs/reslist/dateformat",
199                String, "&nbsp;%Y-%m-%d&nbsp;%H:%M:%S&nbsp;%z");
200     if (!writing && prefs.reslistdateformat == "")
201         prefs.reslistdateformat = "&nbsp;%Y-%m-%d&nbsp;%H:%M:%S&nbsp;%z";
202 
203     SETTING_RW(prefs.reslistfontfamily, "/Recoll/prefs/reslist/fontFamily",
204                String, "");
205 
206     // While building the kio, we don't really care about QT Gui
207     // defaults and referencing QFont introduces a useless dependency
208 #ifdef BUILDING_RECOLLGUI
209     SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int, QFont().pointSize());
210 #else
211     SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int, 12);
212 #endif
213 
214     QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
215     if (writing) {
216         if (prefs.reslistformat.compare(rlfDflt)) {
217             settings.setValue("/Recoll/prefs/reslist/format",
218                               prefs.reslistformat);
219         } else {
220             settings.remove("/Recoll/prefs/reslist/format");
221         }
222     } else {
223         prefs.reslistformat =
224             settings.value("/Recoll/prefs/reslist/format", rlfDflt).toString();
225         prefs.creslistformat = qs2utf8s(prefs.reslistformat);
226     }
227 
228     SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext",
229                String, "");
230     SETTING_RW(prefs.darkMode, "/Recoll/prefs/darkMode", Bool, 0);
231     SETTING_RW(prefs.qssFile, "/Recoll/prefs/stylesheet", String, "");
232     SETTING_RW(prefs.snipCssFile, "/Recoll/prefs/snippets/cssfile", String, "");
233     SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
234                "english");
235     SETTING_RW(prefs.useDesktopOpen, "/Recoll/prefs/useDesktopOpen",
236                Bool, true);
237 
238     SETTING_RW(prefs.keepSort,
239                "/Recoll/prefs/keepSort", Bool, false);
240     SETTING_RW(prefs.sortField, "/Recoll/prefs/sortField", String, "");
241     SETTING_RW(prefs.sortActive,
242                "/Recoll/prefs/sortActive", Bool, false);
243     SETTING_RW(prefs.sortDesc,
244                "/Recoll/prefs/query/sortDesc", Bool, 0);
245     if (!writing) {
246         // Handle transition from older prefs which did not store sortColumn
247         // (Active always meant sort by date).
248         if (prefs.sortActive && prefs.sortField.isNull())
249             prefs.sortField = "mtime";
250     }
251 
252     SETTING_RW(prefs.queryBuildAbstract,
253                "/Recoll/prefs/query/buildAbstract", Bool, true);
254     SETTING_RW(prefs.queryReplaceAbstract,
255                "/Recoll/prefs/query/replaceAbstract", Bool, false);
256     SETTING_RW(prefs.syntAbsLen, "/Recoll/prefs/query/syntAbsLen",
257                Int, 250);
258     SETTING_RW(prefs.syntAbsCtx, "/Recoll/prefs/query/syntAbsCtx",
259                Int, 4);
260     // Abstract snippet separator
261     SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"&hellip;");
262     if (!writing && prefs.abssep == "")
263         prefs.abssep = "&hellip;";
264     SETTING_RW(prefs.snipwMaxLength, "/Recoll/prefs/snipwin/maxlen", Int, 1000);
265     SETTING_RW(prefs.snipwSortByPage,"/Recoll/prefs/snipwin/bypage", Bool,false);
266     SETTING_RW(prefs.alwaysSnippets, "/Recoll/prefs/reslist/alwaysSnippets",
267                Bool,false);
268 
269     SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, "");
270     SETTING_RW(prefs.autoSuffsEnable,
271                "/Recoll/prefs/query/autoSuffsEnable", Bool, false);
272 
273     SETTING_RW(prefs.synFileEnable,
274                "/Recoll/prefs/query/synFileEnable", Bool, false);
275     SETTING_RW(prefs.synFile, "/Recoll/prefs/query/synfile", String, "");
276 
277     SETTING_RW(prefs.termMatchType, "/Recoll/prefs/query/termMatchType",
278                Int, 0);
279     SETTING_RW(prefs.noBeeps, "/Recoll/prefs/query/noBeeps", Bool, false);
280 
281     // This is not really the current program version, just a value to
282     // be used in case we have incompatible changes one day
283     SETTING_RW(prefs.rclVersion, "/Recoll/prefs/rclVersion", Int, 1009);
284 
285     // Ssearch combobox history list
286     if (writing) {
287         settings.setValue("/Recoll/prefs/query/ssearchHistory",
288                           prefs.ssearchHistory);
289     } else {
290         prefs.ssearchHistory =
291             settings.value("/Recoll/prefs/query/ssearchHistory").toStringList();
292     }
293 
294     // Ignored file types (advanced search)
295     if (writing) {
296         settings.setValue("/Recoll/prefs/query/asearchIgnFilTyps",
297                           prefs.asearchIgnFilTyps);
298     } else {
299         prefs.asearchIgnFilTyps = settings.value(
300             "/Recoll/prefs/query/asearchIgnFilTyps").toStringList();
301     }
302 
303     SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat", Bool, false);
304     SETTING_RW(prefs.noClearSearch, "/Recoll/prefs/noClearSearch", Bool, false);
305     SETTING_RW(prefs.noToolbars, "/Recoll/prefs/noToolbars", Bool, false);
306     SETTING_RW(prefs.noStatusBar, "/Recoll/prefs/noStatusBar", Bool, false);
307     SETTING_RW(prefs.noMenuBar, "/Recoll/prefs/noMenuBar", Bool, false);
308     SETTING_RW(prefs.noSSTypCMB, "/Recoll/prefs/noSSTypCMB", Bool, false);
309     SETTING_RW(prefs.resTableTextNoShift, "/Recoll/prefs/resTableTextNoShift", Bool, false);
310     SETTING_RW(prefs.resTableNoHoverMeta, "/Recoll/prefs/resTableNoHoverMeta", Bool, false);
311     SETTING_RW(prefs.noResTableHeader, "/Recoll/prefs/noResTableHeader", Bool, false);
312     SETTING_RW(prefs.showResTableVHeader, "/Recoll/prefs/showResTableVHeader", Bool, false);
313     SETTING_RW(prefs.noResTableRowJumpSC, "/Recoll/prefs/noResTableRowJumpSC", Bool, false);
314     SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false);
315     SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false);
316     SETTING_RW(prefs.trayMessages, "/Recoll/prefs/trayMessages", Bool, false);
317     // See qxtconfirmationmessage. Needs to be -1 for the dialog to show.
318     SETTING_RW(prefs.showTempFileWarning, "Recoll/prefs/showTempFileWarning", Int, -1);
319 
320     if (g_dynconf == 0) {
321         // Happens
322         return;
323     }
324     // The extra databases settings. These are stored as a list of
325     // xapian directory names, encoded in base64 to avoid any
326     // binary/charset conversion issues. There are 2 lists for all
327     // known dbs and active (searched) ones.
328     // When starting up, we also add from the RECOLL_EXTRA_DBS environment
329     // variable.
330     // This are stored inside the dynamic configuration file (aka: history),
331     // as they are likely to depend on RECOLL_CONFDIR.
332     if (writing) {
333         g_dynconf->eraseAll(allEdbsSk);
334         for (const auto& dbdir : prefs.allExtraDbs) {
335             g_dynconf->enterString(allEdbsSk, dbdir);
336         }
337         g_dynconf->eraseAll(actEdbsSk);
338         for (const auto& dbdir : prefs.activeExtraDbs) {
339             g_dynconf->enterString(actEdbsSk, dbdir);
340         }
341     } else {
342         prefs.allExtraDbs = g_dynconf->getStringEntries<vector>(allEdbsSk);
343         const char *cp;
344         if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
345             vector<string> dbl;
346             stringToTokens(cp, dbl, ":");
347             for (const auto& path : dbl) {
348                 string dbdir = path_canon(path);
349                 path_catslash(dbdir);
350                 if (std::find(prefs.allExtraDbs.begin(),
351                               prefs.allExtraDbs.end(), dbdir) !=
352                     prefs.allExtraDbs.end())
353                     continue;
354                 bool stripped;
355                 if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
356                     LOGERR("Not a xapian index: [" << dbdir << "]\n");
357                     continue;
358                 }
359                 if (stripped != o_index_stripchars) {
360                     LOGERR("Incompatible character stripping: [" << dbdir <<
361                            "]\n");
362                     continue;
363                 }
364                 prefs.allExtraDbs.push_back(dbdir);
365             }
366         }
367 
368         // Get the remembered "active external indexes":
369         prefs.activeExtraDbs = g_dynconf->getStringEntries<vector>(actEdbsSk);
370 
371         // Clean up the list: remove directories which are not
372         // actually there: useful for removable volumes.
373         for (auto it = prefs.activeExtraDbs.begin();
374              it != prefs.activeExtraDbs.end();) {
375             bool stripped;
376             if (!Rcl::Db::testDbDir(*it, &stripped) ||
377                 stripped != o_index_stripchars) {
378                 LOGINFO("Not a Xapian index or char stripping differs: ["  <<
379                         *it << "]\n");
380                 it = prefs.activeExtraDbs.erase(it);
381             } else {
382                 it++;
383             }
384         }
385 
386         // Get active db directives from the environment. This can only add to
387         // the remembered and cleaned up list
388         const char *cp4Act;
389         if ((cp4Act = getenv("RECOLL_ACTIVE_EXTRA_DBS")) != 0) {
390             vector<string> dbl;
391             stringToTokens(cp4Act, dbl, ":");
392             for (const auto& path : dbl) {
393                 string dbdir = path_canon(path);
394                 path_catslash(dbdir);
395                 if (std::find(prefs.activeExtraDbs.begin(),
396                               prefs.activeExtraDbs.end(), dbdir) !=
397                     prefs.activeExtraDbs.end())
398                     continue;
399                 bool strpd;
400                 if (!Rcl::Db::testDbDir(dbdir, &strpd) ||
401                     strpd != o_index_stripchars) {
402                     LOGERR("Not a Xapian dir or diff. char stripping: ["  <<
403                            dbdir << "]\n");
404                     continue;
405                 }
406                 prefs.activeExtraDbs.push_back(dbdir);
407             } //for
408         } //if
409     }
410 
411 #if 0
412     std::cerr << "All extra Dbs:\n";
413     for (const auto& dir : prefs.allExtraDbs)
414         std::cerr << "    [" << dir << "]\n";
415     std::cerr << "Active extra Dbs:\n";
416     for (const auto& dir : prefs.activeExtraDbs)
417         std::cerr << "    [" << dir << "]\n";
418 #endif
419 
420     const string asbdSk = "asearchSbd";
421     if (writing) {
422         while (prefs.asearchSubdirHist.size() > 20)
423             prefs.asearchSubdirHist.pop_back();
424         g_dynconf->eraseAll(asbdSk);
425         for (const auto& qdbd : prefs.asearchSubdirHist) {
426             g_dynconf->enterString(asbdSk, qs2utf8s(qdbd));
427         }
428     } else {
429         vector<string> tl = g_dynconf->getStringEntries<vector>(asbdSk);
430         for (const auto& dbd: tl) {
431             prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str()));
432         }
433     }
434     if (!writing) {
435         prefs.setupDarkCSS();
436     }
437     if (!writing)
438         havereadsettings = true;
439 }
440 
setupDarkCSS()441 void PrefsPack::setupDarkCSS()
442 {
443     if (!darkMode) {
444         darkreslistheadertext.clear();
445         return;
446     }
447     if (nullptr == theconfig) {
448         return;
449     }
450     string fn = path_cat(
451         path_cat(theconfig->getDatadir(), "examples"), "recoll-dark.css");
452     string data;
453     string reason;
454     if (!file_to_string(fn, data, &reason)) {
455         std::cerr << "Recoll: Could not read: " << fn << "\n";
456     }
457     darkreslistheadertext = u8s2qs(data);
458 }
459 
stemlang()460 string PrefsPack::stemlang()
461 {
462     string stemLang(qs2utf8s(prefs.queryStemLang));
463     if (stemLang == "ALL") {
464         if (theconfig)
465             theconfig->getConfParam("indexstemminglanguages", stemLang);
466         else
467             stemLang = "";
468     }
469     return stemLang;
470 }
471 
472 #ifdef _WIN32
473 // Once conversion of registry storage to file. If the file-specific
474 // key does not exist, copy from registry to file and create the
475 // file-specific key.
maybeCopyFromRegistry()476 void maybeCopyFromRegistry()
477 {
478     const char* markerkey = "registryToFileDone";
479     std::map<QString, QVariant> settingsmap;
480     {
481         QSettings settings;
482         QStringList keys = settings.allKeys();
483         for (int ki = 0; ki < keys.count(); ki++) {
484             QString key = keys[ki];
485             settingsmap[keys[ki]] = settings.value(keys[ki]);
486         }
487     }
488     QSettings::setDefaultFormat(QSettings::IniFormat);
489     QSettings settings;
490     if (settings.value(markerkey) != QVariant()) {
491         // Already done;
492         return;
493     }
494     for (const auto& entry : settingsmap) {
495         LOGDEB("maybeCopyFromRegistry: KEY [" <<
496                qs2utf8s(entry.first) << "] VALUE [" <<
497                qs2utf8s(entry.second.toString()) << "]\n");
498         settings.setValue(entry.first, entry.second);
499     }
500     settings.setValue(markerkey, 1);
501 }
502 
503 #else /* ! _WIN32 -> */
504 
505 // The Linux settings name unvontarily changed from
506 // ~/.config/Recoll.org/recoll.conf to ~/.config/Recoll.org/recoll.ini
507 // when the Windows version switched from registry to ini storage. Too
508 // late to really fix as 1.26.6 was released (at least in the
509 // lesbonscomptes repo and Debian unstable). For the lucky guys who
510 // did not run 1.26.6, the following was added in 1.26.7 to rename the
511 // file if the .ini target does not exist.
maybeRenameGUISettings()512 static void maybeRenameGUISettings()
513 {
514     string opath = path_cat(path_home(), ".config/Recoll.org/recoll.conf");
515     string npath = path_cat(path_home(), ".config/Recoll.org/recoll.ini");
516     if (path_exists(opath) && !path_exists(npath)) {
517         rename(opath.c_str(), npath.c_str());
518     }
519 }
520 #endif /* ! _WIN32 */
521 
522 #ifdef SHOWEVENTS
eventTypeToStr(int tp)523 const char *eventTypeToStr(int tp)
524 {
525     switch (tp) {
526     case  0: return "None";
527     case  1: return "Timer";
528     case  2: return "MouseButtonPress";
529     case  3: return "MouseButtonRelease";
530     case  4: return "MouseButtonDblClick";
531     case  5: return "MouseMove";
532     case  6: return "KeyPress";
533     case  7: return "KeyRelease";
534     case  8: return "FocusIn";
535     case  9: return "FocusOut";
536     case  10: return "Enter";
537     case  11: return "Leave";
538     case  12: return "Paint";
539     case  13: return "Move";
540     case  14: return "Resize";
541     case  15: return "Create";
542     case  16: return "Destroy";
543     case  17: return "Show";
544     case  18: return "Hide";
545     case  19: return "Close";
546     case  20: return "Quit";
547     case  21: return "ParentChange";
548     case  131: return "ParentAboutToChange";
549     case  22: return "ThreadChange";
550     case  24: return "WindowActivate";
551     case  25: return "WindowDeactivate";
552     case  26: return "ShowToParent";
553     case  27: return "HideToParent";
554     case  31: return "Wheel";
555     case  33: return "WindowTitleChange";
556     case  34: return "WindowIconChange";
557     case  35: return "ApplicationWindowIconChange";
558     case  36: return "ApplicationFontChange";
559     case  37: return "ApplicationLayoutDirectionChange";
560     case  38: return "ApplicationPaletteChange";
561     case  39: return "PaletteChange";
562     case  40: return "Clipboard";
563     case  42: return "Speech";
564     case  43: return "MetaCall";
565     case  50: return "SockAct";
566     case  132: return "WinEventAct";
567     case  52: return "DeferredDelete";
568     case  60: return "DragEnter";
569     case  61: return "DragMove";
570     case  62: return "DragLeave";
571     case  63: return "Drop";
572     case  64: return "DragResponse";
573     case  68: return "ChildAdded";
574     case  69: return "ChildPolished";
575     case  70: return "ChildInserted";
576     case  72: return "LayoutHint";
577     case  71: return "ChildRemoved";
578     case  73: return "ShowWindowRequest";
579     case  74: return "PolishRequest";
580     case  75: return "Polish";
581     case  76: return "LayoutRequest";
582     case  77: return "UpdateRequest";
583     case  78: return "UpdateLater";
584     case  79: return "EmbeddingControl";
585     case  80: return "ActivateControl";
586     case  81: return "DeactivateControl";
587     case  82: return "ContextMenu";
588     case  83: return "InputMethod";
589     case  86: return "AccessibilityPrepare";
590     case  87: return "TabletMove";
591     case  88: return "LocaleChange";
592     case  89: return "LanguageChange";
593     case  90: return "LayoutDirectionChange";
594     case  91: return "Style";
595     case  92: return "TabletPress";
596     case  93: return "TabletRelease";
597     case  94: return "OkRequest";
598     case  95: return "HelpRequest";
599     case  96: return "IconDrag";
600     case  97: return "FontChange";
601     case  98: return "EnabledChange";
602     case  99: return "ActivationChange";
603     case  100: return "StyleChange";
604     case  101: return "IconTextChange";
605     case  102: return "ModifiedChange";
606     case  109: return "MouseTrackingChange";
607     case  103: return "WindowBlocked";
608     case  104: return "WindowUnblocked";
609     case  105: return "WindowStateChange";
610     case  110: return "ToolTip";
611     case  111: return "WhatsThis";
612     case  112: return "StatusTip";
613     case  113: return "ActionChanged";
614     case  114: return "ActionAdded";
615     case  115: return "ActionRemoved";
616     case  116: return "FileOpen";
617     case  117: return "Shortcut";
618     case  51: return "ShortcutOverride";
619     case  30: return "Accel";
620     case  32: return "AccelAvailable";
621     case  118: return "WhatsThisClicked";
622     case  120: return "ToolBarChange";
623     case  121: return "ApplicationActivated";
624     case  122: return "ApplicationDeactivated";
625     case  123: return "QueryWhatsThis";
626     case  124: return "EnterWhatsThisMode";
627     case  125: return "LeaveWhatsThisMode";
628     case  126: return "ZOrderChange";
629     case  127: return "HoverEnter";
630     case  128: return "HoverLeave";
631     case  129: return "HoverMove";
632     case  119: return "AccessibilityHelp";
633     case  130: return "AccessibilityDescription";
634     case  150: return "EnterEditFocus";
635     case  151: return "LeaveEditFocus";
636     case  152: return "AcceptDropsChange";
637     case  153: return "MenubarUpdated";
638     case  154: return "ZeroTimerEvent";
639     case  155: return "GraphicsSceneMouseMove";
640     case  156: return "GraphicsSceneMousePress";
641     case  157: return "GraphicsSceneMouseRelease";
642     case  158: return "GraphicsSceneMouseDoubleClick";
643     case  159: return "GraphicsSceneContextMenu";
644     case  160: return "GraphicsSceneHoverEnter";
645     case  161: return "GraphicsSceneHoverMove";
646     case  162: return "GraphicsSceneHoverLeave";
647     case  163: return "GraphicsSceneHelp";
648     case  164: return "GraphicsSceneDragEnter";
649     case  165: return "GraphicsSceneDragMove";
650     case  166: return "GraphicsSceneDragLeave";
651     case  167: return "GraphicsSceneDrop";
652     case  168: return "GraphicsSceneWheel";
653     case  169: return "KeyboardLayoutChange";
654     case  170: return "DynamicPropertyChange";
655     case  171: return "TabletEnterProximity";
656     case  172: return "TabletLeaveProximity";
657     default: return "UnknownEvent";
658     }
659 }
660 #endif
661