1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2006-2010 Ralf Habacker. All rights reserved. |
4 | ** |
5 | ** This file is part of the KDE installer for windows |
6 | ** |
7 | ** This library is free software; you can redistribute it and/or |
8 | ** modify it under the terms of the GNU Library General Public |
9 | ** License version 2 as published by the Free Software Foundation. |
10 | ** |
11 | ** This library is distributed in the hope that it will be useful, |
12 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | ** Library General Public License for more details. |
15 | ** |
16 | ** You should have received a copy of the GNU Library General Public License |
17 | ** along with this library; see the file COPYING.LIB. If not, write to |
18 | ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | ** Boston, MA 02110-1301, USA. |
20 | ** |
21 | ****************************************************************************/ |
22 | |
23 | #ifndef MISC_H |
24 | #define MISC_H |
25 | |
26 | #include "registry.h" // for compatibility |
27 | |
28 | #include <QRegExp> |
29 | #include <QString> |
30 | #include <QSettings> |
31 | #include <QFlags> |
32 | |
33 | class QFile; |
34 | class QIODevice; |
35 | class QTextStream; |
36 | |
37 | |
38 | typedef enum { RTUnspecified=0, Stable, Unstable, Nightly } ReleaseType; |
39 | ReleaseType toReleaseType(const QString &type); |
40 | const QString toString(ReleaseType type); |
41 | |
42 | struct InstallFile |
43 | { |
44 | QString inputFile; |
45 | QString outputFile; |
46 | bool bAbsInputPath; |
47 | bool usedFile; |
48 | |
49 | InstallFile(const QString &in, const QString &out = QString(), bool absPath = false) |
50 | : inputFile(in), outputFile(out), bAbsInputPath(absPath), usedFile(false) |
51 | {} |
52 | bool operator==(const InstallFile &o) |
53 | { |
54 | return (inputFile == o.inputFile && outputFile == o.outputFile); |
55 | } |
56 | friend QDebug operator<<(QDebug, const InstallFile &); |
57 | friend QDebug operator<<(QDebug, const QList<InstallFile> &); |
58 | friend QTextStream &operator<<(QTextStream &, const InstallFile &); |
59 | friend QTextStream &operator<<(QTextStream &, const QList<InstallFile> &); |
60 | }; |
61 | |
62 | bool parseQtIncludeFiles(QList<InstallFile> &fileList, const QString &root, const QString &subdir, const QString &filter, const QString &exclude); |
63 | |
64 | typedef struct { |
65 | QString shortDesc; |
66 | QString longDesc; |
67 | QString categories; |
68 | QString requires; |
69 | } HintFileDescriptor; |
70 | |
71 | bool parseHintFile(const QString &hintFile,HintFileDescriptor &pkg); |
72 | bool parseHintFile(const QByteArray &ba, HintFileDescriptor &pkg); |
73 | |
74 | bool findExecutables(QList<InstallFile> &fileList, const QString &root, const QString &subdir, const QString &filter, const QString &exclude, bool debugExe=false); |
75 | |
76 | /** |
77 | generate file list |
78 | @param result returned list |
79 | @param root root path where to search |
80 | @param subdir subdir appended to root to search for, use '.' for recursive search from root directory |
81 | @param filter pattern for included file types (separated by space) |
82 | @param excludeList regex for excluded file types - use either this or filter |
83 | @param verbose dump collected files |
84 | @return False in case of errore |
85 | */ |
86 | bool generateFileList(QList<InstallFile> &result, const QString &root, const QString &subdir, const QString &filter, const QList<QRegExp> &excludeList, bool verbose=false); |
87 | |
88 | /** |
89 | generate file list |
90 | @param result returned list |
91 | @param root root path where to search |
92 | @param subdir subdir appended to root to search for, use '.' for recursive search from root directory |
93 | @param filter regex for included file types (separated by space) |
94 | @param exclude pattern for excluded file types (separated by space) - use either this or filter |
95 | @param verbose dump collected files |
96 | @return False in case of errore |
97 | */ |
98 | bool generateFileList(QList<InstallFile> &result, const QString &root, const QString &subdir, const QString &filter, const QString &exclude = QString(), bool verbose=false); |
99 | |
100 | // try to delete a file, if not possible, move to root/tmp/deleteme |
101 | bool deleteFile(const QString &root, const QString &fn); |
102 | |
103 | /// return windows start menu path |
104 | QString (bool bAllUsers); |
105 | |
106 | /// return int value of version string 'a.b.c' as 0x00aabbcc, 'a.b' as 0x00aabb00, 'a' as 0x00aa0000 |
107 | int toVersionInt(const QString &version); |
108 | |
109 | /// return path of executable |
110 | QString exePath(); |
111 | |
112 | /// wait |
113 | void qsleep(int ms); |
114 | |
115 | /// remove a non empty directory structure |
116 | bool removeDirectory(const QString& aDir); |
117 | |
118 | /// check if system is 64 bit Windows |
119 | bool isX64Windows(); |
120 | |
121 | #endif |
122 | |