xref: /haiku/headers/private/netservices/UrlProtocolListener.h (revision a5061ecec55353a5f394759473f1fd6df04890da)
1 /*
2  * Copyright 2010-2017 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _B_URL_PROTOCOL_LISTENER_H_
6 #define _B_URL_PROTOCOL_LISTENER_H_
7 
8 
9 #include <stddef.h>
10 #include <cstdlib>
11 
12 #include <UrlResult.h>
13 
14 
15 class BCertificate;
16 
17 #ifndef LIBNETAPI_DEPRECATED
18 namespace BPrivate {
19 
20 namespace Network {
21 #endif
22 
23 class BUrlRequest;
24 
25 
26 enum BUrlProtocolDebugMessage {
27 	B_URL_PROTOCOL_DEBUG_TEXT,
28 	B_URL_PROTOCOL_DEBUG_ERROR,
29 	B_URL_PROTOCOL_DEBUG_HEADER_IN,
30 	B_URL_PROTOCOL_DEBUG_HEADER_OUT,
31 	B_URL_PROTOCOL_DEBUG_TRANSFER_IN,
32 	B_URL_PROTOCOL_DEBUG_TRANSFER_OUT
33 };
34 
35 
36 class BUrlProtocolListener {
37 public:
38 	virtual	void				ConnectionOpened(BUrlRequest* caller);
39 	virtual	void				HostnameResolved(BUrlRequest* caller,
40 									const char* ip);
41 	virtual	void				ResponseStarted(BUrlRequest* caller);
42 #ifdef LIBNETAPI_DEPRECATED
43 	virtual	void				HeadersReceived(BUrlRequest* caller,
44 									const BUrlResult& result);
45 	virtual	void				DataReceived(BUrlRequest* caller,
46 									const char* data, off_t position,
47 									ssize_t size);
48 	virtual	void				DownloadProgress(BUrlRequest* caller,
49 									ssize_t bytesReceived, ssize_t bytesTotal);
50 	virtual	void				UploadProgress(BUrlRequest* caller,
51 									ssize_t bytesSent, ssize_t bytesTotal);
52 #else
53 	virtual	void				HeadersReceived(BUrlRequest* caller);
54 	virtual	void				BytesWritten(BUrlRequest* caller,
55 									size_t bytesWritten);
56 	virtual	void				DownloadProgress(BUrlRequest* caller,
57 									off_t bytesReceived, off_t bytesTotal);
58 	virtual void				UploadProgress(BUrlRequest* caller,
59 									off_t bytesSent, off_t bytesTotal);
60 #endif
61 
62 	virtual	void				RequestCompleted(BUrlRequest* caller,
63 									bool success);
64 	virtual	void				DebugMessage(BUrlRequest* caller,
65 									BUrlProtocolDebugMessage type,
66 									const char* text);
67 	virtual	bool				CertificateVerificationFailed(
68 									BUrlRequest* caller,
69 									BCertificate& certificate,
70 									const char* message);
71 };
72 
73 #ifndef LIBNETAPI_DEPRECATED
74 } // namespace Network
75 
76 } // namespace BPrivate
77 #endif
78 
79 #endif // _B_URL_PROTOCOL_LISTENER_H_
80