initial commit
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
37
libs/wxWidgets-3.3.1/include/wx/protocol/file.h
Normal file
37
libs/wxWidgets-3.3.1/include/wx/protocol/file.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/protocol/file.h
|
||||
// Purpose: File protocol
|
||||
// Author: Guilhem Lavaux
|
||||
// Created: 1997
|
||||
// Copyright: (c) 1997, 1998 Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_PROTO_FILE_H__
|
||||
#define __WX_PROTO_FILE_H__
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROTOCOL_FILE
|
||||
|
||||
#include "wx/protocol/protocol.h"
|
||||
|
||||
class WXDLLIMPEXP_NET wxFileProto: public wxProtocol
|
||||
{
|
||||
public:
|
||||
wxFileProto();
|
||||
virtual ~wxFileProto();
|
||||
|
||||
bool Abort() override { return true; }
|
||||
wxString GetContentType() const override { return wxEmptyString; }
|
||||
|
||||
wxInputStream *GetInputStream(const wxString& path) override;
|
||||
|
||||
protected:
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFileProto);
|
||||
DECLARE_PROTOCOL(wxFileProto)
|
||||
};
|
||||
|
||||
#endif // wxUSE_PROTOCOL_FILE
|
||||
|
||||
#endif // __WX_PROTO_FILE_H__
|
||||
176
libs/wxWidgets-3.3.1/include/wx/protocol/ftp.h
Normal file
176
libs/wxWidgets-3.3.1/include/wx/protocol/ftp.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/protocol/ftp.h
|
||||
// Purpose: FTP protocol
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by: Mark Johnson, wxWindows@mj10777.de
|
||||
// 20000917 : RmDir, GetLastResult, GetList
|
||||
// Created: 07/07/1997
|
||||
// Copyright: (c) 1997, 1998 Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_FTP_H__
|
||||
#define __WX_FTP_H__
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROTOCOL_FTP
|
||||
|
||||
#include "wx/sckaddr.h"
|
||||
#include "wx/protocol/protocol.h"
|
||||
#include "wx/url.h"
|
||||
|
||||
class WXDLLIMPEXP_NET wxFTP : public wxProtocol
|
||||
{
|
||||
public:
|
||||
enum TransferMode
|
||||
{
|
||||
NONE, // not set by user explicitly
|
||||
ASCII,
|
||||
BINARY
|
||||
};
|
||||
|
||||
wxFTP();
|
||||
virtual ~wxFTP();
|
||||
|
||||
// Connecting and disconnecting
|
||||
virtual bool Connect(const wxSockAddress& addr, bool wait = true) override;
|
||||
virtual bool Connect(const wxString& host) override { return Connect(host, 0); }
|
||||
virtual bool Connect(const wxString& host, unsigned short port);
|
||||
|
||||
// disconnect
|
||||
virtual bool Close() override;
|
||||
|
||||
// Parameters set up
|
||||
|
||||
// set transfer mode now
|
||||
void SetPassive(bool pasv) { m_bPassive = pasv; }
|
||||
bool SetBinary() { return SetTransferMode(BINARY); }
|
||||
bool SetAscii() { return SetTransferMode(ASCII); }
|
||||
bool SetTransferMode(TransferMode mode);
|
||||
|
||||
// Generic FTP interface
|
||||
|
||||
// FTP doesn't know the MIME type of the last downloaded/uploaded file
|
||||
virtual wxString GetContentType() const override { return wxEmptyString; }
|
||||
|
||||
// the last FTP server reply
|
||||
const wxString& GetLastResult() const { return m_lastResult; }
|
||||
|
||||
// send any FTP command (should be full FTP command line but without
|
||||
// trailing "\r\n") and return its return code
|
||||
char SendCommand(const wxString& command);
|
||||
|
||||
// check that the command returned the given code
|
||||
bool CheckCommand(const wxString& command, char expectedReturn)
|
||||
{
|
||||
// SendCommand() does updates m_lastError
|
||||
return SendCommand(command) == expectedReturn;
|
||||
}
|
||||
|
||||
// Filesystem commands
|
||||
bool ChDir(const wxString& dir);
|
||||
bool MkDir(const wxString& dir);
|
||||
bool RmDir(const wxString& dir);
|
||||
wxString Pwd();
|
||||
bool Rename(const wxString& src, const wxString& dst);
|
||||
bool RmFile(const wxString& path);
|
||||
|
||||
// Get the size of a file in the current dir.
|
||||
// this function tries its best to deliver the size in bytes using BINARY
|
||||
// (the SIZE command reports different sizes depending on whether
|
||||
// type is set to ASCII or BINARY)
|
||||
// returns -1 if file is non-existent or size could not be found
|
||||
int GetFileSize(const wxString& fileName);
|
||||
|
||||
// Check to see if a file exists in the current dir
|
||||
bool FileExists(const wxString& fileName);
|
||||
|
||||
// Download methods
|
||||
bool Abort() override;
|
||||
|
||||
virtual wxInputStream *GetInputStream(const wxString& path) override;
|
||||
virtual wxOutputStream *GetOutputStream(const wxString& path);
|
||||
|
||||
// Directory listing
|
||||
|
||||
// get the list of full filenames, the format is fixed: one file name per
|
||||
// line
|
||||
bool GetFilesList(wxArrayString& files,
|
||||
const wxString& wildcard = wxEmptyString)
|
||||
{
|
||||
return GetList(files, wildcard, false);
|
||||
}
|
||||
|
||||
// get a directory list in server dependent format - this can be shown
|
||||
// directly to the user
|
||||
bool GetDirList(wxArrayString& files,
|
||||
const wxString& wildcard = wxEmptyString)
|
||||
{
|
||||
return GetList(files, wildcard, true);
|
||||
}
|
||||
|
||||
// equivalent to either GetFilesList() (default) or GetDirList()
|
||||
bool GetList(wxArrayString& files,
|
||||
const wxString& wildcard = wxEmptyString,
|
||||
bool details = false);
|
||||
|
||||
protected:
|
||||
// this executes a simple ftp command with the given argument and returns
|
||||
// true if it its return code starts with '2'
|
||||
bool DoSimpleCommand(const wxChar *command,
|
||||
const wxString& arg = wxEmptyString);
|
||||
|
||||
// get the server reply, return the first character of the reply code,
|
||||
// '1'..'5' for normal FTP replies, 0 (*not* '0') if an error occurred
|
||||
char GetResult();
|
||||
|
||||
// check that the result is equal to expected value
|
||||
bool CheckResult(char ch) { return GetResult() == ch; }
|
||||
|
||||
// return the socket to be used, Passive/Active versions are used only by
|
||||
// GetPort()
|
||||
wxSocketBase *GetPort();
|
||||
wxSocketBase *GetPassivePort();
|
||||
wxSocketBase *GetActivePort();
|
||||
|
||||
// helper for GetPort()
|
||||
wxString GetPortCmdArgument(const wxIPV4address& Local, const wxIPV4address& New);
|
||||
|
||||
// accept connection from server in active mode, returns the same socket as
|
||||
// passed in passive mode
|
||||
wxSocketBase *AcceptIfActive(wxSocketBase *sock);
|
||||
|
||||
|
||||
// internal variables:
|
||||
|
||||
wxString m_lastResult;
|
||||
|
||||
// true if there is an FTP transfer going on
|
||||
bool m_streaming;
|
||||
|
||||
// although this should be set to ASCII by default according to STD9,
|
||||
// we will use BINARY transfer mode by default for backwards compatibility
|
||||
TransferMode m_currentTransfermode;
|
||||
|
||||
bool m_bPassive;
|
||||
|
||||
// following is true when a read or write times out, we then assume
|
||||
// the connection is dead and abort. we avoid additional delays this way
|
||||
bool m_bEncounteredError;
|
||||
|
||||
|
||||
friend class wxInputFTPStream;
|
||||
friend class wxOutputFTPStream;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFTP);
|
||||
DECLARE_PROTOCOL(wxFTP)
|
||||
};
|
||||
|
||||
// the trace mask used by assorted wxLogTrace() in ftp code, do
|
||||
// wxLog::AddTraceMask(FTP_TRACE_MASK) to see them in output
|
||||
#define FTP_TRACE_MASK wxT("ftp")
|
||||
|
||||
#endif // wxUSE_PROTOCOL_FTP
|
||||
|
||||
#endif // __WX_FTP_H__
|
||||
100
libs/wxWidgets-3.3.1/include/wx/protocol/http.h
Normal file
100
libs/wxWidgets-3.3.1/include/wx/protocol/http.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/protocol/http.h
|
||||
// Purpose: HTTP protocol
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by: Simo Virokannas (authentication, Dec 2005)
|
||||
// Created: August 1997
|
||||
// Copyright: (c) 1997, 1998 Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef _WX_HTTP_H
|
||||
#define _WX_HTTP_H
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROTOCOL_HTTP
|
||||
|
||||
#include "wx/protocol/protocol.h"
|
||||
#include "wx/buffer.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
class WXDLLIMPEXP_NET wxHTTP : public wxProtocol
|
||||
{
|
||||
public:
|
||||
wxHTTP();
|
||||
virtual ~wxHTTP();
|
||||
|
||||
virtual bool Connect(const wxString& host, unsigned short port);
|
||||
virtual bool Connect(const wxString& host) override { return Connect(host, 0); }
|
||||
virtual bool Connect(const wxSockAddress& addr, bool wait = true) override;
|
||||
bool Abort() override;
|
||||
|
||||
wxInputStream *GetInputStream(const wxString& path) override;
|
||||
|
||||
wxString GetContentType() const override;
|
||||
wxString GetHeader(const wxString& header) const;
|
||||
int GetResponse() const { return m_http_response; }
|
||||
|
||||
void SetMethod(const wxString& method) { m_method = method; }
|
||||
void SetHeader(const wxString& header, const wxString& h_data);
|
||||
bool SetPostText(const wxString& contentType,
|
||||
const wxString& data,
|
||||
const wxMBConv& conv = wxConvUTF8);
|
||||
bool SetPostBuffer(const wxString& contentType, const wxMemoryBuffer& data);
|
||||
void SetProxyMode(bool on);
|
||||
|
||||
/* Cookies */
|
||||
wxString GetCookie(const wxString& cookie) const;
|
||||
bool HasCookies() const { return m_cookies.size() > 0; }
|
||||
|
||||
// Use the other SetPostBuffer() overload or SetPostText() instead.
|
||||
wxDEPRECATED(void SetPostBuffer(const wxString& post_buf));
|
||||
|
||||
protected:
|
||||
using wxHeadersMap = std::unordered_map<wxString, wxString>;
|
||||
typedef wxHeadersMap::iterator wxHeaderIterator;
|
||||
typedef wxHeadersMap::const_iterator wxHeaderConstIterator;
|
||||
|
||||
using wxCookiesMap = std::unordered_map<wxString, wxString>;
|
||||
typedef wxCookiesMap::iterator wxCookieIterator;
|
||||
typedef wxCookiesMap::const_iterator wxCookieConstIterator;
|
||||
|
||||
bool BuildRequest(const wxString& path, const wxString& method);
|
||||
void SendHeaders();
|
||||
bool ParseHeaders();
|
||||
|
||||
wxString GenerateAuthString(const wxString& user, const wxString& pass) const;
|
||||
|
||||
// find the header in m_headers
|
||||
wxHeaderIterator FindHeader(const wxString& header);
|
||||
wxHeaderConstIterator FindHeader(const wxString& header) const;
|
||||
wxCookieIterator FindCookie(const wxString& cookie);
|
||||
wxCookieConstIterator FindCookie(const wxString& cookie) const;
|
||||
|
||||
// deletes the header value strings
|
||||
void ClearHeaders();
|
||||
void ClearCookies();
|
||||
|
||||
// internal variables:
|
||||
|
||||
wxString m_method;
|
||||
wxCookiesMap m_cookies;
|
||||
|
||||
wxHeadersMap m_headers;
|
||||
bool m_read,
|
||||
m_proxy_mode;
|
||||
wxSockAddress *m_addr;
|
||||
wxMemoryBuffer m_postBuffer;
|
||||
wxString m_contentType;
|
||||
int m_http_response;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxHTTP);
|
||||
DECLARE_PROTOCOL(wxHTTP)
|
||||
wxDECLARE_NO_COPY_CLASS(wxHTTP);
|
||||
};
|
||||
|
||||
#endif // wxUSE_PROTOCOL_HTTP
|
||||
|
||||
#endif // _WX_HTTP_H
|
||||
|
||||
54
libs/wxWidgets-3.3.1/include/wx/protocol/log.h
Normal file
54
libs/wxWidgets-3.3.1/include/wx/protocol/log.h
Normal file
@@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/protocol/log.h
|
||||
// Purpose: wxProtocolLog class for logging network exchanges
|
||||
// Author: Troelsk, Vadim Zeitlin
|
||||
// Created: 2009-03-06
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROTOCOL_LOG_H_
|
||||
#define _WX_PROTOCOL_LOG_H_
|
||||
|
||||
#include "wx/string.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxProtocolLog: simple class for logging network requests and responses
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_NET wxProtocolLog
|
||||
{
|
||||
public:
|
||||
// Create object doing the logging using wxLogTrace() with the specified
|
||||
// trace mask.
|
||||
wxProtocolLog(const wxString& traceMask)
|
||||
: m_traceMask(traceMask)
|
||||
{
|
||||
}
|
||||
|
||||
// Virtual dtor for the base class
|
||||
virtual ~wxProtocolLog() = default;
|
||||
|
||||
// Called by wxProtocol-derived classes to actually log something
|
||||
virtual void LogRequest(const wxString& str)
|
||||
{
|
||||
DoLogString(wxASCII_STR("==> ") + str);
|
||||
}
|
||||
|
||||
virtual void LogResponse(const wxString& str)
|
||||
{
|
||||
DoLogString(wxASCII_STR("<== ") + str);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Can be overridden by the derived classes.
|
||||
virtual void DoLogString(const wxString& str);
|
||||
|
||||
private:
|
||||
const wxString m_traceMask;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxProtocolLog);
|
||||
};
|
||||
|
||||
#endif // _WX_PROTOCOL_LOG_H_
|
||||
|
||||
176
libs/wxWidgets-3.3.1/include/wx/protocol/protocol.h
Normal file
176
libs/wxWidgets-3.3.1/include/wx/protocol/protocol.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/protocol/protocol.h
|
||||
// Purpose: Protocol base class
|
||||
// Author: Guilhem Lavaux
|
||||
// Created: 10/07/1997
|
||||
// Copyright: (c) 1997, 1998 Guilhem Lavaux
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PROTOCOL_PROTOCOL_H
|
||||
#define _WX_PROTOCOL_PROTOCOL_H
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_PROTOCOL
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/stream.h"
|
||||
|
||||
#if wxUSE_SOCKETS
|
||||
#include "wx/socket.h"
|
||||
#endif
|
||||
|
||||
class WXDLLIMPEXP_FWD_NET wxProtocolLog;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum wxProtocolError
|
||||
{
|
||||
wxPROTO_NOERR = 0,
|
||||
wxPROTO_NETERR,
|
||||
wxPROTO_PROTERR,
|
||||
wxPROTO_CONNERR,
|
||||
wxPROTO_INVVAL,
|
||||
wxPROTO_NOHNDLR,
|
||||
wxPROTO_NOFILE,
|
||||
wxPROTO_ABRT,
|
||||
wxPROTO_RCNCT,
|
||||
wxPROTO_STREAMING
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxProtocol: abstract base class for all protocols
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_NET wxProtocol
|
||||
#if wxUSE_SOCKETS
|
||||
: public wxSocketClient
|
||||
#else
|
||||
: public wxObject
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
wxProtocol();
|
||||
virtual ~wxProtocol();
|
||||
|
||||
#if wxUSE_SOCKETS
|
||||
bool Reconnect();
|
||||
virtual bool Connect( const wxString& WXUNUSED(host) ) { return false; }
|
||||
virtual bool Connect( const wxSockAddress& addr, bool WXUNUSED(wait) = true) override
|
||||
{ return wxSocketClient::Connect(addr); }
|
||||
|
||||
// read a '\r\n' terminated line from the given socket and put it in
|
||||
// result (without the terminators)
|
||||
static wxProtocolError ReadLine(wxSocketBase *socket, wxString& result);
|
||||
|
||||
// read a line from this socket - this one can be overridden in the
|
||||
// derived classes if different line termination convention is to be used
|
||||
virtual wxProtocolError ReadLine(wxString& result);
|
||||
#endif // wxUSE_SOCKETS
|
||||
|
||||
virtual bool Abort() = 0;
|
||||
virtual wxInputStream *GetInputStream(const wxString& path) = 0;
|
||||
virtual wxString GetContentType() const = 0;
|
||||
|
||||
// the error code
|
||||
virtual wxProtocolError GetError() const { return m_lastError; }
|
||||
|
||||
void SetUser(const wxString& user) { m_username = user; }
|
||||
void SetPassword(const wxString& passwd) { m_password = passwd; }
|
||||
|
||||
virtual void SetDefaultTimeout(wxUint32 Value);
|
||||
|
||||
// override wxSocketBase::SetTimeout function to avoid that the internal
|
||||
// m_uiDefaultTimeout goes out-of-sync:
|
||||
virtual void SetTimeout(long seconds) override
|
||||
{ SetDefaultTimeout(static_cast<wxUint32>(seconds)); }
|
||||
|
||||
|
||||
// logging support: each wxProtocol object may have the associated logger
|
||||
// (by default there is none) which is used to log network requests and
|
||||
// responses
|
||||
|
||||
// set the logger, deleting the old one and taking ownership of this one
|
||||
void SetLog(wxProtocolLog *log);
|
||||
|
||||
// return the current logger, may be null
|
||||
wxProtocolLog *GetLog() const { return m_log; }
|
||||
|
||||
// detach the existing logger without deleting it, the caller is
|
||||
// responsible for deleting the returned pointer if it's non-null
|
||||
wxProtocolLog *DetachLog()
|
||||
{
|
||||
wxProtocolLog * const log = m_log;
|
||||
m_log = nullptr;
|
||||
return log;
|
||||
}
|
||||
|
||||
// these functions forward to the same functions with the same names in
|
||||
// wxProtocolLog if we have a valid logger and do nothing otherwise
|
||||
void LogRequest(const wxString& str);
|
||||
void LogResponse(const wxString& str);
|
||||
|
||||
protected:
|
||||
// the timeout associated with the protocol:
|
||||
wxUint32 m_uiDefaultTimeout;
|
||||
|
||||
wxString m_username;
|
||||
wxString m_password;
|
||||
|
||||
// this must be always updated by the derived classes!
|
||||
wxProtocolError m_lastError;
|
||||
|
||||
private:
|
||||
wxProtocolLog *m_log;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxProtocol);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros for protocol classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define DECLARE_PROTOCOL(class) \
|
||||
public: \
|
||||
static wxProtoInfo g_proto_##class;
|
||||
|
||||
#define IMPLEMENT_PROTOCOL(class, name, serv, host) \
|
||||
wxProtoInfo class::g_proto_##class(name, serv, host, wxCLASSINFO(class)); \
|
||||
bool wxProtocolUse##class = true;
|
||||
|
||||
#define USE_PROTOCOL(class) \
|
||||
extern bool wxProtocolUse##class ; \
|
||||
static struct wxProtocolUserFor##class \
|
||||
{ \
|
||||
wxProtocolUserFor##class() { wxProtocolUse##class = true; } \
|
||||
} wxProtocolDoUse##class;
|
||||
|
||||
class WXDLLIMPEXP_NET wxProtoInfo : public wxObject
|
||||
{
|
||||
public:
|
||||
wxProtoInfo(const wxChar *name,
|
||||
const wxChar *serv_name,
|
||||
const bool need_host1,
|
||||
wxClassInfo *info);
|
||||
|
||||
protected:
|
||||
wxProtoInfo *next;
|
||||
wxString m_protoname;
|
||||
wxString prefix;
|
||||
wxString m_servname;
|
||||
wxClassInfo *m_cinfo;
|
||||
bool m_needhost;
|
||||
|
||||
friend class wxURL;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxProtoInfo);
|
||||
wxDECLARE_NO_COPY_CLASS(wxProtoInfo);
|
||||
};
|
||||
|
||||
#endif // wxUSE_PROTOCOL
|
||||
|
||||
#endif // _WX_PROTOCOL_PROTOCOL_H
|
||||
Reference in New Issue
Block a user