1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2008 Christian Ehrlicher <ch.ehrlicher@gmx.de> |
4 | ** All rights reserved. |
5 | ** |
6 | ** This file is part of the KDE installer for windows |
7 | ** |
8 | ** This library is free software; you can redistribute it and/or |
9 | ** modify it under the terms of the GNU Library General Public |
10 | ** License version 2 as published by the Free Software Foundation. |
11 | ** |
12 | ** This library is distributed in the hope that it will be useful, |
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | ** Library General Public License for more details. |
16 | ** |
17 | ** You should have received a copy of the GNU Library General Public License |
18 | ** along with this library; see the file COPYING.LIB. If not, write to |
19 | ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | ** Boston, MA 02110-1301, USA. |
21 | ** |
22 | ****************************************************************************/ |
23 | |
24 | #ifndef UNPACKER_H |
25 | #define UNPACKER_H |
26 | |
27 | #include "installerprogress.h" |
28 | #include "package.h" // StringHash |
29 | |
30 | #include <QObject> |
31 | |
32 | class QEventLoop; |
33 | class UPThread; |
34 | |
35 | /** |
36 | \brief The class Unpacker provides unpackaging of downloaded package files |
37 | |
38 | |
39 | */ |
40 | class Unpacker : public QObject |
41 | { |
42 | Q_OBJECT |
43 | public: |
44 | /// dtor |
45 | virtual ~Unpacker(); |
46 | |
47 | /// singleton |
48 | static Unpacker *instance(); |
49 | |
50 | /// for user interaction |
51 | void setProgress ( InstallerProgress *progress ); |
52 | |
53 | /// returns currently used Installer process instance |
54 | InstallerProgress *progress(); |
55 | |
56 | /// unpack file |
57 | bool unpackFile ( const QString &fn, const QString &destpath, const StringHash &pathRelocations=StringHash() ); |
58 | |
59 | /// cancel file unpack |
60 | void cancel(); |
61 | |
62 | /// get unpacked files |
63 | QStringList unpackedFiles() const; |
64 | |
65 | /// get last error string |
66 | QString lastError() const; |
67 | Q_SIGNALS: |
68 | void done ( bool bOk ); |
69 | void error ( const QString &error ); |
70 | protected Q_SLOTS: |
71 | void setError ( const QString &error ); |
72 | void threadFinished (); |
73 | void progressCallback ( const QString &s ); |
74 | protected: |
75 | InstallerProgress *m_progress; |
76 | UPThread *m_thread; |
77 | bool m_bRet; |
78 | bool m_bFinished; |
79 | QEventLoop *m_loop; |
80 | QString m_lastError; |
81 | private: |
82 | Unpacker (); |
83 | |
84 | friend class UnpackerSingleton; |
85 | }; |
86 | |
87 | #endif // UNPACKER_H |
88 | |