some change
[mdictionary] / src / plugins / xdxf / XdxfDictDownloader.cpp
index 1542e32..96415d9 100644 (file)
@@ -20,6 +20,9 @@
 *******************************************************************************/
 /*!
     \file XdxfDictDownloader.cpp
+    \brief XdxfDictDownloader is responsible for getting dict list from XDXF website
+    and other actions necessary to download and add dictionary
+
     \author Mateusz Półrola <mateusz.polrola@comarch.com>
 */
 
 #include <QDebug>
 #include <QProcess>
 #include <bzlib.h>
-#include <libtar.h>
 #include <stdio.h>
 #include <fcntl.h>
 
+#ifndef Q_WS_MAEMO_5
+    #include <libtar.h>
+#endif
+
+
 typedef void BZFILE;
 
+
 XdxfDictDownloader::XdxfDictDownloader(QObject *parent) :
     QObject(parent) {
     parentDialog = 0;
@@ -64,6 +72,7 @@ void XdxfDictDownloader::download(QWidget *parent) {
     connect(this, SIGNAL(downloadProgress(float)),
             progressDialog, SLOT(updateProgress(float)));
 
+    qDebug()<<"etam 3.1";
     progressDialog->setText(tr("Downloading dictionaries list"));
     progressDialog->show();
 }
@@ -90,7 +99,7 @@ void XdxfDictDownloader::breakDownloading() {
     //if user cancel downloading we kill all running processes, hide progress dialog and set flag that user cancel downloading.
     aborted = true;
     http.kill();
-
+    qDebug()<<"end download";
     if(progressDialog && progressDialog->isVisible()) {
         progressDialog->accept();
     }
@@ -156,7 +165,7 @@ void XdxfDictDownloader::dictListReceived(QNetworkReply *reply) {
     QRegExp regInner("<tr>.*</tr>");
     regInner.setMinimal(true);
     int pos = 0;
-
+    dicts.clear();
     while ((pos = regInner.indexIn(page, pos)) != -1) {
         DownloadDict temp = DownloadDict(regInner.cap(0));
         if(!temp.fromLang().isEmpty())
@@ -167,12 +176,11 @@ void XdxfDictDownloader::dictListReceived(QNetworkReply *reply) {
     XdxfDictSelectDialog selectDialog(dicts, parentDialog);
 
     if(selectDialog.exec()==QDialog::Accepted) {
-
+        qDebug()<<"etap 3.2";
         progressDialog->setText(tr("Downloading dictionary"));
         progressDialog->show();
 
         QString url = selectDialog.link();
-
         _fileName = url.split('/').last();
 
         QProcess clean;
@@ -203,7 +211,7 @@ bool XdxfDictDownloader::extract(QString file) {
     int bufflen = 100;
     char buff[bufflen];
     while(err == BZ_OK) {
-        int len = BZ2_bzRead(&err, afterbzFile, buff, bufflen);
+        unsigned int len = BZ2_bzRead(&err, afterbzFile, buff, bufflen);
         if(fwrite(buff, 1, len, tarfile) != len)
             return false;
     }
@@ -221,7 +229,8 @@ bool XdxfDictDownloader::extract(QString file) {
     if(err == -1)
         return false;
 
-    err = tar_extract_all(t, "/tmp/mdict/");
+    char text[]={"/tmp/mdict/"};
+    err = tar_extract_all(t,text);
     if(err == -1) {
         return false;
     }
@@ -236,3 +245,4 @@ bool XdxfDictDownloader::extract(QString file) {
 }
 
 
+