summaryrefslogtreecommitdiff
path: root/src/findsubtitles
diff options
context:
space:
mode:
authorMateusz Łukasik <mati75@linuxmint.pl>2014-04-21 11:53:35 +0200
committerMateusz Łukasik <mati75@linuxmint.pl>2014-04-21 11:53:35 +0200
commit2a117cc570574099839da41a5ae9fbb2a5ca9e55 (patch)
tree6107da409f9c7f07c0ffa0869a26a161b097aea7 /src/findsubtitles
parentaa68b7bd585a157e8952881e87e2c09de6ec742f (diff)
Imported Upstream version 14.3.0
Diffstat (limited to 'src/findsubtitles')
-rw-r--r--src/findsubtitles/filedownloader/filedownloader.cpp109
-rw-r--r--src/findsubtitles/filedownloader/filedownloader.h32
-rw-r--r--src/findsubtitles/filedownloader/main.cpp2
-rw-r--r--src/findsubtitles/findsubtitles.pro25
-rw-r--r--src/findsubtitles/findsubtitlesconfigdialog.cpp6
-rw-r--r--src/findsubtitles/findsubtitlesconfigdialog.h2
-rw-r--r--src/findsubtitles/findsubtitlesconfigdialog.ui2
-rw-r--r--src/findsubtitles/findsubtitleswindow.cpp3
-rw-r--r--src/findsubtitles/findsubtitleswindow.h2
-rw-r--r--src/findsubtitles/fixsubs.cpp2
-rw-r--r--src/findsubtitles/fixsubs.h2
-rw-r--r--src/findsubtitles/main.cpp2
-rw-r--r--src/findsubtitles/osclient.cpp11
-rw-r--r--src/findsubtitles/osclient.h2
-rw-r--r--src/findsubtitles/osparser.cpp2
-rw-r--r--src/findsubtitles/osparser.h2
-rw-r--r--src/findsubtitles/subchooserdialog.cpp2
-rw-r--r--src/findsubtitles/subchooserdialog.h2
18 files changed, 109 insertions, 101 deletions
diff --git a/src/findsubtitles/filedownloader/filedownloader.cpp b/src/findsubtitles/filedownloader/filedownloader.cpp
index af4eb62..d7a64e3 100644
--- a/src/findsubtitles/filedownloader/filedownloader.cpp
+++ b/src/findsubtitles/filedownloader/filedownloader.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,96 +16,103 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* Based on the Qt network/http example */
-
#include "filedownloader.h"
-#include <QHttp>
-#include <QTimer>
+#include <QFile>
+#include <QMessageBox>
FileDownloader::FileDownloader(QWidget *parent) : QProgressDialog(parent)
{
- http_get_id = -1;
- setMinimumDuration(0);
+ reply = 0;
+ manager = new QNetworkAccessManager(this);
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(gotResponse(QNetworkReply*)));
- http = new QHttp(this);
+ setMinimumDuration(0);
+ setRange(0,0);
- connect(http, SIGNAL(requestFinished(int, bool)),
- this, SLOT(httpRequestFinished(int, bool)));
- connect(http, SIGNAL(dataReadProgress(int, int)),
- this, SLOT(updateDataReadProgress(int, int)));
- connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
- this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(this, SIGNAL(canceled()), this, SLOT(cancelDownload()));
+ /*
+ connect(this, SIGNAL(fileSaved(const QString &, const QString &)), this, SLOT(reportFileSaved(const QString &,const QString &)));
+ connect(this, SIGNAL(saveFailed(const QString &)), this, SLOT(reportSaveFailed(const QString &)));
+ connect(this, SIGNAL(errorOcurred(int,QString)), this, SLOT(reportError(int,QString)));
+ */
setWindowTitle(tr("Downloading..."));
}
FileDownloader::~FileDownloader() {
- //qDebug("FileDownloader::~FileDownloader");
- delete http;
+ delete manager;
}
void FileDownloader::setProxy(QNetworkProxy proxy) {
- http->abort();
- http->setProxy(proxy);
+ manager->setProxy(proxy);
qDebug("FileDownloader::setProxy: host: '%s' port: %d type: %d",
proxy.hostName().toUtf8().constData(), proxy.port(), proxy.type());
}
void FileDownloader::download(QUrl url) {
- QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
- http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
-
- if (!url.userName().isEmpty())
- http->setUser(url.userName(), url.password());
-
- http_request_aborted = false;
- http_get_id = http->get(url.path());
+ QNetworkRequest req(url);
+ req.setRawHeader("User-Agent", "SMPlayer");
+ reply = manager->get(req);
+ connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
+ this, SLOT(updateDataReadProgress(qint64, qint64)));
- setLabelText(tr("Downloading %1").arg(url.toString()));
+ setLabelText(tr("Connecting to %1").arg(url.host()));
}
void FileDownloader::cancelDownload() {
- http_request_aborted = true;
- http->abort();
+ if (reply) reply->abort();
}
-void FileDownloader::httpRequestFinished(int request_id, bool error) {
- qDebug("FileDownloader::httpRequestFinished: request_id %d, error %d", request_id, error);
-
- if (request_id != http_get_id) return;
-
- if (http_request_aborted) {
+void FileDownloader::gotResponse(QNetworkReply* reply) {
+ if (reply->error() == QNetworkReply::NoError) {
+ int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ qDebug("FileDownloader::gotResponse: status: %d", status);
+ switch (status) {
+ case 301:
+ case 302:
+ case 307:
+ QString r_url = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl().toString();
+ qDebug("FileDownloader::gotResponse: redirected: %s", r_url.toLatin1().constData());
+ download(r_url);
+ return;
+ }
+ } else {
hide();
+ emit downloadFailed(reply->errorString());
return;
}
hide();
+ emit downloadFinished(reply->readAll());
+}
- if (error) {
- emit downloadFailed(http->errorString());
- } else {
- emit downloadFinished(http->readAll());
+void FileDownloader::updateDataReadProgress(qint64 bytes_read, qint64 total_bytes) {
+ qDebug() << "FileDownloader::updateDataReadProgress: " << bytes_read << " " << total_bytes;
+ if (total_bytes > -1) {
+ setMaximum(total_bytes);
+ setValue(bytes_read);
}
}
-void FileDownloader::readResponseHeader(const QHttpResponseHeader &responseHeader) {
- if (responseHeader.statusCode() != 200) {
- emit downloadFailed(responseHeader.reasonPhrase());
- http_request_aborted = true;
- hide();
- http->abort();
- return;
- }
+/*
+void FileDownloader::reportFileSaved(const QString &, const QString & version) {
+ hide();
+ QString t = tr("The Youtube code has been updated successfully.");
+ if (!version.isEmpty()) t += "<br>"+ tr("Installed version: %1").arg(version);
+ QMessageBox::information(this, tr("Success"),t);
}
-void FileDownloader::updateDataReadProgress(int bytes_read, int total_bytes) {
- if (http_request_aborted) return;
+void FileDownloader::reportSaveFailed(const QString & file) {
+ hide();
+ QMessageBox::warning(this, tr("Error"), tr("An error happened writing %1").arg(file));
+}
- setMaximum(total_bytes);
- setValue(bytes_read);
+void FileDownloader::reportError(int, QString error_str) {
+ hide();
+ QMessageBox::warning(this, tr("Error"), tr("An error happened while downloading the file:<br>%1").arg(error_str));
}
+*/
#include "moc_filedownloader.cpp"
diff --git a/src/findsubtitles/filedownloader/filedownloader.h b/src/findsubtitles/filedownloader/filedownloader.h
index 1baadef..367eb99 100644
--- a/src/findsubtitles/filedownloader/filedownloader.h
+++ b/src/findsubtitles/filedownloader/filedownloader.h
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,21 +16,18 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* Based on the Qt network/http example */
-
-#ifndef _FILEDOWNLOADER_H_
-#define _FILEDOWNLOADER_H_
+#ifndef FILEDOWNLOADER_H
+#define FILEDOWNLOADER_H
#include <QProgressDialog>
#include <QUrl>
#include <QNetworkProxy>
-
-class QHttp;
-class QHttpResponseHeader;
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
class FileDownloader : public QProgressDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
FileDownloader(QWidget *parent = 0);
@@ -47,15 +44,18 @@ signals:
void downloadFailed(const QString & reason);
private slots:
- void httpRequestFinished(int request_id, bool error);
- void readResponseHeader(const QHttpResponseHeader &responseHeader);
- void updateDataReadProgress(int bytes_read, int total_bytes);
+ void gotResponse(QNetworkReply* reply);
+ void updateDataReadProgress(qint64 bytes_read, qint64 total_bytes);
-private:
- QHttp * http;
- int http_get_id;
- bool http_request_aborted;
+ /*
+ void reportFileSaved(const QString &, const QString &);
+ void reportSaveFailed(const QString &);
+ void reportError(int error_number, QString error_str);
+ */
+private:
+ QNetworkAccessManager* manager;
+ QNetworkReply* reply;
};
#endif
diff --git a/src/findsubtitles/filedownloader/main.cpp b/src/findsubtitles/filedownloader/main.cpp
index 30b9311..cf5a472 100644
--- a/src/findsubtitles/filedownloader/main.cpp
+++ b/src/findsubtitles/filedownloader/main.cpp
@@ -50,6 +50,6 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
FileDownloader w;
w.show();
- w.download(QUrl("http://smplayer.berlios.de/downloads.php?tr_lang=es"));
+ w.download(QUrl("http://smplayer.sf.net/downloads.php"));
return w.exec();
}
diff --git a/src/findsubtitles/findsubtitles.pro b/src/findsubtitles/findsubtitles.pro
index cec1418..43279f5 100644
--- a/src/findsubtitles/findsubtitles.pro
+++ b/src/findsubtitles/findsubtitles.pro
@@ -7,11 +7,12 @@ CONFIG += debug
QT += network xml
-INCLUDEPATH += ..
-DEPENDPATH += ..
+INCLUDEPATH += .. maia
-INCLUDEPATH += maia
-DEPENDPATH += maia
+isEqual(QT_MAJOR_VERSION, 5) {
+ QT += widgets gui
+ #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x040000
+}
HEADERS += ../filehash.h \
../lineedit_with_icon.h \
@@ -32,20 +33,20 @@ SOURCES += ../filehash.cpp \
findsubtitleswindow.cpp \
main.cpp
-HEADERS += maiaObject.h maiaFault.h maiaXmlRpcClient.h osclient.h
-SOURCES += maiaObject.cpp maiaFault.cpp maiaXmlRpcClient.cpp osclient.cpp
+HEADERS += maia/maiaObject.h maia/maiaFault.h maia/maiaXmlRpcClient.h osclient.h
+SOURCES += maia/maiaObject.cpp maia/maiaFault.cpp maia/maiaXmlRpcClient.cpp osclient.cpp
FORMS += findsubtitleswindow.ui findsubtitlesconfigdialog.ui
-DEFINES += NO_SMPLAYER_SUPPORT DOWNLOAD_SUBS
+DEFINES += NO_SMPLAYER_SUPPORT
+DEFINES += DOWNLOAD_SUBS
#DEFINES += USE_QUAZIP
contains( DEFINES, DOWNLOAD_SUBS ) {
INCLUDEPATH += filedownloader
- DEPENDPATH += filedownloader
- HEADERS += filedownloader.h subchooserdialog.h
- SOURCES += filedownloader.cpp subchooserdialog.cpp
+ HEADERS += filedownloader/filedownloader.h subchooserdialog.h
+ SOURCES += filedownloader/filedownloader.cpp subchooserdialog.cpp
FORMS += subchooserdialog.ui
@@ -73,8 +74,8 @@ contains( DEFINES, DOWNLOAD_SUBS ) {
LIBS += -lz
win32 {
- INCLUDEPATH += c:\development\zlib-1.2.3
- LIBS += -Lc:\development\zlib-1.2.3
+ INCLUDEPATH += ..\\..\\zlib
+ LIBS += -L..\\..\\zlib
}
}
diff --git a/src/findsubtitles/findsubtitlesconfigdialog.cpp b/src/findsubtitles/findsubtitlesconfigdialog.cpp
index 1f289d4..bfbafc9 100644
--- a/src/findsubtitles/findsubtitlesconfigdialog.cpp
+++ b/src/findsubtitles/findsubtitlesconfigdialog.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,8 +24,8 @@ FindSubtitlesConfigDialog::FindSubtitlesConfigDialog( QWidget* parent, Qt::Windo
{
setupUi(this);
- proxy_type_combo->addItem( tr("Http"), QNetworkProxy::HttpProxy);
- proxy_type_combo->addItem( tr("Socks5"), QNetworkProxy::Socks5Proxy);
+ proxy_type_combo->addItem( tr("HTTP"), QNetworkProxy::HttpProxy);
+ proxy_type_combo->addItem( tr("SOCKS5"), QNetworkProxy::Socks5Proxy);
use_proxy_check->setWhatsThis( tr("Enable/disable the use of the proxy.") );
proxy_hostname_edit->setWhatsThis( tr("The host name of the proxy.") );
diff --git a/src/findsubtitles/findsubtitlesconfigdialog.h b/src/findsubtitles/findsubtitlesconfigdialog.h
index 5449aeb..82c29ce 100644
--- a/src/findsubtitles/findsubtitlesconfigdialog.h
+++ b/src/findsubtitles/findsubtitlesconfigdialog.h
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/findsubtitlesconfigdialog.ui b/src/findsubtitles/findsubtitlesconfigdialog.ui
index 4420b5f..cf27e15 100644
--- a/src/findsubtitles/findsubtitlesconfigdialog.ui
+++ b/src/findsubtitles/findsubtitlesconfigdialog.ui
@@ -23,7 +23,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
- <string>&amp;Opensubtitles server:</string>
+ <string>&amp;OpenSubtitles server:</string>
</property>
<property name="buddy">
<cstring>server_edit</cstring>
diff --git a/src/findsubtitles/findsubtitleswindow.cpp b/src/findsubtitles/findsubtitleswindow.cpp
index 309bbed..7381fdf 100644
--- a/src/findsubtitles/findsubtitleswindow.cpp
+++ b/src/findsubtitles/findsubtitleswindow.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -516,6 +516,7 @@ void FindSubtitlesWindow::archiveDownloaded(const QByteArray & buffer) {
"file in folder %1\n"
"Please check the permissions of that folder.").arg(fi.absolutePath()));
} else {
+ status->setText(tr("Subtitle saved as %1").arg(output_file));
emit subtitleDownloaded( output_file );
}
}
diff --git a/src/findsubtitles/findsubtitleswindow.h b/src/findsubtitles/findsubtitleswindow.h
index 58b5d63..096e744 100644
--- a/src/findsubtitles/findsubtitleswindow.h
+++ b/src/findsubtitles/findsubtitleswindow.h
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/fixsubs.cpp b/src/findsubtitles/fixsubs.cpp
index 881db2a..7b3b049 100644
--- a/src/findsubtitles/fixsubs.cpp
+++ b/src/findsubtitles/fixsubs.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/fixsubs.h b/src/findsubtitles/fixsubs.h
index b04341d..ac80ec0 100644
--- a/src/findsubtitles/fixsubs.h
+++ b/src/findsubtitles/fixsubs.h
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/main.cpp b/src/findsubtitles/main.cpp
index 90c6a94..9a51115 100644
--- a/src/findsubtitles/main.cpp
+++ b/src/findsubtitles/main.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/osclient.cpp b/src/findsubtitles/osclient.cpp
index dddab36..22d98a7 100644
--- a/src/findsubtitles/osclient.cpp
+++ b/src/findsubtitles/osclient.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -47,11 +47,7 @@ void OSClient::login() {
}
void OSClient::search(const QString & hash, qint64 file_size) {
-#ifdef Q_OS_WIN
- qDebug("OSClient::search: hash: %s, file_size: %I64d", hash.toUtf8().constData(), file_size);
-#else
- qDebug("OSClient::search: hash: %s, file_size: %lld", hash.toUtf8().constData(), file_size);
-#endif
+ qDebug() << "OSClient::search: hash: " << hash << "file_size: " << file_size;
search_hash = hash;
search_size = file_size;
@@ -88,6 +84,9 @@ void OSClient::doSearch() {
list.append(m);
list.append(m);
list.append(m);
+ list.append(m);
+ //list.append(m);
+ list.append(m); // Adding more, sometimes it keeps failing...
QVariantList args;
args << token << QVariant(list);
diff --git a/src/findsubtitles/osclient.h b/src/findsubtitles/osclient.h
index b0fe67b..145bdc4 100644
--- a/src/findsubtitles/osclient.h
+++ b/src/findsubtitles/osclient.h
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/osparser.cpp b/src/findsubtitles/osparser.cpp
index 2ea0d7b..aa9887c 100644
--- a/src/findsubtitles/osparser.cpp
+++ b/src/findsubtitles/osparser.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/osparser.h b/src/findsubtitles/osparser.h
index 0016595..aac82d3 100644
--- a/src/findsubtitles/osparser.h
+++ b/src/findsubtitles/osparser.h
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/subchooserdialog.cpp b/src/findsubtitles/subchooserdialog.cpp
index 23f1d8f..813d0bb 100644
--- a/src/findsubtitles/subchooserdialog.cpp
+++ b/src/findsubtitles/subchooserdialog.cpp
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/src/findsubtitles/subchooserdialog.h b/src/findsubtitles/subchooserdialog.h
index 1884848..8c46d16 100644
--- a/src/findsubtitles/subchooserdialog.h
+++ b/src/findsubtitles/subchooserdialog.h
@@ -1,5 +1,5 @@
/* smplayer, GUI front-end for mplayer.
- Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
+ Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by