2010-10-27 18:03:31 +04:00
|
|
|
/*
|
2014-06-11 16:11:01 +04:00
|
|
|
* Copyright 2010-2014 Haiku Inc. All rights reserved.
|
2010-10-27 18:03:31 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _B_URL_REQUEST_H_
|
|
|
|
#define _B_URL_REQUEST_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <Url.h>
|
|
|
|
#include <UrlContext.h>
|
|
|
|
#include <UrlProtocolListener.h>
|
2013-12-09 23:26:13 +04:00
|
|
|
#include <UrlResult.h>
|
2013-10-08 13:30:56 +04:00
|
|
|
#include <OS.h>
|
2014-06-11 16:11:01 +04:00
|
|
|
#include <Referenceable.h>
|
2010-10-27 18:03:31 +04:00
|
|
|
|
|
|
|
|
2021-01-22 17:20:19 +03:00
|
|
|
#ifndef LIBNETAPI_DEPRECATED
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
namespace Network {
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
class BUrlRequest {
|
|
|
|
public:
|
2020-07-25 07:45:42 +03:00
|
|
|
#ifdef LIBNETAPI_DEPRECATED
|
2010-10-27 18:03:31 +04:00
|
|
|
BUrlRequest(const BUrl& url,
|
2013-10-08 13:30:56 +04:00
|
|
|
BUrlProtocolListener* listener,
|
|
|
|
BUrlContext* context,
|
|
|
|
const char* threadName,
|
|
|
|
const char* protocolName);
|
2020-07-25 07:45:42 +03:00
|
|
|
#else
|
|
|
|
BUrlRequest(const BUrl& url,
|
|
|
|
BDataIO* output,
|
|
|
|
BUrlProtocolListener* listener,
|
|
|
|
BUrlContext* context,
|
|
|
|
const char* threadName,
|
|
|
|
const char* protocolName);
|
|
|
|
#endif
|
2013-02-11 00:36:34 +04:00
|
|
|
virtual ~BUrlRequest();
|
2010-10-27 18:03:31 +04:00
|
|
|
|
2013-10-08 13:30:56 +04:00
|
|
|
// URL protocol thread management
|
|
|
|
virtual thread_id Run();
|
2021-08-15 12:47:17 +03:00
|
|
|
#ifdef LIBNETAPI_DEPRECATED
|
|
|
|
virtual status_t Pause();
|
|
|
|
virtual status_t Resume();
|
|
|
|
#endif
|
|
|
|
|
2013-10-08 13:30:56 +04:00
|
|
|
virtual status_t Stop();
|
2014-09-26 17:51:36 +04:00
|
|
|
virtual void SetTimeout(bigtime_t timeout) {}
|
2013-02-11 00:36:34 +04:00
|
|
|
|
2013-10-08 13:30:56 +04:00
|
|
|
// URL protocol parameters modification
|
|
|
|
status_t SetUrl(const BUrl& url);
|
|
|
|
status_t SetContext(BUrlContext* context);
|
|
|
|
status_t SetListener(BUrlProtocolListener* listener);
|
2020-07-25 07:45:42 +03:00
|
|
|
#ifndef LIBNETAPI_DEPRECATED
|
|
|
|
status_t SetOutput(BDataIO* output);
|
|
|
|
#endif
|
2013-10-08 13:30:56 +04:00
|
|
|
|
|
|
|
// URL protocol parameters access
|
|
|
|
const BUrl& Url() const;
|
|
|
|
BUrlContext* Context() const;
|
|
|
|
BUrlProtocolListener* Listener() const;
|
|
|
|
const BString& Protocol() const;
|
2020-07-25 07:45:42 +03:00
|
|
|
#ifndef LIBNETAPI_DEPRECATED
|
|
|
|
BDataIO* Output() const;
|
|
|
|
#endif
|
2013-10-08 13:30:56 +04:00
|
|
|
|
|
|
|
// URL protocol informations
|
2010-10-27 18:03:31 +04:00
|
|
|
bool IsRunning() const;
|
|
|
|
status_t Status() const;
|
2013-12-09 23:26:13 +04:00
|
|
|
virtual const BUrlResult& Result() const = 0;
|
2013-10-08 13:30:56 +04:00
|
|
|
|
2013-02-11 00:36:34 +04:00
|
|
|
|
2013-10-08 13:30:56 +04:00
|
|
|
protected:
|
|
|
|
static int32 _ThreadEntry(void* arg);
|
2014-08-04 18:25:48 +04:00
|
|
|
virtual void _ProtocolSetup() {};
|
2013-11-15 19:32:18 +04:00
|
|
|
virtual status_t _ProtocolLoop() = 0;
|
2013-10-08 13:30:56 +04:00
|
|
|
virtual void _EmitDebug(BUrlProtocolDebugMessage type,
|
|
|
|
const char* format, ...);
|
2010-10-27 18:03:31 +04:00
|
|
|
protected:
|
|
|
|
BUrl fUrl;
|
2014-06-11 16:11:01 +04:00
|
|
|
BReference<BUrlContext> fContext;
|
2013-10-08 13:30:56 +04:00
|
|
|
BUrlProtocolListener* fListener;
|
2020-07-25 07:45:42 +03:00
|
|
|
#ifndef LIBNETAPI_DEPRECATED
|
|
|
|
BDataIO* fOutput;
|
|
|
|
#endif
|
2013-02-11 00:36:34 +04:00
|
|
|
|
2013-10-08 13:30:56 +04:00
|
|
|
bool fQuit;
|
|
|
|
bool fRunning;
|
|
|
|
status_t fThreadStatus;
|
|
|
|
thread_id fThreadId;
|
|
|
|
BString fThreadName;
|
|
|
|
BString fProtocol;
|
|
|
|
};
|
|
|
|
|
2021-01-22 17:20:19 +03:00
|
|
|
#ifndef LIBNETAPI_DEPRECATED
|
|
|
|
} // namespace Network
|
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
#endif
|
2013-10-08 13:30:56 +04:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
#endif // _B_URL_REQUEST_H_
|