1603e0bdfSNiels Sascha Reedijk /* 2603e0bdfSNiels Sascha Reedijk * Copyright 2010 Haiku Inc. All rights reserved. 3603e0bdfSNiels Sascha Reedijk * Distributed under the terms of the MIT License. 4603e0bdfSNiels Sascha Reedijk */ 5603e0bdfSNiels Sascha Reedijk #ifndef _B_URL_PROTOCOL_DISPATCHING_LISTENER_H_ 6603e0bdfSNiels Sascha Reedijk #define _B_URL_PROTOCOL_DISPATCHING_LISTENER_H_ 7603e0bdfSNiels Sascha Reedijk 8603e0bdfSNiels Sascha Reedijk 9603e0bdfSNiels Sascha Reedijk #include <Messenger.h> 10603e0bdfSNiels Sascha Reedijk #include <Message.h> 11603e0bdfSNiels Sascha Reedijk #include <UrlProtocolListener.h> 12603e0bdfSNiels Sascha Reedijk 13*70b63f18SNiels Sascha Reedijk 14ce64ffdbSNiels Sascha Reedijk namespace BPrivate { 15ce64ffdbSNiels Sascha Reedijk 16ce64ffdbSNiels Sascha Reedijk namespace Network { 17*70b63f18SNiels Sascha Reedijk 18603e0bdfSNiels Sascha Reedijk 19603e0bdfSNiels Sascha Reedijk //! To be in AppTypes.h 20603e0bdfSNiels Sascha Reedijk enum { 21603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_NOTIFICATION = '_UPN' 22603e0bdfSNiels Sascha Reedijk }; 23603e0bdfSNiels Sascha Reedijk 24603e0bdfSNiels Sascha Reedijk 25603e0bdfSNiels Sascha Reedijk // Notification types 26603e0bdfSNiels Sascha Reedijk enum { 27603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_CONNECTION_OPENED, 28603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_HOSTNAME_RESOLVED, 29603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_RESPONSE_STARTED, 30603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_HEADERS_RECEIVED, 3178b14420SLeorize B_URL_PROTOCOL_BYTES_WRITTEN, 32603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_DOWNLOAD_PROGRESS, 33603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_UPLOAD_PROGRESS, 34603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_REQUEST_COMPLETED, 35603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_CERTIFICATE_VERIFICATION_FAILED, 36603e0bdfSNiels Sascha Reedijk B_URL_PROTOCOL_DEBUG_MESSAGE 37603e0bdfSNiels Sascha Reedijk }; 38603e0bdfSNiels Sascha Reedijk 39603e0bdfSNiels Sascha Reedijk 40603e0bdfSNiels Sascha Reedijk class BUrlProtocolDispatchingListener : public BUrlProtocolListener { 41603e0bdfSNiels Sascha Reedijk public: 42603e0bdfSNiels Sascha Reedijk BUrlProtocolDispatchingListener( 43603e0bdfSNiels Sascha Reedijk BHandler* handler); 44603e0bdfSNiels Sascha Reedijk BUrlProtocolDispatchingListener( 45603e0bdfSNiels Sascha Reedijk const BMessenger& messenger); 46603e0bdfSNiels Sascha Reedijk virtual ~BUrlProtocolDispatchingListener(); 47603e0bdfSNiels Sascha Reedijk 48603e0bdfSNiels Sascha Reedijk virtual void ConnectionOpened(BUrlRequest* caller); 49603e0bdfSNiels Sascha Reedijk virtual void HostnameResolved(BUrlRequest* caller, 50603e0bdfSNiels Sascha Reedijk const char* ip); 51603e0bdfSNiels Sascha Reedijk virtual void ResponseStarted(BUrlRequest* caller); 5278b14420SLeorize 5378b14420SLeorize virtual void HeadersReceived(BUrlRequest* caller); 5478b14420SLeorize virtual void BytesWritten(BUrlRequest* caller, 5578b14420SLeorize size_t bytesWritten); 56626466daSX512 virtual void DownloadProgress(BUrlRequest* caller, 57626466daSX512 off_t bytesReceived, off_t bytesTotal); 58626466daSX512 virtual void UploadProgress(BUrlRequest* caller, 59626466daSX512 off_t bytesSent, off_t bytesTotal); 60626466daSX512 61603e0bdfSNiels Sascha Reedijk virtual void RequestCompleted(BUrlRequest* caller, 62603e0bdfSNiels Sascha Reedijk bool success); 63603e0bdfSNiels Sascha Reedijk virtual void DebugMessage(BUrlRequest* caller, 64603e0bdfSNiels Sascha Reedijk BUrlProtocolDebugMessage type, 65603e0bdfSNiels Sascha Reedijk const char* text); 66603e0bdfSNiels Sascha Reedijk virtual bool CertificateVerificationFailed( 67603e0bdfSNiels Sascha Reedijk BUrlRequest* caller, 68603e0bdfSNiels Sascha Reedijk BCertificate& certificate, 69603e0bdfSNiels Sascha Reedijk const char* message); 70603e0bdfSNiels Sascha Reedijk 71603e0bdfSNiels Sascha Reedijk private: 72603e0bdfSNiels Sascha Reedijk void _SendMessage(BMessage* message, 7378b14420SLeorize int8 notification, 7478b14420SLeorize BUrlRequest* caller); 75603e0bdfSNiels Sascha Reedijk 76603e0bdfSNiels Sascha Reedijk private: 77603e0bdfSNiels Sascha Reedijk BMessenger fMessenger; 78603e0bdfSNiels Sascha Reedijk }; 79603e0bdfSNiels Sascha Reedijk 80*70b63f18SNiels Sascha Reedijk 81ce64ffdbSNiels Sascha Reedijk } // namespace Network 82ce64ffdbSNiels Sascha Reedijk 83ce64ffdbSNiels Sascha Reedijk } // namespace BPrivate 84ce64ffdbSNiels Sascha Reedijk 85603e0bdfSNiels Sascha Reedijk #endif // _B_URL_PROTOCOL_DISPATCHING_LISTENER_H_ 86