From e9202ffeccdf6f669184f3f869d2e5b121bea9f3 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 13 Jan 2012 21:42:32 +0000 Subject: Remove unused SalDisplay::IsLocal --- vcl/inc/unx/saldisp.hxx | 6 -- vcl/unx/generic/app/saldisp.cxx | 120 ---------------------------------------- 2 files changed, 126 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index 8fd0507deb36..b8d6cd38ac87 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -304,10 +304,6 @@ protected: srv_vendor_t meServerVendor; SalWM eWindowManager_; - sal_Bool bLocal_; // Server==Client? Init - // in SalDisplay::IsLocal() - sal_Bool mbLocalIsValid; // bLocal_ is valid ? - // until x bytes XLIB_Cursor aPointerCache_[POINTER_COUNT]; @@ -374,8 +370,6 @@ public: XLIB_Cursor GetPointer( int ePointerStyle ); virtual int CaptureMouse( SalFrame *pCapture ); - sal_Bool IsLocal(); - void Remove( XEvent *pEvent ); virtual void initScreen( int nScreen ) const; diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 75882cc21b31..aec8b53920d6 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -226,122 +226,6 @@ static sal_Bool sal_GetVisualInfo( Display *pDisplay, XID nVID, XVisualInfo &rVI return sal_True; } -// --------------------------------------------------------------------------- - -// check wether displaystring is in format N.M or N. or just N -// with N and M beeing natural numbers -static sal_Bool -sal_IsDisplayNumber( const char *pDisplayString ) -{ - if ( ! isdigit(*pDisplayString) ) - return sal_False; - while ( isdigit(*(++pDisplayString)) ) - ; /* do nothing */ - - if ( *pDisplayString == '.' ) - { - while ( isdigit(*(++pDisplayString)) ) - ; /* do nothing */ - } - - return (*pDisplayString == '\0'); -} - -// check whether host1 and host2 point to the same ip address -static sal_Bool -sal_EqualHosts( const OUString& Host1, const OUString& Host2) -{ - oslSocketAddr pHostAddr1; - oslSocketAddr pHostAddr2; - sal_Bool bEqualAddress = sal_False; - - if ( Host1.toChar() >= '0' && Host1.toChar() <= '9' ) - pHostAddr1 = osl_createInetSocketAddr( Host1.pData, 0 ); - else - pHostAddr1 = osl_resolveHostname( Host1.pData ); - - if ( Host2.toChar() >= '0' && Host2.toChar() <= '9' ) - pHostAddr2 = osl_createInetSocketAddr( Host2.pData, 0 ); - else - pHostAddr2 = osl_resolveHostname( Host2.pData ); - - if( pHostAddr1 && pHostAddr2 ) - bEqualAddress = osl_isEqualSocketAddr( pHostAddr1, pHostAddr2 ) ? sal_True : sal_False; - - if( pHostAddr1 ) - osl_destroySocketAddr( pHostAddr1 ); - if( pHostAddr2 ) - osl_destroySocketAddr( pHostAddr2 ); - - return bEqualAddress; -} - -static sal_Bool -sal_IsLocalDisplay( Display *pDisplay ) -{ - const char *pDisplayString = DisplayString( pDisplay ); - - // no string, no idea - if ( pDisplayString == NULL || pDisplayString[ 0 ] == '\0') - return sal_False; - - // check for ":x.y" - if ( pDisplayString[ 0 ] == ':' ) - return sal_IsDisplayNumber( pDisplayString + 1 ); - - // check for fixed token which all mean localhost:x.y - const char pLocal[] = "localhost:"; - const int nLocalLen = sizeof(pLocal) - 1; - if ( strncmp(pDisplayString, pLocal, nLocalLen) == 0 ) - return sal_IsDisplayNumber( pDisplayString + nLocalLen ); - - const char pUnix[] = "unix:"; - const int nUnixLen = sizeof(pUnix) - 1; - if ( strncmp(pDisplayString, pUnix, nUnixLen) == 0 ) - return sal_IsDisplayNumber( pDisplayString + nUnixLen ); - - const char pLoopback[] = "127.0.0.1:"; - const int nLoopbackLen= sizeof(pLoopback) - 1; - if ( strncmp(pDisplayString, pLoopback, nLoopbackLen) == 0 ) - return sal_IsDisplayNumber( pDisplayString + nLoopbackLen ); - - // compare local hostname to displaystring, both may be ip address or - // hostname - sal_Bool bEqual = sal_False; - char *pDisplayHost = strdup( pDisplayString ); - char *pPtr = strrchr( pDisplayHost, ':' ); - - if( pPtr != NULL ) - { - const OUString& rLocalHostname( GetGenericData()->GetHostname() ); - if( rLocalHostname.getLength() ) - { - *pPtr = '\0'; - OUString aDisplayHostname( pDisplayHost, strlen( pDisplayHost ), osl_getThreadTextEncoding() ); - bEqual = sal_EqualHosts( rLocalHostname, aDisplayHostname ); - bEqual = bEqual && sal_IsDisplayNumber( pPtr + 1 ); - } - } - free( pDisplayHost ); - - return bEqual; -} - -// --------------------------------------------------------------------------- -// IsLocal means soffice is running on the same host as the xserver -// since it is not called very often and sal_IsLocalDisplay() is relative -// expensive bLocal_ is initialized on first call - -sal_Bool SalDisplay::IsLocal() -{ - if ( ! mbLocalIsValid ) - { - bLocal_ = sal_IsLocalDisplay( pDisp_ ); - mbLocalIsValid = sal_True; - } - return (sal_Bool)bLocal_; -} - // --------------------------------------------------------------------------- extern "C" srv_vendor_t sal_GetServerVendor( Display *p_display ) @@ -812,10 +696,6 @@ void SalDisplay::Init() SetServerVendor(); X11SalBitmap::ImplCreateCache(); - bLocal_ = sal_False; /* dont care, initialize later by - calling SalDisplay::IsLocal() */ - mbLocalIsValid = sal_False; /* bLocal_ is not yet initialized */ - // - - - - - - - - - - Synchronize - - - - - - - - - - - - - if( getenv( "SAL_SYNCHRONIZE" ) ) XSynchronize( pDisp_, True ); -- cgit v1.2.3