{
wxSocketBase *sock = event.GetSocket();
wxSocketNotify evt = event.GetSocketEvent();
- wxTCPConnection *connection = (wxTCPConnection *)(event.GetClientData());
+ wxTCPConnection *connection = (wxTCPConnection *)(sock->GetClientData());
// This socket is being deleted; skip this event
if (!connection)
DECLARE_DYNAMIC_CLASS(wxSocketModule)
public:
- bool OnInit() { return GSocket_Init(); }
+ bool OnInit() { return GSocket_Init() != 0; }
void OnExit() { GSocket_Cleanup(); }
};
{
wxString email;
- wxString host = wxGetHostName();
+ wxString host = wxGetFullHostName();
if ( !!host )
{
wxString user = wxGetUserId();
if ( !!user )
{
- wxString email(user);
- email << wxT('@') << host;
+ email << user << wxT('@') << host;
}
}
wxStatusBar *statusBar = NULL;
#if wxUSE_NATIVE_STATUSBAR
- if ( UsesNativeStatusBar() )
+ if ( !UsesNativeStatusBar() )
{
- statusBar = (wxStatusBar *)new wxStatusBar95(this, id, style);
-
- statusBar->SetFieldsCount(number);
+ statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style);
}
else
#endif
{
- statusBar = (wxStatusBar *)new wxStatusBarGeneric(this, id, style, name);
+ statusBar = new wxStatusBar(this, id, style, name);
+ }
- // Set the height according to the font and the border size
- wxClientDC dc(statusBar);
- dc.SetFont(statusBar->GetFont());
+ // Set the height according to the font and the border size
+ wxClientDC dc(statusBar);
+ dc.SetFont(statusBar->GetFont());
- wxCoord y;
- dc.GetTextExtent(_T("X"), NULL, &y );
+ wxCoord y;
+ dc.GetTextExtent(_T("X"), NULL, &y );
- int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY());
+ int height = (int)( (11*y)/10 + 2*statusBar->GetBorderY());
- statusBar->SetSize(-1, -1, -1, height);
+ statusBar->SetSize(-1, -1, -1, height);
- statusBar->SetFieldsCount(number);
- }
+ statusBar->SetFieldsCount(number);
return statusBar;
}
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/cursor.h"
+ #include "wx/intl.h"
+ #include "wx/log.h"
#endif //WX_PRECOMP
#include "wx/msw/private.h" // includes <windows.h>
#include "wx/timer.h"
-#include "wx/intl.h"
#include <ctype.h>
#include <sys/stat.h>
#endif //GNUWIN32
-#include "wx/log.h"
-
#ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
// this (3.1 I believe) and how to test for it.
// If this works for Borland 4.0 as well, then no worries.
#include <dir.h>
#endif
+#if defined(__WIN32__) && !defined(__TWIN32__)
+ #include <winsock.h> // we use socket functions in wxGetFullHostName()
+#endif
+
// VZ: there is some code using NetXXX() functions to get the full user name:
// I don't think it's a good idea because they don't work under Win95 and
// seem to return the same as wxGetUserId() under NT. If you really want
// get host name and related
// ----------------------------------------------------------------------------
-// Get full hostname (eg. DoDo.BSn-Germany.crg.de)
+// Get hostname only (without domain name)
bool wxGetHostName(wxChar *buf, int maxSize)
{
#if defined(__WIN32__) && !defined(__TWIN32__)
- // TODO should use GetComputerNameEx() when available
-
DWORD nSize = maxSize;
if ( !::GetComputerName(buf, &nSize) )
{
#endif
}
+// get full hostname (with domain name if possible)
bool wxGetFullHostName(wxChar *buf, int maxSize)
{
+#if defined(__WIN32__) && !defined(__TWIN32__)
+ // TODO should use GetComputerNameEx() when available
+ WSADATA wsa;
+ if ( WSAStartup(MAKEWORD(1, 1), &wsa) == 0 )
+ {
+ wxString host;
+ char bufA[256];
+ if ( gethostname(bufA, WXSIZEOF(bufA)) == 0 )
+ {
+ // gethostname() won't usually include the DNS domain name, for
+ // this we need to work a bit more
+ if ( !strchr(bufA, '.') )
+ {
+ struct hostent *pHostEnt = gethostbyname(bufA);
+
+ if ( pHostEnt )
+ {
+ // Windows will use DNS internally now
+ pHostEnt = gethostbyaddr(pHostEnt->h_addr, 4, PF_INET);
+ }
+
+ if ( pHostEnt )
+ {
+ host = pHostEnt->h_name;
+ }
+ }
+ }
+
+ WSACleanup();
+
+ if ( !!host )
+ {
+ wxStrncpy(buf, host, maxSize);
+
+ return TRUE;
+ }
+ }
+#endif // Win32
+
return wxGetHostName(buf, maxSize);
}