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
33class QFile;
34class QIODevice;
35class QTextStream;
36
37
38typedef enum { RTUnspecified=0, Stable, Unstable, Nightly } ReleaseType;
39ReleaseType toReleaseType(const QString &type);
40const QString toString(ReleaseType type);
41
42struct 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
62bool parseQtIncludeFiles(QList<InstallFile> &fileList, const QString &root, const QString &subdir, const QString &filter, const QString &exclude);
63
64typedef struct {
65 QString shortDesc;
66 QString longDesc;
67 QString categories;
68 QString requires;
69} HintFileDescriptor;
70
71bool parseHintFile(const QString &hintFile,HintFileDescriptor &pkg);
72bool parseHintFile(const QByteArray &ba, HintFileDescriptor &pkg);
73
74bool 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*/
98bool 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
101bool deleteFile(const QString &root, const QString &fn);
102
103/// return windows start menu path
104QString getStartMenuPath(bool bAllUsers);
105
106/// return int value of version string 'a.b.c' as 0x00aabbcc, 'a.b' as 0x00aabb00, 'a' as 0x00aa0000
107int toVersionInt(const QString &version);
108
109/// return path of executable
110QString exePath();
111
112/// wait
113void qsleep(int ms);
114
115/// remove a non empty directory structure
116bool removeDirectory(const QString& aDir);
117
118/// check if system is 64 bit Windows
119bool isX64Windows();
120
121#endif
122