Kaydet (Commit) fc45189c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Replace medDebug with sal/log.hxx functionality

Change-Id: I30bf94043b5b638260704629356d010c8ea6b4e0
üst 6adc24cd
...@@ -29,15 +29,11 @@ ...@@ -29,15 +29,11 @@
#define _MEDIATOR_HXX #define _MEDIATOR_HXX
#include <string.h> #include <string.h>
#include <stdarg.h>
#include <tools/link.hxx> #include <tools/link.hxx>
#include <osl/pipe.hxx> #include <osl/pipe.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <osl/conditn.hxx> #include <osl/conditn.hxx>
#include <osl/thread.hxx> #include <osl/thread.hxx>
#if OSL_DEBUG_LEVEL > 1
#include <stdio.h>
#endif
#include <vector> #include <vector>
...@@ -164,22 +160,6 @@ class MediatorListener : public osl::Thread ...@@ -164,22 +160,6 @@ class MediatorListener : public osl::Thread
virtual void onTerminated(); virtual void onTerminated();
}; };
inline void medDebug( int condition, const char* pFormat, ... )
{
#if OSL_DEBUG_LEVEL > 1
if( condition )
{
va_list ap;
va_start( ap, pFormat );
vfprintf( stderr, pFormat, ap );
va_end( ap );
}
#else
(void)condition;
(void)pFormat;
#endif
}
#endif // _MEDIATOR_HXX #endif // _MEDIATOR_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -62,7 +62,7 @@ Mediator::~Mediator() ...@@ -62,7 +62,7 @@ Mediator::~Mediator()
aHeader[2] = MEDIATOR_MAGIC; aHeader[2] = MEDIATOR_MAGIC;
ssize_t nToWrite = sizeof(aHeader); ssize_t nToWrite = sizeof(aHeader);
bool bSuccess = (nToWrite == write(m_nSocket, aHeader, nToWrite)); bool bSuccess = (nToWrite == write(m_nSocket, aHeader, nToWrite));
SAL_WARN_IF( !bSuccess, "extensions", "short write"); SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write");
} }
// kick the thread out of its run method; it deletes itself // kick the thread out of its run method; it deletes itself
close( m_nSocket ); close( m_nSocket );
...@@ -100,7 +100,7 @@ sal_uLong Mediator::SendMessage( sal_uLong nBytes, const char* pBytes, sal_uLong ...@@ -100,7 +100,7 @@ sal_uLong Mediator::SendMessage( sal_uLong nBytes, const char* pBytes, sal_uLong
memcpy( &pBuffer[3], pBytes, (size_t)nBytes ); memcpy( &pBuffer[3], pBytes, (size_t)nBytes );
ssize_t nToWrite = nBytes + 3*sizeof( sal_uLong ); ssize_t nToWrite = nBytes + 3*sizeof( sal_uLong );
bool bSuccess = (nToWrite == write( m_nSocket, pBuffer, nToWrite )); bool bSuccess = (nToWrite == write( m_nSocket, pBuffer, nToWrite ));
SAL_WARN_IF( !bSuccess, "extensions", "short write"); SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write");
delete [] pBuffer; delete [] pBuffer;
return nMessageID; return nMessageID;
...@@ -222,16 +222,21 @@ void MediatorListener::run() ...@@ -222,16 +222,21 @@ void MediatorListener::run()
} }
else else
{ {
medDebug( 1, "got incomplete MediatorMessage: { %d, %d, %*s }\n", SAL_WARN(
nHeader[0], nHeader[1], nHeader[1], pBuffer ); "extensions.plugin",
"got incomplete MediatorMessage: { " << nHeader[0] << ", "
<< nHeader[1] << ", ... }");
bRun = false; bRun = false;
} }
delete [] pBuffer; delete [] pBuffer;
} }
else else
{ {
medDebug( 1, "got incomplete message header of %d bytes ( nHeader = [ %u, %u ] ), errno is %d\n", SAL_WARN(
nBytes, nHeader[ 0 ], nHeader[ 1 ], (int)errno ); "extensions.plugin",
"got incomplete message header of " << nBytes
<< " bytes (nHeader = [" << nHeader[0] << ", " << nHeader[1]
<< "]), errno is " << errno);
bRun = false; bRun = false;
} }
} }
...@@ -252,7 +257,9 @@ sal_uLong MediatorMessage::ExtractULONG() ...@@ -252,7 +257,9 @@ sal_uLong MediatorMessage::ExtractULONG()
if( ! m_pRun ) if( ! m_pRun )
m_pRun = m_pBytes; m_pRun = m_pBytes;
medDebug( (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::ExtractULONG\n" ); SAL_WARN_IF(
(sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin",
"overflow in MediatorMessage::ExtractULONG");
sal_uLong nCount; sal_uLong nCount;
memcpy( &nCount, m_pRun, sizeof( sal_uLong ) ); memcpy( &nCount, m_pRun, sizeof( sal_uLong ) );
m_pRun += sizeof( sal_uLong ); m_pRun += sizeof( sal_uLong );
...@@ -264,13 +271,17 @@ void* MediatorMessage::GetBytes( sal_uLong& rBytes ) ...@@ -264,13 +271,17 @@ void* MediatorMessage::GetBytes( sal_uLong& rBytes )
if( ! m_pRun ) if( ! m_pRun )
m_pRun = m_pBytes; m_pRun = m_pBytes;
medDebug( (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetBytes\n" ); SAL_WARN_IF(
(sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin",
"overflow in MediatorMessage::GetBytes");
sal_uLong nBytes = ExtractULONG(); sal_uLong nBytes = ExtractULONG();
if( nBytes == 0 ) if( nBytes == 0 )
return NULL; return NULL;
medDebug( (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetBytes\n" ); SAL_WARN_IF(
(sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin",
"overflow in MediatorMessage::GetBytes");
char* pBuffer = new char[ nBytes ]; char* pBuffer = new char[ nBytes ];
memcpy( pBuffer, m_pRun, nBytes ); memcpy( pBuffer, m_pRun, nBytes );
m_pRun += nBytes; m_pRun += nBytes;
...@@ -283,13 +294,17 @@ char* MediatorMessage::GetString() ...@@ -283,13 +294,17 @@ char* MediatorMessage::GetString()
if( ! m_pRun ) if( ! m_pRun )
m_pRun = m_pBytes; m_pRun = m_pBytes;
medDebug( (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetString\n" ); SAL_WARN_IF(
(sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin",
"overflow in MediatorMessage::GetString");
sal_uLong nBytes = ExtractULONG(); sal_uLong nBytes = ExtractULONG();
if( nBytes == 0 ) if( nBytes == 0 )
return NULL; return NULL;
medDebug( (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetString\n" ); SAL_WARN_IF(
(sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin",
"overflow in MediatorMessage::GetString");
char* pBuffer = new char[ nBytes+1 ]; char* pBuffer = new char[ nBytes+1 ];
memcpy( pBuffer, m_pRun, nBytes ); memcpy( pBuffer, m_pRun, nBytes );
pBuffer[ nBytes ] = 0; pBuffer[ nBytes ] = 0;
...@@ -302,10 +317,16 @@ sal_uInt32 MediatorMessage::GetUINT32() ...@@ -302,10 +317,16 @@ sal_uInt32 MediatorMessage::GetUINT32()
if( ! m_pRun ) if( ! m_pRun )
m_pRun = m_pBytes; m_pRun = m_pBytes;
medDebug( (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetUINT32\n" ); SAL_WARN_IF(
(sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin",
"overflow in MediatorMessage::GetUINT32");
sal_uLong nBytes = ExtractULONG(); sal_uLong nBytes = ExtractULONG();
medDebug( nBytes != sizeof( sal_uInt32 ), "No sal_uInt32 in MediatorMessage::GetUINT32\n" ); SAL_WARN_IF(
medDebug( (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetUINT32\n" ); nBytes != sizeof( sal_uInt32 ), "extensions.plugin",
"no sal_uInt32 in MediatorMessage::GetUINT32");
SAL_WARN_IF(
(sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin",
"overflow in MediatorMessage::GetUINT32");
sal_uInt32 nRet; sal_uInt32 nRet;
memcpy( &nRet, m_pRun, sizeof( nRet ) ); memcpy( &nRet, m_pRun, sizeof( nRet ) );
m_pRun += sizeof( sal_uInt32 ); m_pRun += sizeof( sal_uInt32 );
......
...@@ -96,7 +96,7 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ ) ...@@ -96,7 +96,7 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
while( (pMessage = GetNextMessage( sal_False )) ) while( (pMessage = GetNextMessage( sal_False )) )
{ {
nCommand = (CommandAtoms)pMessage->GetUINT32(); nCommand = (CommandAtoms)pMessage->GetUINT32();
medDebug( 1, "%s\n", GetCommandName( nCommand ) ); SAL_INFO("extensions.plugin", GetCommandName(nCommand));
switch( nCommand ) switch( nCommand )
{ {
case eNPN_GetURL: case eNPN_GetURL:
...@@ -146,11 +146,16 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ ) ...@@ -146,11 +146,16 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID ); m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID );
} }
else else
medDebug( 1, "StreamID %d has incoherent urls %s and %s\n", SAL_WARN(
nFileID, pUrl, m_aNPWrapStreams[ nFileID ]->url ); "extensions.plugin",
"StreamID " << nFileID << " has incoherent urls "
<< pUrl << " and "
<< m_aNPWrapStreams[nFileID]->url);
} }
else else
medDebug( 1, "Nonexistent StreamID %d\n", nFileID ); SAL_WARN(
"extensions.plugin",
"nonexistent StreamID " << nFileID);
Respond( pMessage->m_nID, Respond( pMessage->m_nID,
(char*)(&aRet), sizeof( NPError ), NULL ); (char*)(&aRet), sizeof( NPError ), NULL );
...@@ -310,7 +315,9 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ ) ...@@ -310,7 +315,9 @@ IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
} }
break; break;
default: default:
medDebug( 1, "caught unknown NPN request %d\n", nCommand ); SAL_WARN(
"extensions.plugin",
"caught unknown NPN request " << +nCommand);
} }
delete pMessage; delete pMessage;
......
...@@ -63,10 +63,10 @@ static bool bPluginAppQuit = false; ...@@ -63,10 +63,10 @@ static bool bPluginAppQuit = false;
static long GlobalConnectionLostHdl( void* /*pInst*/, void* /*pArg*/ ) static long GlobalConnectionLostHdl( void* /*pInst*/, void* /*pArg*/ )
{ {
medDebug( 1, "pluginapp exiting due to connection lost\n" ); SAL_WARN("extensions.plugin", "pluginapp exiting due to connection lost");
bool bSuccess = (4 == write(wakeup_fd[1], "xxxx", 4 )); bool bSuccess = (4 == write(wakeup_fd[1], "xxxx", 4 ));
SAL_WARN_IF( !bSuccess, "extensions", "short write"); SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write");
return 0; return 0;
} }
...@@ -95,7 +95,7 @@ extern "C" ...@@ -95,7 +95,7 @@ extern "C"
// it seems you can use XtRemoveInput only // it seems you can use XtRemoveInput only
// safely from within the callback // safely from within the callback
// why is that ? // why is that ?
medDebug( 1, "removing wakeup pipe\n" ); SAL_INFO("extensions.plugin", "removing wakeup pipe");
XtRemoveInput( *id ); XtRemoveInput( *id );
XtAppSetExitFlag( app_context ); XtAppSetExitFlag( app_context );
bPluginAppQuit = true; bPluginAppQuit = true;
...@@ -111,9 +111,9 @@ extern "C" ...@@ -111,9 +111,9 @@ extern "C"
IMPL_LINK( PluginConnector, NewMessageHdl, Mediator*, /*pMediator*/ ) IMPL_LINK( PluginConnector, NewMessageHdl, Mediator*, /*pMediator*/ )
{ {
medDebug( 1, "new message handler\n" ); SAL_INFO("extensions.plugin", "new message handler");
bool bSuccess = (4 == write(wakeup_fd[1], "cccc", 4)); bool bSuccess = (4 == write(wakeup_fd[1], "cccc", 4));
SAL_WARN_IF( !bSuccess, "extensions", "short write"); SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write");
return 0; return 0;
} }
...@@ -135,7 +135,10 @@ Widget createSubWidget( char* /*pPluginText*/, Widget shell, XLIB_Window aParent ...@@ -135,7 +135,10 @@ Widget createSubWidget( char* /*pPluginText*/, Widget shell, XLIB_Window aParent
XtRealizeWidget( shell ); XtRealizeWidget( shell );
XtRealizeWidget( newWidget ); XtRealizeWidget( newWidget );
medDebug( 1, "Reparenting new widget %x to %x\n", XtWindow( newWidget ), aParentWindow ); SAL_INFO(
"extensions.plugin",
"reparenting new widget " << XtWindow( newWidget ) << " to "
<< aParentWindow);
XReparentWindow( pXtAppDisplay, XReparentWindow( pXtAppDisplay,
XtWindow( shell ), XtWindow( shell ),
aParentWindow, aParentWindow,
...@@ -178,10 +181,7 @@ static oslModule LoadModule( const char* pPath ) ...@@ -178,10 +181,7 @@ static oslModule LoadModule( const char* pPath )
osl_getFileURLFromSystemPath( sSystemPath.pData, &sFileURL.pData ); osl_getFileURLFromSystemPath( sSystemPath.pData, &sFileURL.pData );
oslModule pLib = osl_loadModule( sFileURL.pData, SAL_LOADMODULE_LAZY ); oslModule pLib = osl_loadModule( sFileURL.pData, SAL_LOADMODULE_LAZY );
if( ! pLib ) SAL_INFO_IF(!pLib, "extensions.plugin", "could not open " << pPath);
{
medDebug( 1, "could not open %s: %s\n", pPath, dlerror() );
}
return pLib; return pLib;
} }
...@@ -189,15 +189,18 @@ static oslModule LoadModule( const char* pPath ) ...@@ -189,15 +189,18 @@ static oslModule LoadModule( const char* pPath )
static void CheckPlugin( const char* pPath ) static void CheckPlugin( const char* pPath )
{ {
oslModule pLib = LoadModule( pPath ); oslModule pLib = LoadModule( pPath );
if (pLib != 0)
char*(*pNP_GetMIMEDescription)() = (char*(*)()) {
osl_getAsciiFunctionSymbol( pLib, "NP_GetMIMEDescription" ); char*(*pNP_GetMIMEDescription)() = (char*(*)())
if( pNP_GetMIMEDescription ) osl_getAsciiFunctionSymbol( pLib, "NP_GetMIMEDescription" );
printf( "%s\n", pNP_GetMIMEDescription() ); if( pNP_GetMIMEDescription )
else printf( "%s\n", pNP_GetMIMEDescription() );
medDebug( 1, "could not get symbol NP_GetMIMEDescription %s\n", dlerror() ); else
SAL_WARN(
osl_unloadModule( pLib ); "extensions.plugin",
"could not get symbol NP_GetMIMEDescription " << dlerror());
osl_unloadModule( pLib );
}
} }
#if OSL_DEBUG_LEVEL > 1 && defined LINUX #if OSL_DEBUG_LEVEL > 1 && defined LINUX
...@@ -351,7 +354,7 @@ int main( int argc, char **argv) ...@@ -351,7 +354,7 @@ int main( int argc, char **argv)
if( pipe( wakeup_fd ) ) if( pipe( wakeup_fd ) )
{ {
medDebug( 1, "could not pipe()\n" ); SAL_WARN("extensions.plugin", "could not pipe()");
return 1; return 1;
} }
// initialize 'wakeup' pipe. // initialize 'wakeup' pipe.
...@@ -410,7 +413,7 @@ int main( int argc, char **argv) ...@@ -410,7 +413,7 @@ int main( int argc, char **argv)
GSource* pXTSource = g_source_new( &aXtEventFuncs, sizeof(GSource) ); GSource* pXTSource = g_source_new( &aXtEventFuncs, sizeof(GSource) );
if( !pXTSource ) if( !pXTSource )
{ {
medDebug( 1, "could not get Xt GSource" ); SAL_WARN("extensions.plugin", "could not get Xt GSource");
return 1; return 1;
} }
...@@ -427,7 +430,7 @@ int main( int argc, char **argv) ...@@ -427,7 +430,7 @@ int main( int argc, char **argv)
GSource *pWakeupSource = g_source_new( &aWakeupEventFuncs, sizeof(GSource) ); GSource *pWakeupSource = g_source_new( &aWakeupEventFuncs, sizeof(GSource) );
if ( pWakeupSource == NULL ) if ( pWakeupSource == NULL )
{ {
medDebug( 1, "could not get wakeup source" ); SAL_WARN("extensions.plugin", "could not get wakeup source");
return 1; return 1;
} }
g_source_set_priority( pWakeupSource, GDK_PRIORITY_EVENTS); g_source_set_priority( pWakeupSource, GDK_PRIORITY_EVENTS);
...@@ -483,16 +486,16 @@ int main( int argc, char **argv) ...@@ -483,16 +486,16 @@ int main( int argc, char **argv)
#endif #endif
} while( ! XtAppGetExitFlag( app_context ) && ! bPluginAppQuit ); } while( ! XtAppGetExitFlag( app_context ) && ! bPluginAppQuit );
medDebug( 1, "left plugin app main loop\n" ); SAL_INFO("extensions.plugin", "left plugin app main loop");
#ifdef ENABLE_GTK #ifdef ENABLE_GTK
g_source_remove(xt_polling_timer_id); g_source_remove(xt_polling_timer_id);
#endif #endif
pNP_Shutdown(); pNP_Shutdown();
medDebug( 1, "NP_Shutdown done\n" ); SAL_INFO("extensions.plugin", "NP_Shutdown done");
osl_unloadModule( pPluginLib ); osl_unloadModule( pPluginLib );
medDebug( 1, "plugin close\n" ); SAL_INFO("extensions.plugin", "plugin close");
close( wakeup_fd[0] ); close( wakeup_fd[0] );
close( wakeup_fd[1] ); close( wakeup_fd[1] );
......
...@@ -44,7 +44,7 @@ sal_uInt32 PluginConnector::GetStreamID( NPStream* pStream ) ...@@ -44,7 +44,7 @@ sal_uInt32 PluginConnector::GetStreamID( NPStream* pStream )
for( size_t i = 0; i < nLen; i++ ) for( size_t i = 0; i < nLen; i++ )
if( m_aNPWrapStreams[ i ] == pStream ) if( m_aNPWrapStreams[ i ] == pStream )
return static_cast<sal_uInt32>(i); return static_cast<sal_uInt32>(i);
medDebug( 1, "Error: NPStream has no ID\n" ); SAL_WARN("extensions.plugin", "NPStream has no ID");
return UnknownStreamID; return UnknownStreamID;
} }
...@@ -54,7 +54,7 @@ sal_uInt32 PluginConnector::GetNPPID( NPP instance ) ...@@ -54,7 +54,7 @@ sal_uInt32 PluginConnector::GetNPPID( NPP instance )
for( size_t i=0; i <nLen; i++ ) for( size_t i=0; i <nLen; i++ )
if( m_aInstances[ i ]->instance == instance ) if( m_aInstances[ i ]->instance == instance )
return static_cast<sal_uInt32>(i); return static_cast<sal_uInt32>(i);
medDebug( 1, "Error: NPP has no ID\n" ); SAL_WARN("extensions.plugin", "NPP has no ID");
return UnknownNPPID; return UnknownNPPID;
} }
......
...@@ -74,6 +74,7 @@ certain functionality. ...@@ -74,6 +74,7 @@ certain functionality.
@section extensions @section extensions
@li @c extensions.plugin
@li @c extensions.scanner @li @c extensions.scanner
@section Filter @section Filter
......
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