More error messages
This commit is contained in:
committed by
craig.p.drummond
parent
3fdc2cd245
commit
a1ecc70dd8
@@ -266,8 +266,7 @@ void ActionDialog::slotButtonClicked(int button)
|
||||
case PAGE_PROGRESS:
|
||||
paused=true;
|
||||
if (MessageBox::Yes==MessageBox::questionYesNo(this, i18n("Are you sure you wish to cancel?"))) {
|
||||
refreshLibrary();
|
||||
reject();
|
||||
cancel();
|
||||
// Need to call this - if not, when dialog is closed by window X control, it is not deleted!!!!
|
||||
Dialog::slotButtonClicked(button);
|
||||
} else if (!performingAction && PAGE_PROGRESS==stack->currentIndex()) {
|
||||
@@ -278,12 +277,17 @@ void ActionDialog::slotButtonClicked(int button)
|
||||
}
|
||||
}
|
||||
|
||||
Device * ActionDialog::getDevice(const QString &udi)
|
||||
Device * ActionDialog::getDevice(const QString &udi, bool logErrors)
|
||||
{
|
||||
if (udi.startsWith(OnlineServicesModel::constUdiPrefix)) {
|
||||
return OnlineServicesModel::self()->device(udi);
|
||||
}
|
||||
Device *dev=DevicesModel::self()->device(udi);
|
||||
|
||||
if (!logErrors) {
|
||||
return dev;
|
||||
}
|
||||
|
||||
QString error;
|
||||
if (!dev) {
|
||||
error=i18n("Device has been removed!");
|
||||
@@ -308,6 +312,23 @@ Device * ActionDialog::getDevice(const QString &udi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ActionDialog::cancel()
|
||||
{
|
||||
Device *dev=0;
|
||||
if(Copy==mode) {
|
||||
dev=getDevice(sourceUdi.isEmpty() ? destUdi : sourceUdi, false);
|
||||
} else if (!sourceUdi.isEmpty()) { // Must be a delete...
|
||||
dev=getDevice(sourceUdi, false);
|
||||
}
|
||||
|
||||
if (dev) {
|
||||
dev->abortJob();
|
||||
}
|
||||
|
||||
refreshLibrary();
|
||||
reject();
|
||||
}
|
||||
|
||||
void ActionDialog::doNext()
|
||||
{
|
||||
if (songsToAction.count()) {
|
||||
@@ -429,6 +450,23 @@ void ActionDialog::actionStatus(int status, bool copiedCover)
|
||||
case Device::FailedToCreateTempFile:
|
||||
setPage(PAGE_ERROR, i18n("Failed to create temporary file.<br/>(Required for transcoding to MTP devices.)<hr/>%1").arg(formatSong(currentSong)));
|
||||
break;
|
||||
case Device::ReadFailed:
|
||||
setPage(PAGE_SKIP, i18n("Failed to read source file.<br/><br/<hr/>%1").arg(formatSong(currentSong)));
|
||||
break;
|
||||
case Device::WriteFailed:
|
||||
setPage(PAGE_SKIP, i18n("Failed to write to destination file.<br/><br/<hr/>%1").arg(formatSong(currentSong)));
|
||||
break;
|
||||
case Device::FailedToUpdateTags:
|
||||
setPage(PAGE_SKIP, i18n("Failed to update metadata.<br/><br/<hr/>%1").arg(formatSong(currentSong)));
|
||||
break;
|
||||
case Device::TooManyRedirects:
|
||||
setPage(PAGE_SKIP, i18n("Failed to download track - too many redirects encountered.<br/><br/<hr/>%1").arg(formatSong(currentSong)));
|
||||
break;
|
||||
case Device::DownloadFailed:
|
||||
setPage(PAGE_SKIP, i18n("Failed to download track.<br/><br/<hr/>%1").arg(formatSong(currentSong)));
|
||||
break;
|
||||
case Device::Cancelled:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -575,8 +613,8 @@ void ActionDialog::removeSong(const Song &s)
|
||||
void ActionDialog::removeSongResult(int status)
|
||||
{
|
||||
FileJob::finished(sender());
|
||||
if (FileJob::StatusOk!=status) {
|
||||
actionStatus(Device::Failed);
|
||||
if (Device::Ok!=status) {
|
||||
actionStatus(status);
|
||||
} else {
|
||||
MusicLibraryModel::self()->removeSongFromList(currentSong);
|
||||
DirViewModel::self()->removeFileFromList(currentSong.file);
|
||||
@@ -595,7 +633,7 @@ void ActionDialog::cleanDirs()
|
||||
void ActionDialog::cleanDirsResult(int status)
|
||||
{
|
||||
FileJob::finished(sender());
|
||||
actionStatus(FileJob::StatusOk==status ? Device::Ok : Device::Failed);
|
||||
actionStatus(status);
|
||||
}
|
||||
|
||||
void ActionDialog::jobPercent(int percent)
|
||||
|
||||
@@ -66,7 +66,8 @@ private Q_SLOTS:
|
||||
void jobPercent(int percent);
|
||||
|
||||
private:
|
||||
Device * getDevice(const QString &udi);
|
||||
void cancel();
|
||||
Device * getDevice(const QString &udi, bool logErrors=true);
|
||||
void configure(const QString &udi);
|
||||
void init(const QString &srcUdi, const QString &dstUdi, const QList<Song> &songs, Mode m);
|
||||
void slotButtonClicked(int button);
|
||||
|
||||
@@ -74,7 +74,15 @@ public:
|
||||
NotConnected,
|
||||
CodecNotAvailable,
|
||||
TranscodeFailed,
|
||||
FailedToCreateTempFile
|
||||
FailedToCreateTempFile,
|
||||
ReadFailed,
|
||||
WriteFailed,
|
||||
FailedToUpdateTags,
|
||||
Cancelled,
|
||||
|
||||
// These are for online services...
|
||||
TooManyRedirects,
|
||||
DownloadFailed
|
||||
};
|
||||
|
||||
enum DevType {
|
||||
@@ -170,7 +178,6 @@ public:
|
||||
bool isConfigured() {
|
||||
return configured;
|
||||
}
|
||||
|
||||
void abortJob() {
|
||||
jobAbortRequested=true;
|
||||
}
|
||||
|
||||
@@ -113,11 +113,11 @@ QString CopyJob::updateTagsLocal()
|
||||
song.file=srcFile;
|
||||
temp=Device::copySongToTemp(song);
|
||||
if (!temp) {
|
||||
emit result(StatusFailed);
|
||||
emit result(Device::FailedToUpdateTags);
|
||||
return QString();
|
||||
}
|
||||
if ((copyOpts&OptsApplyVaFix || copyOpts&OptsUnApplyVaFix) && !Device::fixVariousArtists(temp->fileName(), song, copyOpts&OptsApplyVaFix)) {
|
||||
emit result(StatusFailed);
|
||||
emit result(Device::FailedToUpdateTags);
|
||||
return QString();
|
||||
}
|
||||
if (Device::constEmbedCover==deviceOpts.coverName) {
|
||||
@@ -157,20 +157,20 @@ void CopyJob::run()
|
||||
}
|
||||
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
return;
|
||||
}
|
||||
|
||||
QFile src(srcFile);
|
||||
|
||||
if (!src.open(QIODevice::ReadOnly)) {
|
||||
emit result(StatusFailed);
|
||||
emit result(Device::ReadFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
QFile dest(destFile);
|
||||
if (!dest.open(QIODevice::WriteOnly)) {
|
||||
emit result(StatusFailed);
|
||||
emit result(Device::WriteFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -182,18 +182,18 @@ void CopyJob::run()
|
||||
|
||||
do {
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
return;
|
||||
}
|
||||
bytesRead = src.read(buffer, constChunkSize);
|
||||
readPos+=bytesRead;
|
||||
if (bytesRead<0) {
|
||||
emit result(StatusFailed);
|
||||
emit result(Device::ReadFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,11 +201,11 @@ void CopyJob::run()
|
||||
do {
|
||||
qint64 bytesWritten = dest.write(&buffer[writePos], bytesRead - writePos);
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
return;
|
||||
}
|
||||
if (-1==bytesWritten) {
|
||||
emit result(StatusFailed);
|
||||
emit result(Device::WriteFailed);
|
||||
return;
|
||||
}
|
||||
writePos+=bytesWritten;
|
||||
@@ -220,13 +220,13 @@ void CopyJob::run()
|
||||
updateTagsDest();
|
||||
copyCover(origSrcFile);
|
||||
setPercent(100);
|
||||
emit result(StatusOk);
|
||||
emit result(Device::Ok);
|
||||
}
|
||||
|
||||
void DeleteJob::run()
|
||||
{
|
||||
int status=QFile::remove(fileName) ? StatusOk : StatusFailed;
|
||||
if (remLyrics && StatusOk==status) {
|
||||
int status=QFile::remove(fileName) ? Device::Ok : Device::Failed;
|
||||
if (remLyrics && Device::Ok==status) {
|
||||
QString lyrics=Utils::changeExtension(fileName, LyricsPage::constExtension);
|
||||
if (lyrics!=fileName) {
|
||||
QFile::remove(lyrics);
|
||||
@@ -242,7 +242,7 @@ void CleanJob::run()
|
||||
int current=0;
|
||||
foreach (const QString &d, dirs) {
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
return;
|
||||
}
|
||||
Device::cleanDir(d, base, coverFile);
|
||||
@@ -250,5 +250,5 @@ void CleanJob::run()
|
||||
}
|
||||
|
||||
emit percent(100);
|
||||
emit result(StatusOk);
|
||||
emit result(Device::Ok);
|
||||
}
|
||||
|
||||
@@ -51,12 +51,6 @@ class FileJob : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Status {
|
||||
StatusOk,
|
||||
StatusFailed,
|
||||
StatusCancelled
|
||||
};
|
||||
|
||||
static void finished(QObject *obj) {
|
||||
if (obj) {
|
||||
obj->deleteLater();
|
||||
|
||||
@@ -527,8 +527,8 @@ void FsDevice::addSongResult(int status)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (FileJob::StatusOk!=status) {
|
||||
emit actionStatus(transcoding ? TranscodeFailed : Failed);
|
||||
if (Ok!=status) {
|
||||
emit actionStatus(status);
|
||||
} else {
|
||||
currentSong.file=destFileName;
|
||||
if (needToFixVa) {
|
||||
@@ -550,8 +550,8 @@ void FsDevice::copySongToResult(int status)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (FileJob::StatusOk!=status) {
|
||||
emit actionStatus(Failed);
|
||||
if (Ok!=status) {
|
||||
emit actionStatus(status);
|
||||
} else {
|
||||
currentSong.file=currentMusicPath; // MPD's paths are not full!!!
|
||||
if (needToFixVa) {
|
||||
@@ -571,8 +571,8 @@ void FsDevice::removeSongResult(int status)
|
||||
if (jobAbortRequested) {
|
||||
return;
|
||||
}
|
||||
if (FileJob::StatusOk!=status) {
|
||||
emit actionStatus(Failed);
|
||||
if (Ok!=status) {
|
||||
emit actionStatus(status);
|
||||
} else {
|
||||
removeSongFromList(currentSong);
|
||||
emit actionStatus(Ok);
|
||||
@@ -586,7 +586,7 @@ void FsDevice::cleanDirsResult(int status)
|
||||
if (jobAbortRequested) {
|
||||
return;
|
||||
}
|
||||
emit actionStatus(FileJob::StatusOk==status ? Ok : Failed);
|
||||
emit actionStatus(status);
|
||||
}
|
||||
|
||||
void FsDevice::cacheRead()
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <QStringList>
|
||||
|
||||
class MusicLibraryItemRoot;
|
||||
class KJob;
|
||||
|
||||
class MusicScanner : public QThread
|
||||
{
|
||||
|
||||
@@ -1212,8 +1212,8 @@ void MtpDevice::transcodeSongResult(int status)
|
||||
deleteTemp();
|
||||
return;
|
||||
}
|
||||
if (FileJob::StatusOk!=status) {
|
||||
emit actionStatus(TranscodeFailed);
|
||||
if (Ok!=status) {
|
||||
emit actionStatus(status);
|
||||
} else {
|
||||
emit putSong(currentSong, needToFixVa, DeviceOptions(Device::constNoCover));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ void TranscodingJob::run()
|
||||
}
|
||||
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
} else {
|
||||
QStringList parameters=encoder.params(value, src, destFile);
|
||||
process = new QProcess;
|
||||
@@ -65,7 +65,7 @@ void TranscodingJob::stop()
|
||||
process->close();
|
||||
process->deleteLater();
|
||||
process=0;
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,20 +76,20 @@ void TranscodingJob::finished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
return;
|
||||
}
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
return;
|
||||
}
|
||||
if (0==exitCode) {
|
||||
updateTagsDest();
|
||||
copyCover(srcFile);
|
||||
}
|
||||
emit result(0==exitCode ? StatusOk : StatusFailed);
|
||||
emit result(0==exitCode ? Device::Ok : Device::TranscodeFailed);
|
||||
}
|
||||
|
||||
void TranscodingJob::processOutput()
|
||||
{
|
||||
if (stopRequested) {
|
||||
emit result(StatusCancelled);
|
||||
emit result(Device::Cancelled);
|
||||
return;
|
||||
}
|
||||
QString output = process->readAllStandardOutput().data();
|
||||
|
||||
@@ -74,7 +74,7 @@ void OnlineDevice::downloadFinished()
|
||||
|
||||
if (redirect.isValid()) {
|
||||
if (++redirects >= constMaxRedirects) {
|
||||
emit actionStatus(Failed);
|
||||
emit actionStatus(TooManyRedirects);
|
||||
} else {
|
||||
job=NetworkAccessManager::self()->get(QUrl(redirect.toUrl()));
|
||||
connect(job, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||
@@ -92,11 +92,11 @@ void OnlineDevice::downloadFinished()
|
||||
f.write(reply->readAll());
|
||||
emit actionStatus(Ok);
|
||||
} else {
|
||||
emit actionStatus(Failed);
|
||||
emit actionStatus(WriteFailed);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
emit actionStatus(Failed);
|
||||
emit actionStatus(DownloadFailed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user