}
void XdxfDictDownloader::downloadComplete() {
+ // Downloaded tar file name is different than extracted folder so we need
+ // some clean directory to identify extracted files
QDir dir("/tmp/mdict");
QString dictDirName = dir.entryList().at(2);
+
+ // Dict is in /tmp/mdict/<extracted directory>/dict.xdxf
QFile dictFile("/tmp/mdict/" + dictDirName + "/dict.xdxf");
dictFile.copy(QDir::homePath() + "/.mdictionary/" + dictDirName + ".xdxf");
QFile::remove("/tmp/" + _fileName);
progressDialog->accept();
delete progressDialog;
QString page(QString::fromUtf8(reply->readAll()));
+
+ // You can look at http://xdxf.revdanica.com/down/, we need to get table
+ // with dictionaries entries following regexp match its begining
QRegExp regOuter("<td>Icon</td><td>Name</td><td>Archive filename</td><td>Archive file size</td><td>Dict file size</td><td>Number of articles</td><td>From</td><td>To</td><td>Submitted by</td><td>Submition date</td></tr>(.*)</table>");
regOuter.setMinimal(true);
if(!regOuter.indexIn(page))
return;
+ // Cutting each entry and creating coresponded DownloadDict object
page = regOuter.capturedTexts().at(1);
QRegExp regInner("<tr>.*</tr>");
regInner.setMinimal(true);
_fileName = url.split('/').last();
+ // Now its the tricky part ... its temporary (probably)
+ // We dont have any tar-dev and bz2-dev packages on maemo so we need
+ // to call commands via shell, each command from list is called after
+ // previous call returns 0
+
commands.clear();
commands.push_back("rm -rf /tmp/mdict");
commands.push_back("mkdir /tmp/mdict");
+
+ // Downloading xdxf dict from sourceforge is kind of complicated,
+ // there is a lot of redirection and QNetwork* is kind of lost, we
+ // tried to follow redirection (by hand) but we end up with some
+ // page and js scripts and thats all
+ // Maybe calling wget is not pretty one but its working!
commands.push_back("wget --quiet -P /tmp/ " + url);
commands.push_back(QString("tar -xjvf /tmp/") + _fileName + QString(" -C /tmp/mdict"));