GUI: Add error callback in Options' Cloud tab

Shows OSD message.
This commit is contained in:
Alexander Tkachev 2016-07-20 13:02:18 +06:00
parent 1d78d20fcf
commit 63311bac26
2 changed files with 18 additions and 2 deletions

View File

@ -1624,10 +1624,17 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
case kRefreshStorageCmd:
{
CloudMan.info(new Common::Callback<GlobalOptionsDialog, Cloud::Storage::StorageInfoResponse>(this, &GlobalOptionsDialog::storageInfoCallback), nullptr);
CloudMan.info(
new Common::Callback<GlobalOptionsDialog, Cloud::Storage::StorageInfoResponse>(this, &GlobalOptionsDialog::storageInfoCallback),
new Common::Callback<GlobalOptionsDialog, Networking::ErrorResponse>(this, &GlobalOptionsDialog::storageErrorCallback)
);
Common::String dir = CloudMan.savesDirectoryPath();
if (dir.lastChar() == '/') dir.deleteLastChar();
CloudMan.listDirectory(dir, new Common::Callback<GlobalOptionsDialog, Cloud::Storage::ListDirectoryResponse>(this, &GlobalOptionsDialog::storageListDirectoryCallback), nullptr);
CloudMan.listDirectory(
dir,
new Common::Callback<GlobalOptionsDialog, Cloud::Storage::ListDirectoryResponse>(this, &GlobalOptionsDialog::storageListDirectoryCallback),
new Common::Callback<GlobalOptionsDialog, Networking::ErrorResponse>(this, &GlobalOptionsDialog::storageErrorCallback)
);
break;
}
case kDownloadStorageCmd:
@ -1825,6 +1832,14 @@ void GlobalOptionsDialog::storageListDirectoryCallback(Cloud::Storage::ListDirec
CloudMan.setStorageUsedSpace(CloudMan.getStorageIndex(), totalSize);
_redrawCloudTab = true;
}
void GlobalOptionsDialog::storageErrorCallback(Networking::ErrorResponse response) {
debug("error response (%s, %ld):", (response.failed ? "failed" : "interrupted"), response.httpResponseCode);
debug("%s", response.response.c_str());
if (!response.interrupted)
g_system->displayMessageOnOSD(_("Request failed.\nCheck your Internet connection."));
}
#endif
} // End of namespace GUI

View File

@ -277,6 +277,7 @@ protected:
#ifdef USE_LIBCURL
void storageInfoCallback(Cloud::Storage::StorageInfoResponse response);
void storageListDirectoryCallback(Cloud::Storage::ListDirectoryResponse response);
void storageErrorCallback(Networking::ErrorResponse response);
#endif
};