mirror of https://github.com/cutefishos/appmotor
				
				
				
			New: Basic implementation of the e-booster.
							parent
							
								
									038bf86bc5
								
							
						
					
					
						commit
						28d852e015
					
				@ -0,0 +1,28 @@
 | 
			
		||||
# Qt support
 | 
			
		||||
include(${QT_USE_FILE})
 | 
			
		||||
 | 
			
		||||
set(LAUNCHER "${CMAKE_HOME_DIRECTORY}/src/launcherlib")
 | 
			
		||||
set(COMMON "${CMAKE_HOME_DIRECTORY}/src/common")
 | 
			
		||||
 | 
			
		||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${COMMON} ${LAUNCHER})
 | 
			
		||||
 | 
			
		||||
# Hide all symbols except the ones explicitly exported in the code (like main())
 | 
			
		||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
 | 
			
		||||
 | 
			
		||||
# Set sources
 | 
			
		||||
set(SRC ebooster.cpp pluginfactory.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp
 | 
			
		||||
${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp
 | 
			
		||||
${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp
 | 
			
		||||
${COMMON}/eventhandler.cpp)
 | 
			
		||||
 | 
			
		||||
set(MOC_HDRS ${COMMON}/eventhandler.h)
 | 
			
		||||
qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})
 | 
			
		||||
 | 
			
		||||
# Set libraries to be linked.
 | 
			
		||||
link_libraries(${MEEGOTOUCH_LIBRARIES} ${LIBDL} ${QT_QTCORE_LIBRARY})
 | 
			
		||||
 | 
			
		||||
# Set executable
 | 
			
		||||
add_library(ebooster MODULE ${SRC} ${MOC_SRC})
 | 
			
		||||
 | 
			
		||||
# Add install rule
 | 
			
		||||
install(TARGETS ebooster DESTINATION /usr/lib/applauncherd/)
 | 
			
		||||
@ -0,0 +1,87 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
**
 | 
			
		||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 | 
			
		||||
** All rights reserved.
 | 
			
		||||
** Contact: Nokia Corporation (directui@nokia.com)
 | 
			
		||||
**
 | 
			
		||||
** This file is part of applauncherd
 | 
			
		||||
**
 | 
			
		||||
** If you have questions regarding the use of this file, please contact
 | 
			
		||||
** Nokia at directui@nokia.com.
 | 
			
		||||
**
 | 
			
		||||
** This library is free software; you can redistribute it and/or
 | 
			
		||||
** modify it under the terms of the GNU Lesser General Public
 | 
			
		||||
** License version 2.1 as published by the Free Software Foundation
 | 
			
		||||
** and appearing in the file LICENSE.LGPL included in the packaging
 | 
			
		||||
** of this file.
 | 
			
		||||
**
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "ebooster.h"
 | 
			
		||||
#include "logger.h"
 | 
			
		||||
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_MCOMPONENTCACHE
 | 
			
		||||
#include <mcomponentcache.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
const string EBooster::m_socketId  = "/tmp/booste";
 | 
			
		||||
const string EBooster::m_temporaryProcessName = "booster-e";
 | 
			
		||||
 | 
			
		||||
const string & EBooster::socketId() const
 | 
			
		||||
{
 | 
			
		||||
    return m_socketId;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const string & EBooster::socketName()
 | 
			
		||||
{
 | 
			
		||||
    return m_socketId;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const string & EBooster::temporaryProcessName()
 | 
			
		||||
{
 | 
			
		||||
    return m_temporaryProcessName;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const string & EBooster::boosterTemporaryProcessName() const
 | 
			
		||||
{
 | 
			
		||||
    return temporaryProcessName();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char EBooster::type()
 | 
			
		||||
{
 | 
			
		||||
    return 'e';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool EBooster::preload()
 | 
			
		||||
{
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int EBooster::launchProcess()
 | 
			
		||||
{
 | 
			
		||||
    Booster::setEnvironmentBeforeLaunch();
 | 
			
		||||
 | 
			
		||||
    // Ensure a NULL-terminated argv
 | 
			
		||||
    char ** dummyArgv = new char * [appData()->argc() + 1];
 | 
			
		||||
    const int i2 = appData()->argc();
 | 
			
		||||
    for (int i = 0; i < i2; i++)
 | 
			
		||||
        dummyArgv[i] = strdup(appData()->argv()[i]);
 | 
			
		||||
    dummyArgv[i2] = NULL;
 | 
			
		||||
 | 
			
		||||
    // Exec the binary (execv returns only in case of an error).
 | 
			
		||||
    if (execv(appData()->fileName().c_str(),
 | 
			
		||||
              dummyArgv))
 | 
			
		||||
    {
 | 
			
		||||
        Logger::logError("EBooster: Couldn't execv '%s': %s",
 | 
			
		||||
                         appData()->fileName().c_str(),
 | 
			
		||||
                         strerror(errno));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Delete dummy argv if execv failed
 | 
			
		||||
    for (int i = 0; i < i2; i++)
 | 
			
		||||
        delete dummyArgv[i];
 | 
			
		||||
 | 
			
		||||
    return EXIT_FAILURE;
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,111 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
**
 | 
			
		||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 | 
			
		||||
** All rights reserved.
 | 
			
		||||
** Contact: Nokia Corporation (directui@nokia.com)
 | 
			
		||||
**
 | 
			
		||||
** This file is part of applauncherd
 | 
			
		||||
**
 | 
			
		||||
** If you have questions regarding the use of this file, please contact
 | 
			
		||||
** Nokia at directui@nokia.com.
 | 
			
		||||
**
 | 
			
		||||
** This library is free software; you can redistribute it and/or
 | 
			
		||||
** modify it under the terms of the GNU Lesser General Public
 | 
			
		||||
** License version 2.1 as published by the Free Software Foundation
 | 
			
		||||
** and appearing in the file LICENSE.LGPL included in the packaging
 | 
			
		||||
** of this file.
 | 
			
		||||
**
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef EBOOSTER_H
 | 
			
		||||
#define EBOOSTER_H
 | 
			
		||||
 | 
			
		||||
#include "booster.h"
 | 
			
		||||
#include "eventhandler.h"
 | 
			
		||||
#include <tr1/memory>
 | 
			
		||||
 | 
			
		||||
using std::tr1::shared_ptr;
 | 
			
		||||
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
    \class EBooster
 | 
			
		||||
    \brief EBooster is a "booster" that only exec()'s the given binary.
 | 
			
		||||
 | 
			
		||||
    This can be used with e.g. splash screen to launch any application.
 | 
			
		||||
 */
 | 
			
		||||
class EBooster : public Booster
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
    //! \brief Constructor
 | 
			
		||||
    EBooster() {}
 | 
			
		||||
 | 
			
		||||
    //! \brief Destructor
 | 
			
		||||
    virtual ~EBooster() {}
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief Return the socket name common to all EBooster objects.
 | 
			
		||||
     * \return Path to the socket file.
 | 
			
		||||
     */
 | 
			
		||||
    static const string & socketName();
 | 
			
		||||
 | 
			
		||||
    //! Return the process name to be used when booster is not
 | 
			
		||||
    //! yet transformed into a running application
 | 
			
		||||
    static const string & temporaryProcessName();
 | 
			
		||||
 | 
			
		||||
    //! \reimp
 | 
			
		||||
    virtual const string & boosterTemporaryProcessName() const;
 | 
			
		||||
 | 
			
		||||
    //! \reimp
 | 
			
		||||
    virtual char boosterType() const { return type(); }
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief Return a unique character ('e') represtenting the type of EBoosters.
 | 
			
		||||
     * \return Type character.
 | 
			
		||||
     */
 | 
			
		||||
    static char type();
 | 
			
		||||
 | 
			
		||||
    //! \reimp
 | 
			
		||||
    virtual const string & socketId() const;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
 | 
			
		||||
    //! \reimp
 | 
			
		||||
    virtual int launchProcess();
 | 
			
		||||
 | 
			
		||||
    //! \reimp
 | 
			
		||||
    virtual bool preload();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
    //! Disable copy-constructor
 | 
			
		||||
    EBooster(const EBooster & r);
 | 
			
		||||
 | 
			
		||||
    //! Disable assignment operator
 | 
			
		||||
    EBooster & operator= (const EBooster & r);
 | 
			
		||||
 | 
			
		||||
    static const string m_socketId;
 | 
			
		||||
 | 
			
		||||
    //! Process name to be used when booster is not
 | 
			
		||||
    //! yet transformed into a running application
 | 
			
		||||
    static const string m_temporaryProcessName;
 | 
			
		||||
 | 
			
		||||
    //! wait for socket connection
 | 
			
		||||
    void accept();
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
 | 
			
		||||
    //! Qt signal handler for SIGHUP.
 | 
			
		||||
    void handleSigHup();
 | 
			
		||||
 | 
			
		||||
    //! Qt signal handler for theme change
 | 
			
		||||
    void notifyThemeChange();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef UNIT_TEST
 | 
			
		||||
    friend class Ut_EBooster;
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // EBooster_H
 | 
			
		||||
@ -0,0 +1,45 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
**
 | 
			
		||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 | 
			
		||||
** All rights reserved.
 | 
			
		||||
** Contact: Nokia Corporation (directui@nokia.com)
 | 
			
		||||
**
 | 
			
		||||
** This file is part of applauncherd
 | 
			
		||||
**
 | 
			
		||||
** If you have questions regarding the use of this file, please contact
 | 
			
		||||
** Nokia at directui@nokia.com.
 | 
			
		||||
**
 | 
			
		||||
** This library is free software; you can redistribute it and/or
 | 
			
		||||
** modify it under the terms of the GNU Lesser General Public
 | 
			
		||||
** License version 2.1 as published by the Free Software Foundation
 | 
			
		||||
** and appearing in the file LICENSE.LGPL included in the packaging
 | 
			
		||||
** of this file.
 | 
			
		||||
**
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "ebooster.h"
 | 
			
		||||
#include <QtCore>
 | 
			
		||||
 | 
			
		||||
extern "C" 
 | 
			
		||||
{
 | 
			
		||||
    // Create a new plugin instance.
 | 
			
		||||
    Q_DECL_EXPORT void * create()
 | 
			
		||||
    {
 | 
			
		||||
        return new EBooster;
 | 
			
		||||
    }    
 | 
			
		||||
 | 
			
		||||
    Q_DECL_EXPORT char type()
 | 
			
		||||
    {
 | 
			
		||||
        return EBooster::type();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Q_DECL_EXPORT const char * socketName()
 | 
			
		||||
    {
 | 
			
		||||
        return EBooster::socketName().c_str();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Q_DECL_EXPORT const char * temporaryProcessName()
 | 
			
		||||
    {
 | 
			
		||||
        return EBooster::temporaryProcessName().c_str();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue