many wxIPC Unicode and UTF-8 fixes (use void* instead of wxChar* in the API and UTF-8 as wire format for wxStrings) (patch 1812926)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,6 +32,11 @@ changes:
|
||||
type "const char *", you need to remove wxT() or _T() around the values used
|
||||
to initialize them (which should normally always be ASCII).
|
||||
|
||||
- wxIPC classes didn't work correctly in Unicode build before, this was fixed
|
||||
but at a price of breaking backwards compatibility: many methods which used
|
||||
to work with "wxChar *" before use "void *" now (some int parameters were
|
||||
also changed to size_t). While wxIPC_TEXT can still be used to transfer 7
|
||||
bit text, the new wxIPC_UTF8TEXT format is used for transferring wxStrings.
|
||||
|
||||
|
||||
Changes in behaviour not resulting in compilation errors, please read this!
|
||||
@@ -143,6 +148,7 @@ Major new features in this release
|
||||
All:
|
||||
|
||||
- Allow loading message catalogs from wxFileSystem (Axel Gembe)
|
||||
- Use UTF-8 for Unicode data in wxIPC classes (Anders Larsen)
|
||||
- Added support for user-defined types to wxConfig (Marcin Wojdyr).
|
||||
- Added wxJoin() and wxSplit() functions (Francesco Montorsi).
|
||||
- Added wxMutex::LockTimeout() (Aleksandr Napylov).
|
||||
|
@@ -49,10 +49,17 @@ enum wxIPCFormat
|
||||
wxIPC_PENDATA = 10,
|
||||
wxIPC_RIFF = 11,
|
||||
wxIPC_WAVE = 12,
|
||||
wxIPC_UNICODETEXT = 13,
|
||||
wxIPC_UTF16TEXT = 13, /* CF_UNICODE */
|
||||
wxIPC_ENHMETAFILE = 14,
|
||||
wxIPC_FILENAME = 15, /* CF_HDROP */
|
||||
wxIPC_LOCALE = 16,
|
||||
wxIPC_UTF8TEXT = 17,
|
||||
wxIPC_UTF32TEXT = 18,
|
||||
#if SIZEOF_WCHAR_T == 2
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF16TEXT,
|
||||
#elif SIZEOF_WCHAR_T == 4
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF32TEXT,
|
||||
#endif
|
||||
wxIPC_PRIVATE = 20
|
||||
};
|
||||
\end{verbatim}
|
||||
@@ -67,7 +74,7 @@ enum wxIPCFormat
|
||||
|
||||
\func{}{wxDDEConnection}{\void}
|
||||
|
||||
\func{}{wxDDEConnection}{\param{char* }{buffer}, \param{int}{ size}}
|
||||
\func{}{wxDDEConnection}{\param{void* }{buffer}, \param{size_t}{ size}}
|
||||
|
||||
Constructs a connection object. If no user-defined connection object is
|
||||
to be derived from wxDDEConnection, then the constructor should not be
|
||||
@@ -83,7 +90,13 @@ transactions.
|
||||
|
||||
\membersection{wxDDEConnection::Advise}\label{wxddeconnectionadvise}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
|
||||
|
||||
Called by the server application to advise the client of a change in
|
||||
the data associated with the given item. Causes the client
|
||||
@@ -92,7 +105,13 @@ member to be called. Returns true if successful.
|
||||
|
||||
\membersection{wxDDEConnection::Execute}\label{wxddeconnectionexecute}
|
||||
|
||||
\func{bool}{Execute}{\param{char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Execute}{\param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Execute}{\param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Execute}{\param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Execute}{\param{const wxString& }{data}}
|
||||
|
||||
Called by the client application to execute a command on the server. Can
|
||||
also be used to transfer arbitrary data to the server (similar
|
||||
@@ -114,7 +133,7 @@ successful.
|
||||
|
||||
\membersection{wxDDEConnection::OnAdvise}\label{wxddeconnectiononadvise}
|
||||
|
||||
\func{virtual bool}{OnAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the client application when the server notifies it of a
|
||||
change in the data associated with the given item.
|
||||
@@ -129,7 +148,7 @@ to delete the connection object.
|
||||
|
||||
\membersection{wxDDEConnection::OnExecute}\label{wxddeconnectiononexecute}
|
||||
|
||||
\func{virtual bool}{OnExecute}{\param{const wxString\& }{topic}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnExecute}{\param{const wxString\& }{topic}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat}{ format}}
|
||||
|
||||
Message sent to the server application when the client notifies it to
|
||||
execute the given data. Note that there is no item associated with
|
||||
@@ -137,14 +156,14 @@ this message.
|
||||
|
||||
\membersection{wxDDEConnection::OnPoke}\label{wxddeconnectiononpoke}
|
||||
|
||||
\func{virtual bool}{OnPoke}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnPoke}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the server application when the client notifies it to
|
||||
accept the given data.
|
||||
|
||||
\membersection{wxDDEConnection::OnRequest}\label{wxddeconnectiononrequest}
|
||||
|
||||
\func{virtual const char*}{OnRequest}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{int *}{size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual const void*}{OnRequest}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{size_t * }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the server application when the client
|
||||
calls \helpref{wxDDEConnection::Request}{wxddeconnectionrequest}. The server
|
||||
@@ -170,7 +189,13 @@ this doesn't have much meaning in practice.
|
||||
|
||||
\membersection{wxDDEConnection::Poke}\label{wxddeconnectionpoke}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
|
||||
|
||||
Called by the client application to poke data into the server. Can be
|
||||
used to transfer arbitrary data to the server. Causes the server
|
||||
@@ -179,7 +204,7 @@ to be called. Returns true if successful.
|
||||
|
||||
\membersection{wxDDEConnection::Request}\label{wxddeconnectionrequest}
|
||||
|
||||
\func{char*}{Request}{\param{const wxString\& }{item}, \param{int *}{size}, \param{wxIPCFormat}{ format = wxIPC\_TEXT}}
|
||||
\func{const void*}{Request}{\param{const wxString\& }{item}, \param{size_t *}{size}, \param{wxIPCFormat }{format = wxIPC\_TEXT}}
|
||||
|
||||
Called by the client application to request data from the server. Causes
|
||||
the server connection's \helpref{wxDDEConnection::OnRequest}{wxddeconnectiononrequest} member to be called. Returns a
|
||||
|
@@ -44,10 +44,17 @@ enum wxIPCFormat
|
||||
wxIPC_PENDATA = 10,
|
||||
wxIPC_RIFF = 11,
|
||||
wxIPC_WAVE = 12,
|
||||
wxIPC_UNICODETEXT = 13,
|
||||
wxIPC_UTF16TEXT = 13, /* CF_UNICODE */
|
||||
wxIPC_ENHMETAFILE = 14,
|
||||
wxIPC_FILENAME = 15, /* CF_HDROP */
|
||||
wxIPC_LOCALE = 16,
|
||||
wxIPC_UTF8TEXT = 17,
|
||||
wxIPC_UTF32TEXT = 18,
|
||||
#if SIZEOF_WCHAR_T == 2
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF16TEXT,
|
||||
#elif SIZEOF_WCHAR_T == 4
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF32TEXT,
|
||||
#endif
|
||||
wxIPC_PRIVATE = 20
|
||||
};
|
||||
\end{verbatim}
|
||||
@@ -63,7 +70,7 @@ enum wxIPCFormat
|
||||
|
||||
\func{}{wxConnection}{\void}
|
||||
|
||||
\func{}{wxConnection}{\param{char* }{buffer}, \param{int}{ size}}
|
||||
\func{}{wxConnection}{\param{void* }{buffer}, \param{size_t}{ size}}
|
||||
|
||||
Constructs a connection object. If no user-defined connection
|
||||
object is to be derived from wxConnection, then the constructor
|
||||
@@ -84,7 +91,13 @@ mainly for backwards compatibility.
|
||||
|
||||
\membersection{wxConnection::Advise}\label{wxconnectionadvise}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
|
||||
|
||||
Called by the server application to advise the client of a change
|
||||
in the data associated with the given item. Causes the client
|
||||
@@ -93,7 +106,13 @@ to be called. Returns true if successful.
|
||||
|
||||
\membersection{wxConnection::Execute}\label{wxconnectionexecute}
|
||||
|
||||
\func{bool}{Execute}{\param{char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Execute}{\param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Execute}{\param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Execute}{\param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Execute}{\param{const wxString& }{data}}
|
||||
|
||||
Called by the client application to execute a command on the
|
||||
server. Can also be used to transfer arbitrary data to the server
|
||||
@@ -114,7 +133,7 @@ its side of the connection.
|
||||
|
||||
\membersection{wxConnection::OnAdvise}\label{wxconnectiononadvise}
|
||||
|
||||
\func{virtual bool}{OnAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the client application when the server notifies
|
||||
it of a change in the data associated with the given item, using
|
||||
@@ -133,7 +152,7 @@ the connection object is no longer available.
|
||||
|
||||
\membersection{wxConnection::OnExecute}\label{wxconnectiononexecute}
|
||||
|
||||
\func{virtual bool}{OnExecute}{\param{const wxString\& }{topic}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnExecute}{\param{const wxString\& }{topic}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat}{ format}}
|
||||
|
||||
Message sent to the server application when the client notifies
|
||||
it to execute the given data, using \helpref{Execute}{wxconnectionexecute}.
|
||||
@@ -141,14 +160,14 @@ Note that there is no item associated with this message.
|
||||
|
||||
\membersection{wxConnection::OnPoke}\label{wxconnectiononpoke}
|
||||
|
||||
\func{virtual bool}{OnPoke}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnPoke}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the server application when the client notifies it to
|
||||
accept the given data.
|
||||
|
||||
\membersection{wxConnection::OnRequest}\label{wxconnectiononrequest}
|
||||
|
||||
\func{virtual const char*}{OnRequest}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{int *}{size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual const void*}{OnRequest}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{size_t * }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the server application when the client calls
|
||||
\helpref{wxConnection::Request}{wxconnectionrequest}. The
|
||||
@@ -176,7 +195,13 @@ this doesn't have much meaning in practice.
|
||||
|
||||
\membersection{wxConnection::Poke}\label{wxconnectionpoke}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
|
||||
|
||||
Called by the client application to poke data into the server.
|
||||
Can be used to transfer arbitrary data to the server. Causes the
|
||||
@@ -188,7 +213,7 @@ Returns true if successful.
|
||||
|
||||
\membersection{wxConnection::Request}\label{wxconnectionrequest}
|
||||
|
||||
\func{char*}{Request}{\param{const wxString\& }{item}, \param{int *}{size}, \param{wxIPCFormat}{ format = wxIPC\_TEXT}}
|
||||
\func{const void*}{Request}{\param{const wxString\& }{item}, \param{size_t *}{size}, \param{wxIPCFormat }{format = wxIPC\_TEXT}}
|
||||
|
||||
Called by the client application to request data from the server.
|
||||
Causes the server connection's \helpref{wxConnection::OnRequest}{wxconnectiononrequest}
|
||||
|
@@ -48,10 +48,17 @@ enum wxIPCFormat
|
||||
wxIPC_PENDATA = 10,
|
||||
wxIPC_RIFF = 11,
|
||||
wxIPC_WAVE = 12,
|
||||
wxIPC_UNICODETEXT = 13,
|
||||
wxIPC_UTF16TEXT = 13, /* CF_UNICODE */
|
||||
wxIPC_ENHMETAFILE = 14,
|
||||
wxIPC_FILENAME = 15, /* CF_HDROP */
|
||||
wxIPC_LOCALE = 16,
|
||||
wxIPC_UTF8TEXT = 17,
|
||||
wxIPC_UTF32TEXT = 18,
|
||||
#if SIZEOF_WCHAR_T == 2
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF16TEXT,
|
||||
#elif SIZEOF_WCHAR_T == 4
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF32TEXT,
|
||||
#endif
|
||||
wxIPC_PRIVATE = 20
|
||||
};
|
||||
\end{verbatim}
|
||||
@@ -66,7 +73,7 @@ enum wxIPCFormat
|
||||
|
||||
\func{}{wxTCPConnection}{\void}
|
||||
|
||||
\func{}{wxTCPConnection}{\param{char* }{buffer}, \param{int}{ size}}
|
||||
\func{}{wxTCPConnection}{\param{void* }{buffer}, \param{size_t}{ size}}
|
||||
|
||||
Constructs a connection object. If no user-defined connection object is
|
||||
to be derived from wxTCPConnection, then the constructor should not be
|
||||
@@ -82,7 +89,13 @@ transactions.
|
||||
|
||||
\membersection{wxTCPConnection::Advise}\label{wxtcpconnectionadvise}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Advise}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
|
||||
|
||||
Called by the server application to advise the client of a change in
|
||||
the data associated with the given item. Causes the client
|
||||
@@ -91,7 +104,13 @@ member to be called. Returns true if successful.
|
||||
|
||||
\membersection{wxTCPConnection::Execute}\label{wxtcpconnectionexecute}
|
||||
|
||||
\func{bool}{Execute}{\param{char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Execute}{\param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Execute}{\param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Execute}{\param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Execute}{\param{const wxString& }{data}}
|
||||
|
||||
Called by the client application to execute a command on the server. Can
|
||||
also be used to transfer arbitrary data to the server (similar
|
||||
@@ -113,7 +132,7 @@ successful.
|
||||
|
||||
\membersection{wxTCPConnection::OnAdvise}\label{wxtcpconnectiononadvise}
|
||||
|
||||
\func{virtual bool}{OnAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnAdvise}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the client application when the server notifies it of a
|
||||
change in the data associated with the given item.
|
||||
@@ -128,7 +147,7 @@ to delete the connection object.
|
||||
|
||||
\membersection{wxTCPConnection::OnExecute}\label{wxtcpconnectiononexecute}
|
||||
|
||||
\func{virtual bool}{OnExecute}{\param{const wxString\& }{topic}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnExecute}{\param{const wxString\& }{topic}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat}{ format}}
|
||||
|
||||
Message sent to the server application when the client notifies it to
|
||||
execute the given data. Note that there is no item associated with
|
||||
@@ -136,14 +155,14 @@ this message.
|
||||
|
||||
\membersection{wxTCPConnection::OnPoke}\label{wxtcpconnectiononpoke}
|
||||
|
||||
\func{virtual bool}{OnPoke}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{char* }{data}, \param{int}{ size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual bool}{OnPoke}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the server application when the client notifies it to
|
||||
accept the given data.
|
||||
|
||||
\membersection{wxTCPConnection::OnRequest}\label{wxtcpconnectiononrequest}
|
||||
|
||||
\func{virtual const char*}{OnRequest}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{int *}{size}, \param{wxIPCFormat}{ format}}
|
||||
\func{virtual const void*}{OnRequest}{\param{const wxString\& }{topic}, \param{const wxString\& }{item}, \param{size_t *}{size}, \param{wxIPCFormat }{format}}
|
||||
|
||||
Message sent to the server application when the client
|
||||
calls \helpref{wxTCPConnection::Request}{wxtcpconnectionrequest}. The server
|
||||
@@ -169,7 +188,13 @@ this doesn't have much meaning in practice.
|
||||
|
||||
\membersection{wxTCPConnection::Poke}\label{wxtcpconnectionpoke}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{int}{ size = -1}, \param{wxIPCFormat}{ format = wxCF\_TEXT}}
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const void* }{data}, \param{size_t }{size}, \param{wxIPCFormat }{format = wxIPC\_PRIVATE}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const char* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wchar_t* }{data}, \param{size_t }{size = (size_t)-1}}
|
||||
|
||||
\func{bool}{Poke}{\param{const wxString\& }{item}, \param{const wxString& }{data}}
|
||||
|
||||
Called by the client application to poke data into the server. Can be
|
||||
used to transfer arbitrary data to the server. Causes the server
|
||||
@@ -178,7 +203,7 @@ to be called. Returns true if successful.
|
||||
|
||||
\membersection{wxTCPConnection::Request}\label{wxtcpconnectionrequest}
|
||||
|
||||
\func{char*}{Request}{\param{const wxString\& }{item}, \param{int *}{size}, \param{wxIPCFormat}{ format = wxIPC\_TEXT}}
|
||||
\func{const void*}{Request}{\param{const wxString\& }{item}, \param{size_t *}{size}, \param{wxIPCFormat }{format = wxIPC\_TEXT}}
|
||||
|
||||
Called by the client application to request data from the server. Causes
|
||||
the server connection's \helpref{wxTCPConnection::OnRequest}{wxtcpconnectiononrequest} member to be called. Returns a
|
||||
|
@@ -31,10 +31,19 @@ enum wxIPCFormat
|
||||
wxIPC_PENDATA = 10,
|
||||
wxIPC_RIFF = 11,
|
||||
wxIPC_WAVE = 12,
|
||||
wxIPC_UNICODETEXT = 13,
|
||||
wxIPC_UTF16TEXT = 13, /* CF_UNICODE */
|
||||
wxIPC_ENHMETAFILE = 14,
|
||||
wxIPC_FILENAME = 15, /* CF_HDROP */
|
||||
wxIPC_LOCALE = 16,
|
||||
wxIPC_UTF8TEXT = 17,
|
||||
wxIPC_UTF32TEXT = 18,
|
||||
#if SIZEOF_WCHAR_T == 2
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF16TEXT,
|
||||
#elif SIZEOF_WCHAR_T == 4
|
||||
wxIPC_UNICODETEXT = wxIPC_UTF32TEXT,
|
||||
#else
|
||||
# error "Unknown wchar_t size"
|
||||
#endif
|
||||
wxIPC_PRIVATE = 20
|
||||
};
|
||||
|
||||
@@ -43,51 +52,97 @@ class WXDLLIMPEXP_FWD_BASE wxClientBase;
|
||||
|
||||
class WXDLLIMPEXP_BASE wxConnectionBase: public wxObject
|
||||
{
|
||||
DECLARE_CLASS(wxConnectionBase)
|
||||
|
||||
public:
|
||||
wxConnectionBase(wxChar *buffer, int size); // use external buffer
|
||||
wxConnectionBase(void *buffer, size_t size); // use external buffer
|
||||
wxConnectionBase(); // use internal, adaptive buffer
|
||||
wxConnectionBase(const wxConnectionBase& copy);
|
||||
virtual ~wxConnectionBase(void);
|
||||
virtual ~wxConnectionBase();
|
||||
|
||||
void SetConnected( bool c ) { m_connected = c; }
|
||||
bool GetConnected() { return m_connected; }
|
||||
|
||||
// Calls that CLIENT can make
|
||||
virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0;
|
||||
// FIXME-UTF8: review this code for compatibility implications, update
|
||||
// accordingly, don' use c_str() below
|
||||
virtual bool Execute(const wxString& str)
|
||||
{ return Execute(str.c_str(), -1, wxIPC_TEXT); }
|
||||
virtual wxChar *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0;
|
||||
virtual bool Poke(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
|
||||
bool Execute(const void *data, size_t size, wxIPCFormat fmt = wxIPC_PRIVATE)
|
||||
{ return DoExecute(data, size, fmt); }
|
||||
bool Execute(const char *s, size_t size = wxNO_LEN)
|
||||
{ return DoExecute(s, size == wxNO_LEN ? strlen(s) + 1
|
||||
: size, wxIPC_TEXT); }
|
||||
bool Execute(const wchar_t *ws, size_t size = wxNO_LEN)
|
||||
{ return DoExecute(ws, size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t)
|
||||
: size, wxIPC_UNICODETEXT); }
|
||||
bool Execute(const wxString& s)
|
||||
{
|
||||
const wxUTF8Buf buf = s.utf8_str();
|
||||
return DoExecute(buf, strlen(buf) + 1, wxIPC_UTF8TEXT);
|
||||
}
|
||||
bool Execute(const wxCStrData& cs)
|
||||
{ return Execute(cs.AsString()); }
|
||||
|
||||
virtual const void *Request(const wxString& item,
|
||||
size_t *size = NULL,
|
||||
wxIPCFormat format = wxIPC_TEXT) = 0;
|
||||
|
||||
bool Poke(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat fmt = wxIPC_PRIVATE)
|
||||
{ return DoPoke(item, data, size, fmt); }
|
||||
bool Poke(const wxString& item, const char *s, size_t size = wxNO_LEN)
|
||||
{ return DoPoke(item, s, size == wxNO_LEN ? strlen(s) + 1
|
||||
: size, wxIPC_TEXT); }
|
||||
bool Poke(const wxString& item, const wchar_t *ws, size_t size = wxNO_LEN)
|
||||
{ return DoPoke(item, ws,
|
||||
size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t)
|
||||
: size, wxIPC_UNICODETEXT); }
|
||||
bool Poke(const wxString& item, const wxString s)
|
||||
{
|
||||
const wxUTF8Buf buf = s.utf8_str();
|
||||
return DoPoke(item, buf, strlen(buf) + 1, wxIPC_UTF8TEXT);
|
||||
}
|
||||
bool Poke(const wxString& item, const wxCStrData& cs)
|
||||
{ return Poke(item, cs.AsString()); }
|
||||
|
||||
virtual bool StartAdvise(const wxString& item) = 0;
|
||||
virtual bool StopAdvise(const wxString& item) = 0;
|
||||
|
||||
// Calls that SERVER can make
|
||||
virtual bool Advise(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
|
||||
bool Advise(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat fmt = wxIPC_PRIVATE)
|
||||
{ return DoAdvise(item, data, size, fmt); }
|
||||
bool Advise(const wxString& item, const char *s, size_t size = wxNO_LEN)
|
||||
{ return DoAdvise(item, s, size == wxNO_LEN ? strlen(s) + 1
|
||||
: size, wxIPC_TEXT); }
|
||||
bool Advise(const wxString& item, const wchar_t *ws, size_t size = wxNO_LEN)
|
||||
{ return DoAdvise(item, ws,
|
||||
size == wxNO_LEN ? (wcslen(ws) + 1)*sizeof(wchar_t)
|
||||
: size, wxIPC_UNICODETEXT); }
|
||||
bool Advise(const wxString& item, const wxString s)
|
||||
{
|
||||
const wxUTF8Buf buf = s.utf8_str();
|
||||
return DoAdvise(item, buf, strlen(buf) + 1, wxIPC_UTF8TEXT);
|
||||
}
|
||||
bool Advise(const wxString& item, const wxCStrData& cs)
|
||||
{ return Advise(item, cs.AsString()); }
|
||||
|
||||
// Calls that both can make
|
||||
virtual bool Disconnect(void) = 0;
|
||||
virtual bool Disconnect() = 0;
|
||||
|
||||
|
||||
// Callbacks to SERVER - override at will
|
||||
virtual bool OnExecute(const wxString& WXUNUSED(topic),
|
||||
wxChar *WXUNUSED(data),
|
||||
int WXUNUSED(size),
|
||||
const void *WXUNUSED(data),
|
||||
size_t WXUNUSED(size),
|
||||
wxIPCFormat WXUNUSED(format))
|
||||
{ return false; }
|
||||
|
||||
virtual const wxChar *OnRequest ( const wxString& WXUNUSED(topic),
|
||||
virtual const void *OnRequest(const wxString& WXUNUSED(topic),
|
||||
const wxString& WXUNUSED(item),
|
||||
int *WXUNUSED(size),
|
||||
size_t *size,
|
||||
wxIPCFormat WXUNUSED(format))
|
||||
{ return (wxChar *) NULL; }
|
||||
{ *size = 0; return NULL; }
|
||||
|
||||
virtual bool OnPoke(const wxString& WXUNUSED(topic),
|
||||
const wxString& WXUNUSED(item),
|
||||
wxChar *WXUNUSED(data),
|
||||
int WXUNUSED(size),
|
||||
const void *WXUNUSED(data),
|
||||
size_t WXUNUSED(size),
|
||||
wxIPCFormat WXUNUSED(format))
|
||||
{ return false; }
|
||||
|
||||
@@ -102,54 +157,60 @@ public:
|
||||
// Callbacks to CLIENT - override at will
|
||||
virtual bool OnAdvise(const wxString& WXUNUSED(topic),
|
||||
const wxString& WXUNUSED(item),
|
||||
wxChar *WXUNUSED(data),
|
||||
int WXUNUSED(size),
|
||||
const void *WXUNUSED(data),
|
||||
size_t WXUNUSED(size),
|
||||
wxIPCFormat WXUNUSED(format))
|
||||
{ return false; }
|
||||
|
||||
// Callbacks to BOTH - override at will
|
||||
// Default behaviour is to delete connection and return true
|
||||
virtual bool OnDisconnect(void) = 0;
|
||||
// Callbacks to BOTH
|
||||
virtual bool OnDisconnect() { delete this; return true; }
|
||||
|
||||
|
||||
// return a buffer at least this size, reallocating buffer if needed
|
||||
// returns NULL if using an inadequate user buffer - it can't be resized
|
||||
wxChar * GetBufferAtLeast( size_t bytes );
|
||||
// returns NULL if using an inadequate user buffer which can't be resized
|
||||
void *GetBufferAtLeast(size_t bytes);
|
||||
|
||||
protected:
|
||||
bool m_connected;
|
||||
virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format) = 0;
|
||||
virtual bool DoPoke(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat format) = 0;
|
||||
virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat format) = 0;
|
||||
|
||||
|
||||
private:
|
||||
wxChar * m_buffer;
|
||||
char *m_buffer;
|
||||
size_t m_buffersize;
|
||||
bool m_deletebufferwhendone;
|
||||
|
||||
// can't use DECLARE_NO_COPY_CLASS(wxConnectionBase) because we already
|
||||
// have copy ctor but still forbid the default assignment operator
|
||||
wxConnectionBase& operator=(const wxConnectionBase&);
|
||||
protected:
|
||||
bool m_connected;
|
||||
|
||||
DECLARE_NO_ASSIGN_CLASS(wxConnectionBase);
|
||||
DECLARE_CLASS(wxConnectionBase)
|
||||
};
|
||||
|
||||
|
||||
class WXDLLIMPEXP_BASE wxServerBase : public wxObject
|
||||
{
|
||||
DECLARE_CLASS(wxServerBase)
|
||||
|
||||
public:
|
||||
inline wxServerBase(void) {}
|
||||
inline ~wxServerBase(void) {}
|
||||
wxServerBase() { }
|
||||
virtual ~wxServerBase() { }
|
||||
|
||||
// Returns false on error (e.g. port number is already in use)
|
||||
virtual bool Create(const wxString& serverName) = 0;
|
||||
|
||||
// Callbacks to SERVER - override at will
|
||||
virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) = 0;
|
||||
|
||||
DECLARE_CLASS(wxServerBase)
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_BASE wxClientBase : public wxObject
|
||||
{
|
||||
DECLARE_CLASS(wxClientBase)
|
||||
|
||||
public:
|
||||
inline wxClientBase(void) {}
|
||||
inline ~wxClientBase(void) {}
|
||||
wxClientBase() { }
|
||||
virtual ~wxClientBase() { }
|
||||
|
||||
virtual bool ValidHost(const wxString& host) = 0;
|
||||
|
||||
@@ -159,8 +220,9 @@ public:
|
||||
const wxString& topic) = 0;
|
||||
|
||||
// Callbacks to CLIENT - override at will
|
||||
virtual wxConnectionBase *OnMakeConnection(void) = 0;
|
||||
virtual wxConnectionBase *OnMakeConnection() = 0;
|
||||
|
||||
DECLARE_CLASS(wxClientBase)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_IPCBASEH__
|
||||
#endif // _WX_IPCBASEH__
|
||||
|
@@ -43,31 +43,25 @@ class WXDLLIMPEXP_FWD_BASE wxDDEClient;
|
||||
|
||||
class WXDLLIMPEXP_BASE wxDDEConnection : public wxConnectionBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDDEConnection)
|
||||
public:
|
||||
wxDDEConnection(wxChar *buffer, int size); // use external buffer
|
||||
wxDDEConnection(void *buffer, size_t size); // use external buffer
|
||||
wxDDEConnection(); // use internal buffer
|
||||
virtual ~wxDDEConnection(void);
|
||||
virtual ~wxDDEConnection();
|
||||
|
||||
// Calls that CLIENT can make
|
||||
virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
// FIXME-UTF8: change Execute() to DoExecute() to avoid having to do this;
|
||||
// don't use c_str() below after removing ANSI build
|
||||
virtual bool Execute(const wxString& str)
|
||||
{ return Execute(str.c_str(), -1, wxIPC_TEXT); }
|
||||
virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool Poke(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
// implement base class pure virtual methods
|
||||
virtual const void *Request(const wxString& item,
|
||||
size_t *size = NULL,
|
||||
wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool StartAdvise(const wxString& item);
|
||||
virtual bool StopAdvise(const wxString& item);
|
||||
virtual bool Disconnect();
|
||||
|
||||
// Calls that SERVER can make
|
||||
virtual bool Advise(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
|
||||
// Calls that both can make
|
||||
virtual bool Disconnect(void);
|
||||
|
||||
// Default behaviour is to delete connection and return true
|
||||
virtual bool OnDisconnect(void);
|
||||
protected:
|
||||
virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
|
||||
virtual bool DoPoke(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat format);
|
||||
virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat format);
|
||||
|
||||
public:
|
||||
wxString m_topicName;
|
||||
@@ -75,73 +69,70 @@ public:
|
||||
wxDDEClient* m_client;
|
||||
|
||||
WXHCONV m_hConv;
|
||||
const wxChar* m_sendingData;
|
||||
const void* m_sendingData;
|
||||
int m_dataSize;
|
||||
wxIPCFormat m_dataType;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDDEConnection)
|
||||
DECLARE_DYNAMIC_CLASS(wxDDEConnection)
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_BASE wxDDEServer : public wxServerBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDDEServer)
|
||||
public:
|
||||
wxDDEServer();
|
||||
bool Create(const wxString& server_name);
|
||||
virtual ~wxDDEServer();
|
||||
|
||||
wxDDEServer(void);
|
||||
virtual ~wxDDEServer(void);
|
||||
bool Create(const wxString& server_name); // Returns false if can't create server (e.g. port
|
||||
// number is already in use)
|
||||
virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Implementation
|
||||
|
||||
// Find/delete wxDDEConnection corresponding to the HCONV
|
||||
wxDDEConnection *FindConnection(WXHCONV conv);
|
||||
bool DeleteConnection(WXHCONV conv);
|
||||
inline wxString& GetServiceName(void) const { return (wxString&) m_serviceName; }
|
||||
inline wxDDEConnectionList& GetConnections(void) const
|
||||
{
|
||||
return (wxDDEConnectionList&) m_connections;
|
||||
}
|
||||
wxString& GetServiceName() const { return (wxString&) m_serviceName; }
|
||||
|
||||
wxDDEConnectionList& GetConnections() const
|
||||
{ return (wxDDEConnectionList&) m_connections; }
|
||||
|
||||
protected:
|
||||
int m_lastError;
|
||||
wxString m_serviceName;
|
||||
wxDDEConnectionList m_connections;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxDDEServer)
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_BASE wxDDEClient: public wxClientBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDDEClient)
|
||||
public:
|
||||
wxDDEClient(void);
|
||||
virtual ~wxDDEClient(void);
|
||||
bool ValidHost(const wxString& host);
|
||||
virtual wxConnectionBase *MakeConnection(const wxString& host, const wxString& server, const wxString& topic);
|
||||
// Call this to make a connection.
|
||||
// Returns NULL if cannot.
|
||||
virtual wxConnectionBase *OnMakeConnection(void); // Tailor this to return own connection.
|
||||
wxDDEClient();
|
||||
virtual ~wxDDEClient();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Implementation
|
||||
bool ValidHost(const wxString& host);
|
||||
|
||||
// Call this to make a connection. Returns NULL if cannot.
|
||||
virtual wxConnectionBase *MakeConnection(const wxString& host,
|
||||
const wxString& server,
|
||||
const wxString& topic);
|
||||
|
||||
// Tailor this to return own connection.
|
||||
virtual wxConnectionBase *OnMakeConnection();
|
||||
|
||||
// Find/delete wxDDEConnection corresponding to the HCONV
|
||||
wxDDEConnection *FindConnection(WXHCONV conv);
|
||||
bool DeleteConnection(WXHCONV conv);
|
||||
|
||||
inline wxDDEConnectionList& GetConnections(void) const
|
||||
{
|
||||
return (wxDDEConnectionList&) m_connections;
|
||||
}
|
||||
wxDDEConnectionList& GetConnections() const
|
||||
{ return (wxDDEConnectionList&) m_connections; }
|
||||
|
||||
protected:
|
||||
int m_lastError;
|
||||
wxDDEConnectionList m_connections;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxDDEClient)
|
||||
};
|
||||
|
||||
void WXDLLIMPEXP_BASE wxDDEInitialize();
|
||||
void WXDLLIMPEXP_BASE wxDDECleanUp();
|
||||
|
||||
#endif
|
||||
// _WX_DDE_H_
|
||||
#endif // _WX_DDE_H_
|
||||
|
@@ -54,40 +54,31 @@ class WXDLLIMPEXP_FWD_NET wxTCPClient;
|
||||
|
||||
class WXDLLIMPEXP_NET wxTCPConnection : public wxConnectionBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxTCPConnection)
|
||||
|
||||
public:
|
||||
wxTCPConnection(wxChar *buffer, int size);
|
||||
wxTCPConnection(void *buffer, size_t size);
|
||||
wxTCPConnection();
|
||||
virtual ~wxTCPConnection();
|
||||
|
||||
// Calls that CLIENT can make
|
||||
virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool Poke(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool StartAdvise(const wxString& item);
|
||||
virtual bool StopAdvise(const wxString& item);
|
||||
|
||||
// Calls that SERVER can make
|
||||
virtual bool Advise(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
|
||||
// Calls that both can make
|
||||
virtual bool Disconnect(void);
|
||||
|
||||
// Callbacks to BOTH - override at will
|
||||
// Default behaviour is to delete connection and return true
|
||||
virtual bool OnDisconnect(void) { delete this; return true; }
|
||||
|
||||
// To enable the compressor (NOTE: not implemented!)
|
||||
void Compress(bool on);
|
||||
|
||||
// unhide the Execute overload from wxConnectionBase
|
||||
// FIXME-UTF8: change Execute() to DoExecute() to avoid having to do this;
|
||||
// don't use c_str() below after removing ANSI build
|
||||
virtual bool Execute(const wxString& str)
|
||||
{ return Execute(str.c_str(), -1, wxIPC_TEXT); }
|
||||
|
||||
// implement base class pure virtual methods
|
||||
virtual const void *Request(const wxString& item,
|
||||
size_t *size = NULL,
|
||||
wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool StartAdvise(const wxString& item);
|
||||
virtual bool StopAdvise(const wxString& item);
|
||||
virtual bool Disconnect(void);
|
||||
|
||||
protected:
|
||||
virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
|
||||
virtual bool DoPoke(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat format);
|
||||
virtual bool DoAdvise(const wxString& item, const void *data, size_t size,
|
||||
wxIPCFormat format);
|
||||
|
||||
|
||||
wxSocketBase *m_sock;
|
||||
wxSocketStream *m_sockstrm;
|
||||
wxDataInputStream *m_codeci;
|
||||
@@ -99,22 +90,22 @@ protected:
|
||||
friend class wxTCPEventHandler;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxTCPConnection)
|
||||
DECLARE_DYNAMIC_CLASS(wxTCPConnection)
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_NET wxTCPServer : public wxServerBase
|
||||
{
|
||||
public:
|
||||
wxTCPConnection *topLevelConnection;
|
||||
|
||||
wxTCPServer();
|
||||
virtual ~wxTCPServer();
|
||||
|
||||
// Returns false on error (e.g. port number is already in use)
|
||||
virtual bool Create(const wxString& serverName);
|
||||
|
||||
// Callbacks to SERVER - override at will
|
||||
virtual wxConnectionBase *OnAcceptConnection(const wxString& topic);
|
||||
|
||||
wxTCPConnection *topLevelConnection;
|
||||
|
||||
protected:
|
||||
wxSocketServer *m_server;
|
||||
|
||||
|
@@ -89,7 +89,7 @@
|
||||
#define TEST_WCHAR
|
||||
#define TEST_ZIP
|
||||
#else // #if TEST_ALL
|
||||
#define TEST_MIME
|
||||
#define TEST_CMDLINE
|
||||
#endif
|
||||
|
||||
// some tests are interactive, define this to run them
|
||||
@@ -4273,19 +4273,19 @@ int main(int argc, char **argv)
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
static const wxCmdLineEntryDesc cmdLineDesc[] =
|
||||
{
|
||||
{ wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show this help message"),
|
||||
{ wxCMD_LINE_SWITCH, "h", "help", "show this help message",
|
||||
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
|
||||
{ wxCMD_LINE_SWITCH, _T("v"), _T("verbose"), _T("be verbose") },
|
||||
{ wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet") },
|
||||
{ wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },
|
||||
{ wxCMD_LINE_SWITCH, "q", "quiet", "be quiet" },
|
||||
|
||||
{ wxCMD_LINE_OPTION, _T("o"), _T("output"), _T("output file") },
|
||||
{ wxCMD_LINE_OPTION, _T("i"), _T("input"), _T("input dir") },
|
||||
{ wxCMD_LINE_OPTION, _T("s"), _T("size"), _T("output block size"),
|
||||
{ wxCMD_LINE_OPTION, "o", "output", "output file" },
|
||||
{ wxCMD_LINE_OPTION, "i", "input", "input dir" },
|
||||
{ wxCMD_LINE_OPTION, "s", "size", "output block size",
|
||||
wxCMD_LINE_VAL_NUMBER },
|
||||
{ wxCMD_LINE_OPTION, _T("d"), _T("date"), _T("output file date"),
|
||||
{ wxCMD_LINE_OPTION, "d", "date", "output file date",
|
||||
wxCMD_LINE_VAL_DATE },
|
||||
|
||||
{ wxCMD_LINE_PARAM, NULL, NULL, _T("input file"),
|
||||
{ wxCMD_LINE_PARAM, NULL, NULL, "input file",
|
||||
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE },
|
||||
|
||||
{ wxCMD_LINE_NONE }
|
||||
|
@@ -337,14 +337,14 @@ void MyFrame::OnExecute(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString s = _T("Date");
|
||||
|
||||
m_client->GetConnection()->Execute((const wxChar *)s.c_str());
|
||||
m_client->GetConnection()->Execute((const wxChar *)s.c_str(), (s.Length() + 1) * sizeof(wxChar));
|
||||
m_client->GetConnection()->Execute(s);
|
||||
m_client->GetConnection()->Execute((const char *)s.c_str(), s.length() + 1);
|
||||
#if wxUSE_DDE_FOR_IPC
|
||||
wxLogMessage(_T("DDE Execute can only be used to send text strings, not arbitrary data.\nThe type argument will be ignored, text truncated, converted to Unicode and null terminated."));
|
||||
#endif
|
||||
char bytes[3];
|
||||
bytes[0] = '1'; bytes[1] = '2'; bytes[2] = '3';
|
||||
m_client->GetConnection()->Execute((wxChar *)bytes, 3, wxIPC_PRIVATE);
|
||||
m_client->GetConnection()->Execute(bytes, 3, wxIPC_PRIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,12 +353,12 @@ void MyFrame::OnPoke(wxCommandEvent& WXUNUSED(event))
|
||||
if (m_client->IsConnected())
|
||||
{
|
||||
wxString s = wxDateTime::Now().Format();
|
||||
m_client->GetConnection()->Poke(_T("Date"), (const wxChar *)s.c_str());
|
||||
m_client->GetConnection()->Poke(_T("Date"), s);
|
||||
s = wxDateTime::Now().FormatTime() + _T(" ") + wxDateTime::Now().FormatDate();
|
||||
m_client->GetConnection()->Poke(_T("Date"), (const wxChar *)s.c_str(), (s.Length() + 1) * sizeof(wxChar));
|
||||
m_client->GetConnection()->Poke(_T("Date"), (const char *)s.c_str(), s.length() + 1);
|
||||
char bytes[3];
|
||||
bytes[0] = '1'; bytes[1] = '2'; bytes[2] = '3';
|
||||
m_client->GetConnection()->Poke(_T("bytes[3]"), (wxChar *)bytes, 3, wxIPC_PRIVATE);
|
||||
m_client->GetConnection()->Poke(_T("bytes[3]"), bytes, 3, wxIPC_PRIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ void MyFrame::OnRequest(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (m_client->IsConnected())
|
||||
{
|
||||
int size;
|
||||
size_t size;
|
||||
m_client->GetConnection()->Request(_T("Date"));
|
||||
m_client->GetConnection()->Request(_T("Date+len"), &size);
|
||||
m_client->GetConnection()->Request(_T("bytes[3]"), &size, wxIPC_PRIVATE);
|
||||
@@ -417,7 +417,7 @@ MyClient::~MyClient()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void MyConnection::Log(const wxString& command, const wxString& topic,
|
||||
const wxString& item, const wxChar *data, int size, wxIPCFormat format)
|
||||
const wxString& item, const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
wxString s;
|
||||
if (topic.IsEmpty() && item.IsEmpty())
|
||||
@@ -429,10 +429,17 @@ void MyConnection::Log(const wxString& command, const wxString& topic,
|
||||
else
|
||||
s.Printf(_T("%s(topic=\"%s\",item=\"%s\","), command.c_str(), topic.c_str(), item.c_str());
|
||||
|
||||
if (format == wxIPC_TEXT || format == wxIPC_UNICODETEXT)
|
||||
wxLogMessage(_T("%s\"%s\",%d)"), s.c_str(), data, size);
|
||||
else if (format == wxIPC_PRIVATE)
|
||||
switch (format)
|
||||
{
|
||||
case wxIPC_TEXT:
|
||||
case wxIPC_UTF8TEXT:
|
||||
#if !wxUSE_UNICODE || wxUSE_UNICODE_UTF8
|
||||
wxLogMessage(_T("%s\"%s\",%d)"), s.c_str(), data, size);
|
||||
#else
|
||||
wxLogMessage(_T("%s\"%s\",%d)"), s.c_str(), wxConvUTF8.cMB2WC((const char*)data), size);
|
||||
#endif
|
||||
break;
|
||||
case wxIPC_PRIVATE:
|
||||
if (size == 3)
|
||||
{
|
||||
char *bytes = (char *)data;
|
||||
@@ -440,13 +447,18 @@ void MyConnection::Log(const wxString& command, const wxString& topic,
|
||||
}
|
||||
else
|
||||
wxLogMessage(_T("%s...,%d)"), s.c_str(), size);
|
||||
}
|
||||
else if (format == wxIPC_INVALID)
|
||||
break;
|
||||
case wxIPC_INVALID:
|
||||
wxLogMessage(_T("%s[invalid data],%d)"), s.c_str(), size);
|
||||
break;
|
||||
default:
|
||||
wxLogMessage(_T("%s[unknown data],%d)"), s.c_str(), size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool MyConnection::OnAdvise(const wxString& topic, const wxString& item, wxChar *data,
|
||||
int size, wxIPCFormat format)
|
||||
bool MyConnection::OnAdvise(const wxString& topic, const wxString& item, const void *data,
|
||||
size_t size, wxIPCFormat format)
|
||||
{
|
||||
Log(_T("OnAdvise"), topic, item, data, size, format);
|
||||
return true;
|
||||
@@ -459,24 +471,24 @@ bool MyConnection::OnDisconnect()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyConnection::Execute(const wxChar *data, int size, wxIPCFormat format)
|
||||
bool MyConnection::DoExecute(const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
Log(_T("Execute"), wxEmptyString, wxEmptyString, (wxChar *)data, size, format);
|
||||
bool retval = wxConnection::Execute(data, size, format);
|
||||
Log(_T("Execute"), wxEmptyString, wxEmptyString, data, size, format);
|
||||
bool retval = wxConnection::DoExecute(data, size, format);
|
||||
if (!retval)
|
||||
wxLogMessage(_T("Execute failed!"));
|
||||
return retval;
|
||||
}
|
||||
|
||||
wxChar *MyConnection::Request(const wxString& item, int *size, wxIPCFormat format)
|
||||
const void *MyConnection::Request(const wxString& item, size_t *size, wxIPCFormat format)
|
||||
{
|
||||
wxChar *data = wxConnection::Request(item, size, format);
|
||||
Log(_T("Request"), wxEmptyString, item, data, size ? *size : -1, format);
|
||||
const void *data = wxConnection::Request(item, size, format);
|
||||
Log(_T("Request"), wxEmptyString, item, data, size ? *size : wxNO_LEN, format);
|
||||
return data;
|
||||
}
|
||||
|
||||
bool MyConnection::Poke(const wxString& item, const wxChar *data, int size, wxIPCFormat format)
|
||||
bool MyConnection::DoPoke(const wxString& item, const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
Log(_T("Poke"), wxEmptyString, item, data, size, format);
|
||||
return wxConnection::Poke(item, data, size, format);
|
||||
return wxConnection::DoPoke(item, data, size, format);
|
||||
}
|
||||
|
@@ -81,14 +81,14 @@ protected:
|
||||
class MyConnection: public wxConnection
|
||||
{
|
||||
public:
|
||||
virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool Poke(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool OnAdvise(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format);
|
||||
virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format);
|
||||
virtual const void *Request(const wxString& item, size_t *size = NULL, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool DoPoke(const wxString& item, const void* data, size_t size, wxIPCFormat format);
|
||||
virtual bool OnAdvise(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
|
||||
virtual bool OnDisconnect();
|
||||
protected:
|
||||
void Log(const wxString& command, const wxString& topic,
|
||||
const wxString& item, const wxChar *data, int size, wxIPCFormat format);
|
||||
const wxString& item, const void *data, size_t size, wxIPCFormat format);
|
||||
};
|
||||
|
||||
class MyClient: public wxClient
|
||||
|
@@ -285,18 +285,18 @@ void MyServer::Advise()
|
||||
if (CanAdvise())
|
||||
{
|
||||
wxString s = wxDateTime::Now().Format();
|
||||
m_connection->Advise(m_connection->m_sAdvise, s.c_str());
|
||||
m_connection->Advise(m_connection->m_sAdvise, s);
|
||||
s = wxDateTime::Now().FormatTime() + _T(" ") + wxDateTime::Now().FormatDate();
|
||||
m_connection->Advise(m_connection->m_sAdvise, s.c_str(), (s.Length() + 1) * sizeof(wxChar));
|
||||
m_connection->Advise(m_connection->m_sAdvise, (const char *)s.c_str(), s.Length() + 1);
|
||||
|
||||
#if wxUSE_DDE_FOR_IPC
|
||||
wxLogMessage(_T("DDE Advise type argument cannot be wxIPC_PRIVATE. The client will receive it as wxIPC_TEXT, and receive the correct no of bytes, but not print a correct log entry."));
|
||||
#endif
|
||||
char bytes[3];
|
||||
bytes[0] = '1'; bytes[1] = '2'; bytes[2] = '3';
|
||||
m_connection->Advise(m_connection->m_sAdvise, (wxChar *)bytes, 3, wxIPC_PRIVATE);
|
||||
m_connection->Advise(m_connection->m_sAdvise, bytes, 3, wxIPC_PRIVATE);
|
||||
// this works, but the log treats it as a string now
|
||||
// m_connection->Advise(m_connection->m_sAdvise, (wxChar *)bytes, 3, wxIPC_TEXT );
|
||||
// m_connection->Advise(m_connection->m_sAdvise, bytes, 3, wxIPC_TEXT );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,34 +314,34 @@ MyConnection::~MyConnection()
|
||||
}
|
||||
|
||||
bool MyConnection::OnExecute(const wxString& topic,
|
||||
wxChar *data, int size, wxIPCFormat format)
|
||||
const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
Log(_T("OnExecute"), topic, _T(""), data, size, format);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyConnection::OnPoke(const wxString& topic,
|
||||
const wxString& item, wxChar *data, int size, wxIPCFormat format)
|
||||
const wxString& item, const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
Log(_T("OnPoke"), topic, item, data, size, format);
|
||||
return wxConnection::OnPoke(topic, item, data, size, format);
|
||||
}
|
||||
|
||||
const wxChar *MyConnection::OnRequest(const wxString& topic,
|
||||
const wxString& item, int * size, wxIPCFormat format)
|
||||
const void *MyConnection::OnRequest(const wxString& topic,
|
||||
const wxString& item, size_t *size, wxIPCFormat format)
|
||||
{
|
||||
const wxChar *data;
|
||||
const void *data;
|
||||
if (item == _T("Date"))
|
||||
{
|
||||
m_sRequestDate = wxDateTime::Now().Format();
|
||||
data = m_sRequestDate.c_str();
|
||||
*size = -1;
|
||||
*size = wxNO_LEN;
|
||||
}
|
||||
else if (item == _T("Date+len"))
|
||||
{
|
||||
m_sRequestDate = wxDateTime::Now().FormatTime() + _T(" ") + wxDateTime::Now().FormatDate();
|
||||
data = m_sRequestDate.c_str();
|
||||
*size = (m_sRequestDate.Length() + 1) * sizeof(wxChar);
|
||||
*size = m_sRequestDate.Length() + 1;
|
||||
}
|
||||
else if (item == _T("bytes[3]"))
|
||||
{
|
||||
@@ -379,7 +379,7 @@ bool MyConnection::OnStopAdvise(const wxString& topic,
|
||||
}
|
||||
|
||||
void MyConnection::Log(const wxString& command, const wxString& topic,
|
||||
const wxString& item, const wxChar *data, int size, wxIPCFormat format)
|
||||
const wxString& item, const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
wxString s;
|
||||
if (topic.IsEmpty() && item.IsEmpty())
|
||||
@@ -391,10 +391,17 @@ void MyConnection::Log(const wxString& command, const wxString& topic,
|
||||
else
|
||||
s.Printf(_T("%s(\"%s\",\"%s\","), command.c_str(), topic.c_str(), item.c_str());
|
||||
|
||||
if (format == wxIPC_TEXT || format == wxIPC_UNICODETEXT)
|
||||
wxLogMessage(_T("%s\"%s\",%d)"), s.c_str(), data, size);
|
||||
else if (format == wxIPC_PRIVATE)
|
||||
switch (format)
|
||||
{
|
||||
case wxIPC_TEXT:
|
||||
case wxIPC_UTF8TEXT:
|
||||
#if !wxUSE_UNICODE || wxUSE_UNICODE_UTF8
|
||||
wxLogMessage(_T("%s\"%s\",%d)"), s.c_str(), data, size);
|
||||
#else
|
||||
wxLogMessage(_T("%s\"%s\",%d)"), s.c_str(), wxConvUTF8.cMB2WC((const char*)data), size);
|
||||
#endif
|
||||
break;
|
||||
case wxIPC_PRIVATE:
|
||||
if (size == 3)
|
||||
{
|
||||
char *bytes = (char *)data;
|
||||
@@ -402,15 +409,20 @@ void MyConnection::Log(const wxString& command, const wxString& topic,
|
||||
}
|
||||
else
|
||||
wxLogMessage(_T("%s...,%d)"), s.c_str(), size);
|
||||
}
|
||||
else if (format == wxIPC_INVALID)
|
||||
break;
|
||||
case wxIPC_INVALID:
|
||||
wxLogMessage(_T("%s[invalid data],%d)"), s.c_str(), size);
|
||||
break;
|
||||
default:
|
||||
wxLogMessage(_T("%s[unknown data],%d)"), s.c_str(), size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool MyConnection::Advise(const wxString& item, const wxChar *data, int size, wxIPCFormat format)
|
||||
bool MyConnection::DoAdvise(const wxString& item, const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
Log(_T("Advise"), _T(""), item, data, size, format);
|
||||
return wxConnection::Advise(item, data, size, format);
|
||||
return wxConnection::DoAdvise(item, data, size, format);
|
||||
}
|
||||
|
||||
bool MyConnection::OnDisconnect()
|
||||
|
@@ -69,15 +69,15 @@ public:
|
||||
MyConnection();
|
||||
~MyConnection();
|
||||
|
||||
virtual bool OnExecute(const wxString& topic, wxChar *data, int size, wxIPCFormat format);
|
||||
virtual const wxChar *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format);
|
||||
virtual bool OnPoke(const wxString& topic, const wxString& item, wxChar *data, int size, wxIPCFormat format);
|
||||
virtual bool OnExecute(const wxString& topic, const void *data, size_t size, wxIPCFormat format);
|
||||
virtual const void *OnRequest(const wxString& topic, const wxString& item, size_t *size, wxIPCFormat format);
|
||||
virtual bool OnPoke(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
|
||||
virtual bool OnStartAdvise(const wxString& topic, const wxString& item);
|
||||
virtual bool OnStopAdvise(const wxString& topic, const wxString& item);
|
||||
virtual bool Advise(const wxString& item, const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
|
||||
virtual bool DoAdvise(const wxString& item, const void *data, size_t size, wxIPCFormat format);
|
||||
virtual bool OnDisconnect();
|
||||
protected:
|
||||
void Log(const wxString& command, const wxString& topic, const wxString& item, const wxChar *data, int size, wxIPCFormat format);
|
||||
void Log(const wxString& command, const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format);
|
||||
public:
|
||||
wxString m_sAdvise;
|
||||
protected:
|
||||
|
@@ -25,13 +25,13 @@ IMPLEMENT_CLASS(wxServerBase, wxObject)
|
||||
IMPLEMENT_CLASS(wxClientBase, wxObject)
|
||||
IMPLEMENT_CLASS(wxConnectionBase, wxObject)
|
||||
|
||||
wxConnectionBase::wxConnectionBase(wxChar *buffer, int bytes)
|
||||
: m_connected(true),
|
||||
m_buffer(buffer),
|
||||
wxConnectionBase::wxConnectionBase(void *buffer, size_t bytes)
|
||||
: m_buffer((char *)buffer),
|
||||
m_buffersize(bytes),
|
||||
m_deletebufferwhendone(false)
|
||||
m_deletebufferwhendone(false),
|
||||
m_connected(true)
|
||||
{
|
||||
if ( buffer == (wxChar *)NULL )
|
||||
if ( buffer == NULL )
|
||||
{ // behave like next constructor
|
||||
m_buffersize = 0;
|
||||
m_deletebufferwhendone = true;
|
||||
@@ -39,19 +39,19 @@ wxConnectionBase::wxConnectionBase(wxChar *buffer, int bytes)
|
||||
}
|
||||
|
||||
wxConnectionBase::wxConnectionBase()
|
||||
: m_connected(true),
|
||||
m_buffer(NULL),
|
||||
: m_buffer(NULL),
|
||||
m_buffersize(0),
|
||||
m_deletebufferwhendone(true)
|
||||
m_deletebufferwhendone(true),
|
||||
m_connected(true)
|
||||
{
|
||||
}
|
||||
|
||||
wxConnectionBase::wxConnectionBase(const wxConnectionBase& copy)
|
||||
: wxObject(),
|
||||
m_connected(copy.m_connected),
|
||||
m_buffer(copy.m_buffer),
|
||||
m_buffersize(copy.m_buffersize),
|
||||
m_deletebufferwhendone(false)
|
||||
m_deletebufferwhendone(false),
|
||||
m_connected(copy.m_connected)
|
||||
|
||||
{
|
||||
// copy constructor would require ref-counted pointer to buffer
|
||||
@@ -65,7 +65,7 @@ wxConnectionBase::~wxConnectionBase(void)
|
||||
delete m_buffer;
|
||||
}
|
||||
|
||||
wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
|
||||
void *wxConnectionBase::GetBufferAtLeast( size_t bytes )
|
||||
{
|
||||
if ( m_buffersize >= bytes )
|
||||
return m_buffer;
|
||||
@@ -75,10 +75,7 @@ wxChar *wxConnectionBase::GetBufferAtLeast( size_t bytes )
|
||||
{ // we're in charge of buffer, increase it
|
||||
if ( m_buffer )
|
||||
delete m_buffer;
|
||||
// the argument specifies **byte size**, but m_buffer is of type
|
||||
// wxChar. Under unicode: sizeof(wxChar) > 1, so the buffer size is
|
||||
// bytes / sizeof(wxChar) rounded upwards.
|
||||
m_buffer = new wxChar[(bytes + sizeof(wxChar) - 1) / sizeof(wxChar)];
|
||||
m_buffer = new char[bytes];
|
||||
m_buffersize = bytes;
|
||||
return m_buffer;
|
||||
} // user-supplied buffer, fail
|
||||
|
@@ -344,7 +344,7 @@ wxTCPConnection::wxTCPConnection () : wxConnectionBase()
|
||||
m_codeco = NULL;
|
||||
}
|
||||
|
||||
wxTCPConnection::wxTCPConnection(wxChar *buffer, int size)
|
||||
wxTCPConnection::wxTCPConnection(void *buffer, size_t size)
|
||||
: wxConnectionBase(buffer, size)
|
||||
{
|
||||
m_sock = NULL;
|
||||
@@ -393,7 +393,7 @@ bool wxTCPConnection::Disconnect ()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTCPConnection::Execute(const wxChar *data, int size, wxIPCFormat format)
|
||||
bool wxTCPConnection::DoExecute(const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
if (!m_sock->IsConnected())
|
||||
return false;
|
||||
@@ -402,16 +402,13 @@ bool wxTCPConnection::Execute(const wxChar *data, int size, wxIPCFormat format)
|
||||
m_codeco->Write8(IPC_EXECUTE);
|
||||
m_codeco->Write8(format);
|
||||
|
||||
if (size < 0)
|
||||
size = (wxStrlen(data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
|
||||
m_codeco->Write32(size);
|
||||
m_sockstrm->Write(data, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxChar *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat format)
|
||||
const void *wxTCPConnection::Request (const wxString& item, size_t *size, wxIPCFormat format)
|
||||
{
|
||||
if (!m_sock->IsConnected())
|
||||
return NULL;
|
||||
@@ -428,11 +425,9 @@ wxChar *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat f
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
size_t s;
|
||||
size_t s = m_codeci->Read32();
|
||||
|
||||
s = m_codeci->Read32();
|
||||
|
||||
wxChar *data = GetBufferAtLeast( s );
|
||||
void *data = GetBufferAtLeast( s );
|
||||
wxASSERT_MSG(data != NULL,
|
||||
_T("Buffer too small in wxTCPConnection::Request") );
|
||||
m_sockstrm->Read(data, s);
|
||||
@@ -443,7 +438,7 @@ wxChar *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat f
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTCPConnection::Poke (const wxString& item, const wxChar *data, int size, wxIPCFormat format)
|
||||
bool wxTCPConnection::DoPoke (const wxString& item, const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
if (!m_sock->IsConnected())
|
||||
return false;
|
||||
@@ -452,9 +447,6 @@ bool wxTCPConnection::Poke (const wxString& item, const wxChar *data, int size,
|
||||
m_codeco->WriteString(item);
|
||||
m_codeco->Write8(format);
|
||||
|
||||
if (size < 0)
|
||||
size = (wxStrlen(data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
|
||||
m_codeco->Write32(size);
|
||||
m_sockstrm->Write(data, size);
|
||||
|
||||
@@ -498,8 +490,8 @@ bool wxTCPConnection::StopAdvise (const wxString& item)
|
||||
}
|
||||
|
||||
// Calls that SERVER can make
|
||||
bool wxTCPConnection::Advise (const wxString& item,
|
||||
const wxChar *data, int size, wxIPCFormat format)
|
||||
bool wxTCPConnection::DoAdvise (const wxString& item,
|
||||
const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
if (!m_sock->IsConnected())
|
||||
return false;
|
||||
@@ -508,9 +500,6 @@ bool wxTCPConnection::Advise (const wxString& item,
|
||||
m_codeco->WriteString(item);
|
||||
m_codeco->Write8(format);
|
||||
|
||||
if (size < 0)
|
||||
size = (wxStrlen(data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
|
||||
m_codeco->Write32(size);
|
||||
m_sockstrm->Write(data, size);
|
||||
|
||||
@@ -564,7 +553,7 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
|
||||
{
|
||||
case IPC_EXECUTE:
|
||||
{
|
||||
wxChar *data;
|
||||
void *data;
|
||||
size_t size;
|
||||
wxIPCFormat format;
|
||||
|
||||
@@ -582,14 +571,10 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
|
||||
}
|
||||
case IPC_ADVISE:
|
||||
{
|
||||
wxChar *data;
|
||||
size_t size;
|
||||
wxIPCFormat format;
|
||||
|
||||
item = codeci->ReadString();
|
||||
format = (wxIPCFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = connection->GetBufferAtLeast( size );
|
||||
wxIPCFormat format = (wxIPCFormat)codeci->Read8();
|
||||
size_t size = codeci->Read32();
|
||||
void *data = connection->GetBufferAtLeast( size );
|
||||
wxASSERT_MSG(data != NULL,
|
||||
_T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
|
||||
sockstrm->Read(data, size);
|
||||
@@ -624,14 +609,10 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
|
||||
}
|
||||
case IPC_POKE:
|
||||
{
|
||||
wxIPCFormat format;
|
||||
size_t size;
|
||||
wxChar *data;
|
||||
|
||||
item = codeci->ReadString();
|
||||
format = (wxIPCFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = connection->GetBufferAtLeast( size );
|
||||
wxIPCFormat format = (wxIPCFormat)codeci->Read8();
|
||||
size_t size = codeci->Read32();
|
||||
void *data = connection->GetBufferAtLeast( size );
|
||||
wxASSERT_MSG(data != NULL,
|
||||
_T("Buffer too small in wxTCPEventHandler::Client_OnRequest") );
|
||||
sockstrm->Read(data, size);
|
||||
@@ -647,15 +628,28 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
|
||||
item = codeci->ReadString();
|
||||
format = (wxIPCFormat)codeci->Read8();
|
||||
|
||||
int user_size = -1;
|
||||
const wxChar *user_data = connection->OnRequest (topic_name, item, &user_size, format);
|
||||
size_t user_size = wxNO_LEN;
|
||||
const void *user_data = connection->OnRequest (topic_name, item, &user_size, format);
|
||||
|
||||
if (user_data)
|
||||
{
|
||||
codeco->Write8(IPC_REQUEST_REPLY);
|
||||
|
||||
if (user_size == -1)
|
||||
user_size = (wxStrlen(user_data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
if (user_size == wxNO_LEN)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case wxIPC_TEXT:
|
||||
case wxIPC_UTF8TEXT:
|
||||
user_size = strlen((const char *)user_data) + 1; // includes final NUL
|
||||
break;
|
||||
case wxIPC_UNICODETEXT:
|
||||
user_size = (wcslen((const wchar_t *)user_data) + 1) * sizeof(wchar_t); // includes final NUL
|
||||
break;
|
||||
default:
|
||||
user_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
codeco->Write32(user_size);
|
||||
sockstrm->Write(user_data, user_size);
|
||||
|
@@ -498,7 +498,7 @@ bool wxDDEClient::DeleteConnection(WXHCONV conv)
|
||||
// wxDDEConnection
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxDDEConnection::wxDDEConnection(wxChar *buffer, int size)
|
||||
wxDDEConnection::wxDDEConnection(void *buffer, size_t size)
|
||||
: wxConnectionBase(buffer, size)
|
||||
{
|
||||
m_client = NULL;
|
||||
@@ -545,13 +545,9 @@ bool wxDDEConnection::Disconnect()
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool wxDDEConnection::Execute(const wxChar *data, int size, wxIPCFormat WXUNUSED(format))
|
||||
bool wxDDEConnection::DoExecute(const void *data, size_t size, wxIPCFormat WXUNUSED(format))
|
||||
{
|
||||
DWORD result;
|
||||
if (size < 0)
|
||||
{
|
||||
size = (wxStrlen(data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
}
|
||||
|
||||
bool ok = DdeClientTransaction((LPBYTE)data,
|
||||
size,
|
||||
@@ -572,7 +568,7 @@ bool wxDDEConnection::Execute(const wxChar *data, int size, wxIPCFormat WXUNUSED
|
||||
return ok;
|
||||
}
|
||||
|
||||
wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat format)
|
||||
const void *wxDDEConnection::Request(const wxString& item, size_t *size, wxIPCFormat format)
|
||||
{
|
||||
DWORD result;
|
||||
|
||||
@@ -593,7 +589,7 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo
|
||||
|
||||
DWORD len = DdeGetData(returned_data, NULL, 0, 0);
|
||||
|
||||
wxChar *data = GetBufferAtLeast( len );
|
||||
void *data = GetBufferAtLeast(len);
|
||||
wxASSERT_MSG(data != NULL,
|
||||
_T("Buffer too small in wxDDEConnection::Request") );
|
||||
(void) DdeGetData(returned_data, (LPBYTE)data, len, 0);
|
||||
@@ -601,18 +597,14 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo
|
||||
(void) DdeFreeDataHandle(returned_data);
|
||||
|
||||
if (size)
|
||||
*size = (int)len;
|
||||
*size = (size_t)len;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
bool wxDDEConnection::Poke(const wxString& item, const wxChar *data, int size, wxIPCFormat format)
|
||||
bool wxDDEConnection::DoPoke(const wxString& item, const void *data, size_t size, wxIPCFormat format)
|
||||
{
|
||||
DWORD result;
|
||||
if (size < 0)
|
||||
{
|
||||
size = (wxStrlen(data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
}
|
||||
|
||||
HSZ item_atom = DDEGetAtom(item);
|
||||
bool ok = DdeClientTransaction((LPBYTE)data,
|
||||
@@ -669,16 +661,11 @@ bool wxDDEConnection::StopAdvise(const wxString& item)
|
||||
}
|
||||
|
||||
// Calls that SERVER can make
|
||||
bool wxDDEConnection::Advise(const wxString& item,
|
||||
const wxChar *data,
|
||||
int size,
|
||||
bool wxDDEConnection::DoAdvise(const wxString& item,
|
||||
const void *data,
|
||||
size_t size,
|
||||
wxIPCFormat format)
|
||||
{
|
||||
if (size < 0)
|
||||
{
|
||||
size = (wxStrlen(data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
}
|
||||
|
||||
HSZ item_atom = DDEGetAtom(item);
|
||||
HSZ topic_atom = DDEGetAtom(m_topicName);
|
||||
m_sendingData = data; // mrf: potential for scope problems here?
|
||||
@@ -695,12 +682,6 @@ bool wxDDEConnection::Advise(const wxString& item,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool wxDDEConnection::OnDisconnect()
|
||||
{
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// _DDECallback
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -775,7 +756,7 @@ _DDECallback(WORD wType,
|
||||
{
|
||||
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
||||
|
||||
wxChar *data = connection->GetBufferAtLeast( len );
|
||||
void *data = connection->GetBufferAtLeast(len);
|
||||
wxASSERT_MSG(data != NULL,
|
||||
_T("Buffer too small in _DDECallback (XTYP_EXECUTE)") );
|
||||
|
||||
@@ -804,15 +785,26 @@ _DDECallback(WORD wType,
|
||||
{
|
||||
wxString item_name = DDEStringFromAtom(hsz2);
|
||||
|
||||
int user_size = -1;
|
||||
const wxChar *data = connection->OnRequest(connection->m_topicName,
|
||||
size_t user_size = wxNO_LEN;
|
||||
const void *data = connection->OnRequest(connection->m_topicName,
|
||||
item_name,
|
||||
&user_size,
|
||||
(wxIPCFormat)wFmt);
|
||||
if (data)
|
||||
{
|
||||
if (user_size < 0)
|
||||
user_size = (wxStrlen((wxChar*)data) + 1) * sizeof(wxChar); // includes final NUL
|
||||
if (user_size == wxNO_LEN)
|
||||
switch (wFmt)
|
||||
{
|
||||
case wxIPC_TEXT:
|
||||
case wxIPC_UTF8TEXT:
|
||||
user_size = strlen((const char*)data) + 1; // includes final NUL
|
||||
break;
|
||||
case wxIPC_UNICODETEXT:
|
||||
user_size = (wcslen((const wchar_t*)data) + 1) * sizeof(wchar_t); // includes final NUL
|
||||
break;
|
||||
default:
|
||||
user_size = 0;
|
||||
}
|
||||
|
||||
HDDEDATA handle = DdeCreateDataHandle(DDEIdInst,
|
||||
(LPBYTE)data,
|
||||
@@ -837,7 +829,7 @@ _DDECallback(WORD wType,
|
||||
|
||||
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
||||
|
||||
wxChar *data = connection->GetBufferAtLeast( len );
|
||||
void *data = connection->GetBufferAtLeast(len);
|
||||
wxASSERT_MSG(data != NULL,
|
||||
_T("Buffer too small in _DDECallback (XTYP_POKE)") );
|
||||
|
||||
@@ -924,7 +916,7 @@ _DDECallback(WORD wType,
|
||||
|
||||
DWORD len = DdeGetData(hData, NULL, 0, 0);
|
||||
|
||||
wxChar *data = connection->GetBufferAtLeast( len );
|
||||
void *data = connection->GetBufferAtLeast(len);
|
||||
wxASSERT_MSG(data != NULL,
|
||||
_T("Buffer too small in _DDECallback (XTYP_ADVDATA)") );
|
||||
|
||||
|
Reference in New Issue
Block a user