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//! To be in AppTypes.h 15enum { 16 B_URL_PROTOCOL_NOTIFICATION = '_UPN' 17}; 18 19 20// Notification types 21enum { 22 B_URL_PROTOCOL_CONNECTION_OPENED, 23 B_URL_PROTOCOL_HOSTNAME_RESOLVED, 24 B_URL_PROTOCOL_RESPONSE_STARTED, 25 B_URL_PROTOCOL_HEADERS_RECEIVED, 26 B_URL_PROTOCOL_DATA_RECEIVED, 27 B_URL_PROTOCOL_DOWNLOAD_PROGRESS, 28 B_URL_PROTOCOL_UPLOAD_PROGRESS, 29 B_URL_PROTOCOL_REQUEST_COMPLETED 30}; 31 32 33class BUrlProtocolDispatchingListener : public BUrlProtocolListener { 34public: 35 BUrlProtocolDispatchingListener( 36 BHandler* handler); 37 BUrlProtocolDispatchingListener( 38 const BMessenger& messenger); 39 40 virtual void ConnectionOpened(BUrlProtocol* caller); 41 virtual void HostnameResolved(BUrlProtocol* caller, 42 const char* ip); 43 virtual void ResponseStarted(BUrlProtocol* caller); 44 virtual void HeadersReceived(BUrlProtocol* caller); 45 virtual void DataReceived(BUrlProtocol* caller, 46 const char* data, ssize_t size); 47 virtual void DownloadProgress(BUrlProtocol* caller, 48 ssize_t bytesReceived, ssize_t bytesTotal); 49 virtual void UploadProgress(BUrlProtocol* caller, 50 ssize_t bytesSent, ssize_t bytesTotal); 51 virtual void RequestCompleted(BUrlProtocol* caller, 52 bool success); 53 virtual void DebugMessage(BUrlProtocol*, 54 BUrlProtocolDebugMessage, 55 const char*) { } 56 57private: 58 void _SendMessage(BMessage* message, 59 int8 notification, BUrlProtocol* caller); 60 61private: 62 BMessenger fMessenger; 63}; 64 65#endif // _B_URL_PROTOCOL_DISPATCHING_LISTENER_H_ 66 67