X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/96db102a93ed103a1c757c4445dd71789c2d0054..07cf98cb8eb7625eeffc95e407a9fa1ad863b451:/src/common/socket.cpp diff --git a/src/common/socket.cpp b/src/common/socket.cpp index dba14f4829..0f7a633165 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -44,12 +44,14 @@ #include "wx/sckaddr.h" #include "wx/socket.h" -// GRG: Why is this needed? -#ifdef __WXGTK__ -#include -#define wxYield() gtk_main_iteration() -#endif +#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMOTIF__) || defined(__WXMAC__) + #define PROCESS_EVENTS() wxYield() +#elif defined(__WXGTK__) + #include + #define PROCESS_EVENTS() gtk_main_iteration() +#endif + // -------------------------------------------------------------- // ClassInfos @@ -66,7 +68,7 @@ class wxSocketState : public wxObject public: bool notify_state; GSocketEventFlags evt_notify_state; - wxSocketBase::wxSockFlags socket_flags; + wxSockFlags socket_flags; wxSocketBase::wxSockCbk c_callback; char *c_callback_data; @@ -78,8 +80,7 @@ public: // wxSocketBase ctor and dtor // -------------------------------------------------------------- -wxSocketBase::wxSocketBase(wxSocketBase::wxSockFlags _flags, - wxSocketBase::wxSockType _type) : +wxSocketBase::wxSocketBase(wxSockFlags _flags, wxSockType _type) : wxEvtHandler(), m_socket(NULL), m_id(-1), m_flags(_flags), m_type(_type), @@ -186,9 +187,9 @@ wxUint32 wxSocketBase::DeferRead(char *buffer, wxUint32 nbytes) DoDefer(); } - // Wait for buffer completion. + // Wait for buffer completion. while (m_defer_buffer != NULL) - wxYield(); + PROCESS_EVENTS(); timer.Stop(); @@ -233,13 +234,13 @@ wxUint32 wxSocketBase::_Read(char* buffer, wxUint32 nbytes) // If the socket is not connected, or we have got the whole // needed buffer, return immedately - if (!m_connected || !m_socket || !nbytes) + if (!m_connected || !m_socket || !nbytes) return total; // Possible combinations (they are checked in this order) // NOWAIT // SPEED | WAITALL - // SPEED + // SPEED // WAITALL // NONE // @@ -314,7 +315,7 @@ wxSocketBase& wxSocketBase::ReadMsg(char* buffer, wxUint32 nbytes) if (sig != 0xfeeddead) { - wxLogMessage(_T("Warning: invalid signature returned to ReadMsg")); + wxLogMessage(wxT("Warning: invalid signature returned to ReadMsg")); goto exit; } @@ -372,7 +373,7 @@ wxSocketBase& wxSocketBase::ReadMsg(char* buffer, wxUint32 nbytes) if (sig != 0xdeadfeed) { - //wxLogMessage(_T("Warning: invalid signature returned to ReadMsg")); + //wxLogMessage(wxT("Warning: invalid signature returned to ReadMsg")); goto exit; } @@ -440,9 +441,9 @@ wxUint32 wxSocketBase::DeferWrite(const char *buffer, wxUint32 nbytes) DoDefer(); } - // Wait for buffer completion. + // Wait for buffer completion. while (m_defer_buffer != NULL) - wxYield(); + PROCESS_EVENTS(); timer.Stop(); @@ -451,7 +452,7 @@ wxUint32 wxSocketBase::DeferWrite(const char *buffer, wxUint32 nbytes) m_defering = NO_DEFER; wxString s; - s.Printf("Saliendo de DeferWrite: total %d bytes", nbytes-m_defer_nbytes); + s.Printf(wxT("Saliendo de DeferWrite: total %d bytes"), nbytes-m_defer_nbytes); //wxLogMessage(s); return nbytes-m_defer_nbytes; @@ -488,7 +489,7 @@ wxUint32 wxSocketBase::_Write(const char *buffer, wxUint32 nbytes) // Possible combinations (they are checked in this order) // NOWAIT // SPEED | WAITALL - // SPEED + // SPEED // WAITALL // NONE // @@ -684,7 +685,7 @@ wxSocketBase& wxSocketBase::Discard() // TODO: TriggerRead return *this; - + #undef MAX_BUFSIZE } @@ -770,7 +771,7 @@ void wxSocketBase::RestoreState() // they poll the socket, using GSocket_Select(), to check for // the specified combination of event flags, until an event // occurs or until the timeout ellapses. The polling loop -// calls wxYield(), so this won't block the GUI. +// calls PROCESS_EVENTS(), so this won't block the GUI. bool wxSocketBase::_Wait(long seconds, long milliseconds, wxSocketEventFlags flags) { @@ -848,7 +849,7 @@ bool wxSocketBase::_Wait(long seconds, long milliseconds, wxSocketEventFlags fla } if (timeout != 0) - wxYield(); + PROCESS_EVENTS(); } while ((state == -1) && timeout); @@ -899,7 +900,7 @@ void wxSocketBase::SetFlags(wxSockFlags _flags) { m_flags = _flags; } - + // -------------------------------------------------------------- // wxSocketBase callback management // --------------------------------------------------------------