xref: /haiku/src/apps/haikudepot/server/ServerHelper.h (revision 68d37cfb3a755a7270d772b505ee15c8b18aa5e0)
1 /*
2  * Copyright 2017-2019, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef SERVER_HELPER_H
6 #define SERVER_HELPER_H
7 
8 #include <HttpHeaders.h>
9 
10 #include "ValidationFailure.h"
11 
12 
13 class BMessage;
14 
15 
16 class ServerHelper {
17 public:
18 	static	bool						IsNetworkAvailable();
19 	static	bool						IsPlatformNetworkAvailable();
20 
21 	static	void						NotifyClientTooOld(
22 											const BHttpHeaders& responseHeaders
23 											);
24 	static	void						AlertClientTooOld(BMessage* message);
25 
26 	static	void						NotifyTransportError(status_t error);
27 	static	void						AlertTransportError(BMessage* message);
28 
29 	static	void						NotifyServerJsonRpcError(
30 											BMessage& error);
31 	static	void						AlertServerJsonRpcError(
32 											BMessage* responseEnvelopeMessage);
33 	static	void						GetFailuresFromJsonRpcError(
34 											ValidationFailures& failures,
35 											BMessage& responseEnvelopeMessage);
36 
37 private:
38 	static	void						_GetFailuresFromJsonRpcFailures(
39 											ValidationFailures& failures,
40 											BMessage& jsonRpcFailures);
41 };
42 
43 #endif // SERVER_HELPER_H
44