Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
4ebcfc6b
Commit
4ebcfc6b
authored
Feb 04, 2015
by
Fabio Bas
Browse files
Raise a question popup when zip parsing fails
parent
781f8a66
Changes
2
Show whitespace changes
Inline
Side-by-side
oracle/src/oraclewizard.cpp
View file @
4ebcfc6b
...
...
@@ -30,6 +30,7 @@
#include
"zip/unzip.h"
#define ZIP_SIGNATURE "PK"
#define ALLSETS_URL "http://mtgjson.com/json/AllSets.json.zip"
#define ALLSETS_URL_FALLBACK "http://mtgjson.com/json/AllSets.json"
#else
#define ALLSETS_URL "http://mtgjson.com/json/AllSets.json"
#endif
...
...
@@ -282,19 +283,13 @@ void LoadSetsPage::readSetsFromByteArray(QByteArray data)
ec
=
uz
.
openArchive
(
inBuffer
);
if
(
ec
!=
UnZip
::
Ok
)
{
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"Failed to open Zip archive: %1"
).
arg
(
uz
.
formatError
(
ec
)));
wizard
()
->
enableButtons
();
setEnabled
(
true
);
zipDownloadFailed
(
tr
(
"Failed to open Zip archive: %1."
).
arg
(
uz
.
formatError
(
ec
)));
return
;
}
if
(
uz
.
fileList
().
size
()
!=
1
)
{
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"The Zip archive doesn't contain exactly one file"
));
wizard
()
->
enableButtons
();
setEnabled
(
true
);
zipDownloadFailed
(
tr
(
"The Zip archive doesn't contain exactly one file."
));
return
;
}
fileName
=
uz
.
fileList
().
at
(
0
);
...
...
@@ -302,11 +297,8 @@ void LoadSetsPage::readSetsFromByteArray(QByteArray data)
outBuffer
->
open
(
QBuffer
::
ReadWrite
);
ec
=
uz
.
extractFile
(
fileName
,
outBuffer
);
if
(
ec
!=
UnZip
::
Ok
)
{
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"Zip extraction failed: %1"
).
arg
(
uz
.
formatError
(
ec
)));
zipDownloadFailed
(
tr
(
"Zip extraction failed: %1
.
"
).
arg
(
uz
.
formatError
(
ec
)));
uz
.
closeArchive
();
wizard
()
->
enableButtons
();
setEnabled
(
true
);
return
;
}
...
...
@@ -314,10 +306,12 @@ void LoadSetsPage::readSetsFromByteArray(QByteArray data)
watcher
.
setFuture
(
future
);
return
;
#else
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"Sorry, this version of Oracle does not support zipped files."
));
zipDownloadFailed
(
tr
(
"Sorry, this version of Oracle does not support zipped files."
));
wizard
()
->
enableButtons
();
setEnabled
(
true
);
progressLabel
->
hide
();
progressBar
->
hide
();
return
;
#endif
}
...
...
@@ -326,6 +320,24 @@ void LoadSetsPage::readSetsFromByteArray(QByteArray data)
watcher
.
setFuture
(
future
);
}
void
LoadSetsPage
::
zipDownloadFailed
(
const
QString
&
message
)
{
wizard
()
->
enableButtons
();
setEnabled
(
true
);
progressLabel
->
hide
();
progressBar
->
hide
();
QMessageBox
::
StandardButton
reply
;
reply
=
QMessageBox
::
question
(
this
,
tr
(
"Error"
),
message
+
"<br/>"
+
tr
(
"Do you want to try to download a fresh copy of the uncompressed file instead?"
),
QMessageBox
::
Ok
|
QMessageBox
::
Cancel
,
QMessageBox
::
Ok
);
if
(
reply
==
QMessageBox
::
Ok
)
{
urlRadioButton
->
setChecked
(
true
);
urlLineEdit
->
setText
(
ALLSETS_URL_FALLBACK
);
wizard
()
->
next
();
}
}
void
LoadSetsPage
::
importFinished
()
{
wizard
()
->
enableButtons
();
...
...
oracle/src/oraclewizard.h
View file @
4ebcfc6b
...
...
@@ -77,6 +77,7 @@ private slots:
void
actDownloadProgressSetsFile
(
qint64
received
,
qint64
total
);
void
actDownloadFinishedSetsFile
();
void
importFinished
();
void
zipDownloadFailed
(
const
QString
&
message
);
};
class
ChooseSetsPage
:
public
OracleWizardPage
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment