From 8c32791efd114bed9d411aa2e4f2cddd6a8fcec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pertti=20Kellom=C3=A4ki?= Date: Mon, 24 Jan 2011 14:32:19 +0200 Subject: [PATCH] Changes: The qdeclarativebooster plugin implementation. --- src/invoker/invokelib.h | 1 + src/invoker/invoker.c | 18 ++-- src/qdeclarativebooster/CMakeLists.txt | 10 +++ src/qdeclarativebooster/pluginfactory.cpp | 45 ++++++++++ .../qdeclarativebooster.cpp | 55 ++++++++++++ src/qdeclarativebooster/qdeclarativebooster.h | 88 +++++++++++++++++++ 6 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 src/qdeclarativebooster/pluginfactory.cpp create mode 100644 src/qdeclarativebooster/qdeclarativebooster.cpp create mode 100644 src/qdeclarativebooster/qdeclarativebooster.h diff --git a/src/invoker/invokelib.h b/src/invoker/invokelib.h index dbd94db..9bbcdb6 100644 --- a/src/invoker/invokelib.h +++ b/src/invoker/invokelib.h @@ -30,5 +30,6 @@ void invoke_send_str(int fd, char *str); #define INVOKER_M_SOCK "/tmp/boostm" #define INVOKER_QT_SOCK "/tmp/boostq" +#define INVOKER_QDECL_SOCK "/tmp/boostd" #endif diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index 322ed1e..809e6f7 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -56,10 +56,11 @@ static const unsigned char EXIT_STATUS_APPLICATION_CONNECTION_LOST = 0xfa; static const unsigned char EXIT_STATUS_APPLICATION_NOT_FOUND = 0x7f; // Enumeration of possible application types: -// M_APP : MeeGo Touch application -// QT_APP : Qt/generic application +// M_APP : MeeGo Touch application +// QT_APP : Qt/generic application +// QDECL_APP: QDeclarative (QML) application // -enum APP_TYPE { M_APP, QT_APP, UNKNOWN_APP }; +enum APP_TYPE { M_APP, QT_APP, QDECL_APP, UNKNOWN_APP }; // Environment extern char ** environ; @@ -205,6 +206,10 @@ static int invoker_init(enum APP_TYPE app_type) { strncpy(sun.sun_path, INVOKER_QT_SOCK, maxSize); } + else if (app_type == QDECL_APP) + { + strncpy(sun.sun_path, INVOKER_QDECL_SOCK, maxSize); + } else { die(1, "Unknown type of application: %d\n", app_type); @@ -394,12 +399,13 @@ static void invoker_send_end(int fd) static void usage(int status) { printf("\nUsage: %s [options] [--type=TYPE] [file] [args]\n\n" - "Launch m or qt application compiled as a shared library (-shared) or\n" + "Launch m, qt, or qdeclarative application compiled as a shared library (-shared) or\n" "a position independent executable (-pie) through %s.\n\n" "TYPE chooses the type of booster used. Qt-booster may be used to\n" "launch anything. Possible values for TYPE:\n" " m Launch a MeeGo Touch application.\n" - " qt Launch a Qt application.\n\n" + " qt Launch a Qt application.\n" + " d Launch a Qt Declarative (QML) application.\n\n" "Options:\n" " -c, --creds Print Aegis security credentials (if enabled).\n" " -d, --delay SECS After invoking sleep for SECS seconds\n" @@ -631,6 +637,8 @@ int main(int argc, char *argv[]) app_type = M_APP; else if (strcmp(optarg, "q") == 0 || strcmp(optarg, "qt") == 0) app_type = QT_APP; + else if (strcmp(optarg, "d") == 0) + app_type = QDECL_APP; else { report(report_error, "Unknown application type: %s \n", optarg); diff --git a/src/qdeclarativebooster/CMakeLists.txt b/src/qdeclarativebooster/CMakeLists.txt index 17e6587..5521da4 100644 --- a/src/qdeclarativebooster/CMakeLists.txt +++ b/src/qdeclarativebooster/CMakeLists.txt @@ -9,12 +9,22 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/comm #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") # Set sources +set(PLUGINSRC qdeclarativebooster.cpp pluginfactory.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp +${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp +${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp) set(LIBSRC qdeclarativeboostercache.cpp qdeclarativeboostercache.h qdeclarativeboostercache_p.h) +set(MOC_HDRS qdeclarativebooster.h) +qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) # Set executables add_library(qdeclarativeboostercache SHARED ${LIBSRC}) target_link_libraries(qdeclarativeboostercache ${LIBDL} ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY}) +add_library(qdeclarativebooster MODULE ${PLUGINSRC} ${MOC_SRC}) +target_link_libraries(qdeclarativebooster ${LIBDL} ${QT_QTCORE_LIBRARY} "-L. -lqdeclarativeboostercache") +add_dependencies(qdeclarativebooster qdeclarativeboostercache) + # Add install rule +install(FILES libqdeclarativebooster.so DESTINATION /usr/lib/applauncherd/) install(FILES libqdeclarativeboostercache.so DESTINATION /usr/lib/) install(FILES qdeclarativeboostercache.h DESTINATION /usr/include) diff --git a/src/qdeclarativebooster/pluginfactory.cpp b/src/qdeclarativebooster/pluginfactory.cpp new file mode 100644 index 0000000..a0eab30 --- /dev/null +++ b/src/qdeclarativebooster/pluginfactory.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** +** +** Copyright (C) 2011 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 "qdeclarativebooster.h" +#include + +extern "C" +{ + // Create a new plugin instance. + Q_DECL_EXPORT void * create() + { + return new QDeclarativeBooster; + } + + Q_DECL_EXPORT char type() + { + return QDeclarativeBooster::type(); + } + + Q_DECL_EXPORT const char * socketName() + { + return QDeclarativeBooster::socketName().c_str(); + } + + Q_DECL_EXPORT const char * temporaryProcessName() + { + return QDeclarativeBooster::temporaryProcessName().c_str(); + } +} diff --git a/src/qdeclarativebooster/qdeclarativebooster.cpp b/src/qdeclarativebooster/qdeclarativebooster.cpp new file mode 100644 index 0000000..d4aa67c --- /dev/null +++ b/src/qdeclarativebooster/qdeclarativebooster.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** +** +** Copyright (C) 2011 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 "qdeclarativebooster.h" +#include "qdeclarativeboostercache.h" + +const string QDeclarativeBooster::m_socketId = "/tmp/boostd"; +const string QDeclarativeBooster::m_temporaryProcessName = "booster-d"; + +const string & QDeclarativeBooster::socketId() const +{ + return m_socketId; +} + +const string & QDeclarativeBooster::socketName() +{ + return m_socketId; +} + +const string & QDeclarativeBooster::temporaryProcessName() +{ + return m_temporaryProcessName; +} + +const string & QDeclarativeBooster::boosterTemporaryProcessName() const +{ + return temporaryProcessName(); +} + +char QDeclarativeBooster::type() +{ + return 'd'; +} + +bool QDeclarativeBooster::preload() +{ + QDeclarativeBoosterCache::populate(); + return true; +} diff --git a/src/qdeclarativebooster/qdeclarativebooster.h b/src/qdeclarativebooster/qdeclarativebooster.h new file mode 100644 index 0000000..b206240 --- /dev/null +++ b/src/qdeclarativebooster/qdeclarativebooster.h @@ -0,0 +1,88 @@ +/*************************************************************************** +** +** Copyright (C) 2011 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 QDECLARATIVEBOOSTER_H +#define QDECLARATIVEBOOSTER_H + +#include "booster.h" + +/*! + * \class QDeclarativeBooster. + * \brief QDeclarative-specific version of the Booster. + */ +class QDeclarativeBooster : public Booster +{ +public: + + //! Constructor. + QDeclarativeBooster() {}; + + //! Destructor. + virtual ~QDeclarativeBooster() {}; + + /*! + * \brief Return the socket name common to all QDeclarativeBooster 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 ('d') represtenting the type of QDeclarativeBoosters. + * \return Type character. + */ + static char type(); + + //! \reimp + virtual bool preload(); + +protected: + + //! \reimp + virtual const string & socketId() const; + +private: + + //! Disable copy-constructor + QDeclarativeBooster(const QDeclarativeBooster & r); + + //! Disable assignment operator + QDeclarativeBooster & operator= (const QDeclarativeBooster & 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; + +#ifdef UNIT_TEST + friend class Ut_DBooster; +#endif +}; + +#endif //QDECLARATIVEBOOSTER_H