Пример #1
0
void ExportTemplateManager::_http_download_templates_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {

	switch (p_status) {

		case HTTPRequest::RESULT_CANT_RESOLVE: {
			template_list_state->set_text(TTR("Can't resolve."));
		} break;
		case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
		case HTTPRequest::RESULT_CONNECTION_ERROR:
		case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH: {
			template_list_state->set_text(TTR("Can't connect."));
		} break;
		case HTTPRequest::RESULT_SSL_HANDSHAKE_ERROR:
		case HTTPRequest::RESULT_CANT_CONNECT: {
			template_list_state->set_text(TTR("Can't connect."));
		} break;
		case HTTPRequest::RESULT_NO_RESPONSE: {
			template_list_state->set_text(TTR("No response."));
		} break;
		case HTTPRequest::RESULT_REQUEST_FAILED: {
			template_list_state->set_text(TTR("Req. Failed."));
		} break;
		case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
			template_list_state->set_text(TTR("Redirect Loop."));
		} break;
		default: {
			if (p_code != 200) {
				template_list_state->set_text(TTR("Failed:") + " " + itos(p_code));
			} else {
				String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz");
				FileAccess *f = FileAccess::open(path, FileAccess::WRITE);
				if (!f) {
					template_list_state->set_text(TTR("Can't write file."));
				} else {
					int size = p_data.size();
					PoolVector<uint8_t>::Read r = p_data.read();
					f->store_buffer(r.ptr(), size);
					memdelete(f);
					template_list_state->set_text(TTR("Download Complete."));
					template_downloader->hide();
					_install_from_file(path);
				}
			}
		} break;
	}

	set_process(false);
}
void ExportTemplateManager::_http_download_templates_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {

	switch (p_status) {

		case HTTPRequest::RESULT_CANT_RESOLVE: {
			template_list_state->set_text(TTR("Can't resolve."));
		} break;
		case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
		case HTTPRequest::RESULT_CONNECTION_ERROR:
		case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH: {
			template_list_state->set_text(TTR("Can't connect."));
		} break;
		case HTTPRequest::RESULT_SSL_HANDSHAKE_ERROR:
		case HTTPRequest::RESULT_CANT_CONNECT: {
			template_list_state->set_text(TTR("Can't connect."));
		} break;
		case HTTPRequest::RESULT_NO_RESPONSE: {
			template_list_state->set_text(TTR("No response."));
		} break;
		case HTTPRequest::RESULT_REQUEST_FAILED: {
			template_list_state->set_text(TTR("Request Failed."));
		} break;
		case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
			template_list_state->set_text(TTR("Redirect Loop."));
		} break;
		default: {
			if (p_code != 200) {
				template_list_state->set_text(TTR("Failed:") + " " + itos(p_code));
			} else {
				String path = download_templates->get_download_file();
				template_list_state->set_text(TTR("Download Complete."));
				template_downloader->hide();
				_install_from_file(path, false);
			}
		} break;
	}

	set_process(false);
}