Merge branch 'http' into stardict
authorMarcin Kazmierczak <marcin.kazmierczak@comarch.pl>
Tue, 5 Oct 2010 12:10:49 +0000 (14:10 +0200)
committerMarcin Kazmierczak <marcin.kazmierczak@comarch.pl>
Tue, 5 Oct 2010 12:10:49 +0000 (14:10 +0200)
1  2 
src/plugins/xdxf/XdxfDictDownloader.cpp

@@@ -27,6 -27,8 +27,8 @@@
  #include "XdxfDictDownloader.h"
  #include "XdxfDictDownloadProgressDialog.h"
  #include <QDebug>
+ #include <QProcess>
  
  #include <bzlib.h>
  #include <libtar.h>
@@@ -50,9 -52,6 +52,9 @@@ XdxfDictDownloader::XdxfDictDownloader(
      connect(&http, SIGNAL(finished()), this, SLOT(processFinished()));
      connect(&http, SIGNAL(error(QString)),
              this, SLOT(downloadingError(QString)));
 +    connect(&http, SIGNAL(progress(qint64,qint64)),
 +            this, SLOT(updateDownloadProgress(qint64,qint64)));
 +
  }
  
  void XdxfDictDownloader::download(QWidget *parent) {
@@@ -65,9 -64,6 +67,9 @@@
  
      connect(progressDialog, SIGNAL(cancelDownloading()),
              this, SLOT(breakDownloading()));
 +    connect(this, SIGNAL(downloadProgress(float)),
 +            progressDialog, SLOT(updateProgress(float)));
 +
      progressDialog->setText(tr("Downloading dictionaries list"));
      progressDialog->show();
  }
@@@ -76,10 -72,6 +78,10 @@@ QString XdxfDictDownloader::downloadedF
      return _downloadedFile;
  }
  
 +void XdxfDictDownloader::updateDownloadProgress(qint64 downloaded,
 +                                                qint64 total)   {
 +    Q_EMIT downloadProgress(float(downloaded) / float(total));
 +}
  
  void XdxfDictDownloader::downloadingError(QString error) {
      breakDownloading();
@@@ -211,6 -203,7 +213,7 @@@ bool XdxfDictDownloader::extract(QStrin
      fclose(archive);
  
      // Extracting tar
+     #ifndef Q_WS_MAEMO_5
      TAR *t;
      char * tarfname = new char[file.replace(QRegExp(".bz2%"), "").size()+1];
      strcpy(tarfname, file.replace(QRegExp(".bz2%"), "").toStdString().c_str());
          return false;
      }
      tar_close(t);
+     #else
+     QProcess tar;
+     tar.start("tar -xvf " + file.replace(QRegExp(".bz2%"), "") + " -C /tmp/mdict");
+     tar.waitForFinished(-1);
+     #endif
  
      return true;
  }