summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2011-03-21 17:42:51 +0000
committerMichael Meeks <michael.meeks@novell.com>2011-03-21 21:18:41 +0000
commit138b9c36f7148680dd46fe71ec1aeb6b9013bb27 (patch)
tree09f43e02e05c0ecb0c28f297241c9b2ac335f29f
parentff3904f63805811a0b48aa1b1e767ed777d8bdd2 (diff)
misc fixes, and un-conditionally enable the splash reporting component
Lots of re-work here; un-conditionally use the splash component to do more intelligent fast starting. Throw up the splash screen before we start doing 'pagein' work (to get better progress / launch feedback), and hide javaldx too.
-rwxr-xr-xdesktop/prj/d.lst1
-rw-r--r--desktop/unx/source/args.c20
-rw-r--r--desktop/unx/source/args.h6
-rwxr-xr-xdesktop/unx/source/makefile.mk4
-rwxr-xr-xdesktop/unx/source/splashx.c4
-rwxr-xr-xdesktop/unx/source/start.c458
-rwxr-xr-xdesktop/unx/splash/exports.map1
-rwxr-xr-xdesktop/unx/splash/makefile.mk20
-rwxr-xr-xdesktop/unx/splash/services_unxsplash.cxx160
-rwxr-xr-xdesktop/unx/splash/unxsplash.cxx68
-rwxr-xr-xdesktop/unx/splash/unxsplash.hxx12
11 files changed, 329 insertions, 425 deletions
diff --git a/desktop/prj/d.lst b/desktop/prj/d.lst
index 6c9f53824346..bb18fe3ff945 100755
--- a/desktop/prj/d.lst
+++ b/desktop/prj/d.lst
@@ -144,3 +144,4 @@ mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Jobs
..\%__SRC%\misc\productregistration.jar.component %_DEST%\xml%_EXT%\productregistration.jar.component
..\%__SRC%\misc\socomp.component %_DEST%\xml%_EXT%\socomp.component
..\%__SRC%\misc\spl.component %_DEST%\xml%_EXT%\spl.component
+..\%__SRC%\misc\splash.component %_DEST%\xml%_EXT%\splash.component
diff --git a/desktop/unx/source/args.c b/desktop/unx/source/args.c
index ff08cacf3994..a438f76a7ca5 100644
--- a/desktop/unx/source/args.c
+++ b/desktop/unx/source/args.c
@@ -48,7 +48,7 @@ static struct {
unsigned int bInhibitSplash : 1;
unsigned int bInhibitPagein : 1;
unsigned int bInhibitJavaLdx : 1;
- const char *pagein_type;
+ const char *pPageinType;
} pArgDescr[] = {
/* have a trailing argument */
{ "pt", 1, 0, 0, 0, NULL },
@@ -73,14 +73,16 @@ static struct {
{ "?", 0, 1, 1, 1, NULL },
};
-Args *parse_args (void)
+Args *args_parse (void)
{
Args *args;
sal_uInt32 nArgs, i, j;
sal_Bool skipNextArg;
nArgs = osl_getCommandArgCount();
- args = malloc (sizeof (Args) + sizeof (rtl_uString *) * nArgs);
+ i = sizeof (Args) + sizeof (rtl_uString *) * nArgs;
+ args = malloc (i);
+ memset (args, 0, i);
args->nArgsTotal = nArgs;
/* sort the -env: args to the front */
@@ -130,8 +132,8 @@ Args *parse_args (void)
args->bInhibitSplash |= pArgDescr[j].bInhibitSplash;
args->bInhibitPagein |= pArgDescr[j].bInhibitPagein;
args->bInhibitJavaLdx |= pArgDescr[j].bInhibitJavaLdx;
- if (pArgDescr[j].pagein_type)
- args->pagein_type = pArgDescr[j].pagein_type;
+ if (pArgDescr[j].pPageinType)
+ args->pPageinType = pArgDescr[j].pPageinType;
skipNextArg = pArgDescr[j].bTwoArgs;
}
@@ -141,4 +143,12 @@ Args *parse_args (void)
return args;
}
+void
+args_free (Args *args)
+{
+ /* FIXME: free ppArgs */
+ rtl_uString_release( args->pAppPath );
+ free (args);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/unx/source/args.h b/desktop/unx/source/args.h
index 44ddf6710aef..4a0cb55ffcde 100644
--- a/desktop/unx/source/args.h
+++ b/desktop/unx/source/args.h
@@ -33,7 +33,8 @@
#include <rtl/ustring.h>
typedef struct {
- const char *pagein_type; // @pagein-writer for - writer etc. else NULL
+ rtl_uString *pAppPath;
+ const char *pPageinType; // @pagein-writer for - writer etc. else NULL
sal_Bool bInhibitSplash; // should we show a splash screen
sal_Bool bInhibitPagein; // should we run pagein ?
sal_Bool bInhibitJavaLdx; // should we run javaldx ?
@@ -43,6 +44,7 @@ typedef struct {
rtl_uString *ppArgs[1]; // sorted argument array
} Args;
-Args *parse_args (void);
+Args *args_parse (void);
+void args_free (Args *args);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/unx/source/makefile.mk b/desktop/unx/source/makefile.mk
index e406ce488e8a..f7400867cab2 100755
--- a/desktop/unx/source/makefile.mk
+++ b/desktop/unx/source/makefile.mk
@@ -32,7 +32,7 @@ NO_DEFAULT_STL=TRUE
.INCLUDE : settings.mk
-.IF "$(ENABLE_QUICKSTART_LIBPNG)"!="TRUE"
+.IF "$(ENABLE_QUICKSTART_LIBPNG)"=="TRUE"
CFLAGS+=-DENABLE_QUICKSTART_LIBPNG
.ENDIF
@@ -53,7 +53,7 @@ APP1RPATH = BRAND
APP1OBJS = $(OBJFILES) $(PAGEIN_OBJS)
APP1LIBSALCPPRT=
APP1CODETYPE = C
-APP1STDLIBS = $(STDLIBGUIMT) $(SALLIB) $(LIBPNG_LIBS)
+APP1STDLIBS = $(PTHREAD_LIBS) $(X11LINK_DYNAMIC) $(SALLIB) $(LIBPNG_LIBS)
.IF "$(OS)"=="SOLARIS"
APP1STDLIBS+= -lsocket
.ENDIF
diff --git a/desktop/unx/source/splashx.c b/desktop/unx/source/splashx.c
index 9cc6832399b5..9e0d237decc6 100755
--- a/desktop/unx/source/splashx.c
+++ b/desktop/unx/source/splashx.c
@@ -629,13 +629,16 @@ void splash_close_window()
int splash_load_bmp( const char *filename )
{
+ (void)filename;
return 1;
}
void splash_setup( int barc[3], int framec[3], int posx, int posy, int w, int h )
{
+ (void)barc; (void)framec; (void)posx; (void)posy; (void)w; (void)h;
}
int splash_create_window( int argc, char** argv )
{
+ (void)argc; (void)argv;
return 1;
}
void splash_close_window()
@@ -643,6 +646,7 @@ void splash_close_window()
}
void splash_draw_progress( int progress )
{
+ (void)progress;
}
#endif // ENABLE_QUICKSTART_LIBPNG
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index 5a81b0320ba0..0393b71934bc 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -54,8 +54,6 @@
#define PIPEDEFAULTPATH "/tmp"
#define PIPEALTERNATEPATH "/var/tmp"
-typedef enum { ProgressContinue, ProgressRestart, ProgressExit } ProgressStatus;
-
/* Easier conversions: rtl_uString to rtl_String */
static rtl_String *
ustr_to_str( rtl_uString *pStr )
@@ -95,6 +93,115 @@ ustr_debug( const char *pMessage, rtl_uString *pStr )
#define ustr_debug( a, b ) {}
#endif
+typedef struct {
+ int status_fd;
+ oslProcess child;
+} ChildInfo;
+
+static int
+child_info_get_status_fd (ChildInfo *info)
+{
+ return info->status_fd;
+}
+
+static void
+child_info_destroy (ChildInfo *info)
+{
+ close (info->status_fd);
+ osl_freeProcessHandle (info->child);
+ free (info);
+}
+
+static ChildInfo *
+child_spawn ( Args *args, sal_Bool bAllArgs, sal_Bool bWithStatus )
+{
+ rtl_uString *pApp = NULL, *pTmp = NULL;
+ rtl_uString **ppArgs;
+ sal_uInt32 nArgs, i;
+ char buffer[64];
+ ChildInfo *info;
+ int status_pipe[2];
+ oslProcessError nError;
+
+ info = calloc (1, sizeof (ChildInfo));
+
+ /* create pipe */
+ if ( pipe( status_pipe ) < 0 )
+ {
+ fprintf( stderr, "ERROR: no file handles\n");
+ exit( 1 );
+ }
+ info->status_fd = status_pipe[0];
+
+ /* application name */
+ rtl_uString_newFromAscii( &pApp, "file://" );
+ rtl_uString_newConcat( &pApp, pApp, args->pAppPath );
+ rtl_uString_newFromAscii( &pTmp, "/soffice.bin" );
+ rtl_uString_newConcat( &pApp, pApp, pTmp );
+
+ rtl_uString_new( &pTmp );
+
+ /* copy args */
+ nArgs = bAllArgs ? args->nArgsTotal : args->nArgsEnv;
+ ppArgs = (rtl_uString **)calloc( nArgs + 1, sizeof( rtl_uString* ) );
+ for ( i = 0; i < nArgs; ++i )
+ ppArgs[i] = args->ppArgs[i];
+
+ if( bWithStatus )
+ {
+ /* add the pipe arg */
+ snprintf (buffer, 63, "--splash-pipe=%d", status_pipe[1]);
+ ppArgs[nArgs] = NULL;
+ rtl_uString_newFromAscii( &ppArgs[nArgs], buffer );
+ ++nArgs;
+ }
+
+ /* start the main process */
+ nError = osl_executeProcess( pApp, ppArgs, nArgs,
+ osl_Process_NORMAL,
+ NULL,
+ NULL,
+ NULL, 0,
+ &info->child );
+
+ if ( nError != osl_Process_E_None )
+ {
+ fprintf( stderr, "ERROR %d forking process", nError );
+ ustr_debug( "", pApp );
+ _exit (1);
+ }
+
+ close( status_pipe[1] );
+
+ return info;
+}
+
+static sal_Bool
+child_exited_wait (ChildInfo *info, sal_Bool bShortWait)
+{
+ TimeValue t = { 0, 250 /* ms */ * 1000 * 1000 };
+ if (!bShortWait)
+ t.Seconds = 1024;
+ return osl_joinProcessWithTimeout (info->child, &t) != osl_Process_E_TimedOut;
+}
+
+static int
+child_get_exit_code (ChildInfo *info)
+{
+ oslProcessInfo inf;
+
+ inf.Code = -1;
+ inf.Size = sizeof (inf);
+ if (osl_getProcessInfo (info->child, osl_Process_EXITCODE, &inf) != osl_Process_E_None)
+ {
+ fprintf (stderr, "Warning: failed to fetch libreoffice exit status\n");
+ return -1;
+ }
+ return inf.Code;
+}
+
+typedef enum { ProgressContinue, ProgressRestart, ProgressExit } ProgressStatus;
+
/* Path of the application. */
static rtl_uString *
get_app_path( const char *pAppExec )
@@ -495,7 +602,7 @@ get_bootstrap_value( int *array, int size, rtlBootstrapHandle handle, const char
/* Load the colors and size of the splash. */
static void
-load_splash_defaults( rtl_uString *pAppPath, sal_Bool *pInhibitSplash )
+load_splash_defaults( rtl_uString *pAppPath, sal_Bool *bNoDefaults )
{
rtl_uString *pSettings = NULL, *pTmp = NULL;
rtlBootstrapHandle handle;
@@ -525,7 +632,7 @@ load_splash_defaults( rtl_uString *pAppPath, sal_Bool *pInhibitSplash )
get_bootstrap_value( size, 2, handle, "ProgressSize" );
if ( logo[0] == 0 )
- *pInhibitSplash = sal_True;
+ *bNoDefaults = sal_True;
splash_setup( bar, frame, pos[0], pos[1], size[0], size[1] );
@@ -539,7 +646,7 @@ load_splash_defaults( rtl_uString *pAppPath, sal_Bool *pInhibitSplash )
/* Read the percent to show in splash. */
static ProgressStatus
-read_percent( int status_fd, int *pPercent )
+read_percent( ChildInfo *info, int *pPercent )
{
static char pBuffer[BUFFER_LEN + 1];
static char *pNext = pBuffer;
@@ -556,7 +663,8 @@ read_percent( int status_fd, int *pPercent )
memmove( pBuffer, pNext, nNotProcessed );
/* read data */
- nRead = read( status_fd, pBuffer + nNotProcessed, BUFFER_LEN - nNotProcessed );
+ nRead = read( child_info_get_status_fd (info),
+ pBuffer + nNotProcessed, BUFFER_LEN - nNotProcessed );
if ( nRead < 0 )
return sal_False;
@@ -567,11 +675,13 @@ read_percent( int status_fd, int *pPercent )
pBegin = pBuffer;
pNext = pBuffer;
for ( pIter = pBuffer; *pIter; ++pIter )
+ {
if ( *pIter == '\n' )
{
pBegin = pNext;
pNext = pIter + 1;
}
+ }
#if OSL_DEBUG_LEVEL > 0
fprintf( stderr, "Got status: %s\n", pBegin );
@@ -587,50 +697,6 @@ read_percent( int status_fd, int *pPercent )
return ProgressExit;
}
-/* Periodically update the splash & the percent acconding to what
- status_fd says */
-static ProgressStatus
-show_splash( int status_fd )
-{
- int nRetval;
- struct pollfd aPfd;
-
- int nPercent = 0;
- sal_Bool bFinish = sal_False;
- ProgressStatus eResult = ProgressExit;
-
- /* we want to watch status_fd */
- aPfd.fd = status_fd;
- aPfd.events = POLLIN;
-
-#if OSL_DEBUG_LEVEL > 0
- fprintf( stderr, "Starting main loop, status fd: %d\n", status_fd );
-#endif
-
- /* main loop */
- do {
- splash_draw_progress( nPercent );
-
- /* read from pipe if data available */
- nRetval = poll( &aPfd, 1, 50 );
- if ( aPfd.revents & ( POLLERR | POLLHUP | POLLNVAL ) )
- bFinish = sal_True;
- else if ( nRetval > 0 )
- {
- eResult = read_percent( status_fd, &nPercent );
- bFinish = ( eResult != ProgressContinue );
- }
- else if ( nRetval < 0 )
- bFinish = sal_True;
- } while ( !bFinish );
-
-#if OSL_DEBUG_LEVEL > 0
- fprintf( stderr, "Finishing, result is %s\n",
- ( eResult == ProgressContinue )? "continue" : ( ( eResult == ProgressRestart )? "restart" : "exit" ) );
-#endif
- return eResult;
-}
-
/* Simple system check. */
static void
system_checks( void )
@@ -650,11 +716,6 @@ system_checks( void )
/* re-use the pagein code */
extern int pagein_execute (int argc, char **argv);
-/* parameters from the main thread */
-int status_fd = 0;
-int status_pipe[2];
-rtl_uString *pAppPath = NULL;
-
void
exec_pagein (Args *args)
{
@@ -663,10 +724,10 @@ exec_pagein (Args *args)
argv[0] = "dummy-pagein";
argv[1] = "-L../basis-link/program";
argv[2] = "@pagein-common";
- argv[3] = (char *)args->pagein_type;
+ argv[3] = (char *)args->pPageinType;
argv[4] = NULL;
- pagein_execute (args->pagein_type ? 4 : 3, argv);
+ pagein_execute (args->pPageinType ? 4 : 3, argv);
}
static void extend_library_path (const char *new_element)
@@ -698,11 +759,11 @@ static void extend_library_path (const char *new_element)
static void
exec_javaldx (Args *args)
{
- char *newpath;
- sal_Sequence *line;
+ char newpath[4096];
sal_uInt32 nArgs;
- rtl_uString *pApp = NULL;
+ rtl_uString *pApp;
rtl_uString **ppArgs;
+ rtl_uString *pTmp, *pTmp2;
rtl_uString *pEnvironment[1] = { NULL };
ppArgs = (rtl_uString **)calloc( args->nArgsEnv + 2, sizeof( rtl_uString* ) );
@@ -710,22 +771,38 @@ exec_javaldx (Args *args)
for ( nArgs = 0; nArgs < args->nArgsEnv; ++nArgs )
ppArgs[nArgs] = args->ppArgs[nArgs];
- /* FIXME: do we need to check / turn program/redirectrc into an absolute path ? */
- rtl_uString_newFromAscii( &ppArgs[nArgs++], "-env:INIFILENAME=vnd.sun.star.pathname:./redirectrc" );
+ /* Use absolute path to redirectrc */
+ pTmp = NULL;
+ rtl_uString_newFromAscii( &pTmp, "-env:INIFILENAME=vnd.sun.star.pathname:" );
+ rtl_uString_newConcat( &pTmp, pTmp, args->pAppPath );
+ pTmp2 = NULL;
+ rtl_uString_newFromAscii( &pTmp2, "/redirectrc" );
+ rtl_uString_newConcat( &pTmp, pTmp, pTmp2 );
+ ppArgs[nArgs] = pTmp;
+ rtl_uString_release (pTmp2);
+ nArgs++;
oslProcess javaldx = NULL;
oslFileHandle fileOut= 0;
oslProcessError err;
- rtl_uString_newFromAscii( &pApp, "../ure/bin/javaldx" );
- /* unset to avoid bogus output */
+ /* And also to javaldx */
+ pApp = NULL;
+ rtl_uString_newFromAscii( &pApp, "file://" );
+ rtl_uString_newConcat( &pApp, pApp, args->pAppPath );
+ pTmp = NULL;
+ rtl_uString_newFromAscii( &pTmp, "/../ure/bin/javaldx" );
+ rtl_uString_newConcat( &pApp, pApp, pTmp );
+
+ /* unset to avoid bogus console output */
rtl_uString_newFromAscii( &pEnvironment[0], "G_SLICE" );
+
err = osl_executeProcess_WithRedirectedIO( pApp, ppArgs, nArgs,
- osl_Process_HIDDEN,
+ osl_Process_NORMAL,
NULL, // security
NULL, // work dir
pEnvironment, 1,
- &javaldx, // handle
+ &javaldx, // process handle
NULL,
&fileOut,
NULL);
@@ -734,120 +811,29 @@ exec_javaldx (Args *args)
{
fprintf (stderr, "Warning: failed to launch javaldx - java may not fuction correctly\n");
return;
- }
+ } else {
+ char *chomp;
+ sal_uInt64 bytes_read;
- line = NULL;
- if (!osl_readLine (fileOut, &line) || !line) {
- fprintf (stderr, "Warning: failed to read path from javaldx\n");
- return;
- }
+ /* Magically osl_readLine doesn't work with pipes with E_SPIPE - so be this lame instead: */
+ while (osl_readFile (fileOut, newpath, SAL_N_ELEMENTS (newpath), &bytes_read) == osl_File_E_INTR);
- if (!line->nElements)
- fprintf (stderr, "curious - javaldx returns zero length path\n");
- else {
- newpath = malloc (line->nElements + 1);
- strncpy (newpath, line->elements, line->nElements);
- newpath[line->nElements] = '\0';
-
- fprintf (stderr, "Adding javaldx path of '%s'\n", newpath);
- extend_library_path (newpath);
- }
-
- /* FIXME: should we join it first ? */
- osl_freeProcessHandle(javaldx);
-}
-
-static void SAL_CALL
-fork_app_thread( Args *args )
-{
- rtl_uString *pApp = NULL, *pTmp = NULL, *pArg = NULL;
- rtl_uString **ppArgs;
- sal_uInt32 nArgs, i;
- sal_Bool restart;
-
- oslProcess child;
- oslProcessError nError;
-
- if (!args->bInhibitJavaLdx)
- exec_pagein (args);
-
- if (!args->bInhibitJavaLdx)
- exec_javaldx (args);
-
- /* application name */
- rtl_uString_newFromAscii( &pApp, "file://" );
- rtl_uString_newConcat( &pApp, pApp, pAppPath );
- rtl_uString_newFromAscii( &pTmp, "/soffice.bin" );
- rtl_uString_newConcat( &pApp, pApp, pTmp );
-
- rtl_uString_new( &pTmp );
-
- /* copy args */
- nArgs = osl_getCommandArgCount();
- ppArgs = (rtl_uString **)calloc( nArgs + 1, sizeof( rtl_uString* ) );
- for ( i = 0; i < nArgs; ++i )
- {
- ppArgs[i] = NULL;
- osl_getCommandArg( i, &pTmp );
- rtl_uString_newFromString( &(ppArgs[i]), pTmp );
- }
-
- /* add the pipe arg */
- sal_Unicode pUnicode[RTL_USTR_MAX_VALUEOFINT32];
- rtl_ustr_valueOfInt32( pUnicode, status_pipe[1], 10 );
-
- rtl_uString_newFromAscii( &pArg, "--splash-pipe=" );
- rtl_uString_newFromStr( &pTmp, pUnicode );
- rtl_uString_newConcat( &pArg, pArg, pTmp );
-
- ppArgs[nArgs] = NULL;
- rtl_uString_newFromString( &(ppArgs[nArgs]), pArg );
- ++nArgs;
-
- restart = sal_False;
- do
- {
- oslProcessInfo info;
-
- /* start the main process */
- nError = osl_executeProcess( pApp, ppArgs, nArgs,
- osl_Process_NORMAL,
- NULL,
- NULL,
- NULL, 0,
- &child );
-
- if ( nError != osl_Process_E_None )
- {
- fprintf( stderr, "ERROR %d forking process", nError );
- ustr_debug( "", pApp );
- _exit (1);
+ if (bytes_read <= 0) {
+ fprintf (stderr, "Warning: failed to read path from javaldx\n");
+ return;
}
+ newpath[bytes_read] = '\0';
- /* wait for it to complete */
- osl_joinProcess (child);
-
- info.Size = sizeof (info);
- info.Code = 0;
- if (osl_getProcessInfo (child, osl_Process_EXITCODE, &info) != osl_Process_E_None)
- fprintf (stderr, "Warning: failed to fetch libreoffice exit status\n");
-
- switch (info.Code) {
- case 79: // re-start with just -env: parameters
- fprintf (stderr, "FIXME: re-start with just -env: params !\n");
- restart = sal_True;
- break;
- case 81: // re-start with all arguments
- fprintf (stderr, "FIXME: re-start with all params !\n");
- restart = sal_True;
- break;
- default:
- break;
- }
+ if ((chomp = strstr (newpath, "\n")))
+ *chomp = '\0';
}
- while (restart);
- close( status_pipe[1] );
+#if OSL_DEBUG_LEVEL > 0
+ fprintf (stderr, "Adding javaldx path of '%s'\n", newpath);
+#endif
+ extend_library_path (newpath);
+
+ osl_freeProcessHandle(javaldx);
}
SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
@@ -855,88 +841,126 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
int fd = 0;
sal_Bool bSentArgs = sal_False;
rtl_uString *pPipePath = NULL;
- ProgressStatus eResult = ProgressExit;
Args *args;
- fprintf (stderr, "start !\n");
-
/* turn SIGPIPE into an error */
signal( SIGPIPE, SIG_IGN );
- args = parse_args();
-
-#ifndef ENABLE_QUICKSTART_LIBPNG
- /* we can't load and render it anyway */
- args->bInhibitSplash = sal_True;
-#endif
-
- pAppPath = get_app_path( argv[0] );
- if ( !pAppPath )
+ args = args_parse ();
+ args->pAppPath = get_app_path( argv[0] );
+ if ( !args->pAppPath )
{
fprintf( stderr, "ERROR: Can't read app link\n" );
exit( 1 );
}
- ustr_debug( "App path", pAppPath );
+ ustr_debug( "App path", args->pAppPath );
- pPipePath = get_pipe_path( pAppPath );
+#ifndef ENABLE_QUICKSTART_LIBPNG
+ /* we can't load and render it anyway */
+ args->bInhibitSplash = sal_True;
+#endif
- fprintf (stderr, "try pipe !\n");
+ pPipePath = get_pipe_path( args->pAppPath );
if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
{
rtl_uString *pCwdPath = NULL;
osl_getProcessWorkingDir( &pCwdPath );
- fprintf (stderr, "send args !\n");
-
bSentArgs = send_args( fd, pCwdPath );
}
#if OSL_DEBUG_LEVEL > 0
else
ustr_debug( "Failed to connect to pipe", pPipePath );
#endif
+ close( fd );
if ( !bSentArgs )
{
/* we have to prepare for, and exec the binary */
+ int nPercent = 0;
+ ChildInfo *info;
+ sal_Bool bAllArgs = sal_True;
+ sal_Bool bHaveWindow = sal_False;
+ sal_Bool bShortWait, bRestart;
+
+ /* sanity check pieces */
+ system_checks();
+
+ /* load splash image and create window */
+ if ( !args->bInhibitSplash )
+ {
+ sal_Bool bNoDefaults = sal_False;
+ load_splash_image( args->pAppPath );
+ load_splash_defaults( args->pAppPath, &bNoDefaults );
+
+ if (!bNoDefaults &&
+ ( bHaveWindow = splash_create_window( argc, argv ) ) )
+ splash_draw_progress( 0 );
+ }
+
+ /* pagein */
+ if (!args->bInhibitJavaLdx)
+ exec_pagein (args);
+
+ /* javaldx */
+ if (!args->bInhibitJavaLdx)
+ exec_javaldx (args);
+
do {
- /* sanity check pieces */
- system_checks();
+ bRestart = sal_False;
- /* create pipe */
- if ( pipe( status_pipe ) < 0 )
- {
- fprintf( stderr, "ERROR: no file handles\n");
- exit( 1 );
- }
- int status_fd = status_pipe[0];
- osl_createThread( fork_app_thread, args );
+ /* fast updates if we have somewhere to update it to */
+ bShortWait = bHaveWindow;
- if ( !args->bInhibitSplash )
+ /* Periodically update the splash & the percent according
+ to what status_fd says, poll quickly only while starting */
+ info = child_spawn (args, bAllArgs, bShortWait);
+ while (!child_exited_wait (info, bShortWait))
{
- load_splash_image( pAppPath );
- load_splash_defaults( pAppPath, &args->bInhibitSplash );
- }
+ ProgressStatus eResult;
- if ( !args->bInhibitSplash && splash_create_window( argc, argv ) )
- {
- splash_draw_progress( 0 );
- eResult = show_splash( status_fd );
- splash_close_window();
+ splash_draw_progress( nPercent );
+ eResult = read_percent( info, &nPercent );
+ if (eResult != ProgressContinue)
+ {
+ splash_close_window ();
+ bShortWait = sal_False;
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ fprintf( stderr, "Polling, result is %s\n",
+ ( eResult == ProgressContinue )? "continue" :
+ ( ( eResult == ProgressRestart )? "restart" : "exit" ) );
+#endif
}
- close( status_fd );
+#if OSL_DEBUG_LEVEL > 0
+ fprintf (stderr, "Exited with code '%d'\n", child_get_exit_code (info));
+#endif
+
+ switch (child_get_exit_code (info)) {
+ case 79: // re-start with just -env: parameters
+ fprintf (stderr, "FIXME: re-start with just -env: params !\n");
+ bRestart = sal_True;
+ bAllArgs = sal_False;
+ break;
+ case 81: // re-start with all arguments
+ fprintf (stderr, "FIXME: re-start with all params !\n");
+ bRestart = sal_True;
+ bAllArgs = sal_True;
+ break;
+ default:
+ break;
+ }
- fprintf (stderr, "sleep!\n");
- sleep (100);
- } while ( eResult == ProgressRestart );
+ child_info_destroy (info);
+ } while (bRestart);
}
/* cleanup */
- rtl_uString_release( pAppPath );
rtl_uString_release( pPipePath );
-
- close( fd );
+ args_free (args);
return 0;
}
diff --git a/desktop/unx/splash/exports.map b/desktop/unx/splash/exports.map
index ba501f9ae076..218f0536d7e2 100755
--- a/desktop/unx/splash/exports.map
+++ b/desktop/unx/splash/exports.map
@@ -3,7 +3,6 @@ UDK_3_0_0 {
GetVersionInfo;
component_getImplementationEnvironment;
component_getFactory;
- component_writeInfo;
local:
*;
diff --git a/desktop/unx/splash/makefile.mk b/desktop/unx/splash/makefile.mk
index d182173de1ff..23a9d98ae5bb 100755
--- a/desktop/unx/splash/makefile.mk
+++ b/desktop/unx/splash/makefile.mk
@@ -36,17 +36,9 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
-.IF "$(ENABLE_UNIX_QUICKSTARTER)"!="TRUE"
-
-dummy:
- @echo "Unix quickstarter disabled"
-
-.ELSE
-
# --- Files --------------------------------------------------------
-SLOFILES = $(SLO)$/unxsplash.obj \
- $(SLO)$/services_unxsplash.obj
+SLOFILES = $(SLO)$/unxsplash.obj
SHL1DEPN= makefile.mk
SHL1OBJS= $(SLOFILES)
@@ -64,8 +56,14 @@ SHL1STDLIBS= \
$(CPPULIB) \
$(SALLIB)
-.ENDIF # ENABLE_UNIX_QUICKSTARTER
-
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/splash.component
+
+$(MISC)/splash.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ splash.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt splash.component
diff --git a/desktop/unx/splash/services_unxsplash.cxx b/desktop/unx/splash/services_unxsplash.cxx
deleted file mode 100755
index d370b452b4f3..000000000000
--- a/desktop/unx/splash/services_unxsplash.cxx
+++ /dev/null
@@ -1,160 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * Copyright 2010, Novell Inc.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- * Contributor(s): Jan Holesovsky <kendy@novell.com>
- *
- ************************************************************************/
-#include <com/sun/star/beans/NamedValue.hpp>
-#include <com/sun/star/registry/XRegistryKey.hpp>
-#include <com/sun/star/util/Date.hpp>
-#include <uno/environment.h>
-#include <cppuhelper/factory.hxx>
-#include <unotools/configmgr.hxx>
-
-#include <string.h>
-
-#include "unxsplash.hxx"
-
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::registry;
-using namespace ::desktop;
-
-using ::rtl::OUString;
-
-static const char* pServices[] =
-{
- UnxSplashScreen::serviceName,
- NULL
-};
-
-static const char* pImplementations[] =
-{
- UnxSplashScreen::implementationName,
- NULL
-};
-
-typedef Reference<XInterface>(* fProvider)( const Reference<XMultiServiceFactory>& );
-
-static const fProvider pInstanceProviders[] =
-{
- UnxSplashScreen::getInstance,
- NULL
-};
-
-
-static const char** pSupportedServices[] =
-{
- UnxSplashScreen::interfaces,
- NULL
-};
-
-static Sequence<OUString>
-getSupportedServiceNames( int p ) {
- const char **names = pSupportedServices[p];
- Sequence<OUString> aSeq;
- for ( int i = 0; names[i] != NULL; i++ )
- {
- aSeq.realloc( i+1 );
- aSeq[i] = OUString::createFromAscii( names[i] );
- }
- return aSeq;
-}
-
-extern "C"
-{
-void SAL_CALL
-component_getImplementationEnvironment(
- const sal_Char** ppEnvironmentTypeName,
- uno_Environment** /*ppEnvironment*/ )
-{
- *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
-}
-
-sal_Bool SAL_CALL
-component_writeInfo(
- void* pServiceManager,
- void* pRegistryKey )
-{
- Reference<XMultiServiceFactory> xMan(
- reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
- Reference<XRegistryKey> xKey(
- reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ;
-
- // iterate over service names and register them...
- OUString aImpl;
- const char* pServiceName = NULL;
- const char* pImplName = NULL;
- for ( int i = 0; ( pServices[i] != NULL ) && ( pImplementations[i] != NULL ); i++ )
- {
- pServiceName= pServices[i];
- pImplName = pImplementations[i];
- aImpl = OUString(RTL_CONSTASCII_USTRINGPARAM( "/" ))
- + OUString::createFromAscii( pImplName )
- + OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES" ));
- Reference<XRegistryKey> xNewKey = xKey->createKey( aImpl );
- xNewKey->createKey( OUString::createFromAscii( pServiceName ) );
- }
- return sal_True;
-}
-
-void* SAL_CALL
-component_getFactory(
- const sal_Char* pImplementationName,
- void* pServiceManager,
- void* /*pRegistryKey*/ )
-{
- // Set default return value for this operation - if it failed.
- if ( pImplementationName && pServiceManager )
- {
- Reference< XSingleServiceFactory > xFactory;
- Reference< XMultiServiceFactory > xServiceManager(
- reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
-
- // search implementation
- for ( int i = 0; ( pImplementations[i] != NULL ); i++ )
- {
- if ( strcmp( pImplementations[i], pImplementationName ) == 0 )
- {
- // found implementation
- xFactory = Reference<XSingleServiceFactory>( cppu::createSingleFactory(
- xServiceManager, OUString::createFromAscii( pImplementationName ),
- pInstanceProviders[i], getSupportedServiceNames( i ) ) );
- if ( xFactory.is() )
- {
- // Factory is valid - service was found.
- xFactory->acquire();
- return xFactory.get();
- }
- }
- }
- }
-
- return NULL;
-}
-} // extern "C"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/unx/splash/unxsplash.cxx b/desktop/unx/splash/unxsplash.cxx
index f51e22a7c13a..de703ba5c3de 100755
--- a/desktop/unx/splash/unxsplash.cxx
+++ b/desktop/unx/splash/unxsplash.cxx
@@ -34,6 +34,7 @@
#include <tools/stream.hxx>
#include <sfx2/sfx.hrc>
#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <cppuhelper/implementationentry.hxx>
#include <rtl/logfile.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx>
@@ -41,13 +42,13 @@
#define PIPE_ARG "--splash-pipe="
using namespace ::rtl;
+using namespace ::com::sun::star;
using namespace ::com::sun::star::registry;
namespace desktop
{
-
-UnxSplashScreen::UnxSplashScreen( const Reference< XMultiServiceFactory >& rSMgr )
- : m_rFactory( rSMgr ),
+ UnxSplashScreen::UnxSplashScreen( const Reference< uno::XComponentContext >& xCtx )
+ : m_xCtx( xCtx ),
m_pOutFd( NULL )
{
}
@@ -131,34 +132,65 @@ UnxSplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::
}
}
}
+}
+
+using namespace desktop;
// get service instance...
-UnxSplashScreen *UnxSplashScreen::m_pINSTANCE = NULL;
-osl::Mutex UnxSplashScreen::m_aMutex;
+static uno::Reference< uno::XInterface > m_xINSTANCE;
-Reference< XInterface > UnxSplashScreen::getInstance( const Reference< XMultiServiceFactory >& rSMgr )
+uno::Reference< uno::XInterface > SAL_CALL UnxSplash_createInstance(const uno::Reference< uno::XComponentContext > & xCtx ) throw( uno::Exception )
{
- if ( m_pINSTANCE == NULL )
+ static osl::Mutex m_aMutex;
+ if ( !m_xINSTANCE.is() )
{
osl::MutexGuard guard( m_aMutex );
- if ( m_pINSTANCE == NULL )
- return (XComponent*) new UnxSplashScreen( rSMgr );
+ if ( !m_xINSTANCE.is() )
+ m_xINSTANCE = (cppu::OWeakObject*) new UnxSplashScreen( xCtx );
}
- return (XComponent*)NULL;
+ return m_xINSTANCE;
+}
+
+OUString UnxSplash_getImplementationName()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.comp.PipeSplashScreen" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL UnxSplash_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.PipeSplashScreen" ) );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
}
-// static service info...
-const char* UnxSplashScreen::interfaces[] =
+::cppu::ImplementationEntry aEntries[] =
{
- "com.sun.star.task.XStartusIndicator",
- "com.sun.star.lang.XInitialization",
- NULL,
+ {
+ UnxSplash_createInstance, UnxSplash_getImplementationName,
+ UnxSplash_getSupportedServiceNames,
+ ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
};
-const sal_Char *UnxSplashScreen::serviceName = "com.sun.star.office.PipeSplashScreen";
-const sal_Char *UnxSplashScreen::implementationName = "com.sun.star.office.comp.PipeSplashScreen";
-const sal_Char *UnxSplashScreen::supportedServiceNames[] = { "com.sun.star.office.PipeSplashScreen", NULL };
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName,
+ uno_Environment ** )
+{ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; }
+
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL
+component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey )
+{
+ return ::cppu::component_getFactoryHelper( pImplName, pServiceManager,
+ pRegistryKey, aEntries );
}
+} // extern "C"
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/unx/splash/unxsplash.hxx b/desktop/unx/splash/unxsplash.hxx
index abe5a8cac2bd..b25e858d9bac 100755
--- a/desktop/unx/splash/unxsplash.hxx
+++ b/desktop/unx/splash/unxsplash.hxx
@@ -31,6 +31,7 @@
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <cppuhelper/implbase2.hxx>
@@ -54,24 +55,17 @@ private:
UnxSplashScreen( void );
UnxSplashScreen operator =( const UnxSplashScreen& );
- UnxSplashScreen( const Reference< XMultiServiceFactory >& xFactory );
-
virtual ~UnxSplashScreen();
static UnxSplashScreen *m_pINSTANCE;
static osl::Mutex m_aMutex;
- Reference< XMultiServiceFactory > m_rFactory;
+ Reference< XComponentContext > m_xCtx;
FILE *m_pOutFd;
public:
- static const char* interfaces[];
- static const sal_Char *serviceName;
- static const sal_Char *implementationName;
- static const sal_Char *supportedServiceNames[];
-
- static Reference< XInterface > getInstance( const Reference < XMultiServiceFactory >& xFactory );
+ UnxSplashScreen( const Reference< XComponentContext >& xCtx );
// XStatusIndicator
virtual void SAL_CALL start( const OUString& aText, sal_Int32 nRange ) throw ( RuntimeException );