From d18c8d95ef6a2af5a88181e2414f263c8bf49331 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Tue, 13 Jul 2010 11:14:40 +0300 Subject: [PATCH] Changes: First public release --- .gitignore | 36 + CMakeLists.txt | 80 + COPYING.LESSER | 504 ++++++ FindPkgConfig.cmake | 360 ++++ INSTALL | 37 + README | 136 ++ TODO | 6 + configure | 3 + .../mkspecs/features/meegotouch-boostable.prf | 5 + data/pkgconfig/meegotouch-boostable.pc | 5 + debian/applauncherd-art-tests.install | 1 + debian/applauncherd-bug-tests.install | 1 + debian/applauncherd-dev.install | 2 + debian/applauncherd-doc.install | 1 + debian/applauncherd-functional-tests.install | 1 + debian/applauncherd-invoker.aegis | 8 + debian/applauncherd-invoker.install | 1 + debian/applauncherd-launcher.aegis | 20 + debian/applauncherd-launcher.install | 2 + debian/applauncherd-performance-tests.install | 2 + debian/applauncherd-testapps.aegis | 16 + debian/applauncherd-testapps.install | 16 + debian/applauncherd-tests.install | 6 + debian/applauncherd-testscripts.install | 5 + debian/applauncherd.install | 0 debian/changelog | 120 ++ debian/compat | 1 + debian/control | 127 ++ debian/copyright | 37 + debian/dirs | 2 + debian/docs | 0 debian/rules | 99 ++ doc/Doxyfile | 1510 +++++++++++++++++ src/CMakeLists.txt | 7 + src/common/protocol.h | 43 + src/invoker/CMakeLists.txt | 19 + src/invoker/invokelib.c | 84 + src/invoker/invokelib.h | 37 + src/invoker/invoker.c | 457 +++++ src/invoker/report.c | 99 ++ src/invoker/report.h | 60 + src/invoker/search.c | 105 ++ src/invoker/search.h | 26 + src/launcher/CMakeLists.txt | 37 + src/launcher/appdata.cpp | 131 ++ src/launcher/appdata.h | 110 ++ src/launcher/booster.cpp | 221 +++ src/launcher/booster.h | 139 ++ src/launcher/connection.cpp | 492 ++++++ src/launcher/connection.h | 161 ++ src/launcher/daemon.cpp | 395 +++++ src/launcher/daemon.h | 128 ++ src/launcher/logger.cpp | 212 +++ src/launcher/logger.h | 119 ++ src/launcher/main.cpp | 75 + src/launcher/mbooster.cpp | 57 + src/launcher/mbooster.h | 82 + src/launcher/qtbooster.cpp | 50 + src/launcher/qtbooster.h | 77 + src/launcher/scripts/applauncherd | 15 + tests/CMakeLists.txt | 45 + tests/TestApps/creds/CMakeLists.txt | 15 + tests/TestApps/creds/creds_test.cpp | 106 ++ tests/TestApps/creds/creds_test.pro | 13 + tests/TestApps/creds/fala_ft_creds | 3 + tests/TestApps/helloworld/CMakeLists.txt | 16 + tests/TestApps/helloworld/helloworld.cpp | 65 + tests/TestApps/helloworld/helloworld.pro | 8 + .../helloworld/scripts/create_links.cmake | 6 + .../TestApps/helloworld/scripts/fala_ft_hello | 4 + tests/TestApps/helloworld/scripts/qhelloworld | 5 + tests/TestApps/testapp/CMakeLists.txt | 14 + .../testapp/com.nokia.fala_testapp.service | 4 + tests/TestApps/testapp/main.cpp | 81 + tests/TestApps/testapp/testapp.pro | 14 + tests/TestApps/themetest/CMakeLists.txt | 5 + tests/TestApps/themetest/src/CMakeLists.txt | 20 + .../TestApps/themetest/src/fala_ft_themetest | 3 + .../themetest/src/pkg-config-sourcetree.sh | 3 + tests/TestApps/themetest/src/themetest.cpp | 60 + .../themes/style/fala_ft_themetest.css | 55 + tests/TestApps/themetest/themes/svg/baa.svg | 711 ++++++++ tests/TestScripts/CMakeLists.txt | 10 + tests/TestScripts/check_pipes.py | 48 + tests/TestScripts/tc_theming.rb | 168 ++ tests/TestScripts/test-func-launcher.py | 384 +++++ tests/TestScripts/test-perf-mbooster.py | 264 +++ tests/TestScripts/ts_prestartapp.rb | 74 + tests/art-tests/CMakeLists.txt | 2 + tests/art-tests/tests.xml | 58 + tests/bug-tests/CMakeLists.txt | 2 + tests/bug-tests/tests.xml | 61 + tests/functests/CMakeLists.txt | 2 + tests/functests/tests.xml | 78 + tests/perftests/CMakeLists.txt | 1 + tests/perftests/tests.xml | 31 + tests/unittests/CMakeLists.txt | 8 + tests/unittests/tests.xml | 81 + tests/unittests/ut_booster/CMakeLists.txt | 27 + tests/unittests/ut_booster/ut_booster.cpp | 265 +++ tests/unittests/ut_booster/ut_booster.h | 59 + tests/unittests/ut_connection/CMakeLists.txt | 28 + .../unittests/ut_connection/ut_connection.cpp | 190 +++ tests/unittests/ut_connection/ut_connection.h | 53 + tests/unittests/ut_daemon/CMakeLists.txt | 27 + tests/unittests/ut_daemon/ut_daemon.cpp | 99 ++ tests/unittests/ut_daemon/ut_daemon.h | 54 + tests/unittests/ut_mbooster/CMakeLists.txt | 28 + tests/unittests/ut_mbooster/ut_mbooster.cpp | 49 + tests/unittests/ut_mbooster/ut_mbooster.h | 52 + tests/unittests/ut_qtbooster/CMakeLists.txt | 25 + tests/unittests/ut_qtbooster/ut_qtbooster.cpp | 49 + tests/unittests/ut_qtbooster/ut_qtbooster.h | 52 + 113 files changed, 10173 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 COPYING.LESSER create mode 100644 FindPkgConfig.cmake create mode 100644 INSTALL create mode 100644 README create mode 100644 TODO create mode 100755 configure create mode 100644 data/mkspecs/features/meegotouch-boostable.prf create mode 100644 data/pkgconfig/meegotouch-boostable.pc create mode 100644 debian/applauncherd-art-tests.install create mode 100644 debian/applauncherd-bug-tests.install create mode 100644 debian/applauncherd-dev.install create mode 100644 debian/applauncherd-doc.install create mode 100644 debian/applauncherd-functional-tests.install create mode 100644 debian/applauncherd-invoker.aegis create mode 100644 debian/applauncherd-invoker.install create mode 100644 debian/applauncherd-launcher.aegis create mode 100644 debian/applauncherd-launcher.install create mode 100644 debian/applauncherd-performance-tests.install create mode 100644 debian/applauncherd-testapps.aegis create mode 100644 debian/applauncherd-testapps.install create mode 100644 debian/applauncherd-tests.install create mode 100644 debian/applauncherd-testscripts.install create mode 100644 debian/applauncherd.install create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100755 debian/rules create mode 100644 doc/Doxyfile create mode 100644 src/CMakeLists.txt create mode 100644 src/common/protocol.h create mode 100644 src/invoker/CMakeLists.txt create mode 100644 src/invoker/invokelib.c create mode 100644 src/invoker/invokelib.h create mode 100644 src/invoker/invoker.c create mode 100644 src/invoker/report.c create mode 100644 src/invoker/report.h create mode 100644 src/invoker/search.c create mode 100644 src/invoker/search.h create mode 100644 src/launcher/CMakeLists.txt create mode 100644 src/launcher/appdata.cpp create mode 100644 src/launcher/appdata.h create mode 100644 src/launcher/booster.cpp create mode 100644 src/launcher/booster.h create mode 100644 src/launcher/connection.cpp create mode 100644 src/launcher/connection.h create mode 100644 src/launcher/daemon.cpp create mode 100644 src/launcher/daemon.h create mode 100644 src/launcher/logger.cpp create mode 100644 src/launcher/logger.h create mode 100644 src/launcher/main.cpp create mode 100644 src/launcher/mbooster.cpp create mode 100644 src/launcher/mbooster.h create mode 100644 src/launcher/qtbooster.cpp create mode 100644 src/launcher/qtbooster.h create mode 100755 src/launcher/scripts/applauncherd create mode 100644 tests/CMakeLists.txt create mode 100644 tests/TestApps/creds/CMakeLists.txt create mode 100644 tests/TestApps/creds/creds_test.cpp create mode 100644 tests/TestApps/creds/creds_test.pro create mode 100644 tests/TestApps/creds/fala_ft_creds create mode 100644 tests/TestApps/helloworld/CMakeLists.txt create mode 100644 tests/TestApps/helloworld/helloworld.cpp create mode 100644 tests/TestApps/helloworld/helloworld.pro create mode 100644 tests/TestApps/helloworld/scripts/create_links.cmake create mode 100755 tests/TestApps/helloworld/scripts/fala_ft_hello create mode 100755 tests/TestApps/helloworld/scripts/qhelloworld create mode 100644 tests/TestApps/testapp/CMakeLists.txt create mode 100644 tests/TestApps/testapp/com.nokia.fala_testapp.service create mode 100644 tests/TestApps/testapp/main.cpp create mode 100644 tests/TestApps/testapp/testapp.pro create mode 100644 tests/TestApps/themetest/CMakeLists.txt create mode 100644 tests/TestApps/themetest/src/CMakeLists.txt create mode 100755 tests/TestApps/themetest/src/fala_ft_themetest create mode 100644 tests/TestApps/themetest/src/pkg-config-sourcetree.sh create mode 100644 tests/TestApps/themetest/src/themetest.cpp create mode 100644 tests/TestApps/themetest/themes/style/fala_ft_themetest.css create mode 100644 tests/TestApps/themetest/themes/svg/baa.svg create mode 100644 tests/TestScripts/CMakeLists.txt create mode 100755 tests/TestScripts/check_pipes.py create mode 100755 tests/TestScripts/tc_theming.rb create mode 100644 tests/TestScripts/test-func-launcher.py create mode 100644 tests/TestScripts/test-perf-mbooster.py create mode 100755 tests/TestScripts/ts_prestartapp.rb create mode 100644 tests/art-tests/CMakeLists.txt create mode 100644 tests/art-tests/tests.xml create mode 100644 tests/bug-tests/CMakeLists.txt create mode 100644 tests/bug-tests/tests.xml create mode 100644 tests/functests/CMakeLists.txt create mode 100644 tests/functests/tests.xml create mode 100644 tests/perftests/CMakeLists.txt create mode 100644 tests/perftests/tests.xml create mode 100644 tests/unittests/CMakeLists.txt create mode 100644 tests/unittests/tests.xml create mode 100644 tests/unittests/ut_booster/CMakeLists.txt create mode 100644 tests/unittests/ut_booster/ut_booster.cpp create mode 100644 tests/unittests/ut_booster/ut_booster.h create mode 100644 tests/unittests/ut_connection/CMakeLists.txt create mode 100644 tests/unittests/ut_connection/ut_connection.cpp create mode 100644 tests/unittests/ut_connection/ut_connection.h create mode 100644 tests/unittests/ut_daemon/CMakeLists.txt create mode 100644 tests/unittests/ut_daemon/ut_daemon.cpp create mode 100644 tests/unittests/ut_daemon/ut_daemon.h create mode 100644 tests/unittests/ut_mbooster/CMakeLists.txt create mode 100644 tests/unittests/ut_mbooster/ut_mbooster.cpp create mode 100644 tests/unittests/ut_mbooster/ut_mbooster.h create mode 100644 tests/unittests/ut_qtbooster/CMakeLists.txt create mode 100644 tests/unittests/ut_qtbooster/ut_qtbooster.cpp create mode 100644 tests/unittests/ut_qtbooster/ut_qtbooster.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..433ed93 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +CMakeCache.txt +Makefile +cmake_install.cmake +install_manifest.txt +CMakeFiles/ +*.cxx +*.so +*.o +*.log +*.substvars +tests/unittests/ut_booster/ut_booster +tests/unittests/ut_connection/ut_connection +tests/unittests/ut_daemon/ut_daemon +tests/unittests/ut_mbooster/ut_mbooster +tests/unittests/ut_qtbooster/ut_qtbooster +src/invoker/invoker +src/launcher/applauncherd.bin +tests/perftests/startup-perftest/testapp/testapp +tests/perftests/waitforwindow/wait_window +tests/helloworld/helloworld +tests/perftests/hello_no_launcher/hello_no_launcher +tests/perftests/launcher_perf.txt +debian/applauncherd-dev/ +debian/applauncherd-doc/ +build-stamp +configure-stamp +debian/applauncherd-functional-tests/ +debian/applauncherd-invoker/ +debian/applauncherd-launcher/ +debian/applauncherd-performance-tests/ +debian/applauncherd-tests/ +debian/applauncherd.aegis.more +debian/applauncherd/ +debian/files +debian/tmp/ + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..69d4c70 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,80 @@ +project(Applauncherd) + +cmake_minimum_required(VERSION 2.6) +cmake_policy(VERSION 2.6) + +set(CMAKE_VERBOSE_MAKEFILE ON) + +# Set default C++ flags +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -g -Wno-long-long -O2 -Wextra -Wpointer-arith -Wwrite-strings -Wold-style-cast -Woverloaded-virtual -Wundef") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -g -O2") + +# By default only QtCore and QtGui modules are enabled +#set(QT_USE_QTDBUS TRUE) + +# Find Qt4 +find_package(Qt4 4.6.0 REQUIRED) +include(${QT_USE_FILE}) +if (${QTVERSION} VERSION_LESS 4.6.0) + message(FATAL_ERROR "You need Qt4.6, found ${QTVERSION}.") +endif (${QTVERSION} VERSION_LESS 4.6.0) + +# Find creds.h (and libcreds if the header is found) +message(STATUS "checking for creds.h") +find_file(CREDS_H NAMES creds.h PATHS /usr/include/sys) +if (EXISTS ${CREDS_H}) + message(STATUS " found: " ${CREDS_H}) + message(STATUS "checking for libcreds") + find_library(LIBCREDS NAMES creds) + if (EXISTS ${LIBCREDS}) + add_definitions(-DHAVE_CREDS) + link_libraries(${LIBCREDS}) + message(STATUS " found: " ${LIBCREDS}) + else (EXISTS ${LIBCREDS}) + message(STATUS " not found: Platform Security is disabled.") + endif (EXISTS ${LIBCREDS}) +else (EXISTS ${CREDS_H}) + message(STATUS " not found: Platform Security is disabled.") +endif (EXISTS ${CREDS_H}) + +if ($ENV{DISABLE_VERIFICATION}) + add_definitions(-DDISABLE_VERIFICATION) +endif ($ENV{DISABLE_VERIFICATION}) + + +# Build with test coverage switch if BUILD_COVERAGE environment variable is set +if ($ENV{BUILD_COVERAGE}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs") + set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -ftest-coverage -fprofile-arcs") +endif ($ENV{BUILD_COVERAGE}) + + +# Sub build: applauncherd +add_subdirectory(src) + +# Build tests if BUILD_TESTS environment variable is set +if ($ENV{BUILD_TESTS}) + # Sub build: tests + # This will build the HelloWorld test library, unit tests, functional tests + # and performance tests + add_subdirectory(tests) +endif ($ENV{BUILD_TESTS}) + +# Target for documentation (make doc) +find_program(Doxygen NAMES doxygen) +if (EXISTS ${Doxygen}) + add_custom_target(doc COMMAND ${Doxygen} doc/Doxyfile) +else (EXISTS ${Doxygen}) + message(STATUS "Doxygen not found: you're not able to build documentation.") +endif (EXISTS ${Doxygen}) + +# Install README +install(FILES README DESTINATION /usr/share/doc/applauncherd) + +# Install meegotouch-boostable.pc +install(FILES data/pkgconfig/meegotouch-boostable.pc DESTINATION /usr/lib/pkgconfig) + +# Install the qmake config feature file +install(FILES data/mkspecs/features/meegotouch-boostable.prf DESTINATION /usr/share/qt4/mkspecs/features) + diff --git a/COPYING.LESSER b/COPYING.LESSER new file mode 100644 index 0000000..602bfc9 --- /dev/null +++ b/COPYING.LESSER @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/FindPkgConfig.cmake b/FindPkgConfig.cmake new file mode 100644 index 0000000..ea72491 --- /dev/null +++ b/FindPkgConfig.cmake @@ -0,0 +1,360 @@ +# - a pkg-config module for CMake +# +# Usage: +# pkg_check_modules( [REQUIRED] []*) +# checks for all the given modules +# +# pkg_search_module( [REQUIRED] []*) +# checks for given modules and uses the first working one +# +# When the 'REQUIRED' argument was set, macros will fail with an error +# when module(s) could not be found +# +# It sets the following variables: +# PKG_CONFIG_FOUND ... true if pkg-config works on the system +# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program +# _FOUND ... set to 1 if module(s) exist +# +# For the following variables two sets of values exist; first one is the +# common one and has the given PREFIX. The second set contains flags +# which are given out when pkgconfig was called with the '--static' +# option. +# _LIBRARIES ... only the libraries (w/o the '-l') +# _LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') +# _LDFLAGS ... all required linker flags +# _LDFLAGS_OTHER ... all other linker flags +# _INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') +# _CFLAGS ... all required cflags +# _CFLAGS_OTHER ... the other compiler flags +# +# = for common case +# = _STATIC for static linking +# +# There are some special variables whose prefix depends on the count +# of given modules. When there is only one module, stays +# unchanged. When there are multiple modules, the prefix will be +# changed to _: +# _VERSION ... version of the module +# _PREFIX ... prefix-directory of the module +# _INCLUDEDIR ... include-dir of the module +# _LIBDIR ... lib-dir of the module +# +# = when |MODULES| == 1, else +# = _ +# +# A parameter can have the following formats: +# {MODNAME} ... matches any version +# {MODNAME}>={VERSION} ... at least version is required +# {MODNAME}={VERSION} ... exactly version is required +# {MODNAME}<={VERSION} ... modules must not be newer than +# +# Examples +# pkg_check_modules (GLIB2 glib-2.0) +# +# pkg_check_modules (GLIB2 glib-2.0>=2.10) +# requires at least version 2.10 of glib2 and defines e.g. +# GLIB2_VERSION=2.10.3 +# +# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0) +# requires both glib2 and gtk2, and defines e.g. +# FOO_glib-2.0_VERSION=2.10.3 +# FOO_gtk+-2.0_VERSION=2.8.20 +# +# pkg_check_modules (XRENDER REQUIRED xrender) +# defines e.g.: +# XRENDER_LIBRARIES=Xrender;X11 +# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp +# +# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) + + +# Copyright (C) 2006 Enrico Scholz +# +# Redistribution and use, with or without modification, are permitted +# provided that the following conditions are met: +# +# 1. Redistributions must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. The name of the author may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +### Common stuff #### +set(PKG_CONFIG_VERSION 1) +set(PKG_CONFIG_FOUND 0) + +find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable") +mark_as_advanced(PKG_CONFIG_EXECUTABLE) + +if(PKG_CONFIG_EXECUTABLE) + set(PKG_CONFIG_FOUND 1) +endif(PKG_CONFIG_EXECUTABLE) + + +# Unsets the given variables +macro(_pkgconfig_unset var) + set(${var} "" CACHE INTERNAL "") +endmacro(_pkgconfig_unset) + +macro(_pkgconfig_set var value) + set(${var} ${value} CACHE INTERNAL "") +endmacro(_pkgconfig_set) + +# Invokes pkgconfig, cleans up the result and sets variables +macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) + set(_pkgconfig_invoke_result) + + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist} + OUTPUT_VARIABLE _pkgconfig_invoke_result + RESULT_VARIABLE _pkgconfig_failed) + + if (_pkgconfig_failed) + set(_pkgconfig_${_varname} "") + _pkgconfig_unset(${_prefix}_${_varname}) + else(_pkgconfig_failed) + string(REGEX REPLACE "[\r\n]" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") + string(REGEX REPLACE " +$" "" _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") + + if (NOT ${_regexp} STREQUAL "") + string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") + endif(NOT ${_regexp} STREQUAL "") + + separate_arguments(_pkgconfig_invoke_result) + + #message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}") + set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result}) + _pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}") + endif(_pkgconfig_failed) +endmacro(_pkgconfig_invoke) + +# Invokes pkgconfig two times; once without '--static' and once with +# '--static' +macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) + _pkgconfig_invoke("${_pkglist}" ${_prefix} ${_varname} "${cleanup_regexp}" ${ARGN}) + _pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static ${ARGN}) +endmacro(_pkgconfig_invoke_dyn) + +# Splits given arguments into options and a package list +macro(_pkgconfig_parse_options _result _is_req) + set(${_is_req} 0) + + foreach(_pkg ${ARGN}) + if (_pkg STREQUAL "REQUIRED") + set(${_is_req} 1) + endif (_pkg STREQUAL "REQUIRED") + endforeach(_pkg ${ARGN}) + + set(${_result} ${ARGN}) + list(REMOVE_ITEM ${_result} "REQUIRED") +endmacro(_pkgconfig_parse_options) + +### +macro(_pkg_check_modules_internal _is_required _is_silent _prefix) + _pkgconfig_unset(${_prefix}_FOUND) + _pkgconfig_unset(${_prefix}_VERSION) + _pkgconfig_unset(${_prefix}_PREFIX) + _pkgconfig_unset(${_prefix}_INCLUDEDIR) + _pkgconfig_unset(${_prefix}_LIBDIR) + _pkgconfig_unset(${_prefix}_LIBS) + _pkgconfig_unset(${_prefix}_LIBS_L) + _pkgconfig_unset(${_prefix}_LIBS_PATHS) + _pkgconfig_unset(${_prefix}_LIBS_OTHER) + _pkgconfig_unset(${_prefix}_CFLAGS) + _pkgconfig_unset(${_prefix}_CFLAGS_I) + _pkgconfig_unset(${_prefix}_CFLAGS_OTHER) + _pkgconfig_unset(${_prefix}_STATIC_LIBDIR) + _pkgconfig_unset(${_prefix}_STATIC_LIBS) + _pkgconfig_unset(${_prefix}_STATIC_LIBS_L) + _pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS) + _pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER) + _pkgconfig_unset(${_prefix}_STATIC_CFLAGS) + _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I) + _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER) + + # create a better addressable variable of the modules and calculate its size + set(_pkg_check_modules_list ${ARGN}) + list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt) + + if(PKG_CONFIG_EXECUTABLE) + # give out status message telling checked module + if (NOT ${_is_silent}) + if (_pkg_check_modules_cnt EQUAL 1) + message(STATUS "checking for module '${_pkg_check_modules_list}'") + else(_pkg_check_modules_cnt EQUAL 1) + message(STATUS "checking for modules '${_pkg_check_modules_list}'") + endif(_pkg_check_modules_cnt EQUAL 1) + endif(NOT ${_is_silent}) + + set(_pkg_check_modules_packages) + set(_pkg_check_modules_failed) + + # iterate through module list and check whether they exist and match the required version + foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list}) + set(_pkg_check_modules_exist_query) + + # check whether version is given + if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") + string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") + string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op "${_pkg_check_modules_pkg}") + string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver "${_pkg_check_modules_pkg}") + else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") + set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") + set(_pkg_check_modules_pkg_op) + set(_pkg_check_modules_pkg_ver) + endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") + + # handle the operands + if (_pkg_check_modules_pkg_op STREQUAL ">=") + list(APPEND _pkg_check_modules_exist_query --atleast-version) + endif(_pkg_check_modules_pkg_op STREQUAL ">=") + + if (_pkg_check_modules_pkg_op STREQUAL "=") + list(APPEND _pkg_check_modules_exist_query --exact-version) + endif(_pkg_check_modules_pkg_op STREQUAL "=") + + if (_pkg_check_modules_pkg_op STREQUAL "<=") + list(APPEND _pkg_check_modules_exist_query --max-version) + endif(_pkg_check_modules_pkg_op STREQUAL "<=") + + # create the final query which is of the format: + # * --atleast-version + # * --exact-version + # * --max-version + # * --exists + if (_pkg_check_modules_pkg_op) + list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}") + else(_pkg_check_modules_pkg_op) + list(APPEND _pkg_check_modules_exist_query --exists) + endif(_pkg_check_modules_pkg_op) + + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION) + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX) + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR) + _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR) + + list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}") + list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}") + + # execute the query + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query} + RESULT_VARIABLE _pkgconfig_retval) + + # evaluate result and tell failures + if (_pkgconfig_retval) + if(NOT ${_is_silent}) + message(STATUS " package '${_pkg_check_modules_pkg}' not found") + endif(NOT ${_is_silent}) + + set(_pkg_check_modules_failed 1) + endif(_pkgconfig_retval) + endforeach(_pkg_check_modules_pkg) + + if(_pkg_check_modules_failed) + # fail when requested + if (${_is_required}) + message(SEND_ERROR "A required package was not found") + endif (${_is_required}) + else(_pkg_check_modules_failed) + # when we are here, we checked whether requested modules + # exist. Now, go through them and set variables + + _pkgconfig_set(${_prefix}_FOUND 1) + list(LENGTH _pkg_check_modules_packages pkg_count) + + # iterate through all modules again and set individual variables + foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages}) + # handle case when there is only one package required + if (pkg_count EQUAL 1) + set(_pkg_check_prefix "${_prefix}") + else(pkg_count EQUAL 1) + set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}") + endif(pkg_count EQUAL 1) + + _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION "" --modversion ) + _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX "" --variable=prefix ) + _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR "" --variable=includedir ) + _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) + + message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + endforeach(_pkg_check_modules_pkg) + + # set variables which are combined for multiple modules + _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES "(^| )-l" --libs-only-l ) + _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS "(^| )-L" --libs-only-L ) + _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS "" --libs ) + _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER "" --libs-only-other ) + + _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )-I" --cflags-only-I ) + _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) + _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) + endif(_pkg_check_modules_failed) + else(PKG_CONFIG_EXECUTABLE) + if (${_is_required}) + message(SEND_ERROR "pkg-config tool not found") + endif (${_is_required}) + endif(PKG_CONFIG_EXECUTABLE) +endmacro(_pkg_check_modules_internal) + +### +### User visible macros start here +### + +### +macro(pkg_check_modules _prefix _module0) + # check cached value + if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) + _pkgconfig_parse_options (_pkg_modules _pkg_is_required "${_module0}" ${ARGN}) + _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules}) + + _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) + endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) +endmacro(pkg_check_modules) + +### +macro(pkg_search_module _prefix _module0) + # check cached value + if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) + set(_pkg_modules_found 0) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN}) + + message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + + # iterate through all modules and stop at the first working one. + foreach(_pkg_alt ${_pkg_modules_alt}) + if(NOT _pkg_modules_found) + _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}") + endif(NOT _pkg_modules_found) + + if (${_prefix}_FOUND) + set(_pkg_modules_found 1) + endif(${_prefix}_FOUND) + endforeach(_pkg_alt) + + if (NOT ${_prefix}_FOUND) + if(${_pkg_is_required}) + message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found") + endif(${_pkg_is_required}) + endif(NOT ${_prefix}_FOUND) + + _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) + endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) +endmacro(pkg_search_module) + +### Local Variables: +### mode: cmake +### End: diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..565e1f9 --- /dev/null +++ b/INSTALL @@ -0,0 +1,37 @@ +BUILD & INSTALL +=============== + +Applauncherd uses the CMake build system. + +Configure +--------- + +* Configure applauncherd only: + + ./configure + +* Configure applauncherd + tests: + + BUILD_TESTS=1 ./configure + +* Configure applauncherd with security check for invoker disabled: + + DISABLE_VERIFICATION=1 ./configure + +* If you are building the .deb package, check debian/rules for the configuration used + +Build +----- + +make + +Build Doxygen -documentation if Doxygen was found +------------------------------------------------- + +make doc + +Install +------- + +make install + diff --git a/README b/README new file mode 100644 index 0000000..a2391c2 --- /dev/null +++ b/README @@ -0,0 +1,136 @@ +What is applauncherd? +============================== + +Applauncherd is a daemon and it helps to launch applications faster by preloading MeeGo Touch and Qt dynamically linked libraries and making some initializations before loading the application binary and executing the main function. + +The applauncherd daemon is started by UpStart as part of XSession, that is, at the same level as the desktop (MeeGo Touch homescreen). Applauncherd forks the will-be-application process a.k.a booster before knowing which application is going to be launched next. + +Users use the launcher always through a special invoker program. The invoker (/usr/bin/invoker) tells booster process to load an application binary. + +Before loading, booster process changes its security credentials so that the code in the application binary will be executed with the correct credentials. Loading the binary is done with dlopen(), and therefore the application needs to be compiled and linked as a shared library or a position independent executable. The booster process also sets the +environment variables. Finally, it finds the main function in the application binary with dlsym() and calls the main() with the command line arguments given by the invoker. + +Aegis platform security is used to protect the socket connection between invoker and launcher. Currently this works only on the target device. It is automatically disabled by the build scripts when compiling on x86. + +Each application type (currently Qt and MeeGo Touch) has its own booster process. When booster launches the application by calling the "main()" function, applauncherd will create new booster process of that type. Qt booster can be used for all kinds of applicationts. + +Booster processes do some initializations that cannot be shared among other processes and therefore have to be done after the fork. This allows, for instance, instantiating a MeeGo Touch application before knowing the name of the application. Then the booster process waits for a connection from the invoker with the information about which application should be launched. + +With MeeGo Touch booster it's possible to fetch certain objects from a cache. This will significantly reduce the startup time of an application. Please refer to the MeeGo Touch documentation for instructions on MComponentCache and how to enable it in your application. + + +Using applauncherd +============================== + +1. COMPILING YOUR APPLICATION TO BE LAUNCHABLE + +Binaries intended to be run with applauncherd should be compiled with -fPIC option to produce position independent code. In order to produce a position independent executable, -pie option and -rdynamic options can be used in linking. This allows the result to be executed traditionally and with the launcher. + +To improve linking and load times of shared object libraries the size of dynamic export table it is encouraged to hide the unnecessary symbols from the resulting binary by using -fvisibility=hidden and -fvisibility-inlines-hidden flags in compilation as well. + + Manual settings for QMake + ------------------------- + + If you are using QMake, you can define following variables in .pro file: + + QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden + QMAKE_LFLAGS += -pie -rdynamic + + Manual settings for CMake + ------------------------- + + With CMake, you can compile and install your program like this: + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden -fvisibility-inlines-hidden") + set(CMAKE_EXE_LINKER_FLAGS " -pie -rdynamic") + install(PROGRAMS myapplication DESTINATION /usr/bin RENAME myapplication.launch) + + Automatic settings with pkg-config + ---------------------------------- + + The correct flags can be automatically obtained with: + + pkg-config --cflags --libs meegotouch-boostable + + And with qmake: + + CONFIG += meegotouch-boostable + + CMake also has a pkg-config support. + + When using these, your application must build-depend on applauncherd-dev. + + Symbol visibility + ----------------- + + With -fvisibility=hidden you must make sure that the symbol for main() is exported, + because otherwise the launcher is not able to find the entry point for your + application. This can be done like this (MeeGo Touch): + + #include + + M_EXPORT int main(int argc, char **argv) + { + ... + } + + or like this (Qt): + + #include + + Q_DECL_EXPORT int main(int argc, char **argv) + { + ... + } + + or like this (generic way with gcc): + + extern "C" __attribute__ ((__visibility__("default"))) int main(int argc, char **argv) + { + ... + } + +2. LAUNCHING YOUR APPLICATION + +Rename appication binary to .launch and replace the original binary by a wrapper script that executes invoker with correct application type and the name of the application binary as a parameter. + +Use --type=m parameter for MeeGo Touch applications and --type=qt for plain Qt applications and everything else. Launch script example for typical application: + + #!/bin/sh + echo "/usr/bin/invoker --type=m" $0.launch $@ + exec /usr/bin/invoker --type=m $0.launch $@ + +If you are using D-Bus to launch your application, then this can be done straightly in the .service-file without any wrapper scripts: + + [D-BUS Service] + Name=com.nokia.launchable_app + Exec=/usr/bin/invoker --type=m /usr/bin/launchable_app.launch + +3. STARTING Applaucherd + +Applauncherd is started by UpStart during the boot time, but it can be also started manually in scratchbox or on the device by the /usr/bin/applauncherd -script + +4. PLATFORM SECURITY (Aegis) + +Altough the connection between invoker and launcher is protected by Aegis, Application developer doesn't need to request for any additional security tokens to make things work. + +5. PACKAGING + +Add dependency to applauncherd package to "Depends" section of your applications debian/control file. + + +Current known issues +============================== + + Forking and MComponentCache + --------------------------- + + It's not possible to use MComponentCache if you fork() in your application + before trying to fetch components from the cache. This is just due to the + fact that X11 connections get messed up after fork(). + +Questions and Bug Reports +============================== +TBD + + diff --git a/TODO b/TODO new file mode 100644 index 0000000..a0f1a74 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +TODO +==== + +- Update README + + diff --git a/configure b/configure new file mode 100755 index 0000000..59f264d --- /dev/null +++ b/configure @@ -0,0 +1,3 @@ +#!/bin/sh +rm -f CMakeCache.txt +cmake . diff --git a/data/mkspecs/features/meegotouch-boostable.prf b/data/mkspecs/features/meegotouch-boostable.prf new file mode 100644 index 0000000..7487b09 --- /dev/null +++ b/data/mkspecs/features/meegotouch-boostable.prf @@ -0,0 +1,5 @@ +# Tell qmake to use pkg-config to get correct compiler and linker +# flags to make an application usable with applauncherd. + +CONFIG += link_pkgconfig +PKGCONFIG += meegotouch-boostable diff --git a/data/pkgconfig/meegotouch-boostable.pc b/data/pkgconfig/meegotouch-boostable.pc new file mode 100644 index 0000000..ced3713 --- /dev/null +++ b/data/pkgconfig/meegotouch-boostable.pc @@ -0,0 +1,5 @@ +Name: meegotouch-boostable +Description: make application boostable by applauncherd +Version: 0.2.0 +Libs: -pie -rdynamic +Cflags: -fPIC -fvisibility=hidden -fvisibility-inlines-hidden diff --git a/debian/applauncherd-art-tests.install b/debian/applauncherd-art-tests.install new file mode 100644 index 0000000..38f98f2 --- /dev/null +++ b/debian/applauncherd-art-tests.install @@ -0,0 +1 @@ +usr/share/applauncherd-art-tests/tests.xml diff --git a/debian/applauncherd-bug-tests.install b/debian/applauncherd-bug-tests.install new file mode 100644 index 0000000..cc5bf69 --- /dev/null +++ b/debian/applauncherd-bug-tests.install @@ -0,0 +1 @@ +usr/share/applauncherd-bug-tests/tests.xml diff --git a/debian/applauncherd-dev.install b/debian/applauncherd-dev.install new file mode 100644 index 0000000..c95edd1 --- /dev/null +++ b/debian/applauncherd-dev.install @@ -0,0 +1,2 @@ +usr/lib/pkgconfig/meegotouch-boostable.pc +usr/share/qt4/mkspecs/features/meegotouch-boostable.prf diff --git a/debian/applauncherd-doc.install b/debian/applauncherd-doc.install new file mode 100644 index 0000000..fb568a6 --- /dev/null +++ b/debian/applauncherd-doc.install @@ -0,0 +1 @@ +usr/share/doc/applauncherd/README diff --git a/debian/applauncherd-functional-tests.install b/debian/applauncherd-functional-tests.install new file mode 100644 index 0000000..407647b --- /dev/null +++ b/debian/applauncherd-functional-tests.install @@ -0,0 +1 @@ +usr/share/applauncherd-functional-tests/tests.xml diff --git a/debian/applauncherd-invoker.aegis b/debian/applauncherd-invoker.aegis new file mode 100644 index 0000000..46a6eec --- /dev/null +++ b/debian/applauncherd-invoker.aegis @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/debian/applauncherd-invoker.install b/debian/applauncherd-invoker.install new file mode 100644 index 0000000..cacd828 --- /dev/null +++ b/debian/applauncherd-invoker.install @@ -0,0 +1 @@ +usr/bin/invoker diff --git a/debian/applauncherd-launcher.aegis b/debian/applauncherd-launcher.aegis new file mode 100644 index 0000000..214cba8 --- /dev/null +++ b/debian/applauncherd-launcher.aegis @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/debian/applauncherd-launcher.install b/debian/applauncherd-launcher.install new file mode 100644 index 0000000..fcc41e6 --- /dev/null +++ b/debian/applauncherd-launcher.install @@ -0,0 +1,2 @@ +usr/bin/applauncherd.bin +usr/bin/applauncherd diff --git a/debian/applauncherd-performance-tests.install b/debian/applauncherd-performance-tests.install new file mode 100644 index 0000000..6e69bd1 --- /dev/null +++ b/debian/applauncherd-performance-tests.install @@ -0,0 +1,2 @@ +usr/share/applauncherd-performance-tests/tests.xml + diff --git a/debian/applauncherd-testapps.aegis b/debian/applauncherd-testapps.aegis new file mode 100644 index 0000000..536f598 --- /dev/null +++ b/debian/applauncherd-testapps.aegis @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/debian/applauncherd-testapps.install b/debian/applauncherd-testapps.install new file mode 100644 index 0000000..385c355 --- /dev/null +++ b/debian/applauncherd-testapps.install @@ -0,0 +1,16 @@ +usr/bin/fala_ft_hello +usr/bin/fala_ft_hello1 +usr/bin/fala_ft_hello2 +usr/bin/fala_ft_hello.launch +usr/bin/fala_ft_hello1.launch +usr/bin/fala_ft_hello2.launch +usr/bin/qhelloworld +usr/bin/fala_ft_creds1 +usr/bin/fala_ft_creds1.launch +usr/bin/fala_ft_creds2 +usr/bin/fala_ft_creds2.launch +usr/bin/fala_testapp +usr/share/dbus-1/services/com.nokia.fala_testapp.service +usr/bin/fala_ft_themetest.launch +usr/bin/fala_ft_themetest +usr/share/themes/base/meegotouch/fala_ft_themetest/* diff --git a/debian/applauncherd-tests.install b/debian/applauncherd-tests.install new file mode 100644 index 0000000..4db6698 --- /dev/null +++ b/debian/applauncherd-tests.install @@ -0,0 +1,6 @@ +usr/share/applauncherd-tests/tests.xml +usr/share/applauncherd-tests/ut_daemon +usr/share/applauncherd-tests/ut_booster +usr/share/applauncherd-tests/ut_connection +usr/share/applauncherd-tests/ut_mbooster +usr/share/applauncherd-tests/ut_qtbooster diff --git a/debian/applauncherd-testscripts.install b/debian/applauncherd-testscripts.install new file mode 100644 index 0000000..3d9da9d --- /dev/null +++ b/debian/applauncherd-testscripts.install @@ -0,0 +1,5 @@ +usr/share/applauncherd-testscripts/test-func-launcher.py +usr/share/applauncherd-testscripts/ts_prestartapp.rb +usr/share/applauncherd-testscripts/check_pipes.py +usr/share/applauncherd-testscripts/test-perf-mbooster.py +usr/share/applauncherd-testscripts/tc_theming.rb diff --git a/debian/applauncherd.install b/debian/applauncherd.install new file mode 100644 index 0000000..e69de29 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..af6af50 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,120 @@ +applauncherd (0.7.0-2) stable; urgency=low + + * Fixes: NB#176326 - Conndlgs launched using Applauncherd respawns until respawn limit + + -- Antti Kervinen Tue, 07 Jul 2010 12:21:29 +0300 + +applauncherd (0.7.0-1) stable; urgency=low + + * Invoker waits for launched process to terminate when run with --wait-term + * Dbg packages added: applauncherd-dbg, applauncherd-invoker-dbg, applauncherd-launcher-dbg and applauncherd-testapps-dbg + * Fixes: NB#177439, invoker starts reloading cache too soon + * Implemented: SWP#DUI-3384 + + -- Antti Kervinen Tue, 07 Jul 2010 10:10:29 +0300 + +applauncherd (0.6.0-1) stable; urgency=low + + * applauncherd-art-tests and applauncherd-bug-tests added + + -- Nimika Keshri Thu, 24 Jun 2010 19:26:17 +0300 + +applauncherd (0.5.0-3) stable; urgency=low + + * Fixes: NB#174460, applauncherd-functional-tests package fails very frequently in ART + * Coverity tool fixes + + -- Nimika Keshri Mon, 14 Jun 2010 19:26:20 +0300 + +applauncherd (0.5.0-2) stable; urgency=low + + * delay is initialized to DEFAULT_DELAY + * Refactored test application for performance tests + + -- Nimika Keshri Mon, 07 Jun 2010 12:39:54 +0300 + +applauncherd (0.5.0-1) stable; urgency=low + + * Platform security feature improved + * mcomponentcache enabled + * disable LD_BIND_NOW environment variable + * added delay parameter to invoker, invoker debug logging disabled by default, code refactoring + + -- Nimika Keshri Fri, 04 Jun 2010 12:18:59 +0300 + +applauncherd (0.4.1-1) stable; urgency=low + + * applauncherd-dev install meegotouch-boostable.prf for qmake + * Socket permissions set to 777 + * Documentation updates + * Aegis tests updated / fixed + + -- Jussi Lind Thu, 27 May 2010 14:34:47 +0300 + +applauncherd (0.4.0-1) stable; urgency=low + + * Platform security stuff added: confine for the forked process + verification for the invoker (disabled for now) + * Applauncherd package divided into applauncherd-launcher and applauncherd-invoker + * Fixes: NB#170267, applauncherd-functional-tests package error + * applauncherd-dev installs meegotouch-boostable.pc that shows correct linker flags for applications + * Documentation updates + + -- Jussi Lind Thu, 20 May 2010 15:38:42 +0300 + +applauncherd (0.3.1-1) stable; urgency=low + + * Workaround: NB#168188, populating cache disabled for not allocating graphics memory + + -- Antti Kervinen Mon, 17 May 2010 14:51:25 +0300 + +applauncherd (0.3.0-1) stable; urgency=low + + * Added the feature and requirements fields inside tests.xml files + * Updated functional and unit tests according the MBooster change + * Code refactoring + * Implemented: SWP#DUI-2964 + + -- Olli Leppanen Tue, 05 May 2010 12:16:40 +0300 + +applauncherd (0.2.0-5) stable; urgency=low + + * Naming changes: libdui => libmeegotouch + * Unit tests are updated + * Implemented: SWP#DUI-2483 + + -- Alexey Shilov Tue, 27 Apr 2010 16:16:40 +0300 + +applauncherd (0.2.0-4) stable; urgency=low + + * applifed-performance-tests is trying to overwrite the file ./usr/bin/waitforwindow, which was provided by applauncherd-performance-tests + * Fixes: NB#161251 + + -- Jussi Lind Tue, 06 Apr 2010 13:59:16 +0300 + +applauncherd (0.2.0-3) stable; urgency=low + + * Instructions for developers added + * Process nice parameter passed from invoker to launcher + * Unit tests are updated + * Implemented: SWP#DUI-2127, SWP#DUI-2152 + + -- Alexey Shilov Fri, 11 Mar 2010 13:13:02 +0200 + +applauncherd (0.2.0-2) stable; urgency=low + + * Naming changes: launcher => applauncherd, applaucherd => applauncherd.bin + + -- Jussi Lind Mon, 08 Mar 2010 13:13:02 +0200 + +applauncherd (0.2.0-1) stable; urgency=low + + * First released version: basic launcher functionality with basic test set + * Implemented: SWP#DUI-2270, SWP#DUI-2128 + + -- Jussi Lind Fri, 05 Mar 2010 11:16:03 +0200 + +launcher (0.1.0-1) unstable; urgency=low + + * Initial release + + -- Jussi Lind Fri, 12 Feb 2010 16:00:08 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b0c9221 --- /dev/null +++ b/debian/control @@ -0,0 +1,127 @@ +Source: applauncherd +Section: admin +Priority: important +Maintainer: Jussi Lind +Build-Depends: cmake (>= 2.6.0), debhelper (>= 7), libqt4-dev (>= 4.5.0), libmeegotouch-dev, libcreds2-dev [arm armel], aegis-builder (>= 1.4) [arm armel] +Standards-Version: 3.8.0 + +Package: applauncherd +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-invoker (= ${Source-Version}) +Description: Meta package for applauncherd and invoker + Launcher daemon and invoker to speed up launches. + Special boosters for MeeGo Touch and Qt. + +Package: applauncherd-dbg +Architecture: any +Depends: applauncherd-invoker-dbg, applauncherd-launcher-dbg +Description: Meta package for applauncherd and invoker debug symbols + +Package: applauncherd-invoker +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-launcher (= ${Source-Version}), libcreds2 [arm armel] +Description: Invoker part of applauncherd + Invoker part of applauncherd. + +Package: applauncherd-invoker-dbg +Section: debug +Architecture: any +Depends: applauncherd-invoker (= ${Source-Version}) +Description: Invoker debug package + Debug symbols for invoker + +Package: applauncherd-launcher +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libcreds2 [arm armel] +Description: Launcher part of applauncherd + Launcher part of applauncherd. + +Package: applauncherd-launcher-dbg +Section: debug +Architecture: any +Depends: applauncherd-launcher (= ${Source-Version}) +Description: Launcher debug package + Debug symbols for launcher + +Package: applauncherd-dev +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, pkg-config +Description: Development files for applications using applauncherd + Development files for applications using applauncherd. + +Package: applauncherd-tests +Section: extra +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libmeegotouchcore0, libmeegotouchviews0, libmeegotouchextensions0, libmeegotouchsettings0, testrunner, applauncherd, ci-testing, libcreds[arm armel] +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, staging, acceptance, validation +Description: applauncherd unit tests + Unit testing binaries and shellscripts for testing applauncherd. + +Package: applauncherd-testscripts +Section: extra +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-testapps, testrunner, applauncherd, ci-testing, matti, libcreds2 [arm armel], libcreds2-tools [arm armel], meego-env, mcetools (>= 1.10.40) +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, staging, acceptance, validation +Description: applauncherd testscripts + Testscripts for testing applauncherd + +Package: applauncherd-testapps +Section: extra +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd, libmeegotouchcore0, libmeegotouchviews0, libmeegotouchextensions0, libmeegotouchsettings0, libcreds2 [arm armel], libcreds2-tools [arm armel] +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, staging, acceptance, validation +Description: applaunched testapps + Test applications for testing applauncherd. + +Package: applauncherd-testapps-dbg +Section: debug +Architecture: any +Depends: applauncherd-testapps +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, staging, acceptance, validation +Description: debug symbols for applauncherd testapps + +Package: applauncherd-functional-tests +Section: extra +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-testapps, applauncherd-testscripts +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, staging, acceptance, validation +Description: applauncherd functional tests + Functional tests for testing applauncherd. + +Package: applauncherd-art-tests +Section: extra +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-testapps, applauncherd-testscripts +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, staging, acceptance, validation +Description: applauncherd art tests + Art tests for testing applauncherd. + +Package: applauncherd-bug-tests +Section: extra +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-testapps, applauncherd-testscripts +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, staging, acceptance, validation +Description: applauncherd bug tests + Tests related to bugs for testing applauncherd. + +Package: applauncherd-performance-tests +Section: extra +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-testapps, applauncherd-testscripts +XB-Maemo-CI-Packages: applauncherd +XB-Maemo-CI-Stage: fast, acceptance, validation +Description: applauncherd performance tests + Performance testing binaries and shellscripts for testing applauncherd. + +Package: applauncherd-doc +Section: doc +Architecture: all +Description: Instructions for application developers + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..461dee0 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,37 @@ +This package was debianized by Jussi Lind on +Wed, 28 Oct 2009 12:27:28 +0200. + +It was downloaded from + +Upstream Author(s): + + Antti Kervinen, antti.kervinen@nokia.com + Jussi Lind, jussi.lind@nokia.com + Alexey Shilov, alexey.shilov@nokia.com + Guillem Jover, guillem.jover@nokia.com (original invoker) + +Copyright: + + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + +License: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + +The Debian packaging is copyright 2010 Nokia Corporation and/or its subsidiary(-ies), and is licensed under the LGPL version 2.1. + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..ca882bb --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..e69de29 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..4e3d7b0 --- /dev/null +++ b/debian/rules @@ -0,0 +1,99 @@ +#!/usr/bin/make -f + +#include /usr/share/cdbs/1/rules/debhelper.mk +#include /usr/share/cdbs/1/class/cmake.mk + +# architecture we're building for +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) + +configure: configure-stamp +configure-stamp: + dh_testdir + +ifeq ($(DEB_HOST_ARCH), arm) + # Configure Applauncherd to be build with tests + # TODO: remove DISABLE_VERIFICATION=1 when works + BUILD_TESTS=1 ./configure +else ifeq ($(DEB_HOST_ARCH), armel) + # Configure Applauncherd to be build with tests + # TODO: remove DISABLE_VERIFICATION=1 when works + BUILD_TESTS=1 ./configure +else + # Configure Applauncherd to be build with tests and without checking invoker credentials + BUILD_TESTS=1 ./configure +endif + + touch configure-stamp + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + make + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f CMakeCache.txt + dh_clean + +install: build + dh_testdir + dh_testroot + dh_prep + dh_installdirs + + DESTDIR=debian/tmp make install + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_install --sourcedir=debian/tmp -v +# dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo +# dh_installman + dh_link + dh_strip -p applauncherd-launcher --dbg-package=applauncherd-launcher-dbg + dh_strip -p applauncherd-invoker --dbg-package=applauncherd-invoker-dbg + dh_strip -p applauncherd-testapps --dbg-package=applauncherd-testapps-dbg + dh_compress + dh_fixperms +# dh_perl +# dh_python + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb +# TODO: CLEAN THIS UP! +ifeq ($(DEB_HOST_ARCH), arm) + aegis-deb-add -control debian/applauncherd-launcher/DEBIAN/control .. debian/applauncherd-launcher.aegis=_aegis + aegis-deb-add -control debian/applauncherd-invoker/DEBIAN/control .. debian/applauncherd-invoker.aegis=_aegis + aegis-deb-add -control debian/applauncherd-testapps/DEBIAN/control .. debian/applauncherd-testapps.aegis=_aegis +else ifeq ($(DEB_HOST_ARCH), armel) + aegis-deb-add -control debian/applauncherd-launcher/DEBIAN/control .. debian/applauncherd-launcher.aegis=_aegis + aegis-deb-add -control debian/applauncherd-invoker/DEBIAN/control .. debian/applauncherd-invoker.aegis=_aegis + aegis-deb-add -control debian/applauncherd-testapps/DEBIAN/control .. debian/applauncherd-testapps.aegis=_aegis +endif + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/doc/Doxyfile b/doc/Doxyfile new file mode 100644 index 0000000..053ffda --- /dev/null +++ b/doc/Doxyfile @@ -0,0 +1,1510 @@ +# Doxyfile 1.5.8 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = applauncherd + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, +# Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = src/invoker src/launcher + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.h *.c *.cpp + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. + +GENERATE_TREEVIEW = NONE + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = YES + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = YES + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..04f592f --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,7 @@ +# Sub build: invoker +add_subdirectory(invoker) +# Sub build: launcher +add_subdirectory(launcher) + + + diff --git a/src/common/protocol.h b/src/common/protocol.h new file mode 100644 index 0000000..e823782 --- /dev/null +++ b/src/common/protocol.h @@ -0,0 +1,43 @@ +/*************************************************************************** +** +** 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 PROTOCOL_H +#define PROTOCOL_H + +#include + +const uint32_t INVOKER_MSG_MASK = 0xffff0000; +const uint32_t INVOKER_MSG_MAGIC = 0xb0070000; +const uint32_t INVOKER_MSG_MAGIC_VERSION_MASK = 0x0000ff00; +const uint32_t INVOKER_MSG_MAGIC_VERSION = 0x00000300; +const uint32_t INVOKER_MSG_MAGIC_OPTION_MASK = 0x000000ff; +const uint32_t INVOKER_MSG_MAGIC_OPTION_WAIT = 0x00000001; +const uint32_t INVOKER_MSG_NAME = 0x5a5e0000; +const uint32_t INVOKER_MSG_EXEC = 0xe8ec0000; +const uint32_t INVOKER_MSG_ARGS = 0xa4650000; +const uint32_t INVOKER_MSG_ENV = 0xe5710000; +const uint32_t INVOKER_MSG_PRIO = 0xa1ce0000; +const uint32_t INVOKER_MSG_IO = 0x10fd0000; +const uint32_t INVOKER_MSG_END = 0xdead0000; +const uint32_t INVOKER_MSG_PID = 0x1d1d0000; +const uint32_t INVOKER_MSG_EXIT = 0xe4170000; +const uint32_t INVOKER_MSG_ACK = 0x600d0000; +const uint32_t INVOKER_MSG_BAD_CREDS = 0x60035800; + +#endif // PROTOCOL_H diff --git a/src/invoker/CMakeLists.txt b/src/invoker/CMakeLists.txt new file mode 100644 index 0000000..cd3e2b0 --- /dev/null +++ b/src/invoker/CMakeLists.txt @@ -0,0 +1,19 @@ +# Set sources +set(SRC invokelib.c invoker.c report.c search.c) + +# Set include dirs +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common) + +# Set C flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wall -O2") + +# Set precompiler flags +add_definitions(-DPROG_NAME="invoker") + +# Set target +add_executable(invoker ${SRC}) + +# Add install rule +install(PROGRAMS invoker DESTINATION /usr/bin/) + + diff --git a/src/invoker/invokelib.c b/src/invoker/invokelib.c new file mode 100644 index 0000000..18895d1 --- /dev/null +++ b/src/invoker/invokelib.c @@ -0,0 +1,84 @@ +/*************************************************************************** +** +** 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 +#include +#include +#include +#include + +#include "report.h" +#include "invokelib.h" + +bool invoke_send_msg(int fd, uint32_t msg) +{ + debug("%s: %08x\n", __FUNCTION__, msg); + return write(fd, &msg, sizeof(msg)) != -1; +} + +bool invoke_recv_msg(int fd, uint32_t *msg) +{ + int res = read(fd, msg, sizeof(*msg)); + debug("%s: %08x\n", __FUNCTION__, *msg); + return res != -1; +} + +bool invoke_send_str(int fd, char *str) +{ + uint32_t size; + + /* Send size. */ + size = strlen(str) + 1; + invoke_send_msg(fd, size); + + debug("%s: '%s'\n", __FUNCTION__, str); + + /* Send the string. */ + return write(fd, str, size) != -1; +} + +char* invoke_recv_str(int fd) +{ + int size = 0; + char *str; + + /* Get the size. */ + invoke_recv_msg(fd, (uint32_t*) &size); + str = (char*)malloc(size); + if (!str) + { + error("mallocing in %s\n", __FUNCTION__); + return NULL; + } + + /* Get the string. */ + int ret = read(fd, str, size); + if (ret < size) + { + error("getting string, got %u of %u bytes\n", ret, size); + free(str); + return NULL; + } + str[size - 1] = '\0'; + + debug("%s: '%s'\n", __FUNCTION__, str); + + return str; +} + diff --git a/src/invoker/invokelib.h b/src/invoker/invokelib.h new file mode 100644 index 0000000..1396318 --- /dev/null +++ b/src/invoker/invokelib.h @@ -0,0 +1,37 @@ +/*************************************************************************** +** +** 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 INVOKELIB_H +#define INVOKELIB_H + +#include +#include + +bool invoke_send_msg(int fd, uint32_t msg); +bool invoke_recv_msg(int fd, uint32_t *msg); + +bool invoke_send_str(int fd, char *str); +char *invoke_recv_str(int fd); + +/* FIXME: Should be '/var/run/'. */ +//#define INVOKER_SOCK "/tmp/."PACKAGE +#define INVOKER_M_SOCK "/tmp/mlnchr" +#define INVOKER_QT_SOCK "/tmp/qtlnchr" + +#endif diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c new file mode 100644 index 0000000..8cdbe5a --- /dev/null +++ b/src/invoker/invoker.c @@ -0,0 +1,457 @@ +/*************************************************************************** +** +** 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. +** +****************************************************************************/ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "report.h" +#include "protocol.h" +#include "invokelib.h" +#include "search.h" + +#ifdef HAVE_CREDS + #include +#endif + +// Delay before exit +static const int DEFAULT_DELAY = 0; + +// Enumeration of possible application types: +// M_APP: MeeGo Touch application +// QT_APP: Qt/generic application +// +enum APP_TYPE { M_APP, QT_APP, UNKNOWN_APP }; + +// Environment +extern char ** environ; + +/* + * Show a list of credentials that the client has + */ +static void show_credentials(void) +{ +#ifdef HAVE_CREDS + creds_t creds; + creds_value_t value; + creds_type_t type; + int i; + + creds = creds_gettask(0); + for (i = 0; (type = creds_list(creds, i, &value)) != CREDS_BAD; ++i) { + char buf[200]; + (void)creds_creds2str(type, value, buf, sizeof(buf)); + buf[sizeof(buf)-1] = 0; + printf("\t%s\n", buf); + } + creds_free(creds); +#else + printf("Security credential information isn't available.\n"); +#endif + + exit(0); +} + +static bool invoke_recv_ack(int fd) +{ + uint32_t action; + + // Receive ACK. + invoke_recv_msg(fd, &action); + + if (action == INVOKER_MSG_BAD_CREDS) + { + die(1, "Security credential check failed.\n"); + } + else if (action != INVOKER_MSG_ACK) + { + die(1, "Received wrong ack (%08x)\n", action); + } + + return true; +} + +static int invoker_init(enum APP_TYPE app_type) +{ + int fd; + struct sockaddr_un sun; + + fd = socket(PF_UNIX, SOCK_STREAM, 0); + if (fd < 0) + { + die(1, "Failed to open invoker socket.\n"); + } + + sun.sun_family = AF_UNIX; //AF_FILE; + + const int maxSize = sizeof(sun.sun_path) - 1; + if(app_type == M_APP) + { + strncpy(sun.sun_path, INVOKER_M_SOCK, maxSize); + } + else if (app_type == QT_APP) + { + strncpy(sun.sun_path, INVOKER_QT_SOCK, maxSize); + } + else + { + die(1, "Unknown type of application: %d\n", app_type); + } + + sun.sun_path[maxSize] = '\0'; + + if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) < 0) + { + die(1, "Failed to initiate connect on the socket.\n"); + } + + return fd; +} + +static bool invoker_send_magic(int fd, int options) +{ + // Send magic. + invoke_send_msg(fd, INVOKER_MSG_MAGIC | INVOKER_MSG_MAGIC_VERSION | options); + invoke_recv_ack(fd); + + return true; +} + +static bool invoker_send_name(int fd, char *name) +{ + // Send action. + invoke_send_msg(fd, INVOKER_MSG_NAME); + invoke_send_str(fd, name); + invoke_recv_ack(fd); + + return true; +} + +static bool invoker_send_exec(int fd, char *exec) +{ + // Send action. + invoke_send_msg(fd, INVOKER_MSG_EXEC); + invoke_send_str(fd, exec); + invoke_recv_ack(fd); + + return true; +} + +static bool invoker_send_args(int fd, int argc, char **argv) +{ + int i; + + // Send action. + invoke_send_msg(fd, INVOKER_MSG_ARGS); + invoke_send_msg(fd, argc); + for (i = 0; i < argc; i++) + { + debug("param %d %s \n", i, argv[i]); + invoke_send_str(fd, argv[i]); + } + invoke_recv_ack(fd); + + return true; +} + +static bool invoker_send_prio(int fd, int prio) +{ + // Send action. + invoke_send_msg(fd, INVOKER_MSG_PRIO); + invoke_send_msg(fd, prio); + + invoke_recv_ack(fd); + + return true; +} + +static bool invoker_send_env(int fd) +{ + int i, n_vars; + + // Count the amount of environment variables. + for (n_vars = 0; environ[n_vars] != NULL; n_vars++) ; + + // Send action. + invoke_send_msg(fd, INVOKER_MSG_ENV); + invoke_send_msg(fd, n_vars); + + for (i = 0; i < n_vars; i++) + { + invoke_send_str(fd, environ[i]); + } + + return true; +} + +static bool invoker_send_io(int fd) +{ + struct msghdr msg; + struct cmsghdr *cmsg = NULL; + int io[3] = { 0, 1, 2 }; + char buf[CMSG_SPACE(sizeof(io))]; + struct iovec iov; + int dummy; + + memset(&msg, 0, sizeof(struct msghdr)); + + iov.iov_base = &dummy; + iov.iov_len = 1; + + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + msg.msg_control = buf; + msg.msg_controllen = sizeof(buf); + + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(io)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + + memcpy(CMSG_DATA(cmsg), io, sizeof(io)); + + msg.msg_controllen = cmsg->cmsg_len; + + invoke_send_msg(fd, INVOKER_MSG_IO); + if (sendmsg(fd, &msg, 0) < 0) + { + warning("sendmsg failed in invoker_send_io: %s /n", strerror(errno)); + return false; + } + + return true; +} + +static bool invoker_send_end(int fd) +{ + // Send action. + invoke_send_msg(fd, INVOKER_MSG_END); + invoke_recv_ack(fd); + + return true; +} + +static void usage(int status) +{ + printf("\nUsage: %s [options] [--type=TYPE] [file] [args]\n" + "Launch m or qt application.\n\n" + "TYPE chooses the type of booster used. Qt-booster may be used to launch anything.\n" + "Possible values for TYPE: \n" + " m Launch a MeeGo Touch application.\n" + " qt Launch a Qt application.\n\n" + "Options:\n" + " -c, --creds Print Aegis security credentials (if enabled).\n" + " -d, --delay SECS After invoking sleep for SECS seconds (default %d).\n" + " -w, --wait-term Wait for launched process to terminate.\n" + " -h, --help Print this help message.\n\n" + "Example: %s --type=m /usr/bin/helloworld \n", + PROG_NAME, DEFAULT_DELAY, PROG_NAME); + + exit(status); +} + +static unsigned int get_delay(char *delay_arg) +{ + unsigned int delay; + + if (delay_arg) + { + errno = 0; // To distinguish success/failure after call + delay = strtoul(delay_arg, NULL, 10); + + // Check for various possible errors + if ((errno == ERANGE && delay == ULONG_MAX) || delay == 0) + { + report(report_error, "Wrong value of delay parameter: %s\n", delay_arg); + usage(1); + } + } + else + delay = DEFAULT_DELAY; + + return delay; +} + +static void invoke(int prog_argc, char **prog_argv, char *prog_name, + enum APP_TYPE app_type, int magic_options, bool wait_term) +{ + if (prog_name && prog_argv) + { + errno = 0; + int prog_prio = getpriority(PRIO_PROCESS, 0); + + if (errno && prog_prio < 0) + { + prog_prio = 0; + } + + int fd = invoker_init(app_type); + + invoker_send_magic(fd, magic_options); + invoker_send_name(fd, prog_argv[0]); + invoker_send_exec(fd, prog_name); + invoker_send_args(fd, prog_argc, prog_argv); + invoker_send_prio(fd, prog_prio); + invoker_send_io(fd); + invoker_send_env(fd); + invoker_send_end(fd); + + if (prog_name) + { + free(prog_name); + } + + // Wait for launched process to exit + if (wait_term) + { + char dummy_buf = 0; + recv(fd, (void *)&dummy_buf, 0, MSG_WAITALL); + } + + close(fd); + } +} + +int main(int argc, char *argv[]) +{ + enum APP_TYPE app_type = UNKNOWN_APP; + int prog_argc = 0; + int magic_options = 0; + bool wait_term = false; + unsigned int delay = DEFAULT_DELAY; + char **prog_argv = NULL; + char *prog_name = NULL; + + if (!strstr(argv[0], PROG_NAME) ) + { + // Called with a different name, old way of using invoker + die(1, + "Incorrect use of invoker, don't use symlinks. " + "Run invoker explicitly from e.g. a D-Bus service file instead.\n"); + } + + // stops args parsing as soon as a non-option argument is encountered + putenv("POSIXLY_CORRECT=1"); + + struct option longopts[] = { + {"help", no_argument, NULL, 'h'}, + {"creds", no_argument, NULL, 'c'}, + {"wait-term", no_argument, NULL, 'w'}, + {"type", required_argument, NULL, 't'}, + {"delay", required_argument, NULL, 'd'}, + {0, 0, 0, 0} + }; + + int opt; + while ((opt = getopt_long(argc, argv, "hcwd:t:", longopts, NULL)) != -1) + { + switch(opt) + { + case 'h': + usage(0); + break; + + case 'c': + show_credentials(); + break; + + case 'w': + wait_term = true; + break; + + case 't': + if (strcmp(optarg, "qt") == 0) + app_type = QT_APP; + else if (strcmp(optarg, "m") == 0) + app_type = M_APP; + else + { + report(report_error, "Unknown application type: %s \n", optarg); + usage(1); + } + break; + + case 'd': + delay = get_delay(optarg); + break; + + case '?': + usage(1); + } + } + + // option processing stops as soon as application name is encountered + if (optind < argc) + { + prog_name = search_program(argv[optind]); + if (!prog_name) + { + report(report_error, "Can't find application to invoke.\n"); + usage(0); + } + + char *period = strstr(argv[optind], ".launch"); + if (period) + { + *period = '\0'; + } + + prog_argc = argc - optind; + prog_argv = &argv[optind]; + } + + if (!prog_name) + { + die(1, "Application's name is unknown.\n"); + } + + if (app_type == UNKNOWN_APP) + { + die(1, "Application's type is unknown. \n"); + } + // Send commands to the launcher daemon + info("Invoking execution: '%s'\n", prog_name); + invoke(prog_argc, prog_argv, prog_name, app_type, magic_options, wait_term); + + // Sleep for delay before exiting + if (delay) + { + // DBUS cannot cope some times if the invoker exits too early. + debug("Delaying exit for %d seconds..\n", delay); + sleep(delay); + } + + return 0; +} diff --git a/src/invoker/report.c b/src/invoker/report.c new file mode 100644 index 0000000..a8cd217 --- /dev/null +++ b/src/invoker/report.c @@ -0,0 +1,99 @@ +/*************************************************************************** +** +** 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 +#include +#include +#include + +#include "report.h" + +static enum report_output output = report_console; + +void report_set_output(enum report_output new_output) +{ + if (output == new_output) + return; + + if (output == report_syslog) + closelog(); + + if (new_output == report_syslog) + openlog(PROG_NAME, LOG_PID, LOG_DAEMON); + + output = new_output; +} + +static void vreport(enum report_type type, char *msg, va_list arg) +{ + char str[400]; + char *str_type = ""; + int log_type; + + switch (type) + { + case report_debug: + log_type = LOG_DEBUG; + break; + default: + case report_info: + log_type = LOG_INFO; + break; + case report_warning: + str_type = "warning: "; + log_type = LOG_WARNING; + break; + case report_error: + str_type = "error: "; + log_type = LOG_ERR; + break; + case report_fatal: + str_type = "died: "; + log_type = LOG_ERR; + break; + } + + vsnprintf(str, sizeof(str), msg, arg); + + if (output == report_console) + printf("%s: %s%s", PROG_NAME, str_type, str); + else if (output == report_syslog) + syslog(log_type, "%s%s", str_type, str); +} + +void report(enum report_type type, char *msg, ...) +{ + va_list arg; + + va_start(arg, msg); + vreport(type, msg, arg); + va_end(arg); +} + +void die(int status, char *msg, ...) +{ + va_list arg; + + va_start(arg, msg); + vreport(report_fatal, msg, arg); + va_end(arg); + + exit(status); +} + diff --git a/src/invoker/report.h b/src/invoker/report.h new file mode 100644 index 0000000..20cee1b --- /dev/null +++ b/src/invoker/report.h @@ -0,0 +1,60 @@ +/*************************************************************************** +** +** 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 REPORT_H +#define REPORT_H + +#ifdef __GNUC__ +#define ATTR_NORET __attribute__((noreturn)) +#else +#define ATTR_NORET +#endif + +enum report_output { + report_console, + report_syslog, + report_none +}; + +enum report_type { + report_debug, + report_info, + report_warning, + report_error, + report_fatal +}; + +extern void report_set_output(enum report_output new_output); +extern void report(enum report_type type, char *msg, ...); + +//#define _DEBUG +#ifdef _DEBUG +#define debug(msg, ...) report(report_debug, msg, ##__VA_ARGS__) +#else +#define debug(...) +#endif + +#define info(msg, ...) report(report_info, msg, ##__VA_ARGS__) +#define warning(msg, ...) report(report_warning, msg, ##__VA_ARGS__) +#define error(msg, ...) report(report_error, msg, ##__VA_ARGS__) + +extern void ATTR_NORET die(int status, char *msg, ...); + +#endif + diff --git a/src/invoker/search.c b/src/invoker/search.c new file mode 100644 index 0000000..d3e2277 --- /dev/null +++ b/src/invoker/search.c @@ -0,0 +1,105 @@ +/*************************************************************************** +** +** 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. +** +****************************************************************************/ + +#define _GNU_SOURCE + +#include +#include +#include +#include + +#include "report.h" +#include "search.h" + +static char* merge_paths(const char *base_path, const char *rel_path) +{ + char *path; + + if (asprintf(&path, "%s%s%s", base_path, + (base_path[strlen(base_path) - 1] == '/' ? "" : "/"), + rel_path) < 0) + { + die(1, "allocating merge path buffer"); + } + return path; +} + +char* search_program(const char *progname) +{ + char *launch = NULL; + char *cwd; + + if (progname[0] == '/') + { + launch = strdup(progname); + if (!launch) + { + die(1, "allocating program name buffer"); + } + } + else if (strchr(progname, '/') != NULL) + { + cwd = get_current_dir_name(); + launch = merge_paths(cwd, progname); + free(cwd); + } + else + { + char *path = getenv("PATH"); + char *saveptr = NULL; + char *token; + + if (path == NULL) + { + die(1, "could not get PATH environment variable"); + } + path = strdup(path); + + for (token = strtok_r(path, ":", &saveptr); token != NULL; token = strtok_r(NULL, ":", &saveptr)) + { + launch = merge_paths(token, progname); + + if (access(launch, X_OK) == 0) + break; + + free(launch); + launch = NULL; + } + + free(path); + + if (launch == NULL) + { + die(1, "could not locate program \"%s\" to launch \n", progname); + } + + if (launch[0] != '/') + { + char *relative = launch; + + cwd = get_current_dir_name(); + launch = merge_paths(cwd, relative); + + free(cwd); + free(relative); + } + } + return launch; +} + diff --git a/src/invoker/search.h b/src/invoker/search.h new file mode 100644 index 0000000..f9b8fc0 --- /dev/null +++ b/src/invoker/search.h @@ -0,0 +1,26 @@ +/*************************************************************************** +** +** 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 SEARCH_H +#define SEARCH_H + +char *search_program(const char *progname); + +#endif + diff --git a/src/launcher/CMakeLists.txt b/src/launcher/CMakeLists.txt new file mode 100644 index 0000000..5079cda --- /dev/null +++ b/src/launcher/CMakeLists.txt @@ -0,0 +1,37 @@ +# Qt support +include(${QT_USE_FILE}) + +# Find Meego Touch libraries using pkg-config. +include(FindPkgConfig) +pkg_check_modules(MEEGOTOUCH meegotouch>=0.20 REQUIRED) +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${MEEGOTOUCH_INCLUDE_DIRS}) + +# Check if it's possible to compile MBooster with MComponentCache. If so, +# HAVE_MCOMPONENTCACHE is set. +message(STATUS "checking for mcomponentcache.h") +find_file(M_COMPONENT_CACHE NAMES mcomponentcache.h PATHS ${MEEGOTOUCH_INCLUDE_DIRS}) +if (EXISTS ${M_COMPONENT_CACHE}) + message(STATUS " found") + add_definitions(-DHAVE_MCOMPONENTCACHE) +else (EXISTS ${M_COMPONENT_CACHE}) + message(STATUS " not found") +endif (EXISTS ${M_COMPONENT_CACHE}) + +# Set sources +set(SRC appdata.cpp booster.cpp connection.cpp daemon.cpp mbooster.cpp logger.cpp main.cpp qtbooster.cpp) + +# Set the program name define used in daemon.cpp +add_definitions(-DPROG_NAME="applauncherd") + +# Find libdl +find_library(LIBDL NAMES dl) + +# Set libraries to be linked +link_libraries(${QT_LIBRARIES} ${MEEGOTOUCH_LIBRARIES} ${LIBDL}) + +# Set executable +add_executable(applauncherd.bin ${SRC}) + +# Add install rule +install(PROGRAMS applauncherd.bin scripts/applauncherd DESTINATION /usr/bin/) + diff --git a/src/launcher/appdata.cpp b/src/launcher/appdata.cpp new file mode 100644 index 0000000..85be9c1 --- /dev/null +++ b/src/launcher/appdata.cpp @@ -0,0 +1,131 @@ +/*************************************************************************** +** +** 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 "appdata.h" + +AppData::AppData() : + m_options(0), + m_argc(0), + m_argv(NULL), + m_appName(""), + m_fileName(""), + m_prio(0), + m_entry(NULL), + m_ioDescriptors() +{} + +void AppData::setOptions(int newOptions) +{ + m_options = newOptions; +} + +int AppData::options() const +{ + return m_options; +} + +void AppData::setArgc(int newArgc) +{ + m_argc = newArgc; +} + +int AppData::argc() const +{ + return m_argc; +} + +void AppData::setArgv(const char ** newArgv) +{ + m_argv = newArgv; +} + +const char ** AppData::argv() const +{ + return m_argv; +} + +void AppData::setAppName(const string & newAppName) +{ + m_appName = newAppName; +} + +const string & AppData::appName() const +{ + return m_appName; +} + +void AppData::setFileName(const string & newFileName) +{ + m_fileName = newFileName; +} + +const string & AppData::fileName() const +{ + return m_fileName; +} + +void AppData::setPriority(int newPriority) +{ + m_prio = newPriority; +} + +int AppData::priority() const +{ + return m_prio; +} + +void AppData::setEntry(entry_t newEntry) +{ + m_entry = newEntry; +} + +entry_t AppData::entry() const +{ + return m_entry; +} + +const vector & AppData::ioDescriptors() const +{ + return m_ioDescriptors; +} + +void AppData::setIODescriptors(const vector & newIODescriptors) +{ + m_ioDescriptors = newIODescriptors; +} + +void AppData::deleteArgv() +{ + if (m_argv) + { + for (int i = 0; i < m_argc; i++) + { + delete m_argv[i]; + m_argv[i] = NULL; + } + + delete [] m_argv; + m_argv = NULL; + } +} + +AppData::~AppData() +{ + deleteArgv(); +} diff --git a/src/launcher/appdata.h b/src/launcher/appdata.h new file mode 100644 index 0000000..2e93e99 --- /dev/null +++ b/src/launcher/appdata.h @@ -0,0 +1,110 @@ +/*************************************************************************** +** +** 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 APPDATA_H +#define APPDATA_H + +#include + +using std::string; + +#include + +using std::vector; + +typedef int (*entry_t)(int, char **); + +//! Structure for application data read from the invoker +class AppData +{ +public: + + //! Constructor + AppData(); + + //! Destructor + ~AppData(); + + //! Set options + void setOptions(int options); + + //! Return options + int options() const; + + //! Set argument count + void setArgc(int argc); + + //! Return argument count + int argc() const; + + //! Set address of the argument vector + void setArgv(const char ** argv); + + //! Return address of the argument vector + const char ** argv() const; + + //! Set application name + void setAppName(const string & appName); + + //! Return application name + const string & appName() const; + + //! Set file name + void setFileName(const string & fileName); + + //! Return file name + const string & fileName() const; + + //! Set priority + void setPriority(int priority); + + //! Return priority + int priority() const; + + //! Set entry point for the application + void setEntry(entry_t entry); + + //! Get the entry point + entry_t entry() const; + + //! Get I/O descriptors + const vector & ioDescriptors() const; + + //! Set I/O descriptors + void setIODescriptors(const vector & ioDescriptors); + + //! Frees the memory reserved for argv + void deleteArgv(); + +private: + + AppData(const AppData & r); + AppData & operator= (const AppData & r); + + int m_options; + int m_argc; + const char ** m_argv; + string m_appName; + string m_fileName; + int m_prio; + entry_t m_entry; + vector m_ioDescriptors; +}; + +#endif // APPDATA_H diff --git a/src/launcher/booster.cpp b/src/launcher/booster.cpp new file mode 100644 index 0000000..e3d7030 --- /dev/null +++ b/src/launcher/booster.cpp @@ -0,0 +1,221 @@ +/*************************************************************************** +** +** 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 "booster.h" +#include "connection.h" +#include "logger.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_CREDS + #include +#endif + +Booster::Booster() : + m_argvArraySize(0), + m_oldPriority(0), + m_oldPriorityOk(false) +{} + +Booster::~Booster() +{} + +bool Booster::preload() +{ + return true; +} + +bool Booster::readCommand() +{ + // Setup the conversation channel with the invoker. + Connection conn(socketId()); + + // Accept a new invocation. + if (conn.acceptConn()) + { + if (conn.receiveApplicationData(m_app)) + { + return true; + } + + // Close connection + conn.closeConn(); + } + + return false; +} + +void Booster::run() +{ + if (!m_app.fileName().empty()) + { + Logger::logInfo("invoking '%s' ", m_app.fileName().c_str()); + launchProcess(); + } + else + { + Logger::logError("nothing to invoke\n"); + } +} + +void Booster::renameProcess(int parentArgc, char** parentArgv) +{ + if (m_argvArraySize == 0) + { + // rename process for the first time + // calculate and store size of parentArgv array + + for (int i = 0; i < parentArgc; i++) + m_argvArraySize += strlen(parentArgv[i]) + 1; + + m_argvArraySize--; + } + + if (m_app.appName().empty()) + { + // application name isn't known yet, let's give to the process + // temporary booster name + + string newProcessName("booster-"); + newProcessName.append(1, boosterType()); + + m_app.setAppName(newProcessName); + } + + const char* newProcessName = m_app.appName().c_str(); + Logger::logNotice("set new name for process: %s", newProcessName); + + // This code copies all the new arguments to the space reserved + // in the old argv array. If an argument won't fit then the algorithm + // leaves it fully out and terminates. + + int spaceAvailable = m_argvArraySize; + if (spaceAvailable > 0) + { + memset(parentArgv[0], '\0', spaceAvailable); + strncat(parentArgv[0], newProcessName, spaceAvailable); + + spaceAvailable -= strlen(parentArgv[0]); + + for (int i = 1; i < m_app.argc(); i++) + { + if (spaceAvailable > static_cast(strlen(m_app.argv()[i])) + 1) + { + strncat(parentArgv[0], " ", 1); + strncat(parentArgv[0], m_app.argv()[i], spaceAvailable); + spaceAvailable -= strlen(m_app.argv()[i] + 1); + } + else + { + break; + } + } + } + + // Set the process name using prctl, killall and top use it + if ( prctl(PR_SET_NAME, basename(newProcessName)) == -1 ) + Logger::logError("on set new process name: %s ", strerror(errno)); + + setenv("_", newProcessName, true); +} + +void Booster::launchProcess() +{ + // Possibly restore process priority + errno = 0; + const int cur_prio = getpriority(PRIO_PROCESS, 0); + if (!errno && cur_prio < m_app.priority()) + setpriority(PRIO_PROCESS, 0, m_app.priority()); + + // Load the application and find out the address of main() + void* handle = loadMain(); + + for (unsigned int i = 0; i < m_app.ioDescriptors().size(); i++) + if (m_app.ioDescriptors()[i] > 0) + dup2(m_app.ioDescriptors()[i], i); + + Logger::logNotice("launching process: '%s' ", m_app.fileName().c_str()); + + // Close logger + Logger::closeLog(); + + // Jump to main() + const int retVal = m_app.entry()(m_app.argc(), const_cast(m_app.argv())); + m_app.deleteArgv(); + dlclose(handle); + exit(retVal); +} + +void* Booster::loadMain() +{ +#ifdef HAVE_CREDS + // Set application's platform security credentials + creds_confine(m_app.fileName().c_str()); +#endif + + // Load the application as a library + void * module = dlopen(m_app.fileName().c_str(), RTLD_LAZY | RTLD_GLOBAL); + + if (!module) + Logger::logErrorAndDie(EXIT_FAILURE, "loading invoked application: '%s'\n", dlerror()); + + // Find out the address for symbol "main". + dlerror(); + m_app.setEntry(reinterpret_cast(dlsym(module, "main"))); + + const char * error_s = dlerror(); + if (error_s != NULL) + Logger::logErrorAndDie(EXIT_FAILURE, "loading symbol 'main': '%s'\n", error_s); + + return module; +} + +bool Booster::pushPriority(int nice) +{ + errno = 0; + m_oldPriorityOk = true; + m_oldPriority = getpriority(PRIO_PROCESS, getpid()); + + if (errno) + { + m_oldPriorityOk = false; + } + else + { + return setpriority(PRIO_PROCESS, getpid(), nice) != -1; + } + + return false; +} + +bool Booster::popPriority() +{ + if (m_oldPriorityOk) + { + return setpriority(PRIO_PROCESS, getpid(), m_oldPriority) != -1; + } + + return false; +} diff --git a/src/launcher/booster.h b/src/launcher/booster.h new file mode 100644 index 0000000..2d50ebc --- /dev/null +++ b/src/launcher/booster.h @@ -0,0 +1,139 @@ +/*************************************************************************** +** +** 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 BOOSTER_H +#define BOOSTER_H + +#include +#include + +using std::string; + +#include "appdata.h" + +/*! + * \class Booster + * \brief Abstract base class for all boosters (Qt-booster, M-booster and so on..) + * + * Booster is a class that is used to initialize certain resources in libraries + * common to all applications of a type. + * + * Booster also communicates with the invoker process and handles the actual + * jump to the main() -method of the application to be launched. + * + * Booster instance dies with the launched application and a new one must be created + * in advance so as to launch a new application. + */ +class Booster +{ +public: + + //! Constructor + Booster(); + + //! Destructor + virtual ~Booster(); + + /*! + * \brief Run the application to be invoked. + * This method causes the application binary to be loaded + * using dlopen(). Program execution jumps to the address of + * "main()" found in the newly loaded library. The Booster process + * exits with corresponding exit-code after the execution of + * main() has finished. + */ + void run(); + + /*! + * \brief Wait for connection from invoker and read the input. + * This method accepts a socket connection from the invoker + * and reads the data of an application to be launched. + * + * \return true on success + */ + bool readCommand(); + + /*! + * \brief Initialize and preload stuff + * Override in the custom Booster. + */ + virtual bool preload(); + + /*! + * \brief Rename process. + * This method overrides the argument data starting from initialArgv[0]. + * This is needed so as to get the process name and arguments displayed + * correctly e.g. in the listing by 'ps'. initialArgv[1] may provide an + * empty dummy space to be used. It is assumed, that the arguments are + * located continuosly in memory and this is how it's done in glibc. + * + * \param initialArgc Number of the arguments of the launcher process. + * \param initialArgv Address of the argument array of the launcher process. + */ + void renameProcess(int initialArgc, char** initialArgv); + + /*! + * \brief Return booster type common to all instances. + * This is used in the simple communication between booster process. + * and the daemon. Override in the custom Booster. + * + * \return A (unique) character representing the type of the Booster. + */ + virtual char boosterType() const = 0; + + //! Set nice value and store the old priority. Return true on success. + bool pushPriority(int nice); + + //! Restore the old priority stored by the previous successful setPriority(). + bool popPriority(); + +protected: + + /*! + * \brief Return the communication socket used by a Booster. + * This method returns the socket used between invoker and the Booster. + * (common to all Boosters of the type). Override in the custom Booster. + * \return Path to the socket file + */ + virtual const string & socketId() const = 0; + +private: + + //! Disable copy-constructor + Booster(const Booster & r); + + //! Disable assignment operator + Booster & operator= (const Booster & r); + + + void complainAndExit(); + void launchProcess(); + void* loadMain(); + AppData m_app; + + int m_argvArraySize; + int m_oldPriority; + bool m_oldPriorityOk; + +#ifdef UNIT_TEST + friend class Ut_Booster; +#endif +}; + +#endif // BOOSTER_H diff --git a/src/launcher/connection.cpp b/src/launcher/connection.cpp new file mode 100644 index 0000000..ff296e4 --- /dev/null +++ b/src/launcher/connection.cpp @@ -0,0 +1,492 @@ +/*************************************************************************** +** +** 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 "connection.h" +#include "logger.h" + +#include +#include // For chmod +#include +#include +#include +#include + +#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION) + const char * Connection::m_credsStr = "applauncherd-launcher::access"; +#endif + +PoolType Connection::socketPool; + +Connection::Connection(const string socketId) : + m_fd(-1), + m_curSocket(findSocket(socketId)), + m_fileName(""), + m_argc(0), + m_argv(NULL), + m_priority(0) +{ + m_io[0] = -1; + m_io[1] = -1; + m_io[2] = -1; + + if (m_curSocket == -1) + { + Logger::logErrorAndDie(EXIT_FAILURE, "socket isn't initialized\n"); + } + +#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION) + + m_credsType = creds_str2creds(m_credsStr, &m_credsValue); + + if (m_credsType == CREDS_BAD) + { + Logger::logError("credentials %s conversion failed \n", m_credsStr); + } + +#endif +} + +Connection::~Connection() +{} + +int Connection::findSocket(const string socketId) +{ + PoolType::iterator it(socketPool.find(socketId)); + return it == socketPool.end() ? -1 : it->second; +} + +void Connection::initSocket(const string socketId) +{ + PoolType::iterator it(socketPool.find(socketId)); + if (it == socketPool.end()) + { + Logger::logInfo("%s: init socket '%s'", __FUNCTION__, socketId.c_str()); + + int sockfd = socket(PF_UNIX, SOCK_STREAM, 0); + if (sockfd < 0) + Logger::logErrorAndDie(EXIT_FAILURE, "opening invoker socket\n"); + + unlink(socketId.c_str()); + + struct sockaddr sun; + sun.sa_family = AF_UNIX; + int maxLen = sizeof(sun.sa_data) - 1; + strncpy(sun.sa_data, socketId.c_str(), maxLen); + sun.sa_data[maxLen] = '\0'; + + if (bind(sockfd, &sun, sizeof(sun)) < 0) + Logger::logErrorAndDie(EXIT_FAILURE, "binding to invoker socket\n"); + + if (listen(sockfd, 10) < 0) + Logger::logErrorAndDie(EXIT_FAILURE, "listening to invoker socket\n"); + + chmod(socketId.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | + S_IRGRP | S_IWGRP | S_IXGRP | + S_IROTH | S_IWOTH | S_IXOTH); + + socketPool[socketId] = sockfd; + } +} + +bool Connection::acceptConn() +{ + m_fd = accept(m_curSocket, NULL, NULL); + + if (m_fd < 0) + { + Logger::logError("accepting connections (%s)\n", strerror(errno)); + return false; + } + +#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION) + + creds_t ccreds = creds_getpeer(m_fd); + + int allow = creds_have_p(ccreds, m_credsType, m_credsValue); + + creds_free(ccreds); + + if (!allow) + { + Logger::logError("invoker doesn't have enough credentials to call launcher \n"); + + sendMsg(INVOKER_MSG_BAD_CREDS); + closeConn(); + return false; + } + +#endif + + return true; +} + +void Connection::closeConn() +{ + if (m_fd != -1) + { + close(m_fd); + m_fd = -1; + } +} + +bool Connection::sendMsg(uint32_t msg) +{ + Logger::logInfo("%s: %08x", __FUNCTION__, msg); + return write(m_fd, &msg, sizeof(msg)) != -1; +} + +bool Connection::recvMsg(uint32_t *msg) +{ + uint32_t buf = 0; + int len = sizeof(buf); + ssize_t ret = read(m_fd, &buf, len); + if (ret < len) { + Logger::logError("can't read data from connecton in %s", __FUNCTION__); + *msg = 0; + } else { + Logger::logInfo("%s: %08x", __FUNCTION__, *msg); + *msg = buf; + } + return ret != -1; +} + +bool Connection::sendStr(const char * str) +{ + // Send size. + uint32_t size = strlen(str) + 1; + sendMsg(size); + + Logger::logInfo("%s: '%s'", __FUNCTION__, str); + + // Send the string. + return write(m_fd, str, size) != -1; +} + +const char * Connection::recvStr() +{ + // Get the size. + uint32_t size = 0; + + const uint32_t STR_LEN_MAX = 4096; + bool res = recvMsg(&size); + if (!res || size == 0 || size > STR_LEN_MAX) + { + Logger::logError("string receiving failed in %s, string length is %d", __FUNCTION__, size); + return NULL; + } + + char * str = new char[size]; + if (!str) + { + Logger::logError("mallocing in %s", __FUNCTION__); + return NULL; + } + + // Get the string. + uint32_t ret = read(m_fd, str, size); + if (ret < size) + { + Logger::logError("getting string, got %u of %u bytes", ret, size); + delete [] str; + return NULL; + } + str[size - 1] = '\0'; + Logger::logInfo("%s: '%s'", __FUNCTION__, str); + return str; +} + +int Connection::receiveMagic() +{ + uint32_t magic = 0; + + // Receive the magic. + recvMsg(&magic); + + if ((magic & INVOKER_MSG_MASK) == INVOKER_MSG_MAGIC) + { + if ((magic & INVOKER_MSG_MAGIC_VERSION_MASK) == INVOKER_MSG_MAGIC_VERSION) + sendMsg(INVOKER_MSG_ACK); + else + { + Logger::logError("receiving bad magic version (%08x)\n", magic); + return -1; + } + } + return magic & INVOKER_MSG_MAGIC_OPTION_MASK; +} + +string Connection::receiveAppName() +{ + uint32_t msg = 0; + + // Get the action. + recvMsg(&msg); + if (msg != INVOKER_MSG_NAME) + { + Logger::logError("receiving invalid action (%08x)", msg); + return string(); + } + + const char* name = recvStr(); + if (!name) + { + Logger::logError("receiving application name"); + return string(); + } + sendMsg(INVOKER_MSG_ACK); + + string appName(name); + delete [] name; + return appName; +} + +bool Connection::receiveExec() +{ + const char* filename = recvStr(); + if (!filename) + return false; + + sendMsg(INVOKER_MSG_ACK); + + m_fileName = filename; + delete [] filename; + return true; +} + +bool Connection::receivePriority() +{ + recvMsg(&m_priority); + sendMsg(INVOKER_MSG_ACK); + + return true; +} + +bool Connection::receiveArgs() +{ + // Get argc + recvMsg(&m_argc); + const uint32_t ARG_MAX = 1024; + if (m_argc > 0 && m_argc < ARG_MAX) + { + // Reserve memory for argv + m_argv = new const char * [m_argc]; + if (!m_argv) + { + Logger::logError("reserving memory for argv"); + return false; + } + + // Get argv + for (uint i = 0; i < m_argc; i++) + { + m_argv[i] = recvStr(); + if (!m_argv[i]) + { + Logger::logError("receiving argv[%i]", i); + return false; + } + } + } + else + { + Logger::logError("invalid number of parameters %d", m_argc); + return false; + } + + sendMsg(INVOKER_MSG_ACK); + return true; +} + +// coverity[ +tainted_string_sanitize_content : arg-0 ] +bool putenv_sanitize(const char * s) +{ + return static_cast(strchr(s, '=')); +} + +// coverity[ +free : arg-0 ] +int putenv_wrapper(char * var) +{ + return putenv(var); +} + +bool Connection::receiveEnv() +{ + // Have some "reasonable" limit for environment variables to protect from + // malicious data + const uint32_t MAX_VARS = 1024; + + // Get number of environment variables. + uint32_t n_vars = 0; + recvMsg(&n_vars); + if (n_vars > 0 && n_vars < MAX_VARS) + { + // Get environment variables + for (uint32_t i = 0; i < n_vars; i++) + { + const char * var = recvStr(); + if (var == NULL) + { + Logger::logError("receiving environ[%i]", i); + return false; + } + + // In case of error, just warn and try to continue, as the other side is + // going to keep sending the reset of the message. + // String pointed to by var shall become part of the environment, so altering + // the string shall change the environment, don't free it + if (putenv_sanitize(var)) + { + if (putenv_wrapper(const_cast(var)) != 0) + { + Logger::logWarning("putenv failed"); + } + } + else + { + delete [] var; + var = NULL; + Logger::logWarning("invalid environment data"); + } + } + } + else + { + Logger::logError("invalid environment variable count %d", n_vars); + return false; + } + + return true; +} + +bool Connection::receiveIO() +{ + int dummy = 0; + + struct iovec iov; + iov.iov_base = &dummy; + iov.iov_len = 1; + + char buf[CMSG_SPACE(sizeof(m_io))]; + + struct msghdr msg; + memset(&msg, 0, sizeof(msg)); + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + msg.msg_control = buf; + msg.msg_controllen = sizeof(buf); + + struct cmsghdr *cmsg; + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(m_io)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + + memcpy(CMSG_DATA(cmsg), m_io, sizeof(m_io)); + + if (recvmsg(m_fd, &msg, 0) < 0) + { + Logger::logWarning("recvmsg failed in invoked_get_io: %s", strerror(errno)); + return false; + } + + if (msg.msg_flags) + { + Logger::logWarning("unexpected msg flags in invoked_get_io"); + return false; + } + + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg == NULL || cmsg->cmsg_len != CMSG_LEN(sizeof(m_io)) || + cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) + { + Logger::logWarning("invalid cmsg in invoked_get_io"); + return false; + } + + memcpy(m_io, CMSG_DATA(cmsg), sizeof(m_io)); + + return true; +} + +bool Connection::receiveActions() +{ + Logger::logInfo("enter: %s", __FUNCTION__); + + while (1) + { + uint32_t action = 0; + + // Get the action. + recvMsg(&action); + + switch (action) + { + case INVOKER_MSG_EXEC: + receiveExec(); + break; + case INVOKER_MSG_ARGS: + receiveArgs(); + break; + case INVOKER_MSG_ENV: + receiveEnv(); + break; + case INVOKER_MSG_PRIO: + receivePriority(); + break; + case INVOKER_MSG_IO: + receiveIO(); + break; + case INVOKER_MSG_END: + sendMsg(INVOKER_MSG_ACK); + return true; + default: + Logger::logError("receiving invalid action (%08x)\n", action); + return false; + } + } +} + +bool Connection::receiveApplicationData(AppData & rApp) +{ + // Read magic number + rApp.setOptions(receiveMagic()); + if (rApp.options() == -1) + return false; + + // Read application name + rApp.setAppName(receiveAppName()); + if (rApp.appName().empty()) + return false; + + // Read application parameters + if (receiveActions()) + { + rApp.setFileName(m_fileName); + rApp.setPriority(m_priority); + rApp.setArgc(m_argc); + rApp.setArgv(m_argv); + rApp.setIODescriptors(vector(m_io, m_io + sizeof(m_io))); + } + else + { + return false; + } + + return true; +} diff --git a/src/launcher/connection.h b/src/launcher/connection.h new file mode 100644 index 0000000..6b68fc4 --- /dev/null +++ b/src/launcher/connection.h @@ -0,0 +1,161 @@ +/*************************************************************************** +** +** 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 CONNECTION_H +#define CONNECTION_H + +#include "appdata.h" +#include "protocol.h" + +#include +#include + +using std::string; + +#include + +using std::map; + +#include + +using std::vector; + +typedef map PoolType; + +#ifdef HAVE_CREDS + #include +#endif + + +/*! + * \class Connection. + * \brief Wrapper class for the connection between invoker and launcher. + * + * This class wraps up the UNIX file socket connection between the invoker + * and the launcher daemon. + */ +class Connection +{ +public: + + /*! \brief Constructor. + * \param socketId Path to the UNIX file socket to be used. + */ + explicit Connection(const string socketId); + + //! \brief Destructor + virtual ~Connection(); + + /*! \brief Accept connection. + * Accept a socket connection from the invoker. + * \return true on success. + */ + bool acceptConn(); + + //! \brief Close the socket connection. + void closeConn(); + + //! \brief Receive application data to rApp. + bool receiveApplicationData(AppData & rApp); + + /*! \brief Initialize a file socket. + * \param socketId Path to the socket file + */ + static void initSocket(const string socketId); + +private: + + /*! \brief Receive actions. + * This method executes the actual data-receiving loop and terminates + * after INVOKER_MSG_END is received. + * \return True on success + */ + bool receiveActions(); + + /*! \brief Receive and return the magic number. + * \return The magic number received from the invoker. + */ + int receiveMagic(); + + /*! \brief Receive and return the application name. + * \return Name string + */ + string receiveAppName(); + + /*! \brief Return initialized socket. + * \param socketId Path to the socket file + */ + static int findSocket(const string socketId); + + //! Disable copy-constructor + Connection(const Connection & r); + + //! Disable assignment operator + Connection & operator= (const Connection & r); + + //! Receive executable name + bool receiveExec(); + + //! Receive arguments + bool receiveArgs(); + + //! Receive environment + bool receiveEnv(); + + //! Receive I/O descriptors + bool receiveIO(); + + //! Receive priority + bool receivePriority(); + + //! Send message to a socket. This is a virtual to help unit testing. + virtual bool sendMsg(uint32_t msg); + + //! Receive a message from a socket. This is a virtual to help unit testing. + virtual bool recvMsg(uint32_t *msg); + + //! Send a string. This is a virtual to help unit testing. + virtual bool sendStr(const char * str); + //! Receive a string. This is a virtual to help unit testing. + virtual const char * recvStr(); + + //! Pool of sockets mapped to id's + static PoolType socketPool; + + //! Socket fd + int m_fd; + int m_curSocket; + string m_fileName; + uint32_t m_argc; + const char ** m_argv; + int m_io[3]; + uint32_t m_priority; + +#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION) + static const char * m_credsStr; + creds_value_t m_credsValue; + creds_type_t m_credsType; +#endif + +#ifdef UNIT_TEST + friend class Ut_Connection; +#endif +}; + +#endif //CONNECTION_H diff --git a/src/launcher/daemon.cpp b/src/launcher/daemon.cpp new file mode 100644 index 0000000..a487f20 --- /dev/null +++ b/src/launcher/daemon.cpp @@ -0,0 +1,395 @@ +/*************************************************************************** +** +** 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 "daemon.h" +#include "logger.h" +#include "connection.h" +#include "booster.h" +#include "mbooster.h" +#include "qtbooster.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +Daemon * Daemon::m_instance = NULL; +int Daemon::m_lockFd = -1; + +Daemon::Daemon(int & argc, char * argv[]) : + m_testMode(false), + m_daemon(false), + m_quiet(false) +{ + if (!Daemon::m_instance) + { + Daemon::m_instance = this; + } + else + { + std::cerr << "Daemon already created!" << std::endl; + exit(EXIT_FAILURE); + } + + // Parse arguments + parseArgs(ArgVect(argv, argv + argc)); + + // Disable console output + if (m_quiet) + consoleQuiet(); + + // Store arguments list + m_initialArgv = argv; + m_initialArgc = argc; + + // Daemonize if desired + if (m_daemon) + { + daemonize(); + } +} + +void Daemon::consoleQuiet() +{ + close(0); + close(1); + close(2); + + if (open("/dev/null", O_RDONLY) < 0) + Logger::logErrorAndDie(EXIT_FAILURE, "opening /dev/null readonly"); + + int fd = open("/dev/null", O_WRONLY); + if ((fd == -1) || (dup(fd) < 0)) + Logger::logErrorAndDie(EXIT_FAILURE, "opening /dev/null writeonly"); +} + +Daemon * Daemon::instance() +{ + return Daemon::m_instance; +} + +Daemon::~Daemon() +{} + +bool Daemon::lock(void) +{ + struct flock fl; + + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 1; + + if((m_lockFd = open("/tmp/applauncherd.lock", O_WRONLY | O_CREAT, 0666)) == -1) + return false; + + if(fcntl(m_lockFd, F_SETLK, &fl) == -1) + return false; + + return true; +} + +void Daemon::unlock(void) +{ + if (m_lockFd != -1) + { + close(m_lockFd); + m_lockFd = -1; + } +} + +void Daemon::run() +{ + // Make sure that LD_BIND_NOW does not prevent dynamic linker to + // use lazy binding in later dlopen() calls. + unsetenv("LD_BIND_NOW"); + + // create sockets for each of the boosters + Connection::initSocket(MBooster::socketName()); + Connection::initSocket(QtBooster::socketName()); + + // Pipe used to tell the parent that a new + // booster is needed + int pipefd[2]; + if (pipe(pipefd) == -1) + { + Logger::logErrorAndDie(EXIT_FAILURE, "Creating a pipe failed!!!\n"); + } + + forkBooster(MBooster::type(), pipefd); + forkBooster(QtBooster::type(), pipefd); + + while (true) + { + // Wait for something appearing in the pipe + char msg; + ssize_t count = read(pipefd[0], reinterpret_cast(&msg), 1); + if (count) + { + // Guarantee some time for the just launched application to + // start up before forking new booster. Not doing this would + // slow down the start-up significantly on single core CPUs. + sleep(2); + + // Fork a new booster of the given type + forkBooster(msg, pipefd); + } + else + { + Logger::logWarning("Nothing read from the pipe\n"); + } + } +} + +bool Daemon::forkBooster(char type, int pipefd[2]) +{ + // Fork a new process + pid_t newPid = fork(); + + if (newPid == -1) + Logger::logErrorAndDie(EXIT_FAILURE, "Forking while invoking"); + + if (newPid == 0) /* Child process */ + { + // Reset used signal handlers + signal(SIGCHLD, SIG_DFL); + + // Will get this signal if applauncherd dies + prctl(PR_SET_PDEATHSIG, SIGHUP); + + // Close unused read end + close(pipefd[0]); + + // close lock file, it's not needed in the booster + Daemon::unlock(); + + if (setsid() < 0) + { + Logger::logError("Setting session id\n"); + } + + Logger::logNotice("Running a new Booster of %c type...", type); + + // Create a new booster and initialize it + Booster * booster = NULL; + if (MBooster::type() == type) + { + booster = new MBooster(); + } + else if (QtBooster::type() == type) + { + booster = new QtBooster(); + } + else + { + Logger::logErrorAndDie(EXIT_FAILURE, "Unknown booster type \n"); + } + + // Drop priority (nice = 10) + booster->pushPriority(10); + + // Preload stuff + booster->preload(); + + // Clean-up all the env variables + clearenv(); + + // Rename launcher process to booster + booster->renameProcess(m_initialArgc, m_initialArgv); + + // Restore priority + booster->popPriority(); + + // Wait and read commands from the invoker + Logger::logNotice("Wait for message from invoker"); + booster->readCommand(); + + // Give to the process an application specific name + booster->renameProcess(m_initialArgc, m_initialArgv); + + // Signal the parent process that it can create a new + // waiting booster process and close write end + const char msg = booster->boosterType(); + ssize_t ret = write(pipefd[1], reinterpret_cast(&msg), 1); + if (ret == -1) { + Logger::logError("Can't send signal to launcher process' \n"); + } + + close(pipefd[1]); + + // Don't care about fate of parent applauncherd process any more + prctl(PR_SET_PDEATHSIG, 0); + + // Run the current Booster + booster->run(); + + // Finish + delete booster; + exit(EXIT_SUCCESS); + } + else /* Parent process */ + { + // Store the pid so that we can reap it later + m_children.push_back(newPid); + } + + return true; +} + +void Daemon::reapZombies() +{ + PidVect::iterator i(m_children.begin()); + while (i != m_children.end()) + { + if (waitpid(*i, NULL, WNOHANG)) + { + i = m_children.erase(i); + } + else + { + i++; + } + } +} + +void Daemon::daemonize() +{ + // Our process ID and Session ID + pid_t pid, sid; + + // Fork off the parent process: first fork + pid = fork(); + if (pid < 0) + { + Logger::logError("Unable to fork daemon, code %d (%s)", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + // If we got a good PID, then we can exit the parent process. + if (pid > 0) + { + exit(EXIT_SUCCESS); + } + + // Fork off the parent process: second fork + pid = fork(); + if (pid < 0) + { + Logger::logError("Unable to fork daemon, code %d (%s)", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + // If we got a good PID, then we can exit the parent process. + if (pid > 0) + { + exit(EXIT_SUCCESS); + } + + // Change the file mode mask + umask(0); + + // Open any logs here + + // Create a new SID for the child process + sid = setsid(); + if (sid < 0) + { + Logger::logError("Unable to create a new session, code %d (%s)", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + // Change the current working directory + if ((chdir("/")) < 0) + { + Logger::logError("Unable to change directory to %s, code %d (%s)", "/", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + // Open file descriptors pointing to /dev/null + // Redirect standard file descriptors to /dev/null + // Close new file descriptors + + const int new_stdin = open("/dev/null", O_RDONLY); + if (new_stdin != -1) { + dup2(new_stdin, STDIN_FILENO); + close(new_stdin); + } + + const int new_stdout = open("/dev/null", O_WRONLY); + if (new_stdout != -1) { + dup2(new_stdout, STDOUT_FILENO); + close(new_stdout); + } + + const int new_stderr = open("/dev/null", O_WRONLY); + if (new_stderr != -1) { + dup2(new_stderr, STDERR_FILENO); + close(new_stderr); + } +} + +void Daemon::usage() const +{ + std::cout << "Usage: "<< PROG_NAME << " [options]\n" + << "\n" + << "Options:\n" + << " --daemon Fork and go into the background.\n" + //<< " --pidfile FILE Specify a different pid file (default " << LAUNCHER_PIDFILE << " ).\n" + //<< " --send-app-died Send application died signal.\n" + << " --quiet Do not print anything.\n" + << " --help Print this help message.\n" + << "\n" + << "Use the invoker to start a from the launcher.\n" + << "Where is a binary including a 'main' symbol.\n" + << "Note that the binary needs to be linked with -shared or -pie.\n"; + + exit(EXIT_SUCCESS); +} + +void Daemon::parseArgs(const ArgVect & args) +{ + for (ArgVect::const_iterator i(args.begin()); i != args.end(); i++) + { + if ((*i) == "--help") + { + usage(); + } + else if ((*i) == "--daemon") + { + m_daemon = true; + } + else if ((*i) == "--quiet") + { + m_quiet = true; + } + else if ((*i) == "--test") + { + m_testMode = true; + } + } +} diff --git a/src/launcher/daemon.h b/src/launcher/daemon.h new file mode 100644 index 0000000..8487bf2 --- /dev/null +++ b/src/launcher/daemon.h @@ -0,0 +1,128 @@ +/*************************************************************************** +** +** 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 DAEMON_H +#define DAEMON_H + +#include +#include +#include + +using std::vector; +using std::string; + +/*! + * \class Daemon. + * \brief Daemon wraps up the daemonizing functionality. + * + * Daemon wraps up the daemonizing functionality and is the + * main object of the launcher program. It runs the main loop of the + * application, listens connections from the invoker and forks Booster + * processes. + */ +class Daemon +{ +public: + + /*! + * \brief Constructor + * \param argc Argument count delivered to main() + * \param argv Argument array delivered to main() + * + * Supported arguments: + * --daemon == daemonize + * --quiet == quiet + * --help == print usage + */ + Daemon(int & argc, char * argv[]); + + /*! + * \brief Destructor + */ + virtual ~Daemon(); + + /*! + * \brief Run main loop and fork Boosters. + */ + void run(); + + /*! \brief Return the one-and-only Daemon instance. + * \return Pointer to the Daemon instance. + */ + static Daemon * instance(); + + //! \brief Reapes children processes gone zombies (finished Boosters). + void reapZombies(); + + //! Lock file to prevent launch of second instance + static bool lock(void); + + //! Unlock file (lock is not needed in boosters) + static void unlock(void); + +private: + + //! Disable copy-constructor + Daemon(const Daemon & r); + + //! Disable assignment operator + Daemon & operator= (const Daemon & r); + + //! Parse arguments + typedef vector ArgVect; + void parseArgs(const ArgVect & args); + + //! Fork to a daemon + void daemonize(); + + //! Print usage + void usage() const; + + //! Forks and initializes a new Booster + bool forkBooster(char type, int pipefd[2]); + + //! Don't use console for output + void consoleQuiet(); + + //! Test mode flag + bool m_testMode; + + //! Daemonize flag + bool m_daemon; + + //! Debug print flag + bool m_quiet; + + //! Vector of current child PID's + typedef vector PidVect; + PidVect m_children; + + int m_initialArgc; + char** m_initialArgv; + + static Daemon * m_instance; + + static int m_lockFd; + +#ifdef UNIT_TEST + friend class Ut_Daemon; +#endif +}; + +#endif // DAEMON_H diff --git a/src/launcher/logger.cpp b/src/launcher/logger.cpp new file mode 100644 index 0000000..7067ac1 --- /dev/null +++ b/src/launcher/logger.cpp @@ -0,0 +1,212 @@ +/*************************************************************************** +** +** 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 "logger.h" +#include +#include +#include +#include +#include +#include + +namespace { + const QString logDirectory("/var/log"); + const QString logFileName(logDirectory + "/launcher.log"); + const QString oldLogFileName(logDirectory + "/launcher.log.old"); + const QString dateFormat("yyyy-MM-dd hh:mm:ss.zzz"); +} + +bool Logger::m_isOpened = false; +QTextStream Logger::m_logStream; +QFile Logger::m_logFile; +bool Logger::m_useSyslog = false; +bool Logger::m_echoMode = false; + +void Logger::openLog(const char * progName) +{ + if (!Logger::m_isOpened) + { + // Check if it's possible to write under /var/log + // Should make it possible to get the logs in the enviroments + // with and without syslog. + QDir logDir; + if (logDir.exists(logDirectory)) { + // Directory exists, is it possible to create a file in it? + m_logFile.setFileName(oldLogFileName); + if (m_logFile.open(QIODevice::WriteOnly)) { + m_logFile.close(); + m_logFile.remove(); + } + else { + // It is not possible to write to file. Use syslog + m_useSyslog = true; + } + } + else { + // Directory does not exist. Is it possible to create it? + if (logDir.mkdir(logDirectory) == false) { + // Not possible to create directory. Use syslog. + m_useSyslog = true; + } + } + + // Initialize the logging interface + if (m_useSyslog == false) { + // Remove the oldest log file + m_logFile.setFileName(oldLogFileName); + m_logFile.remove(); + // Copy latest log file to applifed.log.old + m_logFile.setFileName(logFileName); + m_logFile.rename(oldLogFileName); + // Open current log file + m_logFile.setFileName(logFileName); + + if (m_logFile.open(QIODevice::WriteOnly)) { + Logger::m_logStream.setDevice(&m_logFile); + } + else { + m_useSyslog = true; + } + } + + if (m_useSyslog) { + openlog(progName, LOG_PID, LOG_DAEMON); + } + + Logger::m_isOpened = true; + } +} + +void Logger::closeLog() +{ + if (Logger::m_isOpened) { + if (m_useSyslog) { + closelog(); + } + else { + m_logFile.close(); + } + Logger::m_isOpened = false; + } +} + +void Logger::writeLog(const int priority, const char * format, va_list ap) +{ + if (Logger::m_isOpened) { + if (m_echoMode) { + vprintf(format, ap); + printf("\n"); + } + + if (m_useSyslog) { + vsyslog(priority, format, ap); + } + else { + QString msg; + msg.vsprintf(format, ap); + m_logStream << + QDateTime::currentDateTime().toString(dateFormat); + + switch (priority) { + case LOG_NOTICE: + m_logStream << " [NOTICE] "; + break; + case LOG_ERR: + m_logStream << " [ERROR] "; + break; + case LOG_WARNING: + m_logStream << " [WARNING] "; + break; + case LOG_INFO: + m_logStream << " [INFO] "; + break; + default: + m_logStream << " [N/A] "; + break; + } + + m_logStream << msg << "\n"; + m_logStream.flush(); + } + } +} + + +void Logger::logNotice(const char * format, ...) +{ +#ifdef _DEBUG + + va_list(ap); + va_start(ap, format); + writeLog(LOG_NOTICE, format, ap); + va_end(ap); +#else + Q_UNUSED(format); +#endif +} + +void Logger::logWarning(const char * format, ...) +{ +#ifdef _DEBUG + + va_list(ap); + va_start(ap, format); + writeLog(LOG_WARNING, format, ap); + va_end(ap); +#else + Q_UNUSED(format); +#endif +} + +void Logger::logInfo(const char * format, ...) +{ +#ifdef _DEBUG + + va_list(ap); + va_start(ap, format); + writeLog(LOG_INFO, format, ap); + va_end(ap); +#else + Q_UNUSED(format); +#endif +} + +void Logger::logError(const char * format, ...) +{ + va_list(ap); + va_start(ap, format); + writeLog(LOG_ERR, format, ap); + va_end(ap); +} + +void Logger::logErrorAndDie(int code, const char * format, ...) +{ + va_list(ap); + va_start(ap, format); + writeLog(LOG_ERR, format, ap); + va_end(ap); + + exit(code); +} + +void Logger::setEchoMode(bool enable) +{ + Logger::m_echoMode = enable; +} + diff --git a/src/launcher/logger.h b/src/launcher/logger.h new file mode 100644 index 0000000..45df103 --- /dev/null +++ b/src/launcher/logger.h @@ -0,0 +1,119 @@ +/*************************************************************************** +** +** 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 LOGGER_H +#define LOGGER_H + +#include +#include +#include + +/*! + * \class Logger + * \brief Logging utility class + * + */ +class Logger +{ +public: + + /*! + * \brief Open the log + * \param progName Program name as it will be seen in the log. + */ + static void openLog(const char * progName); + + /*! + * \brief Close the log + */ + static void closeLog(); + + + /*! + * \brief Log a notice to the system message logger + * \param format String identical to a printf format string + * \param additionalArgs Depending on the format string, the function may expect a + * sequence of additional arguments, each containing one value to be inserted + * in the format parameter, if any. + */ + static void logNotice(const char * format, ...); + + + /*! + * \brief Log an error to the system message logger + * \param format String identical to a printf format string + * \param additionalArgs Depending on the format string, the function may expect a + * sequence of additional arguments, each containing one value to be inserted + * in the format parameter, if any. + */ + static void logError(const char * format, ...); + + + /*! + * \brief Log a warning to the system message logger + * \param format String identical to a printf format string + * \param additionalArgs Depending on the format string, the function may expect a + * sequence of additional arguments, each containing one value to be inserted + * in the format parameter, if any. + */ + static void logWarning(const char * format, ...); + + + /*! + * \brief Log a piece of information to the system message logger + * \param format String identical to a printf format string + * \param additionalArgs Depending on the format string, the function may expect a + * sequence of additional arguments, each containing one value to be inserted + * in the format parameter, if any. + */ + static void logInfo(const char * format, ...); + + /*! + * \brief Log an error to the system message logger and exit + * \param format String identical to a printf format string + * \param additionalArgs Depending on the format string, the function may expect a + * sequence of additional arguments, each containing one value to be inserted + * in the format parameter, if any. + */ + static void logErrorAndDie(int code, const char * format, ...); + + + /*! + * \brief Forces Logger to echo everything to stdout if set to true. + */ + static void setEchoMode(bool enable); + +private: + + static void writeLog(const int priority, const char * format, va_list ap); + //! True if the log is open + static bool m_isOpened; + //! Log file which is used if the syslog is not available + //static QFile m_logFile; + static QFile m_logFile; + //! Text stream for log file + static QTextStream m_logStream; + //! True if the syslog is available + static bool m_useSyslog; + //! Echo everything to stdout if true + static bool m_echoMode; +}; + +#endif // LOGGER_H + diff --git a/src/launcher/main.cpp b/src/launcher/main.cpp new file mode 100644 index 0000000..147d8b0 --- /dev/null +++ b/src/launcher/main.cpp @@ -0,0 +1,75 @@ +/*************************************************************************** +** +** 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 "daemon.h" +#include "logger.h" + +#include +#include +#include +#include + +//! Signal handler to reap zombies +void reapZombies(int) +{ + if (Daemon::instance()) + Daemon::instance()->reapZombies(); +} + +//! Signal handler to kill booster +void exitBooster(int) +{ + Logger::logErrorAndDie(EXIT_FAILURE, "due to parent process applauncherd died, booster exit too"); +} + +void exitLauncher(int) +{ + exit(0); +} + +//! Main function +int main(int argc, char * argv[]) +{ + // Open the log + Logger::openLog(PROG_NAME); + Logger::logNotice("%s starting..", PROG_NAME); + + // Check that an instance of launcher is not already running + if(!Daemon::lock()) + { + Logger::logErrorAndDie(EXIT_FAILURE, "try to launch second instance"); + } + + // Install signal handlers + signal(SIGCHLD, reapZombies); + signal(SIGHUP, exitBooster); + signal(SIGTERM, exitLauncher); + + // Create main daemon instance + Daemon myDaemon(argc, argv); + + // Run the main loop + myDaemon.run(); + + // Close the log + Logger::closeLog(); + + return EXIT_SUCCESS; +} + diff --git a/src/launcher/mbooster.cpp b/src/launcher/mbooster.cpp new file mode 100644 index 0000000..e15397e --- /dev/null +++ b/src/launcher/mbooster.cpp @@ -0,0 +1,57 @@ +/*************************************************************************** +** +** 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 "mbooster.h" + +#ifdef HAVE_MCOMPONENTCACHE +#include +#endif + +const string MBooster::m_socketId = "/tmp/mlnchr"; + +MBooster::MBooster() +{ +} + +MBooster::~MBooster() +{ +} + +const string & MBooster::socketId() const +{ + return m_socketId; +} + +bool MBooster::preload() +{ +#ifdef HAVE_MCOMPONENTCACHE + MComponentCache::populateForMApplication(); +#endif + return true; +} + +const string & MBooster::socketName() +{ + return m_socketId; +} + +char MBooster::type() +{ + return 'm'; +} diff --git a/src/launcher/mbooster.h b/src/launcher/mbooster.h new file mode 100644 index 0000000..18322d2 --- /dev/null +++ b/src/launcher/mbooster.h @@ -0,0 +1,82 @@ +/*************************************************************************** +** +** 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 MBOOSTER_H +#define MBOOSTER_H + +#include "booster.h" + +/*! + \class MBooster + \brief MeeGo Touch -specific version of the Booster. + + MBooster effectively fills MComponentCache with fresh objects. + MeeGo Touch applications can then try to use already initialized objects + from MComponentCache. This can significantly reduce the startup time of a + MeeGo Touch application. + */ +class MBooster : public Booster +{ +public: + + //! \brief Constructor + MBooster(); + + //! \brief Destructor + virtual ~MBooster(); + + //! \reimp + virtual bool preload(); + + /*! + * \brief Return the socket name common to all MBooster objects. + * \return Path to the socket file. + */ + static const string & socketName(); + + //! \reimp + virtual char boosterType() const { return type(); } + + /*! + * \brief Return a unique character ('d') represtenting the type of MBoosters. + * \return Type character. + */ + static char type(); + +protected: + + //! \reimp + virtual const string & socketId() const; + +private: + + //! Disable copy-constructor + MBooster(const MBooster & r); + + //! Disable assignment operator + MBooster & operator= (const MBooster & r); + + static const string m_socketId; + +#ifdef UNIT_TEST + friend class Ut_MBooster; +#endif +}; + +#endif // MBOOSTER_H diff --git a/src/launcher/qtbooster.cpp b/src/launcher/qtbooster.cpp new file mode 100644 index 0000000..24c5e36 --- /dev/null +++ b/src/launcher/qtbooster.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** +** +** 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 "qtbooster.h" + +const string QtBooster::m_socketId = "/tmp/qtlnchr"; + +QtBooster::QtBooster() +{ +} + +QtBooster::~QtBooster() +{ +} + +const string & QtBooster::socketId() const +{ + return m_socketId; +} + +const string & QtBooster::socketName() +{ + return m_socketId; +} + +char QtBooster::type() +{ + return 'q'; +} + +bool QtBooster::preload() +{ + return true; +} diff --git a/src/launcher/qtbooster.h b/src/launcher/qtbooster.h new file mode 100644 index 0000000..864de2d --- /dev/null +++ b/src/launcher/qtbooster.h @@ -0,0 +1,77 @@ +/*************************************************************************** +** +** 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 QTBOOSTER_H +#define QTBOOSTER_H + +#include "booster.h" + +/*! + * \class QtBooster. + * \brief Qt-specific version of the Booster. + */ +class QtBooster : public Booster +{ +public: + + //! Constructor. + QtBooster(); + + //! Destructor. + virtual ~QtBooster(); + + /*! + * \brief Return the socket name common to all QtBooster objects. + * \return Path to the socket file. + */ + static const string & socketName(); + + //! \reimp + virtual char boosterType() const { return type(); } + + /*! + * \brief Return a unique character ('q') represtenting the type of QtBoosters. + * \return Type character. + */ + static char type(); + + //! \reimp + virtual bool preload(); + +protected: + + //! \reimp + virtual const string & socketId() const; + +private: + + //! Disable copy-constructor + QtBooster(const QtBooster & r); + + //! Disable assignment operator + QtBooster & operator= (const QtBooster & r); + + static const string m_socketId; + +#ifdef UNIT_TEST + friend class Ut_QtBooster; +#endif +}; + +#endif //QTBOOSTER_H diff --git a/src/launcher/scripts/applauncherd b/src/launcher/scripts/applauncherd new file mode 100755 index 0000000..67c1e95 --- /dev/null +++ b/src/launcher/scripts/applauncherd @@ -0,0 +1,15 @@ +#!/bin/sh + +# Forces resolving symbols of libraries to which applauncherd.bin is +# linked to. + +# commented out because of broken libamjpeg library +# export LD_BIND_NOW=1 + +# Use 50 chars long dummy parameter to reserve place for application +# name and parameters so that we get some space to modify them +# afterwards. If the length of the application name with parameters is +# longer than space available, only the params that fully fit will be +# shown in the output of top and ps commands. +exec /usr/bin/applauncherd.bin " " + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..25dc840 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,45 @@ +# Find libmeegotouch for the test programs +include(FindPkgConfig) +pkg_check_modules(MEEGOTOUCH meegotouch>=0.20 REQUIRED) +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${MEEGOTOUCH_INCLUDE_DIRS}) + +# Check if it's possible to compile MBooster with MComponentCache. If so, +# HAVE_MCOMPONENTCACHE is set. +message(STATUS "checking for mcomponentcache.h") +find_file(M_COMPONENT_CACHE NAMES mcomponentcache.h PATHS ${MEEGOTOUCH_INCLUDE_DIRS}) +if (EXISTS ${M_COMPONENT_CACHE}) + message(STATUS " found") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_MCOMPONENTCACHE") +else (EXISTS ${M_COMPONENT_CACHE}) + message(STATUS " not found") +endif (EXISTS ${M_COMPONENT_CACHE}) + +# Sub build: helloworld +add_subdirectory(TestApps/helloworld) + +# Sub build: unit tests +add_subdirectory(unittests) + +# Sub build: perftests +add_subdirectory(perftests) + +# Sub build: functests +add_subdirectory(functests) + +# Sub build: art-tests +add_subdirectory(art-tests) + +# Sub build: bug-tests +add_subdirectory(bug-tests) + +# Sub build: TestScripts +add_subdirectory(TestScripts) + +# Sub build: TestApps +add_subdirectory(TestApps/creds) + +# Sub build: TestApps +add_subdirectory(TestApps/testapp) + +# Sub build: TestApps +add_subdirectory(TestApps/themetest) diff --git a/tests/TestApps/creds/CMakeLists.txt b/tests/TestApps/creds/CMakeLists.txt new file mode 100644 index 0000000..1cc84bc --- /dev/null +++ b/tests/TestApps/creds/CMakeLists.txt @@ -0,0 +1,15 @@ +set(SRC creds_test.cpp) + +link_libraries(${MEEGOTOUCH_LIBRARIES}) + +include(${QT_USE_FILE}) +add_library(creds_test MODULE ${SRC}) + +# max creds +install(PROGRAMS libcreds_test.so DESTINATION /usr/bin RENAME fala_ft_creds1.launch) +install(PROGRAMS fala_ft_creds DESTINATION /usr/bin RENAME fala_ft_creds1) + +# "normal" creds +install(PROGRAMS libcreds_test.so DESTINATION /usr/bin RENAME fala_ft_creds2.launch) +install(PROGRAMS fala_ft_creds DESTINATION /usr/bin RENAME fala_ft_creds2) + diff --git a/tests/TestApps/creds/creds_test.cpp b/tests/TestApps/creds/creds_test.cpp new file mode 100644 index 0000000..cd41924 --- /dev/null +++ b/tests/TestApps/creds/creds_test.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** +** +** 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 +#include +#include +#include +#include +#include + +#ifdef HAVE_MCOMPONENTCACHE +#include +#endif + +#ifdef HAVE_CREDS +#include +#include + +/** + * Returns a QStringList filled with credentials the + * application currently has. + */ +QStringList credentials() +{ + QStringList credList; + + // credentials for the current pid + creds_t creds; + if ((creds = creds_gettask(0)) == NULL) + { + return credList; + } + + creds_type_t creds_type; + creds_value_t creds_value; + int i = 0; + + // Retrieve all credentials + while ((creds_type = creds_list(creds, i++, &creds_value)) != CREDS_BAD) + { + // Some magic to get the correct buffer length + int size = creds_creds2str(creds_type, creds_value, NULL, 0); + + char *buf = new char [size+1]; + creds_creds2str(creds_type, creds_value, buf, size+1); + + credList << QString(buf); + + delete [] buf; + } + + creds_free(creds); + + return credList; +} +#endif // HAVE_CREDS + +M_EXPORT int main(int argc, char **argv) +{ +#ifdef HAVE_MCOMPONENTCACHE + MApplication *app = MComponentCache::mApplication(argc, argv); + MApplicationWindow *win = MComponentCache::mApplicationWindow(); +#else + MApplication *app = new MApplication(argc, argv); + MApplicationWindow *win = new MApplicationWindow; +#endif + + MApplicationPage page; + + win->show(); + + page.setTitle("Applauncherd Aegis test"); + page.appear(); + + MTextEdit *edit = new MTextEdit(MTextEditModel::MultiLine); + edit->setReadOnly(true); + + page.setCentralWidget(edit); + +#ifdef HAVE_CREDS + edit->setText(credentials().join("\n")); +#else + edit->setText("Credential support not compiled"); +#endif + + return app->exec(); +} + + diff --git a/tests/TestApps/creds/creds_test.pro b/tests/TestApps/creds/creds_test.pro new file mode 100644 index 0000000..956ab00 --- /dev/null +++ b/tests/TestApps/creds/creds_test.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +TARGET = creds_test +DEPENDPATH += . +INCLUDEPATH += . + +SOURCES += creds_test.cpp + +CONFIG += meegotouch plugin + +#QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden +#QMAKE_LFLAGS += -pie -rdynamic + +LIBS += -lcreds diff --git a/tests/TestApps/creds/fala_ft_creds b/tests/TestApps/creds/fala_ft_creds new file mode 100644 index 0000000..ac3e8fd --- /dev/null +++ b/tests/TestApps/creds/fala_ft_creds @@ -0,0 +1,3 @@ +#!/bin/sh +echo "/usr/bin/invoker --type=m" $0.launch $@ +exec /usr/bin/invoker --type=m $0.launch $@ diff --git a/tests/TestApps/helloworld/CMakeLists.txt b/tests/TestApps/helloworld/CMakeLists.txt new file mode 100644 index 0000000..a717981 --- /dev/null +++ b/tests/TestApps/helloworld/CMakeLists.txt @@ -0,0 +1,16 @@ +# Set sources +set(SRC helloworld.cpp) + +link_libraries(${MEEGOTOUCH_LIBRARIES}) + +include(${QT_USE_FILE}) +add_library(helloworld MODULE ${SRC}) + +# Install +install(PROGRAMS libhelloworld.so DESTINATION /usr/bin RENAME fala_ft_hello.launch) +install(PROGRAMS scripts/fala_ft_hello DESTINATION /usr/bin/) +install(PROGRAMS scripts/qhelloworld DESTINATION /usr/bin/) + +# Install symlinks so that /usr/bin/helloworldX launches /usr/bin/helloworldX.launch +install(SCRIPT scripts/create_links.cmake) + diff --git a/tests/TestApps/helloworld/helloworld.cpp b/tests/TestApps/helloworld/helloworld.cpp new file mode 100644 index 0000000..a2ea930 --- /dev/null +++ b/tests/TestApps/helloworld/helloworld.cpp @@ -0,0 +1,65 @@ +/*************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_MCOMPONENTCACHE +#include +#endif + +M_EXPORT int main(int, char**); + +int main(int argc, char ** argv) +{ +#ifdef HAVE_MCOMPONENTCACHE + MApplication *app = MComponentCache::mApplication(argc, argv); + MApplicationWindow *window = MComponentCache::mApplicationWindow(); +#else + MApplication *app = new MApplication(argc, argv); + MApplicationWindow *window = new MApplicationWindow; +#endif + + MApplicationPage *mainPage = new MApplicationPage; + mainPage->setTitle("Hello World! (Now supports Launcher)"); + mainPage->centralWidget()->setObjectName("centralWidget"); + + MLayout *layout = new MLayout(mainPage->centralWidget()); + MLinearLayoutPolicy *linearPolicy = new MLinearLayoutPolicy(layout, + Qt::Vertical); + + linearPolicy->addItem(new MLabel("I'm a label")); + linearPolicy->addItem(new MButton("Click me!")); + linearPolicy->addItem(new MSlider); + + window->show(); + + // Explicitly state where to appear, just to be sure :-) + mainPage->appear(window); + + return app->exec(); +} diff --git a/tests/TestApps/helloworld/helloworld.pro b/tests/TestApps/helloworld/helloworld.pro new file mode 100644 index 0000000..33b4603 --- /dev/null +++ b/tests/TestApps/helloworld/helloworld.pro @@ -0,0 +1,8 @@ +TEMPLATE = app +TARGET = fala_ft_hello +CONFIG = qt meegotouch + +QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden +QMAKE_LFLAGS += -pie -rdynamic + +SOURCES += helloworld.cpp diff --git a/tests/TestApps/helloworld/scripts/create_links.cmake b/tests/TestApps/helloworld/scripts/create_links.cmake new file mode 100644 index 0000000..1eca2c6 --- /dev/null +++ b/tests/TestApps/helloworld/scripts/create_links.cmake @@ -0,0 +1,6 @@ +execute_process(COMMAND echo "Creating symlinks for fala_ft_hello..") +execute_process(COMMAND ln -v -s /usr/bin/fala_ft_hello $ENV{DESTDIR}/usr/bin/fala_ft_hello1) +execute_process(COMMAND ln -v -s /usr/bin/fala_ft_hello $ENV{DESTDIR}/usr/bin/fala_ft_hello2) +execute_process(COMMAND ln -v -s /usr/bin/fala_ft_hello.launch $ENV{DESTDIR}/usr/bin/fala_ft_hello1.launch) +execute_process(COMMAND ln -v -s /usr/bin/fala_ft_hello.launch $ENV{DESTDIR}/usr/bin/fala_ft_hello2.launch) + diff --git a/tests/TestApps/helloworld/scripts/fala_ft_hello b/tests/TestApps/helloworld/scripts/fala_ft_hello new file mode 100755 index 0000000..18dfe0c --- /dev/null +++ b/tests/TestApps/helloworld/scripts/fala_ft_hello @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "/usr/bin/invoker --type=m" $0.launch $@ +exec /usr/bin/invoker --type=m $0.launch $@ diff --git a/tests/TestApps/helloworld/scripts/qhelloworld b/tests/TestApps/helloworld/scripts/qhelloworld new file mode 100755 index 0000000..9bf5293 --- /dev/null +++ b/tests/TestApps/helloworld/scripts/qhelloworld @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "/usr/bin/invoker --type=qt" helloworld.launch $@ + +exec /usr/bin/invoker --type=qt helloworld.launch $@ diff --git a/tests/TestApps/testapp/CMakeLists.txt b/tests/TestApps/testapp/CMakeLists.txt new file mode 100644 index 0000000..12e515d --- /dev/null +++ b/tests/TestApps/testapp/CMakeLists.txt @@ -0,0 +1,14 @@ +# Set sources +set(SRC main.cpp) +link_libraries(${MEEGOTOUCH_LIBRARIES}) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden -fvisibility-inlines-hidden") +set(CMAKE_EXE_LINKER_FLAGS "-pie -rdynamic") + +# Enable Qt-support +include(${QT_USE_FILE}) +add_executable(fala_testapp ${SRC}) + +# Install +install(PROGRAMS fala_testapp DESTINATION /usr/bin/) +install(FILES com.nokia.fala_testapp.service DESTINATION /usr/share/dbus-1/services) diff --git a/tests/TestApps/testapp/com.nokia.fala_testapp.service b/tests/TestApps/testapp/com.nokia.fala_testapp.service new file mode 100644 index 0000000..48ea964 --- /dev/null +++ b/tests/TestApps/testapp/com.nokia.fala_testapp.service @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=com.nokia.fala_testapp +Exec=/usr/bin/fala_testapp -prestart + diff --git a/tests/TestApps/testapp/main.cpp b/tests/TestApps/testapp/main.cpp new file mode 100644 index 0000000..1075cb3 --- /dev/null +++ b/tests/TestApps/testapp/main.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** +** +** 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 +#include +#include + +#ifdef HAVE_MCOMPONENTCACHE + #include +#endif + +#include +#include +#include + +void FANGORNLOG(const char* s) +{ + QFile f("/tmp/testapp.log"); + f.open(QIODevice::Append); + f.write(s, qstrlen(s)); + f.write("\n", 1); + f.close(); +} + +void timestamp(const char *s) +{ + timeval tim; + char msg[80]; + gettimeofday(&tim, NULL); + snprintf(msg, 80, "%d.%06d %s\n", + static_cast(tim.tv_sec), static_cast(tim.tv_usec), s); + FANGORNLOG(msg); +} + +class MyApplicationPage: public MApplicationPage +{ +public: + MyApplicationPage(): MApplicationPage() {} + virtual ~MyApplicationPage() {} + void enterDisplayEvent() { + timestamp("MyApplicationPage::enterDisplayEvent"); + } +}; + +M_EXPORT int main(int, char**); + +int main(int argc, char **argv) { + timestamp("application main"); + +#ifdef HAVE_MCOMPONENTCACHE + MApplication* app = MComponentCache::mApplication(argc, argv); + MApplicationWindow* w = MComponentCache::mApplicationWindow(); +#else + MApplication* app = new MApplication(argc, argv); + MApplicationWindow* w = new MApplicationWindow; +#endif + + MyApplicationPage p; + MApplication::setPrestartMode(M::LazyShutdown); + p.setTitle("Applauncherd testapp"); + w->show(); + p.appear(); + return app->exec(); +} + diff --git a/tests/TestApps/testapp/testapp.pro b/tests/TestApps/testapp/testapp.pro new file mode 100644 index 0000000..0e829ee --- /dev/null +++ b/tests/TestApps/testapp/testapp.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Apr 21 10:44:49 2010 +###################################################################### + +TEMPLATE = app +QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden +QMAKE_LFLAGS += -pie -rdynamic +TARGET = testapp +DEPENDPATH += . +INCLUDEPATH += . +CONFIG += meegotouch + +# Input +SOURCES += main.cpp diff --git a/tests/TestApps/themetest/CMakeLists.txt b/tests/TestApps/themetest/CMakeLists.txt new file mode 100644 index 0000000..26a67a3 --- /dev/null +++ b/tests/TestApps/themetest/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(src) + +# Install themes +install(DIRECTORY themes/ DESTINATION /usr/share/themes/base/meegotouch/fala_ft_themetest) + diff --git a/tests/TestApps/themetest/src/CMakeLists.txt b/tests/TestApps/themetest/src/CMakeLists.txt new file mode 100644 index 0000000..0d8018e --- /dev/null +++ b/tests/TestApps/themetest/src/CMakeLists.txt @@ -0,0 +1,20 @@ +# Set sources +set(SRC themetest.cpp) + +link_libraries(${MEEGOTOUCH_LIBRARIES}) + +include(${QT_USE_FILE}) + +# This is an extremely contrived way to get at the compiler +# and linker flags given in meegotouch-boostable.pc in the +# source tree. +execute_process(COMMAND "./pkg-config-sourcetree.sh" "--cflags" "meegotouch-boostable" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE booster_cflags OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND "./pkg-config-sourcetree.sh" "--libs" "meegotouch-boostable" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE booster_libs OUTPUT_STRIP_TRAILING_WHITESPACE) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${booster_cflags}") +set(CMAKE_EXE_LINKER_FLAGS ${booster_libs}) + +add_executable(themetest ${SRC}) + +# Install +install(PROGRAMS themetest DESTINATION /usr/bin RENAME fala_ft_themetest.launch) +install(PROGRAMS fala_ft_themetest DESTINATION /usr/bin/) diff --git a/tests/TestApps/themetest/src/fala_ft_themetest b/tests/TestApps/themetest/src/fala_ft_themetest new file mode 100755 index 0000000..ac3e8fd --- /dev/null +++ b/tests/TestApps/themetest/src/fala_ft_themetest @@ -0,0 +1,3 @@ +#!/bin/sh +echo "/usr/bin/invoker --type=m" $0.launch $@ +exec /usr/bin/invoker --type=m $0.launch $@ diff --git a/tests/TestApps/themetest/src/pkg-config-sourcetree.sh b/tests/TestApps/themetest/src/pkg-config-sourcetree.sh new file mode 100644 index 0000000..4d083b4 --- /dev/null +++ b/tests/TestApps/themetest/src/pkg-config-sourcetree.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Run pkg-config with PKG_CONFIG_PATH set to the source tree. +env PKG_CONFIG_PATH=../../../../data/pkgconfig pkg-config $* diff --git a/tests/TestApps/themetest/src/themetest.cpp b/tests/TestApps/themetest/src/themetest.cpp new file mode 100644 index 0000000..6d9e483 --- /dev/null +++ b/tests/TestApps/themetest/src/themetest.cpp @@ -0,0 +1,60 @@ +/*************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + +extern "C" __attribute__((visibility("default"))) int main(int, char**); + +int main(int argc, char ** argv) +{ + MApplication *app = MComponentCache::mApplication(argc, argv, "fala_ft_themetest"); + MApplicationWindow *window = MComponentCache::mApplicationWindow(); + MApplicationPage page; + page.setTitle("fala_ft_themetest"); + + MLayout *layout = new MLayout; + MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical); + policy->setSpacing(10); + + MLabel *label = new MLabel(QString("Hello, themed world!")); + label->setObjectName("themedlabel"); + label->setAlignment(Qt::AlignCenter); + policy->addItem(label); + + label = new MLabel(QString("With sheep")); + label->setObjectName("themedlabelwithgraphics"); + label->setAlignment(Qt::AlignLeft); + policy->addItem(label); + + page.centralWidget()->setLayout(layout); + page.appear(); + window->show(); + return app->exec(); +} diff --git a/tests/TestApps/themetest/themes/style/fala_ft_themetest.css b/tests/TestApps/themetest/themes/style/fala_ft_themetest.css new file mode 100644 index 0000000..646a922 --- /dev/null +++ b/tests/TestApps/themetest/themes/style/fala_ft_themetest.css @@ -0,0 +1,55 @@ +#themedlabel.Landscape { + preferred-size: 300 79; + minimum-size: 128 79; + maximum-size: 300 79; + + text-color: $COLOR_INVERTED_FOREGROUND; + background-color: #D4F5D0; + font: $FONT_XLARGE; + text-margin-left: 20px; + margin-left: $MARGIN_DOUBLE; + margin-top:$MARGIN_DOUBLE; +} + +#themedlabel.Portrait { + preferred-size: 300 93; + minimum-size: 105 93; + maximum-size: 300 93; + + text-color: $COLOR_INVERTED_FOREGROUND; + background-color: #D4F5D0; + font: $FONT_XLARGE; + text-margin-left: 20px; + + margin-left: $MARGIN_DOUBLE; + margin-top:$MARGIN_DOUBLE; + +} + +#themedlabelwithgraphics.Landscape { + preferred-size: 300 79; + minimum-size: 128 79; + maximum-size: 300 79; + + text-color: $COLOR_INVERTED_FOREGROUND; + background-image: "baa"; + font: $FONT_XLARGE; + text-margin-left: 20px; + margin-left: $MARGIN_DOUBLE; + margin-top:$MARGIN_DOUBLE; +} + +#themedlabelwithgraphics.Portrait { + preferred-size: 300 93; + minimum-size: 105 93; + maximum-size: 300 93; + + text-color: $COLOR_INVERTED_FOREGROUND; + background-image: "baa"; + font: $FONT_XLARGE; + text-margin-left: 20px; + + margin-left: $MARGIN_DOUBLE; + margin-top:$MARGIN_DOUBLE; + +} diff --git a/tests/TestApps/themetest/themes/svg/baa.svg b/tests/TestApps/themetest/themes/svg/baa.svg new file mode 100644 index 0000000..d204f8e --- /dev/null +++ b/tests/TestApps/themetest/themes/svg/baa.svg @@ -0,0 +1,711 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/TestScripts/CMakeLists.txt b/tests/TestScripts/CMakeLists.txt new file mode 100644 index 0000000..dd22bbf --- /dev/null +++ b/tests/TestScripts/CMakeLists.txt @@ -0,0 +1,10 @@ +install(FILES + test-perf-mbooster.py + check_pipes.py + test-func-launcher.py + DESTINATION /usr/share/applauncherd-testscripts) + +install(PROGRAMS + ts_prestartapp.rb + tc_theming.rb + DESTINATION /usr/share/applauncherd-testscripts) diff --git a/tests/TestScripts/check_pipes.py b/tests/TestScripts/check_pipes.py new file mode 100755 index 0000000..41569d6 --- /dev/null +++ b/tests/TestScripts/check_pipes.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# 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. + +import subprocess +import sys + +p = subprocess.Popen("(for p in $(pgrep applauncherd); do ls -l /proc/$p/fd | grep pipe ; done) | awk -F\: '{print $3}' | sort -u", + shell=True, + stdout=subprocess.PIPE) + +result= p.stdout.read() +print type(result), result + +if result[0]!='[': + sys.exit(1) + + +p = subprocess.Popen("(for p in $(pgrep applauncherd); do ls -l /proc/$p/fd | grep pipe ; done) | awk -F\: '{print $3}' | sort -u | wc -l", + shell=True, + stdout=subprocess.PIPE) + +result= int(p.stdout.read()) + +if result!=1: + sys.exit(2) + +p = subprocess.Popen("(for p in $(pgrep applauncherd); do ls -l /proc/$p/fd | grep pipe ; done) | awk -F\: '{print $3}' | wc -l", + shell=True, + stdout=subprocess.PIPE) + +result= int(p.stdout.read()) + +if result!=4: + sys.exit(4) diff --git a/tests/TestScripts/tc_theming.rb b/tests/TestScripts/tc_theming.rb new file mode 100755 index 0000000..d8ccd1f --- /dev/null +++ b/tests/TestScripts/tc_theming.rb @@ -0,0 +1,168 @@ +#!/usr/bin/ruby1.8 +# +# 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. + +""" +This script tests that system theming works for launched applications. + +Testing that changing the theme is done as follows: + + * launch application + * take a screenshot (1) + * change theme + * take a screenshot (2) + * change theme back to original theme + * take a screenshot (3) + * make sure that 1 and 2 differ and that 1 and 3 are the same + +Testing that application specific theming is done using an application +which has application specific theming and application specific svg +graphics: + + * start application without launcher + * take screenshot of themed widgets (1) + * start application with launcher + * take screenshot of themed widgets (2) + * verify that (1) and (2) are equal +""" + +require 'matti' +require 'date' +require 'test/unit' +include MattiVerify + +SCREENSHOT_DIR = '/home/user/MyDocs' + +if ENV.has_key?('_SBOX_DIR') + ENV['PATH'] += ":" + ENV['_SBOX_DIR'] + "/tools/bin" + SCREENSHOT_DIR = '/tmp' +end + +class TC_Theming < Test::Unit::TestCase + def change_theme(theme_name) + puts "Changing theme from #{get_theme()} to #{theme_name}" + + cmd = "gconftool-2 -s /meegotouch/theme/name -t string " + theme_name + + verify_equal(true, 5, "Could not change theme") { + system(cmd) + } + + sleep(5) + end + + def get_theme() + `gconftool-2 -g /meegotouch/theme/name`.strip() + end + + def setup + system('mcetool --set-tklock-mode=unlocked') + @sut = MATTI.sut(:Id => ARGV[0] || 'sut_qt_maemo') + end + + def test_global_theming + app_name = 'fala_ft_hello' + + system("pkill #{app_name}") + + system(app_name) + sleep(5) + + #pid = `pgrep -n #{app_name}` + + app = @sut.application(:name => app_name) + widget = app.MWidget(:name => 'centralWidget') + + original_theme = get_theme() + alternative_theme = 'plankton' + + if original_theme == alternative_theme + alternative_theme = 'blanco' + end + + widget.capture_screen('PNG', SCREENSHOT_DIR + '/testshot1.png', true) + + change_theme(alternative_theme) + + widget.capture_screen('PNG', SCREENSHOT_DIR + '/testshot2.png', true) + + change_theme(original_theme) + + widget.capture_screen('PNG', SCREENSHOT_DIR + '/testshot3.png', true) + + system("pkill #{app_name}") + + # diff returns an error when files are different + verify_equal(false, 1, "Shots 1 & 2 should differ!") { + system("diff #{SCREENSHOT_DIR}/testshot1.png #{SCREENSHOT_DIR}/testshot2.png") + } + + # diff returns success when files are the same + verify_equal(true, 1, "Shots 1 & 3 should be the same!") { + system("diff #{SCREENSHOT_DIR}/testshot1.png #{SCREENSHOT_DIR}/testshot3.png") + } + + File.delete(SCREENSHOT_DIR + "/testshot1.png", + SCREENSHOT_DIR + "/testshot2.png", + SCREENSHOT_DIR + "/testshot3.png") + end + + def test_application_specific_theming + + app_with_launcher = 'fala_ft_themetest' + app_without_launcher = "#{app_with_launcher}.launch" + + # start app and take screenshots of the themed widgets + system("pkill #{app_without_launcher}") + system("pkill #{app_with_launcher}") + system("#{app_without_launcher} &") + sleep(5) + + app = @sut.application(:name => app_without_launcher) + widget = app.MLabel(:name => 'themedlabel') + widget.capture_screen('PNG', '/tmp/testshot1.png', true) + widget = app.MLabel(:name => 'themedlabelwithgraphics') + widget.capture_screen('PNG', '/tmp/testshot2.png', true) + close_button = app.MButton( :name => 'CloseButton' ) + close_button.tap + + # once again using the launcher + system("#{app_with_launcher} &") + sleep(5) + + app = @sut.application(:name => app_with_launcher) + widget = app.MLabel(:name => 'themedlabel') + widget.capture_screen('PNG', '/tmp/testshot3.png', true) + widget = app.MLabel(:name => 'themedlabelwithgraphics') + widget.capture_screen('PNG', '/tmp/testshot4.png', true) + close_button = app.MButton( :name => 'CloseButton' ) + close_button.tap + + + verify_equal(true, 1, "Application specific theming failed with launcher!") { + # diff returns success when files are the same + system("diff /tmp/testshot1.png /tmp/testshot3.png") + } + + verify_equal(true, 1, "Application specific svg files not found with launcher!") { + # diff returns success when files are the same + system("diff /tmp/testshot2.png /tmp/testshot4.png") + } + + File.delete("/tmp/testshot1.png", "/tmp/testshot2.png", + "/tmp/testshot3.png", "/tmp/testshot4.png") + end +end diff --git a/tests/TestScripts/test-func-launcher.py b/tests/TestScripts/test-func-launcher.py new file mode 100644 index 0000000..1b18c3e --- /dev/null +++ b/tests/TestScripts/test-func-launcher.py @@ -0,0 +1,384 @@ +#!/usr/bin/env python +# +# 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. + +""" +This program tests the startup time of the given application with and +without launcher. + +Requirements: +1. DISPLAY environment variable must be set correctly. +2. DBus session bus must be running. +3. DBus session bus address must be stored in /tmp/session_bus_address.user. +4. Given application supports launcher with .launcher binary in /usr/bin/. +5. launcher application should be installed. + +Usage: test-func-launcher + +Example: test-func-launcher /usr/bin/fala_ft_hello + +Authors: ext-nimika.1.keshri@nokia.com + ext-oskari.timperi@nokia.com +""" + +import os +import subprocess +import commands +import time +import sys +import unittest + +LAUNCHER_BINARY='/usr/bin/applauncherd' +DEV_NULL = file("/dev/null","w") +LAUNCHABLE_APPS = ['/usr/bin/fala_ft_hello','/usr/bin/fala_ft_hello1', '/usr/bin/fala_ft_hello2'] +PREFERED_APP = '/usr/bin/fala_ft_hello' + +def debug(*msg): + """ + Debug function + """ + sys.stderr.write('[DEBUG %s] %s\n' % (time.ctime(), \ + ' '.join([str(s) for s in msg]),)) + +def error(*msg): + """ + exit when error, give proper log + """ + sys.stderr.write('ERROR %s\n' % (' '.join([str(s) for s in msg]),)) + sys.exit(1) + +def basename(filepath): + """ + return base name of a file + """ + return os.path.basename(filepath) + +def start_launcher_daemon(): + temp = basename(LAUNCHER_BINARY) + st, op = commands.getstatusoutput("pgrep %s" %temp) + if st == 0: + debug("Launcher already started") + return op + +def check_prerequisites(): + if os.getenv('DISPLAY') == None: + error("DISPLAY is not set. Check the requirements.") + + if os.getenv('DBUS_SESSION_BUS_ADDRESS') == None: + error("DBUS_SESSION_BUS_ADDRESS is not set.\n" + + "You probably want to source /tmp/session_bus_address.user") + + for app in LAUNCHABLE_APPS: + assert(len(basename(app)) <= 14, "For app: %s, base name !<= 14" % app) + +class launcher_tests (unittest.TestCase): + def setUp(self): + #setup here + print "Executing SetUp" + + def tearDown(self): + #teardown here + print "Executing TearDown" + + #Other functions + def run_app_with_launcher(self, appname): + p = subprocess.Popen(appname, + shell=False, + stdout=DEV_NULL, stderr=DEV_NULL) + return p + + #get_pid = lambda appname: commands.getstatusoutput("pgrep %s" % appname)[-1] + + def get_pid(self, appname): + temp = basename(appname)[:14] + st, op = commands.getstatusoutput("pgrep %s" % temp) + if st == 0: + return op + else: + return None + + def kill_process(self, appname=None, apppid=None): + if apppid and appname: + return None + else: + if apppid: + st, op = commands.getstatusoutput("kill -9 %s" % str(apppid)) + if appname: + temp = basename(appname)[:14] + st, op = commands.getstatusoutput("pkill -9 %s" % temp) + os.wait() + + def process_state(self, processid): + st, op = commands.getstatusoutput('cat /proc/%s/stat' %processid) + if st == 0: + return op + else: + debug(op) + return None + + def get_creds(self, path): + """ + Tries to launch an application and if successful, returns the + credentials the application has as a list. + """ + + # try launch the specified application + handle = self.run_app_with_launcher(path) + + # sleep for a moment to allow applauncherd to start the process + time.sleep(5) + + # with luck, the process should have correct name by now + pid = self.get_pid(path) + + debug("%s has PID %s" % (basename(path), pid,)) + + self.assert_(pid != None, "Couldn't launch %s" % basename(path)) + + # get the status and output (needs creds-get from libcreds2-tools + # package) + st, op = commands.getstatusoutput("/usr/bin/creds-get -p %s" % pid) + + self.kill_process(path) + + return op.split("\n"), pid + + #Testcases + def test_001_launcher_exist(self): + """ + To test if the launcher exists and is executable or not + """ + self.assert_(os.path.isfile(LAUNCHER_BINARY), "Launcher file does not exist") + self.assert_(os.access(LAUNCHER_BINARY, os.X_OK), "Launcher exists, but is not executable") + + def test_002_applications_exist(self): + """ + test_launchable_application_exists + """ + failed_apps = [] + for app in LAUNCHABLE_APPS: + temp = "%s.launch" % app + if not (os.path.isfile(temp) and os.access(temp, os.X_OK)): + failed_apps.append(temp) + self.assert_(failed_apps == [], "Some applications do not have the launch files, list: %s" % str(failed_apps)) + + def wait_for_app(self, app = None, timeout = 5, sleep = 0.5): + """ + Waits for an application to start. Checks periodically if + the app is running for a maximum wait set in timeout. + + Returns the pid of the application if it was running before + the timeout finished, otherwise None is returned. + """ + + pid = None + start = time.time() + + while pid == None and time.time() < start + timeout: + pid = self.get_pid(app) + + if pid != None: + break + + print "waiting %s secs for %s" % (sleep, app) + + time.sleep(sleep) + + return pid + + def test_003_zombie_state(self): + """ + To test that no Zombie process exist after the application is killed + """ + #launch application with launcher + #check if the application is running + #kill the application (pid = p.pid) + #check if pgrep appname should be nothing + #self.kill_process(LAUNCHER_BINARY) + + process_handle = self.run_app_with_launcher(PREFERED_APP) + process_id = self.wait_for_app(PREFERED_APP, 5) + print process_id + self.kill_process(PREFERED_APP) + time.sleep(4) + + process_handle = self.run_app_with_launcher(PREFERED_APP) + process_id1 = self.wait_for_app(PREFERED_APP, 5) + print process_id1 + self.kill_process(PREFERED_APP) + time.sleep(4) + + process_id1 = self.get_pid(PREFERED_APP) + print process_id1 + + self.assert_(process_id != process_id1 , "New Process not launched") + self.assert_(process_id1 == None , "Process still running") + + def test_004_launch_multiple_apps(self): + """ + To test that more than one applications are launched by the launcher + """ + for app in LAUNCHABLE_APPS: + #launch application with launcher + #check if the application is running + #check if p.pid is same as pgrep appname + #in a global dictionary, append the pid + process_handle = self.run_app_with_launcher(app) + time.sleep(5) + process_id = self.get_pid(app) + self.assert_(not (process_id == None), "All Applications were not launched using launcher") + self.kill_process(PREFERED_APP) + + + def test_005_one_instance(self): + """ + To test that only one instance of a application exist + """ + #launch application + #self.run_app_with_launcher(appname) + #get pid of application + #launch applicatoin again + #check pgrep application + #y = commands.getstatusoutput(pgrep appname) + #len(y[-1].split(' ')) == 1 + process_handle = self.run_app_with_launcher(PREFERED_APP) + process_id = self.get_pid(PREFERED_APP) + debug("PID of first %s" % process_id) + process_handle1 = self.run_app_with_launcher(PREFERED_APP) + time.sleep(2) + process_id = self.get_pid(PREFERED_APP) + debug("PID of 2nd %s" % process_id) + self.assert_( len(process_id.split(' ')) == 1, "Only one instance of app not running") + self.kill_process(PREFERED_APP) + + + def test_006_creds(self): + """ + Test that the fala_ft_creds* applications have the correct + credentials set (check aegis file included in the debian package) + """ + op1, pid1 = self.get_creds('/usr/bin/fala_ft_creds1') + op2, pid2 = self.get_creds('/usr/bin/fala_ft_creds2') + + debug("fala_ft_creds1 has %s" % ', '.join(op1)) + debug("fala_ft_creds2 has %s" % ', '.join(op2)) + + # required common caps + caps = ['UID::user', 'GID::users', 'SRC::com.nokia.maemo', + 'applauncherd-testapps::applauncherd-testapps'] + + # required caps for fala_ft_creds1 + cap1 = ['Retrieving credentials for pid: %s' %pid1, 'tcb', 'drm', 'Telephony', 'CAP::setuid', 'CAP::setgid', + 'CAP::setfcap'] + caps + + # required caps for fala_ft_creds2 + cap2 = ['Retrieving credentials for pid: %s' %pid2, 'Cellular'] + caps + + # check that all required creds are there + for cap in cap1: + self.assert_(cap in op1, "%s not set for fala_ft_creds1" % cap) + + for cap in cap2: + self.assert_(cap in op2, "%s not set for fala_ft_creds2" % cap) + + # check that no other creds are set + op1.sort() + cap1.sort() + + self.assert_(op1 == cap1, "fala_ft_creds1 has non-requested creds!") + + op2.sort() + cap2.sort() + + self.assert_(op2 == cap2, "fala_ft_creds2 has non-requested creds!") + + def test_007_no_aegis_Bug170905(self): + """ + Check that an application that doesn't have aegis file doesn't + get any funny credentials. + """ + + creds, pid = self.get_creds('/usr/bin/fala_ft_hello') + debug("fala_ft_hello has %s" % ', '.join(creds)) + + req_creds = ['UID::nobody', 'GID::nogroup'] + + creds.sort() + req_creds.sort() + + self.assert_(creds == req_creds, "fala_ft_hello has differnt creds set!") + + def test_008_invoker_creds(self): + """ + Test that the launcher registered customized credentials + and invoker has proper credentials to access launcher + """ + + INVOKER_BINARY='/usr/bin/invoker' + FAKE_INVOKER_BINARY='/usr/bin/faulty_inv' + + #test application used for testing invoker + Testapp = '/usr/bin/fala_ft_hello.launch' + + #launching the testapp with actual invoker + st = os.system('%s --type=m %s'%(INVOKER_BINARY, Testapp)) + pid = self.get_pid(Testapp.replace('.launch', '')) + self.assert_((st == 0), "Application was not launched using launcher") + self.assert_(not (pid == None), "Application was not launched using launcher: actual pid%s" %pid) + print pid + #self.kill_process(Testapp.replace('.launch', '')) + self.kill_process(apppid=pid) + pid = self.get_pid(Testapp.replace('.launch', '')) + self.assert_((pid == None), "Application still running") + + #launching the testapp with fake invoker + st = os.system('%s --type=m %s'%(FAKE_INVOKER_BINARY, Testapp)) + pid = self.get_pid(Testapp.replace('.launch', '')) + self.assert_(not (st == 0), "Application was launched using fake launcher") + self.assert_((pid == None), "Application was launched using fake launcher") + + def test_009_launch_multiple_apps_cont(self): + """ + To test that more than one applications are launched by the launcher + """ + for app in LAUNCHABLE_APPS: + #launch application with launcher + #check if the application is running + #check if p.pid is same as pgrep appname + #in a global dictionary, append the pid + process_handle = self.run_app_with_launcher(app) + time.sleep(8) + process_id = self.get_pid('fala_ft_hello') + pid_list = process_id.split() + self.assert_(len(pid_list) == len(LAUNCHABLE_APPS), "All Applications were not launched using launcher") + self.kill_process(PREFERED_APP) + + +# main +if __name__ == '__main__': + # When run with testrunner, for some reason the PATH doesn't include + # the tools/bin directory + if os.getenv('_SBOX_DIR') != None: + os.environ['PATH'] = os.getenv('PATH') + ":" + os.getenv('_SBOX_DIR') + '/tools/bin' + + check_prerequisites() + start_launcher_daemon() + tests = sys.argv[1:] + mysuite = unittest.TestSuite(map(launcher_tests, tests)) + result = unittest.TextTestRunner(verbosity=2).run(mysuite) + if not result.wasSuccessful(): + sys.exit(1) + sys.exit(0) diff --git a/tests/TestScripts/test-perf-mbooster.py b/tests/TestScripts/test-perf-mbooster.py new file mode 100644 index 0000000..25a0244 --- /dev/null +++ b/tests/TestScripts/test-perf-mbooster.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python +# +# 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. + +""" +This program tests the startup time of the given application with and +without launcher. + +Requirements: +1. DISPLAY environment variable must be set correctly. +2. DBus session bus must be running. +3. DBus session bus address must be stored in /tmp/session_bus_address.user. +4. Given application supports launcher with -launcher commandline argument. +5. waitforwindow application should be installed. + +Usage: test-perf-mbooster + +Example: test-perf-mbooster /usr/bin/testapp + +Authors: Nimika Keshri ext-nimika.1.keshri@nokia.com +""" +import os +import subprocess +import commands +import time +import sys +import unittest + +TESTAPP = '/usr/bin/fala_testapp' +LOG_FILE = '/tmp/testapp.log' +DEV_NULL = file("/dev/null","w") + +_start_time = 0 +_end_time = 0 + +def debug(*msg): + sys.stderr.write('[DEBUG %s] %s\n' % (time.time(), ' '.join([str(s) for s in msg]),)) + +def error(*msg): + sys.stderr.write('ERROR %s\n' % (' '.join([str(s) for s in msg]),)) + sys.exit(1) + +def basename(filepath): + """ + return base name of a file + """ + return os.path.basename(filepath) +def is_executable_file(filename): + return os.path.isfile(filename) and os.access(filename, os.X_OK) + +def check_prerequisites(): + if os.getenv('DISPLAY') == None: + error("DISPLAY is not set. Check the requirements.") + + if os.getenv('DBUS_SESSION_BUS_ADDRESS') == None: + error("DBUS_SESSION_BUS_ADDRESS is not set.\n" + + "You probably want to source /tmp/session_bus_address.user") + + if not is_executable_file(TESTAPP): + error("'%s' is not an executable file\n" % (TESTAPP,) + + "(should be an application that supports launcher)") + + +class launcher_perf_tests (unittest.TestCase): + + def setUp(self): + print "Setup Executed" + + def tearDown(self): + print "Teardown Executed" + + #Other functions + def start_timer(self): + global _start_time + _start_time = time.time() + + def run_without_launcher(self, appname): + """starts the testapp without the launcher""" + os.system ('mcetool --set-tklock-mode=unlocked') + if os.path.exists(LOG_FILE) and os.path.isfile(LOG_FILE): + os.system('rm %s' %LOG_FILE) + self.start_timer() + p = subprocess.Popen(appname, + shell=False, + stdout=DEV_NULL, stderr=DEV_NULL) + debug("app", TESTAPP, "started without launcher") + time.sleep(5) + self.read_log() + app_time = self.app_start_time() + self.kill_process(appname) + return app_time + + def run_without_launcher_without_duihome(self, appname): + """starts the testapp without launcher and without duihome""" + os.system ('mcetool --set-tklock-mode=unlocked') + if os.path.exists(LOG_FILE) and os.path.isfile(LOG_FILE): + os.system('rm %s' %LOG_FILE) + os.system('pkill -STOP duihome') + self.start_timer() + p = subprocess.Popen(TESTAPP, + shell=False, + stdout=DEV_NULL, stderr=DEV_NULL) + debug("app", TESTAPP, "started without launcher") + time.sleep(5) + os.system('pkill -CONT duihome') + self.read_log() + app_time = self.app_start_time() + self.kill_process(appname) + return app_time + + def run_with_launcher(self, appname): + """starts the testapp with launcher and with duihome""" + os.system ('mcetool --set-tklock-mode=unlocked') + if os.path.exists(LOG_FILE) and os.path.isfile(LOG_FILE): + os.system('rm %s' %LOG_FILE) + + self.start_timer() + os.system('invoker --type=m %s' %TESTAPP) + debug("app", TESTAPP, "started with launcher") + time.sleep(5) + self.read_log() + app_time = self.app_start_time() + self.kill_process(appname) + return app_time + + def run_with_launcher_without_duihome(self, appname): + """starts the testapp with launcher but without duihome""" + os.system ('mcetool --set-tklock-mode=unlocked') + if os.path.exists(LOG_FILE) and os.path.isfile(LOG_FILE): + os.system('rm %s' %LOG_FILE) + os.system('pkill -STOP duihome') + self.start_timer() + os.system('invoker --type=m %s' %TESTAPP) + debug("app", TESTAPP, "started with launcher") + time.sleep(5) + os.system('pkill -CONT duihome') + self.read_log() + app_time = self.app_start_time() + self.kill_process(appname) + return app_time + + def read_log(self): + """Reads the log file to get the startup time""" + global _end_time + fh = open(LOG_FILE, "r") + lines = fh.readlines() + lastline = lines[len(lines)-2] + _end_time = lastline.split()[0] + return _end_time + + def app_start_time(self): + """Calculates the startup time for the testapp""" + global _app_start_time + _app_start_time = float(_end_time) - float(_start_time) + return _app_start_time + + def kill_process(self, appname): + """Kills the testapp""" + commands.getoutput("pkill -9 %s" % (basename(appname)[:15],)) + + + def perftest_with_launcher(self, appname): + debug("run app with launcher without duihome") + twlnd = self.run_with_launcher_without_duihome(appname) + time.sleep(5) + + debug("run app with launcher with duihome") + twlwd = self.run_with_launcher(appname) + time.sleep(5) + + return twlwd, twlnd + + + def perftest_without_launcher(self, appname): + """Runs all the 4 scenarios with and without launcher""" + debug("run app without launcher with duihome") + tnlwd = self.run_without_launcher(appname) + time.sleep(5) + + debug("run app without launcher without duihome") + tnlnd = self.run_without_launcher_without_duihome(appname) + time.sleep(5) + + return tnlwd, tnlnd + + + def print_test_report(self, with_without_times, fileobj): + """ + with_without_times is a list of pairs: + (with_launcher_startup_time, + without_launcher_startup_time) + """ + def writeline(*msg): + fileobj.write("%s\n" % ' '.join([str(s) for s in msg])) + def fmtfloat(f): + return "%.2f" % (f,) + def filterstats(data, field): + return tuple([d[field] for d in data]) + + if with_without_times == []: return + + writeline("") + rowformat = "%12s %12s %12s %12s" + writeline('Startup times [s]:') + + writeline(rowformat % ('launcher-Yes', 'launcher-Yes', 'launcher-No', 'launcher-No')) + writeline(rowformat % ('duihome-Yes', 'duihome-No', 'duihome-Yes', 'duihome-No')) + + t1,t2,t3,t4 = [], [], [], [] + for tnlwd,tnlnd,twlwd,twlnd in with_without_times: + t1.append(tnlwd) + t2.append(tnlnd) + t3.append(twlwd) + t4.append(twlnd) + writeline(rowformat % (fmtfloat(tnlwd),fmtfloat(tnlnd), + fmtfloat(twlwd),fmtfloat(twlnd))) + + writeline('Average times:') + writeline(rowformat % (fmtfloat(sum(t1)/len(t1)),fmtfloat(sum(t2)/len(t2)), + fmtfloat(sum(t3)/len(t3)),fmtfloat(sum(t4)/len(t4)))) + return fmtfloat(sum(t1)/len(t1)) + + def test_001(self): + """Performance test to measure the startup time for application + launched using launcher and comparing the results with application launched + without launcher""" + + times = [] + + times1, times2 = [], [] + + for i in xrange(3): + times1.append(self.perftest_with_launcher(TESTAPP)) + + for i in xrange(3): + times2.append(self.perftest_without_launcher(TESTAPP)) + + times = [[t1[0], t1[1], times2[i][0], times2[i][1]] for i, t1 in enumerate(times1)] + avg_with_launcher = self.print_test_report(times, sys.stdout) + self.assert_(float(avg_with_launcher) < float(0.75), "application launched with launcher takes more than 0.75 sec") + + +# main +if __name__ == '__main__': + check_prerequisites() + tests = sys.argv[1:] + mysuite = unittest.TestSuite(map(launcher_perf_tests, tests)) + result = unittest.TextTestRunner(verbosity=2).run(mysuite) + if not result.wasSuccessful(): + sys.exit(1) + sys.exit(0) diff --git a/tests/TestScripts/ts_prestartapp.rb b/tests/TestScripts/ts_prestartapp.rb new file mode 100755 index 0000000..55d2102 --- /dev/null +++ b/tests/TestScripts/ts_prestartapp.rb @@ -0,0 +1,74 @@ +#!/usr/bin/ruby1.8 +# +# 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. +# +# +# * Description: Testcases for the prestart functionality +# +# * Objectives: Test that a prestarted application can be +# launched as well + +require 'matti' +require 'date' +require 'test/unit' +include MattiVerify + +# When run by testrunner in scratchbox, the PATH environment variable +# is missing some vital entries ... +if ENV.has_key?('_SBOX_DIR') + ENV['PATH'] += ":" + ENV['_SBOX_DIR'] + "/tools/bin" +end + +class TC_PRESTARTLAUNCHTESTS < Test::Unit::TestCase + + # method called before any test case + def setup + system "mcetool --set-tklock-mode=unlocked" + @sut = MATTI.sut(:Id=>ARGV[0] || 'sut_qt_maemo') + end + + # method called after any test case for cleanup purposes + def teardown + end + + def test_launch_prestarted_app + #Test that a prestarted application can be launched + @appname = 'fala_testapp' + if system("pgrep #{@appname}") == true + system("kill -9 `pgrep #{@appname}`") + end + sleep 2 + verify_equal(false,2,"Application is Prestarted"){ + system "pgrep #{@appname}"} + sleep 2 + + string = `export DISPLAY=:0; source /tmp/session_bus_address.user;dbus-send --dest=com.nokia.#{@appname} --type="method_call" /org/maemo/m com.nokia.MApplicationIf.ping` + sleep 1 + + verify_equal(true,2,"Application is not Prestarted"){ + system "pgrep #{@appname}"} + pid = string = `pgrep #{@appname}` + sleep 1 + + string = `export DISPLAY=:0; source /tmp/session_bus_address.user;dbus-send --dest=com.nokia.#{@appname} --type="method_call" /org/maemo/m com.nokia.MApplicationIf.launch` + @app = @sut.application( :name => 'fala_testapp' ) + @app.MButton( :name => 'CloseButton' ).tap + newid = string = `pgrep #{@appname}` + verify_true(30,"The application is not prestarted"){pid == newid} + sleep 1 + system "kill -9 `pgrep #{@appname}`" + end +end diff --git a/tests/art-tests/CMakeLists.txt b/tests/art-tests/CMakeLists.txt new file mode 100644 index 0000000..4bb9a11 --- /dev/null +++ b/tests/art-tests/CMakeLists.txt @@ -0,0 +1,2 @@ +install(FILES tests.xml DESTINATION /usr/share/applauncherd-art-tests) + diff --git a/tests/art-tests/tests.xml b/tests/art-tests/tests.xml new file mode 100644 index 0000000..b594514 --- /dev/null +++ b/tests/art-tests/tests.xml @@ -0,0 +1,58 @@ + + + + + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_003_zombie_state + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_004_launch_multiple_apps + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_005_one_instance + + + + + + + false + true + + + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/ts_prestartapp.rb --name test_launch_prestarted_app + + + + false + true + + + + + + + + diff --git a/tests/bug-tests/CMakeLists.txt b/tests/bug-tests/CMakeLists.txt new file mode 100644 index 0000000..5ffa8d3 --- /dev/null +++ b/tests/bug-tests/CMakeLists.txt @@ -0,0 +1,2 @@ +install(FILES tests.xml DESTINATION /usr/share/applauncherd-bug-tests) + diff --git a/tests/bug-tests/tests.xml b/tests/bug-tests/tests.xml new file mode 100644 index 0000000..6b269e5 --- /dev/null +++ b/tests/bug-tests/tests.xml @@ -0,0 +1,61 @@ + + + + + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + + `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_007_no_aegis_Bug170905 + + + + `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_008_invoker_creds + + + + `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_009_launch_multiple_apps_cont + + + + `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_006_creds + + + false + true + + + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + + /usr/share/applauncherd-testscripts/tc_theming.rb --name test_application_specific_theming + + + + /usr/share/applauncherd-testscripts/tc_theming.rb --name test_global_theming + + + + true + true + + + + + + + + diff --git a/tests/functests/CMakeLists.txt b/tests/functests/CMakeLists.txt new file mode 100644 index 0000000..20fe457 --- /dev/null +++ b/tests/functests/CMakeLists.txt @@ -0,0 +1,2 @@ +install(FILES tests.xml DESTINATION /usr/share/applauncherd-functional-tests) + diff --git a/tests/functests/tests.xml b/tests/functests/tests.xml new file mode 100644 index 0000000..4579ab0 --- /dev/null +++ b/tests/functests/tests.xml @@ -0,0 +1,78 @@ + + + + + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + + + source /tmp/session_bus_address.user; `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_001_launcher_exist + + + + source /tmp/session_bus_address.user; `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_002_applications_exist + + + + source /tmp/session_bus_address.user; `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_003_zombie_state + + + + source /tmp/session_bus_address.user; `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_004_launch_multiple_apps + + + + source /tmp/session_bus_address.user; `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_005_one_instance + + + + true + true + + + + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + + source /tmp/session_bus_address.user; `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_006_creds + + + + false + true + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + source /tmp/session_bus_address.user; /usr/share/applauncherd-testscripts/ts_prestartapp.rb --name test_launch_prestarted_app + + + + true + true + + + + + + + + diff --git a/tests/perftests/CMakeLists.txt b/tests/perftests/CMakeLists.txt new file mode 100644 index 0000000..ddb9857 --- /dev/null +++ b/tests/perftests/CMakeLists.txt @@ -0,0 +1 @@ +install(FILES tests.xml DESTINATION /usr/share/applauncherd-performance-tests/) diff --git a/tests/perftests/tests.xml b/tests/perftests/tests.xml new file mode 100644 index 0000000..04af177 --- /dev/null +++ b/tests/perftests/tests.xml @@ -0,0 +1,31 @@ + + + + + + + + + + /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-perf-mbooster.py test_001 > /tmp/launcher_perf.txt + + + + false + true + + + + /tmp/launcher_perf.txt + /tmp/testapp.log + + + + + + + diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt new file mode 100644 index 0000000..d0decef --- /dev/null +++ b/tests/unittests/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(ut_daemon) +add_subdirectory(ut_booster) +add_subdirectory(ut_mbooster) +add_subdirectory(ut_qtbooster) +add_subdirectory(ut_connection) + +install(FILES tests.xml DESTINATION /usr/share/applauncherd-tests) + diff --git a/tests/unittests/tests.xml b/tests/unittests/tests.xml new file mode 100644 index 0000000..36e4974 --- /dev/null +++ b/tests/unittests/tests.xml @@ -0,0 +1,81 @@ + + + + + + + + + + export DISPLAY=:0 + source /tmp/session_bus_address.user + + + + + /usr/share/applauncherd-tests/ut_daemon + + + + /usr/share/applauncherd-tests/ut_connection + + + + true + true + + + + + + + + export DISPLAY=:0 + source /tmp/session_bus_address.user + + + + + + /usr/share/applauncherd-tests/ut_mbooster + + + + + /usr/share/applauncherd-tests/ut_booster + + + + true + true + + + + + + + + export DISPLAY=:0 + source /tmp/session_bus_address.user + + + + + /usr/share/applauncherd-tests/ut_qtbooster + + + + true + true + + + + + + + + + diff --git a/tests/unittests/ut_booster/CMakeLists.txt b/tests/unittests/ut_booster/CMakeLists.txt new file mode 100644 index 0000000..87f1196 --- /dev/null +++ b/tests/unittests/ut_booster/CMakeLists.txt @@ -0,0 +1,27 @@ +set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) + +# Set sources +set(SRC ut_booster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp) + +# Set moc headers +set(MOC_HDRS ut_booster.h) + +# Run moc +qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) + +# Enable test library +set(QT_USE_QTTEST TRUE) + +# Set include paths +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER}) + +link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBCREDS}) + +# Enable Qt (may not be needed, because already defined on higher level) +include(${QT_USE_FILE}) + +add_executable(ut_booster ${SRC} ${MOC_SRC}) + +# Install +install(PROGRAMS ut_booster DESTINATION /usr/share/applauncherd-tests/) + diff --git a/tests/unittests/ut_booster/ut_booster.cpp b/tests/unittests/ut_booster/ut_booster.cpp new file mode 100644 index 0000000..c4af90d --- /dev/null +++ b/tests/unittests/ut_booster/ut_booster.cpp @@ -0,0 +1,265 @@ +/*************************************************************************** +** +** 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 "ut_booster.h" +#include "booster.h" + +// Booster is an abstract base-class, so let's inherit it +class MyBooster : public Booster +{ +public: + MyBooster(); + char boosterType() const; + const std::string & socketId() const; + +private: + const string m_socketId; +}; + +MyBooster::MyBooster() : + m_socketId("/tmp/MyBooster") +{} + +char MyBooster::boosterType() const +{ + return 'm'; +} + +const std::string & MyBooster::socketId() const +{ + return m_socketId; +} + +Ut_Booster::Ut_Booster() +{} + +Ut_Booster::~Ut_Booster() +{} + +void Ut_Booster::initTestCase() +{} + +void Ut_Booster::cleanupTestCase() +{} + +char ** Ut_Booster::packTwoArgs(const char * arg0, const char * arg1) +{ + char ** argv = new char * [2]; + char * result = new char[strlen(arg0) + strlen(arg1) + 2]; + memset(result, '\0', strlen(arg0) + strlen(arg1) + 2); + + strcat(result, arg0); + strcat(result, " "); + strcat(result, arg1); + + // Arguments are allocated consecutively in Linux + argv[0] = result; + argv[1] = argv[0] + strlen(arg0) + 1; + argv[0][strlen(arg0)] = '\0'; + + return argv; +} + +void Ut_Booster::testRenameBoosterProcess() +{ + m_subject.reset(new MyBooster); + + // if m_app.appName isn't initialized, new process name is booster_x + // 20 chars dummy buffer used to fool ps to show correct process name with args + const int INIT_ARGS = 2; + char ** initialArgv = packTwoArgs("oldName", " "); + m_subject->renameProcess(INIT_ARGS, const_cast(initialArgv)); + + // New name and arguments fit and are correct + QVERIFY(strcmp(initialArgv[0], "booster-m") == 0); + + // Define and copy args because it's assumed that they are allocated in the heap + // (AppData deletes the argv on exit) + const int ARGS = 3; + m_subject->m_app.setArgc(ARGS); + + char ** argv = new char * [ARGS]; + argv[0] = strdup("newName"); + argv[1] = strdup("--foo"); + argv[2] = strdup("--bar"); + m_subject->m_app.setArgv(const_cast(argv)); + m_subject->m_app.setAppName("newName"); + m_subject->renameProcess(INIT_ARGS, const_cast(initialArgv)); + + // New name and arguments fit and are correct + QVERIFY2(strcmp(initialArgv[0], "newName --foo --bar") == 0, initialArgv[0]); + + delete initialArgv[0]; + delete [] initialArgv; +} + +void Ut_Booster::testRenameProcess() +{ + m_subject.reset(new MyBooster); + + // Define and copy args because it's assumed that they are allocated in the heap + // (AppData deletes the argv on exit) + const int ARGS = 3; + m_subject->m_app.setArgc(ARGS); + char ** argv = new char * [ARGS]; + argv[0] = strdup("newName"); + argv[1] = strdup("--foo"); + argv[2] = strdup("--bar"); + m_subject->m_app.setArgv(const_cast(argv)); + m_subject->m_app.setAppName(m_subject->m_app.argv()[0]); + + // 20 chars dummy buffer used to fool ps to show correct process name with args + const int INIT_ARGS = 2; + char ** initialArgv = packTwoArgs("oldName", " "); + m_subject->renameProcess(INIT_ARGS, const_cast(initialArgv)); + + // New name and arguments fit and are correct + QVERIFY(strcmp(initialArgv[0], "newName --foo --bar") == 0); + + delete initialArgv[0]; + delete [] initialArgv; +} + +void Ut_Booster::testRenameProcessNotEnoughSpace() +{ + m_subject.reset(new MyBooster); + + const int ARGS = 3; + m_subject->m_app.setArgc(ARGS); + char ** argv = new char * [ARGS]; + argv[0] = strdup("newNameLong"); + argv[1] = strdup("--foo"); + argv[2] = strdup("--bar"); + m_subject->m_app.setArgv(const_cast(argv)); + m_subject->m_app.setAppName(m_subject->m_app.argv()[0]); + + const int INIT_ARGS = 2; + char ** initialArgv = packTwoArgs("oldName", " "); + int initLen = strlen(initialArgv[0]); + m_subject->renameProcess(INIT_ARGS, initialArgv); + + // Not enough space for the new name nor the arguments: + // name should be cut + QVERIFY(strncmp(initialArgv[0], m_subject->m_app.argv()[0], initLen - 1) == 0); + + delete [] initialArgv[0]; + delete [] initialArgv; +} + +void Ut_Booster::testRenameProcessNotEnoughSpace2() +{ + m_subject.reset(new MyBooster); + + const int ARGS = 3; + m_subject->m_app.setArgc(ARGS); + char ** argv = new char * [ARGS]; + argv[0] = strdup("newName"); + argv[1] = strdup("--foo"); + argv[2] = strdup("--bar"); + m_subject->m_app.setArgv(const_cast(argv)); + m_subject->m_app.setAppName(m_subject->m_app.argv()[0]); + + const int INIT_ARGS = 2; + char ** initialArgv = packTwoArgs("oldName", " "); + m_subject->renameProcess(INIT_ARGS, initialArgv); + + // Not enough space for the second argument: + // second argument should be left out + QVERIFY(strcmp(initialArgv[0], "newName --foo") == 0); + + delete initialArgv[0]; + delete [] initialArgv; +} + +void Ut_Booster::testRenameProcessNotEnoughSpace3() +{ + m_subject.reset(new MyBooster); + + const int ARGS = 3; + m_subject->m_app.setArgc(ARGS); + char ** argv = new char * [ARGS]; + argv[0] = strdup("newName"); + argv[1] = strdup("--foo"); + argv[2] = strdup("--bar"); + m_subject->m_app.setArgv(const_cast(argv)); + m_subject->m_app.setAppName(m_subject->m_app.argv()[0]); + + const int INIT_ARGS = 2; + char ** initialArgv = packTwoArgs("app", " "); + + m_subject->renameProcess(INIT_ARGS, initialArgv); + + // Not enough space for arguments but just enough space + // for the new name + QVERIFY(strcmp(initialArgv[0], "newName") == 0); + + delete initialArgv[0]; + delete [] initialArgv; +} + +void Ut_Booster::testRenameProcessNotEnoughSpace4() +{ + m_subject.reset(new MyBooster); + + const int ARGS = 3; + m_subject->m_app.setArgc(ARGS); + char ** argv = new char * [ARGS]; + argv[0] = strdup("newNameLongLong"); + argv[1] = strdup("--foo"); + argv[2] = strdup("--bar"); + m_subject->m_app.setArgv(const_cast(argv)); + m_subject->m_app.setAppName(m_subject->m_app.argv()[0]); + + const int INIT_ARGS = 2; + char ** initialArgv = packTwoArgs("app", " "); + m_subject->renameProcess(INIT_ARGS, initialArgv); + + // Not enough space for newName, but dummy space exist: should be cut + QVERIFY(strcmp(initialArgv[0], "newName") == 0); + + delete initialArgv[0]; + delete [] initialArgv; +} + +void Ut_Booster::testRenameProcessNoArgs() +{ + m_subject.reset(new MyBooster); + + const int ARGS = 2; + m_subject->m_app.setArgc(ARGS); + char ** argv = new char * [ARGS]; + argv[0] = strdup("newName"); + argv[1] = strdup("--foo"); + m_subject->m_app.setArgv(const_cast(argv)); + m_subject->m_app.setAppName(m_subject->m_app.argv()[0]); + + const int INIT_ARGS = 1; + char ** initialArgv = new char * [INIT_ARGS]; + initialArgv[0] = strdup("oldName"); + m_subject->renameProcess(INIT_ARGS, initialArgv); + + // No dummy space argument at all, only name fits + QVERIFY(strcmp(initialArgv[0], m_subject->m_app.argv()[0]) == 0); + + delete initialArgv[0]; + delete [] initialArgv; +} + +QTEST_APPLESS_MAIN(Ut_Booster); + diff --git a/tests/unittests/ut_booster/ut_booster.h b/tests/unittests/ut_booster/ut_booster.h new file mode 100644 index 0000000..15395f3 --- /dev/null +++ b/tests/unittests/ut_booster/ut_booster.h @@ -0,0 +1,59 @@ +/*************************************************************************** +** +** 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 UT_BOOSTER_H +#define UT_BOOSTER_H + +#include +#include + +#include + +#define UNIT_TEST + +class Booster; + +class Ut_Booster : public QObject +{ + Q_OBJECT + +public: + Ut_Booster(); + virtual ~Ut_Booster(); + +private Q_SLOTS: + void initTestCase(); + void testRenameProcess(); + void testRenameProcessNotEnoughSpace(); + void testRenameProcessNotEnoughSpace2(); + void testRenameProcessNotEnoughSpace3(); + void testRenameProcessNotEnoughSpace4(); + void testRenameProcessNoArgs(); + void testRenameBoosterProcess(); + void cleanupTestCase(); + +private: + + char ** packTwoArgs(const char * arg0, const char * arg1); + std::tr1::shared_ptr m_subject; +}; + +#endif // UT_BOOSTER_H + + diff --git a/tests/unittests/ut_connection/CMakeLists.txt b/tests/unittests/ut_connection/CMakeLists.txt new file mode 100644 index 0000000..9e10ba5 --- /dev/null +++ b/tests/unittests/ut_connection/CMakeLists.txt @@ -0,0 +1,28 @@ +set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) + +# Set sources +set(SRC ut_connection.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/daemon.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp ${LAUNCHER}/qtbooster.cpp) + +# Set moc headers +set(MOC_HDRS ut_connection.h) + +# Set the program name define used in daemon.cpp +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME=\\\"applauncherd\\\"") + +# Run moc +qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) + +# Enable test library +set(QT_USE_QTTEST TRUE) + +# Set include paths +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER}) +link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${MEEGOTOUCH_LIBRARIES}) + +# Enable Qt (may not be needed, because already defined on higher level) +include(${QT_USE_FILE}) +add_executable(ut_connection ${SRC} ${MOC_SRC}) + +# Install +install(PROGRAMS ut_connection DESTINATION /usr/share/applauncherd-tests/) + diff --git a/tests/unittests/ut_connection/ut_connection.cpp b/tests/unittests/ut_connection/ut_connection.cpp new file mode 100644 index 0000000..033b685 --- /dev/null +++ b/tests/unittests/ut_connection/ut_connection.cpp @@ -0,0 +1,190 @@ +/*************************************************************************** +** +** 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 "ut_connection.h" +#include "connection.h" +#include +#include +#include + +/* redefine some methods for Connection class */ +class MyConnection : public Connection +{ +public: + int nextMsg; + char* nextStr; + + MyConnection(const string socketId); + bool acceptConn(); + +private: + bool recvMsg(uint32_t *msg); + const char * recvStr(); + bool sendMsg(uint32_t msg); + bool sendStr(const char * str); +}; + +bool MyConnection::acceptConn() { return true; } + +MyConnection::MyConnection(const string socketId) : + Connection(socketId), + nextMsg(0), + nextStr(NULL) +{} + +bool MyConnection::recvMsg(uint32_t *msg) +{ + *msg = nextMsg; + return true; +} + +bool MyConnection::sendMsg(uint32_t) +{ + return true; +} + +bool MyConnection::sendStr(const char *) +{ + return true; +} + +const char * MyConnection::recvStr() +{ + return nextStr; +} + +Ut_Connection::Ut_Connection() +{ +} + +Ut_Connection::~Ut_Connection() +{ +} + +void Ut_Connection::initTestCase() +{ +} + +void Ut_Connection::cleanupTestCase() +{ +} + +/* + * Check that socket initialized for provided socket id + */ +void Ut_Connection::testInitConnection() +{ + unsigned int prevNum = Connection::socketPool.size(); + Connection::initSocket("aaa"); + Connection::initSocket("bbb"); + Connection::initSocket("bbb"); + Connection::initSocket("aaa"); + + QVERIFY(Connection::socketPool.size() == prevNum + 2); + QVERIFY(Connection::findSocket("aaa") != -1); + QVERIFY(Connection::findSocket("ccc") == -1); + QVERIFY(Connection::findSocket("bbb") != -1); + + unlink("aaa"); + unlink("bbb"); +} + +/* + * Check that closeConn() reset socket connection + */ +void Ut_Connection::testAcceptConnection() +{ + char* socketName = (char*) "testAccept"; + + Connection::initSocket(socketName); + MyConnection* conn = new MyConnection(socketName); + conn->m_fd = 1000; + + QVERIFY(conn->acceptConn() == true); + QVERIFY(conn->m_fd > 0); + + conn->closeConn(); + QVERIFY(conn->m_fd == -1); + + unlink("testAccept"); +} + +/* + * Check that env variable passed from invoker will + * be set in launcher process + */ +void Ut_Connection::testGetEnv() +{ + QVERIFY(getenv("MY_TEST_ENV_VAR") == NULL); + QVERIFY(getenv("PATH") != NULL); + + const char* socketName = "testGetEnv"; + Connection::initSocket(socketName); + MyConnection* conn = new MyConnection(socketName); + + char* envVar = strdup("MY_TEST_ENV_VAR=3"); + + conn->nextMsg = 1; + conn->nextStr = envVar; + + QVERIFY(conn->receiveEnv() == true); + QVERIFY(getenv("MY_TEST_ENV_VAR") != NULL); + QVERIFY(getenv("PATH") != NULL); + + unlink(socketName); + delete envVar; +} + +/* + * Check getAppName() function correctness + */ +void Ut_Connection::testGetAppName() +{ + const char* socketName = "testGetAppName"; + + Connection::initSocket(socketName); + + MyConnection* conn = new MyConnection(socketName); + + // wrong type of message + conn->nextMsg = INVOKER_MSG_EXEC; + string wrongStr = conn->receiveAppName(); + QVERIFY(wrongStr.empty()); + + // empty app name + conn->nextMsg = INVOKER_MSG_NAME; + conn->nextStr = NULL; + string emptyName = conn->receiveAppName(); + QVERIFY(emptyName.empty()); + + // real name + string realName("looooongApplicationName"); + char* dupName = strdup(realName.c_str()); + + conn->nextMsg = INVOKER_MSG_NAME; + conn->nextStr = dupName; + + string resName = conn->receiveAppName(); + QVERIFY(!resName.empty()); + QVERIFY(resName.compare(realName) == 0); + + unlink(socketName); +} + +QTEST_APPLESS_MAIN(Ut_Connection); diff --git a/tests/unittests/ut_connection/ut_connection.h b/tests/unittests/ut_connection/ut_connection.h new file mode 100644 index 0000000..809c46f --- /dev/null +++ b/tests/unittests/ut_connection/ut_connection.h @@ -0,0 +1,53 @@ +/*************************************************************************** +** +** 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 UT_CONNECTION_H +#define UT_CONNECTION_H + +#include +#include + +#include + +#define UNIT_TEST + +class Connection; + +class Ut_Connection : public QObject +{ + Q_OBJECT + +public: + Ut_Connection(); + ~Ut_Connection(); + +private Q_SLOTS: + + void initTestCase(); + void cleanupTestCase(); + void testInitConnection(); + void testAcceptConnection(); + void testGetEnv(); + void testGetAppName(); + +private: + std::tr1::shared_ptr m_subject; +}; + +#endif // UT_CONNECTION_H diff --git a/tests/unittests/ut_daemon/CMakeLists.txt b/tests/unittests/ut_daemon/CMakeLists.txt new file mode 100644 index 0000000..097d476 --- /dev/null +++ b/tests/unittests/ut_daemon/CMakeLists.txt @@ -0,0 +1,27 @@ +# Set sources +set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) +set(SRC ut_daemon.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/daemon.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp ${LAUNCHER}/qtbooster.cpp) + +# Set moc headers +set(MOC_HDRS ut_daemon.h) + +# Set the program name define used in daemon.cpp +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROG_NAME=\\\"applauncherd\\\"") + +# Run moc +qt4_wrap_cpp(MOC_SRC ${MOC_HDRS} ) + +# Enable test library +set(QT_USE_QTTEST TRUE) + +# Set include paths +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER}) +link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${MEEGOTOUCH_LIBRARIES}) + +# Enable Qt (may not be needed, because already defined on higher level) +include(${QT_USE_FILE}) +add_executable(ut_daemon ${SRC} ${MOC_SRC}) + +# Install +install(PROGRAMS ut_daemon DESTINATION /usr/share/applauncherd-tests/) + diff --git a/tests/unittests/ut_daemon/ut_daemon.cpp b/tests/unittests/ut_daemon/ut_daemon.cpp new file mode 100644 index 0000000..5d937af --- /dev/null +++ b/tests/unittests/ut_daemon/ut_daemon.cpp @@ -0,0 +1,99 @@ +/*************************************************************************** +** +** 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 "ut_daemon.h" +#include "daemon.h" + +Ut_Daemon::Ut_Daemon() +{ + int argc = 3; + char **argv = new char * [argc]; + argv[0] = strdup("app"); + argv[1] = strdup("--testParameter"); + argv[2] = strdup("--123"); + + m_subject.reset(new Daemon( argc, argv )); +} + +Ut_Daemon::~Ut_Daemon() +{ +} + +void Ut_Daemon::initTestCase() +{} + +void Ut_Daemon::cleanupTestCase() +{} + +void Ut_Daemon::testInitialArguments() +{ + QVERIFY2(m_subject->m_initialArgc == 3, "Failure"); + QCOMPARE(m_subject->m_initialArgv[0], "app"); + QCOMPARE(m_subject->m_initialArgv[1], "--testParameter"); + QCOMPARE(m_subject->m_initialArgv[2], "--123"); +} + +void Ut_Daemon::testParseArgs() +{ + int argc = 4; + char **argv = new char * [argc]; + + argv[0] = strdup("app"); + argv[1] = strdup("--daemon"); + argv[2] = strdup("--quiet"); + argv[3] = strdup("--test"); + + QVERIFY2(m_subject->m_daemon == false, "Failure"); + QVERIFY2(m_subject->m_quiet == false, "Failure"); + QVERIFY2(m_subject->m_testMode == false, "Failure"); + + m_subject->parseArgs(vector(argv, argv + argc)); + + QVERIFY2(m_subject->m_daemon == true, "Failure"); + QVERIFY2(m_subject->m_quiet == true, "Failure"); + QVERIFY2(m_subject->m_testMode == true, "Failure"); + + delete argv[0]; + delete argv[1]; + delete argv[2]; + delete argv[3]; + delete [] argv; +} + +void Ut_Daemon::testVerifyInstance() +{ + QVERIFY2(m_subject.get() == Daemon::instance(), "Failure"); +} + +void Ut_Daemon::testReapZombies() +{ + QVERIFY2(m_subject->m_children.size() == 0, "Failure"); + + for (int i=234234; i<234245; i++) { + m_subject->m_children.push_back(i); + } + + QVERIFY2(m_subject->m_children.size() == 11, "Failure"); + + m_subject->reapZombies(); + + QVERIFY2(m_subject->m_children.size() == 0, "Failure"); +} + +QTEST_APPLESS_MAIN(Ut_Daemon); diff --git a/tests/unittests/ut_daemon/ut_daemon.h b/tests/unittests/ut_daemon/ut_daemon.h new file mode 100644 index 0000000..69c2683 --- /dev/null +++ b/tests/unittests/ut_daemon/ut_daemon.h @@ -0,0 +1,54 @@ +/*************************************************************************** +** +** 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 UT_DAEMON_H +#define UT_DAEMON_H + +#include +#include + +#include + +#define UNIT_TEST + +class Daemon; + +class Ut_Daemon : public QObject +{ + Q_OBJECT + +public: + Ut_Daemon(); + ~Ut_Daemon(); +private Q_SLOTS: + + void initTestCase(); + void cleanupTestCase(); + void testInitialArguments(); + void testParseArgs(); + void testVerifyInstance(); + void testReapZombies(); + +private: + std::tr1::shared_ptr m_subject; +}; + +#endif // UT_DAEMON_H + + diff --git a/tests/unittests/ut_mbooster/CMakeLists.txt b/tests/unittests/ut_mbooster/CMakeLists.txt new file mode 100644 index 0000000..443af12 --- /dev/null +++ b/tests/unittests/ut_mbooster/CMakeLists.txt @@ -0,0 +1,28 @@ +set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) + +# Set sources +set(SRC ut_mbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp + ${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp) + +# Set moc headers +set(MOC_HDRS ut_mbooster.h) + +# Run moc +qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) + +# Enable test library +set(QT_USE_QTTEST TRUE) + +# Set include paths +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER}) + +link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${MEEGOTOUCH_LIBRARIES} ${LIBCREDS}) + +# Enable Qt (may not be needed, because already defined on higher level) +include(${QT_USE_FILE}) + +add_executable(ut_mbooster ${SRC} ${MOC_SRC} ) + +# Install +install(PROGRAMS ut_mbooster DESTINATION /usr/share/applauncherd-tests/) + diff --git a/tests/unittests/ut_mbooster/ut_mbooster.cpp b/tests/unittests/ut_mbooster/ut_mbooster.cpp new file mode 100644 index 0000000..21b0eb5 --- /dev/null +++ b/tests/unittests/ut_mbooster/ut_mbooster.cpp @@ -0,0 +1,49 @@ +/*************************************************************************** +** +** 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 "ut_mbooster.h" +#include "mbooster.h" + +Ut_MBooster::Ut_MBooster() : + m_subject(new MBooster) +{} + +Ut_MBooster::~Ut_MBooster() +{} + +void Ut_MBooster::initTestCase() +{} + +void Ut_MBooster::cleanupTestCase() +{} + +void Ut_MBooster::testSocketName() +{ + QVERIFY2(MBooster::socketName() == MBooster::m_socketId, "Failure"); + QVERIFY2(m_subject->socketId() == MBooster::m_socketId, "Failure"); +} + +void Ut_MBooster::testType() +{ + QVERIFY2(MBooster::type() == 'm', "Failure"); + QVERIFY2(m_subject->boosterType() == 'm', "Failure"); +} + +QTEST_APPLESS_MAIN(Ut_MBooster); + diff --git a/tests/unittests/ut_mbooster/ut_mbooster.h b/tests/unittests/ut_mbooster/ut_mbooster.h new file mode 100644 index 0000000..12aaf7e --- /dev/null +++ b/tests/unittests/ut_mbooster/ut_mbooster.h @@ -0,0 +1,52 @@ +/*************************************************************************** +** +** 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 UT_MBOOSTER_H +#define UT_MBOOSTER_H + +#include +#include + +#include + +#define UNIT_TEST + +class MBooster; + +class Ut_MBooster : public QObject +{ + Q_OBJECT + +public: + Ut_MBooster(); + virtual ~Ut_MBooster(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void testSocketName(); + void testType(); + +private: + std::tr1::shared_ptr m_subject; +}; + +#endif // UT_MBOOSTER_H + + diff --git a/tests/unittests/ut_qtbooster/CMakeLists.txt b/tests/unittests/ut_qtbooster/CMakeLists.txt new file mode 100644 index 0000000..fd9c059 --- /dev/null +++ b/tests/unittests/ut_qtbooster/CMakeLists.txt @@ -0,0 +1,25 @@ +set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) + +# Set sources +set(SRC ut_qtbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp + ${LAUNCHER}/logger.cpp ${LAUNCHER}/qtbooster.cpp) + +# Set moc headers +set(MOC_HDRS ut_qtbooster.h) + +# Run moc +qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) + +# Enable test library +set(QT_USE_QTTEST TRUE) + +# Set include paths +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER}) +link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBCREDS}) + +# Enable Qt (may not be needed, because already defined on higher level) +include(${QT_USE_FILE}) +add_executable(ut_qtbooster ${SRC} ${MOC_SRC}) + +# Install +install(PROGRAMS ut_qtbooster DESTINATION /usr/share/applauncherd-tests/) diff --git a/tests/unittests/ut_qtbooster/ut_qtbooster.cpp b/tests/unittests/ut_qtbooster/ut_qtbooster.cpp new file mode 100644 index 0000000..2a4ae07 --- /dev/null +++ b/tests/unittests/ut_qtbooster/ut_qtbooster.cpp @@ -0,0 +1,49 @@ +/*************************************************************************** +** +** 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 "ut_qtbooster.h" +#include "qtbooster.h" + +Ut_QtBooster::Ut_QtBooster() : + m_subject(new QtBooster) +{} + +Ut_QtBooster::~Ut_QtBooster() +{} + +void Ut_QtBooster::initTestCase() +{} + +void Ut_QtBooster::cleanupTestCase() +{} + +void Ut_QtBooster::testSocketName() +{ + QVERIFY2(QtBooster::socketName() == QtBooster::m_socketId, "Failure"); + QVERIFY2(m_subject->socketId() == QtBooster::m_socketId, "Failure"); +} + +void Ut_QtBooster::testType() +{ + QVERIFY2(QtBooster::type() == 'q', "Failure"); + QVERIFY2(m_subject->boosterType() == 'q', "Failure"); +} + +QTEST_APPLESS_MAIN(Ut_QtBooster); + diff --git a/tests/unittests/ut_qtbooster/ut_qtbooster.h b/tests/unittests/ut_qtbooster/ut_qtbooster.h new file mode 100644 index 0000000..9bc4297 --- /dev/null +++ b/tests/unittests/ut_qtbooster/ut_qtbooster.h @@ -0,0 +1,52 @@ +/*************************************************************************** +** +** 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 UT_QTBOOSTER_H +#define UT_QTBOOSTER_H + +#include +#include + +#include + +#define UNIT_TEST + +class QtBooster; + +class Ut_QtBooster : public QObject +{ + Q_OBJECT + +public: + Ut_QtBooster(); + virtual ~Ut_QtBooster(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void testSocketName(); + void testType(); + +private: + std::tr1::shared_ptr m_subject; +}; + +#endif // UT_QTBOOSTER_H + +