Commit 5f1fb224 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

only attach image files, close progress dialog also if download fits into one received packet

parent 3b0cda71
......@@ -91,7 +91,9 @@ void DownloadDialog::startDownload(const QString& hostName, const QString& path)
m_url += hostName;
m_url += path;
setLabelText(m_url);
updateProgressStatus(i18n("Ready."), 0, 0);
updateProgressStatus(i18n("Ready."),
HttpClient::CS_RequestConnection,
HttpClient::CS_EstimatedBytes);
m_client->sendRequest(hostName, path);
}
}
......
......@@ -68,7 +68,19 @@ HttpClient::~HttpClient()
}
/**
* Emit a progress signal.
* Emit a progress signal with step/total steps.
*
* @param text state text
* @param step current step
* @param totalSteps total number of steps
*/
void HttpClient::emitProgress(const QString& text, int step, int totalSteps)
{
emit progress(text, step, totalSteps);
}
/**
* Emit a progress signal with bytes received/total bytes.
*
* @param text state text
*/
......@@ -124,7 +136,7 @@ void HttpClient::splitNamePort(const QString& namePort,
*/
void HttpClient::slotHostFound()
{
emitProgress(i18n("Host found..."));
emitProgress(i18n("Host found..."), CS_HostFound, CS_EstimatedBytes);
}
/**
......@@ -133,7 +145,7 @@ void HttpClient::slotHostFound()
void HttpClient::slotConnected()
{
m_sock->QCM_writeBlock(m_request.QCM_latin1(), m_request.length());
emitProgress(i18n("Request sent..."));
emitProgress(i18n("Request sent..."), CS_RequestSent, CS_EstimatedBytes);
}
/**
......@@ -308,5 +320,5 @@ void HttpClient::sendRequest(const QString& server, const QString& path)
m_rcvBodyType = "";
m_sock->connectToHost(dest, destPort);
emitProgress(i18n("Connecting..."));
emitProgress(i18n("Connecting..."), CS_Connecting, CS_EstimatedBytes);
}
......@@ -47,6 +47,15 @@ class HttpClient : public QObject
Q_OBJECT
public:
/** Connection progress steps. */
enum ConnectionSteps {
CS_RequestConnection = 0, /**< Send Request */
CS_Connecting = 1, /**< Connecting */
CS_HostFound = 2, /**< Host Found */
CS_RequestSent = 3, /**< Request Sent */
CS_EstimatedBytes = 75000 /**< Estimated total number of bytes */
};
/**
* Constructor.
*/
......@@ -133,7 +142,16 @@ private slots:
private:
/**
* Emit a progress signal.
* Emit a progress signal with step/total steps.
*
* @param text state text
* @param step current step
* @param totalSteps total number of steps
*/
void emitProgress(const QString& text, int step, int totalSteps);
/**
* Emit a progress signal with bytes received/total bytes.
*
* @param text state text
*/
......
......@@ -2817,20 +2817,22 @@ void Kid3App::dropUrl(const QString& txt)
void Kid3App::imageDownloaded(const QByteArray& data,
const QString& mimeType, const QString& url)
{
PictureFrame frame(data, url, PictureFrame::PT_CoverFront, mimeType);
if (m_downloadToAllFilesInDir) {
FileListItem* mp3file = m_view->firstFileInDir();
while (mp3file != 0) {
TaggedFile* taggedFile = mp3file->getFile();
taggedFile->readTags(false);
taggedFile->addFrameV2(frame);
mp3file = m_view->nextFileInDir();
if (mimeType.startsWith("image")) {
PictureFrame frame(data, url, PictureFrame::PT_CoverFront, mimeType);
if (m_downloadToAllFilesInDir) {
FileListItem* mp3file = m_view->firstFileInDir();
while (mp3file != 0) {
TaggedFile* taggedFile = mp3file->getFile();
taggedFile->readTags(false);
taggedFile->addFrameV2(frame);
mp3file = m_view->nextFileInDir();
}
m_downloadToAllFilesInDir = false;
} else {
addFrame(&frame);
}
m_downloadToAllFilesInDir = false;
} else {
addFrame(&frame);
updateGuiControls();
}
updateGuiControls();
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment