diff --git a/src/launcher/CMakeLists.txt b/src/launcher/CMakeLists.txt index c90574b..681f090 100644 --- a/src/launcher/CMakeLists.txt +++ b/src/launcher/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/comm # Set sources set(SRC appdata.cpp booster.cpp boosterfactory.cpp monitorbooster.cpp connection.cpp daemon.cpp mbooster.cpp logger.cpp main.cpp qtbooster.cpp wrtbooster.cpp) -set(MOC_HDRS monitorbooster.h) +set(MOC_HDRS monitorbooster.h mbooster.h) qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) # Find libdl diff --git a/src/launcher/booster.h b/src/launcher/booster.h index 2657102..3575088 100644 --- a/src/launcher/booster.h +++ b/src/launcher/booster.h @@ -134,6 +134,12 @@ protected: //! Returns the given pipe fd (0 = read end, 1 = write end) int pipeFd(bool whichEnd) const; + //! Data structure representing the application to be invoked + AppData m_app; + + //! Socket connection to invoker + Connection* m_conn; + private: //! Disable copy-constructor @@ -152,11 +158,6 @@ private: //! Helper method: load the library and find out address for "main". void* loadMain(); - //! Data structure representing the application to be invoked - AppData m_app; - - //! Socket connection to invoker - Connection* m_conn; //! Size (length) of the argument vector int m_argvArraySize; diff --git a/src/launcher/mbooster.cpp b/src/launcher/mbooster.cpp index 9630e55..adb855b 100644 --- a/src/launcher/mbooster.cpp +++ b/src/launcher/mbooster.cpp @@ -19,6 +19,10 @@ #include "mbooster.h" #include "logger.h" +#include "connection.h" + +#include +#include #ifdef HAVE_MCOMPONENTCACHE #include @@ -72,3 +76,41 @@ int MBooster::processId() { return m_ProcessID; } + +bool MBooster::readCommand() +{ + // Setup the conversation channel with the invoker. + m_conn = new Connection(socketId()); + + // exit from event loop when invoker is ready to connect + connect(this, SIGNAL(connectionAccepted()), MApplication::instance() , SLOT(quit())); + + // start another thread to listen connection from invoker + QtConcurrent::run(this, &MBooster::accept); + + // run event loop so MApplication and MApplicationWindow objects can receive notifications + MApplication::exec(); + + // Receive application data from the invoker + if(!m_conn->receiveApplicationData(m_app)) + { + m_conn->close(); + return false; + } + + // Close the connection if exit status doesn't need + // to be sent back to invoker + if (!m_conn->isReportAppExitStatusNeeded()) + { + m_conn->close(); + } + return true; +} + +void MBooster::accept() +{ + if (m_conn->accept(m_app)) + { + emit connectionAccepted(); + } +} diff --git a/src/launcher/mbooster.h b/src/launcher/mbooster.h index 51fd7d8..98f14e1 100644 --- a/src/launcher/mbooster.h +++ b/src/launcher/mbooster.h @@ -21,6 +21,8 @@ #define MBOOSTER_H #include "booster.h" +#include + /*! \class MBooster @@ -31,8 +33,10 @@ from MComponentCache. This can significantly reduce the startup time of a MeeGo Touch application. */ -class MBooster : public Booster +class MBooster : public QObject, public Booster { + Q_OBJECT + public: //! \brief Constructor @@ -81,6 +85,9 @@ protected: //! \reimp virtual const string & socketId() const; + //! \reimp + virtual bool readCommand(); + private: //! Disable copy-constructor @@ -97,9 +104,14 @@ private: //! yet transformed into a running application static const string m_temporaryProcessName; + void accept(); + #ifdef UNIT_TEST friend class Ut_MBooster; #endif + +signals: + void connectionAccepted(); }; #endif // MBOOSTER_H diff --git a/tests/unittests/ut_boosterfactory/CMakeLists.txt b/tests/unittests/ut_boosterfactory/CMakeLists.txt index e5af40e..52963ca 100644 --- a/tests/unittests/ut_boosterfactory/CMakeLists.txt +++ b/tests/unittests/ut_boosterfactory/CMakeLists.txt @@ -4,7 +4,7 @@ set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) set(SRC ut_boosterfactory.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/mbooster.cpp ${LAUNCHER}/qtbooster.cpp ${LAUNCHER}/monitorbooster.cpp ${LAUNCHER}/wrtbooster.cpp ${LAUNCHER}/boosterfactory.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp) # Set moc headers -set(MOC_HDRS ut_boosterfactory.h ${LAUNCHER}/monitorbooster.h) +set(MOC_HDRS ut_boosterfactory.h ${LAUNCHER}/monitorbooster.h ${LAUNCHER}/mbooster.h) # Run moc qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) diff --git a/tests/unittests/ut_connection/CMakeLists.txt b/tests/unittests/ut_connection/CMakeLists.txt index 65b7f36..5a3b11a 100644 --- a/tests/unittests/ut_connection/CMakeLists.txt +++ b/tests/unittests/ut_connection/CMakeLists.txt @@ -4,7 +4,7 @@ set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) set(SRC ut_connection.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/boosterfactory.cpp ${LAUNCHER}/monitorbooster.cpp ${LAUNCHER}/daemon.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp ${LAUNCHER}/qtbooster.cpp ${LAUNCHER}/wrtbooster.cpp) # Set moc headers -set(MOC_HDRS ut_connection.h ${LAUNCHER}/monitorbooster.h) +set(MOC_HDRS ut_connection.h ${LAUNCHER}/monitorbooster.h ${LAUNCHER}/mbooster.h) # Set the program name define used in daemon.cpp set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME_LAUNCHER=\\\"applauncherd\\\"") diff --git a/tests/unittests/ut_daemon/CMakeLists.txt b/tests/unittests/ut_daemon/CMakeLists.txt index 1df6a08..5d6fb99 100644 --- a/tests/unittests/ut_daemon/CMakeLists.txt +++ b/tests/unittests/ut_daemon/CMakeLists.txt @@ -3,7 +3,7 @@ set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) set(SRC ut_daemon.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/boosterfactory.cpp ${LAUNCHER}/monitorbooster.cpp ${LAUNCHER}/daemon.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp ${LAUNCHER}/qtbooster.cpp ${LAUNCHER}/wrtbooster.cpp) # Set moc headers -set(MOC_HDRS ut_daemon.h ${LAUNCHER}/monitorbooster.h) +set(MOC_HDRS ut_daemon.h ${LAUNCHER}/monitorbooster.h ${LAUNCHER}/mbooster.h) # Set the program name define used in daemon.cpp set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME_LAUNCHER=\\\"applauncherd\\\"") diff --git a/tests/unittests/ut_mbooster/CMakeLists.txt b/tests/unittests/ut_mbooster/CMakeLists.txt index 443af12..6baf39b 100644 --- a/tests/unittests/ut_mbooster/CMakeLists.txt +++ b/tests/unittests/ut_mbooster/CMakeLists.txt @@ -5,7 +5,7 @@ set(SRC ut_mbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCH ${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp) # Set moc headers -set(MOC_HDRS ut_mbooster.h) +set(MOC_HDRS ut_mbooster.h ${LAUNCHER}/mbooster.h) # Run moc qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})