File reportsDir = this.getReportsDirectory();
if (reportsDir.exists()) {
for (String filename : reportsDir.list(Utils.getOpenEyePendingReportsFileFilter())) {
File report = new File(reportsDir, filename);
LogManager.info("OpenEye: Sending pending crash report located at '" + report.getAbsolutePath() + "'");
OpenEyeReportResponse response = Utils.sendOpenEyePendingReport(report);
if (response == null) {
// Pending report was never sent due to an issue. Won't delete the file in case
// it's
// a temporary issue and can be sent again later.
LogManager.error("OpenEye: Couldn't send pending crash report!");
} else {
// OpenEye returned a response to the report, display that to user if needed.
LogManager.info("OpenEye: Pending crash report sent! URL: " + response.getURL());
if (response.hasNote()) {
String[] options = {Language.INSTANCE.localize("common.opencrashreport"), Language.INSTANCE
.localize("common.ok")};
int ret = JOptionPane.showOptionDialog(App.settings.getParent(), "<html><p align=\"center\">"
+ Language.INSTANCE.localizeWithReplace("instance" + "" +
".openeyereport1", "<br/><br/>") + response.getNoteDisplay() + Language.INSTANCE
.localize("instance.openeyereport2") + "</p></html>", Language.INSTANCE.localize
("instance.aboutyourcrash"), JOptionPane.DEFAULT_OPTION, JOptionPane
.INFORMATION_MESSAGE, null, options, options[1]);
if (ret == 0) {
Utils.openBrowser(response.getURL());
}
}
}
Utils.delete(report); // Delete the pending report since we've sent it
}