1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 \file XdxfDictDownloader.h
23 \author Mateusz Półrola <mateusz.polrola@comarch.pl>
26 #ifndef XDXFDICTDOWNLOADER_H
27 #define XDXFDICTDOWNLOADER_H
30 #include "XdxfDictSelectDialog.h"
32 #include <QNetworkAccessManager>
33 #include <QNetworkReply>
34 #include <DownloadDict.h>
35 #include "XdxfDictDownloadProgressDialog.h"
36 #include "../../include/Notify.h"
37 #include "HttpDownloader.h"
42 XdxfDictDownloader is responsible for getting dict list from XDXF website
43 and other actions necessary to download and add dictionary
45 When user want to add dictionary he may choose "browse" or "download",
46 after selecting "download" XDXFDictDownloader would present him list of
47 dictionaries and when he select one downloading would be started. Next
48 step is to extract archive and move file to ~/.mdictionary
50 class XdxfDictDownloader : public QObject {
53 XdxfDictDownloader(QObject *parent = 0);
55 //! \return name of downloaded file
56 QString downloadedFile();
59 //! downloads dictionaries list from xdxf website
60 void download(QWidget* parent);
63 //! emmited when file download precess is complete
64 void fileDownloaded(QString);
66 //! emitted to inform user about errors and warnings
67 void notify(Notify::NotifyType, QString);
69 //! emmited what is update Download Progress
70 void downloadProgress(float);
73 //! obtained list of dictionaries from website
74 void dictListReceived(QNetworkReply*);
76 //! one of system processes finished
77 void processFinished();
79 //! user cancel downloading
80 void breakDownloading();
82 //! handling a download error
83 void downloadingError(QString);
86 function divide two qint64 and result emmit in
87 signals downloadProgress(float)
89 void updateDownloadProgress(qint64, qint64);
92 //! dict is downloaded and unpacked
93 void downloadComplete();
95 QList<DownloadDict> dicts;
96 QWidget* parentDialog;
97 QString _downloadedFile;
98 XdxfDictDownloadProgressDialog* progressDialog;
105 QNetworkAccessManager *manager;
106 bool extract(QString file);
110 #endif // XDXFDICTDOWNLOADER_H