]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/dialup.cpp
Use gdk_window_invalidate instead of gtk_widget_queue_draw as the latter doesn't...
[wxWidgets.git] / src / unix / dialup.cpp
index 79a7ce330588b4d329ac141cdffcaffa830e63f4..96cf13130b6c7cc2f588bd3670f8a8e7f869a2c6 100644 (file)
@@ -1,5 +1,5 @@
 // -*- c++ -*- ////////////////////////////////////////////////////////////////
 // -*- c++ -*- ////////////////////////////////////////////////////////////////
-// Name:        unix/dialup.cpp
+// Name:        src/unix/dialup.cpp
 // Purpose:     Network related wxWidgets classes and functions
 // Author:      Karsten Ballüder
 // Modified by:
 // Purpose:     Network related wxWidgets classes and functions
 // Author:      Karsten Ballüder
 // Modified by:
@@ -9,33 +9,27 @@
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#   pragma implementation "dialup.h"
-#endif
-
 // for compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // for compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#include "wx/setup.h"
-
 #if wxUSE_DIALUP_MANAGER
 
 #if wxUSE_DIALUP_MANAGER
 
+#include "wx/dialup.h"
+
 #ifndef  WX_PRECOMP
 #ifndef  WX_PRECOMP
-#   include "wx/defs.h"
+    #include "wx/string.h"
+    #include "wx/intl.h"
+    #include "wx/log.h"
+    #include "wx/event.h"
+    #include "wx/app.h"
+    #include "wx/utils.h"
+    #include "wx/timer.h"
 #endif // !PCH
 
 #endif // !PCH
 
-#include "wx/string.h"
-#include "wx/event.h"
-#include "wx/dialup.h"
-#include "wx/timer.h"
-#include "wx/filefn.h"
-#include "wx/utils.h"
-#include "wx/log.h"
+#include "wx/filename.h"
 #include "wx/ffile.h"
 #include "wx/process.h"
 #include "wx/ffile.h"
 #include "wx/process.h"
-#include "wx/intl.h"
-#include "wx/app.h"
-#include "wx/wxchar.h"
+#include "wx/crt.h"
 
 #include <stdlib.h>
 
 
 #include <stdlib.h>
 
@@ -49,8 +43,8 @@
 #include <arpa/inet.h>
 #include <errno.h>
 
 #include <arpa/inet.h>
 #include <errno.h>
 
-DEFINE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED)
-DEFINE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED)
+wxDEFINE_EVENT( wxEVT_DIALUP_CONNECTED, wxDialUpEvent );
+wxDEFINE_EVENT( wxEVT_DIALUP_DISCONNECTED, wxDialUpEvent );
 
 // ----------------------------------------------------------------------------
 // A class which groups functions dealing with connecting to the network from a
 
 // ----------------------------------------------------------------------------
 // A class which groups functions dealing with connecting to the network from a
@@ -79,7 +73,7 @@ class WXDLLEXPORT wxDialUpManagerImpl : public wxDialUpManager
 {
 public:
    wxDialUpManagerImpl();
 {
 public:
    wxDialUpManagerImpl();
-   ~wxDialUpManagerImpl();
+   virtual ~wxDialUpManagerImpl();
 
    /** Could the dialup manager be initialized correctly? If this function
        returns false, no other functions will work neither, so it's a good idea
 
    /** Could the dialup manager be initialized correctly? If this function
        returns false, no other functions will work neither, so it's a good idea
@@ -404,7 +398,7 @@ void wxDialUpManagerImpl::DisableAutoCheckOnlineStatus()
 
 void wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno)
 {
 
 void wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno)
 {
-   if(hostname.Length() == 0)
+   if(hostname.length() == 0)
    {
       m_BeaconHost = WXDIALUP_MANAGER_DEFAULT_BEACONHOST;
       m_BeaconPort = 80;
    {
       m_BeaconHost = WXDIALUP_MANAGER_DEFAULT_BEACONHOST;
       m_BeaconPort = 80;
@@ -413,7 +407,7 @@ void wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno)
 
    // does hostname contain a port number?
    wxString port = hostname.After(wxT(':'));
 
    // does hostname contain a port number?
    wxString port = hostname.After(wxT(':'));
-   if(port.Length())
+   if(port.length())
    {
       m_BeaconHost = hostname.Before(wxT(':'));
       m_BeaconPort = wxAtoi(port);
    {
       m_BeaconHost = hostname.Before(wxT(':'));
       m_BeaconPort = wxAtoi(port);
@@ -586,9 +580,11 @@ wxDialUpManagerImpl::NetConnection wxDialUpManagerImpl::CheckConnect()
    }
    else // failed to connect
    {
    }
    else // failed to connect
    {
+#ifdef ENETUNREACH
        if(errno == ENETUNREACH)
           return Net_No; // network is unreachable
        else
        if(errno == ENETUNREACH)
           return Net_No; // network is unreachable
        else
+#endif
           return Net_Unknown; // connect failed, but don't know why
    }
 }
           return Net_Unknown; // connect failed, but don't know why
    }
 }
@@ -654,6 +650,7 @@ wxDialUpManagerImpl::CheckIfconfig()
             _T("/sbin"),         // Linux, FreeBSD, Darwin
             _T("/usr/sbin"),     // SunOS, Solaris, AIX, HP-UX
             _T("/usr/etc"),      // IRIX
             _T("/sbin"),         // Linux, FreeBSD, Darwin
             _T("/usr/sbin"),     // SunOS, Solaris, AIX, HP-UX
             _T("/usr/etc"),      // IRIX
+            _T("/etc"),          // AIX 5
         };
 
         for ( size_t n = 0; n < WXSIZEOF(ifconfigLocations); n++ )
         };
 
         for ( size_t n = 0; n < WXSIZEOF(ifconfigLocations); n++ )
@@ -676,10 +673,13 @@ wxDialUpManagerImpl::CheckIfconfig()
         wxASSERT_MSG( m_IfconfigPath.length(),
                       _T("can't use ifconfig if it wasn't found") );
 
         wxASSERT_MSG( m_IfconfigPath.length(),
                       _T("can't use ifconfig if it wasn't found") );
 
-        wxString tmpfile = wxGetTempFileName( wxT("_wxdialuptest") );
+        wxString tmpfile = wxFileName::CreateTempFileName( wxT("_wxdialuptest") );
         wxString cmd = wxT("/bin/sh -c \'");
         cmd << m_IfconfigPath;
         wxString cmd = wxT("/bin/sh -c \'");
         cmd << m_IfconfigPath;
-#if defined(__SOLARIS__) || defined (__SUNOS__)
+#if defined(__AIX__) || \
+    defined(__NETBSD__) || \
+    defined(__OSF__) || \
+    defined(__SOLARIS__) || defined (__SUNOS__)
         // need to add -a flag
         cmd << wxT(" -a");
 #elif defined(__LINUX__) || defined(__SGI__)
         // need to add -a flag
         cmd << wxT(" -a");
 #elif defined(__LINUX__) || defined(__SGI__)
@@ -721,15 +721,15 @@ wxDialUpManagerImpl::CheckIfconfig()
 
 #if defined(__SOLARIS__) || defined (__SUNOS__)
                     // dialup device under SunOS/Solaris
 
 #if defined(__SOLARIS__) || defined (__SUNOS__)
                     // dialup device under SunOS/Solaris
-                    hasModem = strstr(output.fn_str(),"ipdptp") != (char *)NULL;
-                    hasLAN = strstr(output.fn_str(), "hme") != (char *)NULL;
+                    hasModem = strstr(output.fn_str(),"ipdptp") != NULL;
+                    hasLAN = strstr(output.fn_str(), "hme") != NULL;
 #elif defined(__LINUX__) || defined (__FREEBSD__)
                     hasModem = strstr(output.fn_str(),"ppp")    // ppp
                         || strstr(output.fn_str(),"sl")  // slip
                         || strstr(output.fn_str(),"pl"); // plip
                     hasLAN = strstr(output.fn_str(), "eth") != NULL;
 #elif defined(__SGI__)  // IRIX
 #elif defined(__LINUX__) || defined (__FREEBSD__)
                     hasModem = strstr(output.fn_str(),"ppp")    // ppp
                         || strstr(output.fn_str(),"sl")  // slip
                         || strstr(output.fn_str(),"pl"); // plip
                     hasLAN = strstr(output.fn_str(), "eth") != NULL;
 #elif defined(__SGI__)  // IRIX
-                    hasModem = strstr(output, "ppp") != NULL; // PPP
+                    hasModem = strstr(output.fn_str(), "ppp") != NULL; // PPP
 #elif defined(__HPUX__)
                     // if could run ifconfig on interface, then it exists
                     hasModem = true;
 #elif defined(__HPUX__)
                     // if could run ifconfig on interface, then it exists
                     hasModem = true;
@@ -766,8 +766,10 @@ wxDialUpManagerImpl::NetConnection wxDialUpManagerImpl::CheckPing()
 #ifdef __VMS
         if (wxFileExists( wxT("SYS$SYSTEM:TCPIP$PING.EXE") ))
             m_PingPath = wxT("$SYS$SYSTEM:TCPIP$PING");
 #ifdef __VMS
         if (wxFileExists( wxT("SYS$SYSTEM:TCPIP$PING.EXE") ))
             m_PingPath = wxT("$SYS$SYSTEM:TCPIP$PING");
+#elif defined(__AIX__)
+        m_PingPath = _T("/etc/ping");
 #elif defined(__SGI__)
 #elif defined(__SGI__)
-        m_PingPath = _T("/usr/etc/ping"); 
+        m_PingPath = _T("/usr/etc/ping");
 #else
         if (wxFileExists( wxT("/bin/ping") ))
             m_PingPath = wxT("/bin/ping");
 #else
         if (wxFileExists( wxT("/bin/ping") ))
             m_PingPath = wxT("/bin/ping");
@@ -792,7 +794,12 @@ wxDialUpManagerImpl::NetConnection wxDialUpManagerImpl::CheckPing()
     cmd << m_PingPath << wxT(' ');
 #if defined(__SOLARIS__) || defined (__SUNOS__)
     // nothing to add to ping command
     cmd << m_PingPath << wxT(' ');
 #if defined(__SOLARIS__) || defined (__SUNOS__)
     // nothing to add to ping command
-#elif defined(__LINUX__) || defined (__BSD__) || defined(__VMS) || defined(__SGI__)
+#elif defined(__AIX__) || \
+      defined (__BSD__) || \
+      defined(__LINUX__) || \
+      defined(__OSF__) || \
+      defined(__SGI__) || \
+      defined(__VMS)
     cmd << wxT("-c 1 "); // only ping once
 #elif defined(__HPUX__)
     cmd << wxT("64 1 "); // only ping once (need also specify the packet size)
     cmd << wxT("-c 1 "); // only ping once
 #elif defined(__HPUX__)
     cmd << wxT("64 1 "); // only ping once (need also specify the packet size)