From ee62e73ddc29a5015c4a3e569be90dbfce4652c6 Mon Sep 17 00:00:00 2001 From: sandman Date: Sun, 24 Nov 2002 18:18:35 +0000 Subject: A small library that can be LD_PRELOADed to other applications by the launcher to force these applications to use the Opie style/font/window­ decoration settings. Could also be used for other things in the future... --- (limited to 'core/launcher/libpreload/preload.cpp') diff --git a/core/launcher/libpreload/preload.cpp b/core/launcher/libpreload/preload.cpp new file mode 100644 index 0000000..a94ec65 --- a/dev/null +++ b/core/launcher/libpreload/preload.cpp @@ -0,0 +1,91 @@ + +#define _GNU_SOURCE +//#define private public +//#define protected public + +#include +#include +//#include + +class QStyle; +class QApplication; +class QFont; +class QWSDecoration; + +#include +#include +#include +#include + + +typedef void ( *qapp_setstyle_t ) ( QStyle * ); +typedef void ( *qapp_setdeco_t ) ( QApplication *, QWSDecoration * ); +typedef void ( *qapp_setfont_t ) ( QApplication *, const QFont &, bool, const char * ); + + +static bool *opie_block_style_p = 0; + +extern "C" { + +static void *resolve_symbol ( const char *sym ) +{ + void *adr = ::dlsym ( RTLD_NEXT, sym ); + + if ( !adr ) + ::fprintf ( stderr, "PANIC: Could not resolve symbol \"%s\"\n", sym ); + + return adr; +} + +extern void setStyle__12QApplicationP6QStyle ( QStyle *style ) +{ + static qapp_setstyle_t qsetstyle = 0; + + if ( !qsetstyle ) + qsetstyle = (qapp_setstyle_t) resolve_symbol ( "setStyle__12QApplicationP6QStyle" ); + + if ( !opie_block_style_p ) + opie_block_style_p = (bool *) resolve_symbol ( "opie_block_style" ); + + if ( !qsetstyle || ( opie_block_style_p && *opie_block_style_p )) { + delete style; + return; + } + else + ( *qsetstyle ) ( style ); +} + +extern void setFont__12QApplicationRC5QFontbPCc ( QApplication *app, const QFont &fnt, bool informWidgets, const char * className ) +{ + static qapp_setfont_t qsetfont = 0; + + if ( !qsetfont ) + qsetfont = (qapp_setfont_t) resolve_symbol ( "setFont__12QApplicationRC5QFontbPCc" ); + + if ( !opie_block_style_p ) + opie_block_style_p = (bool *) resolve_symbol ( "opie_block_style" ); + + if ( qsetfont && !( opie_block_style_p && *opie_block_style_p )) + ( *qsetfont ) ( app, fnt, informWidgets, className ); +} + + +extern void qwsSetDecoration__12QApplicationP13QWSDecoration ( QApplication *app, QWSDecoration *deco ) +{ + static qapp_setdeco_t qsetdeco = 0; + + if ( !qsetdeco ) + qsetdeco = (qapp_setdeco_t) resolve_symbol ( "qwsSetDecoration__12QApplicationP13QWSDecoration" ); + + if ( !opie_block_style_p ) + opie_block_style_p = (bool *) resolve_symbol ( "opie_block_style" ); + + if ( !qsetdeco || ( opie_block_style_p && *opie_block_style_p )) { + delete deco; + return; + } + else + ( *qsetdeco ) ( app, deco ); +} + +} -- cgit v0.9.0.2