#include "XdxfDictDownloader.h"
#include "XdxfDictDownloadProgressDialog.h"
#include <QDebug>
+#include <QProcess>
+
#include <bzlib.h>
+#ifndef Q_WS_MAEMO_5
#include <libtar.h>
+#endif
#include <stdio.h>
#include <fcntl.h>
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) {
connect(progressDialog, SIGNAL(cancelDownloading()),
this, SLOT(breakDownloading()));
+ connect(this, SIGNAL(downloadProgress(float)),
+ progressDialog, SLOT(updateProgress(float)));
+
progressDialog->setText(tr("Downloading dictionaries list"));
progressDialog->show();
}
return _downloadedFile;
}
+void XdxfDictDownloader::updateDownloadProgress(qint64 downloaded,
+ qint64 total) {
+ Q_EMIT downloadProgress(float(downloaded) / float(total));
+}
void XdxfDictDownloader::downloadingError(QString error) {
breakDownloading();
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;
}