Kaydet (Commit) e9202ffe authored tarafından Michael Meeks's avatar Michael Meeks

Remove unused SalDisplay::IsLocal

üst 3d13d919
......@@ -194,7 +194,6 @@ SVGExport::GetGlyphPlacement() const
SVGExport::IsUseGradient() const
SVGExport::popClip()
SVGExport::pushClip(basegfx::B2DPolyPolygon const&)
SalDisplay::IsLocal()
SalGraphics::DrawBitmap(SalTwoRect const*, SalBitmap const&, unsigned int, OutputDevice const*)
SalGraphics::DrawNativeControlText(unsigned int, unsigned int, Rectangle const&, unsigned int, ImplControlValue const&, rtl::OUString const&, OutputDevice const*)
SalGraphics::drawAlphaBitmap(SalTwoRect const&, SalBitmap const&, SalBitmap const&)
......
......@@ -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;
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment