X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..b1727cfef7e084b0ba52b69fbe948379d66981da:/src/unix/dialup.cpp diff --git a/src/unix/dialup.cpp b/src/unix/dialup.cpp index 34f62f0d1b..3f96dfba46 100644 --- a/src/unix/dialup.cpp +++ b/src/unix/dialup.cpp @@ -6,13 +6,9 @@ // Created: 03.10.99 // RCS-ID: $Id$ // Copyright: (c) Karsten Ballüder -// Licence: wxWidgets 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" @@ -82,16 +78,16 @@ public: ~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 + returns false, no other functions will work neither, so it's a good idea to call this function and check its result before calling any other wxDialUpManager methods. */ virtual bool IsOk() const - { return TRUE; } + { return true; } /** The simplest way to initiate a dial up: this function dials the given ISP (exact meaning of the parameter depends on the platform), returns - TRUE on success or FALSE on failure and logs the appropriate error + true on success or false on failure and logs the appropriate error message in the latter case. @param nameOfISP optional paramater for dial program @param username unused @@ -105,7 +101,7 @@ public: // Hang up the currently active dial up connection. virtual bool HangUp(); - // returns TRUE if the computer is connected to the network: under Windows, + // returns true if the computer is connected to the network: under Windows, // this just means that a RAS connection exists, under Unix we check that // the "well-known host" (as specified by SetWellKnownHost) is reachable virtual bool IsOnline() const @@ -117,11 +113,11 @@ public: // do we have a constant net connection? virtual bool IsAlwaysOnline() const; - // returns TRUE if (async) dialing is in progress + // returns true if (async) dialing is in progress virtual bool IsDialing() const { return m_DialProcess != NULL; } - // cancel dialing the number initiated with Dial(async = TRUE) + // cancel dialing the number initiated with Dial(async = true) // NB: this won't result in DISCONNECTED event being sent virtual bool CancelDialing(); @@ -132,7 +128,7 @@ public: // so, in general, the user should be allowed to override it. This function // allows to forcefully set the online status - whatever our internal // algorithm may think about it. - virtual void SetOnlineStatus(bool isOnline = TRUE) + virtual void SetOnlineStatus(bool isOnline = true) { m_IsOnline = isOnline ? Net_Connected : Net_No; } // set misc wxDialUpManager options @@ -144,7 +140,7 @@ public: // Windows, the notification about the change of connection status is // instantenous. // - // Returns FALSE if couldn't set up automatic check for online status. + // Returns false if couldn't set up automatic check for online status. virtual bool EnableAutoCheckOnlineStatus(size_t nSeconds); // disable automatic check for connection status change - notice that the @@ -222,7 +218,7 @@ private: friend class wxDialProcess; // determine status - void CheckStatus(bool fromAsync = FALSE) const; + void CheckStatus(bool fromAsync = false) const; // real status check void CheckStatusInternal(); @@ -278,7 +274,7 @@ public: if(m_DupMan) { m_DupMan->m_DialProcess = NULL; - m_DupMan->CheckStatus(TRUE); + m_DupMan->CheckStatus(true); } } private: @@ -327,54 +323,54 @@ wxDialUpManagerImpl::Dial(const wxString &isp, const wxString & WXUNUSED(password), bool async) { - if(m_IsOnline == Net_Connected) - return FALSE; - m_ISPname = isp; - wxString cmd; - if(m_ConnectCommand.Find(wxT("%s"))) - cmd.Printf(m_ConnectCommand,m_ISPname.c_str()); - else - cmd = m_ConnectCommand; + if(m_IsOnline == Net_Connected) + return false; + m_ISPname = isp; + wxString cmd; + if(m_ConnectCommand.Find(wxT("%s"))) + cmd.Printf(m_ConnectCommand,m_ISPname.c_str()); + else + cmd = m_ConnectCommand; - if ( async ) - { - m_DialProcess = new wxDialProcess(this); - m_DialPId = (int)wxExecute(cmd, FALSE, m_DialProcess); - if(m_DialPId == 0) - { - delete m_DialProcess; - m_DialProcess = NULL; - return FALSE; - } - else - return TRUE; - } - else - return wxExecute(cmd, /* sync */ TRUE) == 0; + if ( async ) + { + m_DialProcess = new wxDialProcess(this); + m_DialPId = (int)wxExecute(cmd, false, m_DialProcess); + if(m_DialPId == 0) + { + delete m_DialProcess; + m_DialProcess = NULL; + return false; + } + else + return true; + } + else + return wxExecute(cmd, /* sync */ true) == 0; } bool wxDialUpManagerImpl::HangUp() { - if(m_IsOnline == Net_No) - return FALSE; - if(IsDialing()) - { - wxLogError(_("Already dialling ISP.")); - return FALSE; - } - wxString cmd; - if(m_HangUpCommand.Find(wxT("%s"))) - cmd.Printf(m_HangUpCommand,m_ISPname.c_str(), m_DialProcess); - else - cmd = m_HangUpCommand; - return wxExecute(cmd, /* sync */ TRUE) == 0; + if(m_IsOnline == Net_No) + return false; + if(IsDialing()) + { + wxLogError(_("Already dialling ISP.")); + return false; + } + wxString cmd; + if(m_HangUpCommand.Find(wxT("%s"))) + cmd.Printf(m_HangUpCommand,m_ISPname.c_str(), m_DialProcess); + else + cmd = m_HangUpCommand; + return wxExecute(cmd, /* sync */ true) == 0; } bool wxDialUpManagerImpl::CancelDialing() { if(! IsDialing()) - return FALSE; + return false; return kill(m_DialPId, SIGTERM) > 0; } @@ -640,10 +636,10 @@ int wxDialUpManagerImpl::CheckIfconfig() { #ifdef __VMS - m_CanUseIfconfig = 0; - return -1; + m_CanUseIfconfig = 0; + return -1; #else - // assume that the test doesn't work + // assume that the test doesn't work int netDevice = NetDevice_Unknown; // first time check for ifconfig location @@ -654,6 +650,7 @@ wxDialUpManagerImpl::CheckIfconfig() _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++ ) @@ -679,7 +676,9 @@ wxDialUpManagerImpl::CheckIfconfig() wxString tmpfile = wxGetTempFileName( wxT("_wxdialuptest") ); wxString cmd = wxT("/bin/sh -c \'"); cmd << m_IfconfigPath; -#if defined(__SOLARIS__) || defined (__SUNOS__) +#if defined(__AIX__) || \ + defined(__OSF__) || \ + defined(__SOLARIS__) || defined (__SUNOS__) // need to add -a flag cmd << wxT(" -a"); #elif defined(__LINUX__) || defined(__SGI__) @@ -691,8 +690,13 @@ wxDialUpManagerImpl::CheckIfconfig() // VZ: a wild guess (but without it, ifconfig fails completely) cmd << wxT(" ppp0"); #else -# pragma warning "No ifconfig information for this OS." - m_CanUseIfconfig = 0; + #if defined(__GNUG__) + #warning "No ifconfig information for this OS." + #else + #pragma warning "No ifconfig information for this OS." + #endif + + m_CanUseIfconfig = 0; return -1; #endif cmd << wxT(" >") << tmpfile << wxT('\''); @@ -700,7 +704,7 @@ wxDialUpManagerImpl::CheckIfconfig() so we could let ifconfig write directly to the tmpfile, but this does not work. That should be faster, as it doesn´t call the shell first. I have no idea why. :-( (KB) */ - if ( wxExecute(cmd,TRUE /* sync */) == 0 ) + if ( wxExecute(cmd,true /* sync */) == 0 ) { m_CanUseIfconfig = 1; wxFFile file; @@ -711,8 +715,8 @@ wxDialUpManagerImpl::CheckIfconfig() { // FIXME shouldn't we grep for "^ppp"? (VZ) - bool hasModem = FALSE, - hasLAN = FALSE; + bool hasModem = false, + hasLAN = false; #if defined(__SOLARIS__) || defined (__SUNOS__) // dialup device under SunOS/Solaris @@ -724,10 +728,10 @@ wxDialUpManagerImpl::CheckIfconfig() || 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; + hasModem = true; #endif netDevice = NetDevice_None; @@ -761,6 +765,10 @@ wxDialUpManagerImpl::NetConnection wxDialUpManagerImpl::CheckPing() #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__) + m_PingPath = _T("/usr/etc/ping"); #else if (wxFileExists( wxT("/bin/ping") )) m_PingPath = wxT("/bin/ping"); @@ -779,26 +787,36 @@ wxDialUpManagerImpl::NetConnection wxDialUpManagerImpl::CheckPing() return Net_Unknown; } - wxLogNull ln; // suppress all error messages - wxASSERT(m_PingPath.length()); - wxString cmd; - cmd << m_PingPath << wxT(' '); + wxLogNull ln; // suppress all error messages + wxASSERT(m_PingPath.length()); + wxString cmd; + cmd << m_PingPath << wxT(' '); #if defined(__SOLARIS__) || defined (__SUNOS__) - // nothing to add to ping command -#elif defined(__LINUX__) || defined (__BSD__) || defined( __VMS ) - cmd << wxT("-c 1 "); // only ping once + // nothing to add to ping command +#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("64 1 "); // only ping once (need also specify the packet size) #else -# pragma warning "No Ping information for this OS." - m_CanUsePing = 0; - return Net_Unknown; + #if defined(__GNUG__) + #warning "No Ping information for this OS." + #else + #pragma warning "No Ping information for this OS." + #endif + + m_CanUsePing = 0; + return Net_Unknown; #endif - cmd << m_BeaconHost; - if(wxExecute(cmd, TRUE /* sync */) == 0) - return Net_Connected; - else - return Net_No; + cmd << m_BeaconHost; + if(wxExecute(cmd, true /* sync */) == 0) + return Net_Connected; + else + return Net_No; } /* static */