
/*---------------------------------------------------------------------------*/
/* webserver_delete_handler.h                                                */
/* copyright (c) innovaphone 2016                                            */
/*                                                                           */
/*---------------------------------------------------------------------------*/

class WebserverDeleteHandler : public WebserverWebdavMessageHandler, public IWebserverDelete {
protected:
    UWebserverDelete * user;

    void SendResult() override { user->WebserverDeleteSendResult(this); }

    void CloseComplete() override
    {
        UWebserverDelete * tmp = user;
        user = NULL;
        tmp->WebserverDeleteCloseComplete(this);
    }

public:
    WebserverDeleteHandler(UWebserverMessageHandler * baseUser,
                           byte * extHeaderBuffer,
                           dword connectionID,
                           ulong64 dataSize,
                           char * resourceName,
                           char * resReqPath,
                           class ExtendedHeader & extHeader,
                           IWebserverMessage * const webserverMessageSend,
                           class IInstanceLog * const log,
                           word protocolVersion);
    virtual ~WebserverDeleteHandler();

    void SetUser(UWebserverDelete * user)
    {
        this->userSet = true;
        this->user = user;
    }

	dword GetConnectionID() override { return WebserverWebdavMessageHandler::GetConnectionID(); }
	const char * GetResourceName() override { return WebserverWebdavMessageHandler::GetResourceName(); }
	const char * GetRegisteredPathForRequest() override { return WebserverWebdavMessageHandler::GetRegisteredPathForRequest(); }
	virtual class IDigestAuthenticator * GetAuthenticator() override { return WebserverWebdavMessageHandler::GetAuthenticator(); }
    virtual const char * GetRemoteAddress() { return WebserverMessageHandler::GetRemoteAddress(); }
    virtual word GetRemotePort() { return WebserverMessageHandler::GetRemotePort(); }
    bool IsEncryptedConnection() override { return this->connFlags.connectionIsTLS; }

    const char * GetHeaderFieldValue(const char * fieldName) override { return WebserverWebdavMessageHandler::GetHeaderFieldValue(fieldName); }
    void SetResultCode(ws_webdav_result_t result, ulong64 dataSize = 0) override { WebserverWebdavMessageHandler::SetResultCode(result, dataSize); }
    void SetTransferInfo(wsr_type_t resourceType, ulong64 dataSize, wsr_flags_t flags = WSP_FLAG_NONE, const char* etag = nullptr) { WebserverWebdavMessageHandler::SetTransferInfo(resourceType, dataSize, flags, etag); };
    void SetStatusCode(dword code, const char * description = nullptr) override { WebserverWebdavMessageHandler::SetStatusCode(code, description); }
    void SetHeaderField(const char * fname, const char * fvalue) override { WebserverWebdavMessageHandler::SetHeaderField(fname, fvalue); }
    void Cancel(wsr_cancel_type_t reason) override { WebserverWebdavMessageHandler::Cancel(reason); }
    void Send(const void * buffer, size_t len) override { WebserverWebdavMessageHandler::Send(buffer, len); }
    void Close() override { WebserverWebdavMessageHandler::Close(); }
    void AcceptComplete() override { user->WebserverDeleteRequestAcceptComplete(this); }
};
