1 /* 2 * Copyright 2010 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _B_URL_PROTOCOL_DISPATCHING_LISTENER_H_ 6 #define _B_URL_PROTOCOL_DISPATCHING_LISTENER_H_ 7 8 9 #include <Messenger.h> 10 #include <Message.h> 11 #include <UrlProtocolListener.h> 12 13 14 namespace BPrivate { 15 16 namespace Network { 17 18 19 //! To be in AppTypes.h 20 enum { 21 B_URL_PROTOCOL_NOTIFICATION = '_UPN' 22 }; 23 24 25 // Notification types 26 enum { 27 B_URL_PROTOCOL_CONNECTION_OPENED, 28 B_URL_PROTOCOL_HOSTNAME_RESOLVED, 29 B_URL_PROTOCOL_RESPONSE_STARTED, 30 B_URL_PROTOCOL_HEADERS_RECEIVED, 31 B_URL_PROTOCOL_BYTES_WRITTEN, 32 B_URL_PROTOCOL_DOWNLOAD_PROGRESS, 33 B_URL_PROTOCOL_UPLOAD_PROGRESS, 34 B_URL_PROTOCOL_REQUEST_COMPLETED, 35 B_URL_PROTOCOL_CERTIFICATE_VERIFICATION_FAILED, 36 B_URL_PROTOCOL_DEBUG_MESSAGE 37 }; 38 39 40 class BUrlProtocolDispatchingListener : public BUrlProtocolListener { 41 public: 42 BUrlProtocolDispatchingListener( 43 BHandler* handler); 44 BUrlProtocolDispatchingListener( 45 const BMessenger& messenger); 46 virtual ~BUrlProtocolDispatchingListener(); 47 48 virtual void ConnectionOpened(BUrlRequest* caller); 49 virtual void HostnameResolved(BUrlRequest* caller, 50 const char* ip); 51 virtual void ResponseStarted(BUrlRequest* caller); 52 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 61 virtual void RequestCompleted(BUrlRequest* caller, 62 bool success); 63 virtual void DebugMessage(BUrlRequest* caller, 64 BUrlProtocolDebugMessage type, 65 const char* text); 66 virtual bool CertificateVerificationFailed( 67 BUrlRequest* caller, 68 BCertificate& certificate, 69 const char* message); 70 71 private: 72 void _SendMessage(BMessage* message, 73 int8 notification, 74 BUrlRequest* caller); 75 76 private: 77 BMessenger fMessenger; 78 }; 79 80 81 } // namespace Network 82 83 } // namespace BPrivate 84 85 #endif // _B_URL_PROTOCOL_DISPATCHING_LISTENER_H_ 86