--- /dev/null
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+binaries
+*.ipk
+*~
+cmake_tmp
+*-stamp
+doxygen_output
--- /dev/null
+echo "--------------------------------------"
+echo "Update package database..............."
+echo "--------------------------------------"
+/usr/bin/pkg_fota
--- /dev/null
+Jayoun Lee <airjany@samsung.com>
+Sewook Park <sewook7.park@samsung.com>
+Jaeho Lee <jaeho81.lee@samsung.com>
+Shobhit Srivastava <shobhit.s@samsung.com>
--- /dev/null
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved
+#
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+PROJECT(package-manager C)
+
+SET(VERSION 0.1.68)
+SET(VERSION_MAJOR 0)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+
+
+set(CMAKE_SKIP_BUILD_RPATH true)
+
+#Verbose
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/comm )
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED security-server dlog elementary evas ecore appcore-efl ecore-x ail ecore-file pkgmgr-info pkgmgr-parser iniparser vconf)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+pkg_check_modules(libpkgs REQUIRED dbus-glib-1 dlog ail pkgmgr-info pkgmgr-parser iniparser security-server vconf)
+
+FOREACH(flag ${libpkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(pm_dir "${CMAKE_SOURCE_DIR}")
+SET(pm_inc_dir "${pm_dir}/include")
+SET(pm_c_src_dir "${pm_dir}/client/src")
+SET(pm_c_inc_dir "${pm_dir}/client/include")
+SET(pm_s_src_dir "${pm_dir}/server/src")
+SET(pm_s_inc_dir "${pm_dir}/server/include")
+SET(pm_t_inc_dir "${pm_dir}/types/include")
+
+## About debug
+SET(debug_type "-DPM_CONSOLE_USE") # for debug - use console window
+
+## Additional flag
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+##################
+## build comm libraries
+add_subdirectory(comm)
+add_subdirectory(tool)
+add_subdirectory(types)
+
+###################################################################################################
+## for libpkgmgr-client.so (library)
+SET(PKGMGR_CLIENT "pkgmgr-client")
+SET(libpkgmgr-client_SOURCES ${pm_c_src_dir}/pkgmgr-internal.c ${pm_c_src_dir}/pkgmgr.c ${pm_c_src_dir}/pkgmgr-dbinfo.c)
+SET(libpkgmgr-client_LDFLAGS " -module -avoid-version ")
+SET(libpkgmgr-client_CFLAGS " ${CFLAGS} -fPIC -I${pm_c_inc_dir} -I${pm_inc_dir} -I${pm_t_inc_dir} ${debug_type}")
+
+ADD_LIBRARY(${PKGMGR_CLIENT} SHARED ${libpkgmgr-client_SOURCES})
+SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES COMPILE_FLAGS "${libpkgmgr-client_CFLAGS}")
+TARGET_LINK_LIBRARIES(${PKGMGR_CLIENT} pkgmgr_installer_client pkgmgr_installer_status_broadcast_server pkgmgr-info ${libpkgs_LDFLAGS})
+###################################################################################################
+
+###################################################################################################
+## for pkgmgr-server (binary)
+SET(pkgmgr-server_SOURCES ${pm_s_src_dir}/pkgmgr-server.c ${pm_s_src_dir}/pm-queue.c)
+SET(pkgmgr-server_CFLAGS " -I. -I${pm_inc_dir} -I${pm_s_inc_dir} -I${pm_dir}/comm ${debug_type} -D_GNU_SOURCE ")
+SET(pkgmgr-server_LDFLAGS ${pkgs_LDFLAGS})
+
+ADD_EXECUTABLE(pkgmgr-server ${pkgmgr-server_SOURCES})
+TARGET_LINK_LIBRARIES(pkgmgr-server pkgmgr_installer pkgmgr_installer_pkg_mgr_server)
+TARGET_LINK_LIBRARIES(pkgmgr-server ${pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(pkgmgr-server PROPERTIES COMPILE_FLAGS "${pkgmgr-server_CFLAGS}")
+####################################################################################################
+
+CONFIGURE_FILE(pkgmgr.pc.in pkgmgr.pc @ONLY)
+IF(DEVICE_PROFILE STREQUAL "wearable")
+configure_file(com.samsung.slp.pkgmgr.service.wearable.in com.samsung.slp.pkgmgr.service @ONLY)
+ELSE()
+configure_file(com.samsung.slp.pkgmgr.service.mobile.in com.samsung.slp.pkgmgr.service @ONLY)
+ENDIF()
+configure_file(pkg_path.conf.in pkg_path.conf @ONLY)
+configure_file(710.pkgmgr.patch.sh.in 710.pkgmgr.patch.sh @ONLY)
+
+#INSTALL(FILES ${CMAKE_BINARY_DIR}/libpkgmgr-client.so DESTINATION lib)
+INSTALL(TARGETS ${PKGMGR_CLIENT} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/pkgmgr-server DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/client/include/package-manager.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/client/include/pkgmgr-dbinfo.h DESTINATION include)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/com.samsung.slp.pkgmgr.service DESTINATION ${PREFIX}/share/dbus-1/services/)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/slp-pkgmgr.service DESTINATION ${PREFIX}/lib/systemd/system/)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkg_path.conf DESTINATION ${PREFIX}/etc/package-manager/)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/queue_status DESTINATION etc/package-manager/server/)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/710.pkgmgr.patch.sh DESTINATION /etc/opt/upgrade/)
+
+####################################################################################################
+add_subdirectory(installers)
+# i18n
+add_subdirectory(po)
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
--- /dev/null
+#!/bin/sh
+export TET_INSTALL_HOST_PATH=/dts_fw/TETware
+export TET_INSTALL_TARGET_PATH=/dts_fw/TETware
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # local tetware path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/TETware
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+33 "INSPECT"
--- /dev/null
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/unit/tslist
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
--- /dev/null
+TET_OUTPUT_CAPTURE=False
--- /dev/null
+CC ?= gcc
+
+TARGETS = utc_ApplicationFW_pkgmgr_client_activate_func \
+ utc_ApplicationFW_pkgmgr_client_broadcast_status_func \
+ utc_ApplicationFW_pkgmgr_client_clear_user_data_func \
+ utc_ApplicationFW_pkgmgr_client_move_func \
+ utc_ApplicationFW_pkgmgr_client_deactivate_func \
+ utc_ApplicationFW_pkgmgr_client_free_func \
+ utc_ApplicationFW_pkgmgr_client_install_func \
+ utc_ApplicationFW_pkgmgr_client_listen_status_func \
+ utc_ApplicationFW_pkgmgr_client_new_func \
+ utc_ApplicationFW_pkgmgr_client_uninstall_func \
+ utc_ApplicationFW_pkgmgr_get_pkg_list_func \
+ utc_ApplicationFW_pkgmgr_info_free_func \
+ utc_ApplicationFW_pkgmgr_info_get_string_func \
+ utc_ApplicationFW_pkgmgr_info_new_from_file_func \
+ utc_ApplicationFW_pkgmgr_info_new_func \
+ utc_ApplicationFW_pkgmgr_installer_free_func \
+ utc_ApplicationFW_pkgmgr_installer_get_license_path_func \
+ utc_ApplicationFW_pkgmgr_installer_get_move_type_func \
+ utc_ApplicationFW_pkgmgr_installer_get_request_info_func \
+ utc_ApplicationFW_pkgmgr_installer_get_request_type_func \
+ utc_ApplicationFW_pkgmgr_installer_get_session_id_func \
+ utc_ApplicationFW_pkgmgr_installer_is_quiet_func \
+ utc_ApplicationFW_pkgmgr_installer_new_func \
+ utc_ApplicationFW_pkgmgr_installer_receive_request_func \
+ utc_ApplicationFW_pkgmgr_installer_send_signal_func
+
+PKGS = glib-2.0 dlog pkgmgr pkgmgr-installer
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+LDFLAGS += -L/usr/lib -lpthread
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TARGETS)
--- /dev/null
+#!/bin/sh
+
+TMPSTR=$0
+SCRIPT=${TMPSTR##*/}
+
+if [ $# -lt 2 ]; then
+ echo "Usage) $SCRIPT module_name api_name"
+ exit 1
+fi
+
+MODULE=$1
+API=$2
+TEMPLATE=utc_MODULE_API_func.c.in
+TESTCASE=utc_${MODULE}_${API}_func
+
+sed -e '
+ s^@API@^'"$API"'^g
+ s^@MODULE@^'"$MODULE"'^g
+ ' $TEMPLATE > $TESTCASE.c
+
+if [ ! -e "$TESTCASE.c" ]; then
+ echo "Failed"
+ exit 1
+fi
+echo "Testcase file is $TESTCASE.c"
+echo "Done"
+echo "please put \"$TESTCASE\" as Target in Makefile"
+echo "please put \"/unit/$TESTCASE\" in tslist"
--- /dev/null
+/unit/utc_ApplicationFW_pkgmgr_info_new_func
+/unit/utc_ApplicationFW_pkgmgr_info_free_func
+/unit/utc_ApplicationFW_pkgmgr_get_pkg_list_func
+/unit/utc_ApplicationFW_pkgmgr_info_new_from_file_func
+/unit/utc_ApplicationFW_pkgmgr_info_get_string_func
+/unit/utc_ApplicationFW_pkgmgr_client_listen_status_func
+/unit/utc_ApplicationFW_pkgmgr_client_broadcast_status_func
+/unit/utc_ApplicationFW_pkgmgr_client_new_func
+/unit/utc_ApplicationFW_pkgmgr_client_free_func
+/unit/utc_ApplicationFW_pkgmgr_client_deactivate_func
+/unit/utc_ApplicationFW_pkgmgr_client_activate_func
+/unit/utc_ApplicationFW_pkgmgr_client_install_func
+/unit/utc_ApplicationFW_pkgmgr_client_move_func
+/unit/utc_ApplicationFW_pkgmgr_client_clear_user_data_func
+/unit/utc_ApplicationFW_pkgmgr_client_uninstall_func
+/unit/utc_ApplicationFW_pkgmgr_installer_free_func
+/unit/utc_ApplicationFW_pkgmgr_installer_get_license_path_func
+/unit/utc_ApplicationFW_pkgmgr_installer_get_move_type_func
+/unit/utc_ApplicationFW_pkgmgr_installer_get_request_info_func
+/unit/utc_ApplicationFW_pkgmgr_installer_get_request_type_func
+/unit/utc_ApplicationFW_pkgmgr_installer_get_session_id_func
+/unit/utc_ApplicationFW_pkgmgr_installer_is_quiet_func
+/unit/utc_ApplicationFW_pkgmgr_installer_new_func
+/unit/utc_ApplicationFW_pkgmgr_installer_receive_request_func
+/unit/utc_ApplicationFW_pkgmgr_installer_send_signal_func
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_activate_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_activate_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_activate_func_03(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_activate_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_activate_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_activate_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_activate()
+ */
+static void utc_ApplicationFW_pkgmgr_client_activate_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_activate(pc, "rpm", "com.samsung.calculator");
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_client_activate() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_activate()
+ */
+static void utc_ApplicationFW_pkgmgr_client_activate_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_activate(pc, "rpm", NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_activate() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_activate()
+ */
+static void utc_ApplicationFW_pkgmgr_client_activate_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_activate(NULL, "rpm", "com.samsung.memo");
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_activate() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_03(void);
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_04(void);
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_05(void);
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_06(void);
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_broadcast_status_func_01,
+ POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_broadcast_status_func_02,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_broadcast_status_func_03,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_broadcast_status_func_04,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_broadcast_status_func_05,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_broadcast_status_func_06,
+ NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data)
+{
+ return 0;
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_broadcast_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_BROADCAST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_broadcast_status(pc, "rpm", "com.samsung.calculator",
+ "end", "success");
+ if (r != PKGMGR_R_OK) {
+ tet_infoline
+ ("pkgmgr_client_broadcast_status()"
+ " failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_broadcast_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_BROADCAST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_broadcast_status(pc, "rpm", NULL, "end", "success");
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_broadcast_status()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_broadcast_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_BROADCAST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_broadcast_status(pc, NULL, "com.samsung.calculator",
+ "end", "success");
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_broadcast_status()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 03 of pkgmgr_client_broadcast_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_04(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_BROADCAST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_broadcast_status(pc, "rpm", "com.samsung.calculator",
+ NULL, "success");
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_broadcast_status()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 04 of pkgmgr_client_broadcast_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_05(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_BROADCAST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_broadcast_status(pc, "rpm", "com.samsung.calculator",
+ "end", NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_broadcast_status()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 05 of pkgmgr_client_broadcast_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_broadcast_status_func_06(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_broadcast_status(NULL, "rpm",
+ "com.samsung.calculator", "end",
+ "success");
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_broadcast_status()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_clear_user_data_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_clear_user_data_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_clear_user_data_func_03(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_clear_user_data_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_clear_user_data_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_clear_user_data_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_clear_user_data()
+ */
+static void utc_ApplicationFW_pkgmgr_client_clear_user_data_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_clear_user_data(pc, "rpm", "com.samsung.calendar", PM_QUIET);
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_client_clear_user_data() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_clear_user_data()
+ */
+static void utc_ApplicationFW_pkgmgr_client_clear_user_data_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_clear_user_data(pc, "rpm", NULL, PM_QUIET);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_clear_user_data() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_clear_user_data()
+ */
+static void utc_ApplicationFW_pkgmgr_client_clear_user_data_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_clear_user_data(NULL, "rpm", "com.samsung.calendar", PM_QUIET);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_clear_user_data() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_deactivate_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_deactivate_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_deactivate_func_03(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_deactivate_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_deactivate_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_deactivate_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_deactivate()
+ */
+static void utc_ApplicationFW_pkgmgr_client_deactivate_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_deactivate(pc, "rpm", "com.samsung.calculator");
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_client_deactivate() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_deactivate()
+ */
+static void utc_ApplicationFW_pkgmgr_client_deactivate_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_deactivate(pc, "rpm", NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_deactivate() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_deactivate()
+ */
+static void utc_ApplicationFW_pkgmgr_client_deactivate_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_deactivate(NULL, "rpm", "com.samsung.calculator");
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_deactivate() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_free_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_free_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_free_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_free_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_free()
+ */
+static void utc_ApplicationFW_pkgmgr_client_free_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_free(pc);
+ if (r != PKGMGR_R_OK) {
+ tet_infoline
+ ("pkgmgr_client_free() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_client_free()
+ */
+static void utc_ApplicationFW_pkgmgr_client_free_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ r = pkgmgr_client_free(pc);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_free() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_install_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_install_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_install_func_03(void);
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_install_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_install_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_install_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data)
+{
+ return 0;
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_install()
+ */
+static void utc_ApplicationFW_pkgmgr_client_install_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_install(pc, "rpm", NULL,
+ "/mnt/nfs/slp-pkgmgr/TC/com.samsung.hello-0.0.1-0.armv7l.rpm",
+ NULL, PM_QUIET, event_cb, NULL);
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_client_install() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_install()
+ */
+static void utc_ApplicationFW_pkgmgr_client_install_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_install(pc, "rpm", NULL, NULL, NULL, PM_QUIET,
+ event_cb, NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_install() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_install()
+ */
+static void utc_ApplicationFW_pkgmgr_client_install_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_install(NULL, "rpm", NULL,
+ "/mnt/nfs/slp-pkgmgr/TC/com.samsung.hello-0.0.1-0.armv7l.rpm",
+ NULL, PM_QUIET, event_cb, NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_install() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_listen_status_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_listen_status_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_listen_status_func_03(void);
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_listen_status_func_01,
+ POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_listen_status_func_02,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_listen_status_func_03,
+ NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data)
+{
+ return 0;
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_listen_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_listen_status_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_LISTENING);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_listen_status(pc, event_cb, NULL);
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_client_listen_status()"
+ " failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_listen_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_listen_status_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_LISTENING);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_listen_status(pc, NULL, NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_listen_status()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_listen_status()
+ */
+static void utc_ApplicationFW_pkgmgr_client_listen_status_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_listen_status(NULL, event_cb, NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_listen_status()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_move_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_move_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_move_func_03(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_move_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_move_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_move_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_move()
+ */
+static void utc_ApplicationFW_pkgmgr_client_move_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_move(pc, "rpm", "com.samsung.calculator", PM_MOVE_TO_SDCARD, PM_QUIET);
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_client_move() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_move()
+ */
+static void utc_ApplicationFW_pkgmgr_client_move_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_move(pc, "rpm", NULL, PM_MOVE_TO_SDCARD, PM_QUIET);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_move() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_move()
+ */
+static void utc_ApplicationFW_pkgmgr_client_move_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_move(NULL, "rpm", "com.samsung.calculator", PM_MOVE_TO_SDCARD, PM_QUIET);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_move() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_new_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_new_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_new_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_new_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_new()
+ */
+static void utc_ApplicationFW_pkgmgr_client_new_func_01(void)
+{
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_infoline
+ ("pkgmgr_client_new() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ pkgmgr_client_free(pc);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_client_new()
+ */
+static void utc_ApplicationFW_pkgmgr_client_new_func_02(void)
+{
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(-1);
+ if (pc) {
+ tet_infoline
+ ("pkgmgr_client_new() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_client_uninstall_func_01(void);
+static void utc_ApplicationFW_pkgmgr_client_uninstall_func_02(void);
+static void utc_ApplicationFW_pkgmgr_client_uninstall_func_03(void);
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_client_uninstall_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_uninstall_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_client_uninstall_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int event_cb(int req_id, const char *pkg_type, const char *pkg_name,
+ const char *key, const char *val, const void *pmsg,
+ void *data)
+{
+ return 0;
+}
+
+/**
+ * @brief Positive test case of pkgmgr_client_uninstall()
+ */
+static void utc_ApplicationFW_pkgmgr_client_uninstall_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_uninstall(pc, "rpm", "com.samsung.hello",
+ PM_QUIET, event_cb, NULL);
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_client_uninstall() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_client_uninstall()
+ */
+static void utc_ApplicationFW_pkgmgr_client_uninstall_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_client *pc = NULL;
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (!pc) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_client_uninstall(pc, "rpm", NULL, PM_QUIET, event_cb, NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_uninstall() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ tet_result(TET_PASS);
+}
+
+
+/**
+ * @brief Negative test case 02 of pkgmgr_client_uninstall()
+ */
+static void utc_ApplicationFW_pkgmgr_client_uninstall_func_03(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_client_uninstall(NULL, "rpm", "com.samsung.hello", PM_QUIET,
+ event_cb, NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_client_uninstall() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_get_pkg_list_func_01(void);
+static void utc_ApplicationFW_pkgmgr_get_pkg_list_func_02(void);
+static int iter_fn(const char *pkg_type, const char *pkg_name,
+ const char *version, void *data);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_get_pkg_list_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_get_pkg_list_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int iter_fn(const char *pkg_type, const char *pkg_name,
+ const char *version, void *data)
+{
+ return 0;
+}
+
+/**
+ * @brief Positive test case of pkgmgr_get_pkg_list()
+ */
+static void utc_ApplicationFW_pkgmgr_get_pkg_list_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_get_pkg_list(iter_fn, NULL);
+ if (r != PKGMGR_R_OK) {
+ tet_infoline
+ ("pkgmgr_get_pkg_list() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_get_pkg_list()
+ */
+static void utc_ApplicationFW_pkgmgr_get_pkg_list_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ r = pkgmgr_get_pkg_list(NULL, NULL);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline
+ ("pkgmgr_get_pkg_list() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_info_free_func_01(void);
+static void utc_ApplicationFW_pkgmgr_info_free_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_info_free_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_info_free_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_info_free()
+ */
+static void utc_ApplicationFW_pkgmgr_info_free_func_01(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_info *info = NULL;
+ info = pkgmgr_info_new("rpm", "com.samsung.calculator");
+ if (!info) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_info_free(info);
+ if (r != PKGMGR_R_OK) {
+ tet_infoline("pkgmgr_info_free() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_info_free()
+ */
+static void utc_ApplicationFW_pkgmgr_info_free_func_02(void)
+{
+ int r = PKGMGR_R_ERROR;
+ pkgmgr_info *info = NULL;
+ r = pkgmgr_info_free(info);
+ if (r != PKGMGR_R_EINVAL) {
+ tet_infoline("pkgmgr_info_free() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_info_get_string_func_01(void);
+static void utc_ApplicationFW_pkgmgr_info_get_string_func_02(void);
+static void utc_ApplicationFW_pkgmgr_info_get_string_func_03(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_info_get_string_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_info_get_string_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_info_get_string_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_info_get_string()
+ */
+static void utc_ApplicationFW_pkgmgr_info_get_string_func_01(void)
+{
+ pkgmgr_info *info = NULL;
+ char *str = NULL;
+ info = pkgmgr_info_new("rpm", "com.samsung.calculator");
+ if (!info) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ str = pkgmgr_info_get_string(info, "pkg_name");
+ if (!str) {
+ tet_infoline
+ ("pkgmgr_info_get_string() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ pkgmgr_info_free(info);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_info_get_string()
+ */
+static void utc_ApplicationFW_pkgmgr_info_get_string_func_02(void)
+{
+ char *str = NULL;
+ str = pkgmgr_info_get_string(NULL, "pkg_name");
+ if (str) {
+ tet_infoline
+ ("pkgmgr_info_get_string() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of pkgmgr_info_get_string()
+ */
+static void utc_ApplicationFW_pkgmgr_info_get_string_func_03(void)
+{
+ pkgmgr_info *info = NULL;
+ char *str = NULL;
+ info = pkgmgr_info_new("rpm", "com.samsung.calculator");
+ if (!info) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ str = pkgmgr_info_get_string(info, NULL);
+ if (str) {
+ tet_infoline
+ ("pkgmgr_info_get_string() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ pkgmgr_info_free(info);
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_info_new_from_file_func_01(void);
+static void utc_ApplicationFW_pkgmgr_info_new_from_file_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_info_new_from_file_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_info_new_from_file_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_info_new_from_file()
+ */
+static void utc_ApplicationFW_pkgmgr_info_new_from_file_func_01(void)
+{
+ pkgmgr_info *info = NULL;
+ info =
+ pkgmgr_info_new_from_file("rpm",
+ "/mnt/nfs/slp-pkgmgr/TC/com.samsung.hello-0.0.1-0.armv7l.rpm");
+ if (!info) {
+ tet_infoline
+ ("pkgmgr_info_new_from_file()"
+ " failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ pkgmgr_info_free(info);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_info_new_from_file()
+ */
+static void utc_ApplicationFW_pkgmgr_info_new_from_file_func_02(void)
+{
+ pkgmgr_info *info = NULL;
+ info = pkgmgr_info_new_from_file("rpm", NULL);
+ if (info) {
+ tet_infoline
+ ("pkgmgr_info_new_from_file()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_info_new_func_01(void);
+static void utc_ApplicationFW_pkgmgr_info_new_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_info_new_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_info_new_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_info_new()
+ */
+static void utc_ApplicationFW_pkgmgr_info_new_func_01(void)
+{
+ pkgmgr_info *info = NULL;
+ info = pkgmgr_info_new("rpm", "com.samsung.calculator");
+ if (!info) {
+ tet_infoline("pkgmgr_info_new() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ pkgmgr_info_free(info);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of pkgmgr_info_new()
+ */
+static void utc_ApplicationFW_pkgmgr_info_new_func_02(void)
+{
+ pkgmgr_info *info = NULL;
+ info = pkgmgr_info_new("rpm", NULL);
+ if (info) {
+ tet_infoline("pkgmgr_info_new() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_free_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_free_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_free_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_free_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_free()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_free_func_01(void)
+{
+ int r = -1;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_free(pi);
+ if (r != 0) {
+ tet_infoline
+ ("pkgmgr_installer_free() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_free()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_free_func_02(void)
+{
+ int r = -1;
+ r = pkgmgr_installer_free(NULL);
+ if (r == 0) {
+ tet_infoline
+ ("pkgmgr_installer_free() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_get_license_path_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_get_license_path_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-l", "license", "-d", "com.samsung.hello", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_get_license_path_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_get_license_path_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_get_license_path()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_license_path_func_01(void)
+{
+ int r = -1;
+ char *val = NULL;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ val = pkgmgr_installer_get_license_path(pi);
+ if (val == NULL) {
+ tet_infoline
+ ("pkgmgr_installer_get_license_path() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_get_license_path()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_license_path_func_02(void)
+{
+ char *val = NULL;
+ val = pkgmgr_installer_get_license_path(NULL);
+ if (val) {
+ tet_infoline
+ ("pkgmgr_installer_get_license_path() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_get_move_type_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_get_move_type_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-m", "com.samsung.hello", "-t", "0", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_get_move_type_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_get_move_type_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_get_move_type()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_move_type_func_01(void)
+{
+ int r = -1;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_get_move_type(pi);
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_installer_get_move_type() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_get_move_type()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_move_type_func_02(void)
+{
+ int r = -1;
+ r = pkgmgr_installer_get_move_type(NULL);
+ if (r) {
+ tet_infoline
+ ("pkgmgr_installer_get_move_type() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_get_request_info_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_get_request_info_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-d", "com.samsung.hello", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_get_request_info_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_get_request_info_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_get_request_info()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_request_info_func_01(void)
+{
+ int r = -1;
+ char *val = NULL;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ val = pkgmgr_installer_get_request_info(pi);
+ if (val == NULL) {
+ tet_infoline
+ ("pkgmgr_installer_get_request_info() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_get_request_info()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_request_info_func_02(void)
+{
+ char *val = NULL;
+ val = pkgmgr_installer_get_request_info(NULL);
+ if (val) {
+ tet_infoline
+ ("pkgmgr_installer_get_request_info() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_get_request_type_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_get_request_type_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-d", "com.samsung.hello", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_get_request_type_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_get_request_type_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_get_request_type()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_request_type_func_01(void)
+{
+ int r = -1;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_get_request_type(pi);
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_installer_get_request_type() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_get_request_type()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_request_type_func_02(void)
+{
+ int r = -1;
+ r = pkgmgr_installer_get_request_type(NULL);
+ if (r > 0) {
+ tet_infoline
+ ("pkgmgr_installer_get_request_type() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_get_session_id_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_get_session_id_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-d", "com.samsung.hello", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_get_session_id_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_get_session_id_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_get_session_id()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_session_id_func_01(void)
+{
+ int r = -1;
+ char *val = NULL;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ val = pkgmgr_installer_get_session_id(pi);
+ if (val == NULL) {
+ tet_infoline
+ ("pkgmgr_installer_get_session_id() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_get_session_id()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_get_session_id_func_02(void)
+{
+ char *val = NULL;
+ val = pkgmgr_installer_get_session_id(NULL);
+ if (val) {
+ tet_infoline
+ ("pkgmgr_installer_get_session_id() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_is_quiet_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_is_quiet_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-d", "com.samsung.hello", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_is_quiet_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_is_quiet_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_is_quiet()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_is_quiet_func_01(void)
+{
+ int r = -1;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_is_quiet(pi);
+ if (r != 0) {
+ tet_infoline
+ ("pkgmgr_installer_is_quiet() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_is_quiet()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_is_quiet_func_02(void)
+{
+ int r = -1;
+ r = pkgmgr_installer_is_quiet(NULL);
+ if (r != 0) {
+ tet_infoline
+ ("pkgmgr_installer_is_quiet() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_new_func_01(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_new_func_01, POSITIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_new()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_new_func_01(void)
+{
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_infoline
+ ("pkgmgr_installer_new() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_receive_request_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_receive_request_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-d", "com.samsung.hello", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_receive_request_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_receive_request_func_02, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_receive_request()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_receive_request_func_01(void)
+{
+ int r = -1;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_infoline
+ ("pkgmgr_installer_receive_request() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_receive_request()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_receive_request_func_02(void)
+{
+ int r = -1;
+ r = pkgmgr_installer_receive_request(NULL, 0 , NULL);
+ if (r == 0) {
+ tet_infoline
+ ("pkgmgr_installer_receive_request() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <tet_api.h>
+#include <package-manager.h>
+#include <pkgmgr_installer.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_pkgmgr_installer_send_signal_func_01(void);
+static void utc_ApplicationFW_pkgmgr_installer_send_signal_func_02(void);
+static void utc_ApplicationFW_pkgmgr_installer_send_signal_func_03(void);
+
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+const char *argv[] = { "/usr/bin/rpm-backend", "-k", "key-id", "-d", "com.samsung.hello", NULL };
+int argc = 5;
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_pkgmgr_installer_send_signal_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_send_signal_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_pkgmgr_installer_send_signal_func_03, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of pkgmgr_installer_send_signal()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_send_signal_func_01(void)
+{
+ int r = -1;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_receive_request(pi, argc, argv);
+ if (r != 0) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_send_signal(pi, "rpm", "com.samsung.hello", "install_percent", "100");
+ if (r < 0) {
+ tet_infoline
+ ("pkgmgr_installer_send_signal() failed in positive test case");
+ tet_result(TET_FAIL);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+ pkgmgr_installer_free(pi);
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_send_signal()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_send_signal_func_02(void)
+{
+ int r = -1;
+ r = pkgmgr_installer_send_signal(NULL, "rpm", "com.samsung.hello", "install_percent", "100");
+ if (r == 0) {
+ tet_infoline
+ ("pkgmgr_installer_send_signal() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of pkgmgr_installer_send_signal()
+ */
+static void utc_ApplicationFW_pkgmgr_installer_send_signal_func_03(void)
+{
+ int r = -1;
+ pkgmgr_installer *pi = NULL;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ tet_result(TET_UNINITIATED);
+ return;
+ }
+ r = pkgmgr_installer_send_signal(pi, NULL, NULL, "install_percent", "100");
+ if (r == 0) {
+ tet_infoline
+ ("pkgmgr_installer_send_signal() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+#include <tet_api.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_@MODULE@_@API@_func_01(void);
+static void utc_@MODULE@_@API@_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX },
+ { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX },
+};
+
+static void startup(void)
+{
+ int r;
+/*
+ char *err;
+ r = initailze...;
+ if (r) {
+ err = "Error message.......";
+ tet_infoline(err);
+ tet_delete(POSITIVE_TC_IDX, err);
+ tet_delete(NEGATIVE_TC_IDX, err);
+ }
+*/
+
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+ int r = 0;
+
+/*
+ r = @API@(...);
+*/
+ if (r) {
+ tet_infoline("@API@() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init @API@()
+ */
+static void utc_@MODULE@_@API@_func_02(void)
+{
+ int r = 0;
+
+/*
+ r = @API@(...);
+*/
+ if (!r) {
+ tet_infoline("@API@() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+
+
+
+
+/**
+ * @file package-manager.h
+ * @author Sewook Park <sewook7.park@samsung.com>
+ * @version 0.1
+ * @brief This file declares API of slp-pkgmgr library
+ *
+ * @addtogroup APPLICATION_FRAMEWORK
+ * @{
+ *
+ * @defgroup PackageManager
+ * @section Header to use them:
+ * @code
+ * #include "package-manager.h"
+ * @endcode
+ *
+ * @addtogroup PackageManager
+ * @{
+ */
+
+#ifndef __PKG_MANAGER_H__
+#define __PKG_MANAGER_H__
+
+#include <errno.h>
+#include <stdbool.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+/**
+ * @mainpage
+ *
+ * This is package manager
+ *
+ * Packaeg manager is used to install/uninstall the packages.\n
+ * package includes dpkg, java, widget, etc. and it can be added\n
+ * Security is considered on current package manager\n
+ *
+ */
+
+/**
+ * @file package-manager.h
+ * @brief Package Manager header
+ *
+ * Generated by Sewook Park <sewook7.park@samsung.com>
+ */
+
+
+
+/**
+ * @addtogroup PackageManager
+ * @{
+ */
+
+/**
+ * @brief pkgmgr info types.
+ */
+#define PKGMGR_INFO_STR_PKGTYPE "pkg_type"
+#define PKGMGR_INFO_STR_PKGNAME "pkg_name"
+#define PKGMGR_INFO_STR_VERSION "version"
+#define PKGMGR_INFO_STR_INSTALLED_SIZE "installed_size"
+#define PKGMGR_INFO_STR_DATA_SIZE "data_size"
+#define PKGMGR_INFO_STR_APP_SIZE "app_size"
+#define PKGMGR_INFO_STR_INSTALLED_TIME "installed_time"
+
+/**
+ * @brief listening status type in pkgmgr.
+ */
+#define PKGMGR_CLIENT_STATUS_ALL 0x00
+#define PKGMGR_CLIENT_STATUS_INSTALL 0x01
+#define PKGMGR_CLIENT_STATUS_UNINSTALL 0x02
+#define PKGMGR_CLIENT_STATUS_UPGRADE 0x04
+#define PKGMGR_CLIENT_STATUS_MOVE 0x08
+#define PKGMGR_CLIENT_STATUS_CLEAR_DATA 0x10
+#define PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS 0x20
+#define PKGMGR_CLIENT_STATUS_GET_SIZE 0x40
+/** @} */
+
+/* 1 -100 : Package command errors */
+/* 101-120 : reserved for Core installer */
+/* 121-140 : reserved for Web installer */
+/* 141-160 : reserved for Native installer */
+#define PKGCMD_ERR_PACKAGE_NOT_FOUND 1
+#define PKGCMD_ERR_PACKAGE_INVALID 2
+#define PKGCMD_ERR_PACKAGE_LOWER_VERSION 3
+#define PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND 4
+#define PKGCMD_ERR_MANIFEST_NOT_FOUND 11
+#define PKGCMD_ERR_MANIFEST_INVALID 12
+#define PKGCMD_ERR_CONFIG_NOT_FOUND 13
+#define PKGCMD_ERR_CONFIG_INVALID 14
+#define PKGCMD_ERR_SIGNATURE_NOT_FOUND 21
+#define PKGCMD_ERR_SIGNATURE_INVALID 22
+#define PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED 23
+#define PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND 31
+#define PKGCMD_ERR_CERTIFICATE_INVALID 32
+#define PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED 33
+#define PKGCMD_ERR_CERTIFICATE_EXPIRED 34
+#define PKGCMD_ERR_INVALID_PRIVILEGE 41
+#define PKGCMD_ERR_MENU_ICON_NOT_FOUND 51
+#define PKGCMD_ERR_FATAL_ERROR 61
+#define PKGCMD_ERR_OUT_OF_STORAGE 62
+#define PKGCMD_ERR_OUT_OF_MEMORY 63
+#define PKGCMD_ERR_ARGUMENT_INVALID 64
+
+#define PKGCMD_ERR_PACKAGE_NOT_FOUND_STR "PACKAGE_NOT_FOUND"
+#define PKGCMD_ERR_PACKAGE_INVALID_STR "PACKAGE_INVALID"
+#define PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR "PACKAGE_LOWER_VERSION"
+#define PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR "PACKAGE_EXECUTABLE_NOT_FOUND"
+#define PKGCMD_ERR_MANIFEST_NOT_FOUND_STR "MANIFEST_NOT_FOUND"
+#define PKGCMD_ERR_MANIFEST_INVALID_STR "MANIFEST_INVALID"
+#define PKGCMD_ERR_CONFIG_NOT_FOUND_STR "CONFIG_NOT_FOUND"
+#define PKGCMD_ERR_CONFIG_INVALID_STR "CONFIG_INVALID"
+#define PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR "SIGNATURE_NOT_FOUND"
+#define PKGCMD_ERR_SIGNATURE_INVALID_STR "SIGNATURE_INVALID"
+#define PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR "SIGNATURE_VERIFICATION_FAILED"
+#define PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR "ROOT_CERTIFICATE_NOT_FOUND"
+#define PKGCMD_ERR_CERTIFICATE_INVALID_STR "CERTIFICATE_INVALID"
+#define PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR "CERTIFICATE_CHAIN_VERIFICATION_FAILED"
+#define PKGCMD_ERR_CERTIFICATE_EXPIRED_STR "CERTIFICATE_EXPIRED"
+#define PKGCMD_ERR_INVALID_PRIVILEGE_STR "INVALID_PRIVILEGE"
+#define PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR "MENU_ICON_NOT_FOUND"
+#define PKGCMD_ERR_FATAL_ERROR_STR "FATAL_ERROR"
+#define PKGCMD_ERR_OUT_OF_STORAGE_STR "OUT_OF_STORAGE"
+#define PKGCMD_ERR_OUT_OF_MEMORY_STR "OUT_OF_MEMORY"
+#define PKGCMD_ERR_ARGUMENT_INVALID_STR "ARGUMENT_INVALID"
+#define PKGCMD_ERR_UNKNOWN_STR "Unknown Error"
+
+#define PKG_SIZE_INFO_FILE "/tmp/pkgmgr_size_info.txt"
+#define PKG_SIZE_INFO_PATH "/tmp"
+
+/**
+ * @brief Return values in pkgmgr.
+ */
+typedef enum _pkgmgr_return_val {
+ PKGMGR_R_ETIMEOUT = -4, /**< Timeout */
+ PKGMGR_R_EINVAL = -3, /**< Invalid argument */
+ PKGMGR_R_ECOMM = -2, /**< Comunication Error */
+ PKGMGR_R_ERROR = -1, /**< General error */
+ PKGMGR_R_OK = 0 /**< General success */
+} pkgmgr_return_val;
+/** @} */
+
+/**
+ * @defgroup pkg_operate APIs to install /uninstall / activate application
+ * @ingroup pkgmgr
+ * @brief
+ * APIs to install /uninstall / activate application
+ * - Install application using application package filepath
+ * - Uninstall application using application package name
+ * - Activate application using application package name
+ *
+ */
+
+
+/**
+ * @addtogroup pkg_operate
+ * @{
+ */
+
+typedef void* pkgmgr_pkginfo_h;
+typedef void* pkgmgr_appinfo_h;
+typedef void* pkgmgr_certinfo_h;
+
+typedef int (*pkgmgr_iter_fn)(const char* pkg_type, const char* pkgid,
+ const char* version, void *data);
+
+typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
+ const char *pkgid, const char *key,
+ const char *val, const void *pmsg, void *data);
+
+typedef int (*pkgmgr_info_pkg_list_cb ) (const pkgmgr_pkginfo_h handle,
+ void *user_data);
+
+typedef int (*pkgmgr_info_app_list_cb ) (const pkgmgr_appinfo_h handle,
+ void *user_data);
+
+typedef int (*pkgmgr_info_app_category_list_cb ) (const char *category_name,
+ void *user_data);
+
+
+typedef void pkgmgr_client;
+
+typedef void pkgmgr_info;
+
+typedef enum {
+ PC_REQUEST = 0,
+ PC_LISTENING,
+ PC_BROADCAST,
+}client_type;
+
+typedef enum {
+ PM_DEFAULT,
+ PM_QUIET
+}pkgmgr_mode;
+
+typedef enum {
+ PM_INSTALL_LOCATION_AUTO = 0,
+ PM_INSTALL_LOCATION_INTERNAL_ONLY,
+ PM_INSTALL_LOCATION_PREFER_EXTERNAL,
+}pkgmgr_install_location;
+
+typedef enum {
+ PM_HWACCELERATION_NOT_USE_GL = 0,
+ PM_HWACCELERATION_USE_GL = 1,
+ PM_HWACCELERATION_USE_SYSTEM_SETTING = 2,
+}pkgmgr_hwacceleration_type;
+
+typedef enum {
+ PM_ALL_APP = 0,
+ PM_UI_APP,
+ PM_SVC_APP
+}pkgmgr_app_component;
+
+typedef enum {
+ PM_MOVE_TO_INTERNAL = 0,
+ PM_MOVE_TO_SDCARD = 1,
+}pkgmgr_move_type;
+
+typedef enum {
+ PM_INTERNAL_STORAGE = 0,
+ PM_EXTERNAL_STORAGE = 1,
+}pkgmgr_installed_storage;
+
+typedef enum {
+ PM_AUTHOR_ROOT_CERT = 0,
+ PM_AUTHOR_INTERMEDIATE_CERT = 1,
+ PM_AUTHOR_SIGNER_CERT = 2,
+ PM_DISTRIBUTOR_ROOT_CERT = 3,
+ PM_DISTRIBUTOR_INTERMEDIATE_CERT = 4,
+ PM_DISTRIBUTOR_SIGNER_CERT = 5,
+ PM_DISTRIBUTOR2_ROOT_CERT = 6,
+ PM_DISTRIBUTOR2_INTERMEDIATE_CERT = 7,
+ PM_DISTRIBUTOR2_SIGNER_CERT = 8,
+}pkgmgr_cert_type;
+
+typedef enum {
+ PM_REQUEST_CSC = 0,
+ PM_REQUEST_MOVE = 1,
+ PM_REQUEST_GET_SIZE = 2,
+ PM_REQUEST_KILL_APP = 3,
+ PM_REQUEST_CHECK_APP = 4,
+ PM_REQUEST_MAX
+}pkgmgr_request_service_type;
+
+typedef enum {
+ PM_GET_TOTAL_SIZE= 0,
+ PM_GET_DATA_SIZE = 1,
+ PM_GET_ALL_PKGS = 2,
+ PM_GET_SIZE_INFO = 3,
+ PM_GET_TOTAL_AND_DATA = 4,
+ PM_GET_SIZE_FILE = 5,
+ PM_GET_MAX
+}pkgmgr_getsize_type;
+
+/**
+ * @brief This API creates pkgmgr client.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] ctype client type - PC_REQUEST, PC_LISTENING, PC_BROADCAST
+ * @return pkgmgr_client object
+ * @retval NULL on failure creating an object
+*/
+pkgmgr_client *pkgmgr_client_new(client_type ctype);
+
+/**
+ * @brief This API deletes pkgmgr client.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @return Operation result;
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ERROR internal error
+*/
+int pkgmgr_client_free(pkgmgr_client *pc);
+
+/**
+ * @brief This API installs package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] descriptor_path full path that descriptor is located
+ * @param[in] pkg_path full path that package file is located
+ * @param[in] optional_file optional file which is used for installation
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_install(pkgmgr_client *pc, const char *pkg_type,
+ const char *descriptor_path, const char *pkg_path,
+ const char *optional_file, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data);
+
+/**
+ * @brief This API reinstalls package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkg_path full path that package file is located
+ * @param[in] optional_file optional file which is used for installation
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_reinstall(pkgmgr_client *pc, const char *pkg_type, const char *pkgid,
+ const char *optional_file, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data);
+
+/**
+ * @brief This API uninstalls package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0), error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data);
+
+/**
+ * @brief This API moves installed package to SD card or vice versa.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid application package id
+ * @param[in] move_type PM_MOVE_TO_INTERNAL or PM_MOVE_TO_SDCARD
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ERROR general error
+*/
+int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_type move_type,
+ pkgmgr_handler event_cb, void *data);
+
+/**
+ * @brief This API activates package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_activate(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid);
+
+/**
+ * @brief This API deactivates package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid);
+
+/**
+ * @brief This API activates package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] appid applicaiton id
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_activate_app(pkgmgr_client *pc, const char *appid);
+
+/**
+ * @brief This API activates package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] appid applicaiton id
+ * @param[in] argv argument vector
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[]);
+
+/**
+ * @brief This API deactivates package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] appid applicaiton id
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid);
+
+/**
+ * @brief This API deletes application's private data.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @param[in] mode installation mode - PM_DEFAULT, PM_QUIET
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
+ const char *appid, pkgmgr_mode mode);
+
+/**
+ * @brief This API set status type to listen for the pkgmgr's broadcasting
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] status_type status type to listen
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+*/
+int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type);
+
+/**
+ * @brief This API request to listen the pkgmgr's broadcasting
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+*/
+int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
+ void *data);
+
+/**
+ * @brief This API broadcasts pkgmgr's status
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @param[in] key key to broadcast
+ * @param[in] val value to broadcast
+ * @return 0 if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+*/
+int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid, const char *key,
+ const char *val);
+
+/**
+ * @brief This API gets the package's information.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkg_path package file path to get infomation
+ * @return package entry pointer if success, NULL if fail\n
+*/
+pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path);
+
+/**
+ * @brief This API get package information value
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkg_info pointer for package info entry
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info);
+
+/**
+ * @brief This API requests service
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] service_type pkgmgr_request_service_type
+ * @param[in] service_mode mode which is used for addtional mode selection
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkg_type package type
+ * @param[in] pkgid package id
+ * @param[in] custom_info custom information which is used for addtional information
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode,
+ pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
+ const char *custom_info, pkgmgr_handler event_cb, void *data);
+
+/**
+ * @brief This API requests service
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_request_size_info(void);
+
+/**
+ * @brief This API get package size
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pc pkgmgr_client
+ * @param[in] pkgid package id
+ * @param[in] get_type type for pkgmgr client request to get package size
+ * @param[in] event_cb user callback
+ * @param[in] data user data
+ * @return request_id (>0) if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ECOMM communication error
+*/
+int pkgmgr_client_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data);
+
+int pkgmgr_client_enable_pkg(const char *pkgid);
+int pkgmgr_client_disable_pkg(const char *pkgid);
+
+/**
+ * @brief This API provides package list
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] iter_fn iteration function for list
+ * @param[in] data user data
+ * @return 0 if success, error code(<0) if fail\n
+ * @retval PKGMGR_R_OK success
+ * @retval PKGMGR_R_EINVAL invalid argument
+ * @retval PKGMGR_R_ERROR internal error
+*/
+int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data);
+/** @} */
+
+/**
+ * @defgroup pkg_list APIs to get package information
+ * @ingroup pkgmgr
+ * @brief
+ * API to get package information
+*/
+
+/**
+ * @addtogroup pkg_list
+ * @{
+ */
+
+
+/**
+ * @brief This API gets the package's information.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkg_type package type for the package to get infomation
+ * @param[in] pkgid package id for the package to get infomation
+ * @return package entry pointer if success, NULL if fail\n
+*/
+pkgmgr_info * pkgmgr_info_new(const char *pkg_type, const char *pkgid);
+
+/**
+ * @brief This API gets the package's information.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkg_type package type for the package to get infomation
+ * @param[in] pkg_path package file path to get infomation
+ * @return package entry pointer if success, NULL if fail\n
+*/
+pkgmgr_info * pkgmgr_info_new_from_file(const char *pkg_type,
+ const char *pkg_path);
+
+/**
+ * @brief This API get package information value
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkg_info pointer for package info entry
+ * @param[in] key key for package info field
+ * @return string value if success, NULL if fail\n
+*/
+char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key);
+
+/**
+ * @brief This API get package information value
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkg_info pointer for package info entry
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_info_free(pkgmgr_info * pkg_info);
+
+/**
+ * @brief This API gets list of installed applications.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkg_list_cb iteration function for list
+ * @param[in] user_data user data to be passed to callback function
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data);
+
+/**
+ * @brief This API get package info entry from db
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkgid pointer to package id
+ * @param[out] handle pointer to the package info handle.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle);
+
+/**
+ * @brief This API gets type of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] type to hold package type.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_pkgname(pkgmgr_pkginfo_h handle, char **pkg_name);
+
+/**
+ * @brief This API gets id of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out]pkgid to hold package id.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_pkgid(pkgmgr_pkginfo_h handle, char **pkgid);
+
+/**
+ * @brief This API gets type of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] type to hold package type.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_type(pkgmgr_pkginfo_h handle, char **type);
+
+/**
+ * @brief This API gets version of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] version to hold package version.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_version(pkgmgr_pkginfo_h handle, char **version);
+
+/**
+ * @brief This API gets install location of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] location to hold install location.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location);
+
+/**
+ * @brief This API gets package size of the given package in case of external installation.
+ * size will be 0 if package install location is internal-only.
+ * size will be 0 if package install location is prefer-external but size is not specified in manifest file.
+ * Application should check the return value and use it distinguish the above cases.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] size to hold package size.
+ * @return 0 if success, error code(<0) if fail\n
+ * @return
+*/
+int pkgmgr_pkginfo_get_package_size(pkgmgr_pkginfo_h handle, int *size);
+
+/**
+ * @brief This API gets icon of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] icon to hold package icon.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_icon(pkgmgr_pkginfo_h handle, char **icon);
+
+/**
+ * @brief This API gets label of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] label to hold package label.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label);
+
+/**
+ * @brief This API gets desription of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] description to hold package description.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_description(pkgmgr_pkginfo_h handle, char **description);
+
+/**
+ * @brief This API gets author's name of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] author_name to hold author's name.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_author_name(pkgmgr_pkginfo_h handle, char **author_name);
+
+/**
+ * @brief This API gets author's email of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] author_email to hold author's email id.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_author_email(pkgmgr_pkginfo_h handle, char **author_email);
+
+/**
+ * @brief This API gets author's href of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] author_href to hold author's href.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_author_href(pkgmgr_pkginfo_h handle, char **author_href);
+
+/**
+ * @brief This API gets removable of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] removable to hold removable value.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_is_removable(pkgmgr_pkginfo_h handle, bool *removable);
+
+/**
+ * @brief This API gets preload of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] preload to hold preload value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_is_preload(pkgmgr_pkginfo_h handle, bool *preload);
+
+/**
+ * @brief This API gets readonly value of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] readonly to hold readonly value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_is_readonly(pkgmgr_pkginfo_h handle, bool *readonly);
+
+/**
+ * @brief This API gets accessible of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkgid id of package
+ * @param[out]accessible accessible of package
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_is_accessible(pkgmgr_pkginfo_h handle, bool *accessible);
+
+/**
+ * @brief This API destroy the pacakge info handle
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle);
+
+/**
+ * @brief This API gets installed storage of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkgid id of package
+ * @param[out] storage storage of package
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_installed_storage(pkgmgr_pkginfo_h handle, pkgmgr_installed_storage *storage);
+
+/**
+ * @brief This API gets installed time of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[out] installed_time installed time of package
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_installed_time(pkgmgr_pkginfo_h handle, int *installed_time);
+
+/**
+ * @brief This API gets list of ui-application/service application of the given package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[in] component application component type.
+ * @param[in] app_func application's callback function.
+ * @param[in] user_data user data to be passed to callback function
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
+ pkgmgr_info_app_list_cb app_func, void *user_data);
+
+/**
+ * @brief This API gets list of category for ui-application/service application.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to package info handle
+ * @param[in] category_func callback function.
+ * @param[in] user_data user data to be passed to callback function
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_foreach_category(pkgmgr_appinfo_h handle, pkgmgr_info_app_category_list_cb category_func,
+ void *user_data);
+
+/**
+ * @brief This API gets application info entry from db.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] appid application id
+ * @param[out] handle pointer to app info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle);
+
+/**
+ * @brief This API gets appid of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] appid to hold appid value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid);
+
+/**
+ * @brief This API gets pkgid of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out]pkg_name to hold pkgid value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name);
+
+/**
+ * @brief This API gets pkgid of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] pkgid to hold pkgid value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_pkgid(pkgmgr_appinfo_h handle, char **pkgid);
+
+/**
+ * @brief This API gets exec of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] exec to hold exec value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_exec(pkgmgr_appinfo_h handle, char **exec);
+
+/**
+ * @brief This API gets icon name of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] icon to hold icon value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_icon(pkgmgr_appinfo_h handle, char **icon);
+
+/**
+ * @brief This API gets label of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] label to hold label value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_label(pkgmgr_appinfo_h handle, char **label);
+
+/**
+ * @brief This API gets package name of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] package to hold package value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_package(pkgmgr_appinfo_h handle, char **package);
+
+/**
+ * @brief This API gets component type of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] component to hold component value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_component(pkgmgr_appinfo_h handle, pkgmgr_app_component *component);
+
+/**
+ * @brief This API gets app type of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] app_type to hold the apptype.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_apptype(pkgmgr_appinfo_h handle, char **app_type);
+
+/**
+ * @brief This API gets nodisplay value of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] nodisplay to hold the nodisplay value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_is_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay);
+
+/**
+ * @brief This API gets multiple value of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] multiple to hold the multiple value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_is_multiple(pkgmgr_appinfo_h handle, bool *multiple);
+
+/**
+ * @brief This API gets taskmanage value of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] taskmanage to hold the taskmanage value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_is_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage);
+
+/**
+ * @brief This API gets hwacceleration value of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] hwacceleration to hold the hwacceleration value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_get_hwacceleration(pkgmgr_appinfo_h handle, pkgmgr_hwacceleration_type *hwacceleration);
+
+/**
+ * @brief This API gets onboot value of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] onboot to hold the onboot value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_is_onboot(pkgmgr_appinfo_h handle, bool *onboot);
+
+/**
+ * @brief This API gets autorestart value of the given appid.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @param[out] autorestart to hold the autorestart value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_is_autorestart(pkgmgr_appinfo_h handle, bool *autorestart);
+
+/**
+ * @brief This API destroy the appinfo handle.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to app info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle);
+
+/**
+ * @brief This API creates the certinfo handle.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[out] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle);
+
+/**
+ * @brief This API loads cert info in the handle.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to cert info handle
+ * @param[in] pkgid package ID
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle);
+
+/**
+ * @brief This API gets cert value for corresponding cert type.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to cert info handle
+ * @param[in] cert_type enum value for certificate type
+ * @param[out] cert_value pointer to store cert value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value);
+
+/**
+ * @brief This API destroys cert info handle freeing all resources.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle);
+
+/**
+ * @brief This API gets datacontrol info entry from db.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] providerid pointer to providerid
+ * @param[in] type pointer to type
+ * @param[out] appid pointer to appid value
+ * @param[out] access pointer to access value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access);
+/** @} */
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __PKG_MANAGER_H__ */
+/**
+ * @}
+ * @}
+ */
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @file pkgmgr-dbinfo.h
+ * @author Shobhit Srivastava <shobhit.s@samsung.com>
+ * @version 0.1
+ * @brief This file declares db set API for backend installers
+ *
+ * @addtogroup APPLICATION_FRAMEWORK
+ * @{
+ *
+ * @defgroup PackageManager
+ * @section Header to use them:
+ * @code
+ * #include "pkgmgr-dbinfo.h"
+ * @endcode
+ *
+ * @addtogroup PackageManager
+ * @{
+ */
+
+#ifndef __PKGMGR_DBINFO_H__
+#define __PKGMGR_DBINFO_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+typedef enum {
+ PM_INSTALL_INTERNAL = 0,
+ PM_INSTALL_EXTERNAL,
+} PM_INSTALL_LOCATION;
+
+typedef void* pkgmgr_pkgdbinfo_h;
+
+/**
+ * @brief This API creates package info handle to set info in the db.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] pkgid package id.
+ * @param[out] handle package info handle.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_create_pkgdbinfo(const char *pkgid, pkgmgr_pkgdbinfo_h *handle);
+
+/**
+ * @brief This API sets the package type in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] type package type.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_type_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *type);
+
+/**
+ * @brief This API sets the package version in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] version package version.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_version_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *version);
+
+/**
+ * @brief This API sets install location in DB
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] location install location.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, PM_INSTALL_LOCATION location);
+
+/**
+ * @brief This API sets package size in DB
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] size package size.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_size_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *size);
+
+/**
+ * @brief This API sets label in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] label label text.
+ * @param[in] locale locale (NULL for default).
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_label_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *label, const char *locale);
+
+/**
+ * @brief This API sets icon in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] icon icon name.
+ * @param[in] locale locale (NULL for default).
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_icon_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *icon, const char *locale);
+
+/**
+ * @brief This API sets description in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] description description of the package.
+ * @param[in] locale locale (NULL for default).
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_description_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *description, const char *locale);
+
+/**
+ * @brief This API sets author's name, email, href in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] author_name author' name.
+ * @param[in] author_email author's email.
+ * @param[in] author_href author's href.
+ * @param[in] locale locale (NULL for default).
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_author_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *author_name,
+ const char *author_email, const char *author_href, const char *locale);
+
+/**
+ * @brief This API sets removable in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] removable removable (0 | 1)
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_removable_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int removable);
+
+/**
+ * @brief This API sets preload in DB.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @param[in] preload preload (0 | 1)
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_set_preload_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int preload);
+
+/**
+ * @brief This API save pakage info entry into the db.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_save_pkgdbinfo(pkgmgr_pkgdbinfo_h handle);
+
+/**
+ * @brief This API destroy pakage info handle and free the resources.
+ *
+ * This API is for backend installers.\n
+ *
+ * @param[in] handle package info handle.
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_destroy_pkgdbinfo(pkgmgr_pkgdbinfo_h handle);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __PKGMGR_DBINFO_H__ */
+/**
+ * @}
+ * @}
+ */
+
--- /dev/null
+/*
+ * pkgmgr-debug
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: junsuk. oh <junsuk77.oh@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __PKGMGR_DEBUG_H__
+#define __PKGMGR_DEBUG_H__
+
+#include <dlog.h>
+
+#define _LOGE(fmt, arg...) LOGE(fmt, ##arg)
+#define _LOGD(fmt, arg...) LOGD(fmt, ##arg)
+
+
+#define COLOR_RED "\033[0;31m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_END "\033[0;m"
+
+#define PKGMGR_DEBUG(fmt, ...)\
+ do\
+ {\
+ LOGD("[%s(): %d]" fmt, __FUNCTION__, __LINE__,##__VA_ARGS__);\
+ } while (0)
+
+#define PKGMGR_DEBUG_ERR(fmt, ...)\
+ do\
+ {\
+ LOGE(COLOR_RED"[%s(): %d]" fmt COLOR_END, __FUNCTION__, __LINE__,##__VA_ARGS__);\
+ }while (0)
+
+#define PKGMGR_BEGIN() \
+ do\
+ {\
+ LOGD(COLOR_BLUE"[%s(): %d] BEGIN >>>>"COLOR_END, __FUNCTION__ ,__LINE__);\
+ } while( 0 )
+
+#define PKGMGR_END() \
+ do\
+ {\
+ LOGD(COLOR_BLUE"[%s(): %d] END <<<<"COLOR_END, __FUNCTION__,__LINE__ );\
+ } \
+ while( 0 )
+
+#define ret_if(expr) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) ", #expr); \
+ PKGMGR_END();\
+ return; \
+ } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ PKGMGR_END();\
+ return; \
+ } \
+ } while (0)
+
+#define retv_if(expr, val) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) ", #expr); \
+ PKGMGR_END();\
+ return (val); \
+ } \
+ } while (0)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ PKGMGR_END();\
+ return (val); \
+ } \
+} while (0)
+
+#define trym_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ goto catch; \
+ } \
+ } while (0)
+
+#define tryvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ val; \
+ goto catch; \
+ } \
+ } while (0)
+
+#endif /* __PKGMGR_DEBUG_H__ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __PKG_MANAGER_INTERNAL_H__
+#define __PKG_MANAGER_INTERNAL_H__
+
+#include <unistd.h>
+#include <ctype.h>
+
+#include "package-manager-plugin.h"
+
+typedef package_manager_pkg_info_t package_manager_app_info_t;
+
+
+char *_get_pkg_type_from_desktop_file(const char *pkgid);
+
+package_manager_pkg_info_t *_pkg_malloc_appinfo(int num);
+
+pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
+ const char *library_path);
+
+int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path);
+
+pkg_plugin_set *_package_manager_load_library(const char *pkg_type);
+
+char *_get_info_string(const char *key,
+ const package_manager_pkg_detail_info_t *
+ pkg_detail_info);
+
+int _get_info_int(const char *key,
+ const package_manager_pkg_detail_info_t *pkg_detail_info);
+
+time_t _get_info_time(const char *key,
+ const package_manager_pkg_detail_info_t *
+ pkg_detail_info);
+
+
+#define PKG_BACKEND "backend:"
+#define PKG_BACKENDLIB "backendlib:"
+#define PKG_CONF_PATH "/usr/etc/package-manager/pkg_path.conf"
+
+#define PKG_STATUS "STATUS"
+
+#define PKG_STRING_LEN_MAX 1024
+#define PKG_EXT_LEN_MAX 20
+#define PKG_ARGC_MAX 16
+
+void _app_str_trim(char *input);
+char *_get_backend_path(const char *input_path);
+char *_get_backend_path_with_type(const char *type);
+
+int _get_mime_from_file(const char *filename, char *mimetype, int len);
+int _get_mime_extension(const char *mimetype, char *ext, int len);
+
+#endif /* __PKG_MANAGER_INTERNAL_H__ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <malloc.h>
+#include <sys/time.h>
+
+#include "package-manager.h"
+#include "package-manager-types.h"
+#include "pkgmgr-internal.h"
+#include "pkgmgr-api.h"
+#include "pkgmgr-dbinfo.h"
+#include <pkgmgr-info.h>
+
+API int pkgmgr_create_pkgdbinfo(const char *pkgid, pkgmgr_pkgdbinfo_h *handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_create_pkgdbinfo(pkgid, handle);
+ return ret;
+}
+
+API int pkgmgr_set_type_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *type)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_type_to_pkgdbinfo(handle, type);
+ return ret;
+}
+
+API int pkgmgr_set_version_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *version)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, version);
+ return ret;
+}
+
+API int pkgmgr_set_install_location_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, PM_INSTALL_LOCATION location)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_install_location_to_pkgdbinfo(handle, location);
+ return ret;
+}
+
+API int pkgmgr_set_size_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *size)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_size_to_pkgdbinfo(handle, size);
+ return ret;
+}
+
+API int pkgmgr_set_label_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *label, const char *locale)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, locale);
+ return ret;
+}
+
+API int pkgmgr_set_icon_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *icon, const char *locale)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, locale);
+ return ret;
+}
+
+API int pkgmgr_set_description_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *description, const char *locale)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, locale);
+ return ret;
+}
+
+API int pkgmgr_set_author_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, const char *author_name,
+ const char *author_email, const char *author_href, const char *locale)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, locale);
+ return ret;
+}
+
+API int pkgmgr_set_removable_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int removable)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_removable_to_pkgdbinfo(handle, removable);
+ return ret;
+}
+
+API int pkgmgr_set_preload_to_pkgdbinfo(pkgmgr_pkgdbinfo_h handle, int preload)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, preload);
+ return ret;
+}
+
+API int pkgmgr_save_pkgdbinfo(pkgmgr_pkgdbinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_save_pkgdbinfo(handle);
+ return ret;
+}
+
+API int pkgmgr_destroy_pkgdbinfo(pkgmgr_pkgdbinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_destroy_pkgdbinfo(handle);
+ return ret;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <aul.h>
+#include <xdgmime.h>
+
+#include "pkgmgr-internal.h"
+#include "pkgmgr-debug.h"
+
+#include <unistd.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <ail.h>
+#include <aul.h>
+
+#include "package-manager.h"
+#include <pkgmgr-info.h>
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR"
+#endif /* LOG_TAG */
+
+#define IS_WHITESPACE(CHAR) \
+ ((CHAR == ' ' || CHAR == '\t' || CHAR == '\r' || CHAR == '\n') ? \
+ true : false)
+
+void _app_str_trim(char *input)
+{
+ char *trim_str = input;
+
+ if (input == NULL)
+ return;
+
+ while (*input != 0) {
+ if (!IS_WHITESPACE(*input)) {
+ *trim_str = *input;
+ trim_str++;
+ }
+ input++;
+ }
+
+ *trim_str = 0;
+ return;
+}
+
+char *_get_backend_path(const char *input_path)
+{
+ FILE *fp = NULL;
+ char buffer[1024] = { '\0', };
+ char *type = NULL;
+ char installer_path[PKG_STRING_LEN_MAX] = { '\0', };
+ char pkg_path[PKG_STRING_LEN_MAX] = { '\0', };
+ char backend_path[PKG_STRING_LEN_MAX] = { '\0', };
+
+ if (strrchr(input_path, '/')) {
+ strncpy(pkg_path, strrchr(input_path, '/') + 1,
+ PKG_STRING_LEN_MAX - 1);
+ } else {
+ strncpy(pkg_path, input_path, PKG_STRING_LEN_MAX - 1);
+ }
+
+ _LOGD("pkg_path[%s]\n", pkg_path);
+
+ fp = fopen(PKG_CONF_PATH, "r");
+ if (fp == NULL) {
+ return NULL;
+ }
+
+ char *path = NULL;
+ while (fgets(buffer, 1024, fp) != NULL) {
+ if (buffer[0] == '#')
+ continue;
+
+ _app_str_trim(buffer);
+
+ if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
+ _LOGD("[%s]\n", buffer);
+ _LOGD("[%s]\n", path);
+ path = path + strlen(PKG_BACKEND);
+ _LOGD("[%s]\n", path);
+
+ break;
+ }
+
+ memset(buffer, 0x00, 1024);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ if (path == NULL)
+ return NULL;
+
+/* if(path[strlen(path)] == '/') */
+ snprintf(backend_path, PKG_STRING_LEN_MAX - 1, "%s", path);
+/* else
+ sprintf(backend_path, "%s/", path); */
+
+ type = strrchr(pkg_path, '.');
+ if (type == NULL)
+ type = pkg_path;
+ else
+ type++;
+
+ snprintf(installer_path, PKG_STRING_LEN_MAX - 1,
+ "%s%s", backend_path, type);
+
+ _LOGD("installer_path[%s]\n", installer_path);
+
+ if (access(installer_path, F_OK) != 0)
+ return NULL;
+
+ return strdup(installer_path);
+}
+
+char *_get_backend_path_with_type(const char *type)
+{
+ FILE *fp = NULL;
+ char buffer[1024] = { '\0', };
+ char installer_path[PKG_STRING_LEN_MAX] = { '\0', };
+ char backend_path[PKG_STRING_LEN_MAX] = { '\0', };
+
+ _LOGD("type[%s]\n", type);
+
+ fp = fopen(PKG_CONF_PATH, "r");
+ if (fp == NULL) {
+ return NULL;
+ }
+
+ char *path = NULL;
+ while (fgets(buffer, 1024, fp) != NULL) {
+ if (buffer[0] == '#')
+ continue;
+
+ _app_str_trim(buffer);
+
+ if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
+ _LOGD("[%s]\n", buffer);
+ _LOGD("[%s]\n", path);
+ path = path + strlen(PKG_BACKEND);
+ _LOGD("[%s]\n", path);
+
+ break;
+ }
+
+ memset(buffer, 0x00, 1024);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ if(path == NULL)
+ return NULL;
+
+/* if(path[strlen(path)] == '/') */
+ snprintf(backend_path, PKG_STRING_LEN_MAX - 1, "%s", path);
+/* else
+ sprintf(backend_path, "%s/", path); */
+
+ /* eflwgt package is handled by efltpk backend as there is no separate backend for eflwgt */
+ if(!strcmp(type,"eflwgt")){
+ snprintf(installer_path, PKG_STRING_LEN_MAX - 1,
+ "%sefltpk", backend_path);
+ _LOGD("installer_path[%s]\n", installer_path);
+ }else{
+ snprintf(installer_path, PKG_STRING_LEN_MAX - 1,
+ "%s%s", backend_path, type);
+ _LOGD("installer_path[%s]\n", installer_path);
+ }
+
+ if (access(installer_path, F_OK) != 0) {
+ char extlist[256] = { '\0', };
+ _get_mime_extension(type, extlist, sizeof(extlist));
+ _LOGD("extlist[%s]\n", extlist);
+
+ if (strlen(extlist) == 0)
+ return NULL;
+
+ if (strchr(extlist, ',')) {
+ extlist[strlen(extlist) -
+ strlen(strchr(extlist, ','))] = '\0';
+ }
+ type = strchr(extlist, '.') + 1;
+
+ snprintf(installer_path, PKG_STRING_LEN_MAX - 1,
+ "%s%s", backend_path, type);
+ }
+
+ return strdup(installer_path);
+}
+
+int _get_mime_from_file(const char *filename, char *mimetype, int len)
+{
+ const char *mime;
+ if (filename == NULL)
+ return -1;
+
+ if (access(filename, F_OK) != 0)
+ return -1;
+
+ mime = xdg_mime_get_mime_type_for_file(filename, 0);
+ if (strcmp(mime, "application/octet-stream") == 0) {
+ mime = xdg_mime_get_mime_type_from_file_name(filename);
+ }
+
+ snprintf(mimetype, len, "%s", mime);
+ return 0;
+}
+
+int _get_mime_extension(const char *mimetype, char *ext, int len)
+{
+ const char **extlist;
+ int totlen = 0;
+ const char *unaliased_mimetype;
+
+ if (mimetype == NULL || ext == NULL || len <= 0)
+ return -1;
+
+ unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
+ if (unaliased_mimetype == NULL)
+ return -1;
+
+ extlist = xdg_mime_get_file_names_from_mime_type(unaliased_mimetype);
+ if (extlist == NULL)
+ return -1;
+
+ if (extlist[0] == NULL)
+ return -1;
+
+ ext[0] = 0;
+ while (*extlist != NULL) {
+ if (*(extlist + 1) == NULL) {
+ snprintf(&ext[totlen], len - totlen, "%s", *extlist);
+ break;
+ } else {
+ snprintf(&ext[totlen], len - totlen, "%s,", *extlist);
+ if (strlen(*extlist) > len - totlen - 1)
+ break;
+ totlen += strlen(*extlist) + 1;
+ extlist++;
+ }
+ }
+
+ return 0;
+}
+
+char *_get_pkg_type_from_desktop_file(const char *pkgid)
+{
+ static char pkg_type[PKG_EXT_LEN_MAX];
+
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+
+ ret = ail_package_get_appinfo(pkgid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return NULL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
+ if (ret != AIL_ERROR_OK) {
+ ail_package_destroy_appinfo(handle);
+ return NULL;
+ }
+ snprintf(pkg_type, sizeof(pkg_type) - 1, str);
+
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return NULL;
+ }
+
+ return pkg_type;
+}
+
+package_manager_pkg_info_t *_pkg_malloc_appinfo(int num)
+{
+ package_manager_app_info_t *app_info = NULL;
+ package_manager_app_info_t *first = NULL;
+ package_manager_app_info_t *last = NULL;
+ int i = 0;
+
+ for (i = 0; i < num; i++) {
+ app_info = (package_manager_app_info_t *)
+ malloc(sizeof(package_manager_app_info_t));
+ if (app_info == NULL) {
+ package_manager_app_info_t *temp_info;
+ package_manager_app_info_t *next;
+
+ for (temp_info = first; temp_info != NULL;
+ temp_info = next) {
+ next = temp_info->next;
+ free(temp_info);
+ temp_info = NULL;
+ }
+
+ return NULL;
+ }
+
+ memset(app_info, 0x00, sizeof(package_manager_app_info_t));
+
+ if (first == NULL)
+ first = app_info;
+
+ if (last == NULL)
+ last = app_info;
+ else {
+ last->next = app_info;
+ last = app_info;
+ }
+ }
+
+ return first;
+
+}
+
+static pkg_plugin_set *plugin_set_list[24] = { 0, };
+
+pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
+ const char *library_path)
+{
+ void *library_handle = NULL;
+ int i = 0;
+
+ /* _pkg_plugin_on_load onload = NULL; */
+ bool(*on_load) (pkg_plugin_set *plugin);
+
+ if (library_path == NULL) {
+ _LOGE("pkg library path = [%s] \n", library_path);
+ return NULL;
+ }
+
+ if ((library_handle = dlopen(library_path, RTLD_LAZY)) == NULL) {
+ _LOGE("dlopen is failed library_path[%s]\n", library_path);
+ return NULL;
+ }
+
+ if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL ||
+ dlerror() != NULL) {
+ _LOGE("can not find symbol \n");
+ dlclose(library_handle);
+ return NULL;
+ }
+
+ for (i = 0; plugin_set_list[i]; i++) {
+ if (strcmp(plugin_set_list[i]->pkg_type, pkg_type) == 0) {
+ _LOGD("already loaded [%s] is done well \n",
+ library_path);
+ goto END;
+ }
+ }
+
+ plugin_set_list[i] = (pkg_plugin_set *) malloc(sizeof(pkg_plugin_set));
+ if (plugin_set_list[i] == NULL) {
+ _LOGE("malloc of the plugin_set_list element is failed \n");
+ dlclose(library_handle);
+ return NULL;
+ }
+
+ memset(plugin_set_list[i], 0x0, sizeof(pkg_plugin_set));
+
+ if (on_load(plugin_set_list[i]) != 0) {
+ _LOGE("on_load is failed \n");
+
+ dlclose(library_handle);
+
+ free(plugin_set_list[i]);
+ plugin_set_list[i] = NULL;
+
+ return NULL;
+ }
+
+ plugin_set_list[i]->plugin_handle = library_handle;
+ strncpy(plugin_set_list[i]->pkg_type, pkg_type,
+ PKG_TYPE_STRING_LEN_MAX - 1);
+
+ _LOGD("load library [%s] is done well \n", library_path);
+
+ END:
+ return plugin_set_list[i];
+
+}
+
+int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path)
+{
+ FILE *fp = NULL;
+ char buffer[1024] = { 0 };
+
+ if (pkg_type == NULL || library_path == NULL) {
+ _LOGE("invalid argument\n");
+ return -1;
+ }
+
+ fp = fopen(PKG_CONF_PATH, "r");
+ if (fp == NULL) {
+ _LOGE("no matching backendlib\n");
+ return PKGMGR_R_ERROR;
+ }
+
+ char *path = NULL;
+ while (fgets(buffer, 1024, fp) != NULL) {
+ if (buffer[0] == '#')
+ continue;
+
+ _app_str_trim(buffer);
+
+ if ((path = strstr(buffer, PKG_BACKENDLIB)) != NULL) {
+ _LOGD("[%s]\n", buffer);
+ _LOGD("[%s]\n", path);
+ path = path + strlen(PKG_BACKENDLIB);
+ _LOGD("[%s]\n", path);
+
+ break;
+ }
+
+ memset(buffer, 0x00, 1024);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ if (path == NULL) {
+ _LOGE("no matching backendlib\n");
+ return PKGMGR_R_ERROR;
+ }
+
+ snprintf(library_path, 1024, "%slib%s.so", path, pkg_type);
+
+ return PKGMGR_R_OK;
+
+}
+
+pkg_plugin_set *_package_manager_load_library(const char *pkg_type)
+{
+ char package_path[1024] = { 0 };
+ pkg_plugin_set *plugin_set = NULL;
+
+ if (pkg_type == NULL) {
+ _LOGE("can not load library - pkg_type is null\n");
+ return NULL;
+ }
+
+ if (_pkg_plugin_get_library_path(pkg_type, package_path) ==
+ PKGMGR_R_OK) {
+ plugin_set = _pkg_plugin_load_library(pkg_type, package_path);
+ if (plugin_set == NULL) {
+ _LOGE("can not load library \n");
+ return NULL;
+ }
+ } else {
+ _LOGE("can not find path \n");
+ return NULL;
+ }
+
+ return plugin_set;
+}
+
+typedef struct _detail_info_map_t {
+ char *name;
+ void *field;
+ char *type;
+} detail_info_map_t;
+
+/*
+ typedef struct _package_manager_pkg_detail_info_t {
+ char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
+ char version[PKG_VERSION_STRING_LEN_MAX];
+ char pkg_description[PKG_VALUE_STRING_LEN_MAX];
+ char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
+ time_t installed_time;
+ int installed_size;
+ int app_size;
+ int data_size;
+ char optional_id[PKG_NAME_STRING_LEN_MAX];
+ void *pkg_optional_info;
+ } package_manager_pkg_detail_info_t;
+*/
+
+static package_manager_pkg_detail_info_t tmp_pkg_detail_info;
+
+static detail_info_map_t info_map[] = {
+ {"pkg_type", tmp_pkg_detail_info.pkg_type, "string"},
+ {"pkgid", tmp_pkg_detail_info.pkgid, "string"},
+ {"version", tmp_pkg_detail_info.version, "string"},
+ {"pkg_description", tmp_pkg_detail_info.pkg_description, "string"},
+ {"min_platform_version", tmp_pkg_detail_info.min_platform_version,
+ "string"},
+ {"installed_time", &tmp_pkg_detail_info.installed_time, "time_t"},
+ {"installed_size", &tmp_pkg_detail_info.installed_size, "int"},
+ {"app_size", &tmp_pkg_detail_info.app_size, "int"},
+ {"data_size", &tmp_pkg_detail_info.data_size, "int"},
+ {"optional_id", tmp_pkg_detail_info.optional_id, "string"}
+};
+
+char *_get_info_string(const char *key,
+ const package_manager_pkg_detail_info_t *
+ pkg_detail_info)
+{
+ detail_info_map_t *tmp;
+ int i = 0;
+
+ if (pkg_detail_info == NULL)
+ return NULL;
+
+ memcpy(&tmp_pkg_detail_info, pkg_detail_info,
+ sizeof(package_manager_pkg_detail_info_t));
+
+ for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
+ tmp = &info_map[i];
+ if (strcmp(key, tmp->name) == 0) {
+ if (strcmp(tmp->type, "string") == 0) {
+ return strdup((char *)(tmp->field));
+ } else if (strcmp(tmp->type, "bool") == 0) {
+ char temp[PKG_VALUE_STRING_LEN_MAX];
+ snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
+ "%d", (int)*(bool *) (tmp->field));
+ return strdup(temp);
+ } else if (strcmp(tmp->type, "int") == 0) {
+ char temp[PKG_VALUE_STRING_LEN_MAX];
+ snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
+ "%d", (int)*(int *)(tmp->field));
+ return strdup(temp);
+ } else if (strcmp(tmp->type, "time_t") == 0) {
+ char temp[PKG_VALUE_STRING_LEN_MAX];
+ snprintf(temp, PKG_VALUE_STRING_LEN_MAX - 1,
+ "%d", (int)*(time_t *) (tmp->field));
+ return strdup(temp);
+ } else
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+int _get_info_int(const char *key,
+ const package_manager_pkg_detail_info_t *pkg_detail_info)
+{
+ detail_info_map_t *tmp;
+ int i = 0;
+
+ if (pkg_detail_info == NULL)
+ return -1;
+
+ memcpy(&tmp_pkg_detail_info, pkg_detail_info,
+ sizeof(package_manager_pkg_detail_info_t));
+ for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
+ tmp = &info_map[i];
+ if (strcmp(key, tmp->name) == 0) {
+ if (strcmp(tmp->type, "int") == 0) {
+ return (int)*(int *)(tmp->field);
+ } else
+ return -1;
+ }
+ }
+ return -1;
+}
+
+time_t _get_info_time(const char *key,
+ const package_manager_pkg_detail_info_t *pkg_detail_info)
+{
+ detail_info_map_t *tmp;
+ int i = 0;
+
+ if (pkg_detail_info == NULL)
+ return -1;
+
+ memcpy(&tmp_pkg_detail_info, pkg_detail_info,
+ sizeof(package_manager_pkg_detail_info_t));
+ for (i = 0; i < sizeof(info_map) / sizeof(detail_info_map_t); i++) {
+ tmp = &info_map[i];
+ if (strcmp(key, tmp->name) == 0) {
+ if (strcmp(tmp->type, "time_t") == 0) {
+ return (time_t) *(time_t *) (tmp->field);
+ } else
+ return (time_t) -1;
+ }
+ }
+ return (time_t) -1;
+}
+
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <ail.h>
+#include <aul.h>
+#include <vconf.h>
+#include <db-util.h>
+#include <pkgmgr-info.h>
+#include <iniparser.h>
+#include <security-server.h>
+
+#include "package-manager.h"
+#include "pkgmgr-internal.h"
+#include "pkgmgr-debug.h"
+#include "pkgmgr-api.h"
+#include "comm_client.h"
+#include "comm_status_broadcast_server.h"
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR"
+#endif /* LOG_TAG */
+
+#define PKG_TMP_PATH "/opt/usr/apps/tmp"
+
+#define BINSH_NAME "/bin/sh"
+#define BINSH_SIZE 7
+
+#define PKG_INFO_DB_LABEL "pkgmgr::db"
+#define PKG_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_parser.db-journal"
+
+static int _get_request_id()
+{
+ static int internal_req_id = 1;
+
+ return internal_req_id++;
+}
+
+typedef struct _req_cb_info {
+ int request_id;
+ char *req_key;
+ pkgmgr_handler event_cb;
+ void *data;
+ struct _req_cb_info *next;
+} req_cb_info;
+
+typedef struct _listen_cb_info {
+ int request_id;
+ pkgmgr_handler event_cb;
+ void *data;
+ struct _listen_cb_info *next;
+} listen_cb_info;
+
+typedef struct _pkgmgr_client_t {
+ client_type ctype;
+ int status_type;
+ union {
+ struct _request {
+ comm_client *cc;
+ req_cb_info *rhead;
+ } request;
+ struct _listening {
+ comm_client *cc;
+ listen_cb_info *lhead;
+ } listening;
+ struct _broadcast {
+ DBusConnection *bc;
+ } broadcast;
+ } info;
+} pkgmgr_client_t;
+
+typedef struct _iter_data {
+ pkgmgr_iter_fn iter_fn;
+ void *data;
+} iter_data;
+
+static char *__get_cookie_from_security_server(void)
+{
+ int ret = 0;
+ size_t cookie_size = 0;
+ char *e_cookie = NULL;
+
+ //calculage cookie size
+ cookie_size = security_server_get_cookie_size();
+ retvm_if(cookie_size <= 0, NULL, "security_server_get_cookie_size : cookie_size is %d", cookie_size);
+
+ //get cookie from security server
+ char cookie[cookie_size];
+ cookie[0] = '\0';
+ ret = security_server_request_cookie(cookie, cookie_size);
+ retvm_if(ret < 0, NULL, "security_server_request_cookie fail (%d)", ret);
+
+ //encode cookie
+ e_cookie = g_base64_encode((const guchar *)cookie, cookie_size);
+ retvm_if(e_cookie == NULL, NULL, "g_base64_encode e_cookie is NULL");
+
+ return e_cookie;
+}
+
+static int __xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
+
+static void __error_to_string(int errnumber, char **errstr)
+{
+ if (errstr == NULL)
+ return;
+ switch (errnumber) {
+ case PKGCMD_ERR_PACKAGE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_INVALID:
+ *errstr = PKGCMD_ERR_PACKAGE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_LOWER_VERSION:
+ *errstr = PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_MANIFEST_INVALID:
+ *errstr = PKGCMD_ERR_MANIFEST_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_NOT_FOUND:
+ *errstr = PKGCMD_ERR_CONFIG_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_INVALID:
+ *errstr = PKGCMD_ERR_CONFIG_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_INVALID:
+ *errstr = PKGCMD_ERR_SIGNATURE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_INVALID:
+ *errstr = PKGCMD_ERR_CERTIFICATE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_EXPIRED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_EXPIRED_STR;
+ break;
+ case PKGCMD_ERR_INVALID_PRIVILEGE:
+ *errstr = PKGCMD_ERR_INVALID_PRIVILEGE_STR;
+ break;
+ case PKGCMD_ERR_MENU_ICON_NOT_FOUND:
+ *errstr = PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_FATAL_ERROR:
+ *errstr = PKGCMD_ERR_FATAL_ERROR_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_STORAGE:
+ *errstr = PKGCMD_ERR_OUT_OF_STORAGE_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_MEMORY:
+ *errstr = PKGCMD_ERR_OUT_OF_MEMORY_STR;
+ break;
+ case PKGCMD_ERR_ARGUMENT_INVALID:
+ *errstr = PKGCMD_ERR_ARGUMENT_INVALID_STR;
+ break;
+ default:
+ *errstr = PKGCMD_ERR_UNKNOWN_STR;
+ break;
+ }
+}
+
+static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
+ const char *req_key, pkgmgr_handler event_cb,
+ void *data)
+{
+ req_cb_info *cb_info;
+ req_cb_info *current;
+ req_cb_info *prev;
+
+ cb_info = (req_cb_info *) calloc(1, sizeof(req_cb_info));
+ if (cb_info == NULL) {
+ _LOGD("calloc failed");
+ return;
+ }
+ cb_info->request_id = request_id;
+ cb_info->req_key = strdup(req_key);
+ cb_info->event_cb = event_cb;
+ cb_info->data = data;
+ cb_info->next = NULL;
+
+ if (pc->info.request.rhead == NULL)
+ pc->info.request.rhead = cb_info;
+ else {
+ current = prev = pc->info.request.rhead;
+ while (current) {
+ prev = current;
+ current = current->next;
+ }
+
+ prev->next = cb_info;
+ }
+}
+
+static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
+{
+ req_cb_info *tmp;
+
+ tmp = pc->info.request.rhead;
+
+ if (tmp == NULL) {
+ _LOGE("tmp is NULL");
+ return NULL;
+ }
+
+ _LOGD("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
+
+ while (tmp) {
+ if (strncmp(tmp->req_key, req_key, strlen(tmp->req_key)) == 0)
+ return tmp;
+ tmp = tmp->next;
+ }
+ return NULL;
+}
+
+static void __remove_op_cbinfo(pkgmgr_client_t *pc, req_cb_info *info)
+{
+ req_cb_info *tmp;
+
+ if (pc == NULL || pc->info.request.rhead == NULL || info == NULL)
+ return;
+
+ tmp = pc->info.request.rhead;
+ while (tmp) {
+ if (tmp->next == info) {
+ tmp->next = info->next;
+ free(info);
+ return;
+ }
+ tmp = tmp->next;
+ }
+}
+
+
+static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
+ pkgmgr_handler event_cb, void *data)
+{
+ listen_cb_info *cb_info;
+ listen_cb_info *current;
+ listen_cb_info *prev;
+
+ cb_info = (listen_cb_info *) calloc(1, sizeof(listen_cb_info));
+ if (cb_info == NULL) {
+ _LOGD("calloc failed");
+ return;
+ }
+ cb_info->request_id = request_id;
+ cb_info->event_cb = event_cb;
+ cb_info->data = data;
+ cb_info->next = NULL;
+
+ /* TODO - check the order of callback - FIFO or LIFO => Should be changed to LIFO */
+ if (pc->info.listening.lhead == NULL)
+ pc->info.listening.lhead = cb_info;
+ else {
+ current = prev = pc->info.listening.lhead;
+ while (current) {
+ prev = current;
+ current = current->next;
+ }
+
+ prev->next = cb_info;
+ }
+}
+
+static void __operation_callback(void *cb_data, const char *req_id,
+ const char *pkg_type, const char *pkgid,
+ const char *key, const char *val)
+{
+ pkgmgr_client_t *pc;
+ req_cb_info *cb_info;
+
+ SECURE_LOGD("__operation_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
+ "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
+
+ pc = (pkgmgr_client_t *) cb_data;
+
+ /* find callback info */
+ cb_info = __find_op_cbinfo(pc, req_id);
+ if (cb_info == NULL)
+ return;
+
+ _LOGD("__find_op_cbinfo");
+
+ /* call callback */
+ if (cb_info->event_cb) {
+ cb_info->event_cb(cb_info->request_id, pkg_type, pkgid, key,
+ val, NULL, cb_info->data);
+ _LOGD("event_cb is called");
+ }
+
+ /*remove callback for last call
+ if (strcmp(key, "end") == 0) {
+ __remove_op_cbinfo(pc, cb_info);
+ _LOGD("__remove_op_cbinfo");
+ }
+ */
+
+ return;
+}
+
+static void __status_callback(void *cb_data, const char *req_id,
+ const char *pkg_type, const char *pkgid,
+ const char *key, const char *val)
+{
+ pkgmgr_client_t *pc;
+ listen_cb_info *tmp;
+
+ SECURE_LOGD("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
+ "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
+
+ pc = (pkgmgr_client_t *) cb_data;
+
+ tmp = pc->info.listening.lhead;
+ while (tmp) {
+ if (tmp->event_cb(tmp->request_id, pkg_type, pkgid, key, val,
+ NULL, tmp->data) != 0)
+ break;
+ tmp = tmp->next;
+ }
+
+ return;
+}
+
+static char *__get_req_key(const char *pkg_path)
+{
+ struct timeval tv;
+ long curtime;
+ char timestr[PKG_STRING_LEN_MAX];
+ char *str_req_key;
+ int size;
+
+ gettimeofday(&tv, NULL);
+ curtime = tv.tv_sec * 1000000 + tv.tv_usec;
+ snprintf(timestr, sizeof(timestr), "%ld", curtime);
+
+ size = strlen(pkg_path) + strlen(timestr) + 2;
+ str_req_key = (char *)calloc(size, sizeof(char));
+ if (str_req_key == NULL) {
+ _LOGD("calloc failed");
+ return NULL;
+ }
+ snprintf(str_req_key, size, "%s_%s", pkg_path, timestr);
+
+ return str_req_key;
+}
+
+static char *__get_type_from_path(const char *pkg_path)
+{
+ int ret;
+ char mimetype[255] = { '\0', };
+ char extlist[256] = { '\0', };
+ char *pkg_type;
+
+ ret = _get_mime_from_file(pkg_path, mimetype, sizeof(mimetype));
+ if (ret) {
+ _LOGE("_get_mime_from_file() failed - error code[%d]\n",
+ ret);
+ return NULL;
+ }
+
+ ret = _get_mime_extension(mimetype, extlist, sizeof(extlist));
+ if (ret) {
+ _LOGE("_get_mime_extension() failed - error code[%d]\n",
+ ret);
+ return NULL;
+ }
+
+ if (strlen(extlist) == 0)
+ return NULL;
+
+ if (strchr(extlist, ',')) {
+ extlist[strlen(extlist) - strlen(strchr(extlist, ','))] = '\0';
+ }
+ pkg_type = strchr(extlist, '.') + 1;
+ return strdup(pkg_type);
+}
+
+static int __get_pkgid_by_appid(const char *appid, char **pkgid)
+{
+ pkgmgrinfo_appinfo_h pkgmgrinfo_appinfo = NULL;
+ int ret = -1;
+ char *pkg_id = NULL;
+ char *pkg_id_dup = NULL;
+
+ if (pkgmgrinfo_appinfo_get_appinfo(appid, &pkgmgrinfo_appinfo) != PMINFO_R_OK)
+ return -1;
+
+ if (pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo, &pkg_id) != PMINFO_R_OK)
+ goto err;
+
+ pkg_id_dup = strdup(pkg_id);
+ if (pkg_id_dup == NULL)
+ goto err;
+
+ *pkgid = pkg_id_dup;
+ ret = PMINFO_R_OK;
+
+err:
+ pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo);
+
+ return ret;
+}
+
+static inline ail_cb_ret_e __appinfo_cb(const ail_appinfo_h appinfo, void *user_data)
+{
+ char *package;
+ ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+
+ if (package) {
+ (* (char **) user_data) = strdup(package);
+ ret = AIL_CB_RET_CANCEL;
+ }
+
+ return ret;
+}
+
+static char *__get_app_info_from_db_by_apppath(const char *apppath)
+{
+ char *caller_appid = NULL;
+ ail_filter_h filter;
+ ail_error_e ret;
+ int count;
+
+ if (apppath == NULL)
+ return NULL;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return NULL;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ return NULL;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &count);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ return NULL;
+ }
+ if (count < 1) {
+ ail_filter_destroy(filter);
+ return NULL;
+ }
+
+ ail_filter_list_appinfo_foreach(filter, __appinfo_cb, &caller_appid);
+
+ ail_filter_destroy(filter);
+
+ return caller_appid;
+}
+
+static inline int __read_proc(const char *path, char *buf, int size)
+{
+ int fd = 0;
+ int ret = 0;
+
+ if (buf == NULL || path == NULL)
+ return -1;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+
+ close(fd);
+
+ return ret;
+}
+
+char *__proc_get_cmdline_bypid(int pid)
+{
+ char buf[PKG_STRING_LEN_MAX] = {'\0', };
+ int ret = 0;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ return NULL;
+
+ /* support app launched by shell script*/
+ if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
+ return strdup(&buf[BINSH_SIZE + 1]);
+ else
+ return strdup(buf);
+}
+
+static int __get_appid_bypid(int pid, char *pkgname, int len)
+{
+ char *cmdline = NULL;
+ char *caller_appid = NULL;
+
+ cmdline = __proc_get_cmdline_bypid(pid);
+ if (cmdline == NULL)
+ return -1;
+
+ caller_appid = __get_app_info_from_db_by_apppath(cmdline);
+ snprintf(pkgname, len, "%s", caller_appid);
+
+ free(cmdline);
+ free(caller_appid);
+
+ return 0;
+}
+
+static char *__get_caller_pkgid()
+{
+ char *caller_appid[PKG_STRING_LEN_MAX] = {0, };
+ char *caller_pkgid = NULL;
+
+ if (__get_appid_bypid(getpid(), caller_appid, sizeof(caller_appid)) < 0) {
+ _LOGE("get appid fail!!!\n");
+ return NULL;
+ }
+ if (__get_pkgid_by_appid(caller_appid, &caller_pkgid) < 0){
+ _LOGE("get pkgid fail!!!\n");
+ return NULL;
+ }
+
+ return caller_pkgid;
+}
+
+static inline int __pkgmgr_read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
+
+ if (buf == NULL || path == NULL)
+ return -1;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+
+ close(fd);
+
+ return ret;
+}
+
+static inline int __pkgmgr_find_pid_by_cmdline(const char *dname,
+ const char *cmdline, const char *apppath)
+{
+ int pid = 0;
+
+ if (strncmp(cmdline, apppath, PKG_STRING_LEN_MAX-1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
+
+ return pid;
+}
+
+void __make_sizeinfo_file(char *description)
+{
+ FILE* file = NULL;
+ int fd = 0;
+
+ if(description == NULL)
+ return;
+
+ file = fopen(PKG_SIZE_INFO_FILE, "w");
+ if (file == NULL) {
+ _LOGE("Couldn't open the file %s \n", PKG_SIZE_INFO_FILE);
+ return;
+ }
+
+ fwrite(description, 1, strlen(description), file);
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+}
+
+static int __check_sync_condition(char *req_key)
+{
+ int ret = 0;
+ ssize_t r;
+ char *buf;
+ size_t len;
+
+ char info_file[PKG_STRING_LEN_MAX] = {'\0', };
+
+ snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_SIZE_INFO_PATH, req_key);
+ if (access(info_file, F_OK)==0) {
+ _LOGE("sync check file[%s] exist !!! it is need to delete\n",info_file);
+
+ r = lgetxattr (info_file, "security.SMACK64", NULL, 0);
+ if (r == -1) {
+ _LOGE("get smack attr len error(%d)\n", errno);
+ return -1;
+ }
+
+ len = r;
+ buf = malloc(len);
+ if (buf == NULL) {
+ _LOGE("malloc fail");
+ return -1;
+ }
+
+ r = lgetxattr (info_file, "security.SMACK64", buf, len);
+ if (r == -1) {
+ _LOGE("get smack attr error(%d)\n", errno);
+ free(buf);
+ return -1;
+ }
+
+ if (len != (size_t) r) {
+ _LOGE("unexpected size(%zu/%zd)\n", len, r);
+ free(buf);
+ return -1;
+ }
+
+ _LOGE("file[%s] has smack[%s]\n", info_file, buf);
+
+ free(buf);
+
+ ret = remove(info_file);
+ if (ret < 0)
+ _LOGD("file is can not remove[%s, %d]\n", info_file, ret);
+ }
+ return ret;
+}
+
+static int __check_sync_process(char *req_key)
+{
+ int ret = 0;
+ char info_file[PKG_STRING_LEN_MAX] = {'\0', };
+ int result = -1;
+ int check_cnt = 0;
+ FILE *fp;
+ char buf[PKG_STRING_LEN_MAX] = {0};
+
+ snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_SIZE_INFO_PATH, req_key);
+ while(1)
+ {
+ check_cnt ++;
+
+ if (access(info_file, F_OK)==0) {
+ fp = fopen(info_file, "r");
+ if (fp == NULL){
+ _LOGD("file is not generated yet.... wait\n");
+ usleep(10 * 1000); /* 10ms sleep*/
+ continue;
+ }
+
+ fgets(buf, PKG_STRING_LEN_MAX, fp);
+ fclose(fp);
+
+ _LOGD("info_file file is generated, result = %s. \n", buf);
+ result = atoi(buf);
+ break;
+ }
+
+ _LOGD("file is not generated yet.... wait\n");
+ usleep(10 * 1000); /* 10ms sleep*/
+
+ if (check_cnt > 6000) { /* 60s time over*/
+ _LOGD("wait time over!!\n");
+ break;
+ }
+ }
+
+ ret = remove(info_file);
+ if (ret < 0)
+ _LOGD("file is can not remove[%s, %d]\n", info_file, ret);
+
+ return result;
+}
+
+static int __csc_process(const char *csc_path, char *result_path)
+{
+ int ret = 0;
+ int cnt = 0;
+ int count = 0;
+ int csc_fail = 0;
+ int fd = 0;
+ char *pkgtype = NULL;
+ char *des = NULL;
+ char buf[PKG_STRING_LEN_MAX] = {0,};
+ char type_buf[1024] = { 0 };
+ char des_buf[1024] = { 0 };
+ dictionary *csc = NULL;
+ FILE* file = NULL;
+
+ csc = iniparser_load(csc_path);
+ retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path);
+
+ file = fopen(result_path, "w");
+ tryvm_if(file == NULL, ret = PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path);
+
+ count = iniparser_getint(csc, "csc packages:count", -1);
+ tryvm_if(count == 0, ret = PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path);
+
+ snprintf(buf, PKG_STRING_LEN_MAX, "[result]\n");
+ fwrite(buf, 1, strlen(buf), file);
+ snprintf(buf, PKG_STRING_LEN_MAX, "count = %d\n", count);
+ fwrite(buf, 1, strlen(buf), file);
+
+ for(cnt = 1 ; cnt <= count ; cnt++)
+ {
+ snprintf(type_buf, PKG_STRING_LEN_MAX - 1, "csc packages:type_%03d", cnt);
+ snprintf(des_buf, PKG_STRING_LEN_MAX - 1, "csc packages:description_%03d", cnt);
+
+ pkgtype = iniparser_getstr(csc, type_buf);
+ des = iniparser_getstr(csc, des_buf);
+ ret = 0;
+
+ if (pkgtype == NULL) {
+ csc_fail++;
+ snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get pkgtype\n", type_buf);
+ fwrite(buf, 1, strlen(buf), file);
+ continue;
+ } else if (des == NULL) {
+ csc_fail++;
+ snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get description\n", des_buf);
+ fwrite(buf, 1, strlen(buf), file);
+ continue;
+ }
+
+ snprintf(buf, PKG_STRING_LEN_MAX, "type_%03d = %s\n", cnt, pkgtype);
+ fwrite(buf, 1, strlen(buf), file);
+ snprintf(buf, PKG_STRING_LEN_MAX, "description_%03d = %s\n", cnt, des);
+ fwrite(buf, 1, strlen(buf), file);
+
+ if (strcmp(pkgtype, "tpk") == 0) {
+ const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-c", des, NULL };
+ ret = __xsystem(ospinstaller_argv);
+ } else if (strcmp(pkgtype, "wgt")== 0) {
+ const char *wrtinstaller_argv[] = { "/usr/bin/wrt-installer", "-c", des, NULL };
+ ret = __xsystem(wrtinstaller_argv);
+ } else if (strcmp(pkgtype, "xml")== 0) {
+ const char *rpminstaller_argv[] = { "/usr/bin/rpm-backend", "-k", "csc-xml", "-s", des, NULL };
+ ret = __xsystem(rpminstaller_argv);
+ } else {
+ csc_fail++;
+ ret = -1;
+ }
+
+ if (ret != 0) {
+ char *errstr = NULL;
+ __error_to_string(ret, &errstr);
+ snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = fail[%s]\n", cnt, errstr);
+ }
+ else
+ snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = success\n", cnt);
+
+ fwrite(buf, 1, strlen(buf), file);
+ }
+
+catch:
+ iniparser_freedict(csc);
+ if (file != NULL) {
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+ }
+
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+ __xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+ __xsystem(argv_parserjn);
+
+ return ret;
+}
+
+static int __get_size_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
+{
+ char *req_key = NULL;
+ int ret =0;
+ char *pkgtype = "rpm";
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int i = 0;
+ char buf[128] = {'\0'};
+ char *cookie = NULL;
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+
+ req_key = __get_req_key(pkgid);
+
+ snprintf(buf, 128, "%d", get_type);
+ argv[argcnt++] = strdup(pkgid);
+ argv[argcnt++] = strdup(buf);
+ argv[argcnt++] = strdup(req_key);
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+
+ /* request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, 1);
+ if (ret < 0)
+ _LOGE("comm_client_request failed, ret=%d\n", ret);
+
+ ret = __check_sync_process(req_key);
+ if (ret < 0)
+ _LOGE("get size failed, ret=%d\n", ret);
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ return ret;
+}
+
+static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
+{
+ char *req_key = NULL;
+ int req_id = 0;
+ int ret =0;
+ pkgmgrinfo_pkginfo_h handle;
+ char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int i = 0;
+ char buf[128] = {'\0'};
+ char *cookie = NULL;
+ pkgmgrinfo_install_location location = 0;
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
+
+ pkgmgrinfo_pkginfo_get_install_location(handle, &location);
+ tryvm_if(location == PMINFO_INSTALL_LOCATION_INTERNAL_ONLY, ret = PKGMGR_R_ERROR, "package[%s] is internal-only, can not be moved", pkgid);
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
+
+ installer_path = _get_backend_path_with_type(pkgtype);
+ req_key = __get_req_key(pkgid);
+ req_id = _get_request_id();
+
+ /* generate argv */
+ snprintf(buf, 128, "%d", move_type);
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-m");
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkgid);
+ /* argv[5] */
+ argv[argcnt++] = strdup("-t");
+ /* argv[6] */
+ argv[argcnt++] = strdup(buf);
+ /* argv[7] */
+ argv[argcnt++] = strdup("-q");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+
+ ret = __check_sync_condition(pkgid);
+
+ /* 6. request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, 1);
+ if (ret < 0)
+ _LOGE("comm_client_request failed, ret=%d\n", ret);
+
+ ret = __check_sync_process(pkgid);
+ if (ret != 0)
+ _LOGE("move pkg failed, ret=%d\n", ret);
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return ret;
+}
+
+static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_client * pc, const char *pkgid, void *data)
+{
+ const char *pkgtype = NULL;
+ char *req_key = NULL;
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+ int pid = -1;
+
+ /* Check for NULL value of pc */
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(pkgid);
+
+ /* 3. request activate */
+ if (service_type == PM_REQUEST_KILL_APP)
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_KILL_APP, pkgtype, pkgid, NULL, NULL, 1);
+ else if (service_type == PM_REQUEST_CHECK_APP)
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_CHECK_APP, pkgtype, pkgid, NULL, NULL, 1);
+
+ if (ret < 0)
+ _LOGE("request failed, ret=%d\n", ret);
+
+ pid = __check_sync_process(pkgid);
+ * (int *) data = pid;
+
+catch:
+ if(req_key)
+ free(req_key);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ return ret;
+
+}
+
+static int __request_size_info(pkgmgr_client * pc)
+{
+ char *req_key = NULL;
+ int ret =0;
+ char *pkgtype = "rpm";
+ char *pkgid = "size_info";
+ pkgmgr_getsize_type get_type = PM_GET_SIZE_INFO;
+
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int i = 0;
+ char buf[128] = {'\0'};
+ char *cookie = NULL;
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+
+ req_key = __get_req_key(pkgid);
+
+ snprintf(buf, 128, "%d", get_type);
+ argv[argcnt++] = strdup(pkgid);
+ argv[argcnt++] = strdup(buf);
+ argv[argcnt++] = strdup(buf);
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+
+ /* request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, 1);
+ if (ret < 0)
+ _LOGE("comm_client_request failed, ret=%d\n", ret);
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ return ret;
+}
+
+static int __change_op_cb_for_getsize(pkgmgr_client *pc)
+{
+ int ret = -1;
+
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* free listening head */
+ req_cb_info *tmp = NULL;
+ req_cb_info *prev = NULL;
+ for (tmp = mpc->info.request.rhead; tmp;) {
+ prev = tmp;
+ tmp = tmp->next;
+ free(prev);
+ }
+
+ /* free dbus connection */
+ ret = comm_client_free(mpc->info.request.cc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
+
+ /* Manage pc for seperated event */
+ mpc->ctype = PC_REQUEST;
+ mpc->status_type = PKGMGR_CLIENT_STATUS_GET_SIZE;
+
+
+ mpc->info.request.cc = comm_client_new();
+ retvm_if(mpc->info.request.cc == NULL, PKGMGR_R_ERROR, "client creation failed");
+
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_GET_SIZE, mpc->info.request.cc, __operation_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "set_status_callback() failed - %d", ret);
+
+ return PKGMGR_R_OK;
+}
+
+API pkgmgr_client *pkgmgr_client_new(client_type ctype)
+{
+ pkgmgr_client_t *pc = NULL;
+ int ret = -1;
+
+ retvm_if(ctype != PC_REQUEST && ctype != PC_LISTENING && ctype != PC_BROADCAST, NULL, "ctype is not client_type");
+
+ /* Allocate memory for ADT:pkgmgr_client */
+ pc = calloc(1, sizeof(pkgmgr_client_t));
+ retvm_if(pc == NULL, NULL, "No memory");
+
+ /* Manage pc */
+ pc->ctype = ctype;
+ pc->status_type = PKGMGR_CLIENT_STATUS_ALL;
+
+ if (pc->ctype == PC_REQUEST) {
+ pc->info.request.cc = comm_client_new();
+ trym_if(pc->info.request.cc == NULL, "client creation failed");
+
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.request.cc, __operation_callback, pc);
+ trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
+ } else if (pc->ctype == PC_LISTENING) {
+ pc->info.listening.cc = comm_client_new();
+ trym_if(pc->info.listening.cc == NULL, "client creation failed");
+
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.listening.cc, __status_callback, pc);
+ trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
+ } else if (pc->ctype == PC_BROADCAST) {
+ pc->info.broadcast.bc = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
+ trym_if(pc->info.broadcast.bc == NULL, "client creation failed");
+ }
+
+ return (pkgmgr_client *) pc;
+
+ catch:
+ if (pc)
+ free(pc);
+ return NULL;
+}
+
+API int pkgmgr_client_free(pkgmgr_client *pc)
+{
+ int ret = -1;
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc == NULL, PKGMGR_R_EINVAL, "Invalid argument");
+
+ if (mpc->ctype == PC_REQUEST) {
+ req_cb_info *tmp;
+ req_cb_info *prev;
+ for (tmp = mpc->info.request.rhead; tmp;) {
+ prev = tmp;
+ tmp = tmp->next;
+ free(prev);
+ }
+
+ ret = comm_client_free(mpc->info.request.cc);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
+ } else if (mpc->ctype == PC_LISTENING) {
+ listen_cb_info *tmp;
+ listen_cb_info *prev;
+ for (tmp = mpc->info.listening.lhead; tmp;) {
+ prev = tmp;
+ tmp = tmp->next;
+ free(prev);
+ }
+
+ ret = comm_client_free(mpc->info.listening.cc);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
+ } else if (mpc->ctype == PC_BROADCAST) {
+ comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
+ ret = 0;
+ } else {
+ _LOGE("Invalid client type\n");
+ return PKGMGR_R_EINVAL;
+ }
+
+ free(mpc);
+ mpc = NULL;
+ return PKGMGR_R_OK;
+
+ catch:
+ if (mpc) {
+ free(mpc);
+ mpc = NULL;
+ }
+ return PKGMGR_R_ERROR;
+}
+
+API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
+ const char *descriptor_path, const char *pkg_path,
+ const char *optional_file, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data)
+{
+ char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = 0;
+ char *cookie = NULL;
+ char *caller_pkgid = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL");
+
+ /* 0. check the pc type */
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ if (descriptor_path) {
+ retvm_if(strlen(descriptor_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "descriptor_path over PKG_STRING_LEN_MAX");
+ retvm_if(access(descriptor_path, F_OK) != 0, PKGMGR_R_EINVAL, "descriptor_path access fail");
+ }
+
+ retvm_if(pkg_path == NULL, PKGMGR_R_EINVAL, "pkg_path is NULL");
+ retvm_if(strlen(pkg_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkg_path over PKG_STRING_LEN_MAX");
+ retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
+
+ if (optional_file)
+ retvm_if(strlen(optional_file) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
+
+ /* 2. get installer path using pkg_path */
+ if (pkg_type) {
+ installer_path = _get_backend_path_with_type(pkg_type);
+ pkgtype = strdup(pkg_type);
+ } else {
+ installer_path = _get_backend_path(pkg_path);
+ pkgtype = __get_type_from_path(pkg_path);
+ }
+ if (installer_path == NULL) {
+ free(pkgtype);
+ _LOGE("installer_path is NULL\n");
+ return PKGMGR_R_EINVAL;
+ }
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkg_path);
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
+
+ caller_pkgid = __get_caller_pkgid();
+ if (caller_pkgid == NULL)
+ _LOGE("caller dont have pkgid..\n");
+
+ /* 5. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-i");
+ /* argv[(4)] if exists */
+ if (descriptor_path)
+ argv[argcnt++] = strdup(descriptor_path);
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkg_path);
+ /* argv[(5)] if exists */
+ if (optional_file){
+ argv[argcnt++] = strdup("-o");
+ argv[argcnt++] = strdup(optional_file);
+ }
+ if (caller_pkgid) {
+ argv[argcnt++] = strdup("-p");
+ argv[argcnt++] = strdup(caller_pkgid);
+ }
+
+
+/* argv[6] -q option should be located at the end of command !! */
+ if (mode == PM_QUIET)
+ argv[argcnt++] = strdup("-q");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_path, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if (args)
+ free(args);
+ if (pkgtype)
+ free(pkgtype);
+ if (cookie)
+ free(cookie);
+
+ return ret;
+}
+
+API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
+ const char *optional_file, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data)
+{
+ char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = 0;
+ char *cookie = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
+
+
+ /* 1. check argument */
+ retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
+ retv_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL);
+ if (optional_file) {
+ if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
+ return PKGMGR_R_EINVAL;
+ }
+
+ /* 2. get installer path using pkg_path */
+ installer_path = _get_backend_path_with_type(pkg_type);
+ pkgtype = strdup(pkg_type);
+ tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path is null");
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkgid);
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
+
+ /* 5. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-r");
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkgid);
+ /* argv[(5)] if exists */
+ if (optional_file){
+ argv[argcnt++] = strdup("-o");
+ argv[argcnt++] = strdup(optional_file);
+ }
+
+ /* argv[5] -q option should be located at the end of command !! */
+ if (mode == PM_QUIET)
+ argv[argcnt++] = strdup("-q");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed");
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if (args)
+ free(args);
+ if (pkgtype)
+ free(pkgtype);
+ if (cookie)
+ free(cookie);
+
+ return ret;
+}
+
+API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid, pkgmgr_mode mode,
+ pkgmgr_handler event_cb, void *data)
+{
+ char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = -1;
+ char *cookie = NULL;
+ bool removable = false;
+ char *caller_pkgid = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
+
+ /* 1. check argument */
+ retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
+
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+
+ /*check package id */
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
+ tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
+
+ /*check type */
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
+ tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
+
+ /*check removable*/
+ pkgmgrinfo_pkginfo_is_removable(handle, &removable);
+ tryvm_if(removable == false, ret = PKGMGR_R_ERROR, "Pkgid(%s) can not be removed, This is non-removalbe package...\n", pkgid);
+
+ /*check pkgid length */
+ tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
+
+ /* 2. get installer path using pkgtype */
+ installer_path = _get_backend_path_with_type(pkgtype);
+ tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkgid);
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
+
+ caller_pkgid = __get_caller_pkgid();
+ if (caller_pkgid == NULL)
+ _LOGE("caller dont have pkgid..\n");
+
+ /* 5. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-d");
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkgid);
+ if (caller_pkgid) {
+ argv[argcnt++] = strdup("-p");
+ argv[argcnt++] = caller_pkgid;
+ }
+ /* argv[5] -q option should be located at the end of command !! */
+ if (mode == PM_QUIET)
+ argv[argcnt++] = strdup("-q");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ PKGMGR_END();\
+ return ret;
+}
+
+API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
+{
+ char *pkgtype = NULL;
+ char *installer_path= NULL;
+ char *req_key = NULL;
+ int req_id = 0;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = -1;
+ char *cookie = NULL;
+ char buf[128] = {'\0'};
+ pkgmgrinfo_install_location location = 0;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
+
+ /* 1. check argument */
+ retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
+
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+
+ /*check package id */
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
+ tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
+
+ pkgmgrinfo_pkginfo_get_install_location(handle, &location);
+ tryvm_if(location == PMINFO_INSTALL_LOCATION_INTERNAL_ONLY, ret = PKGMGR_R_ERROR, "package[%s] is internal-only, can not be moved", pkgid);
+
+ /*check type */
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
+ tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
+ tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
+
+ /*check pkgid length */
+ tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
+
+ /*check move_type */
+ tryvm_if((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "move_type is not supported");
+
+ /* 2. get installer path using pkgtype */
+ installer_path = _get_backend_path_with_type(pkgtype);
+ tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(pkgid);
+
+ /* 4. add callback info - add callback info to pkgmgr_client */
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
+
+ /* 5. generate argv */
+ snprintf(buf, 128, "%d", move_type);
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-m");
+ /* argv[4] */
+ argv[argcnt++] = strdup(pkgid);
+ /* argv[5] */
+ argv[argcnt++] = strdup("-t");
+ /* argv[6] */
+ argv[argcnt++] = strdup(buf);
+ /* argv[5] -q option should be located at the end of command !! */
+ argv[argcnt++] = strdup("-q");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+ /******************* end of quote ************************/
+
+ /* 6. request install */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
+
+ ret = req_id;
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ PKGMGR_END();\
+ return ret;
+}
+
+API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type,
+ const char *pkgid)
+{
+ const char *pkgtype = NULL;
+ char *req_key = NULL;
+ char *cookie = NULL;
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if ((ret == 0) && (handle != NULL)) {
+ SECURE_LOGD("pkg[%s] is already installed.", pkgid);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ // This package is already installed. skip the activation event.
+ return PKGMGR_R_OK;
+ }
+
+ if (pkg_type == NULL) {
+ pkgtype = _get_pkg_type_from_desktop_file(pkgid);
+ retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
+ } else
+ pkgtype = pkg_type;
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(pkgid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "1 PKG", cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ free(req_key);
+ return ret;
+}
+
+API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid)
+{
+ const char *pkgtype = NULL;
+ char *req_key = NULL;
+ char *cookie = NULL;
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ // This package is not installed. skip the deactivation event.
+ if ((ret < 0) || (handle == NULL)) {
+ SECURE_LOGD("pkg[%s] is not installed.", pkgid);
+ return PKGMGR_R_OK;
+ }
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ if (pkg_type == NULL) {
+ pkgtype = _get_pkg_type_from_desktop_file(pkgid);
+ if (pkgtype == NULL)
+ return PKGMGR_R_EINVAL;
+ } else
+ pkgtype = pkg_type;
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(pkgid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "0 PKG", cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ free(req_key);
+ return ret;
+}
+
+API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
+{
+ const char *pkgtype = NULL;
+ char *req_key = NULL;
+ char *cookie = NULL;
+ int ret = 0;
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ pkgtype = _get_pkg_type_from_desktop_file(appid);
+ retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(appid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "1 APP", cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ free(req_key);
+ return ret;
+}
+
+API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[])
+{
+ const char *pkgtype = NULL;
+ char *req_key = NULL;
+ char *cookie = NULL;
+ int ret = 0;
+ int i = 0;
+ char *temp = NULL;
+ int len = 0;
+ int argcnt = 0;
+ char *args = NULL;
+ char *argsr = NULL;
+ char argsrv[PKG_ARGC_MAX] = { NULL, };
+
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ pkgtype = _get_pkg_type_from_desktop_file(appid);
+ retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(appid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ if (argv) {
+ for (i = 0; argv[i]; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ argcnt++;
+ }
+
+ if (argcnt) {
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ }
+ }
+
+ argsr = (char *)calloc(strlen("1 APP")+3+len, sizeof(char));
+ tryvm_if(argsr == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
+
+ snprintf(argsrv, PKG_ARGC_MAX, "1 APP %s", args);
+ strncpy(argsr, argsrv, strlen(argsrv));
+
+ _LOGD("argsr [%s]\n", argsr);
+ /******************* end of quote ************************/
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, argsr, cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+
+ free(req_key);
+ free(args);
+ free(argsr);
+
+ return ret;
+}
+
+API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
+{
+ const char *pkgtype = NULL;
+ char *req_key = NULL;
+ char *cookie = NULL;
+ int ret = 0;
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
+
+ /* 1. check argument */
+ retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+ retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
+
+ pkgtype = _get_pkg_type_from_desktop_file(appid);
+ retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
+
+ /* 2. generate req_key */
+ req_key = __get_req_key(appid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ /* 3. request activate */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "0 APP", cookie, 1);
+ tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
+
+ ret = PKGMGR_R_OK;
+
+catch:
+ free(req_key);
+ return ret;
+}
+
+
+API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
+ const char *appid, pkgmgr_mode mode)
+{
+ const char *pkgtype = NULL;
+ char *installer_path = NULL;
+ char *req_key = NULL;
+ int i = 0;
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int ret = 0;
+ char *cookie = NULL;
+
+ /* Check for NULL value of pc */
+ if (pc == NULL) {
+ _LOGD("package manager client handle is NULL\n");
+ return PKGMGR_R_EINVAL;
+ }
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ if (mpc->ctype != PC_REQUEST)
+ return PKGMGR_R_EINVAL;
+
+ /* 1. check argument */
+ if (appid == NULL)
+ return PKGMGR_R_EINVAL;
+
+
+ if (pkg_type == NULL) {
+ pkgtype = _get_pkg_type_from_desktop_file(appid);
+ if (pkgtype == NULL)
+ return PKGMGR_R_EINVAL;
+ } else
+ pkgtype = pkg_type;
+
+ if (strlen(appid) >= PKG_STRING_LEN_MAX)
+ return PKGMGR_R_EINVAL;
+
+ /* 2. get installer path using pkg_path */
+ installer_path = _get_backend_path_with_type(pkgtype);
+ if (installer_path == NULL)
+ return PKGMGR_R_EINVAL;
+
+ /* 3. generate req_key */
+ req_key = __get_req_key(appid);
+
+ /* 4. generate argv */
+
+ /* argv[0] installer path */
+ argv[argcnt++] = installer_path;
+ /* argv[1] */
+ argv[argcnt++] = strdup("-k");
+ /* argv[2] */
+ argv[argcnt++] = req_key;
+ /* argv[3] */
+ argv[argcnt++] = strdup("-c");
+ /* argv[4] */
+ argv[argcnt++] = strdup(appid);
+ /* argv[5] -q option should be located at the end of command !! */
+ if (mode == PM_QUIET)
+ argv[argcnt++] = strdup("-q");
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ if (args == NULL) {
+ _LOGD("calloc failed");
+
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ return PKGMGR_R_ERROR;
+ }
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+ /******************* end of quote ************************/
+
+ /* 6. request clear */
+ ret = comm_client_request(mpc->info.request.cc, req_key,
+ COMM_REQ_TO_CLEARER, pkgtype, appid,
+ args, cookie, 1);
+ if (ret < 0) {
+ _LOGE("request failed, ret=%d\n", ret);
+
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ free(args);
+ return PKGMGR_R_ECOMM;
+ }
+
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ free(args);
+
+ return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type)
+{
+ int ret = -1;
+
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+ retvm_if(status_type == PKGMGR_CLIENT_STATUS_ALL, PKGMGR_R_OK, "status_type is PKGMGR_CLIENT_STATUS_ALL");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* free listening head */
+ listen_cb_info *tmp = NULL;
+ listen_cb_info *prev = NULL;
+ for (tmp = mpc->info.listening.lhead; tmp;) {
+ prev = tmp;
+ tmp = tmp->next;
+ free(prev);
+ }
+
+ /* free dbus connection */
+ ret = comm_client_free(mpc->info.listening.cc);
+ retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
+
+ /* Manage pc for seperated event */
+ mpc->ctype = PC_LISTENING;
+ mpc->status_type = status_type;
+
+ mpc->info.listening.cc = comm_client_new();
+ retvm_if(mpc->info.listening.cc == NULL, PKGMGR_R_EINVAL, "client creation failed");
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL) == PKGMGR_CLIENT_STATUS_INSTALL) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "PKGMGR_CLIENT_STATUS_INSTALL failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UNINSTALL) == PKGMGR_CLIENT_STATUS_UNINSTALL) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UNINSTALL, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UNINSTALL failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_MOVE) == PKGMGR_CLIENT_STATUS_MOVE) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_MOVE, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_MOVE failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) == PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL_PROGRESS, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_INSTALL_PROGRESS failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UPGRADE) == PKGMGR_CLIENT_STATUS_UPGRADE) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UPGRADE, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UPGRADE failed - %d", ret);
+ }
+
+ if ((mpc->status_type & PKGMGR_CLIENT_STATUS_GET_SIZE) == PKGMGR_CLIENT_STATUS_GET_SIZE) {
+ ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_GET_SIZE, mpc->info.listening.cc, __status_callback, pc);
+ retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_GET_SIZE failed - %d", ret);
+ }
+
+ return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
+ void *data)
+{
+ int req_id;
+ /* Check for NULL value of pc */
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check input */
+ retvm_if(mpc->ctype != PC_LISTENING, PKGMGR_R_EINVAL, "ctype is not PC_LISTENING");
+ retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL");
+
+ /* 1. get id */
+ req_id = _get_request_id();
+
+ /* 2. add callback info to pkgmgr_client */
+ __add_stat_cbinfo(mpc, req_id, event_cb, data);
+ return req_id;
+}
+
+API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
+ const char *pkgid, const char *key,
+ const char *val)
+{
+ /* Check for NULL value of pc */
+ if (pc == NULL) {
+ _LOGD("package manager client handle is NULL\n");
+ return PKGMGR_R_EINVAL;
+ }
+ /* Check for valid arguments. NULL parameter causes DBUS to abort */
+ if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
+ _LOGD("Argument supplied is NULL\n");
+ return PKGMGR_R_EINVAL;
+ }
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+ /* 0. check the pc type */
+ if (mpc->ctype != PC_BROADCAST)
+ return PKGMGR_R_EINVAL;
+
+ comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, mpc->info.broadcast.bc,
+ PKG_STATUS, pkg_type,
+ pkgid, key, val);
+
+ return PKGMGR_R_OK;
+}
+
+API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
+{
+ return pkgmgr_info_new_from_file(NULL, pkg_path);
+}
+
+API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info)
+{
+ if (pkg_info == NULL)
+ return PKGMGR_R_EINVAL;
+
+ package_manager_pkg_detail_info_t *info = (package_manager_pkg_detail_info_t *)pkg_info;
+
+ if (info->icon_buf)
+ free(info->icon_buf);
+
+ free(info);
+ info = NULL;
+
+ return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode,
+ pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
+ const char *custom_info, pkgmgr_handler event_cb, void *data)
+{
+ int ret =0;
+
+ /* Check for NULL value of service type */
+ retvm_if(service_type > PM_REQUEST_MAX, PKGMGR_R_EINVAL, "service type is not defined\n");
+ retvm_if(service_type < 0, PKGMGR_R_EINVAL, "service type is error\n");
+
+ switch (service_type) {
+ case PM_REQUEST_CSC:
+ tryvm_if(custom_info == NULL, ret = PKGMGR_R_EINVAL, "custom_info is NULL\n");
+ tryvm_if(strlen(custom_info) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
+ tryvm_if(data == NULL, ret = PKGMGR_R_EINVAL, "data is NULL\n");
+
+ ret = __csc_process(custom_info, (char *)data);
+ if (ret < 0)
+ _LOGE("__csc_process fail \n");
+ else
+ ret = PKGMGR_R_OK;
+
+ break;
+
+ case PM_REQUEST_MOVE:
+ tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
+ tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
+ tryvm_if((service_mode < PM_MOVE_TO_INTERNAL) || (service_mode > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "service_mode[%d] is wrong\n", service_mode);
+
+ ret = __move_pkg_process(pc, pkgid, (pkgmgr_move_type)service_mode, event_cb, data);
+ break;
+
+ case PM_REQUEST_GET_SIZE:
+ tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
+ tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
+ tryvm_if((service_mode < PM_GET_TOTAL_SIZE) || (service_mode >= PM_GET_MAX), ret = PKGMGR_R_EINVAL, "service_mode[%d] is wrong\n", service_mode);
+
+ ret = __get_size_process(pc, pkgid, (pkgmgr_getsize_type)service_mode, event_cb, data);
+ break;
+
+ case PM_REQUEST_KILL_APP:
+ case PM_REQUEST_CHECK_APP:
+ tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
+ tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
+
+ ret = __check_app_process(service_type, pc, pkgid, data);
+ if (ret < 0)
+ _LOGE("__check_app_process fail \n");
+ else
+ ret = PKGMGR_R_OK;
+
+ break;
+
+ default:
+ _LOGE("Wrong Request\n");
+ ret = -1;
+ break;
+ }
+
+catch:
+
+ return ret;
+}
+
+API int pkgmgr_client_request_size_info(void)
+{
+ int ret = 0;
+ pkgmgr_client *pc = NULL;
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ retvm_if(pc == NULL, PKGMGR_R_EINVAL, "request pc is null\n");
+
+ ret = __request_size_info(pc);
+ if (ret < 0) {
+ _LOGE("__request_size_info fail \n");
+ }
+
+ pkgmgr_client_free(pc);
+ return ret;
+}
+
+API int pkgmgr_client_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
+{
+ char *req_key = NULL;
+ int ret =0;
+ char *pkgtype = "rpm";
+ char *argv[PKG_ARGC_MAX] = { NULL, };
+ char *args = NULL;
+ int argcnt = 0;
+ int len = 0;
+ char *temp = NULL;
+ int i = 0;
+ char buf[128] = {'\0'};
+ char *cookie = NULL;
+ int req_id = 0;
+
+ pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+ retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
+ retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL\n");
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL\n");
+
+ ret = __change_op_cb_for_getsize(mpc);
+ retvm_if(ret < 0 , PKGMGR_R_EINVAL, "__change_op_cb_for_getsize is fail");
+
+ req_key = __get_req_key(pkgid);
+ retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
+
+ req_id = _get_request_id();
+ __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
+
+ snprintf(buf, 128, "%d", get_type);
+ argv[argcnt++] = strdup(pkgid);
+ argv[argcnt++] = strdup(buf);
+ argv[argcnt++] = strdup("-k");
+ argv[argcnt++] = req_key;
+
+ /*** add quote in all string for special charactor like '\n'*** FIX */
+ for (i = 0; i < argcnt; i++) {
+ temp = g_shell_quote(argv[i]);
+ len += (strlen(temp) + 1);
+ g_free(temp);
+ }
+
+ args = (char *)calloc(len, sizeof(char));
+ tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
+
+ strncpy(args, argv[0], len - 1);
+
+ for (i = 1; i < argcnt; i++) {
+ strncat(args, " ", strlen(" "));
+ temp = g_shell_quote(argv[i]);
+ strncat(args, temp, strlen(temp));
+ g_free(temp);
+ }
+ _LOGD("[args] %s [len] %d\n", args, len);
+
+ /* get cookie from security-server */
+ cookie = __get_cookie_from_security_server();
+ tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
+
+ /* request */
+ ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, 1);
+ if (ret < 0)
+ _LOGE("comm_client_request failed, ret=%d\n", ret);
+
+catch:
+ for (i = 0; i < argcnt; i++)
+ free(argv[i]);
+
+ if(args)
+ free(args);
+ if (cookie)
+ free(cookie);
+
+ return ret;
+}
+
+API int pkgmgr_client_enable_pkg(const char *pkgid)
+{
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ if (strstr(pkgid,":")==NULL) {
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if ((ret == 0) && (handle != NULL)) {
+ SECURE_LOGD("pkg[%s] is already installed.", pkgid);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ // This package is already installed. skip the activation event.
+ return PKGMGR_R_OK;
+ }
+ }
+
+ const char *enable_argv[] = { "/usr/bin/rpm-backend", "-k", "change-state", "-i", pkgid, NULL };
+ ret = __xsystem(enable_argv);
+ if (ret < 0)
+ SECURE_LOGD("enable pkg[%s] failed\n", pkgid);
+ else
+ SECURE_LOGD("enable pkg[%s] success\n", pkgid);
+ return ret;
+}
+
+API int pkgmgr_client_disable_pkg(const char *pkgid)
+{
+ retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
+
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle = NULL;
+
+ if (strstr(pkgid,":")==NULL) {
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ // This package is not installed. skip the deactivation event.
+ if ((ret < 0) || (handle == NULL)) {
+ SECURE_LOGD("pkg[%s] is not installed.", pkgid);
+ return PKGMGR_R_OK;
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ }
+
+ const char *disable_argv[] = { "/usr/bin/rpm-backend", "-k", "change-state", "-d", pkgid, NULL };
+ ret = __xsystem(disable_argv);
+ if (ret < 0)
+ SECURE_LOGD("disable pkg[%s] failed\n", pkgid);
+ else
+ SECURE_LOGD("disable pkg[%s] success\n", pkgid);
+ return ret;
+}
+
+#define __START_OF_OLD_API
+ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+{
+ char *type;
+ char *package;
+ char *version;
+
+ iter_data *udata = (iter_data *) user_data;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &type);
+ if (type == NULL)
+ type = "";
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+ if (package == NULL)
+ package = "";
+ ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &version);
+ if (version == NULL)
+ version = "";
+
+ if (udata->iter_fn(type, package, version, udata->data) != 0)
+ return AIL_CB_RET_CANCEL;
+
+ return AIL_CB_RET_CONTINUE;
+}
+
+API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data)
+{
+ int cnt = -1;
+ ail_filter_h filter;
+ ail_error_e ret;
+
+ if (iter_fn == NULL)
+ return PKGMGR_R_EINVAL;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return PKGMGR_R_ERROR;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ return PKGMGR_R_ERROR;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ return PKGMGR_R_ERROR;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &cnt);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ return PKGMGR_R_ERROR;
+ }
+
+ iter_data *udata = calloc(1, sizeof(iter_data));
+ if (udata == NULL) {
+ _LOGE("calloc failed");
+ ail_filter_destroy(filter);
+
+ return PKGMGR_R_ERROR;
+ }
+ udata->iter_fn = iter_fn;
+ udata->data = data;
+
+ ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata);
+
+ free(udata);
+
+ ret = ail_filter_destroy(filter);
+ if (ret != AIL_ERROR_OK) {
+ return PKGMGR_R_ERROR;
+ }
+
+ return PKGMGR_R_OK;
+}
+
+API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkgid)
+{
+ const char *pkgtype;
+ pkg_plugin_set *plugin_set = NULL;
+ package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
+
+ /* 1. check argument */
+ if (pkgid == NULL)
+ return NULL;
+
+ if (pkg_type == NULL) {
+ pkgtype = _get_pkg_type_from_desktop_file(pkgid);
+ if (pkgtype == NULL)
+ return NULL;
+ } else
+ pkgtype = pkg_type;
+
+ if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
+ return NULL;
+
+ pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
+ if (pkg_detail_info == NULL) {
+ _LOGE("*** Failed to alloc package_handler_info.\n");
+ return NULL;
+ }
+
+ plugin_set = _package_manager_load_library(pkgtype);
+ if (plugin_set == NULL) {
+ _LOGE("*** Failed to load library");
+ free(pkg_detail_info);
+ return NULL;
+ }
+
+ if (plugin_set->pkg_is_installed) {
+ if (plugin_set->pkg_is_installed(pkgid) != 0) {
+ _LOGE("*** Failed to call pkg_is_installed()");
+ free(pkg_detail_info);
+ return NULL;
+ }
+
+ if (plugin_set->get_pkg_detail_info) {
+ if (plugin_set->get_pkg_detail_info(pkgid,
+ pkg_detail_info) != 0) {
+ _LOGE("*** Failed to call get_pkg_detail_info()");
+ free(pkg_detail_info);
+ return NULL;
+ }
+ }
+ }
+
+ return (pkgmgr_info *) pkg_detail_info;
+}
+
+API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key)
+{
+ package_manager_pkg_detail_info_t *pkg_detail_info;
+
+ if (pkg_info == NULL)
+ return NULL;
+ if (key == NULL)
+ return NULL;
+
+ pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info;
+
+ return _get_info_string(key, pkg_detail_info);
+}
+
+API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type,
+ const char *pkg_path)
+{
+ pkg_plugin_set *plugin_set = NULL;
+ package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
+ char *pkgtype;
+ if (pkg_path == NULL) {
+ _LOGE("pkg_path is NULL\n");
+ return NULL;
+ }
+
+ if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) {
+ _LOGE("length of pkg_path is too long - %d.\n",
+ strlen(pkg_path));
+ return NULL;
+ }
+
+ pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
+ if (pkg_detail_info == NULL) {
+ _LOGE("*** Failed to alloc package_handler_info.\n");
+ return NULL;
+ }
+
+ if (pkg_type == NULL)
+ pkgtype = __get_type_from_path(pkg_path);
+ else
+ pkgtype = strdup(pkg_type);
+
+ plugin_set = _package_manager_load_library(pkgtype);
+ if (plugin_set == NULL) {
+ free(pkg_detail_info);
+ free(pkgtype);
+ return NULL;
+ }
+
+ if (plugin_set->get_pkg_detail_info_from_package) {
+ if (plugin_set->get_pkg_detail_info_from_package(pkg_path,
+ pkg_detail_info) != 0) {
+ free(pkg_detail_info);
+ free(pkgtype);
+ return NULL;
+ }
+ }
+
+ free(pkgtype);
+ return (pkgmgr_info *) pkg_detail_info;
+}
+
+API int pkgmgr_info_free(pkgmgr_info * pkg_info)
+{
+ if (pkg_info == NULL)
+ return PKGMGR_R_EINVAL;
+
+ free(pkg_info);
+ pkg_info = NULL;
+
+ return 0;
+}
+
+#define __END_OF_OLD_API
+
+API int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_list(pkg_list_cb, user_data);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, handle);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_pkgname(pkgmgr_pkginfo_h handle, char **pkg_name)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_pkgname(handle, pkg_name);
+ return ret;
+}
+
+
+API int pkgmgr_pkginfo_get_pkgid(pkgmgr_pkginfo_h handle, char **pkgid)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, pkgid);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_type(pkgmgr_pkginfo_h handle, char **type)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_type(handle, type);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_version(pkgmgr_pkginfo_h handle, char **version)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_version(handle, version);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location)
+{
+ int ret = 0;
+ pkgmgrinfo_install_location loc;
+ ret = pkgmgrinfo_pkginfo_get_install_location(handle, &loc);
+ *location = loc;
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_package_size(pkgmgr_pkginfo_h handle, int *size)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_package_size(handle, size);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_icon(pkgmgr_pkginfo_h handle, char **icon)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_icon(handle, icon);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_label(handle, label);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_description(pkgmgr_pkginfo_h handle, char **description)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_description(handle, description);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_author_name(pkgmgr_pkginfo_h handle, char **author_name)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_author_name(handle, author_name);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_author_email(pkgmgr_pkginfo_h handle, char **author_email)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_author_email(handle, author_email);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_author_href(pkgmgr_pkginfo_h handle, char **author_href)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_author_href(handle, author_href);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_is_removable(pkgmgr_pkginfo_h handle, bool *removable)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_is_removable(handle, removable);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_is_preload(pkgmgr_pkginfo_h handle, bool *preload)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_is_preload(handle, preload);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_is_readonly(pkgmgr_pkginfo_h handle, bool *readonly)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_is_readonly(handle, readonly);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_is_accessible(pkgmgr_pkginfo_h handle, bool *accessible)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_is_accessible(handle, accessible);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_installed_storage(pkgmgr_pkginfo_h handle, pkgmgr_installed_storage *storage)
+{
+ int ret = 0;
+ pkgmgrinfo_installed_storage sto;
+ ret = pkgmgrinfo_pkginfo_get_installed_storage(handle, &sto);
+ *storage = sto;
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_installed_time(pkgmgr_pkginfo_h handle, int *installed_time)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_installed_time(handle, installed_time);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
+ pkgmgr_info_app_list_cb app_func, void *user_data)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_list(handle, component, app_func, user_data);
+ return ret;
+}
+
+API int pkgmgr_appinfo_foreach_category(pkgmgr_appinfo_h handle, pkgmgr_info_app_category_list_cb category_func,
+ void *user_data)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, user_data);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, handle);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_appid(handle, appid);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_pkgname(handle, pkg_name);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_pkgid(pkgmgr_appinfo_h handle, char **pkgid)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, pkgid);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_icon(pkgmgr_appinfo_h handle, char **icon)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_icon(handle, icon);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_label(pkgmgr_appinfo_h handle, char **label)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_label(handle, label);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_exec(pkgmgr_appinfo_h handle, char **exec)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_exec(handle, exec);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_component(pkgmgr_appinfo_h handle, pkgmgr_app_component *component)
+{
+ int ret = 0;
+ pkgmgrinfo_app_component comp;
+ ret = pkgmgrinfo_appinfo_get_component(handle, &comp);
+ *component = comp;
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_apptype(pkgmgr_appinfo_h handle, char **app_type)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, app_type);
+ return ret;
+}
+
+API int pkgmgr_appinfo_is_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_is_nodisplay(handle, nodisplay);
+ return ret;
+}
+
+API int pkgmgr_appinfo_is_multiple(pkgmgr_appinfo_h handle, bool *multiple)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_is_multiple(handle, multiple);
+ return ret;
+}
+
+API int pkgmgr_appinfo_is_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_is_taskmanage(handle, taskmanage);
+ return ret;
+}
+
+API int pkgmgr_appinfo_get_hwacceleration(pkgmgr_appinfo_h handle, pkgmgr_hwacceleration_type *hwacceleration)
+{
+ int ret = 0;
+ pkgmgrinfo_app_hwacceleration hwacc;
+ ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
+ *hwacceleration = hwacc;
+ return ret;
+}
+
+API int pkgmgr_appinfo_is_onboot(pkgmgr_appinfo_h handle, bool *onboot)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_is_onboot(handle, onboot);
+ return ret;
+}
+
+API int pkgmgr_appinfo_is_autorestart(pkgmgr_appinfo_h handle, bool *autorestart)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_is_autorestart(handle, autorestart);
+ return ret;
+}
+
+API int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_create_certinfo(handle);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_get_cert_value(handle, cert_type, cert_value);
+ return ret;
+}
+
+API int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
+ return ret;
+}
+
+API int pkgmgr_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_datacontrol_get_info(providerid, type, appid, access);
+ return ret;
+}
--- /dev/null
+[D-BUS Service]
+Name=com.samsung.slp.pkgmgr
+Exec=@PREFIX@/bin/env DISPLAY=:0 @PREFIX@/bin/pkgmgr-server
+User=root
--- /dev/null
+[D-BUS Service]
+Name=com.samsung.slp.pkgmgr
+Exec=/bin/false
+SystemdService=slp-pkgmgr.service
+User=root
\ No newline at end of file
--- /dev/null
+### Description
+# Communication modules for pkg-mgr client lib and server process
+# By Youmin Ha <youmin.ha@samsung.com>
+
+cmake_minimum_required(VERSION 2.6)
+#set(CMAKE_SKIP_BUILD_RPATH true)
+set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+
+### Versioning
+if(DEFINED ${VERSION})
+ message("VERSION: ${VERSION}")
+else()
+ message("VERSION is not defined. set it as 0.1.0")
+ set(VERSION 0.1.0)
+endif()
+if(DEFINED ${VERSION_MAJOR})
+ message("VERSION_MAJOR: ${VERSION_MAJOR}")
+else()
+ message( "VERSION_MAJOR is not defined. set it as 0")
+ set(VERSION_MAJOR 0)
+endif()
+message(STATUS "version/major : ${VERSION} / ${VERSION_MAJOR}")
+
+### Get required CFLAGS, LDFLAGS from pkg-config
+
+include(FindPkgConfig)
+pkg_check_modules(comm_pkgs REQUIRED dbus-1 glib-2.0 dbus-glib-1 gio-2.0 gio-unix-2.0 dlog pkgmgr-info)
+
+foreach(flag ${comm_pkgs_CFLAGS})
+ set(comm_pkgs_CFLAGS_str "${comm_pkgs_CFLAGS_str} ${flag}")
+endforeach()
+
+
+### Set current binary dir to be included (for generated *.h files)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+
+### Create dbus-glib bindings headers (client/server) from xml by dbus-binding-tool
+
+# comm_pkg_mgr : package manger interface (client - package manager process)
+add_custom_target(comm_pkg_mgr_client_dbus_bindings.h
+ COMMAND dbus-binding-tool --prefix=pkgmgr --mode=glib-client
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
+ --output=${CMAKE_CURRENT_BINARY_DIR}/comm_pkg_mgr_client_dbus_bindings.h
+ )
+add_custom_target(comm_pkg_mgr_server_dbus_bindings.h
+ COMMAND dbus-binding-tool --prefix=pkgmgr --mode=glib-server
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
+ --output=${CMAKE_CURRENT_BINARY_DIR}/comm_pkg_mgr_server_dbus_bindings.h
+ )
+
+#GDBUS specific code
+add_custom_command(OUTPUT comm_pkg_mgr_client_gdbus_generated.c comm_pkg_mgr_client_gdbus_generated.h
+ COMMAND gdbus-codegen --generate-c-code comm_pkg_mgr_client_gdbus_generated
+ --interface-prefix pkgmgr ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
+ )
+
+# comm_status_broadcast : status broadcast interface (client - backend process)
+add_custom_target(comm_status_broadcast_client_dbus_bindings.h
+ COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-client
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml
+ --output=${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_client_dbus_bindings.h
+ )
+add_custom_target(comm_status_broadcast_server_dbus_bindings.h
+ COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-server
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml
+ --output=${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_server_dbus_bindings.h
+ )
+
+### Create marshaller header/source for signal (client must use this)
+add_custom_target(comm_status_broadcast_signal_marshaller.h
+ COMMAND glib-genmarshal --header ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast_signal_marshaller.list > ${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.h
+ )
+add_custom_target(comm_status_broadcast_signal_marshaller.c
+ COMMAND glib-genmarshal --body ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast_signal_marshaller.list > ${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.c
+ )
+set_source_files_properties(comm_status_broadcast_signal_marshaller.c PROPERTIES GENERATED true) # This source is generated during build time, so this property must be set
+
+
+
+
+
+### Build modules
+
+## client for apps
+# Send request, get status signal
+add_library(pkgmgr_installer_client SHARED
+ comm_client_gdbus.c
+ comm_pkg_mgr_client_gdbus_generated.c
+ #${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_signal_marshaller.c
+ )
+set_target_properties(pkgmgr_installer_client PROPERTIES SOVERSION ${VERSION_MAJOR})
+set_target_properties(pkgmgr_installer_client PROPERTIES VERSION ${VERSION})
+set_target_properties(pkgmgr_installer_client PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
+target_link_libraries(pkgmgr_installer_client ${comm_pkgs_LDFLAGS})
+#add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_dbus_bindings.h comm_status_broadcast_client_dbus_bindings.h comm_status_broadcast_signal_marshaller.h comm_status_broadcast_signal_marshaller.c)
+add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_gdbus_generated.h comm_pkg_mgr_client_gdbus_generated.c)
+
+## pkg-mgr server for PMS
+# Get request
+add_library(pkgmgr_installer_pkg_mgr_server STATIC
+ comm_pkg_mgr_server.c)
+set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES SOVERSION ${VERSION_MAJOR})
+set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES VERSION ${VERSION})
+set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
+target_link_libraries(pkgmgr_installer_pkg_mgr_server ${comm_pkgs_LDFLAGS})
+add_dependencies(pkgmgr_installer_pkg_mgr_server comm_pkg_mgr_server_dbus_bindings.h)
+
+## status-broadcast server for backend/downloader
+# Send signal
+add_library(pkgmgr_installer_status_broadcast_server SHARED
+ comm_status_broadcast_server_dbus.c
+ )
+set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES SOVERSION ${VERSION_MAJOR})
+set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES VERSION ${VERSION})
+set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
+target_link_libraries(pkgmgr_installer_status_broadcast_server ${comm_pkgs_LDFLAGS})
+add_dependencies(pkgmgr_installer_status_broadcast_server comm_status_broadcast_server_dbus_bindings.h)
+
+
+## comm_socket
+# Internal lib
+add_library(comm_socket STATIC comm_socket.c)
+set_target_properties(comm_socket PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
+#target_link_libraries(comm_socket)
+
+## pkgmgr_installer object (by youmin.ha)
+# This library is for installer backend
+add_library(pkgmgr_installer SHARED pkgmgr_installer.c)
+set_target_properties(pkgmgr_installer PROPERTIES SOVERSION ${VERSION_MAJOR})
+set_target_properties(pkgmgr_installer PROPERTIES VERSION ${VERSION})
+set_target_properties(pkgmgr_installer PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
+target_link_libraries(pkgmgr_installer pkgmgr_installer_status_broadcast_server ${comm_pkgs_LDFLAGS})
+
+
+### Create pc file
+configure_file(pkgmgr-installer-client.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc @ONLY)
+configure_file(pkgmgr-installer-status-broadcast-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-status-broadcast-server.pc @ONLY)
+configure_file(pkgmgr-installer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc @ONLY)
+
+
+## Install
+INSTALL(TARGETS
+ pkgmgr_installer_client
+ pkgmgr_installer_status_broadcast_server
+ pkgmgr_installer
+ DESTINATION lib
+ COMPONENT RuntimeLibraries)
+INSTALL(FILES
+ comm_client.h
+ comm_status_broadcast_server.h
+ comm_config.h
+ pkgmgr_installer.h
+ DESTINATION include/pkgmgr)
+
+
+INSTALL(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc
+ ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-status-broadcast-server.pc
+ ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc
+ DESTINATION lib/pkgconfig)
+
+
+
+
+## test
+add_subdirectory(test)
+
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+/**
+ * @ingroup SLP_PG
+ * @defgroup pacakge_manager_PG PackageManagerStructure
+ * @brief A programming guide for deelopers who want to make a frontend/backend pair for a package type.
+ * @{
+
+<h1 class="pg">Introduction</h1>
+ <h2 class="pg">Terms of use</h2>
+ <ul>
+ <li><b>frontend</b> an installer frontend process</li>
+ <li><b>backend</b> an installer backend process</li>
+ <li><b>backendlib</b> a library of backend plugin</li>
+ <li><b>PMS</b> Package manager server</li>
+ </ul>
+
+ <h2 class="pg">Structure overview</h2>
+
+ When a command to install/update/delete a package to package-manager system, a frontend process receives request, and pass it to the package manager server. Package manager server will queue all requests, and runs backend one by one.<br>
+For example, <br>
+ <center>SamsungApps --(install foo.deb)--> frontend --(install foo.deb)--> PMS --(Run dpkg backend to install foo.deb)--> backend</center><br>
+
+When 'install' command is given, the package file to be installed is already downloaded by user's application (SamsungApps, ...), and these frontend/PMS/backend are only responsible for installing it.<br>
+Requests between frontend and PMS, and signal broadcasting between backend and frontend/apps are implemented by dbus.<br>
+<h2></h2><br>
+
+ To get the package information, backend plugin library is used. Each backend library provides the predefined functions, and package manager client library uses it.<br>
+ <center>SamsungApps ~~> package-manager client library ~~> backend end plugin library </center>
+ <center>(link and API call) (dynamic loading and symbol binding) </center><br>
+
+
+Detailed informations for each process are explained below.
+
+ <h2 class="pg">Frontend</h2>
+
+ A frontend is a program which shows UI to users(if needed), requests install/update/delete/recover to PMS, and shows installing status(if needed). frontend/backend programs must be exist per one package type. Again, each package type must have one frontend/backend pair.<br>
+
+ A frontend process runs with <b>user provilege</b>, executed by package-manager client API, in include/package-manager.h;
+<ul>
+ <li>package_manager_install_application()</li>
+ <li>package_manager_uninstall_application()</li>
+</ul>
+
+ Frontend process does following things;
+<ul>
+ <li>Gets arguments from argv, with one of following options;
+ <ul>
+ <li>-i <filepath> : Install package</li>
+ <li>-u <filepath> : Update package</li>
+ <li>-r : Recover package system</li>
+ <li>-d <package_name> : Delete package</li>
+ </ul>
+ </li>
+ <li>Gets cookie from security server.</li>
+ <li>Sends request to PMS, with various arguments and cookie.</li>
+ <li>Waits backend's status signals.</li>
+ <li>Updates UI accroding to backend's status signal, if necessary.</li>
+ <li>Finishes process when 'end' signal from backend comes.</li>
+</ul>
+
+A frontend has UI, so it runs in event-loop (usually ecore_loop, sometimes g_main_loop). We provide an object 'comm_client', which is integrated with g_main_loop. So, you have to program event-loop based code. Luckily the ecore_loop in SLP is integrated with g_main_loop, so you don't need to worry about using comm_client API in ecore_loop.
+
+ <h3 class="pg">Rules</h3>
+A frontend must have following features;
+<ul>
+ <li>Must be able to parse -i, -u, -r, -d, -q options.</li>
+ <li>Must be able to parse -k <req_id> option. This string is passed to backend, as a request id.
+ <li>Must have UI(at least a OK/Cancel dialog), which can be ignored by -q option.</li>
+ <li>Must be able to use g_main_loop based functions.</li>
+</ul>
+
+
+
+ <h2 class="pg">Package manager server</h2>
+Package Manager Server(PMS) is a <b>root</b> privilege process, which queues all requests from lots of frontends, and runs backends accrding to each requests. <br>
+PMS has a queue internally, which stores each request and runs one by one. <br>
+When no PMS is running yet, first frontend's request will execute PMS.
+
+ PMS process does following things;
+<ul>
+ <li>Receives requests from a frontend via dbus.</li>
+ <li>If the request has a wrong cookie, discard it.</li>
+ <li>Puts the request into the queue.</li>
+ <li>Pops a request from the queue, and sends it to corresponding backend.</li>
+ <li>When the backend finishes, run next request in the queue.</li>
+</ul>
+
+PMS is already made and installed in your system.
+
+ <h2 class="pg">Backend</h2>
+
+for a certain package type, a backend is a <b>root</b> privilege process invoked by PMS, which is doing following things;
+<ul>
+ <li>Parses input values</li>
+ <li>Checks signing of the package file, and verifies its validity (if necessary)
+ <li>Does install/update/delete a pacakge, or recovers package system, or </li>
+ <li>activate/deactivate a package</li>
+ <li>Broadcasts current status</li>
+</ul>
+
+ <h3 class="pg">Rules</h3>
+A backend must have following features;
+<ul>
+ <li>Must parse args string from frontend.</li>
+ <li>Must install/update/delete a package.</li>
+ <li>Must be able to recover package system, when it is corrupted.</li>
+ <li>Must broadcast current install/status</li>
+</ul>
+
+ <h2 class="pg">Backend library</h2>
+
+for a certain package type, a backend library is just a <b>library</b> client process uses this library.
+Backend library does following things;
+<ul>
+ <li>Checks whether package is installed or not</li>
+ <li>Gets the list of installed package</li>
+ <li>Gets the information of installed package</li>
+ <li>Gets the information from package file</li>
+</ul>
+
+ <h3 class="pg">Rules</h3>
+A backend must have following features;
+<ul>
+ <li>Must check whether package is installed or not.</li>
+ <li>Must get the list of installed package.</li>
+ <li>Must get the information of installed package.</li>
+ <li>Must gets the information from package file</li>
+</ul>
+
+
+<h1 class="pg">Programming guide</h1>
+
+ <h2 class="pg">Requied dev package</h2>
+libpkgmgr-installer-dev package is provided to develop installer frontend/backend. <br>
+@code
+$ apt-get install libpkgmgr-installer-dev
+@endcode
+
+libpkgmgr-types-dev package is provided to develop installer backendlib. <br>
+@code
+$ apt-get install libpkgmgr-types-dev
+@endcode
+
+Three package-config files are installed; pkgmgr-installer-client.pc and pkgmgr-installer-status-broadcast-server.pc and pkgmgr-types.pc
+The first one is for frontend, the second one is for backend, and last one if for backendlib <br>
+
+
+ <h2 class="pg">Installer frontend's programming guide</h2>
+
+comm_client module is provided for frontend programming, which can do comminucations with PMS and backend process.<br>
+
+Example code is in packages/test/frontend.c. <br>
+
+<B>NOTE:</b> This example code uses g_main_loop. If you use ecore_loop, you don't need to run g_main_loop_*() functions. <br>
+
+Every installer frontend's command arguments are like this; <br>
+@code
+$ <frontend> <cmd_opt> [<opt_val>] -k <req_id>
+@endcode
+<ul>
+ <li>frontend : An installer frontend executable file. </li>
+ <li>cmd_opt : One of -i(install package), -u(update package), -d(delete package), -r(recover package system), -a(activate package)</li>
+ <li>opt_val : Means package file path (with -i/-u), package name (with -d, -a). When cmd_opt is -r, no opt_val is required. </li>
+ <li>req_id : A request id, which is passed from frontend (with -k option) to backend. </li>
+</ul>
+
+
+
+ <h3 class="pg">Get a cookie from security-server</h3>
+To authenticate this frontend process, firstly you have to get a cookie from security server.<br>
+security-server.h from security-server package has cookie APIs. For more information, see security-server.h file.<br>
+@code
+
+#include <security-server.h>
+
+/* ...... */
+
+char *cookie;
+int cookie_size;
+int cookie_ret;
+
+cookie_size = security_server_get_cookie_size();
+/* If security server is down or some other error occured, raise failure */
+if(0 >= cookie_size) {
+ /* TODO: raise error */
+} else {
+ cookie = calloc(cookie_size, sizeof(char));
+ cookie_ret = security_server_request_cookie(cookie, cookie_size);
+ /* TODO: Check cookie_ret... (See security-server.h to check return code) */
+}
+
+@endcode
+This cookie string will be passed to PMS later.
+
+ <h3 class="pg">Parse argv options</h3>
+All frontends must support at least 5 options; -i, -u, -d, -r, -k, and -q. Parse each options, and do requested job. <br>
+Only one of following options must be taken. <br>
+ <ul>
+ <li>-i <filepath> : Install package</li>
+ <li>-u <filepath> : Update package</li>
+ <li>-r : Recover package system</li>
+ <li>-d <package_name> : Delete package</li>
+ </ul>
+Following options must be able to taken. <br>
+ <ul>
+ <li>-k <request_id> : An <b>unique string</b> to identify this request. This key will be included in status broadcast signals from backend.</li>
+ <li>-q : Quiet option. Do now show UI.</li>
+ </ul>
+
+
+The sample code uses getopt() function in unistd.h to parse argv options.<br>
+
+@code
+#include <unistd.h>
+#define BUFSIZE 256
+
+/* ...... */
+
+const char *opts_str = "i:u:d:rqk:";
+int s = 0;
+int quite = 0;
+int mode = 0;
+char buf[BUFSIZE];
+char req_id[BUFSIZE];
+
+
+while(-1 != (s = getopt(argc, argv, opts_str))) {
+ switch(s) {
+ case 'i':
+ if(mode) break;
+ mode = MODE_INSTALL;
+ strncpy(buf, optarg, BUFSIZE);
+ break;
+ case 'u':
+ if(mode) break;
+ mode = MODE_UPDATE;
+ strncpy(buf, optarg, BUFSIZE);
+ break;
+ case 'd':
+ if(mode) break;
+ mode = MODE_DELETE;
+ strncpy(buf, optarg, BUFSIZE);
+ break;
+ case 'r':
+ if(mode) break;
+ mode = MODE_RECOVER;
+ break;
+ case 'q':
+ quite = 1;
+ break;
+ case 'k':
+ strncpy(req_id, optarg, BUFSIZE);
+
+ default:
+ usage(); /* Show usage, and exit */
+ }
+}
+
+@endcode
+
+ <h3 class="pg">Do send a request to install,update,delete or recover</h3>
+After parsing argv options, now your frontend knows what command will be request to your backend. For this work, we provide APIs.
+
+ <h3 class="pg"></h3>
+ <h3 class="pg"></h3>
+ <h3 class="pg"></h3>
+
+ <h2 class="pg">Installer backend's programming guide</h2>
+
+Example code is in packages/test/backend.c. <br>
+
+ <h3 class="pg">Parse command args</h3>
+Every installer backend's command arguments are like this; <br>
+@code
+$ <backend> <req_id> <pkgid> [<arg1> <arg2> <arg3> ...]
+@endcode
+<ul>
+ <li>backend : An installer backend executable file. </li>
+ <li>req_id : A request id, which is passed from frontend (with -k option). This is broadcasted with all signals from this backend. </li>
+ <li>pkgid : package name</li>
+ <li>arg1, arg2, ... : Separated arguments from frontend. You can use anything. This is a rule just between frontend and backend. </li>
+</ul>
+
+Those options must be parsed and processed properly. <br>
+
+ <h3 class="pg">Broadcast installing status</h3>
+Backend must broadcast its installing status. You can broadcast your status by using following API.
+@code
+#include "comm_status_broadcast_server.h"
+
+/* ... */
+
+DBusConnection *conn;
+conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
+
+comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "start", "0");
+/* ... */
+comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL,conn, req_id, pkg_type, pkgid, "install_percent", "60");
+/* ... */
+comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, req_id, pkg_type, pkgid, "end", "0");
+
+/* ... */
+@endcode
+
+Last two values are key/value pair. Following values are mandatory;
+<table>
+ <tr>
+ <th>key</th>
+ <th>value</th>
+ <th>Comment</th>
+ </tr>
+ <tr>
+ <td>start</td>
+ <td>download|install|uninstall|update|recover</td>
+ <td>Start backend process. <br>NOTE: 'download' is used only by downloader.</td>
+ </tr>
+ <tr>
+ <td>install_percent</td>
+ <td>[number between 0~100]</td>
+ <td>Install progress</td>
+ </tr>
+ <tr>
+ <td>error</td>
+ <td>[string]</td>
+ <td>Error message</td>
+ </tr>
+ <tr>
+ <td>end</td>
+ <td>ok|fail</td>
+ <td>End backend (Process termination)</td>
+ </tr>
+</table>
+
+Following values are required also. If you need any of them in downloader or installer backend, send it. <br>
+<table>
+ <tr>
+ <th>key</th>
+ <th>value</th>
+ <th>Comment</th>
+ </tr>
+ <tr>
+ <td>icon_path</td>
+ <td>path of icon file</td>
+ <td>Before icon and *.desktop files are installed, menu-screen must have temporary icon file. This option indicates temporary icon file's path.<br>If no icon_path is provided, menu-screen will use general temporary icon.</td>
+ </tr>
+ <tr>
+ <td>download_percent</td>
+ <td>[number between 0~100]</td>
+ <td>Download progress<br>NOTE: This key is used by downloader only. Installer backends don't use this.</td>
+</table>
+
+You can send any other key/val pair by this API, to send any information to your frontend or donwloader app. Any keys except above will be ignored by PMS.<br>
+
+
+
+ <h2 class="pg">Installer backendlib's programming guide</h2>
+Example code is in packages/installers/sample/sample_backendlib.c. <br>
+
+ <h3 class="pg">Plugin implementation</h3>
+Backendlib should implemented according to following Rule.
+<ul>
+ <li>Exported API : pkg_plugin_onload() is a exported symbol. This symbol is found when after loading the library. </li>
+ <li>function pointer : _pkg_plugin_set defines the structor of function pointer. Each functions are implemented. </li>
+ <li>function mapping : defined each functions are connected to function pointer when pkg_plugin_onload() is called. </li>
+</ul>
+
+@code
+#include "package-manager-plugin.h"
+
+
+static void pkg_native_plugin_unload (void)
+{
+ //ToDo
+}
+
+static int pkg_plugin_app_is_installed(const char *pkgid)
+{
+ //ToDo
+
+ return 0;
+}
+
+static int pkg_plugin_get_installed_apps_list(package_manager_pkg_info_t **list, int *count)
+{
+ //ToDo
+
+ return 0;
+}
+
+static int pkg_plugin_get_app_detail_info(const char *pkgid, package_manager_pkg_detail_info_t* pkg_detail_info)
+{
+ //ToDo
+
+ return 0;
+}
+
+static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path, package_manager_pkg_detail_info_t* pkg_detail_info)
+{
+ //ToDo
+
+ return 0;
+}
+
+
+int pkg_plugin_onload (pkg_plugin_set * set)
+{
+ if(set == NULL)
+ {
+ return -1;
+ }
+
+ memset(set, 0x00, sizeof(pkg_plugin_set));
+
+ set->plugin_unload = pkg_native_plugin_unload;
+ set->pkg_is_installed = pkg_plugin_app_is_installed;
+ set->get_installed_pkg_list = pkg_plugin_get_installed_apps_list;
+ set->get_pkg_detail_info = pkg_plugin_get_app_detail_info;
+ set->get_pkg_detail_info_from_package = pkg_plugin_get_app_detail_info_from_package;
+
+ return 0;
+}
+@endcode
+
+
+
+ <h2 class="pg">Install frontend/backend</h2>
+Your frontend/backend binary executables have to be installed. Usually they are installed into @PREFIX@/bin/. <br>
+
+One thing you must do is that your backend binary's owner must be <b>root</b>, permission must be <b>700</b>.
+In case of backendlib, it's permission is <b>644</b>.
+
+
+ <h2 class="pg">Create symlinks for your frontend/backend binaries and backendlib library</h2>
+After installing your frontend/backend, You have to create symlinks pointing your frontend/backend binaries. <br>
+Those symlinks must be installed as following paths;
+<ul>
+ <li>frontend : @PREFIX@/etc/package-manager/frontend/<your package file's extension></li>
+ <li>backend : @PREFIX@/etc/package-manager/backend/<your package file's extension></li>
+ <li>backendlib : @PREFIX@/etc/package-manager/backendlib/lib[<your package file's extension>].so</li>
+</ul>
+For example, the debian package (*.deb) must have symlink @PREFIX@/etc/package-manager/frontend/deb, which is pointing actual frontend binary.<br>
+Client API and PMS will find actual frontend/backend binaries from those paths. <br>
+
+ * @}
+ */
--- /dev/null
+
+#export CFLAGS=""
+#export LDFLAGS=""
+
+cd `dirname $0`
+
+PREFIX=/usr
+
+rm -rf cmake_tmp
+mkdir -p cmake_tmp
+cd cmake_tmp
+
+CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} &&
+make &&
+
+# test
+{
+ export LD_LIBRARY_PATH=`pwd`
+ cd test
+# ./test_comm_client &
+# ./test_comm_status_broadcast_server
+# ./test_comm_socket &&
+ ./test_pkgmgr_installer
+}
+if [ "$?" == "0" ]; then
+ echo "Test done."
+else
+ echo "Test failed!"
+fi
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "comm_config.h"
+#include "comm_client.h"
+#include "comm_pkg_mgr_client_dbus_bindings.h"
+#include "comm_status_broadcast_client_dbus_bindings.h"
+#include "comm_status_broadcast_signal_marshaller.h"
+#include <stdlib.h>
+#include <string.h>
+
+struct comm_client {
+ /* Resources to be freed */
+ DBusGConnection *conn;
+ GError *err;
+ DBusGProxy *request_proxy;
+ DBusGProxy *signal_proxy;
+ char *pkgid;
+
+ status_cb signal_cb;
+ void *signal_cb_data;
+};
+
+comm_client *comm_client_new(void)
+{
+ comm_client *cc = NULL;
+
+ cc = calloc(1, sizeof(comm_client));
+ if (NULL == cc)
+ return NULL;
+
+ cc->conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &(cc->err));
+ if (NULL == cc->conn) {
+ g_printerr("Failed to open connection to dbus: %s\n",
+ cc->err->message);
+ g_error_free(cc->err);
+ cc->err = NULL;
+ comm_client_free(cc);
+ return NULL;
+ }
+
+ cc->request_proxy = dbus_g_proxy_new_for_name(cc->conn,
+ COMM_PKG_MGR_DBUS_SERVICE,
+ /* name : written in service file */
+ COMM_PKG_MGR_DBUS_PATH,
+ /* path : written as a node in xml */
+ COMM_PKG_MGR_DBUS_INTERFACE
+ /* interface : written as an interface in xml */
+ );
+
+ return cc;
+}
+
+int comm_client_free(comm_client *cc)
+{
+ if (NULL == cc)
+ return -1;
+
+ if (cc->err)
+ g_error_free(cc->err);
+ if (cc->conn)
+ dbus_g_connection_unref(cc->conn);
+ if (cc->request_proxy)
+ g_object_unref(cc->request_proxy);
+ if (cc->signal_proxy)
+ g_object_unref(cc->signal_proxy);
+ if (cc->pkgid)
+ free(cc->pkgid);
+
+ free(cc);
+
+ return 0;
+}
+
+static void
+status_signal_handler(DBusGProxy *proxy,
+ const char *req_id,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *key, const char *val, gpointer data)
+{
+ comm_client *cc = (comm_client *) data;
+
+ SECURE_LOGD("Got signal: %s/%s/%s/%s/%s", req_id, pkg_type,
+ pkgid, key, val);
+ if (cc->signal_cb) {
+ if (cc->pkgid && pkgid &&
+ 0 == strncmp(cc->pkgid, pkgid,
+ strlen(cc->pkgid))) {
+ dbg("Run signal handler");
+ cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
+ pkgid, key, val);
+ } else {
+ dbg("pkgid is different. (My pkgid:%s)"
+ " Though pass signal to user callback.", cc->pkgid);
+ cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
+ pkgid, key, val);
+ }
+ } else {
+ dbg("No signal handler is set. Do nothing.");
+ }
+}
+
+int
+comm_client_request(comm_client *cc, const char *req_id, const int req_type,
+ const char *pkg_type, const char *pkgid,
+ const char *args, const char *cookie)
+{
+ gboolean r;
+ gint ret = COMM_RET_ERROR;
+
+ SECURE_LOGD("got request:%s/%d/%s/%s/%s/%s\n", req_id, req_type, pkg_type,
+ pkgid, args, cookie);
+
+ if (!pkgid)
+ pkgid = ""; /* NULL check */
+
+ r = com_samsung_slp_pkgmgr_request(cc->request_proxy, req_id, req_type,
+ pkg_type, pkgid, args, cookie,
+ &ret, &(cc->err));
+ if (TRUE == r) {
+ ret = COMM_RET_OK;
+ } else {
+ g_printerr("Failed to send request via dbus: %s\n",
+ cc->err->message);
+ if (cc->err) {
+ g_error_free(cc->err);
+ cc->err = NULL;
+ }
+ return ret;
+ }
+ dbg("request sent");
+
+ if (cc->pkgid) {
+ dbg("freeing pkgid");
+ free(cc->pkgid);
+ dbg("freed pkgid");
+ }
+ cc->pkgid = strdup(pkgid);
+
+ dbg("ret:%d", ret);
+
+ return ret;
+}
+
+int
+comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
+{
+ /* set callback */
+ if (!cc->signal_proxy) {
+ dbg("signal_proxy is NULL. Try to create a proxy for signal.");
+ cc->signal_proxy = dbus_g_proxy_new_for_name(cc->conn,
+ COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX,
+ COMM_STATUS_BROADCAST_DBUS_PATH,
+ COMM_STATUS_BROADCAST_DBUS_INTERFACE);
+ if (NULL == cc->signal_proxy) {
+ g_printerr("Failed to create proxy for signal\n", NULL);
+ return COMM_RET_ERROR;
+ } else {
+ }
+ } else {
+ /* Proxy is existing. Do nothing. */
+ }
+
+ cc->signal_cb = cb;
+ cc->signal_cb_data = cb_data;
+
+ dbg("Register signal-type marshaller.");
+ dbus_g_object_register_marshaller(
+ g_cclosure_user_marshal_VOID__STRING_STRING_STRING_STRING_STRING,
+ /* marshaller */
+ G_TYPE_NONE, /* return type */
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); /* termination flag */
+
+ dbg("Add signal to proxy.");
+ dbus_g_proxy_add_signal(cc->signal_proxy,
+ COMM_STATUS_BROADCAST_SIGNAL_STATUS,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+
+ dbg("Connect signal to proxy.");
+
+ dbus_g_proxy_connect_signal(cc->signal_proxy,
+ COMM_STATUS_BROADCAST_SIGNAL_STATUS,
+ G_CALLBACK(status_signal_handler),
+ cc, NULL);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __COMM_CLIENT_H__
+#define __COMM_CLIENT_H__
+
+#include "comm_config.h"
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+enum {
+ COMM_CLIENT_STATUS_CALLBACK_FLAG_NONE = 0,
+};
+
+typedef struct comm_client comm_client;
+typedef void (*status_cb) (void *cb_data, const char *req_id,
+ const char *pkg_type, const char *pkgid,
+ const char *key, const char *val);
+
+API comm_client *comm_client_new(void);
+API int comm_client_free(comm_client *cc);
+
+API int comm_client_request(comm_client *cc, const char *req_id,
+ const int req_type, const char *pkg_type,
+ const char *pkgid, const char *args,
+ const char *cookie, int is_block);
+
+API int comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data);
+#endif /* __COMM_CLIENT_H__ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+/*
+ * comm_client_dbus.c
+ * comm_client library using pure dbus
+ * (dbus-glib is used only to register into g_main_loop)
+ */
+
+#include "comm_config.h"
+#include "comm_client.h"
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <fcntl.h>
+
+/*******************
+ * ADT description
+ */
+
+/* Storing status_cb */
+struct signal_callback_data {
+ status_cb cb;
+ void *cb_data;
+};
+
+/* comm_client ADT */
+struct comm_client {
+ DBusConnection *conn;
+ struct signal_callback_data *sig_cb_data;
+};
+
+/*********************************
+ * Internal function description
+ */
+
+static inline int __comm_read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
+
+ if (buf == NULL || path == NULL)
+ return -1;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+
+ close(fd);
+
+ return ret;
+}
+static inline int __comm_find_pid_by_cmdline(const char *dname,
+ const char *cmdline, const char *apppath)
+{
+ int pid = 0;
+
+ if (strncmp(cmdline, apppath, 1024-1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
+
+ return pid;
+}
+
+static int __comm_proc_iter_kill_cmdline(const char *apppath)
+{
+ DIR *dp;
+ struct dirent *dentry;
+ int pid;
+ int ret;
+ char buf[1024];
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
+ ret = __comm_read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ continue;
+
+ pid = __comm_find_pid_by_cmdline(dentry->d_name, buf, apppath);
+ if (pid > 0) {
+ int pgid;
+
+ pgid = getpgid(pid);
+ if (pgid <= 1) {
+ closedir(dp);
+ return -1;
+ }
+
+ if (killpg(pgid, SIGKILL) < 0) {
+ closedir(dp);
+ return -1;
+ }
+ }
+ }
+
+ closedir(dp);
+ return 0;
+}
+static char *__get_interface(int status_type)
+{
+ char *interface = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ interface = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ interface = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ interface = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
+ break;
+
+ default:
+ interface = NULL;
+ }
+ return interface;
+}
+
+/**
+ * signal handler filter
+ * Filter signal, and run user callback
+ */
+DBusHandlerResult
+_on_signal_handle_filter(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ DBusError err;
+
+ dbg("start function");
+
+ dbus_error_init(&err);
+
+ /* Values to be received by signal */
+ char *req_id = NULL;
+ char *pkg_type = NULL;
+ char *pkgid = NULL;
+ char *key = NULL;
+ char *val = NULL;
+
+ /* User's signal handler */
+ struct signal_callback_data *sig_cb_data;
+ sig_cb_data = (struct signal_callback_data *)user_data;
+
+ /* Signal check */
+ if ((dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_INTERFACE, COMM_STATUS_BROADCAST_SIGNAL_STATUS)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UNINSTALL)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_MOVE)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UPGRADE)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_GET_SIZE)) ||
+ (dbus_message_is_signal(msg, COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS))) {
+
+ /* Signal type check */
+ if (dbus_message_get_args(msg, &err,
+ DBUS_TYPE_STRING, &req_id,
+ DBUS_TYPE_STRING, &pkg_type,
+ DBUS_TYPE_STRING, &pkgid,
+ DBUS_TYPE_STRING, &key,
+ DBUS_TYPE_STRING, &val,
+ DBUS_TYPE_INVALID)) {
+ /* Got signal! */
+ SECURE_LOGD("Got signal: %s / %s / %s / %s / %s", req_id,
+ pkg_type, pkgid, key, val);
+
+ /* Run signal callback if exist */
+ if (sig_cb_data && sig_cb_data->cb) {
+ sig_cb_data->cb(sig_cb_data->cb_data, req_id,
+ pkg_type, pkgid, key, val);
+
+ dbg("callback function is end");
+ }
+
+ dbg("handled signal. exit function");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ }
+ dbg("Didn't handled signal. anyway exit function");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+/**
+ * signal_callback_data free function
+ * Just free it!
+ */
+void _free_sig_cb_data(void *memory)
+{
+ struct signal_callback_data *sig_cb_data;
+ sig_cb_data = (struct signal_callback_data *)memory;
+ if (!sig_cb_data)
+ return;
+ free(sig_cb_data);
+}
+
+/*******************
+ * API description
+ */
+
+/**
+ * Create a new comm_client object
+ */
+comm_client *comm_client_new(void)
+{
+ DBusError err;
+ comm_client *cc = NULL;
+
+ /* Allocate memory for ADT:comm_client */
+ cc = calloc(1, sizeof(comm_client));
+ if (NULL == cc) {
+ ERR("No memory");
+ goto ERROR_CLEANUP;
+ }
+
+ /* Connect to dbus */
+ dbus_error_init(&err);
+ cc->conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ ERR("dbus connection error (%s)", err.message);
+ dbus_error_free(&err);
+ goto ERROR_CLEANUP;
+ }
+ if (NULL == cc->conn) {
+ ERR("dbus connection is not set, even dbus error isn't raised");
+ goto ERROR_CLEANUP;
+ }
+
+ /* TODO: requesting name for dbus is needed? */
+
+ /* Register my connection to g_main_loop (with default context) */
+ dbus_connection_setup_with_g_main(cc->conn, NULL);
+
+ return cc;
+
+ ERROR_CLEANUP:
+ if (cc)
+ free(cc);
+ return NULL;
+}
+
+/**
+ * Free comm_client object
+ */
+int comm_client_free(comm_client *cc)
+{
+ if (!cc)
+ return -1;
+ if (!(cc->conn) || !dbus_connection_get_is_connected(cc->conn)) {
+ ERR("Invalid dbus connection");
+ return -2;
+ }
+
+ /* Free signal filter if signal callback is exist */
+ if (cc->sig_cb_data) {
+ dbus_connection_remove_filter(cc->conn,
+ _on_signal_handle_filter,
+ cc->sig_cb_data);
+ /* TODO: Is it needed to free cc->sig_cb_data here? */
+ /* _free_sig_cb_data(cc->sig_cb_data); */
+ }
+
+ dbus_connection_close(cc->conn);
+ dbus_connection_unref(cc->conn);
+
+ free(cc);
+
+ return 0;
+}
+
+/**
+ * Request a message
+ */
+int
+comm_client_request(
+ comm_client *cc,
+ const char *req_id,
+ const int req_type,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *args,
+ const char *cookie,
+ int is_block)
+{
+ DBusError err;
+ DBusMessage *msg = NULL;
+ int r = COMM_RET_ERROR; /* Default return */
+
+ if (!cc){
+ ERR("Invalid dbus input");
+ return COMM_RET_ERROR;
+ }
+
+ /* Create a dbus message */
+ msg = dbus_message_new_method_call(COMM_PKG_MGR_DBUS_SERVICE,
+ COMM_PKG_MGR_DBUS_PATH,
+ COMM_PKG_MGR_DBUS_INTERFACE,
+ COMM_PKG_MGR_METHOD_REQUEST);
+ if (NULL == msg) {
+ r = COMM_RET_NOMEM;
+ ERR("dbus_message_new_method_call fail : msg is NULL");
+ goto ERROR_CLEANUP;
+ }
+
+ /* Assign default values if NULL (NULL is not allowed) */
+ if (NULL == req_id)
+ req_id = "tmp_reqid";
+ if (NULL == pkg_type)
+ pkg_type = "none";
+ if (NULL == pkgid)
+ pkgid = "";
+ if (NULL == args)
+ args = "";
+ if (NULL == cookie)
+ cookie = "";
+
+ dbus_error_init(&err);
+
+ /* Append arguments */
+ if (!dbus_message_append_args(msg,
+ DBUS_TYPE_STRING, &req_id,
+ DBUS_TYPE_INT32, &req_type,
+ DBUS_TYPE_STRING, &pkg_type,
+ DBUS_TYPE_STRING, &pkgid,
+ DBUS_TYPE_STRING, &args,
+ DBUS_TYPE_STRING, &cookie,
+ DBUS_TYPE_INVALID)) {
+ r = -3;
+ ERR("dbus_message_append_args fail");
+ goto ERROR_CLEANUP;
+ }
+
+ /* Send message , timeout -1 = _DBUS_DEFAULT_TIMEOUT_VALUE (25 * 1000) 25 seconds*/
+ if (is_block == 1){
+ if(!dbus_connection_send_with_reply_and_block(cc->conn, msg,
+ -1, NULL)) {
+ ERR("try send msg to dbus by timeout");
+ sleep(1);
+ if(!dbus_connection_send_with_reply_and_block(cc->conn, msg,
+ -1, &err)) {
+ r = -4;
+ ERR("dbus_connection_send_with_reply_and_block fail");
+
+ __comm_proc_iter_kill_cmdline("pkgmgr-server");
+
+ if (dbus_error_is_set(&err))
+ ERR("dbus error:%s", err.message);
+ goto ERROR_CLEANUP;
+ }
+ }
+ } else {
+ if (!dbus_connection_send(cc->conn, msg, NULL)) {
+ r = -5;
+ ERR("dbus_connection_send fail");
+ goto ERROR_CLEANUP;
+ }
+ }
+ dbus_connection_flush(cc->conn);
+
+ /* Cleanup and return */
+ dbus_message_unref(msg);
+ /* NOTE: It is not needed to free DBusMessageIter. */
+
+ return 0;
+
+ ERROR_CLEANUP:
+ if (COMM_RET_NOMEM == r)
+ ERR("No memory!");
+ else
+ ERR("General error!");
+
+ if (msg)
+ dbus_message_unref(msg);
+
+ dbus_error_free(&err);
+
+ return r;
+}
+
+/**
+ * Set a callback for status signal
+ */
+int
+comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data)
+{
+ DBusError err;
+ char buf[256] = { 0, };
+ int r = COMM_RET_ERROR;
+
+ dbus_error_init(&err);
+
+ if (NULL == cc)
+ goto ERROR_CLEANUP;
+
+ /* Add a rule for signal */
+ snprintf(buf, 255, "type='signal',interface='%s'", __get_interface(comm_status_type));
+ dbus_bus_add_match(cc->conn, buf, &err);
+ if (dbus_error_is_set(&err)) {
+ ERR("dbus error:%s", err.message);
+ r = COMM_RET_ERROR;
+ goto ERROR_CLEANUP;
+ }
+
+ /* If previous signal handler is set already, remove filter first */
+ if (cc->sig_cb_data) {
+ dbus_connection_remove_filter(cc->conn,
+ _on_signal_handle_filter,
+ cc->sig_cb_data);
+ /* TODO: Is it needed to free cc->sig_cb_data here? */
+ }
+
+ /* Create new sig_cb_data */
+ cc->sig_cb_data = calloc(1, sizeof(struct signal_callback_data));
+ (cc->sig_cb_data)->cb = cb;
+ (cc->sig_cb_data)->cb_data = cb_data;
+
+ /* Add signal filter */
+ if (!dbus_connection_add_filter(cc->conn,
+ _on_signal_handle_filter,
+ cc->sig_cb_data, _free_sig_cb_data)) {
+ r = COMM_RET_NOMEM;
+ goto ERROR_CLEANUP;
+ }
+
+ /* Cleanup and return */
+ dbus_error_free(&err);
+ return COMM_RET_OK;
+
+ ERROR_CLEANUP:
+ if (COMM_RET_NOMEM == r)
+ ERR("No memory");
+ else
+ ERR("General error");
+
+ dbus_error_free(&err);
+ return r;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/*
+ * comm_client_gdbus.c
+ * comm_client library using gdbus
+ */
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include "comm_config.h"
+#include "comm_client.h"
+#include "comm_pkg_mgr_client_gdbus_generated.h"
+
+/*******************
+ * ADT description
+ */
+
+/* Storing status_cb */
+struct signal_callback_data {
+ status_cb cb;
+ void *cb_data;
+};
+
+/* comm_client ADT */
+struct comm_client {
+ guint subscription_id;
+ GDBusConnection *conn;
+ struct signal_callback_data *sig_cb_data;
+};
+
+#define COMM_CLIENT_RETRY_MAX 5
+
+static int __retry_request(comm_client *cc,
+ const gchar *req_id,
+ gint req_type,
+ const gchar *pkg_type,
+ const gchar *pkgid,
+ const gchar *args,
+ const gchar *cookie,
+ gint *ret)
+{
+ ComSamsungSlpPkgmgr *proxy;
+ GError *error = NULL;
+ int rc = 0;
+
+ proxy = com_samsung_slp_pkgmgr_proxy_new_sync(cc->conn,
+ G_DBUS_PROXY_FLAGS_NONE, COMM_PKG_MGR_DBUS_SERVICE,
+ COMM_PKG_MGR_DBUS_PATH,
+ NULL, &error);
+ if (proxy == NULL) {
+ ERR("Unable to create proxy[rc=%d, err=%s]\n", rc, error->message);
+ return FALSE;
+ }
+
+ rc = com_samsung_slp_pkgmgr_call_request_sync(proxy,
+ req_id, req_type, pkg_type, pkgid, args, cookie, &ret, NULL, &error);
+ if (!rc) {
+ ERR("Failed to send request[rc=%d, err=%s]\n", rc, error->message);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static char *__get_interface(int status_type)
+{
+ char *ifc = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ ifc = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ ifc = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ ifc = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ ifc = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ ifc = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ ifc = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ ifc = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
+ break;
+
+ default:
+ break;
+ }
+ return ifc;
+}
+
+/**
+ * signal handler filter
+ * Filter signal, and run user callback
+ */
+void _on_signal_handle_filter(GDBusConnection *conn,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ if (interface_name && strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE) &&
+ strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE)) {
+ dbg("Interface name did not match. Drop the message");
+ return;
+ }
+ if (signal_name && strcmp(signal_name, COMM_STATUS_BROADCAST_SIGNAL_STATUS) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UNINSTALL) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UPGRADE) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_MOVE) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_GET_SIZE) &&
+ strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS)) {
+ dbg("Signal name did not match. Drop the message");
+ return;
+ }
+ /* Values to be received by signal */
+ char *req_id = NULL;
+ char *pkg_type = NULL;
+ char *pkgid = NULL;
+ char *key = NULL;
+ char *val = NULL;
+
+ /* User's signal handler */
+ struct signal_callback_data *sig_cb_data;
+ if (user_data)
+ sig_cb_data = (struct signal_callback_data *)user_data;
+ else
+ return;
+
+ g_variant_get(parameters, "(&s&s&s&s&s)",
+ &req_id, &pkg_type, &pkgid, &key, &val);
+ /* Got signal! */
+ SECURE_LOGD("Got signal: [%s] %s / %s / %s / %s / %s", signal_name, req_id,
+ pkg_type, pkgid, key, val);
+
+ /* Run signal callback if exist */
+ if (sig_cb_data && sig_cb_data->cb) {
+ sig_cb_data->cb(sig_cb_data->cb_data, req_id,
+ pkg_type, pkgid, key, val);
+ dbg("callback function is end");
+ }
+ dbg("Handled signal. Exit function");
+ return;
+}
+
+/**
+ * signal_callback_data free function
+ * Just free it!
+ */
+void _free_sig_cb_data(void *data)
+{
+ struct signal_callback_data *sig_cb_data = NULL;
+ if (data)
+ sig_cb_data = (struct signal_callback_data *)data;
+ if (!sig_cb_data)
+ return;
+ free(sig_cb_data);
+}
+
+/*******************
+ * API description
+ */
+
+/**
+ * Create a new comm_client object
+ */
+comm_client *comm_client_new(void)
+{
+ GError *error = NULL;
+ comm_client *cc = NULL;
+
+ /* Allocate memory for ADT:comm_client */
+ g_type_init();
+ cc = calloc(1, sizeof(comm_client));
+ if (NULL == cc) {
+ ERR("No memory");
+ goto ERROR_CLEANUP;
+ }
+
+ /* Connect to gdbus. Gets shared BUS */
+ cc->conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ ERR("gdbus connection error (%s)", error->message);
+ g_error_free(error);
+ goto ERROR_CLEANUP;
+ }
+ if (NULL == cc->conn) {
+ ERR("gdbus connection is not set, even gdbus error isn't raised");
+ goto ERROR_CLEANUP;
+ }
+ return cc;
+
+ ERROR_CLEANUP:
+ if (cc)
+ free(cc);
+ return NULL;
+}
+
+/**
+ * Free comm_client object
+ */
+int comm_client_free(comm_client *cc)
+{
+ if (!cc)
+ return -1;
+ if (!(cc->conn) || g_dbus_connection_is_closed(cc->conn)) {
+ ERR("Invalid gdbus connection");
+ return -2;
+ }
+
+ /* Cleanup ADT */
+ /* flush remaining buffer: blocking mode */
+ g_dbus_connection_flush_sync(cc->conn, NULL, NULL);
+
+ /* Free signal filter if signal callback is exist */
+ if (cc->sig_cb_data) {
+ g_dbus_connection_signal_unsubscribe(cc->conn, cc->subscription_id);
+ /* TODO: Is it needed to free cc->sig_cb_data here? */
+ /* _free_sig_cb_data(cc->sig_cb_data); */
+ }
+ /* just unref because it is shared BUS.
+ If ref count is 0 it will get free'd automatically
+ */
+ g_object_unref(cc->conn);
+ free(cc);
+
+ return 0;
+}
+
+/**
+ * Request a message
+ */
+int
+comm_client_request(
+ comm_client *cc,
+ const char *req_id,
+ const int req_type,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *args,
+ const char *cookie,
+ int is_block)
+{
+ GError *error = NULL;
+ int ret = 0;
+ int rc = 0;
+ int retry_cnt = 0;
+
+ ComSamsungSlpPkgmgr *proxy;
+ if (!cc){
+ ERR("Invalid gdbus input");
+ return COMM_RET_ERROR;
+ }
+ proxy = com_samsung_slp_pkgmgr_proxy_new_sync(cc->conn,
+ G_DBUS_PROXY_FLAGS_NONE, COMM_PKG_MGR_DBUS_SERVICE,
+ COMM_PKG_MGR_DBUS_PATH,
+ NULL, &error);
+ if (proxy == NULL) {
+ ERR("Unable to create proxy[rc=%d, err=%s]\n", rc, error->message);
+ return COMM_RET_ERROR;
+ }
+
+ /* Assign default values if NULL (NULL is not allowed) */
+ if (req_id == NULL)
+ req_id = "tmp_reqid";
+ if (pkg_type == NULL)
+ pkg_type = "none";
+ if (pkgid == NULL)
+ pkgid = "";
+ if (args == NULL)
+ args = "";
+ if (cookie == NULL)
+ cookie = "";
+
+ rc = com_samsung_slp_pkgmgr_call_request_sync(proxy,
+ req_id, req_type, pkg_type, pkgid, args, cookie, &ret, NULL, &error);
+
+ while (rc == FALSE) {
+ ERR("Failed to send request, sleep and retry[rc=%d, err=%s]\n", rc, error->message);
+ sleep(1);
+
+ if(retry_cnt == COMM_CLIENT_RETRY_MAX) {
+ ERR("retry_cnt is max, stop retry\n");
+ return COMM_RET_ERROR;
+ }
+ retry_cnt++;
+
+ rc = __retry_request(cc, req_id, req_type, pkg_type, pkgid, args, cookie, &ret);
+ if(rc == TRUE) {
+ ERR("__retry_request is success[retry_cnt=%d]\n", retry_cnt);
+ return COMM_RET_OK;
+ }
+ }
+ return COMM_RET_OK;
+}
+
+/**
+ * Set a callback for status signal
+ */
+int
+comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data)
+{
+ int r = COMM_RET_ERROR;
+ char *ifc = NULL;
+
+ if (NULL == cc)
+ goto ERROR_CLEANUP;
+
+ ifc = __get_interface(comm_status_type);
+ if (ifc == NULL) {
+ ERR("Invalid interface name\n");
+ return COMM_RET_ERROR;
+ }
+
+ /* Create new sig_cb_data */
+ cc->sig_cb_data = calloc(1, sizeof(struct signal_callback_data));
+ (cc->sig_cb_data)->cb = cb;
+ (cc->sig_cb_data)->cb_data = cb_data;
+
+ /* Add a filter for signal */
+ cc->subscription_id = g_dbus_connection_signal_subscribe(cc->conn, NULL, ifc,
+ NULL, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
+ _on_signal_handle_filter, (gpointer)cc->sig_cb_data, _free_sig_cb_data);
+ if (!cc->subscription_id) {
+ ERR("Failed to add filter\n");
+ r = COMM_RET_ERROR;
+ goto ERROR_CLEANUP;
+ }
+
+ return COMM_RET_OK;
+
+ ERROR_CLEANUP:
+ ERR("General error");
+ return r;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __COMM_CONFIG_H__
+#define __COMM_CONFIG_H__
+
+#include <stdlib.h> /* for NULL */
+#include <libgen.h>
+
+/* API export macro */
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+/* Debug message macro */
+#define USE_DLOG 1 /* Use dlog! */
+
+#ifndef NDEBUG
+#ifdef USE_DLOG
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR"
+#endif /* LOG_TAG */
+#include <dlog.h>
+
+#define dbg(fmt, arg...) LOGD(fmt, ##arg)
+#define ERR(fmt, arg...) LOGE(fmt, ##arg)
+
+#else
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#define dbg(fmtstr, args...) \
+ do {
+ fprintf(stdout, "[%d:comm]%s:%d:%s(): " \
+ fmtstr "\n", getpid(),\
+ basename(__FILE__), __LINE__, __func__, ##args);\
+ } while (0)
+
+#define ERR(fmtstr, args...) \
+ do {
+ fprintf(stderr, "[%d:comm]%s:%d:%s(): " \
+ fmtstr "\n", getpid(),\
+ basename(__FILE__), __LINE__, __func__, ##args);\
+ } while (0)
+#endif /* USE_DLOG */
+#else
+#define dbg(fmtstr, args...)
+#endif
+
+/* from comm_pkg_mgr.xml
+ */
+#define COMM_PKG_MGR_DBUS_SERVICE "com.samsung.slp.pkgmgr"
+#define COMM_PKG_MGR_DBUS_PATH "/com/samsung/slp/pkgmgr"
+#define COMM_PKG_MGR_DBUS_INTERFACE "com.samsung.slp.pkgmgr"
+#define COMM_PKG_MGR_METHOD_REQUEST "Request"
+#define COMM_PKG_MGR_METHOD_ECHO_STRING "EchoString"
+
+/* from comm_status_broadcast
+ */
+#define COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX \
+ "com.samsung.slp.pkgmgr_status"
+#define COMM_STATUS_BROADCAST_DBUS_PATH \
+ "/com/samsung/slp/pkgmgr_status"
+#define COMM_STATUS_BROADCAST_DBUS_INTERFACE \
+ "com.samsung.slp.pkgmgr_status"
+#define COMM_STATUS_BROADCAST_SIGNAL_STATUS "status"
+
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_SERVICE_PREFIX "com.samsung.slp.pkgmgr.install"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH "/com/samsung/slp/pkgmgr/install"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE "com.samsung.slp.pkgmgr.install"
+#define COMM_STATUS_BROADCAST_EVENT_INSTALL "install"
+
+#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_SERVICE_PREFIX "com.samsung.slp.pkgmgr.uninstall"
+#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH "/com/samsung/slp/pkgmgr/uninstall"
+#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE "com.samsung.slp.pkgmgr.uninstall"
+#define COMM_STATUS_BROADCAST_EVENT_UNINSTALL "uninstall"
+
+#define COMM_STATUS_BROADCAST_DBUS_MOVE_SERVICE_PREFIX "com.samsung.slp.pkgmgr.move"
+#define COMM_STATUS_BROADCAST_DBUS_MOVE_PATH "/com/samsung/slp/pkgmgr/move"
+#define COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE "com.samsung.slp.pkgmgr.move"
+#define COMM_STATUS_BROADCAST_EVENT_MOVE "move"
+
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_SERVICE_PREFIX "com.samsung.slp.pkgmgr.install.progress"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_PATH "/com/samsung/slp/pkgmgr/install/progress"
+#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE "com.samsung.slp.pkgmgr.install.progress"
+#define COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS "install_progress"
+
+#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_SERVICE_PREFIX "com.samsung.slp.pkgmgr.upgrade"
+#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH "/com/samsung/slp/pkgmgr/upgrade"
+#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE "com.samsung.slp.pkgmgr.upgrade"
+#define COMM_STATUS_BROADCAST_EVENT_UPGRADE "upgrade"
+
+#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_SERVICE_PREFIX "com.samsung.slp.pkgmgr.get.size"
+#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH "/com/samsung/slp/pkgmgr/get/size"
+#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE "com.samsung.slp.pkgmgr.get.size"
+#define COMM_STATUS_BROADCAST_EVENT_GET_SIZE "get_size"
+
+
+/********
+ * enums
+ ********/
+
+/* req_type */
+enum {
+ /* to installer */
+ COMM_REQ_TO_INSTALLER = 1,
+
+ /* to activator */
+ COMM_REQ_TO_ACTIVATOR,
+
+ /* to clearer */
+ COMM_REQ_TO_CLEARER,
+
+ /* to mover*/
+ COMM_REQ_TO_MOVER,
+
+ /* cancel job */
+ COMM_REQ_CANCEL,
+
+ /*get package size */
+ COMM_REQ_GET_SIZE,
+
+ /*kill app */
+ COMM_REQ_KILL_APP,
+
+ /*check app */
+ COMM_REQ_CHECK_APP,
+
+ COMM_REQ_MAX_SENTINEL
+};
+
+/* return value */
+enum {
+ COMM_RET_NOMEM = -2,
+ COMM_RET_ERROR = -1,
+ COMM_RET_OK = 0,
+ COMM_RET_QUEUED,
+
+ COMM_RET_MAX_SENTINEL
+};
+
+/* broadcast type */
+enum {
+ COMM_STATUS_BROADCAST_ALL = 1,
+ COMM_STATUS_BROADCAST_INSTALL,
+ COMM_STATUS_BROADCAST_UNINSTALL,
+ COMM_STATUS_BROADCAST_MOVE,
+ COMM_STATUS_BROADCAST_INSTALL_PROGRESS,
+ COMM_STATUS_BROADCAST_UPGRADE,
+ COMM_STATUS_BROADCAST_GET_SIZE,
+ COMM_STATUS_BROADCAST_MAX
+};
+
+#endif /* __COMM_CONFIG_H__ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/com/samsung/slp/pkgmgr">
+ <interface name="com.samsung.slp.pkgmgr">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="pkgmgr" />
+ <method name="Request">
+ <arg type="s" name="req_id" direction="in" />
+ <arg type="i" name="req_type" direction="in" />
+ <arg type="s" name="pkg_type" direction="in" />
+ <arg type="s" name="pkgid" direction="in" />
+ <arg type="s" name="args" direction="in" />
+ <arg type="s" name="cookie" direction="in" />
+ <arg type="i" name="ret" direction="out" />
+ </method>
+ </interface>
+</node>
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "comm_config.h"
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "comm_pkg_mgr_server.h"
+
+/* object class def: do nothing on this */
+struct PkgMgrObjectClass {
+ GObjectClass parent_class;
+};
+
+/* object def: has connection */
+struct PkgMgrObject {
+ GObject parent;
+
+ DBusGConnection *bus;
+
+ request_callback req_cb;
+ void *req_cb_data;
+};
+
+#define PKG_MGR_OBJECT(object) \
+(G_TYPE_CHECK_INSTANCE_CAST((object), \
+ PKG_MGR_TYPE_OBJECT, PkgMgrObject))
+#define PKG_MGR_OBJECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ PKG_MGR_TYPE_OBJECT, PkgMgrObjectClass))
+#define PKG_MGR_IS_OBJECT(object) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((object), \
+ PKG_MGR_TYPE_OBJECT))
+#define PKG_MGR_IS_OBJECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ PKG_MGR_TYPE_OBJECT))
+#define PKG_MGR_OBJECT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ PKG_MGR_TYPE_OBJECT, PkgMgrObjectClass))
+
+/* Macro that creates follwoing functions automatically;
+ * - pkgmgr_object_get_type()
+ * - pkgmgr_object_parent_class
+ */
+G_DEFINE_TYPE(PkgMgrObject, pkg_mgr_object, G_TYPE_OBJECT);
+
+/* Method declarations
+ * Used for binding stub.
+ */
+GCallback pkgmgr_request(PkgMgrObject *obj, const gchar *req_id,
+ const gint req_type, const gchar *pkg_type,
+ const gchar *pkgid, const gchar *args,
+ const gchar *cookie, gint *ret, GError *err);
+
+/* Include stub header */
+#include "comm_pkg_mgr_server_dbus_bindings.h"
+
+static void pkg_mgr_object_finalize(GObject *self);
+static void pkg_mgr_object_init(PkgMgrObject *obj);
+static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass);
+static void pkg_mgr_object_init(PkgMgrObject *obj)
+{
+ dbg("called");
+ g_assert(NULL != obj);
+
+ GError *err = NULL;
+
+ /* Establish dbus session */
+ obj->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (NULL == obj->bus) {
+ dbg("Failed to open connection to dbus: %s", err->message);
+ return;
+ }
+
+ /* Create a proxy to resgister, connecting dbus daemon */
+ DBusGProxy *proxy = NULL;
+ proxy = dbus_g_proxy_new_for_name(obj->bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+ if (NULL == proxy) {
+ dbg("Failed to get a proxy");
+ return;
+ }
+ /* Register service name
+ * NOTE: refer to
+ http://dbus.freedesktop.org/doc/dbus-specification.html
+ */
+ guint result;
+ if (!dbus_g_proxy_call(proxy, "RequestName", &err,
+ /* input vars */
+ G_TYPE_STRING, COMM_PKG_MGR_DBUS_SERVICE,
+ /* service name */
+ G_TYPE_UINT, 0, /* default flag */
+ G_TYPE_INVALID,
+ /* output vars */
+ G_TYPE_UINT, &result, G_TYPE_INVALID)) {
+ g_printerr("dbus RequestName RPC failed %s %d", err->message, TRUE);
+ return;
+ }
+ dbg("RequestName returns: %d", result);
+
+ dbus_g_connection_register_g_object(obj->bus,
+ COMM_PKG_MGR_DBUS_PATH,
+ G_OBJECT(obj));
+ dbg("Ready to serve requests");
+
+ g_object_unref(proxy);
+
+ dbg("done");
+}
+
+static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass)
+{
+ dbg("called");
+
+ g_assert(NULL != klass);
+
+ dbus_g_object_type_install_info(PKG_MGR_TYPE_OBJECT,
+ &dbus_glib_pkgmgr_object_info);
+
+ dbg("done");
+}
+
+static void pkg_mgr_object_finalize(GObject *self)
+{
+ /* PkgMgrObjectClass *klass = (PkgMgrObjectClass *) G_OBJECT_CLASS(self); */
+
+ /* Call parent's finalize function
+ * 'server_object_parent_class' comes from G_DEFINE_TYPE() macro.
+ */
+ G_OBJECT_CLASS(pkg_mgr_object_parent_class)->finalize(self);
+}
+
+/* dbus-glib methods */
+
+GCallback
+pkgmgr_request(PkgMgrObject *obj,
+ const gchar *req_id,
+ const gint req_type,
+ const gchar *pkg_type,
+ const gchar *pkgid,
+ const gchar *args,
+ const gchar *cookie, gint *ret, GError *err)
+{
+ dbg("Called");
+ *ret = COMM_RET_OK; /* TODO: fix this! */
+
+ /* TODO: Add business logic
+ * - add to queue, or remove from queue
+ * */
+
+ if (obj->req_cb) {
+ SECURE_LOGD("Call request callback(obj, %s, %d, %s, %s, %s, *ret)",
+ req_id, req_type, pkg_type, pkgid, args);
+ obj->req_cb(obj->req_cb_data, req_id, req_type, pkg_type,
+ pkgid, args, cookie, ret);
+ } else {
+ dbg("Attempt to call request callback,"
+ " but request callback is not set. Do nothing.\n"
+ "Use pkg_mgr_set_request_callback()"
+ " to register your callback.");
+ }
+
+ return (GCallback) TRUE;
+}
+
+/* Other APIs
+ */
+
+/**
+ * Set request callback function
+ */
+void pkg_mgr_set_request_callback(PkgMgrObject *obj, request_callback req_cb,
+ void *cb_data)
+{
+ obj->req_cb = req_cb;
+ obj->req_cb_data = cb_data;
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __COMM_PKG_MGR_SERVER_H__
+#define __COMM_PKG_MGR_SERVER_H__
+
+#include "comm_config.h"
+#include <glib-object.h>
+
+typedef struct PkgMgrObjectClass PkgMgrObjectClass;
+typedef struct PkgMgrObject PkgMgrObject;
+
+/* For returning server object's GType.
+ * I don't use this. Just forward declaration for G_DEFINE_TYPE() macro. */
+API GType pkg_mgr_object_get_type(void);
+#define PKG_MGR_TYPE_OBJECT (pkg_mgr_object_get_type())
+
+typedef void (*request_callback) (void *cb_data, const char *req_id,
+ const int req_type, const char *pkg_type,
+ const char *pkgid, const char *args,
+ const char *cookie, int *ret);
+
+API void pkg_mgr_set_request_callback(PkgMgrObject *obj,
+ request_callback req_cb, void *cb_data);
+
+#endif /* __COMM_PKG_MGR_SERVER_H__ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "comm_socket.h"
+
+#include <glib-2.0/glib.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#define __USE_GNU
+#include <sys/socket.h>
+#include <linux/un.h> /* for sockaddr_un */
+
+#define COMM_SOCKET_SERVER_SOCK_PATH_PREFIX "/tmp/comm_socket_"
+
+#define CHK_CS_RET(r) \
+ do { if (NULL == cs) return (r); } while (0)
+
+struct comm_socket {
+ int sockfd;
+};
+
+static int _get_new_socket(void)
+{
+ int fd = -1;
+ fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ if (fd < 0) {
+ if (EINVAL == errno) {
+ /* Try again, without SOCK_CLOEXEC option */
+ fd = socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (fd < 0) {
+ return -EINVAL;
+ }
+ } else {
+ return -errno;
+ }
+ }
+
+ return fd;
+}
+
+static void _set_sockaddr_un(struct sockaddr_un *saddr, const char *sock_path)
+{
+ saddr->sun_family = AF_UNIX;
+ snprintf(saddr->sun_path, UNIX_PATH_MAX, sock_path);
+}
+
+static const char *_create_server_sock_path(void)
+{
+ static char sock_path[UNIX_PATH_MAX];
+
+ snprintf(sock_path, UNIX_PATH_MAX, "%s_%d",
+ COMM_SOCKET_SERVER_SOCK_PATH_PREFIX, getpid());
+ unlink(sock_path);
+ return sock_path;
+}
+
+comm_socket *_comm_socket_new(void)
+{
+ comm_socket *cs;
+
+ cs = (comm_socket *) calloc(1, sizeof(struct comm_socket));
+
+ return cs;
+}
+
+int _comm_socket_free(comm_socket *cs)
+{
+ CHK_CS_RET(-EINVAL);
+ free(cs);
+ return 0;
+}
+
+int _comm_socket_create_server(comm_socket *cs, const char *sock_path)
+{
+ CHK_CS_RET(-EINVAL);
+ if (cs->sockfd)
+ return -EISCONN;
+
+
+ int fd = -1;
+ fd = _get_new_socket();
+ if (fd < 0)
+ return fd;
+
+ struct sockaddr_un saddr;
+ _set_sockaddr_un(&saddr, _create_server_sock_path());
+
+ /* bind */
+ if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr))) {
+ close(fd);
+ return -errno;
+ }
+
+ /* chmod */
+ if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+ close(fd);
+ return -errno;
+ }
+
+ /* listen */
+ if (-1 == listen(fd, 10)) {
+ close(fd);
+ return -errno;
+ }
+
+ cs->sockfd = fd;
+
+ return 0;
+}
+
+static gboolean _read_socket(GIOChannel *source, GIOCondition io)
+{
+ return FALSE;
+}
+
+int comm_socket_server_add_wait_to_thread(comm_socket *cs, void *cb,
+ void *cb_data, GMainContext *context)
+{
+ CHK_CS_RET(-EINVAL);
+ if (!cs->sockfd)
+ return -ENOTCONN;
+
+ GIOChannel *channel;
+ GSource *src;
+
+ channel = g_io_channel_unix_new(cs->sockfd);
+ src = g_io_create_watch(channel, G_IO_IN);
+ g_source_set_callback(src, (GSourceFunc) _read_socket, NULL, NULL);
+ g_source_attach(src, context);
+ g_source_unref(src);
+
+ return 0;
+}
+
+int comm_socket_connect_to_server(comm_socket *cs,
+ const char *server_sock_path)
+{
+ CHK_CS_RET(-EINVAL);
+ if (cs->sockfd)
+ return -EISCONN;
+
+ int r;
+
+ int fd = -1;
+ fd = _get_new_socket();
+ if (fd < 0)
+ return fd;
+
+ /* Try to connect to server_sock_path */
+ struct sockaddr_un saddr;
+ _set_sockaddr_un(&saddr, server_sock_path);
+
+ r = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr));
+ if (0 != r) {
+ close(fd);
+ return -r;
+ }
+
+ /* remember sockfd */
+ cs->sockfd = fd;
+
+ return 0;
+}
+
+int _comm_socket_disconnect(comm_socket *cs)
+{
+ CHK_CS_RET(-EINVAL);
+ if (!cs->sockfd)
+ return -EBADFD;
+
+ if (close(cs->sockfd))
+ return -errno;
+
+ cs->sockfd = 0;
+
+ return 0;
+}
+
+int _comm_socket_send(comm_socket *cs, void **data, int *datasize)
+{
+ CHK_CS_RET(-EINVAL);
+ return 0;
+}
+
+int _comm_socket_recv(comm_socket *cs, void *data, int datasize)
+{
+ CHK_CS_RET(-EINVAL);
+ return 0;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+typedef struct comm_socket comm_socket;
+
+comm_socket *_comm_socket_new(void);
+int _comm_socket_free(comm_socket *csc);
+int _comm_socket_connect(comm_socket *csc, const char *server_sock_path);
+int _comm_socket_disconnect(comm_socket *csc);
+int _comm_socket_create_server(comm_socket *cs, const char *sock_path);
+int _comm_socket_send(comm_socket *csc, void **data, int *datasize);
+int _comm_socket_recv(comm_socket *csc, void *data, int datasize);
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "comm_socket_client.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#define CHK_CSC_RET(r) \
+ do { if (NULL == csc) return (r); } while (0)
+
+struct comm_socket_client {
+ int sockfd;
+};
+
+comm_socket_client *_comm_socket_client_new(const char *server_sock_path)
+{
+ int fd = -1;
+ fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ if (fd < 0) {
+ if (EINVAL == errno) {
+ /* Try again, without SOCK_CLOEXEC option */
+ fd = socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (fd < 0) {
+ return NULL;
+ }
+ } else {
+ return NULL;
+ }
+ }
+
+ /* Try to connect to server_sock_path */
+ struct sockaddr_un saddr = { 0, };
+
+}
+
+int _comm_socket_client_free(comm_socket_client *csc)
+{
+ CHK_CSC_RET(-EINVAL);
+ free(csc);
+ return 0;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+typedef struct comm_socket_client comm_socket_client;
+
+comm_socket_client *_comm_socket_client_new(const char *server_sock_path);
+int _comm_socket_client_free(comm_socket_client *csc);
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/com/samsung/slp/pkgmgr_status">
+ <interface name="com.samsung.slp.pkgmgr_status">
+ <signal name="status">
+ <arg type="s" name="req_id" direction="out" />
+ <arg type="s" name="pkgtype" direction="out" />
+ <arg type="s" name="pkgid" direction="out" />
+ <arg type="s" name="key" direction="out" />
+ <arg type="s" name="val" direction="out" />
+ </signal>
+ </interface>
+</node>
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "comm_config.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <dbus/dbus.h>
+
+#include "comm_status_broadcast_server.h"
+
+/***************************
+ * dbus-glib API for server
+ ***************************/
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+
+/* object class def: do nothing on this */
+struct StatusBroadcastObjectClass {
+ GObjectClass parent_class;
+
+ guint signal;
+};
+
+/* object def: has connection */
+struct StatusBroadcastObject {
+ GObject parent;
+
+ DBusGConnection *bus;
+ char *dbus_service_name;
+};
+
+#define STATUS_BROADCAST_OBJECT(object) \
+(G_TYPE_CHECK_INSTANCE_CAST((object), \
+ STATUS_BROADCAST_TYPE_OBJECT, StatusBroadcastObject))
+#define STATUS_BROADCAST_OBJECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ STATUS_BROADCAST_TYPE_OBJECT, StatusBroadcastObjectClass))
+#define STATUS_BROADCAST_IS_OBJECT(object) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((object), \
+ STATUS_BROADCAST_TYPE_OBJECT))
+#define STATUS_BROADCAST_IS_OBJECT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ STATUS_BROADCAST_TYPE_OBJECT))
+#define STATUS_BROADCAST_OBJECT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ STATUS_BROADCAST_TYPE_OBJECT, StatusBroadcastObjectClass))
+
+/* Macro that creates follwoing functions automatically;
+ * - status_broadcast_object_get_type()
+ * - status_broadcast_object_parent_class
+ */
+G_DEFINE_TYPE(StatusBroadcastObject, status_broadcast_object, G_TYPE_OBJECT);
+
+/* method/signal declarations
+ * Used for binding stub.
+ */
+
+/* Include stub header */
+#include "comm_status_broadcast_server_dbus_bindings.h"
+
+static void
+__status_broadcast_object_class_init(StatusBroadcastObjectClass *klass);
+static void __status_broadcast_object_init(StatusBroadcastObject *obj);
+static void __status_broadcast_object_finalize(GObject *self);
+
+static void
+__status_broadcast_object_class_init(StatusBroadcastObjectClass *klass)
+{
+ dbg("called");
+
+ g_assert(NULL != klass);
+
+ klass->signal = g_signal_new(COMM_STATUS_BROADCAST_SIGNAL_STATUS,
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 3,
+ G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING);
+
+ dbus_g_object_type_install_info(STATUS_BROADCAST_TYPE_OBJECT,
+ &dbus_glib_status_broadcast_object_info);
+
+ dbg("done");
+}
+
+static void __status_broadcast_object_init(StatusBroadcastObject *obj)
+{
+ dbg("called");
+ g_assert(NULL != obj);
+
+ GError *err = NULL;
+
+ /* Establish dbus session */
+ obj->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (NULL == obj->bus) {
+ dbg("Failed to open connection to dbus: %s", err->message);
+ return;
+ }
+
+ /* Create a proxy to resgister, connecting dbus daemon */
+ DBusGProxy *proxy = NULL;
+ proxy = dbus_g_proxy_new_for_name(obj->bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+ if (NULL == proxy) {
+ dbg("Failed to get a proxy");
+ return;
+ }
+ /* Register service name
+ * NOTE: refer to
+ http://dbus.freedesktop.org/doc/dbus-specification.html
+ */
+
+ guint result;
+ if (!dbus_g_proxy_call(proxy, "RequestName", &err,
+ /* input vars */
+ G_TYPE_STRING, COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX,
+ /* service name */
+ G_TYPE_UINT, 0, /* default flag */
+ G_TYPE_INVALID,
+ /* output vars */
+ G_TYPE_UINT, &result, G_TYPE_INVALID)) {
+ g_printerr("dbus RequestName RPC failed", err->message, TRUE);
+ return;
+ }
+ dbg("RequestName returns: %d", result);
+
+ dbus_g_connection_register_g_object(obj->bus,
+ COMM_STATUS_BROADCAST_DBUS_PATH,
+ G_OBJECT(obj));
+ dbg("Ready to serve requests");
+
+ g_object_unref(proxy);
+
+ dbg("done");
+}
+
+static void __status_broadcast_object_finalize(GObject *self)
+{
+ StatusBroadcastObjectClass *klass =
+ (StatusBroadcastObjectClass *) G_OBJECT_CLASS(self);
+
+ /* Call parent's finalize function
+ * 'server_object_parent_class' comes from G_DEFINE_TYPE() macro.
+ */
+ G_OBJECT_CLASS(status_broadcast_object_parent_class)->finalize(self);
+}
+
+/* dbus-glib methods/signals */
+
+void
+status_broadcast_emit_status(StatusBroadcastObject *obj,
+ const char *pkg, const char *key, const char *val)
+{
+ StatusBroadcastObjectClass *klass;
+ klass = STATUS_BROADCAST_OBJECT_GET_CLASS(obj);
+
+ dbg("Send signal: %s/%s/%s", pkg, key, val);
+ g_signal_emit(obj, klass->signal, 0, pkg, key, val);
+
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __COMM_STATUS_BROADCAST_SERVER_H__
+#define __COMM_STATUS_BROADCAST_SERVER_H__
+
+#include "comm_config.h"
+#include <dbus/dbus.h>
+
+/* pure dbus api */
+API DBusConnection *comm_status_broadcast_server_connect(int comm_status_type);
+API void comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *conn,
+ const char *req_id,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *key,
+ const char *val);
+API void comm_status_broadcast_server_disconnect(DBusConnection *conn);
+#endif /* __COMM_STATUS_BROADCAST_SERVER_H__ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "comm_config.h"
+#include "comm_status_broadcast_server.h"
+#include <dbus/dbus.h>
+
+/********************************************
+ * pure dbus signal service for internal use
+ ********************************************/
+static char *__get_prifix(int status_type)
+{
+ char *prifix = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ prifix = COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ prifix = COMM_STATUS_BROADCAST_DBUS_INSTALL_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ prifix = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ prifix = COMM_STATUS_BROADCAST_DBUS_MOVE_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ prifix = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ prifix = COMM_STATUS_BROADCAST_DBUS_UPGRADE_SERVICE_PREFIX;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ prifix = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_SERVICE_PREFIX;
+ break;
+
+ default:
+ prifix = NULL;
+ }
+ return prifix;
+}
+
+static char *__get_path(int status_type)
+{
+ char *path = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ path = COMM_STATUS_BROADCAST_DBUS_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ path = COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ path = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ path = COMM_STATUS_BROADCAST_DBUS_MOVE_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ path = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ path = COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ path = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH;
+ break;
+
+ default:
+ path = NULL;
+ }
+ return path;
+}
+
+static char *__get_interface(int status_type)
+{
+ char *interface = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ interface = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ interface = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ interface = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ interface = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
+ break;
+
+ default:
+ interface = NULL;
+ }
+ return interface;
+}
+
+static char *__get_name(int status_type)
+{
+ char *name = NULL;
+
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ name = COMM_STATUS_BROADCAST_SIGNAL_STATUS;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL:
+ name = COMM_STATUS_BROADCAST_EVENT_INSTALL;
+ break;
+
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ name = COMM_STATUS_BROADCAST_EVENT_UNINSTALL;
+ break;
+
+ case COMM_STATUS_BROADCAST_MOVE:
+ name = COMM_STATUS_BROADCAST_EVENT_MOVE;
+ break;
+
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ name = COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS;
+ break;
+
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ name = COMM_STATUS_BROADCAST_EVENT_UPGRADE;
+ break;
+
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ name = COMM_STATUS_BROADCAST_EVENT_GET_SIZE;
+ break;
+
+ default:
+ name = NULL;
+ }
+ return name;
+}
+
+API DBusConnection *comm_status_broadcast_server_connect(int status_type)
+{
+ DBusError err;
+ DBusConnection *conn;
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ dbg("Connection error: %s", err.message);
+ dbus_error_free(&err);
+ }
+ dbus_error_free(&err);
+ if (NULL == conn) {
+ dbg("conn is NULL");
+ return NULL;
+ }
+
+ dbus_bus_request_name(conn, __get_prifix(status_type), DBUS_NAME_FLAG_ALLOW_REPLACEMENT, &err);
+ if (dbus_error_is_set(&err)) {
+ SECURE_LOGD("Failed to request name: %s", err.message);
+ dbus_error_free(&err);
+ return NULL;
+ }
+
+ return conn;
+}
+
+API void
+comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *conn,
+ const char *req_id,
+ const char *pkg_type,
+ const char *pkgid, const char *key,
+ const char *val)
+{
+ dbus_uint32_t serial = 0;
+ DBusMessage *msg;
+ DBusMessageIter args;
+
+ const char *values[] = {
+ req_id,
+ pkg_type,
+ pkgid,
+ key,
+ val
+ };
+ int i;
+
+ if (conn == NULL) {
+ dbg("dbus conn is NULL");
+ return;
+ }
+
+ msg = dbus_message_new_signal(__get_path(comm_status_type), __get_interface(comm_status_type), __get_name(comm_status_type));
+ if (NULL == msg) {
+ dbg("msg NULL");
+ return;
+ }
+
+ dbus_message_iter_init_append(msg, &args);
+
+ for (i = 0; i < 5; i++) {
+ if (!dbus_message_iter_append_basic
+ (&args, DBUS_TYPE_STRING, &(values[i]))) {
+ dbg("dbus_message_iter_append_basic failed:"
+ " Out of memory");
+ return;
+ }
+ }
+ if (!dbus_connection_send(conn, msg, &serial)) {
+ dbg("dbus_connection_send failed: Out of memory");
+ return;
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(msg);
+}
+
+API void comm_status_broadcast_server_disconnect(DBusConnection *conn)
+{
+ if (!conn)
+ return;
+ dbus_connection_unref(conn);
+}
--- /dev/null
+VOID:STRING,STRING,STRING,STRING,STRING
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __ERROR_REPORT_H__
+#define __ERROR_REPORT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Error reporting: kernel style */
+#include <errno.h>
+#define MAX_ERRNO 4095
+#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
+static inline void *ERR_PTR(long error)
+{
+ return (void *)error;
+}
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ERROR_REPORT_H__ */
--- /dev/null
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: package manager installer
+Description: SLP package manager's installer library
+Version: @VERSION@
+Requires: dbus-1 dbus-glib-1
+Libs: -L${libdir} -lpkgmgr_installer_client
+Cflags: -I${includedir}/pkgmgr
--- /dev/null
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: package manager installer
+Description: SLP package manager's installer library
+Version: @VERSION@
+Requires: dbus-1 dbus-glib-1
+Libs: -L${libdir} -lpkgmgr_installer_status_broadcast_server
+Cflags: -I${includedir}/pkgmgr
--- /dev/null
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: package manager installer library
+Description: SLP package manager's installer lib for each backends
+Version: @VERSION@
+Requires: pkgmgr-installer-status-broadcast-server
+Libs: -L${libdir} -lpkgmgr_installer
+Cflags: -I${includedir}/pkgmgr
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "pkgmgr_installer.h"
+#include "pkgmgr_installer_config.h"
+
+#include "comm_config.h"
+#include "comm_socket.h"
+#include "comm_status_broadcast_server.h"
+#include "error_report.h"
+
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+#include <db-util.h>
+#include <pkgmgr-info.h>
+
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR_INSTALLER"
+#endif /* LOG_TAG */
+
+#define MAX_STRLEN 1024
+#define MAX_QUERY_LEN 4096
+
+#define CHK_PI_RET(r) \
+ do { if (NULL == pi) return (r); } while (0)
+
+/* ADT */
+struct pkgmgr_installer {
+ int request_type;
+ int quiet;
+ int move_type;
+ char *pkgmgr_info;
+ char *session_id;
+ char *license_path;
+ char *quiet_socket_path;
+ char *optional_data;
+ char *caller_pkgid;
+
+ DBusConnection *conn;
+};
+
+/* API */
+
+static int __send_signal_for_event(int comm_status_type, pkgmgr_installer *pi,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *key, const char *val)
+{
+ if (!pi)
+ return -1;
+
+ if (!pi->conn)
+ pi->conn = comm_status_broadcast_server_connect(comm_status_type);
+
+ char *sid = pi->session_id;
+ if (!sid)
+ sid = "";
+ comm_status_broadcast_server_send_signal(comm_status_type, pi->conn, sid, pkg_type, pkgid, key, val);
+
+ return 0;
+}
+
+API int __send_event(pkgmgr_installer *pi,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *key, const char *val)
+{
+ int r = -1;
+
+ if (strcmp(key,PKGMGR_INSTALLER_START_KEY_STR) == 0) {
+ if(strcmp(val,PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0) {
+ pi->request_type = PKGMGR_REQ_UPGRADE;
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UPGRADE, pi, pkg_type, pkgid, key, val);
+ }
+ if(pi->request_type == PKGMGR_REQ_INSTALL) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL, pi, pkg_type, pkgid, key, val);
+ } else if (pi->request_type == PKGMGR_REQ_UNINSTALL){
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UNINSTALL, pi, pkg_type, pkgid, key, val);
+ }
+ } else if (strcmp(key,PKGMGR_INSTALLER_END_KEY_STR) == 0) {
+ if(pi->request_type == PKGMGR_REQ_INSTALL) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL, pi, pkg_type, pkgid, key, val);
+ } else if (pi->request_type == PKGMGR_REQ_UNINSTALL){
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UNINSTALL, pi, pkg_type, pkgid, key, val);
+ } else if (pi->request_type == PKGMGR_REQ_UPGRADE){
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_UPGRADE, pi, pkg_type, pkgid, key, val);
+ }
+ } else if (strcmp(key,PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR) == 0) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_INSTALL_PROGRESS, pi, pkg_type, pkgid, key, val);
+ }
+
+ return r;
+}
+
+API pkgmgr_installer *pkgmgr_installer_new(void)
+{
+ pkgmgr_installer *pi = NULL;
+ pi = calloc(1, sizeof(struct pkgmgr_installer));
+ if (NULL == pi)
+ return ERR_PTR(-ENOMEM);
+
+ pi->request_type = PKGMGR_REQ_INVALID;
+ pi->quiet = 0;
+
+ return pi;
+}
+
+API int pkgmgr_installer_free(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(-EINVAL);
+
+ /* free members */
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ if (pi->session_id)
+ free(pi->session_id);
+ if (pi->optional_data)
+ free(pi->optional_data);
+ if (pi->caller_pkgid)
+ free(pi->caller_pkgid);
+
+ if (pi->conn)
+ comm_status_broadcast_server_disconnect(pi->conn);
+
+ free(pi);
+
+ return 0;
+}
+
+API int
+pkgmgr_installer_receive_request(pkgmgr_installer *pi,
+ const int argc, char **argv)
+{
+ CHK_PI_RET(-EINVAL);
+
+ int r = 0;
+
+ /* Parse argv */
+ optind = 1; /* Initialize optind to clear prev. index */
+ int opt_idx = 0;
+ int c;
+ int mode = 0;
+ while (1) {
+ c = getopt_long(argc, argv, short_opts, long_opts, &opt_idx);
+ /* printf("c=%d %c\n", c, c); //debug */
+ if (-1 == c)
+ break; /* Parse is end */
+ switch (c) {
+ case 'k': /* session id */
+ if (pi->session_id)
+ free(pi->session_id);
+ pi->session_id = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'l': /* license path */
+ if (pi->license_path)
+ free(pi->license_path);
+ pi->license_path = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'i': /* install */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 'i';
+ pi->request_type = PKGMGR_REQ_INSTALL;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'd': /* uninstall */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 'd';
+ pi->request_type = PKGMGR_REQ_UNINSTALL;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+
+ case 'c': /* clear */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 'c';
+ pi->request_type = PKGMGR_REQ_CLEAR;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'm': /* move */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 'm';
+ pi->request_type = PKGMGR_REQ_MOVE;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'r': /* reinstall */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 'r';
+ pi->request_type = PKGMGR_REQ_REINSTALL;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 't': /* move type*/
+ pi->move_type = atoi(optarg);
+ break;
+
+ case 'q': /* quiet mode */
+ /* if(mode) { r = -EINVAL; goto RET; }
+ mode = 'q'; */
+ pi->quiet = 1;
+ /* pi->quiet_socket_path = strndup(optarg, MAX_STRLEN);
+ maximum 255 bytes
+ return
+ */
+
+ break;
+
+ case 'p': /* caller pkgid*/
+ if (pi->caller_pkgid)
+ free(pi->caller_pkgid);
+ pi->caller_pkgid = strndup(optarg, MAX_STRLEN);
+
+ break;
+
+ case 's': /* smack */
+ if (mode) {
+ r = -EINVAL;
+ goto RET;
+ }
+ mode = 's';
+ pi->request_type = PKGMGR_REQ_SMACK;
+ if (pi->pkgmgr_info)
+ free(pi->pkgmgr_info);
+ pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+ break;
+
+ case 'o': /* optional data*/
+ pi->optional_data = strndup(optarg, MAX_STRLEN);
+ break;
+
+ /* Otherwise */
+ case '?': /* Not an option */
+ break;
+
+ case ':': /* */
+ break;
+
+ }
+ }
+
+ /* quiet mode : get options from socket (to be impelemented) */
+
+ /* normal mode : get options from argv */
+
+ RET:
+ return r;
+}
+
+API int pkgmgr_installer_get_request_type(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->request_type;
+}
+
+API const char *pkgmgr_installer_get_request_info(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->pkgmgr_info;
+}
+
+API const char *pkgmgr_installer_get_session_id(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->session_id;
+}
+
+API const char *pkgmgr_installer_get_license_path(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->license_path;
+}
+
+API const char *pkgmgr_installer_get_optional_data(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->optional_data;
+}
+
+API int pkgmgr_installer_is_quiet(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->quiet;
+}
+
+API int pkgmgr_installer_get_move_type(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->move_type;
+}
+
+API const char *pkgmgr_installer_get_caller_pkgid(pkgmgr_installer *pi)
+{
+ CHK_PI_RET(PKGMGR_REQ_INVALID);
+ return pi->caller_pkgid;
+}
+
+API int
+pkgmgr_installer_send_signal(pkgmgr_installer *pi,
+ const char *pkg_type,
+ const char *pkgid,
+ const char *key, const char *val)
+{
+ int r = 0;
+
+ if (strcmp(pkg_type,PKGMGR_INSTALLER_GET_SIZE_KEY_STR) == 0) {
+ r = __send_signal_for_event(COMM_STATUS_BROADCAST_GET_SIZE, pi, pkg_type, pkgid, key, val);
+ return r;
+ }
+
+ if (!pi->conn)
+ pi->conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
+
+ char *sid = pi->session_id;
+ if (!sid)
+ sid = "";
+ comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, pi->conn, sid, pkg_type,
+ pkgid, key, val);
+
+ __send_event(pi, pkg_type, pkgid, key, val);
+
+ return r;
+}
+
+API int pkgmgr_installer_create_certinfo_set_handle(pkgmgr_instcertinfo_h *handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_create_certinfo_set_handle(handle);
+ return ret;
+}
+
+API int pkgmgr_installer_set_cert_value(pkgmgr_instcertinfo_h handle, pkgmgr_instcert_type cert_type, char *cert_value)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_set_cert_value(handle, cert_type, cert_value);
+ return ret;
+}
+
+API int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_save_certinfo(pkgid, handle);
+ return ret;
+}
+
+API int pkgmgr_installer_destroy_certinfo_set_handle(pkgmgr_instcertinfo_h handle)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_destroy_certinfo_set_handle(handle);
+ return ret;
+}
+
+API int pkgmgr_installer_delete_certinfo(const char *pkgid)
+{
+ int ret = 0;
+ ret = pkgmgrinfo_delete_certinfo(pkgid);
+ return ret;
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __PKGMGR_INSTALLER_H__
+#define __PKGMGR_INSTALLER_H__
+
+/**
+ * @file pkgmgr_installer.h
+ * @author Youmin Ha <youmin.ha@samsung.com>
+ * @version 0.1
+ * @brief This file declares API of pkgmgr_installer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <getopt.h>
+#include <dlog.h>
+
+
+
+/**
+ * pkgmgr_installer is an opaque type for an object
+ */
+typedef struct pkgmgr_installer pkgmgr_installer;
+typedef void* pkgmgr_instcertinfo_h;
+
+/**
+ * @brief listening event type in pkgmgr.
+ */
+#define PKGMGR_INSTALLER_START_KEY_STR "start"
+#define PKGMGR_INSTALLER_END_KEY_STR "end"
+#define PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR "install_percent"
+#define PKGMGR_INSTALLER_GET_SIZE_KEY_STR "get_size"
+
+#define PKGMGR_INSTALLER_INSTALL_EVENT_STR "install"
+#define PKGMGR_INSTALLER_UNINSTALL_EVENT_STR "uninstall"
+#define PKGMGR_INSTALLER_MOVE_EVENT_STR "move"
+#define PKGMGR_INSTALLER_UPGRADE_EVENT_STR "update"
+#define PKGMGR_INSTALLER_OK_EVENT_STR "ok"
+#define PKGMGR_INSTALLER_FAIL_EVENT_STR "fail"
+
+
+
+
+/**
+ * Request type.
+ */
+enum {
+ PKGMGR_REQ_PERM = -1,
+ PKGMGR_REQ_INVALID = 0,
+ PKGMGR_REQ_INSTALL = 1,
+ PKGMGR_REQ_UNINSTALL = 2,
+ PKGMGR_REQ_CLEAR = 3,
+ PKGMGR_REQ_MOVE = 4,
+ PKGMGR_REQ_RECOVER = 5,
+ PKGMGR_REQ_REINSTALL = 6,
+ PKGMGR_REQ_GETSIZE = 7,
+ PKGMGR_REQ_UPGRADE = 8,
+ PKGMGR_REQ_SMACK = 9
+};
+
+enum {
+ PKGMGR_INSTALLER_EINVAL = -2, /**< Invalid argument */
+ PKGMGR_INSTALLER_ERROR = -1, /**< General error */
+ PKGMGR_INSTALLER_EOK = 0 /**< General success */
+};
+
+
+typedef enum {
+ PM_SET_AUTHOR_ROOT_CERT = 0,
+ PM_SET_AUTHOR_INTERMEDIATE_CERT = 1,
+ PM_SET_AUTHOR_SIGNER_CERT = 2,
+ PM_SET_DISTRIBUTOR_ROOT_CERT = 3,
+ PM_SET_DISTRIBUTOR_INTERMEDIATE_CERT = 4,
+ PM_SET_DISTRIBUTOR_SIGNER_CERT = 5,
+ PM_SET_DISTRIBUTOR2_ROOT_CERT = 6,
+ PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT = 7,
+ PM_SET_DISTRIBUTOR2_SIGNER_CERT = 8,
+}pkgmgr_instcert_type;
+
+
+/**
+ * @brief Create a pkgmgr_installer object.
+ * @pre None
+ * @post pkgmgr_installer object must be freed.
+ * @see pkgmgr_installer_free
+ * @return pkgmgr_installer object
+ * @retval NULL on failure creating an object
+ * @remark None
+@code
+#include <pkgmgr_installer.h>
+pkgmgr_installer *pi = pkgmgr_installer_new();
+pkgmgr_installer_free(pi);
+@endcode
+ */
+pkgmgr_installer *pkgmgr_installer_new(void);
+
+/**
+ @brief Free a pkgmgr_installer object
+ @pre pi must be a valid object.
+ @post None
+ @see pkgmgr_installer_new
+ @param[in] pi A pkgmgr_installer object
+ @return Operation result
+ @retval 0 on success
+ @retval -errno on error
+ @remark None
+ @code
+#include <pkgmgr_installer.h>
+pkgmgr_installer *pi = pkgmgr_installer_new();
+pkgmgr_installer_free(pi);
+ @endcode
+ */
+int pkgmgr_installer_free(pkgmgr_installer *pi);
+
+/**
+ @brief Receive a request from argv
+ @pre None
+ @post pkgmgr_installer_get_*(), pkgmgr_installer_is_quiet() can be called.
+ @see pkgmgr_installer_get_request_type, pkgmgr_installer_get_request_info, pkgmgr_installer_get_session_id, pkgmgr_installer_is_quiet
+ @param[in] pi a pkgmgr_installer object
+ @param[in] argc argc from system
+ @param[in] argv argv from system
+ @return Operation result
+ @retval 0 on success
+ @retval -errno on failure
+ @remark None
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r;
+
+ pi = pkgmgr_installer_new();
+ int r = pkgmgr_installer_receive_request(pi, argc, argv);
+ pkgmgr_installer_free(pi);
+
+ return 0;
+}
+ @endcode
+ */
+int pkgmgr_installer_receive_request(pkgmgr_installer *pi,
+ const int argc, char **argv);
+
+/**
+ @brief Get request type
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return Request type (One of PKGMGR_REQ_* enum values)
+ @remark None
+ @code
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+
+ switch(pkgmgr_installer_get_request_type(pi)) {
+ case PKGMGR_REQ_PERM:
+ // Do error processing
+ break;
+ case PKGMGR_REQ_INVALID:
+ // Do error processing
+ r = -1;
+ break;
+ case PKGMGR_REQ_INSTALL:
+ // Do install processing
+ break;
+ case PKGMGR_REQ_UNINSTALL:
+ // Do uninstall processing
+ break;
+ case PKGMGR_REQ_RECOVER:
+ // Do recovere processing
+ break;
+ case PKGMGR_REQ_REINSTALL:
+ // Do reinstall processing
+ break;
+ default:
+ goto CLEANUP_END;
+ }
+CLEANUP_END:
+ pkgmgr_installer_free(pi);
+
+ return r;
+}
+ @endcode
+ */
+int pkgmgr_installer_get_request_type(pkgmgr_installer *pi);
+
+/**
+ @brief Get request info
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return Request info. When PKGMGR_REQ_INSTALL, this is a package file path to be installed. When PKGMGR_REQ_UNINSTALL, this is a package name to be uninstalled.
+ @retval NULL on function failure
+ @remark Returned string must not be modified.
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *req_info = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ req_info = (char *) pkgmgr_installer_get_request_info(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+const char *pkgmgr_installer_get_request_info(pkgmgr_installer *pi);
+
+/**
+ @brief Get session ID for a certain session
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return A session ID
+ @retval NULL on function failure
+ @remark Returned string must not be modified.
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *session_id = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ session_id = (char *) pkgmgr_installer_get_session_id(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+@endcode
+ */
+const char *pkgmgr_installer_get_session_id(pkgmgr_installer *pi);
+
+/**
+ @brief Get a license path
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return license path
+ @retval NULL on function failure
+ @remark Returned string must not be modified.
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *license_path = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ session_id = (char *) pkgmgr_installer_get_license_path(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+@endcode
+ */
+const char *pkgmgr_installer_get_license_path(pkgmgr_installer *pi);
+
+/**
+ @brief Get a optional data
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return optional data
+ @retval NULL on function failure
+ @remark Returned string must not be modified.
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *optional_data = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ optional_data = (char *) pkgmgr_installer_get_optional_data(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+@endcode
+ */
+const char *pkgmgr_installer_get_optional_data(pkgmgr_installer *pi);
+
+/**
+ @brief Get if a request is with quite mode or not
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return Operation result
+ @retval 0 if a request is not quiet mode
+ @retval 1 if a request is quiet mode
+ @remark None
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ if(pkgmgr_installer_is_quiet(pi)) {
+ // Do quiet mode work...
+ } else {
+ // Do normal mode work...
+ }
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+int pkgmgr_installer_is_quiet(pkgmgr_installer *pi);
+
+/**
+ @brief Get move type
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return Operation result
+ @retval enum value of move type
+ @remark None
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ move_type = pkgmgr_installer_get_move_type(pi);
+
+ //Do Something
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+int pkgmgr_installer_get_move_type(pkgmgr_installer *pi);
+
+/**
+ @brief Get caller package id
+ @pre pkgmgr_installer_receive_request() must be called.
+ @post None
+ @see pkgmgr_installer_receive_request
+ @param[in] pi pkgmgr_installer object
+ @return Operation result
+ @retval enum value of move type
+ @remark None
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *pkgid = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+ pkgid = (char *) pkgmgr_installer_get_caller_pkgid(pi);
+
+ // Do something...
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+const char *pkgmgr_installer_get_caller_pkgid(pkgmgr_installer *pi);
+
+/**
+ @brief Send a process status signal
+ @pre None
+ @post None
+ @see None
+ @param[in] pi pkgmgr_installer object
+ @param[in] pkg_type package type: "deb", "jar", "wgt", ...
+ @param[in] pkgid package id
+ @param[in] key Signal key
+ @param[in] val Signal value
+ @return Operation result
+ @retval 0 on success
+ @retval -errno on failure
+ @remark If pkgmgr_installer_receive_request() is not called, the session ID will be null string (=="/0").
+ @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+ pkgmgr_installer *pi;
+ int r = 0;
+ char *session_id = NULL;
+
+ pi = pkgmgr_installer_new();
+ if(!pi) return -1;
+ if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+ r = -1;
+ goto CLEANUP_RET;
+ }
+
+ // Do something...
+ pkgmgr_installer_send_signal(pi,
+ "deb", "com.samsung.foo", "install_percent", "100");
+ // A sample signal
+
+ pkgmgr_installer_free(pi);
+ return r;
+}
+ @endcode
+ */
+int pkgmgr_installer_send_signal(pkgmgr_installer *pi,
+ const char *pkg_type,
+ const char *pkgid, const char *key,
+ const char *val);
+
+/**
+ * @brief This API creates the certinfo handle.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[out] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_create_certinfo_set_handle(pkgmgr_instcertinfo_h *handle);
+
+/**
+ * @brief This API sets cert value for corresponding cert type.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to cert info handle
+ * @param[in] cert_type enum value for certificate type
+ * @param[in] cert_value certificate value
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_set_cert_value(pkgmgr_instcertinfo_h handle, pkgmgr_instcert_type cert_type, char *cert_value);
+
+/**
+ * @brief This API saves cert info in DB.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkgid package ID
+ * @param[in] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle);
+
+/**
+ * @brief This API destroys cert info handle freeing all resources.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] handle pointer to cert info handle
+ * @return 0 if success, error code(<0) if fail\n
+*/
+int pkgmgr_installer_destroy_certinfo_set_handle(pkgmgr_instcertinfo_h handle);
+
+/**
+ * @brief This API deletes cert info from DB. To be used to cleanup info upon pkg uninstallation
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in] pkgid package ID
+ * @return 0 if success, error code(<0) if fail\n
+*/
+ int pkgmgr_installer_delete_certinfo(const char *pkgid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PKGMGR_INSTALLER_H__ */
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef __PACKAGE_INSTALLER_CONFIG_H__
+#define __PACKAGE_INSTALLER_CONFIG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Supported options */
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:q";
+const struct option long_opts[] = {
+ { "session-id", 1, NULL, 'k' },
+ { "license-path", 1, NULL, 'l' },
+ { "install", 1, NULL, 'i' },
+ { "uninstall", 1, NULL, 'd' },
+ { "clear", 1, NULL, 'c' },
+ { "move", 1, NULL, 'm' },
+ { "move-type", 1, NULL, 't' },
+ { "optional-data", 0, NULL, 'o' },
+ { "reinstall", 0, NULL, 'r' },
+ { "caller-pkgid", 1, NULL, 'p' },
+ { "smack", 1, NULL, 's' },
+ { "quiet", 1, NULL, 'q' },
+ { 0, 0, 0, 0 } /* sentinel */
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PACKAGE_INSTALLER_CONFIG_H__ */
--- /dev/null
+include(FindPkgConfig)
+pkg_check_modules(test_pkgs REQUIRED dbus-glib-1 glib-2.0 dlog)
+
+add_definitions(${test_pkgs_CFLAGS})
+
+
+add_executable(test_comm_pkg_mgr_server
+ test_comm_pkg_mgr_server.c)
+target_link_libraries(test_comm_pkg_mgr_server pkgmgr_installer_pkg_mgr_server)
+target_link_libraries(test_comm_pkg_mgr_server ${test_pkgs_LDFLAGS})
+
+add_executable(test_comm_status_broadcast_server
+ test_comm_status_broadcast_server.c)
+target_link_libraries(test_comm_status_broadcast_server pkgmgr_installer_status_broadcast_server)
+target_link_libraries(test_comm_status_broadcast_server ${test_pkgs_LDFLAGS})
+
+add_executable(test_comm_client
+ test_comm_client.c)
+target_link_libraries(test_comm_client pkgmgr_installer_client)
+target_link_libraries(test_comm_client ${test_pkgs_LDFLAGS})
+
+
+add_executable(test_comm_socket
+ test_comm_socket.c)
+target_link_libraries(test_comm_socket comm_socket ${test_pkgs_LDFLAGS})
+set_target_properties(test_comm_socket PROPERTIES SKIP_BUILD_RPATH true)
+
+
+add_executable(test_pkgmgr_installer
+ test_pkgmgr_installer.c)
+target_link_libraries(test_pkgmgr_installer pkgmgr_installer pkgmgr_installer_client ${test_pkgs_LDFLAGS})
+set_target_properties(test_pkgmgr_installer PROPERTIES SKIP_BUILD_RPATH true)
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "comm_client.h"
+#include <stdio.h>
+#include <glib.h>
+
+static GMainLoop *mainloop;
+
+void
+stat_cb(void *data, const char *req_id, const char *pkg_type,
+ const char *pkgid, const char *key, const char *val)
+{
+ printf(">>user callback>> Got: %s %s %s %s %s\n", req_id, pkg_type,
+ pkgid, key, val);
+
+ g_main_loop_quit(mainloop);
+}
+
+int main(int argc, char **argv)
+{
+
+ g_type_init();
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ comm_client *cc = comm_client_new();
+
+ gint ret;
+ ret = comm_client_request(cc, "__test__req_key", COMM_REQ_TO_INSTALLER,
+ "dpkg", "test_pkg", "arg1 arg2 arg3",
+ "this_is_a_cookie", 0);
+
+ printf("client: waiting signal...\n");
+ comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, cc, stat_cb, NULL);
+
+ g_main_loop_run(mainloop);
+
+ comm_client_free(cc);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "comm_pkg_mgr_server.h"
+#include <glib.h>
+#include <stdio.h>
+
+void
+req_cb(void *cb_data, const char *req_id, const int req_type,
+ const char *pkg_type, const char *pkgid, const char *args,
+ const char *cookie, int *ret)
+{
+ /* TODO: Do your job here */
+ printf(">> in callback >> Got request: %s %d %s %s %s (cookie:%s)\n",
+ req_id, req_type, pkg_type, pkgid, args, cookie);
+}
+
+gboolean queue_job(void *data)
+{
+ /* .i..
+
+ if (no_need_more) {
+ g_main_loop_quit(mainloop);
+ return FALSE;
+
+ */
+ return TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ g_type_init();
+
+ GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
+
+ PkgMgrObject *pkg_mgr;
+ pkg_mgr = g_object_new(PKG_MGR_TYPE_OBJECT, NULL);
+
+ pkg_mgr_set_request_callback(pkg_mgr, req_cb, NULL);
+
+ g_timeout_add_seconds(1, queue_job, NULL);
+
+ g_main_loop_run(mainloop);
+
+ /* TODO: add cleanup code */
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "comm_socket.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void __test_comm_socket_create_server(void);
+static void __test_comm_socket_create_server(void)
+{
+ comm_socket *cs;
+ cs = _comm_socket_new();
+
+ char *tmp_file_path = "/tmp/____asjdfjlsdjlfjxcvj";
+ assert(0 == _comm_socket_create_server(cs, tmp_file_path));
+
+ _comm_socket_free(cs);
+}
+
+int main(int argc, char **argv)
+{
+ __test_comm_socket_create_server();
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "comm_status_broadcast_server.h"
+#include <glib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+static int _main_dbus(int argc, char **argv);
+static int _main_dbus(int argc, char **argv)
+{
+ DBusConnection *conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
+ int i;
+ for (i = 0; i < 100; i++) {
+ comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, conn, "test_id",
+ "test", "test_pkgid",
+ "test_key",
+ "test_val");
+ sleep(1);
+ printf(">>> sent signal: %d\n", i);
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ return _main_dbus(argc, argv);
+
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "pkgmgr_installer.h"
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "comm_client.h"
+static int _argc;
+static char **_argv;
+static GMainLoop *mainloop;
+
+static void __test_pi_new_free(void);
+static void __test_pi_receive_request_standard_mode();
+static void __test_pi_send_signal();
+static void __test_pi_receive_request_quiet_mode();
+
+static void __test_pi_new_free(void)
+{
+ pkgmgr_installer *pi = pkgmgr_installer_new();
+ assert(NULL != pi);
+
+ pkgmgr_installer_free(pi);
+}
+
+static void __test_pi_receive_request_standard_mode(void)
+{
+ pkgmgr_installer *pi;
+
+ struct test_data {
+ char *argv[1024];
+ int size_argv;
+ int desired_ret_type;
+ char *desired_pkg_info;
+ char *desired_session_id;
+ };
+
+ /* Test data collection: Add more test here, except -q */
+ struct test_data td[] = {
+ { {"a", "-i", "abc" }, 3, PKGMGR_REQ_INSTALL, "abc", NULL},
+ { {"a", "-i", "ghi", "-k", "key1" }, 5, PKGMGR_REQ_INSTALL,
+ "ghi", "key1" },
+ { {"a", "-i", "abc", "-k", "key1", "-k", "key2" }, 7,
+ PKGMGR_REQ_INSTALL, "abc", "key2" },
+ { { NULL }, 0, 0, NULL, NULL } /* sentinel */
+ };
+
+ /* Run test! */
+ int i = 0;
+ struct test_data *p_td = td + i;
+ while (p_td && p_td->size_argv) {
+
+ printf(">>> %s %d %d %s\n", p_td->argv[0], p_td->size_argv,
+ p_td->desired_ret_type, p_td->desired_pkg_info);
+
+ pi = pkgmgr_installer_new();
+ assert(NULL != pi);
+
+ assert(0 == pkgmgr_installer_receive_request(
+ pi, p_td->size_argv, p_td->argv));
+ assert(p_td->desired_ret_type ==
+ pkgmgr_installer_get_request_type(pi));
+ assert(pkgmgr_installer_get_request_info(pi)); /* NULL check */
+ assert(!strcmp(p_td->desired_pkg_info,
+ pkgmgr_installer_get_request_info(pi)));
+ if (p_td->desired_session_id) {
+ assert(pkgmgr_installer_get_session_id(pi));
+ assert(!strcmp(p_td->desired_session_id,
+ pkgmgr_installer_get_session_id(pi)));
+ } else {
+ assert(p_td->desired_session_id ==
+ pkgmgr_installer_get_session_id(pi));
+ }
+ pkgmgr_installer_free(pi);
+
+ /* next */
+ i++;
+ p_td = td + i;
+ }
+}
+
+struct signal_counter {
+ int start;
+ int install_percent;
+ int end;
+};
+
+static gboolean timer_stop_mainloop(void *data)
+{
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+static void
+get_signal_cb(void *cb_data, const char *req_id, const char *pkg_type,
+ const char *pkgid, const char *key, const char *val)
+{
+ struct signal_counter *counter = (struct signal_counter *)cb_data;
+
+ printf("get_signal_cb() called\n");
+ if (!strcmp("start", key))
+ counter->start += 1;
+ if (!strcmp("install_percent", key))
+ counter->install_percent = atoi(val);
+ if (!strcmp("end", key))
+ counter->end += 1;
+
+ g_main_loop_quit(mainloop);
+}
+
+static gboolean timer_send_signal(void *data)
+{
+ pkgmgr_installer *pi = (pkgmgr_installer *) data;
+ printf("try to send signal\n");
+ assert(0 == pkgmgr_installer_send_signal(pi, "deb", "testpkg", "start",
+ "install"));
+ printf("sent signal\n");
+ return FALSE;
+}
+
+static void __test_pi_send_signal(void)
+{
+ pkgmgr_installer *pi;
+ pi = pkgmgr_installer_new();
+ assert(NULL != pi);
+
+ /* receiver */
+ struct signal_counter counter = { 0, };
+ comm_client *cc;
+ cc = comm_client_new();
+ comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, cc, get_signal_cb, &counter);
+
+ /* sender */
+ g_timeout_add_seconds(1, timer_send_signal, pi);
+
+ /* Set timeout, and run main loop */
+ g_timeout_add_seconds(5, timer_stop_mainloop, NULL);
+
+ printf("start loop\n");
+ g_main_loop_run(mainloop);
+
+ /* find values */
+ printf("exit loop\n");
+ assert(1 == counter.start);
+
+ comm_client_free(cc);
+
+ pkgmgr_installer_free(pi);
+}
+
+void __test_pi_receive_request_quiet_mode()
+{
+ pkgmgr_installer *pi;
+
+ struct test_data {
+ char *argv[1024];
+ int size_argv;
+ int desired_ret_type;
+ char *desired_pkg_info;
+ char *desired_session_id;
+ };
+
+ /* Test data collection: Add more test here, except -q */
+ struct test_data td[] = {
+ { {"a", "-q", "-i", "abc" }, 4, PKGMGR_REQ_INSTALL, "abc", NULL},
+ { {"a", "-i", "ghi", "-k", "key1", "-q" }, 6,
+ PKGMGR_REQ_INSTALL, "ghi", "key1"},
+ { {NULL}, 0, 0, NULL, NULL } /* sentinel */
+ };
+
+ /* Run test! */
+ int i = 0;
+ int r;
+ struct test_data *p_td = td + i;
+ while (p_td && p_td->size_argv) {
+
+ printf(">>> %s %d %d %s\n", p_td->argv[0], p_td->size_argv,
+ p_td->desired_ret_type, p_td->desired_pkg_info);
+
+ pi = pkgmgr_installer_new();
+ assert(NULL != pi);
+ r = pkgmgr_installer_receive_request(pi, p_td->size_argv,
+ p_td->argv);
+ printf("desired=0, r=%d\n", r);
+ assert(0 == r);
+ assert(p_td->desired_ret_type ==
+ pkgmgr_installer_get_request_type(pi));
+ assert(pkgmgr_installer_get_request_info(pi)); /* NULL check */
+ assert(!strcmp
+ (p_td->desired_pkg_info,
+ pkgmgr_installer_get_request_info(pi)));
+ assert(pkgmgr_installer_is_quiet(pi));
+ if (p_td->desired_session_id) {
+ assert(pkgmgr_installer_get_session_id(pi));
+ assert(!strcmp
+ (p_td->desired_session_id,
+ pkgmgr_installer_get_session_id(pi)));
+ } else {
+ assert(p_td->desired_session_id ==
+ pkgmgr_installer_get_session_id(pi));
+ }
+ pkgmgr_installer_free(pi);
+
+ /* next */
+ i++;
+ p_td = td + i;
+ }
+}
+
+/* Test collection */
+static void __test_pkgmgr_installer(void)
+{
+ __test_pi_new_free();
+ __test_pi_receive_request_standard_mode();
+ __test_pi_send_signal();
+ __test_pi_receive_request_quiet_mode();
+}
+
+/* main function */
+int main(int argc, char **argv)
+{
+ _argc = argc;
+ _argv = argv;
+
+ /* For event loop */
+ g_type_init();
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ __test_pkgmgr_installer();
+
+ return 0;
+}
+
--- /dev/null
+slp-pkgmgr (0.1.122) unstable; urgency=low
+
+ * Applied manifest
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.122
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 25 Jul 2012 19:11:44 +0900
+
+slp-pkgmgr (0.1.115) unstable; urgency=low
+
+ * Fixed bug when backend installer exits with failure
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.115
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 21 May 2012 21:12:04 +0900
+
+slp-pkgmgr (0.1.114) unstable; urgency=low
+
+ * Fixed server hang issue on pressing NO in popup
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.114
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 07 May 2012 15:34:45 +0900
+
+slp-pkgmgr (0.1.113) unstable; urgency=low
+
+ * Implemented multiple queue support
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.113
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 20 Apr 2012 10:51:58 +0900
+
+slp-pkgmgr (0.1.112) unstable; urgency=low
+
+ * Fixed activate/deactivate feature
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.112
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 03 Apr 2012 20:39:45 +0900
+
+slp-pkgmgr (0.1.111) unstable; urgency=low
+
+ * Fixed pkgmgr-install desktop to support rpm
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.111
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 30 Mar 2012 11:50:01 +0900
+
+slp-pkgmgr (0.1.110) unstable; urgency=low
+
+ * Fixed popup UI bug
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.110
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 23 Mar 2012 19:06:13 +0900
+
+slp-pkgmgr (0.1.109) unstable; urgency=low
+
+ * Fixed compile warnings
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.109
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 20 Mar 2012 15:36:02 +0900
+
+slp-pkgmgr (0.1.108) unstable; urgency=low
+
+ * Fixed desktop file
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.108
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 16 Mar 2012 21:35:27 +0900
+
+slp-pkgmgr (0.1.107) unstable; urgency=low
+
+ * Fixed bug for elementary modification
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.107
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 15 Mar 2012 15:04:39 +0900
+
+slp-pkgmgr (0.1.106) unstable; urgency=low
+
+ * Fixed code for elementary 1.0 release
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.106
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 13 Mar 2012 17:52:30 +0900
+
+slp-pkgmgr (0.1.105) unstable; urgency=low
+
+ * Support Appsvc for pkgmgr-install
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.105
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 27 Feb 2012 21:34:10 +0900
+
+slp-pkgmgr (0.1.104) unstable; urgency=low
+
+ * Added clear_user_data API
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.104
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 25 Jan 2012 17:47:26 +0900
+
+slp-pkgmgr (0.1.103) unstable; urgency=low
+
+ * Added Pkgmgr TC and fixed issues
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.103
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 26 Dec 2011 19:06:00 +0900
+
+slp-pkgmgr (0.1.102) unstable; urgency=low
+
+ * Removed README file
+ * Git: slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.102
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 22 Dec 2011 20:19:24 +0900
+
+slp-pkgmgr (0.1.101) unstable; urgency=low
+
+ * Fixed pkgmgr_info_new bug
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.101
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 22 Dec 2011 17:27:37 +0900
+
+slp-pkgmgr (0.1.100) unstable; urgency=low
+
+ * Fixed package activate/deactivate
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.100
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 13 Dec 2011 19:51:00 +0900
+
+slp-pkgmgr (0.1.99) unstable; urgency=low
+
+ * Added ecore_init() due to ecore internal logic change
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.99
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 09 Dec 2011 10:17:31 +0900
+
+slp-pkgmgr (0.1.98) unstable; urgency=low
+
+ * Cleanup code
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.98
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 06 Dec 2011 16:31:23 +0900
+
+slp-pkgmgr (0.1.97) unstable; urgency=low
+
+ * Updated changelog
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.97
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 05 Dec 2011 16:05:30 +0900
+
+slp-pkgmgr (0.1.96) unstable; urgency=low
+
+ * Fix pkgcmd exit code according to the installation result for SDK support
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.96
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 24 Nov 2011 15:12:31 +0900
+
+slp-pkgmgr (0.1.95) unstable; urgency=low
+
+ * Fixed gcc warnings, Klockwork issues and regression test issues
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.95
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 09 Nov 2011 15:45:40 +0900
+
+slp-pkgmgr (0.1.94) unstable; urgency=low
+
+ * Changed Boilerplate as per the guideline
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.94
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 07 Nov 2011 18:30:37 +0900
+
+slp-pkgmgr (0.1.93) unstable; urgency=low
+
+ * Apply AIL update in pkgmgr
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.93
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 31 Oct 2011 15:37:21 +0900
+
+slp-pkgmgr (0.1.92) unstable; urgency=low
+
+ * Fix prevent bug
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.92
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 26 Oct 2011 20:54:24 +0900
+
+slp-pkgmgr (0.1.91) unstable; urgency=low
+
+ * Fix package_manager_pkg_detail_info_t
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.91
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 20 Oct 2011 21:26:13 +0900
+
+slp-pkgmgr (0.1.90) unstable; urgency=low
+
+ * Apply localization string
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.90
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 18 Oct 2011 17:40:10 +0900
+
+slp-pkgmgr (0.1.89) unstable; urgency=low
+
+ * Add app_size in package_manager_pkg_detail_info_t
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.89
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 18 Oct 2011 11:54:56 +0900
+
+slp-pkgmgr (0.1.88) unstable; urgency=low
+
+ * Fix string
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.88
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 14 Oct 2011 10:49:17 +0900
+
+slp-pkgmgr (0.1.87) unstable; urgency=low
+
+ * set elm_scale
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.87
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 12 Oct 2011 13:06:20 +0900
+
+slp-pkgmgr (0.1.86) unstable; urgency=low
+
+ * Fix pkgmgr-install inteface to use bundle_import_from_argv()
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.86
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 07 Oct 2011 16:31:00 +0900
+
+slp-pkgmgr (0.1.85) unstable; urgency=low
+
+ * Remove unnecessary define
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.85
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 05 Oct 2011 15:47:42 +0900
+
+slp-pkgmgr (0.1.84) unstable; urgency=low
+
+ * Terminate application before uninstalling
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.84
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 28 Sep 2011 11:06:58 +0900
+
+slp-pkgmgr (0.1.83) unstable; urgency=low
+
+ * Fixed server bug while creating popup
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.83
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 23 Sep 2011 14:36:43 +0900
+
+slp-pkgmgr (0.1.82) unstable; urgency=low
+
+ * Remove old API
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.82
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 22 Sep 2011 12:25:55 +0900
+
+slp-pkgmgr (0.1.81) unstable; urgency=low
+
+ * Remove old AIL structure
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.81
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 21 Sep 2011 18:00:00 +0900
+
+slp-pkgmgr (0.1.80) unstable; urgency=low
+
+ * Fix callback unresistering
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.80
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 20 Sep 2011 20:09:45 +0900
+
+slp-pkgmgr (0.1.79) unstable; urgency=low
+
+ * Fix bug - pkgmgr-client/server
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.79
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 19 Sep 2011 19:05:37 +0900
+
+slp-pkgmgr (0.1.78) unstable; urgency=low
+
+ * Fix prevent defects
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.78
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 06 Sep 2011 11:12:54 +0900
+
+slp-pkgmgr (0.1.77) unstable; urgency=low
+
+ * Use name instead of pkg_name on uninstallation
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.77
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 05 Sep 2011 16:15:54 +0900
+
+slp-pkgmgr (0.1.76) unstable; urgency=low
+
+ * Fix bug
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.76
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 29 Aug 2011 15:17:47 +0900
+
+slp-pkgmgr (0.1.75) unstable; urgency=low
+
+ * Apply new API
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.75
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 25 Aug 2011 21:08:35 +0900
+
+slp-pkgmgr (0.1.74) unstable; urgency=low
+
+ * Fixed Prevent Issues
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.74
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 24 Aug 2011 20:12:30 +0900
+
+slp-pkgmgr (0.1.73) unstable; urgency=low
+
+ * Fix for AIL exception
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.73
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 23 Aug 2011 17:12:30 +0900
+
+slp-pkgmgr (0.1.72) unstable; urgency=low
+
+ * Cleanup code
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.72
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 19 Aug 2011 11:46:33 +0900
+
+slp-pkgmgr (0.1.71) unstable; urgency=low
+
+ * Add info type
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.71
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 18 Aug 2011 18:40:30 +0900
+
+slp-pkgmgr (0.1.70) unstable; urgency=low
+
+ * Add optional_id in package_manager_pkg_detail_info_t
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.70
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 10 Aug 2011 19:18:52 +0900
+
+slp-pkgmgr (0.1.69) unstable; urgency=low
+
+ * Apply new AIL API
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.69
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 09 Aug 2011 14:25:09 +0900
+
+slp-pkgmgr (0.1.68) unstable; urgency=low
+
+ * Apply code cleanup
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.68
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 01 Aug 2011 19:32:38 +0900
+
+slp-pkgmgr (0.1.67) unstable; urgency=low
+
+ * Apply Boilerplate
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.67
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 13 Jul 2011 17:33:40 +0900
+
+slp-pkgmgr (0.1.66) unstable; urgency=low
+
+ * Cleanup code
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.66
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 05 Jul 2011 17:59:59 +0900
+
+slp-pkgmgr (0.1.65) unstable; urgency=low
+
+ * Cleanup control file
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.65
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 04 Jul 2011 20:25:20 +0900
+
+slp-pkgmgr (0.1.64) unstable; urgency=low
+
+ * Cleanup code
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.64
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 28 Jun 2011 19:40:17 +0900
+
+slp-pkgmgr (0.1.63) unstable; urgency=low
+
+ * Cleanup code
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.63
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 24 Jun 2011 19:09:13 +0900
+
+slp-pkgmgr (0.1.62) unstable; urgency=low
+
+ * Fix prevent defect
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.62
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 20 Jun 2011 14:37:43 +0900
+
+slp-pkgmgr (0.1.61) unstable; urgency=low
+
+ * Change popup type to modal
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.61
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 06 Jun 2011 12:59:16 +0900
+
+slp-pkgmgr (0.1.60) unstable; urgency=low
+
+ * Apply ail
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.60
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 18 May 2011 20:25:58 +0900
+
+slp-pkgmgr (0.1.59) unstable; urgency=low
+
+ * Fix build error - CMakeLists.txt
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.59
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 18 May 2011 14:31:49 +0900
+
+slp-pkgmgr (0.1.58) unstable; urgency=low
+
+ * Move pkgmgr-tool pkgmgr-install to libpkgmgr-client-0
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.58
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 17 May 2011 20:41:15 +0900
+
+slp-pkgmgr (0.1.57) unstable; urgency=low
+
+ * Fix argument handling - to include # character
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.57
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 16 May 2011 20:56:26 +0900
+
+slp-pkgmgr (0.1.56) unstable; urgency=low
+
+ * Fix popup problem
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.56
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 11 May 2011 16:18:05 +0900
+
+slp-pkgmgr (0.1.55) unstable; urgency=low
+
+ * Fix popup problem
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.55
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 11 May 2011 16:11:00 +0900
+
+slp-pkgmgr (0.1.54) unstable; urgency=low
+
+ * Fix getting type in pkgmgr-client
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.54
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 25 Apr 2011 21:26:31 +0900
+
+slp-pkgmgr (0.1.53) unstable; urgency=low
+
+ * Fix bug in pkgmgr-client
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.53
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 18 Apr 2011 18:38:26 +0900
+
+slp-pkgmgr (0.1.52) unstable; urgency=low
+
+ * Fix item name in desktop file: X-SLP-PackageType
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.52
+
+ -- Youmin Ha <youmin.ha@samsung.com> Fri, 15 Apr 2011 10:50:01 +0900
+
+slp-pkgmgr (0.1.51) unstable; urgency=low
+
+ * Read pkg_type from desktop file when uninstall
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.51
+
+ -- Youmin Ha <youmin.ha@samsung.com> Thu, 14 Apr 2011 14:40:41 +0900
+
+slp-pkgmgr (0.1.50) unstable; urgency=low
+
+ * Fix pkgmgr-tool
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.50
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 04 Apr 2011 21:35:36 +0900
+
+slp-pkgmgr (0.1.49) unstable; urgency=low
+
+ * Fix build error and popup string
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.49
+
+ -- Sewook Park <sewook7.park@samsung.com> Sat, 02 Apr 2011 17:22:23 +0900
+
+slp-pkgmgr (0.1.48) unstable; urgency=low
+
+ * Change popup handling in pkgmgr
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.48
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 01 Apr 2011 17:05:28 +0900
+
+slp-pkgmgr (0.1.47) unstable; urgency=low
+
+ * Add function body for get_license_path()
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.47
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 16 Mar 2011 18:40:02 +0900
+
+slp-pkgmgr (0.1.46) unstable; urgency=low
+
+ * Add api: pkgmgr_installer_get_license_path()
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.46
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 14 Mar 2011 17:15:43 +0900
+
+slp-pkgmgr (0.1.45) unstable; urgency=low
+
+ * Add license parameter on package_manager_install_application_with_type()
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.45
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 10 Mar 2011 13:54:27 +0900
+
+slp-pkgmgr (0.1.44) unstable; urgency=low
+
+ * Apply 2sec wait in pkgmgr-install
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.44
+
+ -- Youmin Ha <youmin.ha@samsung.com> Tue, 08 Mar 2011 15:14:10 +0900
+slp-pkgmgr (0.1.43) unstable; urgency=low
+
+ * Fix mime bugs
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.43
+
+ -- Youmin Ha <youmin.ha@samsung.com> Fri, 04 Mar 2011 09:20:23 +0900
+
+slp-pkgmgr (0.1.42) unstable; urgency=low
+
+ * Fix for argument which has white space
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.42
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 04 Mar 2011 01:42:07 +0900
+
+slp-pkgmgr (0.1.41) unstable; urgency=low
+
+ * Fix pkgmgr-server.postinst -exclude updaet-mime-database
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.41
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 03 Mar 2011 23:07:08 +0900
+
+slp-pkgmgr (0.1.40) unstable; urgency=low
+
+ * Fix MAX_PKG_TYPE_LEN to 128
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.40
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 03 Mar 2011 21:54:45 +0900
+
+slp-pkgmgr (0.1.39-1) unstable; urgency=low
+
+ * Fix header to pass api review (no code change)
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.39-1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Thu, 03 Mar 2011 20:27:45 +0900
+
+slp-pkgmgr (0.1.39) unstable; urgency=low
+
+ * Support wgt mime type, Fix build error
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.39
+
+ -- Youmin Ha <youmin.ha@samsung.com> Thu, 03 Mar 2011 18:53:17 +0900
+
+slp-pkgmgr (0.1.38) unstable; urgency=low
+
+ * Fix trivial bug
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.38
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 03 Mar 2011 16:45:07 +0900
+
+slp-pkgmgr (0.1.37) unstable; urgency=low
+
+ * Change pkgmgr architecture
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.37
+
+ -- Sewook7.park <sewook7.park@samsung.com> Thu, 03 Mar 2011 15:36:33 +0900
+
+slp-pkgmgr (0.1.36-2) unstable; urgency=low
+
+ * Rollback
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.36-2
+
+ -- Sewook Park <sewook7.park@samsung.com> Sat, 26 Feb 2011 16:06:20 +0900
+
+slp-pkgmgr (0.1.36) unstable; urgency=low
+
+ * Add install_with_license API
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.36
+
+ -- Sewook Park <sewook7.park@samsung.com> Sat, 26 Feb 2011 14:48:31 +0900
+
+slp-pkgmgr (0.1.35) unstable; urgency=low
+
+ * Install pkgmgr-tool into the binary package, to be used with SDK
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.35
+
+ -- Youmin Ha <youmin.ha@samsung.com> Tue, 22 Feb 2011 16:45:32 +0900
+
+slp-pkgmgr (0.1.34) unstable; urgency=low
+
+ * fix pkgmgr_tool
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.34
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 18 Feb 2011 13:40:52 +0900
+
+slp-pkgmgr (0.1.33) unstable; urgency=low
+
+ * check argument length (Found by prevent)
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.33
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 16 Feb 2011 20:17:13 +0900
+
+slp-pkgmgr (0.1.32) unstable; urgency=low
+
+ * Add null check to pkgmgr_server (Found by prevent)
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.32
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 16 Feb 2011 14:36:34 +0900
+
+slp-pkgmgr (0.1.31) unstable; urgency=low
+
+ * pkgmgr_tool fix
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.31
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 02 Feb 2011 15:29:27 +0900
+
+slp-pkgmgr (0.1.30) unstable; urgency=low
+
+ * Prevent bug fix
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.30
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 26 Jan 2011 10:24:51 +0900
+
+slp-pkgmgr (0.1.29) unstable; urgency=low
+
+ * fix the return value of comm_client_free()
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.29
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 18 Jan 2011 15:09:56 +0900
+
+slp-pkgmgr (0.1.28) unstable; urgency=low
+
+ * Change pkgmgr structure
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.28
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 14 Jan 2011 14:05:22 +0900
+
+slp-pkgmgr (0.1.27-1) unstable; urgency=low
+
+ * upload
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.27-1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 29 Dec 2010 15:21:11 +0900
+
+slp-pkgmgr (0.1.27) unstable; urgency=low
+
+ * Initialize gerror variable to NULL, to avoid error from
+ g_shell_parse_argv()
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.27
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 29 Dec 2010 14:45:33 +0900
+
+slp-pkgmgr (0.1.26) unstable; urgency=low
+
+ * fix pkgmgr_tool
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.26
+
+ -- root <sewook7.park@samsung.com> Tue, 21 Dec 2010 19:50:57 +0900
+
+slp-pkgmgr (0.1.25) unstable; urgency=low
+
+ * fix pkgmgr_client bug - resource free of result_callback
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.25
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 20 Dec 2010 21:17:19 +0900
+
+slp-pkgmgr (0.1.24) unstable; urgency=low
+
+ * Apply new dbus-based comm_client library. (Known bugs are fixed)
+ Avoid BS fron opengl, by unsetting ELM_ENGINE environnent variable.
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.24
+
+ -- Youmin Ha <youmin.ha@samsung.com> Sat, 18 Dec 2010 16:44:23 +0900
+
+slp-pkgmgr (0.1.23-2) unstable; urgency=low
+
+ * fix control
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.23-2
+
+ -- root <sewook7.park@samsung.com> Mon, 13 Dec 2010 15:07:17 +0900
+
+slp-pkgmgr (0.1.23-1) unstable; urgency=low
+
+ * add aul on control
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.23-1
+
+ -- root <sewook7.park@samsung.com> Mon, 13 Dec 2010 13:42:50 +0900
+
+slp-pkgmgr (0.1.23) unstable; urgency=low
+
+ * add pkgmgr_client API - package_manager_install_application_with_type()
+ * Git: 165.213.180.234:slp/pkgs/s/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.23
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 10 Dec 2010 17:14:31 +0900
+
+slp-pkgmgr (0.1.22) unstable; urgency=low
+
+ * fix pkgmgr_client for system package
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.22
+
+ -- root <sewook7.park@samsung.com> Mon, 06 Dec 2010 12:13:00 +0900
+
+slp-pkgmgr (0.1.21) unstable; urgency=low
+
+ * fix bugs in pkgmgr_client
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.21
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 03 Dec 2010 17:48:14 +0900
+
+slp-pkgmgr (0.1.20) unstable; urgency=low
+
+ * fix bugs in comm_client
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.20
+
+ -- Youmin Ha <youmin.ha@samsung.com> Fri, 03 Dec 2010 15:13:52 +0900
+
+slp-pkgmgr (0.1.19) unstable; urgency=low
+
+ * fix pkgmgr_client - bug fix, pkg_info
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.19
+
+ -- root <sewook7.park@samsung.com> Wed, 01 Dec 2010 20:04:10 +0900
+
+slp-pkgmgr (0.1.18) unstable; urgency=low
+
+ * NULL check on pkg_name in comm_client_request()
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.18
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 24 Nov 2010 21:28:17 +0900
+
+slp-pkgmgr (0.1.17) unstable; urgency=low
+
+ * fix pkgmgr_tool bug, add LOG_TAG
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.17
+
+ -- root <sewook7.park@samsung.com> Wed, 24 Nov 2010 19:46:41 +0900
+
+slp-pkgmgr (0.1.16) unstable; urgency=low
+
+ * fix pkgmgr-client bug
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.16
+
+ -- root <sewook7.park@samsung.com> Thu, 18 Nov 2010 14:52:42 +0900
+
+slp-pkgmgr (0.1.15) unstable; urgency=low
+
+ * remove pkgmgr_frontend_test, pkgmgr_backend_test
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.15
+
+ -- root <sewook7.park@samsung.com> Fri, 12 Nov 2010 14:15:47 +0900
+
+slp-pkgmgr (0.1.14-2) unstable; urgency=low
+
+ * fix pkgmgr-client log
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.14-2
+
+ -- root <sewook7.park@samsung.com> Thu, 11 Nov 2010 14:02:25 +0900
+
+slp-pkgmgr (0.1.14-1) unstable; urgency=low
+
+ * fix pkgmgr-client
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.14-1
+
+ -- root <sewook7.park@samsung.com> Thu, 11 Nov 2010 11:51:15 +0900
+
+slp-pkgmgr (0.1.14) unstable; urgency=low
+
+ * fix pkgmgr-client
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.14
+
+ -- root <sewook7.park@samsung.com> Wed, 10 Nov 2010 14:29:37 +0900
+
+slp-pkgmgr (0.1.13) unstable; urgency=low
+
+ * add activator facility
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.13
+
+ -- Kidong Kim <kd0228.kim@samsung.com> Wed, 10 Nov 2010 10:39:59 +0900
+
+slp-pkgmgr (0.1.12) unstable; urgency=low
+
+ * fix package dependency
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.12
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 10 Nov 2010 09:13:23 +0900
+
+slp-pkgmgr (0.1.11) unstable; urgency=low
+
+ * re-versioning
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.11
+
+ -- Youmin Ha <youmin.ha@samsung.com> Tue, 09 Nov 2010 18:08:06 +0900
+
+slp-pkgmgr (0.1.10-4) unstable; urgency=low
+
+ * fix shared libs' dependencies
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.10-4
+
+ -- Youmin Ha <youmin.ha@samsung.com> Tue, 09 Nov 2010 18:03:25 +0900
+
+slp-pkgmgr (0.1.10-3) unstable; urgency=low
+
+ * Fix build error
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.10-3
+
+ -- root <sewook7.park@samsung.com> Tue, 09 Nov 2010 16:17:42 +0900
+
+slp-pkgmgr (0.1.10-2) unstable; urgency=low
+
+ * Fix pkgmgr-client & pkgmgr-server
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.10-2
+
+ -- root <sewook7.park@samsung.com> Tue, 09 Nov 2010 14:15:58 +0900
+
+slp-pkgmgr (0.1.10-1) unstable; urgency=low
+
+ * Fix pc files
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.10-1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Tue, 09 Nov 2010 11:29:28 +0900
+
+slp-pkgmgr (0.1.10) unstable; urgency=low
+
+ * Free comm_client in libpkgmgr_client.so
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.10
+
+ -- root <sewook7.park@samsung.com> Mon, 08 Nov 2010 20:30:37 +0900
+
+slp-pkgmgr (0.1.9) unstable; urgency=low
+
+ * Make comm* libs to shared libs
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.9
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 08 Nov 2010 15:20:42 +0900
+
+slp-pkgmgr (0.1.8-1) unstable; urgency=low
+
+ * fix PG
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.8-1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 08 Nov 2010 10:46:06 +0900
+
+slp-pkgmgr (0.1.8) unstable; urgency=low
+
+ * fix client - get_list
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.8
+
+ -- root <youmin.ha@samsung.com> Wed, 03 Nov 2010 12:03:16 +0900
+
+slp-pkgmgr (0.1.7) unstable; urgency=low
+
+ * add listen/broadcast API
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.7
+
+ -- Youmin Ha <youmin.ha@samsung.com> Thu, 28 Oct 2010 17:15:11 +0900
+
+slp-pkgmgr (0.1.6) unstable; urgency=low
+
+ * fix PMS code, which generates argv for backend
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.6
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 27 Oct 2010 19:46:57 +0900
+
+slp-pkgmgr (0.1.5) unstable; urgency=low
+
+ * if PMS_STANDALONE env_var is set, PMS doens't stop.
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.5
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 27 Oct 2010 17:51:03 +0900
+
+slp-pkgmgr (0.1.4) unstable; urgency=low
+
+ * fix auto-activation
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.4
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 27 Oct 2010 17:41:54 +0900
+
+slp-pkgmgr (0.1.3) unstable; urgency=low
+
+ * apply new dbus service/path/interface, fix bug
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.3
+
+ -- Youmin Ha <youmin.ha@samsung.com> Tue, 26 Oct 2010 12:23:54 +0900
+
+slp-pkgmgr (0.1.2-1) unstable; urgency=low
+
+ * fix pc file
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.2-1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Sat, 23 Oct 2010 13:37:57 +0900
+
+slp-pkgmgr (0.1.2) unstable; urgency=low
+
+ * fix bug in pkgmgr-server
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.2
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 20 Oct 2010 16:38:58 +0900
+
+slp-pkgmgr (0.1.1-5) unstable; urgency=low
+
+ * install comm_config.h
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.1-5
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 18 Oct 2010 20:45:10 +0900
+
+slp-pkgmgr (0.1.1-4) unstable; urgency=low
+
+ * Fix build flags
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.1-4
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 18 Oct 2010 20:19:57 +0900
+
+slp-pkgmgr (0.1.1-3) unstable; urgency=low
+
+ * change max pkg name length
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.1-3
+
+ -- Kidong Kim <kd0228.kim@samsung.com> Mon, 18 Oct 2010 19:42:01 +0900
+
+slp-pkgmgr (0.1.1-2) unstable; urgency=low
+
+ * fix wrong version of dependent package
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.1-2
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 18 Oct 2010 19:22:14 +0900
+
+slp-pkgmgr (0.1.1-1) unstable; urgency=low
+
+ * fix build-dependency
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.1-1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 18 Oct 2010 18:07:37 +0900
+
+slp-pkgmgr (0.1.1) unstable; urgency=low
+
+ * Release first version
+ * Git: 165.213.180.234:/git/slp/pkgs/slp-pkgmgr
+ * Tag: slp-pkgmgr_0.1.1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Mon, 18 Oct 2010 18:07:37 +0900
+
+slp-pkgmgr (0.1.0) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Kidong Kim <kd0228.kim@samsung.com> Thu, 16 Sep 2010 09:31:11 +0900
--- /dev/null
+Source: slp-pkgmgr
+Priority: extra
+Maintainer: Sewook Park <sewook7.park@samsung.com>, Youmin Ha <youmin.ha@samsung.com>
+Build-Depends: debhelper (>= 5), autotools-dev, libsecurity-server-client-dev, libdbus-1-dev, libdbus-glib-1-dev, libecore-dev, dlog-dev, libaul-1-dev, libail-0-dev, libappcore-efl-dev, libxml2-dev
+Standards-Version: 3.7.2
+Section: base
+
+Package: libpkgmgr-client-dev
+Section: libdevel
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-client-0 (= ${Source-Version}), libecore-dev, libsecurity-server-client-dev, libaul-1-dev, libail-0-dev, libpkgmgr-types-dev(>= ${Source-Version}), libpkgmgr-installer-dev (>= ${Source-Version}), libpkgmgr-parser-dev (>= ${Source-Version})
+Description: Package Manager client library develpoment package
+
+Package: libpkgmgr-client-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-installer (>= ${Source-Version}), libpkgmgr-parser (>= ${Source-Version}), pkgmgr-server (>= ${Source-Version})
+Description: Packager Manager client library package
+
+Package: pkgmgr-server
+Section: base
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libpkgmgr-installer (>= ${Source-Version})
+Description: Package Manager server
+
+Package: pkgmgr-server-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, pkgmgr-server
+Description: debug package of Package Manager source package
+
+Package: libpkgmgr-installer
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Library for installer backend.
+
+Package: libpkgmgr-installer-dev
+Section: libdevel
+Architecture: any
+Depends: libpkgmgr-installer (= ${Source-Version}),
+Description: Dev package for libpkgmgr-installer
+
+Package: libpkgmgr-parser
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Parser Library for installer backend.
+
+Package: libpkgmgr-parser-dev
+Section: libdevel
+Architecture: any
+Depends: libpkgmgr-parser (= ${Source-Version}),
+Description: Dev package for libpkgmgr-parser
+
+Package: libpkgmgr-types-dev
+Section: libdevel
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Package Manager client types develpoment package
--- /dev/null
+@PREFIX@/lib/libpkgmgr-client.so*
+@PREFIX@/etc/package-manager/pkg_path.conf
+@PREFIX@/bin/pkgcmd
+@PREFIX@/bin/pkgmgr-install
+@PREFIX@/share/applications/*.desktop
+@PREFIX@/share/mime/packages/*.xml
--- /dev/null
+#!/bin/sh
+
+#if [ ${USER} == "root" ]
+#then
+# chown root:root /usr/lib/libss-client.so
+#fi
+
+mkdir -p /usr/etc/package-manager/frontend
+mkdir -p /usr/etc/package-manager/backend
+
+# For pkgmgr-install:
+# Update mime database to support package mime types
+update-mime-database /usr/share/mime
+
+echo "Done." > /dev/null
--- /dev/null
+@PREFIX@/include/package-manager.h
+@PREFIX@/lib/pkgconfig/pkgmgr.pc
--- /dev/null
+@PREFIX@/include/pkgmgr/pkgmgr_installer.h
+@PREFIX@/lib/pkgconfig/pkgmgr-installer-client.pc
+@PREFIX@/lib/pkgconfig/pkgmgr-installer-status-broadcast-server.pc
+@PREFIX@/lib/pkgconfig/pkgmgr-installer.pc
--- /dev/null
+@PREFIX@/lib/libpkgmgr_installer_client.so*
+@PREFIX@/lib/libpkgmgr_installer_status_broadcast_server.so*
+@PREFIX@/lib/libpkgmgr_installer.so*
--- /dev/null
+@PREFIX@/include/package-manager-types.h
+@PREFIX@/include/package-manager-plugin.h
+@PREFIX@/lib/pkgconfig/pkgmgr-types.pc
--- /dev/null
+@PREFIX@/bin/pkgmgr-server
+@PREFIX@/share/dbus-1/services/com.samsung.slp.pkgmgr.service
+@PREFIX@/share/locale/*
--- /dev/null
+#!/bin/sh
+
+#if [ ${USER} == "root" ]
+#then
+# chown root:root /usr/bin/ss-server
+# chown root:root /etc/rc.d/init.d/ss-serverd
+#fi
+
+#chmod 700 /usr/bin/ss-server
+#chmod 755 /etc/rc.d/init.d/ss-serverd
+mkdir -p /usr/etc/package-manager/server
+
+echo "Done." > /dev/null
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+BUILDDIR = $(CURDIR)/cmake_tmp
+
+CFLAGS ?= -Wall -g
+CXXFLAGS ?= -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+ CXXFLAGS += -O0
+else
+ CFLAGS += -O2
+ CXXFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ mkdir -p $(BUILDDIR)
+ cd $(BUILDDIR) && CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+# Add here commands to compile the package.
+ cd $(BUILDDIR) && $(MAKE)
+
+ #docbook-to-man debian/wavplayer.sgml > wavplayer.1
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+ rm -rf CMakeCache.txt
+ rm -rf CMakeFiles
+ rm -rf cmake_install.cmake
+ rm -rf Makefile
+ rm -rf install_manifest.txt
+ rm -rf *.so
+ rm -rf *.pc
+
+ rm -rf $(BUILDDIR)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ cd $(BUILDDIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+# mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
+# ln -s ../init.d/ss-serverd $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S40ss-server
+
+
+# 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_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+# dh_strip
+ dh_strip --dbg-package=pkgmgr-server-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+/**
+
+ *
+ * @ingroup SLP_PG
+ * @defgroup PackageManagerClient
+
+
+@par package manager Programming Guide
+
+<h1 class="pg"> Introduction</h1>
+<h2 class="pg"> Purpose of this document</h2>
+The purpose of this document is to describe how applications can usepackage manager APIs.\n
+This document gives only programming guidelines to application engineers.
+
+<h2 class="pg"> Scope</h2>
+The scope of this document is limited to Samsung platform package manager API usage.
+
+<h1 class="pg"> Architecture</h1>
+<h2 class="pg"> Architecture overview</h2>
+package manager is responsible for installing / uninstalling / activating application. It also support getting application list API \n
+
+Dbus is used for communication between frontend and package-server / package-server and client library..\n
+Each type of packages have been implemented and these are used for each type of operation.
+
+@image html high-level.png "High-Level Architure"
+
+<h2 class="pg"> SLP Features</h2>
+package manager has the following features:\n
+
+ - Install /Uninstall /Activate Application (Primitive APIs)
+ - It can install/uninstall an application
+ - It can activate/deactivate application.
+
+ - Application List
+ - It provides the list of applications that are installed.
+ - It provides the API to free the list.
+
+ - Listen / Broadcast status
+ - It can listen the status broadcasted by other application.
+ - It can broadcast the status to other application.
+
+<h1 class="pg"> package manager API descriptions</h1>
+<b> SEE API manual </b>
+
+<h1 class="pg"> package manager features with sample code</h1>
+<h2 class="pg"> Install /Uninstall /Activate an application</h2>
+
+Client application
+- Install request with return callback function
+
+@code
+// the package path is "/opt/usr/apps/com.samsung.hello.deb"
+#include <package-manager.h>
+
+int static return_cb(pkg_request_id req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data)
+{
+ pkgmgr_client *pc = (pkgmgr_client *)data;
+
+ if( strcmp(key, "end") == 0) {
+ pkgmgr_client_free(pc);
+ exit(0);
+ }
+}
+
+void install_func()
+{
+ int result = 0;
+ pkgmgr_client *pc = NULL;
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if(pc == NULL) {
+ printf("pc is NULL\n");
+ return -1;
+ }
+
+ result = pkgmgr_client_install(pc, NULL, des, "/opt/usr/apps/com.samsung.hello.deb", NULL, PM_DEFAULT, return_cb, pc);
+ if(result < 0) {
+ fprintf(stderr, "Install failed! %d\n", result);
+ return -1;
+ }
+
+}
+@endcode
+
+
+- Uninstall request with return callback function
+
+@code
+// the package type is "deb", package name is "com.samsung.hello"
+#include <package-manager.h>
+
+int static return_cb(pkg_request_id req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data)
+{
+ pkgmgr_client *pc = (pkgmgr_client *)data;
+
+ if( strcmp(key, "end") == 0) {
+ pkgmgr_client_free(pc);
+ exit(0);
+ }
+}
+
+void uninstall_func()
+{
+ int result = 0;
+ pkgmgr_client *pc = NULL;
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if(pc == NULL) {
+ printf("pc is NULL\n");
+ return -1;
+ }
+
+ result = pkgmgr_client_uninstall(pc, "deb", des, "com.samsung.hello", PM_DEFAULT, return_cb, pc);
+ if(result < 0) {
+ fprintf(stderr, "Uninstall failed! %d\n", result);
+ return -1;
+ }
+
+}
+@endcode
+
+
+- Activate request with return callback function
+
+@code
+// the package type is "deb", package name is "com.samsung.hello"
+#include <package-manager.h>
+
+
+void activate_func()
+{
+ int result = 0;
+ pkgmgr_client *pc = NULL;
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if(pc == NULL) {
+ printf("pc is NULL\n");
+ return -1;
+ }
+
+ result = pkgmgr_client_activate(pc, "deb", "com.samsung.hello");
+ if(result < 0) {
+ fprintf(stderr, "Activation failed! %d\n", result);
+ return -1;
+ }
+
+ pkgmgr_client_free(pc);
+
+}
+@endcode
+
+
+
+<h2 class="pg"> Get Installed Application List </h2>
+
+- Get/free application list
+- This package manager function is used to get the list of all installed applications which can be removed.
+
+@code
+#include <package-manager.h>
+
+static int __iter_fn(const char* pkg_type, const char* pkg_name, const char* version, void *data)
+{
+ printf("pkg_type %s, pkg_name %s, version %s\n", pkg_type, pkg_name, version);
+
+ return 0;
+}
+
+void getlist_func()
+{
+ pkgmgr_get_pkg_list(__iter_fn, NULL);
+}
+@endcode
+
+
+
+<h2 class="pg"> Listen and broadcast the status </h2>
+
+- Listen / broadcast the status
+- This package manager function is used to listen the status broadcasted by other application.
+
+@code
+#include <package-manager.h>
+
+int static return_cb(pkg_request_id req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data)
+{
+ pkgmgr_client *pc = (pkgmgr_client *)data;
+
+ if( strcmp(key, "end") == 0) {
+ pkgmgr_client_free(pc);
+ exit(0);
+ }
+}
+
+void listen_func()
+{
+ int result = 0;
+ pkgmgr_client *pc = NULL;
+
+ pc = pkgmgr_client_new(PC_LISTENING);
+ if(pc == NULL) {
+ printf("pc is NULL\n");
+ return -1;
+ }
+
+ result = pkgmgr_client_listen_status(pc, return_cb, pc);
+ if(result < 0)
+ {
+ fprintf(stderr, "status listen failed!\n");
+ return -1;
+ }
+}
+@endcode
+
+
+- This package manager function is used to listen the status broadcasted by other application.
+
+@code
+// the package type is "deb", package name is "com.samsung.hello", key is "key_string", val is "val_string"
+#include <package-manager.h>
+
+void broadcast_func()
+{
+ int result = 0;
+ pkgmgr_client *pc = NULL;
+
+ pc= pkgmgr_client_new(PC_BROADCAST);
+ if(pc == NULL) {
+ printf("pc is NULL\n");
+ return -1;
+ }
+
+ int result = pkgmgr_client_broadcast_status(pc, "deb", "com.samsung.hello", "key_string", "val_string");
+ if(result < 0) {
+ fprintf(stderr, "status broadcast failed!\n");
+ return -1;
+ }
+
+ pkgmgr_client_free(pc);
+}
+@endcode
+
+
+*/
+
+/**
+@}
+*/
+
+
--- /dev/null
+../types/include/package-manager-plugin.h
\ No newline at end of file
--- /dev/null
+../types/include/package-manager-types.h
\ No newline at end of file
--- /dev/null
+../client/include/package-manager.h
\ No newline at end of file
--- /dev/null
+../client/include/pkgmgr-dbinfo.h
\ No newline at end of file
--- /dev/null
+add_subdirectory(sample)
--- /dev/null
+include(FindPkgConfig)
+pkg_check_modules(parser_pkgs REQUIRED dlog libxml-2.0)
+
+foreach(flag ${parser_pkgs_CFLAGS})
+ set(parser_pkgs_CFLAGS_str "${parser_pkgs_CFLAGS_str} ${flag}")
+endforeach()
+
+add_executable(pkgmgr_backend_sample
+ sample_backend.c)
+target_link_libraries(pkgmgr_backend_sample pkgmgr_installer)
+
+add_library(pkgmgr_backend_lib_sample SHARED
+ sample_backendlib.c)
+
+add_library(pkgmgr_parser_lib_sample SHARED
+ sample_parserlib.c)
+set_target_properties(pkgmgr_parser_lib_sample PROPERTIES COMPILE_FLAGS "${parser_pkgs_CFLAGS_str}")
+target_link_libraries(pkgmgr_parser_lib_sample ${parser_pkgs_LDFLAGS})
+
+install(TARGETS pkgmgr_backend_sample
+ DESTINATION bin
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
+
+install(TARGETS pkgmgr_backend_lib_sample
+ DESTINATION lib
+ COMPONENT RuntimeLibraries
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
+
+install(TARGETS pkgmgr_parser_lib_sample
+ DESTINATION lib
+ COMPONENT RuntimeLibraries
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+/* sample_backend.c
+ * test package
+ */
+
+
+/* Pkgmgr installer headers */
+#include "pkgmgr_installer.h"
+
+/* GUI headers */
+
+/* glibc headers */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+static int __confirm_ui(void *data, char *msg);
+static int __install_package(const char *pkg_file_path);
+static int __uninstall_package(const char *pkgid);
+static int __recover_package_system(void);
+
+static pkgmgr_installer *_pi;
+
+static int __confirm_ui(void *data, char *msg)
+{
+ /* Show confirm ui */
+
+ return 1;
+}
+
+static int __install_package(const char *pkg_file_path)
+{
+ if (__confirm_ui(NULL, "Install?")) {
+ /* Install package, and send signal */
+
+ }
+
+ int ret = 0;
+ ret = pkgmgr_installer_send_signal(_pi, "sample", "abc", "end", "ok");
+
+ return ret;
+}
+
+static int __uninstall_package(const char *pkgid)
+{
+ return 0;
+}
+
+static int __clear_package(const char *pkgid)
+{
+ return 0;
+}
+
+static int __recover_package_system(void)
+{
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int ret = 0;
+ pkgmgr_installer *pi = pkgmgr_installer_new();
+
+ _pi = pi;
+
+ pkgmgr_installer_receive_request(pi, argc, argv);
+
+ int req_type = pkgmgr_installer_get_request_type(pi);
+ if (PKGMGR_REQ_INVALID >= req_type)
+ return EINVAL;
+
+ const char *pkg_info = pkgmgr_installer_get_request_info(pi);
+
+ switch (req_type) {
+ case PKGMGR_REQ_INSTALL:
+ ret = __install_package(pkg_info);
+ break;
+ case PKGMGR_REQ_UNINSTALL:
+ ret = __uninstall_package(pkg_info);
+ break;
+ case PKGMGR_REQ_CLEAR:
+ ret = __clear_package(pkg_info);
+ break;
+ case PKGMGR_REQ_RECOVER:
+ ret = __recover_package_system();
+ break;
+ default:
+ ret = EINVAL;
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+/* sample_backendlib.c
+ * test package
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "package-manager-plugin.h"
+
+static void pkg_native_plugin_on_unload(void);
+static int pkg_plugin_app_is_installed(const char *pkgid);
+static int pkg_plugin_get_installed_apps_list(const char *category,
+ const char *option,
+ package_manager_pkg_info_t **
+ list, int *count);
+static int pkg_plugin_get_app_detail_info(const char *pkgid,
+ package_manager_pkg_detail_info_t *
+ pkg_detail_info);
+static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path,
+ package_manager_pkg_detail_info_t
+ *pkg_detail_info);
+
+static void pkg_native_plugin_on_unload(void)
+{
+ printf("pkg_native_plugin_unload() is called\n");
+}
+
+static int pkg_plugin_app_is_installed(const char *pkgid)
+{
+ printf("pkg_plugin_app_is_installed() is called\n");
+
+ return 0;
+}
+
+static int pkg_plugin_get_installed_apps_list(const char *category,
+ const char *option,
+ package_manager_pkg_info_t **
+ list, int *count)
+{
+ printf("pkg_plugin_get_installed_apps_list() is called\n");
+
+ return 0;
+}
+
+static int pkg_plugin_get_app_detail_info(const char *pkgid,
+ package_manager_pkg_detail_info_t *
+ pkg_detail_info)
+{
+ printf("pkg_plugin_get_app_detail_info() is called\n");
+
+ return 0;
+}
+
+static int pkg_plugin_get_app_detail_info_from_package(const char *pkg_path,
+ package_manager_pkg_detail_info_t
+ *pkg_detail_info)
+{
+ printf("pkg_plugin_get_app_detail_info_from_package() is called\n");
+
+ return 0;
+}
+
+__attribute__ ((visibility("default")))
+int pkg_plugin_on_load(pkg_plugin_set *set)
+{
+ if (set == NULL) {
+ return -1;
+ }
+
+ memset(set, 0x00, sizeof(pkg_plugin_set));
+
+ set->plugin_on_unload = pkg_native_plugin_on_unload;
+ set->pkg_is_installed = pkg_plugin_app_is_installed;
+ set->get_installed_pkg_list = pkg_plugin_get_installed_apps_list;
+ set->get_pkg_detail_info = pkg_plugin_get_app_detail_info;
+ set->get_pkg_detail_info_from_package =
+ pkg_plugin_get_app_detail_info_from_package;
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+/* sample_parserlib.c
+ * test package
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <libxml/xmlreader.h>
+
+/* debug output */
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "PKGMGR_PARSER"
+
+#define DBGE(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
+#define DBGI(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
+
+
+static void
+print_element_names(xmlNode * a_node)
+{
+ xmlNode *cur_node = NULL;
+
+ for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
+ if (cur_node->type == XML_ELEMENT_NODE) {
+ DBGI("node type: Element, name: %s\n", cur_node->name);
+ }
+
+ print_element_names(cur_node->children);
+ }
+}
+
+
+__attribute__ ((visibility("default")))
+int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr)
+{
+ xmlNode *root_element = NULL;
+
+ xmlTextReaderPtr reader = xmlReaderWalker(docPtr);
+ if(reader != NULL) {
+ int ret = xmlTextReaderRead(reader);
+ while(ret == 1) {
+ ret = xmlTextReaderRead(reader);
+ }
+ xmlFreeTextReader(reader);
+
+ if(ret != 0) {
+ DBGE("failed to parse");
+ }
+ }
+
+ /*Get the root element node */
+ root_element = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
+
+ print_element_names(root_element);
+
+ return 0;
+}
+
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-client"/>
+ <provide>
+ <label name="pkgmgr-client::db"/>
+ </provide>
+ <permit>
+ <smack permit="pkgmgr" type="rwx"/>
+ </permit>
+ </define>
+ <request>
+ <domain name="pkgmgr-client"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/lib/libpkgmgr-client.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr-client.so.0.1.68" label="_"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-installer"/>
+ </define>
+ <request>
+ <domain name="pkgmgr-installer"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/lib/libpkgmgr_installer.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer.so.0.1.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_client.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_client.so.0.1.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_status_broadcast_server.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_installer_status_broadcast_server.so.0.1.0" label="_"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr"/>
+ <provide>
+ <label name="pkgmgr::svc"/>
+ <label name="pkgmgr::info"/>
+ </provide>
+ <request>
+ <smack request="pkgmgr::svc" type="rwx"/>
+ <smack request="pkgmgr::info" type="rwx"/>
+ <smack request="dbus" type="rwx"/>
+ <smack request="system::homedir" type="rwxat"/>
+ <smack request="system::media" type="rwxat"/>
+ <smack request="ail::db" type="rwx"/>
+ <smack request="system::vconf" type="rwxat"/>
+ <smack request="system::vconf_inhouse" type="rwxat"/>
+ <smack request="pkgmgr::db" type="rwx"/>
+ </request>
+ </define>
+ <request>
+ <domain name="pkgmgr"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/pkg_smack" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkg_fota" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkg_initdb" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkgcmd" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkginfo" exec_label="pkgmgr"/>
+ <filesystem path="/usr/lib/libpkgmgr_parser_lib_sample.so" label="_"/>
+ <filesystem path="/usr/share/dbus-1/services/com.samsung.slp.pkgmgr.service" label="_" exec_label="none"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-parser"/>
+ </define>
+ <request>
+ <domain name="pkgmgr-parser"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/lib/libpkgmgr_parser.so.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_parser.so.0.1.0" label="_"/>
+ <filesystem path="/usr/lib/libpkgmgr_parser_lib_sample.so" label="_"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-server"/>
+ <request>
+ <smack request="system::homedir" type="rwxat"/>
+ </request>
+ </define>
+ <request>
+ <domain name="pkgmgr-server"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/pkgmgr-server" exec_label="pkgmgr-server"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr-server"/>
+ <request>
+ <smack request="system::homedir" type="rwxat"/>
+ <smack request="security-server::api-cookie-check" type="w"/>
+ <smack request="system::use_internet" type="w"/>
+ </request>
+ <permit>
+ <smack permit="system::use_internet" type="w"/>
+ </permit>
+ </define>
+ <request>
+ <domain name="pkgmgr-server"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/pkgmgr-server" exec_label="pkgmgr-server"/>
+ </assign>
+</manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="pkgmgr"/>
+ <provide>
+ <label name="pkgmgr::svc"/>
+ <label name="pkgmgr::info"/>
+ </provide>
+ <request>
+ <smack request="pkgmgr::svc" type="rwx"/>
+ <smack request="pkgmgr::info" type="rwx"/>
+ <smack request="dbus" type="rwx"/>
+ <smack request="system::homedir" type="rwxat"/>
+ <smack request="system::media" type="rwxat"/>
+ <smack request="ail::db" type="rwx"/>
+ <smack request="system::vconf" type="rwxat"/>
+ <smack request="system::vconf_inhouse" type="rwxat"/>
+ <smack request="pkgmgr::db" type="rwx"/>
+ <smack request="device::sys_logging" type="w"/>
+ <smack request="device::app_logging" type="w"/>
+ <smack request="sdbd" type="r"/>
+ </request>
+ </define>
+ <request>
+ <domain name="pkgmgr"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/pkg_fota" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkg_initdb" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkgcmd" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkginfo" exec_label="pkgmgr"/>
+ <filesystem path="/usr/bin/pkg_getsize" exec_label="pkgmgr"/>
+ <filesystem path="/usr/lib/libpkgmgr_parser_lib_sample.so" label="_"/>
+ <filesystem path="/usr/share/dbus-1/services/com.samsung.slp.pkgmgr.service" label="_" exec_label="none"/>
+ </assign>
+</manifest>
--- /dev/null
+#sbs-git:slp/pkgs/s/slp-pkgmgr pkgmgr 0.1.103 29b53909a5d6e8728429f0a188177eac691cb6ce
+Name: pkgmgr
+Summary: Packager Manager client library package
+Version: 0.2.166
+Release: 1
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+Source1: pkgmgr_recovery-wearable.service
+Source2: pkgmgr_recovery-mobile.service
+Source101: pkgmgr-wearable.manifest
+Source102: pkgmgr-mobile.manifest
+Source103: pkgmgr-server-wearable.manifest
+Source104: pkgmgr-server-mobile.manifest
+Source105: pkgmgr-client.manifest
+Source106: pkgmgr-installer.manifest
+
+BuildRequires: cmake
+BuildRequires: unzip
+BuildRequires: gettext-tools
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(security-server)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-unix-2.0)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(ail)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(iniparser)
+BuildRequires: pkgmgr-info-parser-devel
+BuildRequires: pkgmgr-info-parser
+BuildRequires: python-xml
+
+
+%description
+Packager Manager client library package for packaging
+
+Requires(post): ail
+Requires(post): pkgmgr-info
+
+%package client
+Summary: Package Manager client library develpoment package
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+Requires: shared-mime-info
+Requires(post): pkgmgr
+
+%description client
+Package Manager client library develpoment package for packaging
+
+%package client-devel
+Summary: Package Manager client library develpoment package
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description client-devel
+Package Manager client library develpoment package for packaging
+
+%package server
+Summary: Package Manager server
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description server
+Package Manager server for packaging
+
+%package installer
+Summary: Library for installer frontend/backend.
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description installer
+Library for installer frontend/backend for packaging.
+
+%package installer-devel
+Summary: Dev package for libpkgmgr-installer
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description installer-devel
+Dev package for libpkgmgr-installer for packaging.
+
+
+%package types-devel
+Summary: Package Manager manifest parser develpoment package
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description types-devel
+Package Manager client types develpoment package for packaging
+
+
+%prep
+%setup -q
+%if 0%{?tizen_profile_wearable}
+ cp %{SOURCE101} ./pkgmgr.manifest
+ cp %{SOURCE103} ./pkgmgr-server.manifest
+%else if 0%{?tizen_profile_mobile}
+ cp %{SOURCE102} ./pkgmgr.manifest
+ cp %{SOURCE104} ./pkgmgr-server.manifest
+%endif
+cp %{SOURCE105} %{SOURCE106} .
+
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS ?DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+
+%if 0%{?tizen_profile_wearable}
+cmake . -DDEVICE_PROFILE=wearable -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%else if 0%{?tizen_profile_mobile}
+cmake . -DDEVICE_PROFILE=mobile -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%else
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%endif
+
+
+%build
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
+cp LICENSE %{buildroot}/usr/share/license/%{name}-client
+cp LICENSE %{buildroot}/usr/share/license/%{name}-installer
+cp LICENSE %{buildroot}/usr/share/license/%{name}-server
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+%if 0%{?tizen_profile_wearable}
+install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/pkgmgr_recovery.service
+ln -s ../pkgmgr_recovery.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/pkgmgr_recovery.service
+%else if 0%{?tizen_profile_mobile}
+install -m 0644 %SOURCE2 %{buildroot}%{_libdir}/systemd/system/pkgmgr_recovery.service
+ln -s ../pkgmgr_recovery.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/pkgmgr_recovery.service
+%endif
+
+%post
+/sbin/ldconfig
+
+mkdir -p /usr/etc/package-manager/backend
+mkdir -p /usr/etc/package-manager/backendlib
+mkdir -p /etc/opt/upgrade
+
+vconftool set -t int memory/pkgmgr/status "0" -f -s system::vconf_inhouse
+
+# For pkgmgr-install:
+# Update mime database to support package mime types
+update-mime-database /usr/share/mime
+
+%posttrans
+#init DB
+mkdir -p /usr/share/packages
+mkdir -p /opt/share/packages
+mkdir -p /opt/share/packages/.recovery/pkgmgr
+mkdir -p /opt/share/packages/.recovery/tpk
+mkdir -p /opt/share/packages/.recovery/wgt
+mkdir -p /opt/share/packages/.recovery/fota
+
+mkdir -p /usr/share/applications
+mkdir -p /opt/share/applications
+mkdir -p /opt/dbspace/
+
+pkg_initdb
+
+chsmack -a 'pkgmgr::db' /opt/dbspace/.pkgmgr_parser.db*
+chsmack -a 'pkgmgr::db' /opt/dbspace/.pkgmgr_cert.db*
+chsmack -a 'ail::db' /opt/dbspace/.app_info.db*
+chsmack -a '_' /usr/etc/package-manager/pkg_path.conf
+
+rm -rf /opt/usr/apps/tmp/pkgmgr_tmp.txt
+
+%post server
+
+/sbin/ldconfig
+mkdir -p /usr/etc/package-manager/server
+
+%post client -p /sbin/ldconfig
+
+%postun client -p /sbin/ldconfig
+
+%post installer -p /sbin/ldconfig
+
+%postun installer -p /sbin/ldconfig
+
+%files
+%manifest pkgmgr.manifest
+%defattr(-,root,root,-)
+%{_bindir}/pkgcmd
+%{_bindir}/pkg_initdb
+%{_bindir}/pkg_fota
+%{_bindir}/pkg_getsize
+%{_bindir}/pkginfo
+%{_bindir}/pkgmgr-install
+%{_datadir}/packages/com.samsung.pkgmgr-install.xml
+%{_datadir}/mime/packages/mime.wac.xml
+%{_datadir}/mime/packages/mime.tpk.xml
+%{_libdir}/libpkgmgr_parser_lib_sample.so
+%exclude %{_bindir}/pkgmgr_backend_sample
+%exclude %{_includedir}/pkgmgr/comm_client.h
+%exclude %{_includedir}/pkgmgr/comm_config.h
+%exclude %{_includedir}/pkgmgr/comm_status_broadcast_server.h
+%exclude %{_libdir}/libpkgmgr_backend_lib_sample.so
+%exclude /usr/etc/package-manager/server/queue_status
+%attr(0700,root,root) /etc/opt/upgrade/710.pkgmgr.patch.sh
+%attr(0700,root,root) /usr/etc/package-manager/pkg_recovery.sh
+%{_libdir}/systemd/system/multi-user.target.wants/pkgmgr_recovery.service
+%{_libdir}/systemd/system/pkgmgr_recovery.service
+/usr/share/license/%{name}
+
+%files client
+%manifest pkgmgr-client.manifest
+%defattr(-,root,root,-)
+%{_prefix}/etc/package-manager/pkg_path.conf
+%{_libdir}/libpkgmgr-client.so.*
+/usr/share/license/%{name}-client
+
+%files client-devel
+%defattr(-,root,root,-)
+%{_includedir}/package-manager.h
+%{_includedir}/pkgmgr-dbinfo.h
+%{_libdir}/pkgconfig/pkgmgr.pc
+%{_libdir}/libpkgmgr-client.so
+
+%files server
+%manifest pkgmgr-server.manifest
+%defattr(-,root,root,-)
+%{_datadir}/dbus-1/services/com.samsung.slp.pkgmgr.service
+%{_libdir}/systemd/system/slp-pkgmgr.service
+%{_bindir}/pkgmgr-server
+%{_datadir}/locale/*/LC_MESSAGES/*.mo
+/usr/share/license/%{name}-server
+
+%files installer
+%manifest pkgmgr-installer.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libpkgmgr_installer.so.*
+%{_libdir}/libpkgmgr_installer_status_broadcast_server.so.*
+%{_libdir}/libpkgmgr_installer_client.so.*
+/usr/share/license/%{name}-installer
+
+%files installer-devel
+%defattr(-,root,root,-)
+%{_includedir}/pkgmgr/pkgmgr_installer.h
+%{_libdir}/pkgconfig/pkgmgr-installer-status-broadcast-server.pc
+%{_libdir}/pkgconfig/pkgmgr-installer.pc
+%{_libdir}/pkgconfig/pkgmgr-installer-client.pc
+%{_libdir}/libpkgmgr_installer.so
+%{_libdir}/libpkgmgr_installer_client.so
+%{_libdir}/libpkgmgr_installer_status_broadcast_server.so
+
+
+%files types-devel
+%defattr(-,root,root,-)
+%{_includedir}/package-manager-types.h
+%{_includedir}/package-manager-plugin.h
+%{_libdir}/pkgconfig/pkgmgr-types.pc
--- /dev/null
+[Unit]
+Description=pkgmgr recovery
+Before=launchpad-preload.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/etc/package-manager/pkg_recovery.sh
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+# usage
+# backend:directory_path
+# backendlib:directory_path
+
+backend:/usr/etc/package-manager/backend/
+backendlib:/usr/etc/package-manager/backendlib/
--- /dev/null
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: package manager
+Description: SLP Package Manager Package
+Version: @VERSION@
+Requires: security-server dlog pkgmgr-types pkgmgr-installer-client pkgmgr-installer-status-broadcast-server
+Libs: -L${libdir} -L${libdir}/pkgmgr -lpkgmgr-client
+Cflags: -I${includedir}
--- /dev/null
+# for i18n
+
+SET(POFILES en_US.po en_GB.po ja_JP.po ko_KR.po zh_CN.po)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+ SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+ MESSAGE("PO: ${pofile}")
+ GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+ GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+ SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${moFile}
+ COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+ DEPENDS ${absPofile}
+ )
+ INSTALL(FILES ${moFile}
+ DESTINATION share/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+ SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
--- /dev/null
+# List of source files containing translatable strings.
+server/src/pkgmgr-server.c
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-10-14 19:06+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: server/src/pkgmgr-server.c:251
+#, c-format
+msgid "Install?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:287
+#, c-format
+msgid "Uninstall?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:290
+#, c-format
+msgid "Invalid request"
+msgstr ""
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-10-14 19:06+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: server/src/pkgmgr-server.c:251
+#, c-format
+msgid "Install?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:287
+#, c-format
+msgid "Uninstall?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:290
+#, c-format
+msgid "Invalid request"
+msgstr ""
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-10-14 19:06+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: server/src/pkgmgr-server.c:251
+#, c-format
+msgid "Install?"
+msgstr "インストールしますか?"
+
+#: server/src/pkgmgr-server.c:287
+#, c-format
+msgid "Uninstall?"
+msgstr "アンインストールしますか?"
+
+#: server/src/pkgmgr-server.c:290
+#, c-format
+msgid "Invalid request"
+msgstr "無効なリクエストです"
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-10-14 19:06+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: server/src/pkgmgr-server.c:251
+#, c-format
+msgid "Install?"
+msgstr "설치할까요?"
+
+#: server/src/pkgmgr-server.c:287
+#, c-format
+msgid "Uninstall?"
+msgstr "삭제할까요?"
+
+#: server/src/pkgmgr-server.c:290
+#, c-format
+msgid "Invalid request"
+msgstr "요청이 바르지 않습니다"
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-10-14 19:06+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: server/src/pkgmgr-server.c:251
+#, c-format
+msgid "Install?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:287
+#, c-format
+msgid "Uninstall?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:290
+#, c-format
+msgid "Invalid request"
+msgstr ""
--- /dev/null
+#!/bin/sh
+
+PACKAGE=package-manager
+SRCROOT=..
+POTFILES=POTFILES.in
+
+#ALL_LINGUAS= am az be ca cs da de el en_CA en_GB es et fi fr hr hu it ja ko lv mk ml ms nb ne nl pa pl pt pt_BR ru rw sk sl sr sr@Latn sv ta tr uk vi zh_CN zh_TW
+ALL_LINGUAS="en_US en_GB ja_JP ko_KR zh_CN"
+
+XGETTEXT=/usr/bin/xgettext
+MSGMERGE=/usr/bin/msgmerge
+
+echo -n "Make ${PACKAGE}.pot "
+if [ ! -e $POTFILES ] ; then
+ echo "$POTFILES not found"
+ exit 1
+fi
+
+$XGETTEXT --default-domain=${PACKAGE} --directory=${SRCROOT} \
+ --add-comments --keyword=_ --keyword=N_ --files-from=$POTFILES
+if [ $? -ne 0 ]; then
+ echo "xgettext error"
+ exit 1
+fi
+
+if [ ! -f ${PACKAGE}.po ]; then
+ echo "No such file: ${PACKAGE}.po"
+ exit 1
+fi
+
+rm -f ${PACKAGE}.pot && mv ${PACKAGE}.po ${PACKAGE}.pot
+echo "done"
+
+for LANG in $ALL_LINGUAS; do
+ echo "$LANG : "
+
+ if [ ! -e $LANG.po ] ; then
+ sed 's/CHARSET/UTF-8/g' ${PACKAGE}.pot > ${LANG}.po
+ echo "${LANG}.po created"
+ else
+ if $MSGMERGE ${LANG}.po ${PACKAGE}.pot -o ${LANG}.new.po ; then
+ if cmp ${LANG}.po ${LANG}.new.po > /dev/null 2>&1; then
+ rm -f ${LANG}.new.po
+ else
+ if mv -f ${LANG}.new.po ${LANG}.po; then
+ echo ""
+ else
+ echo "msgmerge for $LANG.po failed: cannot move $LANG.new.po to $LANG.po" 1>&2
+ rm -f ${LANG}.new.po
+ exit 1
+ fi
+ fi
+ else
+ echo "msgmerge for $LANG failed!"
+ rm -f ${LANG}.new.po
+ fi
+ fi
+ echo ""
+done
+
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-10-14 19:06+0900\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: server/src/pkgmgr-server.c:251
+#, c-format
+msgid "Install?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:287
+#, c-format
+msgid "Uninstall?"
+msgstr ""
+
+#: server/src/pkgmgr-server.c:290
+#, c-format
+msgid "Invalid request"
+msgstr ""
--- /dev/null
+This file is for creating required directory.
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef _PKGMGR_SERVER_H_
+#define _PKGMGR_SERVER_H_
+
+#define CONF_FILE "/usr/etc/package-manager/server/.config"
+#define DESKTOP_FILE_DIRS "/usr/share/install-info/desktop.conf"
+
+#define PKG_BACKEND "backend:"
+#define PKG_CONF_PATH "/usr/etc/package-manager/pkg_path.conf"
+
+#define MAX_REQ_ID_LEN 256
+#define MAX_PKG_TYPE_LEN 128
+#define MAX_PKG_NAME_LEN 256
+#define MAX_PKG_ARGS_LEN 4096
+#define MAX_COOKIE_LEN 32
+#define DESKTOP_FILE_DIRS_NUM 1024
+
+typedef struct {
+ char req_id[MAX_REQ_ID_LEN];
+ int req_type;
+ char pkg_type[MAX_PKG_TYPE_LEN];
+ char pkgid[MAX_PKG_NAME_LEN];
+ char args[MAX_PKG_ARGS_LEN];
+ char cookie[MAX_COOKIE_LEN];
+} pm_dbus_msg;
+
+typedef struct backend_info_t {
+ int pid;
+ char pkgtype[MAX_PKG_TYPE_LEN];
+ char pkgid[MAX_PKG_NAME_LEN];
+ char args[MAX_PKG_ARGS_LEN];
+}backend_info;
+
+struct pm_inotify_paths_t {
+ int wd;
+ char *path;
+};
+typedef struct pm_inotify_paths_t pm_inotify_paths;
+
+char *_get_backend_cmd(char *type);
+void _pm_desktop_file_monitor_init();
+void _pm_desktop_file_monitor_fini();
+int _pm_desktop_file_dir_search(pm_inotify_paths *paths, int number);
+
+#endif /* _PKGMGR_SERVER_H_ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#ifndef _PM_QUEUE_H_
+#define _PM_QUEUE_H_
+
+#include "pkgmgr-server.h"
+
+#define STATUS_FILE "/usr/etc/package-manager/server/queue_status"
+/* #define STATUS_FILE "./queue_status" */
+
+typedef struct _pm_queue_data {
+ pm_dbus_msg *msg;
+ struct _pm_queue_data *next;
+} pm_queue_data;
+
+typedef struct queue_info_map_t {
+ char pkgtype[MAX_PKG_TYPE_LEN];
+ char backend[MAX_PKG_NAME_LEN];
+ int queue_slot;
+ pm_queue_data *head;
+} queue_info_map;
+
+#define MAX_QUEUE_NUM 128
+
+int _pm_queue_init();
+int _pm_queue_push(pm_dbus_msg *item);
+/*position specifies the queue from which to pop request*/
+pm_dbus_msg *_pm_queue_pop(int position);
+void _pm_queue_final();
+void _pm_queue_delete(pm_dbus_msg *item);
+pm_queue_data *_add_node();
+void _save_queue_status(pm_dbus_msg *item, char *status);
+void _print_queue(int position);
+
+#endif /* _PM_QUEUE_H_ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/inotify.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <glib.h>
+#include <signal.h>
+#include <Elementary.h>
+#include <appcore-efl.h>
+#include <Ecore_X.h>
+#include <Ecore_File.h>
+#include <ail.h>
+#include <pkgmgr-info.h>
+#include <pkgmgr_parser.h>
+
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <security-server.h>
+
+#include <vconf.h>
+
+#include "pkgmgr_installer.h"
+#include "comm_pkg_mgr_server.h"
+#include "pkgmgr-server.h"
+#include "pm-queue.h"
+#include "comm_config.h"
+#include <dbus/dbus.h>
+
+/* debug output */
+#if defined(NDEBUG)
+#define DBG(fmt, args...)
+#define __SET_DBG_OUTPUT(fp)
+#elif defined(PRINT)
+#include <stdio.h>
+FILE *___log = NULL;
+#define DBG(fmt, args...) \
+ {if (!___log) ___log = stderr; \
+ fprintf(___log, "[DBG:PMS]%s:%d:%s(): " fmt "\n",\
+ basename(__FILE__), __LINE__, __func__, ##args); fflush(___log); }
+#define __SET_DBG_OUTPUT(fp) \
+ (___log = fp)
+#else
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "PKGMGR_SERVER"
+
+#define DBGE(fmt, arg...) LOGE(fmt,##arg)
+#define DBG(fmt, arg...) LOGD(fmt,##arg)
+#endif
+
+#if !defined(PACKAGE)
+#define PACKAGE "package-manager"
+#endif
+
+#if !defined(LOCALEDIR)
+#define LOCALEDIR "/usr/share/locale"
+#endif
+
+#define PACKAGE_RECOVERY_DIR "/opt/share/packages/.recovery/pkgmgr"
+
+#define DESKTOP_W 720.0
+
+#define NO_MATCHING_FILE 11
+
+static int backend_flag = 0; /* 0 means that backend process is not running */
+static int drawing_popup = 0; /* 0 means that pkgmgr-server has no popup now */
+
+/* For pkgs with no desktop file, inotify callback wont be called.
+* To handle that case ail_db_update is initialized as 1
+* This flag will be used to ensure that pkgmgr server does not exit
+* before the db is updated. */
+int ail_db_update = 1;
+
+/*
+8 bit value to represent maximum 8 backends.
+Each bit position corresponds to a queue slot which
+is dynamically determined.
+*/
+char backend_busy = 0;
+/*
+8 bit value to represent quiet mode operation for maximum 8 backends
+1->quiet 0->non-quiet
+Each bit position corresponds to a queue slot which
+is dynamically determined.
+*/
+char backend_mode = 63; /*00111111*/
+extern int num_of_backends;
+
+backend_info *begin;
+extern queue_info_map *start;
+extern int entries;
+int pos = 0;
+/*To store info in case of backend crash*/
+char pname[MAX_PKG_NAME_LEN] = {'\0'};
+char ptype[MAX_PKG_TYPE_LEN] = {'\0'};
+char args[MAX_PKG_ARGS_LEN] = {'\0'};
+
+GMainLoop *mainloop = NULL;
+
+
+/* operation_type */
+typedef enum {
+ OPERATION_INSTALL = 0,
+ OPERATION_UNINSTALL,
+ OPERATION_ACTIVATE,
+ OPERATION_REINSTALL,
+ OPERATION_MAX
+} OPERATION_TYPE;
+
+typedef enum {
+ PMSVC_ALL_APP = 0,
+ PMSVC_UI_APP,
+ PMSVC_SVC_APP
+}pkgmgr_svc_app_component;
+
+struct appdata {
+ Evas_Object *win;
+ Evas_Object *notify;
+ pm_dbus_msg *item;
+ OPERATION_TYPE op_type;
+};
+
+struct pm_desktop_notifier_t {
+ int ifd;
+ Ecore_Fd_Handler *handler;
+};
+typedef struct pm_desktop_notifier_t pm_desktop_notifier;
+
+pm_desktop_notifier desktop_notifier;
+pm_inotify_paths paths[DESKTOP_FILE_DIRS_NUM];
+static int __check_backend_status_for_exit();
+static int __check_queue_status_for_exit();
+static int __check_backend_mode();
+static int __is_backend_busy(int position);
+static void __set_backend_busy(int position);
+static void __set_backend_free(int position);
+static int __is_backend_mode_quiet(int position);
+static void __set_backend_mode(int position);
+static void __unset_backend_mode(int position);
+static void response_cb1(void *data, Evas_Object *notify, void *event_info);
+static void response_cb2(void *data, Evas_Object *notify, void *event_info);
+static int create_popup(struct appdata *ad);
+static void sighandler(int signo);
+static int __get_position_from_pkg_type(char *pkgtype);
+static int __is_efl_tpk_app(char *pkgpath);
+static int __is_efl_wgt_app(char * pkgid);
+static int __xsystem(const char *argv[]);
+
+gboolean queue_job(void *data);
+gboolean send_fail_signal(void *data);
+gboolean exit_server(void *data);
+static Eina_Bool __directory_notify(void *data, Ecore_Fd_Handler *fd_handler);
+
+/* To check whether a particular backend is free/busy*/
+static int __is_backend_busy(int position)
+{
+ return backend_busy & 1<<position;
+}
+/*To set a particular backend as busy*/
+static void __set_backend_busy(int position)
+{
+ backend_busy = backend_busy | 1<<position;
+}
+/*To set a particular backend as free */
+static void __set_backend_free(int position)
+{
+ backend_busy = backend_busy & ~(1<<position);
+}
+/* To check whether a particular backend is running in quiet mode*/
+static int __is_backend_mode_quiet(int position)
+{
+ return backend_mode & 1<<position;
+}
+/*To set a particular backend mode as quiet*/
+static void __set_backend_mode(int position)
+{
+ backend_mode = backend_mode | 1<<position;
+}
+/*To unset a particular backend mode */
+static void __unset_backend_mode(int position)
+{
+ backend_mode = backend_mode & ~(1<<position);
+}
+
+static void __set_recovery_mode(char *pkgid, char *pkg_type)
+{
+ char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
+ char buffer[MAX_PKG_NAME_LEN] = { 0 };
+ char *pkgid_tmp = NULL;
+ FILE *rev_file = NULL;
+
+ if (pkgid == NULL) {
+ DBG("pkgid is null\n");
+ return;
+ }
+
+ /*if pkgid has a "/"charactor, that is a path name for installation, then extract pkgid from absolute path*/
+ if (strstr(pkgid, "/")) {
+ pkgid_tmp = strrchr(pkgid, '/') + 1;
+ if (pkgid_tmp == NULL) {
+ DBG("pkgid_tmp[%s] is null\n", pkgid);
+ return;
+ }
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid_tmp);
+ } else {
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid);
+ }
+
+ rev_file = fopen(recovery_file, "w");
+ if (rev_file== NULL) {
+ DBG("rev_file[%s] is null\n", recovery_file);
+ return;
+ }
+
+ snprintf(buffer, MAX_PKG_NAME_LEN, "pkgid : %s\n", pkgid);
+ fwrite(buffer, sizeof(char), strlen(buffer), rev_file);
+
+ fclose(rev_file);
+}
+
+static void __unset_recovery_mode(char *pkgid, char *pkg_type)
+{
+ int ret = -1;
+ char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
+ char *pkgid_tmp = NULL;
+
+ if (pkgid == NULL) {
+ DBG("pkgid is null\n");
+ return;
+ }
+
+ /*if pkgid has a "/"charactor, that is a path name for installation, then extract pkgid from absolute path*/
+ if (strstr(pkgid, "/")) {
+ pkgid_tmp = strrchr(pkgid, '/') + 1;
+ if (pkgid_tmp == NULL) {
+ DBG("pkgid_tmp[%s] is null\n", pkgid);
+ return;
+ }
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid_tmp);
+ } else {
+ snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid);
+ }
+
+ ret = remove(recovery_file);
+ if (ret < 0)
+ DBG("remove recovery_file[%s] fail\n", recovery_file);
+}
+
+static int __check_privilege_by_cookie(const char *e_cookie, int req_type)
+{
+ guchar *cookie = NULL;
+ gsize size;
+ int ret = PMINFO_R_ERROR;
+
+ if (e_cookie == NULL) {
+ DBG("e_cookie is NULL!!!\n");
+ return PMINFO_R_ERROR;
+ }
+
+ cookie = g_base64_decode(e_cookie, &size);
+ if (cookie == NULL) {
+ DBG("Unable to decode cookie!!!\n");
+ return PMINFO_R_ERROR;
+ }
+
+ switch (req_type) {
+ case COMM_REQ_TO_INSTALLER:
+ if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "pkgmgr::svc", "r"))
+ ret = PMINFO_R_OK;
+
+ break;
+
+ case COMM_REQ_TO_MOVER:
+ if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "pkgmgr::svc", "x"))
+ ret = PMINFO_R_OK;
+ break;
+
+ case COMM_REQ_GET_SIZE:
+ if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "pkgmgr::info", "r"))
+ ret = PMINFO_R_OK;
+ break;
+
+ default:
+ DBG("Check your request[%d]..\n", req_type);
+ break;
+ }
+
+ DBG("security_server[req-type:%d] check cookie result = %d, \n", req_type, ret);
+
+ if (cookie){
+ g_free(cookie);
+ cookie = NULL;
+ }
+
+ return ret;
+}
+
+static int __get_position_from_pkg_type(char *pkgtype)
+{
+ int i = 0;
+ queue_info_map *ptr;
+ ptr = start;
+ for(i = 0; i < entries; i++)
+ {
+ if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN))
+ return ptr->queue_slot;
+ else
+ ptr++;
+
+ }
+ return -1;
+}
+
+static int __xsystem(const char *argv[])
+{
+ int err = 0;
+ int status = 0;
+ pid_t pid;
+
+ pid = fork();
+
+ switch (pid) {
+ case -1:
+ DBG("fork() failed");
+ return -1;
+ case 0:
+ if (execvp(argv[0], (char *const *)argv) == -1) {
+ DBG("execvp() failed");
+ }
+ _exit(100);
+ default:
+ /* parent */
+ do {
+ err = waitpid(pid, &status, WUNTRACED | WCONTINUED);
+ if (err == -1) {
+ DBG("waitpid failed\n");
+ return -1;
+ }
+ } while (!WIFEXITED(status) && !WIFSIGNALED(status));
+ break;
+ }
+ if (WIFEXITED(status))
+ return WEXITSTATUS(status);
+ else
+ return -1;
+}
+
+static int __is_efl_tpk_app(char *pkgid)
+{
+ int ret = 0;
+ char *type = NULL;
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-j", pkgid, "*.rpm", "-d", "/tmp/efltpk-unzip", NULL };
+ /*const char *unzip_opt_argv[] = { "/usr/bin/unzip", "-j", pkgid, "opt/share/packages/*", "-d", "/tmp/efltpk-unzip", NULL };*/
+ const char *delete_argv[] = { "/bin/rm", "-rf", "/tmp/efltpk-unzip", NULL };
+ pkgmgrinfo_pkginfo_h handle;
+ /*Check for uninstall case. If we fail to get handle then request is for installation*/
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret == PMINFO_R_OK) {
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if (ret != PMINFO_R_OK) {
+ DBG("Failed to get package type\n");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return -1;
+ }
+ if (strcmp(type, "efltpk") == 0) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 1;
+ } else {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 0;
+ }
+ }
+ /*Install request*/
+ if (strstr(pkgid, ".tpk") == NULL) {
+ DBG("TPK package");
+ return 0;
+ }
+ __xsystem(delete_argv);
+ ret = mkdir("/tmp/efltpk-unzip", 0755);
+ if (ret != 0) {
+ DBG("Failed to create temporary directory to unzip tpk package\n");
+ return -1;
+ }
+ /*In case of installation request, pkgid contains the pkgpath*/
+ ret = __xsystem(unzip_argv);
+ if (ret) {
+ DBG("Unzip of tpk package failed. error:%d\n", ret);
+ if (ret == NO_MATCHING_FILE) /*no matching file found*/
+ ret = 0;
+ else
+ ret = -1;
+ } else
+ ret = 1;
+err:
+ __xsystem(delete_argv);
+ return ret;
+}
+
+
+
+static int __is_efl_wgt_app(char *pkgid)
+{
+ int ret = 0;
+ char *type = NULL;
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-j", pkgid, "*.rpm", "-d", "/tmp/eflwgt-unzip", NULL };
+ const char *delete_argv[] = { "/bin/rm", "-rf", "/tmp/eflwgt-unzip", NULL };
+ pkgmgrinfo_pkginfo_h handle;
+ /*Check for uninstall case. If we fail to get handle then request is for installation*/
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret == PMINFO_R_OK) {
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if (ret != PMINFO_R_OK) {
+ DBG("Failed to get package type\n");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return -1;
+ }
+ if (strcmp(type, "eflwgt") == 0) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 1;
+ } else {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 0;
+ }
+ }
+
+ /*Install request*/
+ if (strstr(pkgid, ".wgt") == NULL) {
+ DBG("WGT package");
+ return 0;
+ }
+ __xsystem(delete_argv);
+ ret = mkdir("/tmp/eflwgt-unzip", 0755);
+ if (ret != 0) {
+ DBG("Failed to create temporary directory to unzip wgt package\n");
+ return -1;
+ }
+ /*In case of installation request, pkgid contains the pkgpath*/
+ ret = __xsystem(unzip_argv);
+ if (ret) {
+ DBG("Unzip of wgt package failed. error:%d\n", ret);
+ if (ret == NO_MATCHING_FILE) /*no matching file found*/
+ ret = 0;
+ else
+ ret = -1;
+ }else{
+ ret = 1;
+ }
+err:
+ __xsystem(delete_argv);
+ return ret;
+
+}
+
+
+static Eina_Bool __directory_notify(void *data, Ecore_Fd_Handler *fd_handler)
+{
+ ail_db_update = 0;
+ char *buf = NULL;
+ ssize_t read_size = 0;
+ ssize_t len = 0;
+ ssize_t i = 0;
+ int fd = -1;
+
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+ if(fd < 0) {
+ DBG("ecore_main_fd_handler_fd_get error");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ DBG("ifd [%d]\n", fd);
+
+ if (ioctl(fd, FIONREAD, &read_size) < 0) {
+ DBG("Failed to get byte size\n");
+ ail_db_update = 1;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (read_size <= 0) {
+ DBG("Buffer is not ready!!!\n");
+ ail_db_update = 1;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ buf = calloc(1, read_size+1);
+ if (!buf) {
+ DBG("Failed to allocate memory for event handling\n");
+ ail_db_update = 1;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ len = read(fd, buf, read_size);
+ buf[len] = 0;
+
+ while (i < len) {
+ struct inotify_event *event = (struct inotify_event*) &buf[i];
+ char *str_potksed = "potksed.";
+ char *cut;
+ ssize_t idx;
+ int nev_name;
+
+ /* 1. check the extension of a file */
+ nev_name = strlen(event->name) - 1;
+ for (idx = 0; nev_name >= 0 && str_potksed[idx]; idx++) {
+ if (event->name[nev_name] != str_potksed[idx]) {
+ break;
+ }
+ nev_name --;
+ }
+
+ if (str_potksed[idx] != '\0') {
+ DBG("This is not a desktop file : %s\n", event->name);
+ i += sizeof(struct inotify_event) + event->len;
+ continue;
+ }
+
+ if (event->name[0] == '\0')
+ continue;
+
+ cut = strstr(event->name, ".desktop");
+ if (cut)
+ *cut = '\0';
+ DBG("Package : %s\n", event->name);
+
+ /* add & update */
+ if (event->mask & IN_CLOSE_WRITE || event->mask & IN_MOVED_TO) {
+ ail_appinfo_h ai = NULL;
+ ail_error_e ret;
+
+ ret = ail_package_get_appinfo(event->name, &ai);
+ if (ai)
+ ail_package_destroy_appinfo(ai);
+
+ if (AIL_ERROR_NO_DATA == ret) {
+ if (ail_desktop_add(event->name) < 0) {
+ DBG("Failed to add a new package (%s)\n", event->name);
+ }
+ } else if (AIL_ERROR_OK == ret) {
+ if (ail_desktop_update(event->name) < 0) {
+ DBG("Failed to add a new package (%s)\n", event->name);
+ }
+ } else;
+ /* delete */
+ } else if (event->mask & IN_DELETE) {
+ if (ail_desktop_remove(event->name) < 0)
+ DBG("Failed to remove a package (%s)\n",
+ event->name);
+ } else {
+ DBG("this event is not dealt with inotify\n");
+ }
+
+ i += sizeof(struct inotify_event) + event->len;
+ }
+
+ free(buf);
+ ail_db_update = 1;
+ return ECORE_CALLBACK_RENEW;
+}
+
+static
+void response_cb1(void *data, Evas_Object *notify, void *event_info)
+{
+ struct appdata *ad = (struct appdata *)data;
+ int p = 0;
+ int ret = 0;
+ DBG("start of response_cb()\n");
+
+ /* YES */
+ DBG("Uninstalling... [%s]\n", ad->item->pkgid);
+
+ if (strlen(ad->item->pkgid) == 0) {
+ DBG("package_name is empty\n");
+ }
+
+ if (strlen(ad->item->pkg_type) == 0) {
+ DBG("Fail : Uninstalling... [%s]\n",
+ ad->item->pkgid);
+ free(ad->item);
+ evas_object_del(ad->notify);
+ evas_object_del(ad->win);
+ drawing_popup = 0;
+
+ return;
+ }
+
+ DBG("pkg_type = [%s]\n", ad->item->pkg_type);
+
+ ret = _pm_queue_push(ad->item);
+ p = __get_position_from_pkg_type(ad->item->pkg_type);
+ __unset_backend_mode(p);
+
+ /* Free resource */
+ free(ad->item);
+ evas_object_del(ad->notify);
+ evas_object_del(ad->win);
+ /***************/
+ if (ret == 0)
+ g_idle_add(queue_job, NULL);
+
+ DBG("end of response_cb()\n");
+
+ drawing_popup = 0;
+
+ return;
+}
+
+static
+void response_cb2(void *data, Evas_Object *notify, void *event_info)
+{
+ int p = 0;
+ struct appdata *ad = (struct appdata *)data;
+
+ DBG("start of response_cb()\n");
+
+ /* NO */
+ pkgmgr_installer *pi;
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ DBG("Failure in creating the pkgmgr_installer object");
+ return;
+ }
+
+ ret_parse = g_shell_parse_argv(ad->item->args,
+ &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ DBG("Failed to split args: %s", ad->item->args);
+ DBG("messsage: %s", gerr->message);
+ pkgmgr_installer_free(pi);
+ return;
+ }
+
+ pkgmgr_installer_receive_request(pi, argcp, argvp);
+
+ pkgmgr_installer_send_signal(pi, ad->item->pkg_type,
+ ad->item->pkgid, "end",
+ "cancel");
+
+ pkgmgr_installer_free(pi);
+ p = __get_position_from_pkg_type(ad->item->pkg_type);
+ __set_backend_mode(p);
+
+ /* Free resource */
+ free(ad->item);
+ evas_object_del(ad->notify);
+ evas_object_del(ad->win);
+ /***************/
+ /* queue_job should be called for every request that is pushed
+ into queue. In "NO" case, request is not pushed so no need of
+ calling queue_job*/
+
+ DBG("end of response_cb()\n");
+
+ drawing_popup = 0;
+
+ return;
+}
+
+#if 0
+static char *__get_exe_path(const char *pkgid)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+ char *exe_path;
+
+ ret = ail_package_get_appinfo(pkgid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ DBGE("ail_package_get_appinfo() failed");
+ return NULL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_EXE_PATH, &str);
+ if (ret != AIL_ERROR_OK) {
+ DBGE("ail_appinfo_get_str() failed");
+ ail_package_destroy_appinfo(handle);
+ return NULL;
+ }
+
+ exe_path = strdup(str);
+ if (exe_path == NULL) {
+ DBGE("strdup() failed");
+ ail_package_destroy_appinfo(handle);
+ return NULL;
+ }
+
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ DBGE("ail_package_destroy_appinfo() failed");
+ free(exe_path);
+ return NULL;
+ }
+
+ return exe_path;
+}
+#endif
+
+static
+int create_popup(struct appdata *ad)
+{
+ DBG("start of create_popup()\n");
+
+ drawing_popup = 1;
+
+ char sentence[MAX_PKG_ARGS_LEN] = { '\0' };
+ char *pkgid = NULL;
+ char app_name[MAX_PKG_NAME_LEN] = { '\0' };
+
+ ad->win = elm_win_add(NULL, PACKAGE, ELM_WIN_DIALOG_BASIC);
+ if (!ad->win) {
+ DBG("Failed to create a new window\n");
+ drawing_popup = 0;
+ return -1;
+ }
+
+ elm_win_alpha_set(ad->win, EINA_TRUE);
+ elm_win_title_set(ad->win, "test");
+ elm_win_borderless_set(ad->win, EINA_TRUE);
+ elm_win_raise(ad->win);
+
+ int rotation = 0;
+ int w;
+ int h;
+ int x;
+ int y;
+ unsigned char *prop_data = NULL;
+ int count;
+ ecore_x_window_geometry_get(ecore_x_window_root_get(
+ ecore_x_window_focus_get()),
+ &x, &y, &w, &h);
+ int ret =
+ ecore_x_window_prop_property_get(ecore_x_window_root_get
+ (ecore_x_window_focus_get()),
+ ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
+ ECORE_X_ATOM_CARDINAL,
+ 32, &prop_data, &count);
+ if (ret && prop_data)
+ memcpy(&rotation, prop_data, sizeof(int));
+ if (prop_data)
+ free(prop_data);
+ evas_object_resize(ad->win, w, h);
+ evas_object_move(ad->win, x, y);
+
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, &rots, 4);
+ }
+
+ double s;
+ s = w / DESKTOP_W;
+ elm_config_scale_set(s);
+
+ evas_object_show(ad->win);
+
+ ad->notify = elm_popup_add(ad->win);
+ if (!ad->notify) {
+ DBG("failed to create notify object\n");
+ evas_object_del(ad->win);
+ drawing_popup = 0;
+ return -1;
+ }
+
+ /* Sentence of popup */
+ pkgid = strrchr(ad->item->pkgid, '/') == NULL ?
+ ad->item->pkgid : strrchr(ad->item->pkgid, '/') + 1;
+
+ if (ad->op_type == OPERATION_INSTALL) {
+ snprintf(sentence, sizeof(sentence) - 1, _("Install?"));
+ } else if (ad->op_type == OPERATION_UNINSTALL) {
+ char *label = NULL;
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret < 0){
+ drawing_popup = 0;
+ evas_object_del(ad->notify);
+ evas_object_del(ad->win);
+ return -1;
+ }
+ ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
+ if (ret < 0){
+ drawing_popup = 0;
+ evas_object_del(ad->notify);
+ evas_object_del(ad->win);
+ return -1;
+ }
+
+ snprintf(app_name, sizeof(app_name) - 1, label);
+ ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ if (ret < 0){
+ drawing_popup = 0;
+ evas_object_del(ad->notify);
+ evas_object_del(ad->win);
+ return -1;
+ }
+
+ pkgid = app_name;
+
+ snprintf(sentence, sizeof(sentence) - 1, _("Uninstall?"));
+ } else if (ad->op_type == OPERATION_REINSTALL) {
+ snprintf(sentence, sizeof(sentence) - 1, _("Reinstall?"));
+ } else
+ snprintf(sentence, sizeof(sentence) - 1, _("Invalid request"));
+
+ elm_object_part_text_set(ad->notify, "title,text", pkgid);
+ evas_object_size_hint_weight_set(ad->notify, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+
+ evas_object_show(ad->notify);
+ /***********************************/
+
+ elm_object_text_set(ad->notify, sentence);
+
+ Evas_Object *button1 = NULL;
+ Evas_Object *button2 = NULL;
+
+ button1 = elm_button_add(ad->notify);
+ elm_object_text_set(button1, "Yes");
+ elm_object_part_content_set(ad->notify, "button1", button1);
+ evas_object_smart_callback_add(button1, "clicked", response_cb1, ad);
+
+ button2 = elm_button_add(ad->notify);
+ elm_object_text_set(button2, "No");
+ elm_object_part_content_set(ad->notify, "button2", button2);
+ evas_object_smart_callback_add(button2, "clicked", response_cb2, ad);
+
+ evas_object_show(ad->notify);
+
+ DBG("end of create_popup()\n");
+ return 0;
+}
+
+gboolean send_fail_signal(void *data)
+{
+ DBG("send_fail_signal start\n");
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+ pkgmgr_installer *pi;
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ DBG("Failure in creating the pkgmgr_installer object");
+ return FALSE;
+ }
+ ret_parse = g_shell_parse_argv(args,
+ &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ DBG("Failed to split args: %s", args);
+ DBG("messsage: %s", gerr->message);
+ pkgmgr_installer_free(pi);
+ return FALSE;
+ }
+
+ pkgmgr_installer_receive_request(pi, argcp, argvp);
+ pkgmgr_installer_send_signal(pi, ptype, pname, "end", "fail");
+ pkgmgr_installer_free(pi);
+ return FALSE;
+}
+
+static void sighandler(int signo)
+{
+ int status;
+ pid_t cpid;
+ int i = 0;
+ backend_info *ptr = NULL;
+ ptr = begin;
+
+ while ((cpid = waitpid(-1, &status, WNOHANG)) > 0) {
+ DBG("child exit [%d]\n", cpid);
+ if (WIFEXITED(status)) {
+ DBG("child NORMAL exit [%d]\n", cpid);
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (cpid == (ptr + i)->pid) {
+ __set_backend_free(i);
+ __set_backend_mode(i);
+ __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
+ break;
+ }
+ }
+ }
+ else if (WIFSIGNALED(status)) {
+ DBG("child SIGNALED exit [%d]\n", cpid);
+ /*get the pkgid and pkgtype to send fail signal*/
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (cpid == (ptr + i)->pid) {
+ __set_backend_free(i);
+ __set_backend_mode(i);
+ __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
+ strncpy(pname, (ptr + i)->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy(ptype, (ptr + i)->pkgtype, MAX_PKG_TYPE_LEN-1);
+ strncpy(args, (ptr + i)->args, MAX_PKG_ARGS_LEN-1);
+ g_idle_add(send_fail_signal, NULL);
+ break;
+ }
+ }
+ }
+ }
+
+}
+
+void req_cb(void *cb_data, const char *req_id, const int req_type,
+ const char *pkg_type, const char *pkgid, const char *args,
+ const char *cookie, int *ret)
+{
+ static int sig_reg = 0;
+ int err = -1;
+ int p = 0;
+ int cookie_result = 0;
+
+ SECURE_LOGD(">> in callback >> Got request: [%s] [%d] [%s] [%s] [%s] [%s]",
+ req_id, req_type, pkg_type, pkgid, args, cookie);
+
+ struct appdata *ad = (struct appdata *)cb_data;
+
+ pm_dbus_msg *item = calloc(1, sizeof(pm_dbus_msg));
+ memset(item, 0x00, sizeof(pm_dbus_msg));
+
+ strncpy(item->req_id, req_id, sizeof(item->req_id) - 1);
+ item->req_type = req_type;
+ /*
+ If package type is eflwgt then change the package type to efltpk before
+ pushing the request in queue so that efltpk installer can handle the request.
+ */
+ if(!strcmp(pkg_type,"eflwgt"))
+ strncpy(item->pkg_type,"efltpk",sizeof(item->pkg_type));
+ else
+ strncpy(item->pkg_type, pkg_type, sizeof(item->pkg_type) - 1);
+
+ strncpy(item->pkgid, pkgid, sizeof(item->pkgid) - 1);
+ strncpy(item->args, args, sizeof(item->args) - 1);
+ strncpy(item->cookie, cookie, sizeof(item->cookie) - 1);
+
+ if (sig_reg == 0) {
+ struct sigaction act;
+
+ act.sa_handler = sighandler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_NOCLDSTOP;
+
+ if (sigaction(SIGCHLD, &act, NULL) < 0) {
+ DBG("signal: SIGCHLD failed\n");
+ } else
+ DBG("signal: SIGCHLD succeed\n");
+ if (g_timeout_add_seconds(2, exit_server, NULL))
+ DBG("g_timeout_add_seconds() Added to Main Loop");
+
+ sig_reg = 1;
+ }
+
+ DBG("req_type=(%d) drawing_popup=(%d) backend_flag=(%d)\n", req_type,
+ drawing_popup, backend_flag);
+
+ char *quiet = NULL;
+
+ switch (item->req_type) {
+ case COMM_REQ_TO_INSTALLER:
+ /* check caller privilege */
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ DBG("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = COMM_RET_ERROR;
+ goto err;
+ }
+
+ /* -q option should be located at the end of command !! */
+ if (((quiet = strstr(args, " -q")) &&
+ (quiet[strlen(quiet)] == '\0')) ||
+ ((quiet = strstr(args, " '-q'")) &&
+ (quiet[strlen(quiet)] == '\0'))) {
+ /* quiet mode */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ /* Free resource */
+ free(item);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = COMM_RET_OK;
+ } else {
+ /* non quiet mode */
+ p = __get_position_from_pkg_type(item->pkg_type);
+ if (drawing_popup == 0 &&
+ !__is_backend_busy(p) &&
+ __check_backend_mode()) {
+ /* if there is no popup */
+ ad->item = item;
+
+ if (strstr(args, " -i ")
+ || strstr(args, " '-i' "))
+ ad->op_type = OPERATION_INSTALL;
+ else if (strstr(args, " -d ")
+ || strstr(args, " '-d' ")) {
+ ad->op_type = OPERATION_UNINSTALL;
+
+ /* 2011-04-01
+ Change the mode temporarily. This should be removed */
+ /*strncat(item->args, " -q",
+ strlen(" -q"));*/
+ } else if (strstr(args, " -r ")
+ || strstr(args, " '-r' "))
+ ad->op_type = OPERATION_REINSTALL;
+ else
+ ad->op_type = OPERATION_MAX;
+
+ err = create_popup(ad);
+ if (err != 0) {
+ *ret = COMM_RET_ERROR;
+ DBG("create popup failed\n");
+ /*queue_job(NULL);*/
+ goto err;
+ } else {
+ *ret = COMM_RET_OK;
+ }
+ } else {
+ DBG("info drawing_popup:%d, __is_backend_busy(p):%d, __check_backend_mode():%d\n",
+ drawing_popup, __is_backend_busy(p), __check_backend_mode());
+ /* if popup is already being drawn */
+ *ret = COMM_RET_ERROR;
+ goto err;
+ }
+ }
+ break;
+ case COMM_REQ_TO_ACTIVATOR:
+ /* In case of activate, there is no popup */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ /* Free resource */
+ free(item);
+
+/* g_idle_add(queue_job, NULL); */
+ if (err == 0)
+ queue_job(NULL);
+ *ret = COMM_RET_OK;
+ break;
+ case COMM_REQ_TO_CLEARER:
+ /* In case of clearer, there is no popup */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ /*the backend shows the success/failure popup
+ so this request is non quiet*/
+ __unset_backend_mode(p);
+ /* Free resource */
+ free(item);
+
+/* g_idle_add(queue_job, NULL); */
+ if (err == 0)
+ queue_job(NULL);
+ *ret = COMM_RET_OK;
+ break;
+ case COMM_REQ_TO_MOVER:
+ /* check caller privilege */
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ DBG("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = COMM_RET_ERROR;
+ goto err;
+ }
+
+ /* In case of mover, there is no popup */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ /*the backend shows the success/failure popup
+ so this request is non quiet*/
+ __unset_backend_mode(p);
+ /* Free resource */
+ free(item);
+ if (err == 0)
+ queue_job(NULL);
+ *ret = COMM_RET_OK;
+ break;
+ case COMM_REQ_CANCEL:
+ ad->item = item;
+ _pm_queue_delete(ad->item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __unset_backend_mode(p);
+ free(item);
+ *ret = COMM_RET_OK;
+ break;
+ case COMM_REQ_GET_SIZE:
+ /* check caller privilege */
+ cookie_result = __check_privilege_by_cookie(cookie, item->req_type);
+ if (cookie_result < 0){
+ DBG("__check_privilege_by_cookie result fail[%d]\n", cookie_result);
+ *ret = COMM_RET_ERROR;
+ goto err;
+ }
+
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ /* Free resource */
+ free(item);
+ if (err == 0)
+ g_idle_add(queue_job, NULL);
+ *ret = COMM_RET_OK;
+ break;
+
+ case COMM_REQ_CHECK_APP:
+ case COMM_REQ_KILL_APP:
+ /* In case of activate, there is no popup */
+ err = _pm_queue_push(item);
+ p = __get_position_from_pkg_type(item->pkg_type);
+ __set_backend_mode(p);
+ /* Free resource */
+ free(item);
+
+/* g_idle_add(queue_job, NULL); */
+ if (err == 0)
+ queue_job(NULL);
+ *ret = COMM_RET_OK;
+ break;
+
+ default:
+ DBG("Check your request..\n");
+ *ret = COMM_RET_ERROR;
+ break;
+ }
+err:
+ if (*ret == COMM_RET_ERROR) {
+ DBG("Failed to handle request %s %s\n",item->pkg_type, item->pkgid);
+ pkgmgr_installer *pi;
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ DBG("Failure in creating the pkgmgr_installer object");
+ free(item);
+ return;
+ }
+
+ ret_parse = g_shell_parse_argv(args, &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ DBG("Failed to split args: %s", args);
+ DBG("messsage: %s", gerr->message);
+ pkgmgr_installer_free(pi);
+ free(item);
+ return;
+ }
+
+ pkgmgr_installer_receive_request(pi, argcp, argvp);
+
+ pkgmgr_installer_send_signal(pi, item->pkg_type,
+ item->pkgid, "end",
+ "fail");
+
+ pkgmgr_installer_free(pi);
+
+ free(item);
+ }
+ return;
+}
+
+static int __check_backend_mode()
+{
+ int i = 0;
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (__is_backend_mode_quiet(i))
+ continue;
+ else
+ return 0;
+ }
+ return 1;
+}
+static int __check_backend_status_for_exit()
+{
+ int i = 0;
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (!__is_backend_busy(i))
+ continue;
+ else
+ return 0;
+ }
+ return 1;
+}
+
+static int __check_queue_status_for_exit()
+{
+ pm_queue_data *head[MAX_QUEUE_NUM] = {NULL,};
+ queue_info_map *ptr = NULL;
+ ptr = start;
+ int i = 0;
+ int c = 0;
+ int slot = -1;
+ for(i = 0; i < entries; i++)
+ {
+ if (ptr->queue_slot <= slot) {
+ ptr++;
+ continue;
+ }
+ else {
+ head[c] = ptr->head;
+ slot = ptr->queue_slot;
+ c++;
+ ptr++;
+ }
+ }
+ for(i = 0; i < num_of_backends; i++)
+ {
+ if (!head[i])
+ continue;
+ else
+ return 0;
+ }
+ return 1;
+}
+gboolean exit_server(void *data)
+{
+ DBG("exit_server Start\n");
+ if (__check_backend_status_for_exit() &&
+ __check_queue_status_for_exit() &&
+ drawing_popup == 0) {
+ if (!getenv("PMS_STANDALONE") && ail_db_update) {
+ ecore_main_loop_quit();
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+
+int __app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ int ret = 0;
+ char *appid = NULL;
+ int *data = (int *)user_data;
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret != PMINFO_R_OK) {
+ DBGE("fail to activate/deactivte package");
+ exit(1);
+ }
+
+ ret = pkgmgrinfo_appinfo_set_state_enabled(appid, (*data));
+ if (ret != PMINFO_R_OK) {
+ DBGE("fail to activate/deactivte package");
+ exit(1);
+ }
+
+ ret = ail_desktop_appinfo_modify_bool(appid,
+ AIL_PROP_X_SLP_ENABLED_BOOL,
+ (*data), TRUE);
+ if (ret != AIL_ERROR_OK) {
+ DBGE("fail to activate/deactivte package");
+ exit(1);
+ }
+ return 0;
+}
+
+static int __pkgcmd_read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
+ if (buf == NULL || path == NULL)
+ return -1;
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+ close(fd);
+ return ret;
+}
+
+static int __pkgcmd_find_pid_by_cmdline(const char *dname,
+ const char *cmdline, const char *apppath)
+{
+ int pid = 0;
+
+ if (strcmp(cmdline, apppath) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
+ return pid;
+}
+
+static int __pkgcmd_proc_iter_kill_cmdline(const char *apppath, int option)
+{
+ DIR *dp;
+ struct dirent *dentry;
+ int pid;
+ int ret;
+ char buf[1024] = {'\0'};
+ int pgid;
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
+ ret = __pkgcmd_read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ continue;
+
+ pid = __pkgcmd_find_pid_by_cmdline(dentry->d_name, buf, apppath);
+ if (pid > 0) {
+ if (option == 0) {
+ closedir(dp);
+ return pid;
+ }
+ pgid = getpgid(pid);
+ if (pgid <= 1) {
+ closedir(dp);
+ return -1;
+ }
+ if (killpg(pgid, SIGKILL) < 0) {
+ closedir(dp);
+ return -1;
+ }
+ closedir(dp);
+ return pid;
+ }
+ }
+ closedir(dp);
+ return 0;
+}
+
+static void __make_pid_info_file(char *req_key, int size)
+{
+ int ret = 0;
+ FILE* file = NULL;
+ int fd = 0;
+ char buf[MAX_PKG_TYPE_LEN] = {0};
+ const char* app_info_label = "*";
+ char info_file[MAX_PKG_TYPE_LEN] = {'\0', };
+
+ if(req_key == NULL)
+ return;
+
+ snprintf(info_file, MAX_PKG_TYPE_LEN, "/tmp/%s", req_key);
+ DBGE("File path = %s\n", info_file);
+
+ file = fopen(info_file, "w");
+ if (file == NULL) {
+ DBGE("Couldn't open the file %s \n", info_file);
+ return;
+ }
+
+ snprintf(buf, 128, "%d\n", size);
+ fwrite(buf, 1, strlen(buf), file);
+
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+
+ if(lsetxattr(info_file, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ DBGE("error(%d) in setting smack label",errno);
+ }
+ ret = chmod(info_file, 0777);
+ if(ret < 0)
+ return;
+ ret = chown(info_file, 5000, 5000);
+ if(ret < 0)
+ return;
+}
+
+static int __pkgcmd_app_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *pkgid = NULL;
+ char *exec = NULL;
+ int ret = 0;
+ int pid = -1;
+ if (handle == NULL) {
+ perror("appinfo handle is NULL\n");
+ exit(1);
+ }
+ ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+ if (ret) {
+ perror("Failed to get app exec path\n");
+ exit(1);
+ }
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
+ if (ret) {
+ perror("Failed to get appid\n");
+ exit(1);
+ }
+
+ if (strcmp(user_data, "kill") == 0)
+ pid = __pkgcmd_proc_iter_kill_cmdline(exec, 1);
+ else if(strcmp(user_data, "check") == 0)
+ pid = __pkgcmd_proc_iter_kill_cmdline(exec, 0);
+
+// vconf_set_int(VCONFKEY_PKGMGR_STATUS, pid);
+ __make_pid_info_file(pkgid, pid);
+
+ return 0;
+}
+
+void __pm_send_sub_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val)
+{
+ dbus_uint32_t serial = 0;
+ DBusMessage *msg = NULL;
+ DBusMessageIter args;
+ DBusError err;
+ DBusConnection *conn = NULL;
+ const char *values[] = {
+ req_id,
+ pkg_type,
+ pkgid,
+ key,
+ val
+ };
+ int i;
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ DBG("Connection error: %s", err.message);
+ dbus_error_free(&err);
+ }
+ dbus_error_free(&err);
+ if (NULL == conn) {
+ DBG("conn is NULL");
+ return NULL;
+ }
+
+ if (strcmp(key,PKGMGR_INSTALLER_START_KEY_STR) == 0) {
+ if (strcmp(val,PKGMGR_INSTALLER_INSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL);
+ } else if (strcmp(val,PKGMGR_INSTALLER_UNINSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UNINSTALL);
+ } else if (strcmp(val,PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UPGRADE);
+ }
+ } else if (strcmp(key,PKGMGR_INSTALLER_END_KEY_STR) == 0) {
+ if (strcmp(req_id,PKGMGR_INSTALLER_INSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_INSTALL);
+ } else if (strcmp(req_id,PKGMGR_INSTALLER_UNINSTALL_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UNINSTALL);
+ } else if (strcmp(req_id,PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0) {
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_UPGRADE);
+ }
+ }
+ if (NULL == msg) {
+ DBG("msg NULL");
+ return;
+ }
+
+ dbus_message_iter_init_append(msg, &args);
+
+ for (i = 0; i < 5; i++) {
+ if (!dbus_message_iter_append_basic
+ (&args, DBUS_TYPE_STRING, &(values[i]))) {
+ DBG("dbus_message_iter_append_basic failed:"
+ " Out of memory");
+ return;
+ }
+ }
+ if (!dbus_connection_send(conn, msg, &serial)) {
+ DBG("dbus_connection_send failed: Out of memory");
+ return;
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(msg);
+}
+
+void __pm_send_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val)
+{
+ dbus_uint32_t serial = 0;
+ DBusMessage *msg;
+ DBusMessageIter args;
+ DBusError err;
+ DBusConnection *conn;
+ const char *values[] = {
+ req_id,
+ pkg_type,
+ pkgid,
+ key,
+ val
+ };
+ int i;
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ DBG("Connection error: %s", err.message);
+ dbus_error_free(&err);
+ }
+ dbus_error_free(&err);
+ if (NULL == conn) {
+ DBG("conn is NULL");
+ return NULL;
+ }
+
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_PATH, COMM_STATUS_BROADCAST_DBUS_INTERFACE, COMM_STATUS_BROADCAST_SIGNAL_STATUS);
+ if (NULL == msg) {
+ DBG("msg NULL");
+ return;
+ }
+
+ dbus_message_iter_init_append(msg, &args);
+
+ for (i = 0; i < 5; i++) {
+ if (!dbus_message_iter_append_basic
+ (&args, DBUS_TYPE_STRING, &(values[i]))) {
+ DBG("dbus_message_iter_append_basic failed:"
+ " Out of memory");
+ return;
+ }
+ }
+ if (!dbus_connection_send(conn, msg, &serial)) {
+ DBG("dbus_connection_send failed: Out of memory");
+ return;
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(msg);
+
+ __pm_send_sub_signal(req_id, pkg_type, pkgid, key, val);
+}
+
+int __check_rw_manifest(const char *manifest)
+{
+ if(strstr(manifest, MANIFEST_RO_PREFIX)) {
+ const char *cp_argv[] = { "/bin/cp", "-rf", manifest, "/opt/share/packages/", NULL };
+ __xsystem(cp_argv);
+ return -1;
+ }
+ return 0;
+}
+
+gboolean queue_job(void *data)
+{
+ /* DBG("queue_job start"); */
+ pm_dbus_msg *item;
+ backend_info *ptr = NULL;
+ ptr = begin;
+ int x = 0;
+ /* Pop a job from queue */
+pop:
+ if (!__is_backend_busy(pos % num_of_backends)) {
+ item = _pm_queue_pop(pos % num_of_backends);
+ pos = (pos + 1) % num_of_backends;
+ }
+ else {
+ pos = (pos + 1) % num_of_backends;
+ goto pop;
+ }
+
+ int ret = 0;
+ char *backend_cmd = NULL;
+
+ /* queue is empty and backend process is not running */
+ if ( (item == NULL) || (item->req_type == -1) ) {
+ if(item)
+ free(item);
+ goto pop;
+ }
+ __set_backend_busy((pos + num_of_backends - 1) % num_of_backends);
+ __set_recovery_mode(item->pkgid, item->pkg_type);
+
+ switch (item->req_type) {
+ case COMM_REQ_TO_INSTALLER:
+ DBG("installer start");
+ _save_queue_status(item, "processing");
+ DBG("saved queue status. Now try fork()");
+ /*save pkg type and pkg name for future*/
+ x = (pos + num_of_backends - 1) % num_of_backends;
+ strncpy((ptr + x)->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1);
+ strncpy((ptr + x)->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy((ptr + x)->args, item->args, MAX_PKG_ARGS_LEN-1);
+ (ptr + x)->pid = fork();
+ DBG("child forked [%d]\n", (ptr + x)->pid);
+
+ switch ((ptr + x)->pid) {
+ case 0: /* child */
+ DBG("before run _get_backend_cmd()");
+ /*Check for efl-tpk app*/
+ backend_cmd = _get_backend_cmd(item->pkg_type);
+
+ if (strcmp(item->pkg_type, "tpk") == 0) {
+ ret = __is_efl_tpk_app(item->pkgid);
+ if (ret == 1) {
+ if (backend_cmd)
+ free(backend_cmd);
+ backend_cmd = _get_backend_cmd("efltpk");
+ }
+ }
+
+ /* Check for wgt package of native apps */
+ if(strcmp(item->pkg_type,"wgt") == 0){
+ ret = __is_efl_wgt_app(item->pkgid);
+ if(ret == 1){
+ if(backend_cmd)
+ free(backend_cmd);
+ backend_cmd = _get_backend_cmd("efltpk");
+ }
+ }
+
+ if (NULL == backend_cmd)
+ break;
+
+ DBG("Try to exec [%s][%s]", item->pkg_type,
+ backend_cmd);
+ fprintf(stdout, "Try to exec [%s][%s]\n",
+ item->pkg_type, backend_cmd);
+
+ /* Create args vector
+ * req_id + pkgid + args
+ *
+ * vector size = # of args +
+ *(req_id + pkgid + NULL termination = 3)
+ * Last value must be NULL for execv.
+ */
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+ ret_parse = g_shell_parse_argv(item->args,
+ &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ DBG("Failed to split args: %s", item->args);
+ DBG("messsage: %s", gerr->message);
+ exit(1);
+ }
+
+ /* Setup argument !!! */
+ /*char **args_vector =
+ calloc(argcp + 4, sizeof(char *)); */
+ char **args_vector = calloc(argcp + 1, sizeof(char *));
+ /*args_vector[0] = strdup(backend_cmd);
+ args_vector[1] = strdup(item->req_id);
+ args_vector[2] = strdup(item->pkgid); */
+ int arg_idx;
+ for (arg_idx = 0; arg_idx < argcp; arg_idx++) {
+ /* args_vector[arg_idx+3] = argvp[arg_idx]; */
+ args_vector[arg_idx] = argvp[arg_idx];
+ }
+
+ /* dbg */
+ /*for(arg_idx = 0; arg_idx < argcp+3; arg_idx++) { */
+ for (arg_idx = 0; arg_idx < argcp + 1; arg_idx++) {
+ DBG(">>>>>> args_vector[%d]=%s",
+ arg_idx, args_vector[arg_idx]);
+ }
+
+ /* Execute backend !!! */
+ ret = execv(backend_cmd, args_vector);
+
+ /* Code below: exec failure. Should not be happened! */
+ DBG(">>>>>> OOPS 2!!!");
+
+ /* g_strfreev(args_vector); *//* FIXME: causes error */
+
+ if (ret == -1) {
+ perror("fail to exec");
+ exit(1);
+ }
+ _save_queue_status(item, "done");
+ if (NULL != backend_cmd)
+ free(backend_cmd);
+ exit(0); /* exit */
+ break;
+
+ case -1: /* error */
+ fprintf(stderr, "Fail to execute fork()\n");
+ exit(1);
+ break;
+
+ default: /* parent */
+ DBG("parent \n");
+ _save_queue_status(item, "done");
+ break;
+ }
+ break;
+ case COMM_REQ_TO_ACTIVATOR:
+ DBG("activator start");
+ int val = 0;
+ _save_queue_status(item, "processing");
+ DBG("saved queue status. Now try fork()");
+ /*save pkg type and pkg name for future*/
+ x = (pos + num_of_backends - 1) % num_of_backends;
+ strncpy((ptr + x)->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1);
+ strncpy((ptr + x)->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy((ptr + x)->args, item->args, MAX_PKG_ARGS_LEN-1);
+ (ptr + x)->pid = fork();
+ DBG("child forked [%d]\n", (ptr + x)->pid);
+
+ switch ((ptr + x)->pid) {
+ case 0: /* child */
+ if (item->args[0] == '1') /* activate */
+ val = 1;
+ else if (item->args[0] == '0') /* deactivate */
+ val = 0;
+ else {
+ DBG("error in args parameter:[%c]\n",
+ item->args[0]);
+ exit(1);
+ }
+
+ DBG("activated val %d", val);
+
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+ char *label = NULL;
+ ret_parse = g_shell_parse_argv(item->args,
+ &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ DBG("Failed to split args: %s", item->args);
+ DBG("messsage: %s", gerr->message);
+ exit(1);
+ }
+
+ if (!strcmp(argvp[1], "APP")) { /* in case of application */
+ DBG("(De)activate APP");
+ int opt;
+ while ((opt = getopt(argcp, argvp, "l:")) != -1) {
+ switch (opt) {
+ case 'l':
+ label = strdup(optarg);
+ DBG("activated label %s", label);
+ break;
+ default: /* '?' */
+ DBGE("Incorrect argument %s\n", item->args);
+ exit(1);
+ }
+ }
+
+ ret = pkgmgrinfo_appinfo_set_state_enabled(item->pkgid, val);
+ if (ret != PMINFO_R_OK) {
+ DBGE("fail to activate/deactivte package");
+ exit(1);
+ }
+
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_START_KEY_STR, PKGMGR_INSTALLER_UPGRADE_EVENT_STR);
+
+ if (label) {
+ ret = pkgmgrinfo_appinfo_set_default_label(item->pkgid, label);
+ if (ret != PMINFO_R_OK) {
+ DBGE("fail to activate/deactivte package");
+ exit(1);
+ }
+
+ ret = ail_desktop_appinfo_modify_str(item->pkgid,
+ AIL_PROP_NAME_STR,
+ label, FALSE);
+ if (ret != AIL_ERROR_OK) {
+ DBGE("fail to activate/deactivte package");
+ exit(1);
+ }
+ free(label);
+ }
+
+ ret = ail_desktop_appinfo_modify_bool(item->pkgid, AIL_PROP_X_SLP_ENABLED_BOOL, val, TRUE);
+
+ if (ret < 0) {
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_FAIL_EVENT_STR);
+ DBGE("COMM_REQ_TO_ACTIVATOR failed\n");
+ exit(1);
+ }
+
+ __pm_send_signal(PKGMGR_INSTALLER_UPGRADE_EVENT_STR, item->pkg_type, item->pkgid, PKGMGR_INSTALLER_END_KEY_STR, PKGMGR_INSTALLER_OK_EVENT_STR);
+ } else { /* in case of package */
+ SECURE_LOGD("(De)activate PKG[pkgid=%s, val=%d]", item->pkgid, val);
+ if (val) {
+ const char *enable_argv[] = { "/usr/bin/rpm-backend", "-k", "change-state", "-i", item->pkgid, NULL };
+ __xsystem(enable_argv);
+ } else {
+ const char *disable_argv[] = { "/usr/bin/rpm-backend", "-k", "change-state", "-d", item->pkgid, NULL };
+ __xsystem(disable_argv);
+ }
+ }
+
+ _save_queue_status(item, "done");
+ exit(0);
+ break;
+
+ case -1: /* error */
+ fprintf(stderr, "Fail to execute fork()\n");
+ exit(1);
+ break;
+
+ default: /* parent */
+ DBG("parent exit\n");
+ _save_queue_status(item, "done");
+ break;
+ }
+ break;
+ case COMM_REQ_TO_MOVER:
+ case COMM_REQ_TO_CLEARER:
+ DBG("cleaner start");
+ _save_queue_status(item, "processing");
+ DBG("saved queue status. Now try fork()");
+ /*save pkg type and pkg name for future*/
+ x = (pos + num_of_backends - 1) % num_of_backends;
+ strncpy((ptr + x)->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1);
+ strncpy((ptr + x)->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy((ptr + x)->args, item->args, MAX_PKG_ARGS_LEN-1);
+ (ptr + x)->pid = fork();
+ DBG("child forked [%d]\n", (ptr + x)->pid);
+
+ switch ((ptr + x)->pid) {
+ case 0: /* child */
+ DBG("before run _get_backend_cmd()");
+ backend_cmd = _get_backend_cmd(item->pkg_type);
+ if (NULL == backend_cmd)
+ break;
+
+ DBG("Try to exec [%s][%s]", item->pkg_type,
+ backend_cmd);
+ fprintf(stdout, "Try to exec [%s][%s]\n",
+ item->pkg_type, backend_cmd);
+
+ /* Create args vector
+ * req_id + pkgid + args
+ *
+ * vector size = # of args +
+ *(req_id + pkgid + NULL termination = 3)
+ * Last value must be NULL for execv.
+ */
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+ ret_parse = g_shell_parse_argv(item->args,
+ &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ DBG("Failed to split args: %s", item->args);
+ DBG("messsage: %s", gerr->message);
+ exit(1);
+ }
+
+ /* Setup argument !!! */
+ /*char **args_vector =
+ calloc(argcp + 4, sizeof(char *)); */
+ char **args_vector = calloc(argcp + 1, sizeof(char *));
+ /*args_vector[0] = strdup(backend_cmd);
+ args_vector[1] = strdup(item->req_id);
+ args_vector[2] = strdup(item->pkgid); */
+ int arg_idx;
+ for (arg_idx = 0; arg_idx < argcp; arg_idx++) {
+ /* args_vector[arg_idx+3] = argvp[arg_idx]; */
+ args_vector[arg_idx] = argvp[arg_idx];
+ }
+
+ /* dbg */
+ /*for(arg_idx = 0; arg_idx < argcp+3; arg_idx++) { */
+ for (arg_idx = 0; arg_idx < argcp + 1; arg_idx++) {
+ DBG(">>>>>> args_vector[%d]=%s",
+ arg_idx, args_vector[arg_idx]);
+ }
+
+ /* Execute backend !!! */
+ ret = execv(backend_cmd, args_vector);
+
+ /* Code below: exec failure. Should not be happened! */
+ DBG(">>>>>> OOPS 2!!!");
+
+ /* g_strfreev(args_vector); *//* FIXME: causes error */
+
+ if (ret == -1) {
+ perror("fail to exec");
+ exit(1);
+ }
+ _save_queue_status(item, "done");
+ if (NULL != backend_cmd)
+ free(backend_cmd);
+ exit(0);
+ break;
+
+ case -1: /* error */
+ fprintf(stderr, "Fail to execute fork()\n");
+ exit(1);
+ break;
+
+ default: /* parent */
+ DBG("parent \n");
+ _save_queue_status(item, "done");
+ break;
+ }
+ break;
+
+ case COMM_REQ_GET_SIZE:
+ DBG("COMM_REQ_GET_SIZE pkgid = %s\n", item->pkgid);
+ _save_queue_status(item, "processing");
+ DBG("saved queue status. Now try fork()");
+ /*save pkg type and pkg name for future*/
+ x = (pos + num_of_backends - 1) % num_of_backends;
+ strncpy((ptr + x)->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1);
+ strncpy((ptr + x)->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy((ptr + x)->args, item->args, MAX_PKG_ARGS_LEN-1);
+ (ptr + x)->pid = fork();
+ DBG("child forked [%d]\n", (ptr + x)->pid);
+
+ switch ((ptr + x)->pid) {
+ case 0: /* child */
+ DBG("before run _get_backend_cmd()");
+ backend_cmd = strdup("/usr/bin/pkg_getsize");
+ if (NULL == backend_cmd)
+ break;
+
+ DBG("Try to exec [%s][%s]", item->pkg_type,
+ backend_cmd);
+ fprintf(stdout, "Try to exec [%s][%s]\n",
+ item->pkg_type, backend_cmd);
+
+ /* Create args vector
+ * req_id + pkgid + args
+ *
+ * vector size = # of args +
+ *(req_id + pkgid + NULL termination = 3)
+ * Last value must be NULL for execv.
+ */
+ gboolean ret_parse;
+ gint argcp;
+ gchar **argvp;
+ GError *gerr = NULL;
+ ret_parse = g_shell_parse_argv(item->args,
+ &argcp, &argvp, &gerr);
+ if (FALSE == ret_parse) {
+ DBG("Failed to split args: %s", item->args);
+ DBG("messsage: %s", gerr->message);
+ exit(1);
+ }
+
+ /* Setup argument !!! */
+ /*char **args_vector =
+ calloc(argcp + 4, sizeof(char *)); */
+ char **args_vector = calloc(argcp + 1, sizeof(char *));
+ /*args_vector[0] = strdup(backend_cmd);
+ args_vector[1] = strdup(item->req_id);
+ args_vector[2] = strdup(item->pkgid); */
+ int arg_idx;
+ for (arg_idx = 0; arg_idx < argcp; arg_idx++) {
+ /* args_vector[arg_idx+3] = argvp[arg_idx]; */
+ args_vector[arg_idx] = argvp[arg_idx];
+ }
+
+ /* dbg */
+ /*for(arg_idx = 0; arg_idx < argcp+3; arg_idx++) { */
+ for (arg_idx = 0; arg_idx < argcp + 1; arg_idx++) {
+ DBG(">>>>>> args_vector[%d]=%s",
+ arg_idx, args_vector[arg_idx]);
+ }
+
+ /* Execute backend !!! */
+ ret = execv(backend_cmd, args_vector);
+
+ /* Code below: exec failure. Should not be happened! */
+ DBG(">>>>>> OOPS 2!!!");
+
+ /* g_strfreev(args_vector); *//* FIXME: causes error */
+
+ if (ret == -1) {
+ perror("fail to exec");
+ exit(1);
+ }
+ _save_queue_status(item, "done");
+ if (NULL != backend_cmd)
+ free(backend_cmd);
+ exit(0);
+ break;
+
+ case -1: /* error */
+ fprintf(stderr, "Fail to execute fork()\n");
+ exit(1);
+ break;
+
+ default: /* parent */
+ DBG("parent \n");
+ _save_queue_status(item, "done");
+ break;
+ }
+ break;
+
+ case COMM_REQ_KILL_APP:
+ case COMM_REQ_CHECK_APP:
+ DBG("COMM_REQ_CHECK_APP start");
+ _save_queue_status(item, "processing");
+ DBG("saved queue status. Now try fork()");
+ /*save pkg type and pkg name for future*/
+ x = (pos + num_of_backends - 1) % num_of_backends;
+ strncpy((ptr + x)->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1);
+ strncpy((ptr + x)->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1);
+ strncpy((ptr + x)->args, item->args, MAX_PKG_ARGS_LEN-1);
+ (ptr + x)->pid = fork();
+ DBG("child forked [%d]\n", (ptr + x)->pid);
+
+ switch ((ptr + x)->pid) {
+ case 0: /* child */
+ DBG("child run parse argv()");
+
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(item->pkgid, &handle);
+ if (ret < 0) {
+ DBG("Failed to get handle\n");
+ exit(1);
+ }
+
+ if (item->req_type == COMM_REQ_KILL_APP) {
+ ret = pkgmgrinfo_appinfo_get_list(handle, PMSVC_UI_APP, __pkgcmd_app_cb, "kill");
+ if (ret < 0) {
+ DBG("pkgmgrinfo_appinfo_get_list() failed\n");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ exit(1);
+ }
+ } else if (item->req_type == COMM_REQ_CHECK_APP) {
+ ret = pkgmgrinfo_appinfo_get_list(handle, PMSVC_UI_APP, __pkgcmd_app_cb, "check");
+ if (ret < 0) {
+ DBG("pkgmgrinfo_appinfo_get_list() failed\n");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ exit(1);
+ }
+ }
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ _save_queue_status(item, "done");
+ exit(0);
+ break;
+
+ case -1: /* error */
+ fprintf(stderr, "Fail to execute fork()\n");
+ exit(1);
+ break;
+
+ default: /* parent */
+ DBG("parent exit\n");
+ _save_queue_status(item, "done");
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ free(item);
+
+ return FALSE;
+}
+
+#define IS_WHITESPACE(CHAR) \
+((CHAR == ' ' || CHAR == '\t' || CHAR == '\r' || CHAR == '\n') ? TRUE : FALSE)
+
+void _app_str_trim(char *input)
+{
+ char *trim_str = input;
+
+ if (input == NULL)
+ return;
+
+ while (*input != 0) {
+ if (!IS_WHITESPACE(*input)) {
+ *trim_str = *input;
+ trim_str++;
+ }
+ input++;
+ }
+
+ *trim_str = 0;
+ return;
+}
+
+char *_get_backend_cmd(char *type)
+{
+ FILE *fp = NULL;
+ char buffer[1024] = { 0 };
+ char *command = NULL;
+ int size = 0;
+ fp = fopen(PKG_CONF_PATH, "r");
+ if (fp == NULL) {
+ return NULL;
+ }
+
+ char *path = NULL;
+ while (fgets(buffer, 1024, fp) != NULL) {
+ if (buffer[0] == '#')
+ continue;
+
+ _app_str_trim(buffer);
+
+ if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
+ DBG("buffer [%s]", buffer);
+ path = path + strlen(PKG_BACKEND);
+ DBG("path [%s]", path);
+
+ command =
+ (char *)malloc(sizeof(char) * strlen(path) +
+ strlen(type) + 1);
+ if (command == NULL) {
+ fclose(fp);
+ return NULL;
+ }
+
+ size = strlen(path) + strlen(type) + 1;
+ snprintf(command, size, "%s%s", path, type);
+ command[strlen(path) + strlen(type)] = '\0';
+ DBG("command [%s]", command);
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return command;
+ }
+
+ memset(buffer, 0x00, 1024);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return NULL; /* cannot find proper command */
+}
+
+void _pm_desktop_file_monitor_init()
+{
+ int wd = 0;
+ int i = 0;
+ int ret = 0;
+
+ desktop_notifier.ifd = inotify_init();
+ if (desktop_notifier.ifd == -1) {
+ DBG("inotify_init error: %s\n", strerror(errno));
+ return;
+ }
+
+ ret = _pm_desktop_file_dir_search(paths, DESKTOP_FILE_DIRS_NUM);
+ if (ret) {
+ DBG("desktop file dir search failed\n");
+ return;
+ }
+
+ for (i = 0; i < DESKTOP_FILE_DIRS_NUM && paths[i].path; i++) {
+ DBG("Configuration file for desktop file monitoring [%s] is added\n", paths[i].path);
+ if (access(paths[i].path, R_OK) != 0) {
+ ecore_file_mkpath(paths[i].path);
+ if (chmod(paths[i].path, 0777) == -1) {
+ DBG("cannot chmod %s\n", paths[i].path);
+ }
+ }
+
+ wd = inotify_add_watch(desktop_notifier.ifd, paths[i].path,
+ IN_CLOSE_WRITE | IN_MOVED_TO | IN_DELETE);
+ if (wd == -1) {
+ DBG("inotify_add_watch error: %s\n", strerror(errno));
+ close(desktop_notifier.ifd);
+ return;
+ }
+
+ paths[i].wd = wd;
+ }
+
+ desktop_notifier.handler =
+ ecore_main_fd_handler_add(desktop_notifier.ifd, ECORE_FD_READ,
+ __directory_notify, NULL, NULL, NULL);
+ if (!desktop_notifier.handler) {
+ /* TODO: Handle me.. EXCEPTION!! */
+ DBG("cannot add handler for inotify\n");
+ }
+}
+
+void _pm_desktop_file_monitor_fini()
+{
+ register int i;
+
+ if (desktop_notifier.handler) {
+ ecore_main_fd_handler_del(desktop_notifier.handler);
+ desktop_notifier.handler = NULL;
+ }
+
+ for (i = 0; i < DESKTOP_FILE_DIRS_NUM; i++) {
+ if (paths[i].wd) {
+ if (inotify_rm_watch(desktop_notifier.ifd, paths[i].wd)
+ < 0) {
+ DBG("inotify remove watch failed\n");
+ }
+ paths[i].wd = 0;
+ }
+ }
+
+ if (desktop_notifier.ifd) {
+ close(desktop_notifier.ifd);
+ desktop_notifier.ifd = -1;
+ }
+}
+
+
+int _pm_desktop_file_dir_search(pm_inotify_paths *paths, int number)
+{
+ char *buf = NULL;
+ char *noti_dir = NULL;
+ char *saveptr = NULL;
+ int len = 0;
+ int i = 0;
+ int fd = -1;
+ int read_size = 0;
+
+ fd = open(DESKTOP_FILE_DIRS, O_RDONLY);
+ if (fd < 0) {
+ DBG("Failed to open %s\n", DESKTOP_FILE_DIRS);
+ return -EFAULT;
+ }
+
+ if (ioctl(fd, FIONREAD, &read_size) < 0) {
+ DBG("Failed to get a size of %s file.\n", DESKTOP_FILE_DIRS);
+ close(fd);
+ return -EFAULT;
+ }
+
+ if (read_size <= 0) {
+ DBG("Buffer is not ready.\n");
+ close(fd);
+ return -EFAULT;
+ }
+
+ buf = calloc(1, read_size+1);
+ if (!buf) {
+ DBG("Failed to allocate heap.\n");
+ close(fd);
+ return -EFAULT;
+ }
+
+ len = read(fd, buf, read_size);
+ if (len < 0) {
+ DBG("Failed to read.\n");
+ close(fd);
+ free(buf);
+ return -EFAULT;
+ }
+
+ buf[len] = 0;
+
+ noti_dir = strtok_r(buf, "\n", &saveptr);
+ if (!noti_dir) {
+ DBG("Failed to strtok for %s.\n", buf);
+ close(fd);
+ free(buf);
+ return -EFAULT;
+ }
+
+ do {
+ char *begin;
+
+ begin = noti_dir;
+ while (*begin != 0) {
+ if (isspace(*begin))
+ begin++;
+ else
+ break;
+ }
+ if (*begin == '#' || *begin == 0) {
+ noti_dir = strtok_r(NULL, "\n", &saveptr);
+ continue;
+ }
+
+ paths[i].path = strdup(begin);
+ noti_dir = strtok_r(NULL, "\n", &saveptr);
+ i++;
+ } while (number > i && noti_dir);
+
+ paths[i].path = NULL;
+ close(fd);
+ free(buf);
+
+ return EXIT_SUCCESS;
+}
+
+/**< Called before main loop */
+int app_create(void *user_data)
+{
+ /* printf("called app_create\n"); */
+ return 0;
+}
+
+/**< Called after main loop */
+int app_terminate(void *user_data)
+{
+ /* printf("called app_terminate\n"); */
+ return 0;
+}
+
+/**< Called when every window goes back */
+int app_pause(void *user_data)
+{
+ /* printf("called app_pause\n"); */
+ return 0;
+}
+
+/**< Called when any window comes on top */
+int app_resume(void *user_data)
+{
+ /* printf("called app_resume\n"); */
+ return 0;
+}
+
+/**< Called at the first idler*/
+int app_reset(bundle *b, void *user_data)
+{
+ /* printf("called app_reset\n"); */
+ return 0;
+}
+
+int __set_attr_app_info_db()
+{
+ ssize_t r;
+ char *buf;
+ size_t len;
+ const char* app_info_label = "ail::db";
+ const char* app_info_path = "/opt/dbspace/.app_info.db-journal";
+
+ r = lgetxattr (app_info_path, "security.SMACK64", NULL, 0);
+ if (r == -1) {
+ DBG("get smack attr len error(%d)", errno);
+ return -1;
+ }
+
+ len = r;
+ buf = malloc(len);
+ if (buf == NULL) {
+ DBG("malloc fail");
+ return -1;
+ }
+
+ r = lgetxattr (app_info_path, "security.SMACK64", buf, len);
+ if (r == -1) {
+ DBG("get smack attr error(%d)", errno);
+ free(buf);
+ return -1;
+ }
+
+ if (len != (size_t) r) {
+ DBG("unexpected size(%zu/%zd)", len, r);
+ free(buf);
+ return -1;
+ }
+
+ if(strncmp(buf, app_info_label, len) != 0) {
+ DBG("wrong smack label(%s) for app info db. lable need to be set right lable", buf);
+
+ if(lsetxattr(app_info_path, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ DBG("error(%d) in setting smack label",errno);
+ }
+ }
+
+ free(buf);
+
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ FILE *fp_status = NULL;
+ char buf[32] = { 0, };
+ pid_t pid;
+ char *backend_cmd = NULL;
+ char *backend_name = NULL;
+ backend_info *ptr = NULL;
+ int r;
+
+ ecore_init();
+
+ DBG("server start");
+
+ /* check smack label of app info db.
+ This is for case that journal file is not exist at booting time */
+ __set_attr_app_info_db();
+
+ if (argv[1]) {
+ if (strcmp(argv[1], "init") == 0) {
+ /* if current status is "processing",
+ execute related backend with '-r' option */
+ if (!(fp_status = fopen(STATUS_FILE, "r")))
+ return 0; /*if file is not exist, terminated. */
+
+ fgets(buf, 32, fp_status);
+ /* if processing <-- unintended termination */
+ if (strcmp(buf, "processing") == 0) {
+ pid = fork();
+
+ if (pid == 0) { /* child */
+ fgets(buf, 32, fp_status);
+ backend_cmd = _get_backend_cmd(buf);
+ if (!backend_cmd) { /* if NULL, */
+ DBG("fail to get"
+ " backend command");
+ goto err;
+ }
+ backend_name =
+ strrchr(backend_cmd, '/');
+
+ execl(backend_cmd, backend_name, "-r",
+ NULL);
+ if (backend_cmd)
+ free(backend_cmd);
+ fprintf(fp_status, " ");
+ err:
+ fclose(fp_status);
+ exit(13);
+ } else if (pid < 0) { /* error */
+ DBG("fork fail");
+ fclose(fp_status);
+ return 0;
+ } else { /* parent */
+
+ DBG("parent end\n");
+ fprintf(fp_status, " ");
+ fclose(fp_status);
+ return 0;
+ }
+ }
+ }
+ }
+
+ r = _pm_queue_init();
+ if (r) {
+ DBG("Queue Initialization Failed\n");
+ return -1;
+ }
+
+ /*Initialize inotify to monitor desktop file updates */
+/* _pm_desktop_file_monitor_init(); */
+
+ /*Allocate memory for holding pid, pkgtype and pkgid*/
+ ptr = (backend_info*)calloc(num_of_backends, sizeof(backend_info));
+ if (ptr == NULL) {
+ DBG("Malloc Failed\n");
+ return -1;
+ }
+ memset(ptr, '\0', num_of_backends * sizeof(backend_info));
+ begin = ptr;
+
+ /* init internationalization */
+ r = appcore_set_i18n(PACKAGE, LOCALEDIR);
+ if (r)
+ return -1;
+
+ g_type_init();
+ mainloop = g_main_loop_new(NULL, FALSE);
+ ecore_main_loop_glib_integrate();
+
+ struct appdata ad;
+ struct appcore_ops ops;
+ ops.create = app_create;
+ ops.terminate = app_terminate;
+ ops.pause = app_pause;
+ ops.resume = app_resume;
+ ops.reset = app_reset;
+ ops.data = &ad;
+
+ DBG("Main loop is created.");
+
+ PkgMgrObject *pkg_mgr;
+ pkg_mgr = g_object_new(PKG_MGR_TYPE_OBJECT, NULL);
+ pkg_mgr_set_request_callback(pkg_mgr, req_cb, &ad);
+ DBG("pkg_mgr object is created, and request callback is registered.");
+
+/* g_main_loop_run(mainloop); */
+ appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+
+ DBG("Quit main loop.");
+/* _pm_desktop_file_monitor_fini(); */
+ _pm_queue_final();
+ /*Free backend info */
+ if (begin) {
+ free(begin);
+ begin = NULL;
+ }
+
+ /* check smack label of app info db.
+ This is for case that journal is recreated internally at sqlite lib */
+ __set_attr_app_info_db();
+
+ DBG("package manager server terminated.");
+
+ return 0;
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "pkgmgr-server.h"
+#include "pm-queue.h"
+
+#define BACKEND_INFO_DIR "/usr/etc/package-manager/backend"
+
+static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg *item);
+static void __update_head_from_pkgtype(pm_queue_data *data);
+static int __entry_exist(char *backend);
+static int __is_pkg_supported(char *pkgtype);
+
+queue_info_map *start = NULL;
+int entries = 0;
+int slot = 0;
+int num_of_backends = 0;
+
+/*Function to check whether a particular package type
+is supported or not. It parses the queue info map
+to get the information.
+It will prevent the accidental hanging of server.
+Returns 1 if found.*/
+static int __is_pkg_supported(char *pkgtype)
+{
+ queue_info_map *ptr = NULL;
+ ptr = start;
+ int i = 0;
+ /*
+ If package type is eflwgt then return true as there is no separate backend for eflwgt.
+ It is handled by efltpk backend.
+ */
+ if(!strcmp(pkgtype,"eflwgt" ))
+ return 1;
+
+ for(i = 0; i < entries; i++)
+ {
+ if (!strncmp(ptr->pkgtype, pkgtype, MAX_PKG_TYPE_LEN))
+ return 1;
+ else {
+ ptr++;
+ continue;
+ }
+ }
+ return 0;
+}
+
+/*tells whether a particular backend exists in the
+* info map or not.
+* on Success it return the queue slot of the already present entry
+* on Failure -1 is returned*/
+static int __entry_exist(char *backend)
+{
+ queue_info_map *ptr = NULL;
+ ptr = start;
+ int i = 0;
+ for(i = 0; i < entries; i++)
+ {
+ if (!strncmp(ptr->backend, backend, MAX_PKG_NAME_LEN))
+ return ptr->queue_slot;
+ else {
+ ptr++;
+ continue;
+ }
+ }
+ return -1;
+}
+
+/*In case of first push, it updates the queue head
+and copies it to all duplicate entries in queue info map*/
+static void __update_head_from_pkgtype(pm_queue_data *data)
+{
+ queue_info_map *ptr = NULL;
+ ptr = start;
+ int slot = -1;
+ int i = 0;
+ for(i = 0; i < entries; i++)
+ {
+ if (!strncmp(ptr->pkgtype, data->msg->pkg_type, MAX_PKG_TYPE_LEN)) {
+ ptr->head = data;
+ slot = ptr->queue_slot;
+ }
+ else {
+ ptr++;
+ continue;
+ }
+ }
+ /*update head for each duplicate entry*/
+ ptr = start;
+ for(i = 0; i < entries; i++)
+ {
+ if(ptr->queue_slot == slot && !ptr->head) {
+ ptr->head = data;
+ }
+ ptr++;
+ }
+ return;
+}
+
+/*Gets the queue head based on pkg type*/
+static pm_queue_data *__get_head_from_pkgtype(pm_dbus_msg *item)
+{
+ queue_info_map *ptr = NULL;
+ ptr = start;
+ int i = 0;
+ for(i = 0; i < entries; i++)
+ {
+ if (!strncmp(ptr->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN))
+ return ptr->head;
+ else {
+ ptr++;
+ continue;
+ }
+ }
+ return NULL;
+
+}
+
+int _pm_queue_init()
+{
+ /*Find the num of backends currently supported and initialize
+ that many queues. It is dynamically determined.*/
+ struct dirent **namelist;
+ struct stat fileinfo;
+ queue_info_map *ptr = NULL;
+ int n = 0;
+ int c = 0;
+ int i = 0;
+ int ret = 0;
+ char abs_filename[MAX_PKG_NAME_LEN] = {'\0'};
+ char buf[MAX_PKG_NAME_LEN] = {'\0'};
+ n = scandir(BACKEND_INFO_DIR, &namelist, NULL, alphasort);
+ if (n < 0) {
+ perror("scandir");
+ return -1;
+ }
+ i = n;
+ /*Find number of backends (symlinks + executables)
+ The /usr/etc/package-manager/backend dir should not conatin
+ any other file except the backends.*/
+ while(n--)
+ {
+ if(!strcmp(namelist[n]->d_name, ".") ||
+ !strcmp(namelist[n]->d_name, ".."))
+ continue;
+ snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s",
+ BACKEND_INFO_DIR, namelist[n]->d_name);
+ if (lstat(abs_filename, &fileinfo)) {
+ perror("lstat");
+ continue;
+ }
+ if (S_ISDIR(fileinfo.st_mode))
+ continue;
+ c++;
+ memset(abs_filename, 0x00, MAX_PKG_NAME_LEN);
+ }
+ /*Add entries to info map.*/
+ ptr = (queue_info_map*)calloc(c , sizeof(queue_info_map));
+ memset(ptr, '\0', c * sizeof(queue_info_map));
+ start = ptr;
+ for(n = 0; n < c ; n++)
+ {
+ ptr->backend[0] = '\0';
+ ptr->head = NULL;
+ ptr->queue_slot = -2;/*-1 can be error return*/
+ ptr->pkgtype[0] = '\0';
+ ptr++;
+ }
+ n = i;
+ ptr = start;
+ while(n--)
+ {
+ if(!strcmp(namelist[n]->d_name, ".") ||
+ !strcmp(namelist[n]->d_name, ".."))
+ continue;
+ snprintf(abs_filename, MAX_PKG_NAME_LEN, "%s/%s",
+ BACKEND_INFO_DIR, namelist[n]->d_name);
+ if (lstat(abs_filename, &fileinfo) < 0) {
+ perror(abs_filename);
+ return -1;
+ }
+ if (S_ISDIR(fileinfo.st_mode))
+ continue;
+ /*Found backend*/
+ if (S_ISLNK(fileinfo.st_mode)) {
+ /*found a symlink*/
+ ret = readlink(abs_filename, buf, MAX_PKG_NAME_LEN - 1);
+ if (ret == -1) {
+ perror("readlink");
+ return -1;
+ }
+ buf[ret] = '\0';
+ }
+ /*executable*/
+ else {
+ strncpy(buf, abs_filename, MAX_PKG_NAME_LEN - 1);
+ }
+ ret = __entry_exist(buf);
+ if (ret == -1) {
+ strncpy(ptr->backend, buf, MAX_PKG_NAME_LEN - 1);
+ strncpy(ptr->pkgtype, namelist[n]->d_name, MAX_PKG_TYPE_LEN - 1);
+ ptr->queue_slot = slot;
+ ptr->head = NULL;
+ entries++;
+ slot++;
+ ptr++;
+ }
+ else {
+ strncpy(ptr->backend, buf, MAX_PKG_NAME_LEN - 1);
+ strncpy(ptr->pkgtype, namelist[n]->d_name, MAX_PKG_TYPE_LEN - 1);
+ ptr->queue_slot = ret;
+ ptr->head = NULL;
+ entries++;
+ ptr++;
+ }
+ free(namelist[n]);
+ memset(buf, 0x00, MAX_PKG_NAME_LEN);
+ continue;
+ }
+ free(namelist);
+ num_of_backends = slot;
+#ifdef DEBUG_INFO
+ /*Debug info*/
+ printf("Queue Info Map\n");
+ printf("Number of Backends is %d\n", num_of_backends);
+ printf("Number of Entries is %d\n", entries);
+ printf("Backend\tType\tSlot\tHead\n");
+ ptr = start;
+ for(n = 0; n < entries; n++)
+ {
+ printf("%s\t%s\t%d\t%p\n", ptr->backend, ptr->pkgtype, ptr->queue_slot, ptr->head);
+ ptr++;
+ }
+#endif
+ return 0;
+}
+
+int _pm_queue_push(pm_dbus_msg *item)
+{
+ pm_queue_data *data = NULL;
+ pm_queue_data *cur = NULL;
+ pm_queue_data *tmp = NULL;
+ int ret = 0;
+ ret = __is_pkg_supported(item->pkg_type);
+ if (ret == 0)
+ return -1;
+
+ cur = __get_head_from_pkgtype(item);
+ tmp = cur;
+
+ data = _add_node();
+ if (!data) { /* fail to allocate mem */
+ fprintf(stderr, "Fail to allocate memory\n");
+ return -1;
+ }
+
+ strncpy(data->msg->req_id, item->req_id, strlen(item->req_id));
+ data->msg->req_type = item->req_type;
+ strncpy(data->msg->pkg_type, item->pkg_type, strlen(item->pkg_type));
+ strncpy(data->msg->pkgid, item->pkgid, strlen(item->pkgid));
+ strncpy(data->msg->args, item->args, strlen(item->args));
+ strncpy(data->msg->cookie, item->cookie, strlen(item->cookie));
+
+ data->next = NULL;
+
+ if (cur == NULL) {
+ /* first push */
+ cur = data;
+ __update_head_from_pkgtype(data);
+ }
+ else {
+ while (tmp->next)
+ tmp = tmp->next;
+
+ tmp->next = data;
+ }
+ return 0;
+}
+
+/*pop request from queue slot "position" */
+pm_dbus_msg *_pm_queue_pop(int position)
+{
+ pm_dbus_msg *ret;
+ pm_queue_data *cur = NULL;
+ pm_queue_data *saveptr = NULL;
+ queue_info_map *ptr = start;
+ int i = 0;
+
+ ret = (pm_dbus_msg *) malloc(sizeof(pm_dbus_msg));
+ if (!ret) {
+ fprintf(stderr, "Mem alloc error\n");
+ return NULL;
+ }
+ memset(ret, 0x00, sizeof(pm_dbus_msg));
+
+ for(i = 0; i < entries; i++)
+ {
+ if (ptr->queue_slot == position) {
+ cur = ptr->head;
+ break;
+ }
+ ptr++;
+ }
+
+ if (!cur) { /* queue is empty */
+ ret->req_type = -1;
+ return ret;
+ }
+
+ strncpy(ret->req_id, cur->msg->req_id, strlen(cur->msg->req_id));
+ ret->req_type = cur->msg->req_type;
+ strncpy(ret->pkg_type, cur->msg->pkg_type, strlen(cur->msg->pkg_type));
+ strncpy(ret->pkgid, cur->msg->pkgid, strlen(cur->msg->pkgid));
+ strncpy(ret->args, cur->msg->args, strlen(cur->msg->args));
+ strncpy(ret->cookie, cur->msg->cookie, strlen(cur->msg->cookie));
+
+ ptr->head = cur->next;
+ saveptr = ptr->head;
+ cur->next = NULL;
+ free(cur->msg);
+ free(cur);
+ /*update head for each duplicate queue entry*/
+ ptr = start;
+ for(i = 0; i < entries; i++)
+ {
+ if(ptr->queue_slot == position) {
+ ptr->head = saveptr;
+ }
+ ptr++;
+ }
+ return ret;
+}
+
+/*populate an array of all queue heads and delete them one by one*/
+void _pm_queue_final()
+{
+ int c = 0;
+ int i = 0;
+ int slot = -1;
+ pm_queue_data *cur = NULL;
+ pm_queue_data *tail = NULL;
+ pm_queue_data *prev = NULL;
+ pm_queue_data *head[MAX_QUEUE_NUM] = {NULL,};
+ queue_info_map *ptr = NULL;
+ ptr = start;
+
+ for(i = 0; i < num_of_backends; i++)
+ {
+ head[i] = NULL;
+ }
+
+ for(i = 0; i < entries; i++)
+ {
+ if (ptr->queue_slot <= slot) {
+ ptr++;
+ continue;
+ }
+ else {
+ head[c] = ptr->head;
+ slot = ptr->queue_slot;
+ c++;
+ ptr++;
+ }
+ }
+
+ c = 0;
+ while(c < num_of_backends) {
+ if (!head[c]) { /* in case of head is NULL */
+ fprintf(stderr, "queue is NULL\n");
+ c = c + 1;
+ continue;
+ }
+
+ while (head[c]->next) {
+ cur = head[c]->next;
+
+ while (cur->next) {
+ prev = cur;
+ cur = cur->next;
+ }
+
+ tail = cur;
+
+ free(tail->msg);
+ free(tail);
+ prev->next = NULL;
+ }
+
+ free(head[c]->msg);
+ free(head[c]);
+
+ head[c] = NULL;
+ c = c + 1;
+ }
+ /*Free the info map*/
+ if (start) {
+ free(start);
+ start = NULL;
+ }
+}
+
+pm_queue_data *_add_node()
+{
+ pm_queue_data *newnode = NULL;
+
+ newnode = (pm_queue_data *) malloc(sizeof(pm_queue_data));
+ if (!newnode) { /* if NULL */
+ fprintf(stderr, "Mem alloc error\n");
+ return NULL;
+ }
+ memset(newnode, 0x00, sizeof(pm_queue_data));
+
+ newnode->msg = (pm_dbus_msg *) malloc(sizeof(pm_dbus_msg));
+ if (!newnode->msg) {
+ fprintf(stderr, "Mem alloc error\n");
+ free(newnode);
+ return NULL;
+ }
+ memset(newnode->msg, 0x00, sizeof(pm_dbus_msg));
+
+ return newnode;
+}
+
+void _pm_queue_delete(pm_dbus_msg *item)
+{
+ /* Assume that pacakge name is unique */
+ pm_queue_data *cur = NULL;
+ pm_queue_data *prev = NULL;
+ cur = __get_head_from_pkgtype(item);
+ prev = cur;
+ if (cur) {
+ while (cur->next) {
+ if (!strcmp(item->pkgid, cur->msg->pkgid)) {
+ prev->next = cur->next;
+ free(cur->msg);
+ free(cur);
+ break;
+ }
+ prev = cur;
+ cur = cur->next;
+ }
+ }
+}
+
+void _save_queue_status(pm_dbus_msg *item, char *status)
+{
+ FILE *fp_status = NULL;
+
+ fp_status = fopen(STATUS_FILE, "w"); /* overwrite always */
+ if (!fp_status) {
+ fprintf(stderr, "Can't open status file:%s\n", STATUS_FILE);
+ return;
+ }
+
+ fprintf(fp_status, "%s\n", status);
+ fprintf(fp_status, "%s\n", item->pkg_type);
+
+ fsync(fp_status->_fileno);
+ fclose(fp_status);
+}
+
+void _print_queue(int position)
+{
+ pm_queue_data *cur = NULL;
+ queue_info_map *ptr = start;
+ int i = 0;
+ for(i =0; i < entries; i++)
+ {
+ if (ptr->queue_slot == position) {
+ cur = ptr->head;
+ break;
+ }
+ ptr++;
+ }
+ int index = 1;
+ if (!cur) {
+ return;
+ }
+
+ while (cur) {
+ index++;
+ cur = cur->next;
+ }
+}
--- /dev/null
+[Unit]
+Description=SLP Package Manager
+
+[Service]
+BusName=com.samsung.slp.pkgmgr
+ExecStart=/usr/bin/pkgmgr-server
\ No newline at end of file
--- /dev/null
+
+#export CFLAGS=""
+#export LDFLAGS=""
+
+cd `dirname $0`
+
+PREFIX=/usr
+
+rm -rf cmake_tmp
+mkdir -p cmake_tmp
+cd cmake_tmp
+
+CFLAGS="${CFLAGS} -g" LDFLAGS="${LDFLAGS}" cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_BUILD_TYPE=Debug &&
+make &&
+mkdir -p destdir &&
+make install DESTDIR=destdir
+
--- /dev/null
+# Test executables
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
+
+#Verbose
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 ail libxml-2.0 bundle pkgmgr-info pkgmgr-parser vconf iniparser)
+FOREACH(flag ${pkgs_test_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+pkg_check_modules(toolpkgs REQUIRED appcore-efl dlog bundle glib-2.0 pkgmgr-info pkgmgr-parser vconf iniparser)
+FOREACH(flag ${libpkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+add_executable(pkgcmd
+ pkg_cmd.c)
+target_link_libraries(pkgcmd pkgmgr-client ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkgcmd DESTINATION bin)
+
+add_executable(pkginfo
+ pkg_info.c)
+target_link_libraries(pkginfo pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkginfo DESTINATION bin)
+
+add_executable(pkg_getsize
+ pkg_getsize.c)
+target_link_libraries(pkg_getsize pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkg_getsize DESTINATION bin)
+
+add_executable(pkg_initdb
+ pkg_initdb.c)
+target_link_libraries(pkg_initdb ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkg_initdb DESTINATION bin)
+
+add_executable(pkg_fota
+ pkg_fota.c)
+target_link_libraries(pkg_fota ${pkgs_test_LDFLAGS})
+INSTALL(TARGETS pkg_fota DESTINATION bin)
+
+add_executable(pkgmgr-install pkgmgr-install.c)
+target_link_libraries(pkgmgr-install pkgmgr-client pkgmgr-info ${toolpkgs_LDFLAGS})
+install(TARGETS pkgmgr-install DESTINATION bin)
+
+configure_file(com.samsung.pkgmgr-install.xml.in ${CMAKE_BINARY_DIR}/com.samsung.pkgmgr-install.xml @ONLY)
+install(FILES ${CMAKE_BINARY_DIR}/com.samsung.pkgmgr-install.xml DESTINATION /usr/share/packages/)
+
+configure_file(pkg_recovery.sh.in pkg_recovery.sh @ONLY)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkg_recovery.sh DESTINATION /usr/etc/package-manager/)
+
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.wac.xml DESTINATION /usr/share/mime/packages/)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.tpk.xml DESTINATION /usr/share/mime/packages/)
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="com.samsung.pkgmgr-install" version="0.0.2" install-location="internal-only" nodisplay-setting="true">
+ <label>pkgmgr-install</label>
+ <author email="sewook7.park@samsung.com" href="www.samsung.com">Sewook Park</author>
+ <description>pkgmgr-install</description>
+ <ui-application appid="com.samsung.pkgmgr-install" exec="/usr/bin/pkgmgr-install" nodisplay="true" multiple="false" type="capp" taskmanage="false">
+ <label>pkgmgr-install</label>
+ <application-service>
+ <operation name="http://tizen.org/appcontrol/operation/view"/>
+ <mime name="application/widget"/>
+ <mime name="application/vnd.wac.widget-sharing"/>
+ <mime name="application/x-rpm"/>
+ <mime name="application/x-redhat-package-manager"/>
+ <mime name="application/vnd.tizen.package"/>
+ </application-service>
+ </ui-application>
+</manifest>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/vnd.tizen.package">
+ <!--Created automatically by update-mime-database. DO NOT EDIT!-->
+ <comment>Tizen Package</comment>
+ <acronym>TPK</acronym>
+ <expanded-acronym>Tizen PacKage</expanded-acronym>
+ <glob pattern="*.tpk"/>
+ </mime-type>
+</mime-info>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/widget">
+ <!--Created automatically by update-mime-database. DO NOT EDIT!-->
+ <comment>WAC Widget</comment>
+ <comment xml:lang="ko">WAC 위젯</comment>
+ <acronym>WGT</acronym>
+ <expanded-acronym>wac WidGeT</expanded-acronym>
+ <glob pattern="*.wgt"/>
+ <alias type="application/vnd.wac.widget-sharing"/>
+ </mime-type>
+</mime-info>
--- /dev/null
+
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <getopt.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <glib.h>
+#include <ail.h>
+#include <glib-object.h>
+#include <pkgmgr-info.h>
+#include "package-manager.h"
+#include "package-manager-types.h"
+
+#define PKG_TOOL_VERSION "0.1"
+#define APP_INSTALLATION_PATH_RW "/opt/usr/apps"
+
+static int __process_request();
+static void __print_usage();
+static int __is_authorized();
+static int __is_app_installed(char *pkgid);
+static void __print_pkg_info(pkgmgr_info * pkg_info);
+static int __return_cb(int req_id, const char *pkg_type, const char *pkgid,
+ const char *key, const char *val, const void *pmsg,
+ void *data);
+static int __convert_to_absolute_path(char *path);
+
+/* Supported options */
+const char *short_options = "iurmcgCkaADL:lsd:p:t:n:T:S:qh";
+const struct option long_options[] = {
+ {"install", 0, NULL, 'i'},
+ {"uninstall", 0, NULL, 'u'},
+ {"reinstall", 0, NULL, 'r'},
+ {"move", 0, NULL, 'm'},
+ {"clear", 0, NULL, 'c'},
+ {"getsize", 0, NULL, 'g'},
+ {"activate", 0, NULL, 'A'},
+ {"deactivate", 0, NULL, 'D'},
+ {"activate with Label", 1, NULL, 'L'},
+ {"check", 0, NULL, 'C'},
+ {"kill", 0, NULL, 'k'},
+ {"app-path", 0, NULL, 'a'},
+ {"list", 0, NULL, 'l'},
+ {"show", 0, NULL, 's'},
+ {"descriptor", 1, NULL, 'd'},
+ {"package-path", 1, NULL, 'p'},
+ {"package-type", 1, NULL, 't'},
+ {"package-name", 1, NULL, 'n'},
+ {"move-type", 1, NULL, 'T'},
+ {"getsize-type", 1, NULL, 'T'},
+ {"csc", 1, NULL, 'S'},
+ {"quiet", 0, NULL, 'q'},
+ {"help", 0, NULL, 'h'},
+ {0, 0, 0, 0} /* sentinel */
+};
+
+enum pm_tool_request_e {
+ INSTALL_REQ = 1,
+ UNINSTALL_REQ,
+ REINSTALL_REQ,
+ CSC_REQ,
+ GETSIZE_REQ,
+ CLEAR_REQ,
+ MOVE_REQ,
+ ACTIVATE_REQ,
+ DEACTIVATE_REQ,
+ APPPATH_REQ,
+ CHECKAPP_REQ,
+ KILLAPP_REQ,
+ LIST_REQ,
+ SHOW_REQ,
+ HELP_REQ
+};
+typedef enum pm_tool_request_e req_type;
+
+struct pm_tool_args_t {
+ req_type request;
+ char pkg_path[PKG_NAME_STRING_LEN_MAX];
+ char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
+ char des_path[PKG_NAME_STRING_LEN_MAX];
+ char label[PKG_NAME_STRING_LEN_MAX];
+ int quiet;
+ int type;
+ int result;
+};
+typedef struct pm_tool_args_t pm_tool_args;
+pm_tool_args data;
+
+static GMainLoop *main_loop = NULL;
+
+static void __error_no_to_string(int errnumber, char **errstr)
+{
+ if (errstr == NULL)
+ return;
+ switch (errnumber) {
+ case PKGCMD_ERR_PACKAGE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_INVALID:
+ *errstr = PKGCMD_ERR_PACKAGE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_LOWER_VERSION:
+ *errstr = PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR;
+ break;
+ case PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_MANIFEST_INVALID:
+ *errstr = PKGCMD_ERR_MANIFEST_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_NOT_FOUND:
+ *errstr = PKGCMD_ERR_CONFIG_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CONFIG_INVALID:
+ *errstr = PKGCMD_ERR_CONFIG_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_INVALID:
+ *errstr = PKGCMD_ERR_SIGNATURE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND:
+ *errstr = PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_INVALID:
+ *errstr = PKGCMD_ERR_CERTIFICATE_INVALID_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR;
+ break;
+ case PKGCMD_ERR_CERTIFICATE_EXPIRED:
+ *errstr = PKGCMD_ERR_CERTIFICATE_EXPIRED_STR;
+ break;
+ case PKGCMD_ERR_INVALID_PRIVILEGE:
+ *errstr = PKGCMD_ERR_INVALID_PRIVILEGE_STR;
+ break;
+ case PKGCMD_ERR_MENU_ICON_NOT_FOUND:
+ *errstr = PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR;
+ break;
+ case PKGCMD_ERR_FATAL_ERROR:
+ *errstr = PKGCMD_ERR_FATAL_ERROR_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_STORAGE:
+ *errstr = PKGCMD_ERR_OUT_OF_STORAGE_STR;
+ break;
+ case PKGCMD_ERR_OUT_OF_MEMORY:
+ *errstr = PKGCMD_ERR_OUT_OF_MEMORY_STR;
+ break;
+ case PKGCMD_ERR_ARGUMENT_INVALID:
+ *errstr = PKGCMD_ERR_ARGUMENT_INVALID_STR;
+ break;
+ default:
+ *errstr = PKGCMD_ERR_UNKNOWN_STR;
+ break;
+ }
+}
+
+static int __return_cb(int req_id, const char *pkg_type,
+ const char *pkgid, const char *key, const char *val,
+ const void *pmsg, void *priv_data)
+{
+ if (strncmp(key, "error", strlen("error")) == 0) {
+ int ret_val;
+ char delims[] = ":";
+ char *extra_str = NULL;
+ char *ret_result = NULL;
+
+ ret_val = atoi(val);
+ data.result = ret_val;
+
+ strtok(val, delims);
+ ret_result = strtok(NULL, delims);
+ if (ret_result){
+ extra_str = strdup(ret_result);
+ printf("__return_cb req_id[%d] pkg_type[%s] pkgid[%s] key[%s] val[%d] error message: %s\n",
+ req_id, pkg_type, pkgid, key, ret_val, extra_str);
+ free(extra_str);
+ }
+ else
+ printf("__return_cb req_id[%d] pkg_type[%s] pkgid[%s] key[%s] val[%d]\n",
+ req_id, pkg_type, pkgid, key, ret_val);
+ } else
+ printf("__return_cb req_id[%d] pkg_type[%s] "
+ "pkgid[%s] key[%s] val[%s]\n",
+ req_id, pkg_type, pkgid, key, val);
+
+ if (strncmp(key, "end", strlen("end")) == 0) {
+ if ((strncmp(val, "fail", strlen("fail")) == 0) && data.result == 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ }
+ g_main_loop_quit(main_loop);
+ }
+
+ return 0;
+}
+
+static int __convert_to_absolute_path(char *path)
+{
+ char abs[PKG_NAME_STRING_LEN_MAX] = {'\0'};
+ char temp[PKG_NAME_STRING_LEN_MAX] = {'\0'};
+ char *ptr = NULL;
+ if (path == NULL) {
+ printf("path is NULL\n");
+ return -1;
+ }
+ strncpy(temp, path, PKG_NAME_STRING_LEN_MAX - 1);
+ if (strchr(path, '/') == NULL) {
+ getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1);
+ if (abs[0] == '\0') {
+ printf("getcwd() failed\n");
+ return -1;
+ }
+ memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX);
+ snprintf(data.pkg_path, PKG_NAME_STRING_LEN_MAX - 1, "%s/%s", abs, temp);
+ return 0;
+ }
+ if (strncmp(path, "./", 2) == 0) {
+ ptr = temp;
+ getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1);
+ if (abs[0] == '\0') {
+ printf("getcwd() failed\n");
+ return -1;
+ }
+ ptr = ptr + 2;
+ memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX);
+ snprintf(data.pkg_path, PKG_NAME_STRING_LEN_MAX - 1, "%s/%s", abs, ptr);
+ return 0;
+ }
+ return 0;
+}
+
+static int __is_app_installed(char *pkgid)
+{
+#if 0
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str = NULL;
+ ret = ail_package_get_appinfo(pkgid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+ ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+//#else
+ pkgmgr_pkginfo_h handle;
+ int ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
+ if(ret < 0) {
+ printf("package is not in pkgmgr_info DB\n");
+ return -1;
+ } else
+ pkgmgr_pkginfo_destroy_pkginfo(handle);
+#endif
+
+ return 0;
+}
+
+static void __print_usage()
+{
+ printf("\nPackage Manager Tool Version: %s\n\n", PKG_TOOL_VERSION);
+ printf("-i, --install install the package\n");
+ printf("-u, --uninstall uninstall the package\n");
+ printf("-r, --reinstall reinstall the package\n");
+ printf("-c, --clear clear user data\n");
+ printf("-m, --move move package\n");
+ printf("-g, --getsize get size of given package\n");
+ printf("-T, --getsize-type get type [0 : total size /1: data size]\n");
+ printf("-l, --list display list of installed packages\n");
+ printf("-s, --show show detail package info\n");
+ printf("-a, --app-path show app installation path\n");
+ printf("-C, --check check if applications belonging to a package are running or not\n");
+ printf("-k, --kill terminate applications belonging to a package\n");
+ printf("-d, --descriptor provide descriptor path\n");
+ printf("-p, --package-path provide package path\n");
+ printf("-n, --package-name provide package name\n");
+ printf("-t, --package-type provide package type\n");
+ printf("-T, --move-type provide move type [0 : move to internal /1: move to external]\n");
+ printf("-q, --quiet quiet mode operation\n");
+ printf("-h, --help print this help\n\n");
+
+ printf("Usage: pkgcmd [options] (--quiet)\n");
+ printf("pkgcmd -i -t <pkg type> (-d <descriptor path>) -p <pkg path> (-q)\n");
+ printf("pkgcmd -u -n <pkgid> (-q)\n");
+ printf("pkgcmd -r -t <pkg type> -n <pkgid> \n");
+ printf("pkgcmd -l (-t <pkg type>) \n");
+ printf("pkgcmd -s -t <pkg type> -p <pkg path> (-q)\n");
+ printf("pkgcmd -s -t <pkg type> -n <pkg name> (-q)\n");
+ printf("pkgcmd -m -T <move type> -n <pkg name>\n\n");
+ printf("pkgcmd -g -T <getsize type> -n <pkgid> \n");
+ printf("pkgcmd -C -n <pkgid> \n");
+ printf("pkgcmd -k -n <pkgid> \n");
+
+ printf("Example:\n");
+ printf("pkgcmd -u -n com.samsung.calculator\n");
+ printf("pkgcmd -i -t rpm -p /mnt/nfs/com.samsung.calculator_0.1.2-95_armel.rpm\n");
+ printf("pkgcmd -r -t rpm -n com.samsung.calculator\n");
+ printf("pkgcmd -c -t rpm -n com.samsung.hello\n");
+ printf("pkgcmd -m -T 1 -n com.samsung.hello\n");
+ printf("pkgcmd -C -n com.samsung.hello\n");
+ printf("pkgcmd -k -n com.samsung.hello\n");
+ printf("pkgcmd -a\n");
+ printf("pkgcmd -a -t rpm -n com.samsung.hello\n");
+ printf("pkgcmd -l\n");
+ printf("pkgcmd -l -t tpk\n");
+ printf("pkgcmd -g -T 0 -n com.samsung.calculator\n");
+
+ exit(0);
+
+}
+
+static void __print_pkg_info(pkgmgr_info *pkg_info)
+{
+ char *temp = NULL;
+
+ temp = pkgmgr_info_get_string(pkg_info, "pkg_type");
+ if (temp) {
+ printf("pkg_type : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "pkgid");
+ if (temp) {
+ printf("pkgid : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "version");
+ if (temp) {
+ printf("version : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "pkg_vendor");
+ if (temp) {
+ printf("pkg_vendor : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "pkg_description");
+ if (temp) {
+ printf("pkg_description : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "pkg_mimetype");
+ if (temp) {
+ printf("pkg_mimetype : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "pkg_installed_path_package");
+ if (temp) {
+ printf("pkg_installed_path_package : %s\n", temp);
+ free(temp);
+ }
+
+ temp =
+ pkgmgr_info_get_string(pkg_info, "pkg_installed_path_descriptor");
+ if (temp) {
+ printf("pkg_installed_path_descriptor : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "category");
+ if (temp) {
+ printf("category : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "min_platform_version");
+ if (temp) {
+ printf("min_platform_version : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "visible");
+ if (temp) {
+ printf("visible : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "removable");
+ if (temp) {
+ printf("removable : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "installed_size");
+ if (temp) {
+ printf("installed_size : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "installed_time");
+ if (temp) {
+ printf("installed_time : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "data_size");
+ if (temp) {
+ printf("data_size : %s\n", temp);
+ free(temp);
+ }
+
+ temp = pkgmgr_info_get_string(pkg_info, "optional_id");
+ if (temp) {
+ printf("optional_id : %s\n", temp);
+ free(temp);
+ }
+}
+
+static int __pkgmgr_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *pkg_type = NULL;
+ char *pkg_version = NULL;
+ char *pkg_label = NULL;
+ char *pkg_rootpath = NULL;
+
+ ret = pkgmgr_pkginfo_get_pkgid(handle, &pkgid);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_pkgid\n");
+ return ret;
+ }
+ ret = pkgmgr_pkginfo_get_type(handle, &pkg_type);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_type\n");
+ return ret;
+ }
+ ret = pkgmgr_pkginfo_get_version(handle, &pkg_version);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_version\n");
+ return ret;
+ }
+ ret = pkgmgr_pkginfo_get_label(handle, &pkg_label);
+ if (ret == -1) {
+ printf("Failed to get pkgmgr_pkginfo_get_label\n");
+ return ret;
+ }
+ if (pkg_type && strcmp(pkg_type, "wgt") == 0)
+ {
+ char buf[1024] = {0};
+ ret = pkgmgrinfo_pkginfo_get_root_path(handle, &pkg_rootpath);
+ if (ret == -1) {
+ printf("pkgmgrinfo_pkginfo_get_root_path\n");
+ return ret;
+ }
+
+ snprintf(buf, 1023, "%s/author-signature.xml", pkg_rootpath);
+
+ if (access(buf, F_OK) == 0)
+ {
+ printf("pkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\tpkg_subtype [%s]\n", pkg_type, pkgid, pkg_label, pkg_version, "hybrid");
+ return ret;
+ }
+ }
+
+ printf("pkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\n", pkg_type, pkgid, pkg_label, pkg_version);
+
+ return ret;
+}
+
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ int size = 0;
+ char *pkgid;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ printf("pkgmgr_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, (pkgmgr_client *)user_data, NULL, pkgid, NULL, NULL, NULL);
+ if (ret < 0){
+ printf("pkgmgr_client_request_service Failed\n");
+ return -1;
+ }
+
+ printf("pkg[%s] size = %d\n", pkgid, ret);
+
+ return 0;
+}
+
+static int __process_request()
+{
+ int ret = -1;
+ int mode = PM_DEFAULT;
+ pkgmgr_client *pc = NULL;
+ char buf[1024] = {'\0'};
+ int pid = -1;
+ switch (data.request) {
+ case INSTALL_REQ:
+ if (data.pkg_type[0] == '\0' || data.pkg_path[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+ break;
+ }
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+ if (data.quiet == 0)
+ mode = PM_DEFAULT;
+ else
+ mode = PM_QUIET;
+ if (data.des_path[0] == '\0')
+ ret =
+ pkgmgr_client_install(pc, data.pkg_type, NULL,
+ data.pkg_path, NULL, mode,
+ __return_cb, pc);
+ else
+ ret =
+ pkgmgr_client_install(pc, data.pkg_type,
+ data.des_path, data.pkg_path,
+ NULL, mode, __return_cb, pc);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ if (access(data.pkg_path, F_OK) != 0)
+ data.result = PKGCMD_ERR_PACKAGE_NOT_FOUND;
+ break;
+ }
+ g_main_loop_run(main_loop);
+ ret = data.result;
+ break;
+
+ case UNINSTALL_REQ:
+ if (data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+ break;
+ }
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+ if (data.quiet == 0)
+ mode = PM_DEFAULT;
+ else
+ mode = PM_QUIET;
+
+ ret = __is_app_installed(data.pkgid);
+ if (ret == -1) {
+ printf("package is not installed\n");
+ break;
+ }
+
+ ret =
+ pkgmgr_client_uninstall(pc, data.pkg_type, data.pkgid,
+ mode, __return_cb, NULL);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ if (access(data.pkg_path, F_OK) != 0)
+ data.result = PKGCMD_ERR_PACKAGE_NOT_FOUND;
+ break;
+ }
+ g_main_loop_run(main_loop);
+ ret = data.result;
+ break;
+
+ case REINSTALL_REQ:
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+ break;
+ }
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ mode = PM_QUIET;
+ ret = pkgmgr_client_reinstall(pc, data.pkg_type, data.pkgid, NULL, mode, __return_cb, pc);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ if (access(data.pkg_path, F_OK) != 0)
+ data.result = PKGCMD_ERR_PACKAGE_NOT_FOUND;
+ break;
+ }
+ g_main_loop_run(main_loop);
+ ret = data.result;
+ break;
+
+ case CLEAR_REQ:
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ ret = -1;
+ break;
+ }
+ if (data.quiet == 0)
+ mode = PM_DEFAULT;
+ else
+ mode = PM_QUIET;
+ ret = __is_app_installed(data.pkgid);
+ if (ret == -1) {
+ printf("package is not installed\n");
+ break;
+ }
+ ret = pkgmgr_client_clear_user_data(pc, data.pkg_type,
+ data.pkgid, mode);
+ if (ret < 0)
+ break;
+ ret = data.result;
+ break;
+
+ case ACTIVATE_REQ:
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ if ( strcmp(data.pkg_type, "root") == 0 ) {
+ ret = pkgmgr_client_enable_pkg(data.pkgid);
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ ret = -1;
+ break;
+ }
+
+ if ( strcmp(data.pkg_type, "app") == 0 ) {
+ if (strlen(data.label) == 0) {
+ ret = pkgmgr_client_activate_app(pc, data.pkgid);
+ if (ret < 0)
+ break;
+ } else {
+ printf("label [%s]\n", data.label);
+ char *largv[3] = {NULL, };
+ largv[0] = "-l";
+ largv[1] = data.label;
+ ret = pkgmgr_client_activate_appv(pc, data.pkgid, largv);
+ if (ret < 0)
+ break;
+ }
+ } else {
+ ret = pkgmgr_client_activate(pc, data.pkg_type, data.pkgid);
+ if (ret < 0)
+ break;
+ }
+ ret = data.result;
+
+ break;
+
+
+ case DEACTIVATE_REQ:
+ if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ if ( strcmp(data.pkg_type, "root") == 0 ) {
+ ret = pkgmgr_client_disable_pkg(data.pkgid);
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ ret = -1;
+ break;
+ }
+
+ if ( strcmp(data.pkg_type, "app") == 0 ) {
+ ret = pkgmgr_client_deactivate_app(pc, data.pkgid);
+ if (ret < 0)
+ break;
+ } else {
+ ret = pkgmgr_client_deactivate(pc, data.pkg_type, data.pkgid);
+ if (ret < 0)
+ break;
+ }
+ ret = data.result;
+
+ break;
+
+ case MOVE_REQ:
+ if (data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ g_type_init();
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ ret = -1;
+ break;
+ }
+
+ ret = __is_app_installed(data.pkgid);
+ if (ret == -1) {
+ printf("package is not installed\n");
+ break;
+ }
+
+ ret = pkgmgr_client_move(pc, data.pkgid, data.type, __return_cb, NULL);
+
+ printf("pkg[%s] move result = %d\n", data.pkgid, ret);
+
+ if (ret < 0)
+ break;
+
+ g_main_loop_run(main_loop);
+
+ ret = data.result;
+ break;
+
+ case APPPATH_REQ:
+ if (data.pkg_type[0] == '\0' && data.pkgid[0] == '\0') {
+ printf("Tizen Application Installation Path: %s\n", APP_INSTALLATION_PATH_RW);
+ ret = 0;
+ break;
+ }
+ if ((data.pkg_type[0] == '\0') || (data.pkgid[0] == '\0')) {
+ printf("Use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+ if (strncmp(data.pkg_type, "rpm", PKG_TYPE_STRING_LEN_MAX - 1) == 0) {
+ snprintf(buf, 1023, "%s/%s", APP_INSTALLATION_PATH_RW, data.pkgid);
+ printf("Tizen Application Installation Path: %s\n", buf);
+ ret = 0;
+ break;
+ } else if (strncmp(data.pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX - 1) == 0) {
+ snprintf(buf, 1023, "%s/%s/res/wgt", APP_INSTALLATION_PATH_RW, data.pkgid);
+ printf("Tizen Application Installation Path: %s\n", buf);
+ ret = 0;
+ break;
+ } else if (strncmp(data.pkg_type, "tpk", PKG_TYPE_STRING_LEN_MAX - 1) == 0) {
+ snprintf(buf, 1023, "%s/%s", APP_INSTALLATION_PATH_RW, data.pkgid);
+ printf("Tizen Application Installation Path: %s\n", buf);
+ ret = 0;
+ break;
+ } else {
+ printf("Invalid package type.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+ break;
+
+ case KILLAPP_REQ:
+ case CHECKAPP_REQ:
+ if (data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (data.request == KILLAPP_REQ) {
+ ret = pkgmgr_client_request_service(PM_REQUEST_KILL_APP, NULL, pc, NULL, data.pkgid, NULL, NULL, &pid);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+ if (pid)
+ printf("Pkgid: %s is Terminated\n", data.pkgid);
+ else
+ printf("Pkgid: %s is already Terminated\n", data.pkgid);
+
+ } else if (data.request == CHECKAPP_REQ) {
+ ret = pkgmgr_client_request_service(PM_REQUEST_CHECK_APP, NULL, pc, NULL, data.pkgid, NULL, NULL, &pid);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (pid)
+ printf("Pkgid: %s is Running\n", data.pkgid);
+ else
+ printf("Pkgid: %s is Not Running\n", data.pkgid);
+ }
+ ret = data.result;
+ break;
+
+ case LIST_REQ:
+ if (data.pkg_type[0] == '\0') {
+ ret = pkgmgr_pkginfo_get_list(__pkgmgr_list_cb, NULL);
+ if (ret == -1) {
+ printf("Failed to get package list\n");
+ break;
+ }
+ break;
+ } else {
+ pkgmgrinfo_pkginfo_filter_h handle;
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret == -1) {
+ printf("Failed to get package filter handle\n");
+ break;
+ }
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, data.pkg_type);
+ if (ret == -1) {
+ printf("Failed to add package type filter\n");
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ break;
+ }
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgmgr_list_cb, NULL);
+ if (ret == -1) {
+ printf("Failed to get package filter list\n");
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ break;
+ }
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ break;
+ }
+
+ case SHOW_REQ:
+ if (data.pkgid[0] != '\0') {
+ pkgmgr_info *pkg_info =
+ pkgmgr_info_new(data.pkg_type, data.pkgid);
+ if (pkg_info == NULL) {
+ printf("Failed to get pkginfo handle\n");
+ ret = -1;
+ break;
+ }
+ __print_pkg_info(pkg_info);
+ ret = pkgmgr_info_free(pkg_info);
+ break;
+ }
+ if (data.pkg_path[0] != '\0') {
+ pkgmgr_info *pkg_info =
+ pkgmgr_info_new_from_file(data.pkg_type,
+ data.pkg_path);
+ if (pkg_info == NULL) {
+ printf("Failed to get pkginfo handle\n");
+ ret = -1;
+ break;
+ }
+ __print_pkg_info(pkg_info);
+ ret = pkgmgr_info_free(pkg_info);
+ break;
+ }
+ printf("Either pkgid or pkgpath should be supplied\n");
+ ret = -1;
+ break;
+
+ case CSC_REQ:
+ ret = pkgmgr_client_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, data.des_path, NULL, (void *)data.pkg_path);
+ if (ret < 0)
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+
+ case GETSIZE_REQ:
+ if (data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (data.type == 9) {
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, (void *)pc);
+ break;
+ }
+
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, data.type, pc, NULL, data.pkgid, NULL, NULL, NULL);
+ if (ret < 0){
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ printf("pkg[%s] size = %d\n", data.pkgid, ret);
+ ret = data.result;
+ break;
+
+ case HELP_REQ:
+ __print_usage();
+ ret = 0;
+ break;
+
+ default:
+ printf("Wrong Request\n");
+ ret = -1;
+ break;
+ }
+
+ if (pc) {
+ pkgmgr_client_free(pc);
+ pc = NULL;
+ }
+ return ret;
+}
+
+static int __is_authorized()
+{
+ /* pkgcmd needs root or developer privileges.
+ If launched via fork/exec, the launching program
+ must be running as root */
+
+ uid_t uid = getuid();
+ if ((uid_t) 0 == uid || (uid_t) 5100 == uid)
+ return 1;
+ else
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ optind = 1;
+ int opt_idx = 0;
+ int c = -1;
+ int ret = -1;
+ char *errstr = NULL;
+ long starttime;
+ long endtime;
+ struct timeval tv;
+
+ if (!__is_authorized()) {
+ printf("You are not an authorized user!\n");
+ return PKGCMD_ERR_FATAL_ERROR;
+ }
+
+ if (argc == 1)
+ __print_usage();
+
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ data.request = -1;
+ memset(data.des_path, '\0', PKG_NAME_STRING_LEN_MAX);
+ memset(data.pkg_path, '\0', PKG_NAME_STRING_LEN_MAX);
+ memset(data.pkgid, '\0', PKG_NAME_STRING_LEN_MAX);
+ memset(data.pkg_type, '\0', PKG_TYPE_STRING_LEN_MAX);
+ memset(data.label, '\0', PKG_TYPE_STRING_LEN_MAX);
+ data.quiet = 0;
+ data.result = 0;
+ data.type = -1;
+ while (1) {
+ c = getopt_long(argc, argv, short_options, long_options,
+ &opt_idx);
+ if (c == -1)
+ break; /* Parse end */
+ switch (c) {
+ case 'i': /* install */
+ data.request = INSTALL_REQ;
+ break;
+
+ case 'u': /* uninstall */
+ data.request = UNINSTALL_REQ;
+ break;
+
+ case 'r': /* reinstall */
+ data.request = REINSTALL_REQ;
+ break;
+
+ case 'c': /* clear */
+ data.request = CLEAR_REQ;
+ break;
+
+ case 'g': /* get pkg size */
+ data.request = GETSIZE_REQ;
+ break;
+
+ case 'm': /* move */
+ data.request = MOVE_REQ;
+ break;
+
+ case 'S': /* csc packages */
+ data.request = CSC_REQ;
+ if (optarg)
+ strncpy(data.des_path, optarg, PKG_NAME_STRING_LEN_MAX);
+ printf("csc file is %s\n", data.des_path);
+ break;
+
+ case 'A': /* activate */
+ data.request = ACTIVATE_REQ;
+ break;
+
+ case 'D': /* deactivate */
+ data.request = DEACTIVATE_REQ;
+ break;
+
+ case 'L': /* activate with Label */
+ data.request = ACTIVATE_REQ;
+ if (optarg)
+ strncpy(data.label, optarg,
+ PKG_NAME_STRING_LEN_MAX);
+ break;
+
+ case 'a': /* app installation path */
+ data.request = APPPATH_REQ;
+ break;
+
+ case 'k': /* Terminate applications of a package */
+ data.request = KILLAPP_REQ;
+ break;
+
+ case 'C': /* Check running status of applications of a package */
+ data.request = CHECKAPP_REQ;
+ break;
+
+ case 'l': /* list */
+ data.request = LIST_REQ;
+ break;
+
+ case 's': /* show */
+ data.request = SHOW_REQ;
+ break;
+
+ case 'p': /* package path */
+ if (optarg)
+ strncpy(data.pkg_path, optarg,
+ PKG_NAME_STRING_LEN_MAX);
+ ret = __convert_to_absolute_path(data.pkg_path);
+ if (ret == -1) {
+ printf("conversion of relative path to absolute path failed\n");
+ return -1;
+ }
+ printf("path is %s\n", data.pkg_path);
+ break;
+
+ case 'd': /* descriptor path */
+ if (optarg)
+ strncpy(data.des_path, optarg,
+ PKG_NAME_STRING_LEN_MAX);
+ break;
+
+ case 'n': /* package name */
+ if (optarg)
+ strncpy(data.pkgid, optarg,
+ PKG_NAME_STRING_LEN_MAX);
+ break;
+
+ case 't': /* package type */
+ if (optarg)
+ strncpy(data.pkg_type, optarg,
+ PKG_TYPE_STRING_LEN_MAX);
+ break;
+
+ case 'T': /* move type */
+ data.type = atoi(optarg);
+ break;
+
+ case 'h': /* help */
+ data.request = HELP_REQ;
+ break;
+
+ case 'q': /* quiet mode */
+ data.quiet = 1;
+ break;
+
+ /* Otherwise */
+ case '?': /* Not an option */
+ __print_usage();
+ break;
+
+ case ':': /* */
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ ret = __process_request();
+ if ((ret == -1) && (data.result != 0))
+ data.result = PKGCMD_ERR_ARGUMENT_INVALID;
+
+ if (ret != 0) {
+ __error_no_to_string(data.result, &errstr);
+ printf("processing result : %s [%d] failed\n", errstr, data.result);
+ } else {
+ if (data.request == INSTALL_REQ)
+ sleep(2);
+ }
+
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+ printf("spend time for pkgcmd is [%d]ms\n", (int)(endtime - starttime));
+
+ return data.result;
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <iniparser.h>
+
+#include <pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+
+#define PKGMGR_FOTA_PATH "/opt/share/packages/.recovery/fota/"
+#define FACTORYRESET_BACKUP_FILE "/usr/system/RestoreDir/opt.zip"
+#define CSC_APPLIST_INI_FILE "/opt/system/csc-default/app/applist.ini"
+
+#define DBSPACE_PATH "/opt/dbspace/"
+#define PKGMGR_DB DBSPACE_PATH".pkgmgr_parser.db"
+#define PKGMGR_DB_BACKUP DBSPACE_PATH".pkgmgr_parser_b.db"
+
+#define PKGMGR_DB_JOURNAL DBSPACE_PATH".pkgmgr_parser.db-journal"
+#define PKGMGR_DB_JOURNAL_BACKUP DBSPACE_PATH".pkgmgr_parser_b.db-journal"
+
+#define FOTA_PKGMGR_DB_FILE PKGMGR_FOTA_PATH".pkgmgr_parser.db"
+
+#define CSC_PKGID_LIST_FILE PKGMGR_FOTA_PATH"csc_pkgid_list.txt"
+
+#define RO_PKGID_LIST_FILE PKGMGR_FOTA_PATH"ro_pkgid_list.txt"
+#define RW_PKGID_LIST_FILE PKGMGR_FOTA_PATH"rw_pkgid_list.txt"
+
+#define RO_FOTA_PKGID_LIST_FILE PKGMGR_FOTA_PATH"ro_fota_pkgid_list.txt"
+#define RW_FOTA_PKGID_LIST_FILE PKGMGR_FOTA_PATH"rw_fota_pkgid_list.txt"
+
+#define FOTA_RESULT_FILE PKGMGR_FOTA_PATH"result.txt"
+#define TPK_MANIFEST_FILE PKGMGR_FOTA_PATH"manifest.xml"
+
+#define PKG_INFO_DB_LABEL "pkgmgr::db"
+#define PKG_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_parser.db-journal"
+
+#define OPT_MANIFEST_DIRECTORY "/opt/share/packages"
+#define USR_MANIFEST_DIRECTORY "/usr/share/packages"
+#define BUFSZE 1024
+
+#define TOKEN_MANEFEST_STR "manifest"
+#define TOKEN_PKGID_STR "package="
+#define TOKEN_VERSION_STR "version="
+#define TOKEN_TYPE_STR "type="
+#define TOKEN_PATH_STR "path"
+#define TOKEN_TPK_PKGID_STR "<Id>"
+
+#define SEPERATOR_START '"'
+#define SEPERATOR_END '"'
+#define SEPERATOR_MID ':'
+
+#define _LOG(fmt, arg...) do { \
+ int fd = 0;\
+ FILE* file = NULL;\
+ file = fopen(FOTA_RESULT_FILE, "a");\
+ if (file == NULL) break;\
+ fprintf(file, "[PKG_FOTA] "fmt"", ##arg); \
+ fflush(file);\
+ fd = fileno(file);\
+ fsync(fd);\
+ fclose(file);\
+ fprintf(stderr, "[PKG_FOTA] "fmt"", ##arg);\
+} while (0)
+
+typedef enum {
+ PKG_IS_NOT_EXIST = 0,
+ PKG_IS_SAME,
+ PKG_IS_UPDATED,
+ PKG_IS_INSERTED,
+ PKG_IS_REMOVED
+} COMPARE_RESULT;
+
+static int initdb_xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
+
+static void __remove_pkgid_list()
+{
+ if (access(FOTA_RESULT_FILE, R_OK) == 0){
+ (void)remove(FOTA_RESULT_FILE);
+ }
+
+ if (access(RO_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RO_PKGID_LIST_FILE);
+ }
+
+ if (access(RO_FOTA_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RO_FOTA_PKGID_LIST_FILE);
+ }
+
+ if (access(CSC_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(CSC_PKGID_LIST_FILE);
+ }
+
+ if (access(TPK_MANIFEST_FILE, R_OK) == 0){
+ (void)remove(TPK_MANIFEST_FILE);
+ }
+
+ if (access(RW_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RW_PKGID_LIST_FILE);
+ }
+
+ if (access(RW_FOTA_PKGID_LIST_FILE, R_OK) == 0){
+ (void)remove(RW_FOTA_PKGID_LIST_FILE);
+ }
+}
+
+static int __make_pkgid_list(char *file_path, char *pkgid, char *version, char *type)
+{
+ FILE *fp;\
+
+ if (NULL == pkgid)
+ return 0;
+
+ fp = fopen(file_path, "a+");\
+ if (NULL == fp)
+ return -1;
+
+ fprintf(fp, "%s\"%s\" %s\"%s\" %s\"%s\":\n", TOKEN_PKGID_STR, pkgid, TOKEN_VERSION_STR, version, TOKEN_TYPE_STR, type); \
+ fclose(fp);\
+
+ return 0;
+}
+
+static int __pkgid_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid = NULL;
+ char *version = NULL;
+ char *type = NULL;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
+ if(ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if(ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = __make_pkgid_list((char *)user_data, pkgid, version, type);
+
+ return ret;
+}
+
+static void __str_trim(char *input)
+{
+ char *trim_str = input;
+
+ if (input == NULL)
+ return;
+
+ while (*input != 0) {
+ if (!isspace(*input)) {
+ *trim_str = *input;
+ trim_str++;
+ }
+ input++;
+ }
+
+ *trim_str = 0;
+ return;
+}
+
+static char * __getvalue(const char* pBuf, const char* pKey)
+{
+ const char* p = NULL;
+ const char* pStart = NULL;
+ const char* pEnd = NULL;
+
+ p = strstr(pBuf, pKey);
+ if (p == NULL)
+ return NULL;
+
+ pStart = p + strlen(pKey) + 1;
+ pEnd = strchr(pStart, SEPERATOR_END);
+ if (pEnd == NULL) {
+ pEnd = strchr(pStart, SEPERATOR_MID);
+ if (pEnd == NULL)
+ return NULL;
+ }
+
+ size_t len = pEnd - pStart;
+ if (len <= 0)
+ return NULL;
+
+ char *pRes = (char*)malloc(len + 1);
+ strncpy(pRes, pStart, len);
+ pRes[len] = 0;
+
+ return pRes;
+}
+
+static char * __find_str(const char* manifest, const char *str)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *get_str = NULL;
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", manifest);
+ return NULL;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ if (strstr(buf, TOKEN_MANEFEST_STR) != NULL) {
+ get_str = __getvalue(buf, str);
+ if (get_str != NULL) {
+ fclose(fp);
+ return get_str;
+ }
+ }
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return NULL;
+}
+
+static int __compare_version(char *orig_version, char *fota_version)
+{
+ int i = 1;
+ char* orig_str[4]= {0, };
+ char* fota_str[4]= {0, };
+
+ char orig_ver[BUFSZE] = {0};
+ char fota_ver[BUFSZE] = {0};
+
+ if ((orig_version == NULL) || (fota_version == NULL)) {
+ _LOG("Version is null \n");
+ return PKG_IS_SAME;
+ }
+
+ snprintf(orig_ver, BUFSZE-1, "%s", orig_version);
+ snprintf(fota_ver, BUFSZE-1, "%s", fota_version);
+
+ orig_str[0] = strtok(orig_ver,".");
+ while(1)
+ {
+ orig_str[i] = strtok(NULL,".");
+ if(orig_str[i] == NULL)
+ break;
+ i++;
+ }
+
+ i = 1;
+ fota_str[0] = strtok(fota_ver,".");
+ while(1)
+ {
+ fota_str[i] = strtok(NULL,".");
+ if(fota_str[i] == NULL)
+ break;
+ i++;
+ }
+
+ if((orig_str[0] == NULL) || (orig_str[1] == NULL) || (orig_str[2] == NULL))
+ return PKG_IS_SAME;
+
+ /*check first number*/
+ if (atoi(orig_str[0]) < atoi(fota_str[0])) {
+ return PKG_IS_UPDATED;
+ } else if (atoi(orig_str[0]) == atoi(fota_str[0])) {
+ /*check 2nd number*/
+ if (atoi(orig_str[1]) < atoi(fota_str[1])) {
+ return PKG_IS_UPDATED;
+ } else if (atoi(orig_str[1]) == atoi(fota_str[1])) {
+ /*check 3rd number*/
+ if (atoi(orig_str[2]) < atoi(fota_str[2])) {
+ return PKG_IS_UPDATED;
+ }
+ }
+ }
+
+ /*other case is same*/
+ return PKG_IS_SAME;
+}
+
+static int __compare_pkgid(char *file_path, char *fota_pkgid, char *fota_version)
+{
+ int ret = PKG_IS_NOT_EXIST;
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *pkgid = NULL;
+ char *version = NULL;
+
+ if((file_path == NULL) || (fota_pkgid == NULL) || (fota_version == NULL)){
+ _LOG("input is null\n");
+ return -1;
+ }
+
+ fp = fopen(file_path, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", file_path);
+ return -1;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ continue;
+ }
+ version = __getvalue(buf, TOKEN_VERSION_STR);
+ if(version == NULL) {
+ free(pkgid);
+ _LOG("version is null\n");
+ continue;
+ }
+
+ if(strcmp(pkgid, fota_pkgid) == 0) {
+ if(__compare_version(version, fota_version) == PKG_IS_UPDATED) {
+ ret = PKG_IS_UPDATED;
+ _LOG("Pkg[%s] is updated[orig ver=%s, fota ver=%s]\n", fota_pkgid, version, fota_version);
+ free(pkgid);
+ free(version);
+ break;
+ }
+
+ free(pkgid);
+ free(version);
+ ret = PKG_IS_SAME;
+ break;
+ }
+
+ free(pkgid);
+ free(version);
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return ret;
+}
+
+static int __compare_csc_pkgid(const char *pkgid)
+{
+ int ret = 0;
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *csc_pkgid = NULL;
+
+ if(pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ return ret;
+ }
+
+ fp = fopen(CSC_PKGID_LIST_FILE, "r");
+ if (fp == NULL) {
+// _LOG("Fail get : %s\n", CSC_PKGID_LIST_FILE);
+ return ret;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ csc_pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if(csc_pkgid == NULL) {
+ _LOG("pkgid is null\n");
+ memset(buf, 0x00, BUFSZE);
+ continue;
+ }
+
+ if(strcmp(csc_pkgid, pkgid) == 0) {
+ _LOG("pkgid[%s] is already processed by csc \n", pkgid);
+ free(csc_pkgid);
+ ret = -1;
+ break;
+ }
+
+ free(csc_pkgid);
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return ret;
+}
+
+static char *__get_pkgid_from_tpk_manifest(const char* manifest)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s \n", manifest);
+ return NULL;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ const char* p = NULL;
+ const char* pStart = NULL;
+
+ p = strstr(buf, TOKEN_TPK_PKGID_STR);
+ if (p != NULL) {
+ pStart = p + strlen(TOKEN_TPK_PKGID_STR);
+ char *pRes = (char*)malloc(11);
+ strncpy(pRes, pStart, 10);
+ pRes[10] = 0;
+ fclose(fp);
+ return pRes;
+ }
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return NULL;
+}
+
+char* __manifest_to_package(const char* manifest)
+{
+ char *package;
+
+ if(manifest == NULL)
+ return NULL;
+
+ package = strdup(manifest);
+ if(package == NULL)
+ return NULL;
+
+ if (!strstr(package, ".xml")) {
+ _LOG("%s is not a manifest file \n", manifest);
+ free(package);
+ return NULL;
+ }
+
+ return package;
+}
+
+static void __send_args_to_backend(char *pkgid, char *type, int compare_result)
+{
+ int ret = 0;
+ char *op = NULL;
+ char buf[BUFSZE] = {0};
+
+ if (compare_result == PKG_IS_SAME) {
+// _LOG("Pkgid[%s] - [%s] is same\n", pkgid, type);
+ return;
+ }
+
+ if (__compare_csc_pkgid(pkgid) < 0) {
+ return;
+ }
+
+ switch (compare_result) {
+ case 2:
+ op = "update";
+// _LOG("pkgid[%s] is update, it is already exist\n", pkgid);
+ break;
+
+ case 3:
+ op = "install";
+ _LOG("pkgid[%s] is install, it is new\n", pkgid);
+ break;
+
+ case 4:
+ op = "uninstall";
+ _LOG("pkgid[%s] is uninstall, it is deleted\n", pkgid);
+ break;
+
+ default:
+ break;
+ }
+
+ snprintf(buf, sizeof(buf), "path=%s:op=%s", pkgid, op);
+
+ if (strcmp(type,"rpm") == 0) {
+ const char *rpm_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-fota", "-s", buf, NULL };
+ ret = initdb_xsystem(rpm_argv);
+ } else if(strcmp(type,"tpk") == 0) {
+ const char *osp_argv[] = { "/usr/bin/osp-installer", "-f", buf, NULL };
+ ret = initdb_xsystem(osp_argv);
+ } else if(strcmp(type,"wgt") == 0) {
+ const char *wrt_argv[] = { "/usr/bin/wrt-installer", "-f", buf, NULL };
+ ret = initdb_xsystem(wrt_argv);
+ } else {
+ _LOG("Pkgid[%s] - [%s] is not supported\n", pkgid, type);
+ return;
+ }
+
+ _LOG("Pkgid[%s] -- send args done -- type[%s], operation[%s], result[%d]\n", pkgid, type, op, ret);
+}
+
+
+static void __send_args_to_backend_for_rw_fota(char *pkgid, char *type, int compare_result)
+{
+ int ret = 0;
+ char *op = NULL;
+ char buf[BUFSZE] = {0};
+
+ if (compare_result == PKG_IS_SAME) {
+// _LOG("Pkgid[%s] - [%s] is same\n", pkgid, type);
+ return;
+ }
+
+ if (__compare_csc_pkgid(pkgid) < 0) {
+ return;
+ }
+
+ switch (compare_result) {
+ case 2:
+ op = "update";
+ _LOG("pkgid[%s] is update, it is already exist\n", pkgid);
+ break;
+ case 3:
+ op = "install";
+ _LOG("pkgid[%s] is install, it is new\n", pkgid);
+ break;
+ case 4:
+ op = "uninstall";
+ _LOG("pkgid[%s] is uninstall, it is deleted\n", pkgid);
+ break;
+ default:
+ break;
+ }
+
+ snprintf(buf, sizeof(buf), "path=%s:op=%s", pkgid, op);
+
+ if (strcmp(type,"rpm") == 0) {
+ const char *rpm_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-rw-fota", "-s", buf, NULL };
+ ret = initdb_xsystem(rpm_argv);
+ } else if(strcmp(type,"tpk") == 0) {
+ const char *osp_argv[] = { "/usr/bin/osp-installer", "-F", buf, NULL };
+ ret = initdb_xsystem(osp_argv);
+ } else if(strcmp(type,"wgt") == 0) {
+ const char *wrt_argv[] = { "/usr/bin/wrt-installer", "-F", buf, NULL };
+ ret = initdb_xsystem(wrt_argv);
+ } else {
+ _LOG("Pkgid[%s] - [%s] is not supported\n", pkgid, type);
+ return;
+ }
+
+ _LOG("Result :: Pkgid[%s], type[%s], operation[%s], result[%d]\n", pkgid, type, op, ret);
+}
+
+static int __find_preload_pkgid_from_xml(const char *file_path)
+{
+ int ret = 0;
+ char buf[BUFSZE] = {0};
+ DIR *dir;
+ struct dirent entry, *result;
+
+ dir = opendir(USR_MANIFEST_DIRECTORY);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _LOG("Failed to access the [%s] because %s\n", USR_MANIFEST_DIRECTORY, buf);
+ return -1;
+ }
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *manifest;
+ char *pkgid;
+ char *version;
+ char *type;
+
+ if (entry.d_name[0] == '.') continue;
+
+ manifest = __manifest_to_package(entry.d_name);
+ if (!manifest) {
+ _LOG("Failed to convert file to xml[%s]\n", entry.d_name);
+ continue;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s", USR_MANIFEST_DIRECTORY, manifest);
+
+ ret = pkgmgr_parser_check_manifest_validation(buf);
+ if (ret < 0) {
+// _LOG("manifest validation failed : %s \n", buf);
+ free(manifest);
+ continue;
+ }
+
+ pkgid = __find_str(buf, TOKEN_PKGID_STR);
+ if(pkgid == NULL) {
+ free(manifest);
+ continue;
+ }
+ version = __find_str(buf, TOKEN_VERSION_STR);
+ if(version == NULL)
+ version = strdup("0.0.1");
+ type = __find_str(buf, TOKEN_TYPE_STR);
+ if(type == NULL)
+ type = strdup("rpm");
+
+ ret = __make_pkgid_list(file_path, pkgid, version, type);
+ if (ret < 0)
+ _LOG("Make file Fail : %s => %s, %s\n", buf, pkgid, version);
+
+ free(pkgid);
+ free(version);
+ free(type);
+ free(manifest);
+ }
+
+ closedir(dir);
+
+ return 0;
+}
+
+static int __find_preload_pkgid_from_db(const char *file_path, int is_readonly)
+{
+ int ret = 0;
+ pkgmgrinfo_pkginfo_filter_h handle = NULL;
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret > 0) {
+ _LOG("pkginfo filter handle create failed\n");
+ return -1;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, 1);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ }
+
+ if (is_readonly == 1) {
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, 0);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_READONLY, 1);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ }
+ } else {
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_READONLY, 0);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ }
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgid_list_cb, (void *)file_path);
+ if (ret < 0) {
+ _LOG("pkgmgrinfo_pkginfo_filter_foreach_pkginfo() failed\n");
+ ret = -1;
+ }
+
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ return ret;
+}
+
+static int __find_matched_pkgid_from_list(const char *source_file, const char *target_file, int rw_fota_enabled)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *pkgid = NULL;
+ char *version = NULL;
+ char *type = NULL;
+
+ int same_pkg_cnt = 0;
+ int update_pkg_cnt = 0;
+ int insert_pkg_cnt = 0;
+ int total_pkg_cnt = 0;
+
+ int compare_result = 0;
+
+ fp = fopen(source_file, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", source_file);
+ return -1;
+ }
+
+ _LOG("Searching...... inserted or Updated package \n");
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ version = __getvalue(buf, TOKEN_VERSION_STR);
+ type = __getvalue(buf, TOKEN_TYPE_STR);
+
+ if(pkgid == NULL) {
+ if(version) {
+ free(version);
+ version = NULL;
+ }
+ if(type) {
+ free(type);
+ type = NULL;
+ }
+ continue;
+ }
+
+ compare_result = __compare_pkgid(target_file, pkgid, version);
+ if(compare_result == PKG_IS_NOT_EXIST) {
+ compare_result = PKG_IS_INSERTED;
+ insert_pkg_cnt++;
+ } else if (compare_result == PKG_IS_SAME) {
+ same_pkg_cnt++;
+ } else if (compare_result == PKG_IS_UPDATED) {
+ update_pkg_cnt++;
+ }
+
+ total_pkg_cnt++;
+
+ if (rw_fota_enabled == 1)
+ __send_args_to_backend_for_rw_fota(pkgid, type, compare_result);
+ else
+ __send_args_to_backend(pkgid, type, compare_result);
+
+ memset(buf, 0x00, BUFSZE);
+ if(pkgid) {
+ free(pkgid);
+ pkgid = NULL;
+ }
+ if(version) {
+ free(version);
+ version = NULL;
+ }
+ if(type) {
+ free(type);
+ type = NULL;
+ }
+ }
+
+ _LOG("Finish Searching ::: [Total pkg=%d, same pkg=%d, updated pkg=%d, inserted package=%d]\n\n", total_pkg_cnt, same_pkg_cnt, update_pkg_cnt, insert_pkg_cnt);
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return 0;
+}
+
+static int __find_deleted_pkgid_from_list(const char *source_file, const char *target_file, int rw_fota_enabled)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *pkgid = NULL;
+ char *version = NULL;
+ char *type = NULL;
+
+ int deleted_pkg_cnt = 0;
+ int total_pkg_cnt = 0;
+
+ int compare_result = 0;
+
+ fp = fopen(source_file, "r");
+ if (fp == NULL) {
+ _LOG("Fail get : %s\n", source_file);
+ return -1;
+ }
+
+ _LOG("Searching...... deleted package \n");
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ version = __getvalue(buf, TOKEN_VERSION_STR);
+ type = __getvalue(buf, TOKEN_TYPE_STR);
+
+ if(pkgid == NULL) {
+ if(version) {
+ free(version);
+ version = NULL;
+ }
+ if(type) {
+ free(type);
+ type = NULL;
+ }
+ continue;
+ }
+
+ compare_result = __compare_pkgid(target_file, pkgid, version);
+ if(compare_result == PKG_IS_NOT_EXIST) {
+ compare_result = PKG_IS_REMOVED;
+
+ if (rw_fota_enabled == 1)
+ __send_args_to_backend_for_rw_fota(pkgid, type, compare_result);
+ else
+ __send_args_to_backend(pkgid, type, compare_result);
+
+ deleted_pkg_cnt++;
+ }
+ total_pkg_cnt++;
+
+ memset(buf, 0x00, BUFSZE);
+ if(pkgid) {
+ free(pkgid);
+ pkgid = NULL;
+ }
+ if(version) {
+ free(version);
+ version = NULL;
+ }
+ if(type) {
+ free(type);
+ type = NULL;
+ }
+ }
+
+ _LOG("Finish Searching ::: [Total pkg=%d, deleted package=%d]\n\n", total_pkg_cnt, deleted_pkg_cnt);
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return 0;
+
+}
+
+static void __find_tpk_pkgid_from_csc(const char *tpk_path, char *result_path)
+{
+ int ret = 0;
+ char *pkgid = NULL;
+
+ /*check : input param is pkgid or tpk file*/
+ if (strstr(tpk_path, ".tpk") == NULL) {
+ __make_pkgid_list(result_path, tpk_path, NULL, NULL);
+ return;
+ }
+
+ /*unzip manifest from tpk*/
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-j", tpk_path, "info/manifest.xml", "-d", PKGMGR_FOTA_PATH, NULL };
+ ret = initdb_xsystem(unzip_argv);
+ if (ret < 0) {
+ _LOG("unzip_argv fail[%s]", tpk_path);
+ return;
+ }
+
+ /*open manifest and get pkgid*/
+ pkgid = __get_pkgid_from_tpk_manifest(TPK_MANIFEST_FILE);
+ if (pkgid == NULL) {
+ _LOG("pkgid is null[%s]", tpk_path);
+ return;
+ }
+
+ /*make csc pkgid list*/
+ __make_pkgid_list(result_path, pkgid, NULL, NULL);
+
+ /*free variable*/
+ free(pkgid);
+
+ (void)remove(TPK_MANIFEST_FILE);
+}
+
+static void __find_xml_pkgid_from_csc(const char *xml_path, char *result_path)
+{
+ char *pkgid = NULL;
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0,};
+
+ if (strstr(xml_path, ".xml") == NULL) {
+ __make_pkgid_list(result_path, xml_path, NULL, NULL);
+ return;
+ }
+
+ fp = fopen(xml_path, "r");
+ if (fp == NULL) {
+ return;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+ pkgid = __getvalue(buf, TOKEN_PKGID_STR);
+ if (pkgid != NULL) {
+ /*make csc pkgid list*/
+ __make_pkgid_list(result_path, pkgid, NULL, NULL);
+ free(pkgid);
+ fclose(fp);
+ return;
+ }
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+}
+
+static void __get_pkgid_list_from_db_and_xml()
+{
+ int ret = 0;
+ int is_readonly = 1;
+
+ /*get pkgid of old version */
+ ret = __find_preload_pkgid_from_db(RO_PKGID_LIST_FILE, is_readonly);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_db fail.\n");
+ } else {
+ _LOG("Make original pkgid success!! \n");
+ }
+
+ /*get pkgid of updated version by fota*/
+ ret = __find_preload_pkgid_from_xml(RO_FOTA_PKGID_LIST_FILE);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_xml fail.\n");
+ } else {
+ _LOG("Make fota pkgid success!! \n\n");
+ }
+}
+
+static void __get_pkgid_list_from_db_and_zip()
+{
+ int ret = 0;
+ int is_readonly = 0;
+
+ /*get pkgid from orginal pkgmgr db*/
+ ret = __find_preload_pkgid_from_db(RW_PKGID_LIST_FILE, is_readonly);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_db fail.\n");
+ } else {
+ _LOG("Make original pkgid success!! \n");
+ }
+
+ /*move orginal pkgmgr db to backup*/
+ const char *db_mv_argv[] = { "/bin/mv", PKGMGR_DB, PKGMGR_DB_BACKUP, NULL };
+ ret = initdb_xsystem(db_mv_argv);
+ if (ret < 0) {
+ _LOG("move orginal pkgmgr db to backup fail.\n");
+ }
+ const char *jn_mv_argv[] = { "/bin/mv", PKGMGR_DB_JOURNAL, PKGMGR_DB_JOURNAL_BACKUP, NULL };
+ ret = initdb_xsystem(jn_mv_argv);
+ if (ret < 0) {
+ _LOG("move orginal pkgmgr db to backup fail.\n");
+ }
+
+ /*unzip pkgmgr db from factoryrest data*/
+ const char *unzip_argv[] = { "/usr/bin/unzip", "-j", FACTORYRESET_BACKUP_FILE, "opt/dbspace/.pkgmgr_parser.db", "-d", PKGMGR_FOTA_PATH, NULL };
+ ret = initdb_xsystem(unzip_argv);
+ if (ret < 0) {
+ _LOG("unzip pkgmgr db from factoryrest data fail.\n");
+ }
+
+ /*move fota pkgmgr db to dbspace*/
+ const char *fota__mv_argv[] = { "/bin/mv", FOTA_PKGMGR_DB_FILE, DBSPACE_PATH, NULL };
+ ret = initdb_xsystem(fota__mv_argv);
+ if (ret < 0) {
+ _LOG("move fota pkgmgr db to dbspace fail.\n");
+ }
+
+ /*get pkgid from fota pkgmgr db*/
+ ret = __find_preload_pkgid_from_db(RW_FOTA_PKGID_LIST_FILE, is_readonly);
+ if (ret < 0) {
+ _LOG("__find_preload_pkgid_from_db fail.\n");
+ } else {
+ _LOG("Make fota pkgid success!! \n\n");
+ }
+
+ /*del pkgmgr db and recover orginal pkgmgr db from backup*/
+ const char *db_rm_argv[] = { "/bin/rm", "-f", PKGMGR_DB, NULL };
+ ret = initdb_xsystem(db_rm_argv);
+ if (ret < 0) {
+ _LOG("del pkgmgr db fail.\n");
+ }
+ const char *jn_rm_argv[] = { "/bin/rm", "-f", PKGMGR_DB_JOURNAL, NULL };
+ ret = initdb_xsystem(jn_rm_argv);
+ if (ret < 0) {
+ _LOG("del pkgmgr db fail.\n");
+ }
+
+ const char *db_recover_argv[] = { "/bin/mv", PKGMGR_DB_BACKUP, PKGMGR_DB, NULL };
+ ret = initdb_xsystem(db_recover_argv);
+ if (ret < 0) {
+ _LOG("recover orginal pkgmgr db fail.\n");
+ }
+ const char *jn_recover_argv[] = { "/bin/mv", PKGMGR_DB_JOURNAL_BACKUP, PKGMGR_DB_JOURNAL, NULL };
+ ret = initdb_xsystem(jn_recover_argv);
+ if (ret < 0) {
+ _LOG("recover orginal pkgmgr db fail.\n");
+ }
+
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+ initdb_xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+ initdb_xsystem(argv_parserjn);
+}
+
+static void __get_pkgid_list_from_csc()
+{
+ int cnt = 0;
+ int count = 0;
+
+ char *pkgtype = NULL;
+ char *des = NULL;
+ char *path = NULL;
+
+ char type_buf[BUFSZE] = { 0 };
+ char des_buf[BUFSZE] = { 0 };
+ dictionary *csc = NULL;
+
+ csc = iniparser_load(CSC_APPLIST_INI_FILE);
+ if (csc == NULL) {
+ _LOG("Dont have csc applist file\n\n");
+ return;
+ }
+
+ count = iniparser_getint(csc, "csc packages:count", -1);
+ if (count == 0) {
+ _LOG("csc [%s] dont have packages \n", CSC_APPLIST_INI_FILE);
+ goto end;
+ }
+
+ for(cnt = 1 ; cnt <= count ; cnt++)
+ {
+ snprintf(type_buf, BUFSZE - 1, "csc packages:type_%03d", cnt);
+ snprintf(des_buf, BUFSZE - 1, "csc packages:description_%03d", cnt);
+
+ /*parse csc description and type*/
+ pkgtype = iniparser_getstr(csc, type_buf);
+ des = iniparser_getstr(csc, des_buf);
+
+ if ((pkgtype == NULL) || (des == NULL)) {
+ continue;
+ }
+
+ /*get tpk path from csc description*/
+ path = __getvalue(des, TOKEN_PATH_STR);
+ if (path == NULL) {
+ _LOG("description[%s] has error", des);
+ continue;
+ }
+
+ if (strcmp(pkgtype, "tpk") == 0) {
+ __find_tpk_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ } else if (strcmp(pkgtype, "wgt")== 0) {
+// __find_wgt_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ } else if (strcmp(pkgtype, "xml")== 0) {
+ __find_xml_pkgid_from_csc(path, CSC_PKGID_LIST_FILE);
+ }
+
+ free(path);
+ }
+
+end:
+ iniparser_freedict(csc);
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ int rw_fota_enabled = 0;
+
+ /*clean pkgid list file, if it is exit*/
+ __remove_pkgid_list();
+
+ _LOG("=======================================================\n");
+ _LOG(" RO preload package fota\n");
+ _LOG("=======================================================\n");
+
+ /*get pkgid from orginal pkgmgr db*/
+ __get_pkgid_list_from_db_and_xml();
+
+ /*get pkgid from csc applist*/
+ __get_pkgid_list_from_csc();
+
+ _LOG("Ready RO pkgid list for compare\n\n");
+
+ /*find deleted pkgid*/
+ ret = __find_deleted_pkgid_from_list(RO_PKGID_LIST_FILE, RO_FOTA_PKGID_LIST_FILE, rw_fota_enabled);
+ if (ret < 0) {
+ _LOG("__find_deleted_pkgid_from_list fail.\n");
+ }
+
+ /*find updated, inserted pkgid*/
+ ret = __find_matched_pkgid_from_list(RO_FOTA_PKGID_LIST_FILE, RO_PKGID_LIST_FILE, rw_fota_enabled);
+ if (ret < 0) {
+ _LOG("__find_matched_pkgid_from_list fail.\n");
+ }
+
+ _LOG("End RO pkgid list for compare\n\n");
+
+ if (access(FACTORYRESET_BACKUP_FILE, R_OK) == 0) {
+ _LOG("=======================================================\n");
+ _LOG(" RW preload package fota\n");
+ _LOG("=======================================================\n");
+
+ rw_fota_enabled = 1;
+
+ /*get pkgid from orginal pkgmgr db*/
+ __get_pkgid_list_from_db_and_zip();
+
+ if (access(RW_FOTA_PKGID_LIST_FILE, R_OK) != 0){
+ _LOG(" !!! Dont have preload downloaded package in /opt/usr/apps !!!\n\n");
+ goto end;
+ }
+
+ _LOG("Ready RW pkgid list for compare\n\n");
+
+ /*find updated, inserted pkgid*/
+ ret = __find_matched_pkgid_from_list(RW_FOTA_PKGID_LIST_FILE, RW_PKGID_LIST_FILE, rw_fota_enabled);
+ if (ret < 0) {
+ _LOG("__find_matched_pkgid_from_list fail.\n");
+ }
+
+ _LOG("End RW pkgid list for compare\n\n");
+ }
+
+ /*clean pkgid list file, if it is exit*/
+ // __remove_pkgid_list();
+
+end:
+ _LOG("=======================================================\n");
+ _LOG(" End fota process\n");
+ _LOG("=======================================================\n");
+
+ return 0;
+}
+
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <pkgmgr-info.h>
+#include <vconf.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <dbus/dbus.h>
+
+#include "pkgmgr-debug.h"
+#include "package-manager.h"
+#include "pkgmgr_installer.h"
+#include "comm_config.h"
+
+
+#undef LOG_TAG
+#ifndef LOG_TAG
+#define LOG_TAG "PKGMGR_GETSIZE"
+#endif /* LOG_TAG */
+
+#define MAX_PKG_INFO_LEN 10
+#define MAX_PKG_BUF_LEN 1024
+#define BLOCK_SIZE 4096 /*in bytes*/
+
+#define PKG_RW_PATH "/opt/usr/apps/"
+
+char* directory_list[4][10] = { {"bin", "info", "res", "info", "data", "shared", "setting", "lib", NULL},
+ {"bin", "info", "res", "info", "shared", "setting", "lib", NULL},
+ {"data", NULL},
+ NULL };
+
+void __getsize_send_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val);
+
+long long __stat_size(struct stat *s)
+{
+ long long blksize = s->st_blksize;
+ long long size = s->st_blocks * 512;
+
+ if (blksize) {
+ size = (size + blksize - 1) & (~(blksize - 1));
+ }
+
+ return size;
+}
+
+long long __calculate_dir_size(int dfd, int depth, int type)
+{
+ long long size = 0;
+ struct stat s;
+ DIR *d = NULL;
+ struct dirent *de = NULL;
+ int i = 0;
+
+ depth++;
+
+ d = fdopendir(dfd);
+ if (d == NULL) {
+ close(dfd);
+ return 0;
+ }
+
+ while ((de = readdir(d))) {
+ int skip = 0;
+ const char *name = de->d_name;
+ if (name[0] == '.') {
+ if (name[1] == 0)
+ continue;
+ if ((name[1] == '.') && (name[2] == 0))
+ continue;
+ }
+
+ if (depth == 1 && de->d_type == DT_DIR) {
+ for (i = 0; directory_list[type][i]; i++) {
+ if (strcmp(name, directory_list[type][i]) == 0) {
+ skip = -1;
+ break;
+ }
+ }
+
+ if (skip == 0)
+ continue;
+ }
+
+ if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) == 0) {
+ size += __stat_size(&s);
+ }
+
+ if (de->d_type == DT_DIR) {
+ int subfd;
+
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ size += __calculate_dir_size(subfd, depth, type);
+ }
+ }
+ }
+
+ closedir(d);
+ return size;
+}
+
+int __set_attr_info_file()
+{
+ const char* app_info_label = "*";
+
+ if(lsetxattr(PKG_SIZE_INFO_FILE, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ _LOGE("error(%d) in setting smack label",errno);
+ return -1;
+ }
+
+ return 0;
+}
+
+void __make_sizeinfo_file(char *package_size_info)
+{
+ FILE* file = NULL;
+ int fd = 0;
+
+ if(package_size_info == NULL)
+ return;
+
+ file = fopen(PKG_SIZE_INFO_FILE, "w");
+ if (file == NULL) {
+ _LOGE("Couldn't open the file %s \n", PKG_SIZE_INFO_FILE);
+ return;
+ }
+
+ fwrite(package_size_info, 1, strlen(package_size_info), file);
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+
+ if (__set_attr_info_file() < 0)
+ _LOGE("Fail set label file %s \n", PKG_SIZE_INFO_FILE);
+}
+
+int __get_size_info(char *pkgid, int *pkg_data_size, int *pkg_total_size)
+{
+ DIR *dir = NULL;
+ int dfd = 0;
+ struct stat f_stat;
+ struct dirent *de = NULL;
+
+ dir = opendir(PKG_RW_PATH);
+ if (dir == NULL) {
+ _LOGE("Couldn't open the directory %s \n", PKG_RW_PATH);
+ return -1;
+ }
+
+ while ((de = readdir(dir)))
+ {
+ int total_size = 0;
+ int others_size = 0;
+ int data_size = 0;
+
+ const char *name = de->d_name;
+ if (name[0] == '.') {
+ if (name[1] == 0)
+ continue;
+ if ((name[1] == '.') && (name[2] == 0))
+ continue;
+ }
+
+ if (strcmp(name, pkgid) != 0){
+ continue;
+ }
+
+ dfd = dirfd(dir);
+ if (de->d_type == DT_DIR) {
+ int subfd = 0;
+
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ if (fstat(subfd, &f_stat) == 0) // root
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ others_size += __calculate_dir_size(subfd, 0, 1);
+ }
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ int datafd = 0;
+ datafd = openat(subfd, "data", O_RDONLY | O_DIRECTORY);
+ if (datafd >= 0) {
+ if (fstat(datafd, &f_stat) == 0) // data
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ data_size = __calculate_dir_size(datafd, 1, 2);
+ }
+ }
+ }
+
+ total_size = others_size + data_size;
+ *pkg_total_size = total_size;
+ *pkg_data_size = data_size;
+ }
+ closedir(dir);
+ return 0;
+}
+
+int __create_size_info(int argc, char *argv[])
+{
+ char *package_size_info = NULL;
+ int info_len = MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN;
+ pkgmgr_installer *pi;
+ char total_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ char data_buf[MAX_PKG_BUF_LEN] = {'\0'};
+
+ DIR *dir = NULL;
+ int dfd = 0;
+ struct stat f_stat;
+ struct dirent *de = NULL;
+
+ dir = opendir(PKG_RW_PATH);
+ if (dir == NULL)
+ {
+ _LOGE("Couldn't open the directory %s \n", PKG_RW_PATH);
+ return -1;
+ }
+
+ package_size_info = (char*)malloc(info_len);
+ memset(package_size_info, 0, info_len);
+
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ _LOGD("Failure in creating the pkgmgr_installer object");
+ return -1;
+ }
+
+ while ((de = readdir(dir)))
+ {
+ int total_size = 0;
+ int others_size = 0;
+ int data_size = 0;
+
+ char size_string[128] = {0};
+ const char *name = de->d_name;
+ if (name[0] == '.') {
+ if (name[1] == 0)
+ continue;
+ if ((name[1] == '.') && (name[2] == 0))
+ continue;
+ }
+
+ dfd = dirfd(dir);
+ if (de->d_type == DT_DIR) {
+ int subfd = 0;
+
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ if (fstat(subfd, &f_stat) == 0) // root
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ others_size += __calculate_dir_size(subfd, 0, 1);
+ }
+ subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY);
+ if (subfd >= 0) {
+ int datafd = 0;
+ datafd = openat(subfd, "data", O_RDONLY | O_DIRECTORY);
+ if (datafd >= 0) {
+ if (fstat(datafd, &f_stat) == 0) // data
+ {
+ others_size += __stat_size(&f_stat);
+ }
+ data_size = __calculate_dir_size(datafd, 1, 2);
+ }
+ }
+ }
+
+ total_size = others_size + data_size;
+
+ /*send size info to client*/
+ snprintf(total_buf, MAX_PKG_BUF_LEN - 1, "%d", total_size);
+ snprintf(data_buf, MAX_PKG_BUF_LEN - 1, "%d", data_size);
+
+ pkgmgr_installer_receive_request(pi, argc, argv);
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, name, data_buf, total_buf);
+
+ sprintf(size_string, "%s=%d/%d:", name, total_size, data_size);
+ strncat(package_size_info, size_string, info_len);
+ }
+ closedir(dir);
+
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, "get_size", "get_size", "end");
+ pkgmgr_installer_free(pi);
+
+ __make_sizeinfo_file(package_size_info);
+ if(package_size_info)
+ free(package_size_info);
+
+ return 0;
+}
+
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid;
+ int data_size = 0;
+ int total_size = 0;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ _LOGE("pkgmgr_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = __get_size_info(pkgid, &data_size, &total_size);
+ if ((ret < 0) || (total_size < 0))
+ return -1;
+
+ * (int *) user_data += total_size;
+ return 0;
+}
+
+void __make_size_info_file(char *req_key, int size)
+{
+ int ret = 0;
+ FILE* file = NULL;
+ int fd = 0;
+ char buf[MAX_PKG_BUF_LEN] = {0};
+ const char* app_info_label = "*";
+ char info_file[MAX_PKG_BUF_LEN] = {'\0', };
+
+ if(req_key == NULL)
+ return;
+
+ snprintf(info_file, MAX_PKG_BUF_LEN, "%s/%s", PKG_SIZE_INFO_PATH, req_key);
+ _LOGE("File path = %s\n", info_file);
+
+ file = fopen(info_file, "w");
+ if (file == NULL) {
+ _LOGE("Couldn't open the file %s \n", info_file);
+ return;
+ }
+
+ snprintf(buf, 128, "%d\n", size);
+ fwrite(buf, 1, strlen(buf), file);
+
+ fflush(file);
+ fd = fileno(file);
+ fsync(fd);
+ fclose(file);
+
+ if(lsetxattr(info_file, "security.SMACK64", app_info_label, strlen(app_info_label), 0)) {
+ _LOGE("error(%d) in setting smack label",errno);
+ }
+ ret = chmod(info_file, 0777);
+ if(ret < 0)
+ return;
+
+ ret = chown(info_file, 5000, 5000);
+ if(ret < 0)
+ return;
+}
+
+void __getsize_send_signal(const char *req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val)
+{
+ dbus_uint32_t serial = 0;
+ DBusMessage *msg;
+ DBusMessageIter args;
+ DBusError err;
+ DBusConnection *conn;
+ const char *values[] = {
+ req_id,
+ pkg_type,
+ pkgid,
+ key,
+ val
+ };
+ int i;
+
+ dbus_error_init(&err);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err)) {
+ _LOGE("Connection error: %s", err.message);
+ }
+ if (NULL == conn) {
+ _LOGE("conn is NULL");
+ return;
+ }
+
+ msg = dbus_message_new_signal(COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH, COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE, COMM_STATUS_BROADCAST_EVENT_GET_SIZE);
+ if (NULL == msg) {
+ _LOGE("msg is NULL");
+ return;
+ }
+
+ dbus_message_iter_init_append(msg, &args);
+
+ for (i = 0; i < 5; i++) {
+ if (!dbus_message_iter_append_basic
+ (&args, DBUS_TYPE_STRING, &(values[i]))) {
+ _LOGE("dbus_message_iter_append_basic failed:"
+ " Out of memory");
+ return;
+ }
+ }
+ if (!dbus_connection_send(conn, msg, &serial)) {
+ _LOGE("dbus_connection_send failed: Out of memory");
+ return;
+ }
+ dbus_connection_flush(conn);
+ dbus_message_unref(msg);
+}
+
+static int __send_sizeinfo_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid;
+ int data_size = 0;
+ int total_size = 0;
+
+ char total_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ char data_buf[MAX_PKG_BUF_LEN] = {'\0'};
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ _LOGE("pkgmgr_pkginfo_get_pkgid() failed\n");
+ }
+
+ ret = __get_size_info(pkgid, &data_size, &total_size);
+
+ /*send size info to client*/
+ snprintf(total_buf, MAX_PKG_BUF_LEN - 1, "%d", total_size);
+ snprintf(data_buf, MAX_PKG_BUF_LEN - 1, "%d", data_size);
+
+ __getsize_send_signal(PKGMGR_INSTALLER_GET_SIZE_KEY_STR, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, pkgid, data_buf, total_buf);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = -1;
+ int data_size = 0;
+ int total_size = 0;
+ int get_type = 0;
+ char *pkgid = NULL;
+ char *req_key = NULL;
+
+ char data_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ char total_buf[MAX_PKG_BUF_LEN] = {'\0'};
+ pkgmgr_installer *pi = NULL;
+
+ // argv has bellowed meaning
+ // argv[0] = pkgid
+ // argv[1] = get type
+ // argv[2] = req_key
+
+ if(argv[0] == NULL) {
+ _LOGE("pkgid is NULL\n");
+ return -1;
+ }
+
+ pkgid = argv[0];
+ get_type = atoi(argv[1]);
+
+ _LOGD("start get size : [pkgid = %s, request type = %d] \n", pkgid, get_type);
+
+ if(get_type == PM_GET_SIZE_INFO) {
+ ret = pkgmgrinfo_pkginfo_get_list(__send_sizeinfo_cb, NULL);
+ __getsize_send_signal(PKGMGR_INSTALLER_GET_SIZE_KEY_STR, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, "get_size", "get_size", "end");
+ } else if(get_type == PM_GET_ALL_PKGS) {
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, &total_size);
+ } else if(get_type == PM_GET_SIZE_FILE) {
+ ret = __create_size_info(argc, argv);
+ } else {
+ ret = __get_size_info(pkgid, &data_size, &total_size);
+ }
+
+ if(get_type != PM_GET_SIZE_INFO) {
+ pi = pkgmgr_installer_new();
+ if (!pi) {
+ _LOGD("Failure in creating the pkgmgr_installer object");
+ } else {
+ snprintf(data_buf, MAX_PKG_BUF_LEN - 1, "%d", data_size);
+ snprintf(total_buf, MAX_PKG_BUF_LEN - 1, "%d", total_size);
+ pkgmgr_installer_receive_request(pi, argc, argv);
+ pkgmgr_installer_send_signal(pi, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, pkgid, data_buf, total_buf);
+ pkgmgr_installer_free(pi);
+ }
+// __getsize_send_signal(PKGMGR_INSTALLER_GET_SIZE_KEY_STR, PKGMGR_INSTALLER_GET_SIZE_KEY_STR, pkgid, data_buf, total_buf);
+ }
+
+ req_key = (char *)calloc(strlen(argv[2])+1, sizeof(char));
+ if(req_key == NULL)
+ return -1;
+ strncpy(req_key, argv[2], strlen(argv[2]));
+
+ if (strncmp(req_key, pkgid, strlen(pkgid)) == 0) {
+ _LOGD("make a file for sync request [pkgid = %s] \n", pkgid);
+ __make_size_info_file(req_key , total_size);
+ }
+
+ _LOGD("finish get size : [result = %d] \n", ret);
+
+ free(req_key);
+ return 0;
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <vconf.h>
+#include <pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+#include "package-manager.h"
+#include "package-manager-types.h"
+#include "pkgmgr-dbinfo.h"
+#include "pkgmgr_installer.h"
+
+
+static void __print_usage();
+static int __get_pkg_info(char *pkgid);
+static int __get_app_info(char *appid);
+static int __get_app_list(char *pkgid);
+static int __get_app_category_list(char *appid);
+static int __get_app_metadata_list(char *appid);
+static int __get_app_control_list(char *appid);
+static int __get_pkg_list(void);
+static int __get_installed_app_list();
+static int __add_app_filter(void);
+static int __add_pkg_filter(void);
+static int __insert_manifest_in_db(char *manifest);
+static int __remove_manifest_from_db(char *manifest);
+static int __set_pkginfo_in_db(char *pkgid);
+static int __set_certinfo_in_db(char *pkgid);
+static int __get_certinfo_from_db(char *pkgid);
+static int __del_certinfo_from_db(char *pkgid);
+static int __get_integer_input_data(void);
+char *__get_string_input_data(void);
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data);
+static int __app_category_list_cb(const char *category_name, void *user_data);
+static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data);
+static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
+int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data);
+
+static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *type = NULL;
+ char *version = NULL;
+ char *author_name = NULL;
+ char *author_email = NULL;
+ char *author_href = NULL;
+ char *root_path = NULL;
+ char *mainappid = NULL;
+ pkgmgr_install_location location = 0;
+ char *icon = NULL;
+ char *label = NULL;
+ char *desc = NULL;
+ bool removable = 0;
+ bool preload = 0;
+ bool readonly = 0;
+ bool update = 0;
+ bool system = 0;
+ int size = -1;
+ int installed_time = -1;
+
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if (ret < 0) {
+ printf("Failed to get pkg type\n");
+ }
+ if (type)
+ printf("Type: %s\n", type);
+
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
+ if (ret < 0) {
+ printf("Failed to get version\n");
+ }
+ if (version)
+ printf("Version: %s\n", version);
+
+ ret = pkgmgrinfo_pkginfo_get_install_location(handle, &location);
+ if (ret < 0) {
+ printf("Failed to get install location\n");
+ }
+ printf("Install Location: %d\n", location);
+
+ ret = pkgmgrinfo_pkginfo_get_package_size(handle, &size);
+ if (ret < 0) {
+ printf("Failed to get package size \n");
+ }
+ printf("Package Size: %d\n", size);
+
+ ret = pkgmgrinfo_pkginfo_get_icon(handle, &icon);
+ if (ret < 0) {
+ printf("Failed to get icon\n");
+ }
+ if (icon)
+ printf("Icon: %s\n", icon);
+
+ ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
+ if (ret < 0) {
+ printf("Failed to get label\n");
+ }
+ if (label)
+ printf("Label: %s\n", label);
+
+ ret = pkgmgrinfo_pkginfo_get_description(handle, &desc);
+ if (ret < 0) {
+ printf("Failed to get description\n");
+ }
+ if (desc)
+ printf("Description: %s\n", desc);
+
+ ret = pkgmgrinfo_pkginfo_get_author_name(handle, &author_name);
+ if (ret < 0) {
+ printf("Failed to get author name\n");
+ }
+ if (author_name)
+ printf("Author Name: %s\n", author_name);
+
+ ret = pkgmgrinfo_pkginfo_get_author_email(handle, &author_email);
+ if (ret < 0) {
+ printf("Failed to get author email\n");
+ }
+ if (author_email)
+ printf("Author Email: %s\n", author_email);
+
+ ret = pkgmgrinfo_pkginfo_get_author_href(handle, &author_href);
+ if (ret < 0) {
+ printf("Failed to get author href\n");
+ }
+ if (author_href)
+ printf("Author Href: %s\n", author_href);
+
+ ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
+ if (ret < 0) {
+ printf("Failed to get root_path\n");
+ }
+ if (author_href)
+ printf("root_path : %s\n", root_path);
+
+ ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid);
+ if (ret < 0) {
+ printf("Failed to get mainappid\n");
+ }
+ if (author_href)
+ printf("mainappid : %s\n", mainappid);
+
+ ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
+ if (ret < 0) {
+ printf("Failed to get install time\n");
+ }
+ printf("Install time: %d\n", installed_time);
+
+ ret = pkgmgrinfo_pkginfo_is_removable(handle, &removable);
+ if (ret < 0) {
+ printf("Failed to get removable\n");
+ }
+ else
+ printf("Removable: %d\n", removable);
+
+ ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
+ if (ret < 0) {
+ printf("Failed to get preload\n");
+ }
+ else
+ printf("Preload: %d\n", preload);
+
+ ret = pkgmgrinfo_pkginfo_is_readonly(handle, &readonly);
+ if (ret < 0) {
+ printf("Failed to get readonly\n");
+ }
+ else
+ printf("Readonly: %d\n", readonly);
+
+ ret = pkgmgrinfo_pkginfo_is_update(handle, &update);
+ if (ret < 0) {
+ printf("Failed to get update\n");
+ }
+ else
+ printf("update: %d\n", update);
+
+ ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
+ if (ret < 0) {
+ printf("Failed to get system\n");
+ }
+ else
+ printf("system: %d\n", system);
+
+ return 0;
+}
+int __get_app_id(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *appid = NULL;
+ char *apptype = NULL;
+ int ret = -1;
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret < 0) {
+ printf("Failed to get appid\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
+ if (ret < 0) {
+ printf("Failed to get package\n");
+ }
+ printf("apptype [%s]\t appid [%s]\n", apptype, appid);
+
+ return 0;
+}
+
+static int __get_integer_input_data(void)
+{
+ char input_str[32] = { 0, };
+ int data = 0;
+
+ if (fgets(input_str, sizeof(input_str), stdin) == NULL) {
+ printf("fgets() failed....\n");
+ return -1;
+ }
+
+ if (sscanf(input_str, "%4d", &data) != 1) {
+ printf("Input only integer option....\n");
+ return -1;
+ }
+
+ return data;
+}
+
+
+char *__get_string_input_data(void)
+{
+ char *data = (char *)malloc(1024);
+ if (data == NULL) {
+ printf("Malloc Failed\n");
+ return NULL;
+ }
+ if (fgets(data,1024,stdin) == NULL){
+ printf("Buffer overflow!!! try again\n");
+ exit(-1);
+ }
+ data[strlen(data) - 1] = '\0';
+ return data;
+}
+
+static void __print_usage()
+{
+ printf("For Getting package|App Info\n");
+ printf("\tpkginfo --[pkg|app] <pkgid|appid>\n\n");
+ printf("For Getting list of installed packages\n");
+ printf("\tpkginfo --listpkg \n\n");
+ printf("For Getting list of installed applications\n");
+ printf("\tpkginfo --listapp \n\n");
+ printf("For Getting list of disabled packages\n");
+ printf("\tpkginfo --listdisabled\n\n");
+ printf("For Getting app list for a particular package\n");
+ printf("\tpkginfo --list <pkgid>\n\n");
+ printf("For Getting app category list for a particular application\n");
+ printf("\tpkginfo --category <appid>\n\n");
+ printf("For Getting app metadata list for a particular application\n");
+ printf("\tpkginfo --metadata <appid>\n\n");
+ printf("For Getting app control list for a particular application\n");
+ printf("\tpkginfo --appcontrol <appid>\n\n");
+ printf("To insert|remove manifest info in DB\n");
+ printf("\tpkginfo --[imd|rmd] <manifest file name>\n\n");
+ printf("To set pkginfo in DB\n");
+ printf("\tpkginfo --setdb <pkgid>\n\n");
+ printf("To set manifest validation\n");
+ printf("\tpkginfo --check <manifest file name>\n\n");
+ printf("To set cert info in DB\n");
+ printf("\tpkginfo --setcert <pkgid>\n\n");
+ printf("To get cert info from DB\n");
+ printf("\tpkginfo --getcert <pkgid>\n\n");
+ printf("To compare pkg cert info from DB\n");
+ printf("\tpkginfo --cmp-pkgcert <lhs_pkgid> <rhs_pkgid>\n\n");
+ printf("To compare app cert info from DB\n");
+ printf("\tpkginfo --cmp-appcert <lhs_appid> <rhs_appid>\n\n");
+ printf("To delete all cert info from DB\n");
+ printf("\tpkginfo --delcert <pkgid>\n\n");
+ printf("To add application filter values [Multiple values can be added]\n");
+ printf("\tpkginfo --app-flt\n\n");
+ printf("To add package filter values [Multiple values can be added]\n");
+ printf("\tpkginfo --pkg-flt\n\n");
+ printf("To add metadata filter values\n");
+ printf("\tpkginfo --metadata-flt\n\n");
+}
+
+static void __print_arg_filter_usage()
+{
+ printf("=========================================\n");
+ printf("pkginfo --arg-flt key value\n");
+ printf("ex : pkginfo --arg-flt 6 webapp\n");
+ printf("key list is bellowed\n");
+ printf("2 --> filter by app ID\n");
+ printf("3 --> filter by app component\n");
+ printf("4 --> filter by app exec\n");
+ printf("5 --> filter by app icon\n");
+ printf("6 --> filter by app type\n");
+ printf("7 --> filter by app operation\n");
+ printf("8 --> filter by app uri\n");
+ printf("9 --> filter by app mime\n");
+ printf("10 --> filter by app category\n");
+ printf("11 --> filter by app nodisplay [0|1]\n");
+ printf("12 --> filter by app multiple [0|1]\n");
+ printf("13 --> filter by app onboot [0|1]\n");
+ printf("14 --> filter by app autorestart [0|1]\n");
+ printf("15 --> filter by app taskmanage [0|1]\n");
+ printf("16 --> filter by app hwacceleration\n");
+ printf("17 --> filter by app screenreader\n");
+ printf("=========================================\n");
+}
+
+static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *appid = NULL;
+ pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ printf("appid : %s\n", appid);
+ return 0;
+}
+
+static int __add_metadata_filter()
+{
+ int ret = 0;
+ pkgmgrinfo_appinfo_metadata_filter_h handle;
+ char *key = NULL;
+ char *value = NULL;
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
+ if (ret != PMINFO_R_OK){
+ printf("pkgmgrinfo_appinfo_metadata_filter_create() failed\n");
+ return ret;
+ }
+
+ printf("enter metadata - key\n");
+ key = __get_string_input_data();
+ printf("enter metadata - value\n");
+ value = __get_string_input_data();
+
+ printf("filter condition : key=[%s], value=[%s]\n", key, value);
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, key, value);
+ if (ret != PMINFO_R_OK){
+ printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
+ goto err;
+ }
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, __app_list_cb, NULL);
+ if (ret != PMINFO_R_OK){
+ printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
+ goto err;
+ }
+
+err:
+ pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
+ if (key) {
+ free(key);
+ key = NULL;
+ }
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ return ret;
+}
+
+static int __add_app_filter()
+{
+ int ret = 0;
+ int choice = -1;
+ char *value = NULL;
+ int val = -1;
+ int count = 0;
+ pkgmgrinfo_appinfo_filter_h handle;
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
+ if (ret > 0) {
+ printf("appinfo filter handle create failed\n");
+ return -1;
+ }
+ while (choice != 0 && choice != 1)
+ {
+ printf("Enter Choice\n");
+ printf("0 --> Finalize filter and get count of apps\n");
+ printf("1 --> Finalize filter and get list of apps\n");
+ printf("2 --> filter by app ID\n");
+ printf("3 --> filter by app component\n");
+ printf("4 --> filter by app exec\n");
+ printf("5 --> filter by app icon\n");
+ printf("6 --> filter by app type\n");
+ printf("7 --> filter by app operation\n");
+ printf("8 --> filter by app uri\n");
+ printf("9 --> filter by app mime\n");
+ printf("10 --> filter by app category\n");
+ printf("11 --> filter by app nodisplay [0|1]\n");
+ printf("12 --> filter by app multiple [0|1]\n");
+ printf("13 --> filter by app onboot [0|1]\n");
+ printf("14 --> filter by app autorestart [0|1]\n");
+ printf("15 --> filter by app taskmanage [0|1]\n");
+ printf("16 --> filter by app hwacceleration\n");
+ printf("17 --> filter by app screenreader\n");
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_count() failed\n");
+ ret = -1;
+ goto err;
+ }
+ printf("App count = %d\n", count);
+ break;
+ case 1:
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 2:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_ID, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 3:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_COMPONENT, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 4:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_EXEC, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 5:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_ICON, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 6:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_TYPE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 7:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_OPERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 8:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_URI, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 9:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_MIME, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 10:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_CATEGORY, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 11:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 12:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 13:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_ONBOOT, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 14:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 15:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 16:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 17:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle,
+ PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ default:
+ printf("Invalid filter property\n");
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ ret = -1;
+ goto err;
+ }
+ }
+ ret = 0;
+err:
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ return ret;
+}
+
+static int __add_pkg_filter()
+{
+ int ret = 0;
+ int choice = -1;
+ char *value = NULL;
+ int val = -1;
+ int count = 0;
+ pkgmgrinfo_pkginfo_filter_h handle;
+ ret = pkgmgrinfo_pkginfo_filter_create(&handle);
+ if (ret > 0) {
+ printf("pkginfo filter handle create failed\n");
+ return -1;
+ }
+ while (choice != 0 && choice !=1)
+ {
+ printf("Enter Choice\n");
+ printf("0 --> Finalize filter and get count of packages\n");
+ printf("1 --> Finalize filter and get list of packages\n");
+ printf("2 --> filter by package ID\n");
+ printf("3 --> filter by package version\n");
+ printf("4 --> filter by package type\n");
+ printf("5 --> filter by package install location\n");
+ printf("6 --> filter by author name\n");
+ printf("7 --> filter by author email\n");
+ printf("8 --> filter by author href\n");
+ printf("9 --> filter by package removable [0|1]\n");
+ printf("10 --> filter by package readonly [0|1]\n");
+ printf("11 --> filter by package preload [0|1]\n");
+ printf("12 --> filter by package update [0|1]\n");
+ printf("13 --> filter by package appsetting [0|1]\n");
+ printf("14 --> filter by package size\n");
+ printf("15 --> filter by package installed storage[installed_internal | installed_external]\n");
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_count() failed\n");
+ ret = -1;
+ goto err;
+ }
+ printf("Package count = %d\n", count);
+ break;
+ case 1:
+ ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_foreach_pkginfo() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 2:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_ID, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 3:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_VERSION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 4:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_TYPE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 5:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 6:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 7:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 8:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 9:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 10:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_READONLY, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 11:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 12:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_UPDATE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 13:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 14:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_int(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_SIZE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_int() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 15:
+ value = __get_string_input_data();
+ ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ default:
+ printf("Invalid filter property\n");
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ ret = -1;
+ goto err;
+ }
+ }
+ ret = 0;
+err:
+ pkgmgrinfo_pkginfo_filter_destroy(handle);
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ return ret;
+}
+
+static int __add_arg_filter(char *key, char *value)
+{
+ int ret = 0;
+ int choice = -1;
+ int val = -1;
+ pkgmgrinfo_appinfo_filter_h handle;
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
+ if (ret > 0) {
+ printf("appinfo filter handle create failed\n");
+ return -1;
+ }
+ choice = atoi(key);
+
+ switch (choice) {
+ case 2:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 3:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_COMPONENT, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 4:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_EXEC, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 5:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ICON, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 6:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 7:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_OPERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 8:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_URI, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 9:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_MIME, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 10:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 11:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 12:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 13:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_ONBOOT, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 14:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 15:
+ val = atoi(value);
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 16:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+ case 17:
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
+
+ default:
+ __print_arg_filter_usage();
+ goto err;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
+ ret = -1;
+ goto err;
+ }
+
+err:
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ return ret;
+}
+static int __del_certinfo_from_db(char *pkgid)
+{
+ int ret = 0;
+ if (pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_installer_delete_certinfo(pkgid);
+ if (ret < 0) {
+ printf("pkgmgr_installer_delete_certinfo failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_certinfo_from_db(char *pkgid)
+{
+ if (pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+ int ret = 0;
+ int choice = -1;
+ int i = 0;
+ const char *value = NULL;
+ pkgmgr_certinfo_h handle = NULL;
+ ret = pkgmgr_pkginfo_create_certinfo(&handle);
+ if (ret < 0) {
+ printf("pkgmgr_pkginfo_create_certinfo failed\n");
+ return -1;
+ }
+ ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle);
+ if (ret < 0) {
+ printf("pkgmgr_pkginfo_load_certinfo failed\n");
+ return -1;
+ }
+ while (choice != 0)
+ {
+ printf("Enter the choice to get\n");
+ printf("0 --> to get all cert values\n");
+ printf("1 --> author root certificate\n");
+ printf("2 --> author intermediate certificate\n");
+ printf("3 --> author signer certificate\n");
+ printf("4 --> distributor root certificate\n");
+ printf("5 --> distributor intermediate certificate\n");
+ printf("6 --> distributor signer certificate\n");
+ printf("7 --> distributor2 root certificate\n");
+ printf("8 --> distributor2 intermediate certificate\n");
+ printf("9 --> distributor2 signer certificate\n");
+ printf("10 --> exit\n");
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ for (i = 0; i < 9; i++)
+ {
+ pkgmgr_pkginfo_get_cert_value(handle, i, &value);
+ if (value)
+ printf("cert type[%d] value = %s\n", i, value);
+ }
+ ret = pkgmgr_pkginfo_destroy_certinfo(handle);
+ if (ret < 0) {
+ printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
+ ret = -1;
+ goto end;
+ }
+ ret = 0;
+ goto end;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ ret = pkgmgr_pkginfo_get_cert_value(handle, choice - 1, &value);
+ if (value)
+ printf("cert type[%d] value = %s\n", choice - 1, value);
+ break;
+ case 10:
+ ret = pkgmgr_pkginfo_destroy_certinfo(handle);
+ if (ret < 0) {
+ printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
+ return -1;
+ }
+ ret = 0;
+ goto end;
+ default:
+ printf("Invalid choice entered\n");
+ ret = -1;
+ break;
+ }
+ }
+
+end:
+ return ret;
+}
+
+static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid)
+{
+ if (lhs_pkgid == NULL || rhs_pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+
+ int ret = 0;
+ pkgmgrinfo_cert_compare_result_type_e result;
+ ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
+ if (ret != PMINFO_R_OK) {
+ return -1;
+ }
+
+ printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
+ printf("pkgid =[%s] and [%s] compare result = [%d] \n", lhs_pkgid, rhs_pkgid, result);
+ return 0;
+}
+
+static int __compare_app_certinfo_from_db(char *lhs_appid, char *rhs_appid)
+{
+ if (lhs_appid == NULL || rhs_appid == NULL) {
+ printf("appid is NULL\n");
+ return -1;
+ }
+
+ int ret = 0;
+ pkgmgrinfo_cert_compare_result_type_e result;
+ ret = pkgmgrinfo_pkginfo_compare_app_cert_info(lhs_appid, rhs_appid, &result);
+ if (ret != PMINFO_R_OK) {
+ return -1;
+ }
+
+ printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
+ printf("appid =[%s] and [%s] compare result = [%d] \n", lhs_appid, rhs_appid, result);
+ return 0;
+}
+
+static int __set_certinfo_in_db(char *pkgid)
+{
+ if (pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+ int ret = 0;
+ int choice = -1;
+ char *value = NULL;
+ pkgmgr_instcertinfo_h handle = NULL;
+ ret = pkgmgr_installer_create_certinfo_set_handle(&handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_create_certinfo_set_handle failed\n");
+ return -1;
+ }
+ while (choice != 0)
+ {
+ printf("Enter the choice you want to set\n");
+ printf("0 --> to set data in DB\n");
+ printf("1 --> author root certificate\n");
+ printf("2 --> author intermediate certificate\n");
+ printf("3 --> author signer certificate\n");
+ printf("4 --> distributor root certificate\n");
+ printf("5 --> distributor intermediate certificate\n");
+ printf("6 --> distributor signer certificate\n");
+ printf("7 --> distributor2 root certificate\n");
+ printf("8 --> distributor2 intermediate certificate\n");
+ printf("9 --> distributor2 signer certificate\n");
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ ret = pkgmgr_installer_save_certinfo(pkgid, handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_save_certinfo failed\n");
+ pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ return -1;
+ }
+ ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
+ return -1;
+ }
+ return 0;
+ case 1:
+ printf("Enter Author Root Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 0, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 2:
+ printf("Enter Author Intermediate Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 1, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 3:
+ printf("Enter Author Signer Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 2, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 4:
+ printf("Enter Distributor Root Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 3, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 5:
+ printf("Enter Distributor Intermediate Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 4, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 6:
+ printf("Enter Distributor Signer Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 5, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 7:
+ printf("Enter Distributor2 Root Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 6, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 8:
+ printf("Enter Distributor2 Intermediate Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 7, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ case 9:
+ printf("Enter Distributor2 Signer Certificate Value: \n");
+ value = __get_string_input_data();
+ ret = pkgmgr_installer_set_cert_value(handle, 8, value);
+ if (ret < 0) {
+ printf("pkgmgr_installer_set_cert_value failed\n");
+ ret = -1;
+ goto err;
+ }
+ free(value);
+ value = NULL;
+ break;
+ default:
+ printf("Invalid Number Entered\n");
+ choice = 0;
+ ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ if (ret < 0) {
+ printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
+ return -1;
+ }
+ break;
+ }
+ }
+err:
+ if (value) {
+ free(value);
+ value = NULL;
+ }
+ pkgmgr_installer_destroy_certinfo_set_handle(handle);
+ return ret;
+}
+
+static int __set_pkginfo_in_db(char *pkgid)
+{
+ if (pkgid == NULL) {
+ printf("pkgid is NULL\n");
+ return -1;
+ }
+ int ret = 0;
+ int choice = -1;
+ int preload = -1;
+ int removable = -1;
+ int location = -1;
+ char *locale = NULL;
+ pkgmgr_pkgdbinfo_h handle = NULL;
+ INSTALL_LOCATION storage = 0;
+
+ ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+ if (ret < 0) {
+ printf("pkgmgrinfo_create_pkgdbinfo failed\n");
+ return -1;
+ }
+ while (choice != 0)
+ {
+ printf("Enter the choice you want to set\n");
+ printf("0 --> to set data in DB\n");
+ printf("1 --> pkg type\n");
+ printf("2 --> pkg version\n");
+ printf("3 --> pkg instal location\n");
+ printf("4 --> pkg label\n");
+ printf("5 --> pkg icon\n");
+ printf("6 --> pkg description\n");
+ printf("7 --> pkg author\n");
+ printf("8 --> pkg removable\n");
+ printf("9 --> pkg preload\n");
+ printf("10 --> pkg size\n");
+ printf("11 --> pkg installed storage\n");
+ choice = __get_integer_input_data();
+ switch (choice) {
+ case 0:
+ ret = pkgmgrinfo_save_pkgdbinfo(handle);
+ if (ret < 0) {
+ printf("pkgmgrinfo_save_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ return -1;
+ }
+ ret = pkgmgrinfo_destroy_pkgdbinfo(handle);
+ if (ret < 0) {
+ printf("pkgmgrinfo_destroy_pkgdbinfo failed\n");
+ return -1;
+ }
+ break;
+ case 1:
+ printf("Enter type: \n");
+ char *type = __get_string_input_data();
+ ret = pkgmgrinfo_set_type_to_pkgdbinfo(handle, type);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_type_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ free(type);
+ return -1;
+ }
+ free(type);
+ break;
+ case 2:
+ printf("Enter version: \n");
+ char *version = __get_string_input_data();
+ ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, version);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_version_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ free(version);
+ return -1;
+ }
+ free(version);
+ break;
+ case 3:
+ printf("Enter install location [0:internal | 1:external]: \n");
+ location = __get_integer_input_data();
+ ret = pkgmgrinfo_set_install_location_to_pkgdbinfo(handle, location);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_install_location_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ return -1;
+ }
+ break;
+ case 4:
+ printf("Enter label :\n");
+ char *label = __get_string_input_data();
+ printf("Enter locale ['def' for default]: \n");
+ locale = __get_string_input_data();
+ if (strcmp(locale, "def") == 0)
+ ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, NULL);
+ else
+ ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, locale);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_label_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ free(locale);
+ free(label);
+ return -1;
+ }
+ free(locale);
+ free(label);
+ break;
+ case 5:
+ printf("Enter icon: \n");
+ char *icon = __get_string_input_data();
+ printf("Enter locale ['def' for default]: \n");
+ locale = __get_string_input_data();
+ if (strcmp(locale, "def") == 0)
+ ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, NULL);
+ else
+ ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, locale);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_icon_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ free(locale);
+ free(icon);
+ return -1;
+ }
+ free(locale);
+ free(icon);
+ break;
+ case 6:
+ printf("Enter description: \n");
+ char *description = __get_string_input_data();
+ printf("Enter locale ['def' for default]: \n");
+ locale = __get_string_input_data();
+ if (strcmp(locale, "def") == 0)
+ ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, NULL);
+ else
+ ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, locale);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_description_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ free(locale);
+ free(description);
+ return -1;
+ }
+ free(locale);
+ free(description);
+ break;
+ case 7:
+ printf("Enter author name: \n");
+ char *author_name = __get_string_input_data();
+ printf("Enter locale ['def' for default]: \n");
+ locale = __get_string_input_data();
+ printf("Enter author email: \n");
+ char *author_email = __get_string_input_data();
+ printf("Enter author href: \n");
+ char *author_href = __get_string_input_data();
+ if (strcmp(locale, "def") == 0)
+ ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, NULL);
+ else
+ ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, locale);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_author_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ free(locale);
+ free(author_name);
+ free(author_email);
+ free(author_href);
+ return -1;
+ }
+ free(locale);
+ free(author_name);
+ free(author_email);
+ free(author_href);
+ break;
+ case 8:
+ printf("Enter removable [0:false | 1:true]: \n");
+ removable = __get_integer_input_data();
+ ret = pkgmgrinfo_set_removable_to_pkgdbinfo(handle, removable);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_removable_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ return -1;
+ }
+ break;
+ case 9:
+ printf("Enter preload [0:false | 1:true]: \n");
+ preload = __get_integer_input_data();
+ ret = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, preload);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_preload_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ return -1;
+ }
+ break;
+ case 10:
+ printf("Enter size in MB \n");
+ char *size = __get_string_input_data();
+ ret = pkgmgrinfo_set_size_to_pkgdbinfo(handle, size);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_size_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ free(size);
+ return -1;
+ }
+ free(size);
+ break;
+ case 11:
+ printf("Enter insatlled storage [ 0:INTERNAL | 1:EXTERNAL ] \n");
+ storage = __get_integer_input_data();
+ ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, storage);
+ if (ret < 0) {
+ printf("pkgmgrinfo_set_installed_storage_to_pkgdbinfo failed\n");
+ pkgmgrinfo_destroy_pkgdbinfo(handle);
+ return -1;
+ }
+ break;
+ default:
+ printf("Invalid number entered\n");
+ continue;
+ }
+ }
+ return 0;
+}
+
+static int __insert_manifest_in_db(char *manifest)
+{
+ int ret = 0;
+ if (manifest == NULL) {
+ printf("Manifest file is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
+ if (ret < 0) {
+ printf("insert in db failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __fota_insert_manifest_in_db(char *manifest)
+{
+ int ret = 0;
+ char *temp[] = {"fota=true", NULL};
+
+ if (manifest == NULL) {
+ printf("Manifest file is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_parser_parse_manifest_for_installation(manifest, temp);
+ if (ret < 0) {
+ printf("insert in db failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __remove_manifest_from_db(char *manifest)
+{
+ int ret = 0;
+ if (manifest == NULL) {
+ printf("Manifest file is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
+ if (ret < 0) {
+ printf("remove from db failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+ char *appid;
+ char *data = NULL;
+ if (user_data) {
+ data = (char *)user_data;
+ }
+ int ret = -1;
+ char *exec = NULL;
+ char *icon = NULL;
+ char *label = NULL;
+ pkgmgr_app_component component = 0;
+ char *apptype = NULL;
+ bool nodisplay = 0;
+ bool multiple = 0;
+ bool taskmanage = 0;
+ pkgmgr_hwacceleration_type hwacceleration;
+ pkgmgrinfo_app_screenreader screenreader;
+ bool onboot = 0;
+ bool autorestart = 0;
+ char *package = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret < 0) {
+ printf("Failed to get appid\n");
+ }
+ if (appid)
+ printf("Appid: %s\n", appid);
+
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
+ if (ret < 0) {
+ printf("Failed to get package\n");
+ }
+ if (package)
+ printf("Package: %s\n", package);
+
+ ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+ if (ret < 0) {
+ printf("Failed to get exec\n");
+ }
+ if (exec)
+ printf("Exec: %s\n", exec);
+
+ ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
+ if (ret < 0) {
+ printf("Failed to get icon\n");
+ }
+ if (icon)
+ printf("Icon: %s\n", icon);
+
+ ret = pkgmgrinfo_appinfo_get_label(handle, &label);
+ if (ret < 0) {
+ printf("Failed to get label\n");
+ }
+ if (label)
+ printf("Label: %s\n", label);
+
+ ret = pkgmgrinfo_appinfo_get_component(handle, &component);
+ if (ret < 0) {
+ printf("Failed to get component\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
+ if (ret < 0) {
+ printf("Failed to get apptype\n");
+ }
+ if (apptype)
+ printf("Apptype: %s\n", apptype);
+
+ if (component == PM_UI_APP) {
+ printf("component: uiapp\n");
+ ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
+ if (ret < 0) {
+ printf("Failed to get multiple\n");
+ } else {
+ printf("Multiple: %d\n", multiple);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
+ if (ret < 0) {
+ printf("Failed to get nodisplay\n");
+ } else {
+ printf("Nodisplay: %d \n", nodisplay);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
+ if (ret < 0) {
+ printf("Failed to get taskmanage\n");
+ } else {
+ printf("Taskmanage: %d\n", taskmanage);
+ }
+
+ ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
+ if (ret < 0) {
+ printf("Failed to get hwacceleration\n");
+ } else {
+ printf("hw-acceleration: %d\n", hwacceleration);
+ }
+
+ ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
+ if (ret < 0) {
+ printf("Failed to get screenreader\n");
+ } else {
+ printf("screenreader: %d\n", screenreader);
+ }
+
+ }
+ if (component == PM_SVC_APP) {
+ printf("component: svcapp\n");
+ ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
+ if (ret < 0) {
+ printf("Failed to get onboot\n");
+ } else {
+ printf("Onboot: %d\n", onboot);
+ }
+
+ ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
+ if (ret < 0) {
+ printf("Failed to get autorestart\n");
+ } else {
+ printf("Autorestart: %d \n", autorestart);
+ }
+ }
+ if (data)
+ printf("user_data : %s\n\n", data);
+
+ return 0;
+}
+
+
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+ char *test_data = "test data";
+ int ret = -1;
+ char *pkgid;
+ char *pkg_type;
+ char *pkg_version;
+ bool preload = 0;
+ int installed_time = -1;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_type() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_version() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_is_preload() failed\n");
+ }
+ ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_installed_time() failed\n");
+ }
+
+
+ printf("---------------------------------------\n");
+ printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tinstalled_time [%d]\n", pkg_type,
+ pkgid, pkg_version, preload, installed_time);
+
+ printf("**List of Ui-Apps**\n");
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
+ if (ret < 0) {
+ printf("pkgmgrinfo_get_info_app() failed\n");
+ }
+ printf("**List of Svc-Apps**\n");
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
+ if (ret < 0) {
+ printf("pkgmgrinfo_get_info_app() failed\n");
+ }
+
+ printf("---------------------------------------\n");
+
+ return 0;
+}
+
+static int __disabled_pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
+{
+ int ret = -1;
+ char *pkgid;
+ char *appid;
+ char *label;
+ char *icon;
+ char *pkg_type;
+ char *pkg_version;
+ bool preload = 0;
+ pkgmgrinfo_appinfo_h apphandle;
+
+ ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
+ return 0;
+ }
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_type() failed\n");
+ }
+
+ ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &appid);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_mainappid() failed\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_disabled_appinfo(appid, &apphandle);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_mainappid() failed\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_label(apphandle, &label);
+ if(ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_mainappid() failed\n");
+ }
+ ret = pkgmgrinfo_appinfo_get_icon(apphandle, &icon);
+ if(ret < 0) {
+ printf("pkgmgrinfo_appinfo_get_icon() failed\n");
+ }
+
+ printf("---------------------------------------\n");
+ printf("pkg info : pkgid=[%s] type=[%s] mainappid=[%s]\n", pkgid, pkg_type, appid);
+ printf("app info : appid=[%s] label=[%s] icon=[%s]\n", appid, label, icon);
+ printf("---------------------------------------\n");
+
+ pkgmgrinfo_appinfo_destroy_appinfo(apphandle);
+
+ return 0;
+}
+
+static int __get_pkg_list()
+{
+ int ret = -1;
+ ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_list() failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_installed_app_list()
+{
+ int ret = -1;
+ ret = pkgmgrinfo_appinfo_get_installed_list(app_func, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_get_installed_list() failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_disabled_pkg_list()
+{
+ int ret = -1;
+ ret = pkgmgrinfo_pkginfo_get_disabled_list(__disabled_pkg_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_pkginfo_get_disabled_list() failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __app_category_list_cb(const char *category_name, void *user_data)
+{
+ if (category_name)
+ printf("Category: %s\n", category_name);
+ return 0;
+}
+
+static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data)
+{
+ if (metadata_name && metadata_value) {
+ printf("Name: %s\n", metadata_name);
+ printf("Value: %s\n", metadata_value);
+ printf("\n");
+ }
+ return 0;
+}
+
+static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data)
+{
+ printf("-------------------------------------------------------\n");
+ int i = 0;
+ int ret = 0;
+ int oc = 0;
+ int mc = 0;
+ int uc = 0;
+ int sc = 0;
+ char **operation = NULL;
+ char **uri = NULL;
+ char **mime = NULL;
+ char **subapp = NULL;
+
+ ret = pkgmgrinfo_appinfo_get_operation(handle, &oc, &operation);
+ if (ret < 0) {
+ printf("Get Operation Failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_get_uri(handle, &uc, &uri);
+ if (ret < 0) {
+ printf("Get Uri Failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_get_mime(handle, &mc, &mime);
+ if (ret < 0) {
+ printf("Get Mime Failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_get_subapp(handle, &sc, &subapp);
+ if (ret < 0) {
+ printf("Get subapp Failed\n");
+ return -1;
+ }
+
+ for (i = 0; i < oc; i++) {
+ if (operation && operation[i])
+ printf("Operation: %s\n", operation[i]);
+ }
+ for (i = 0; i < uc; i++) {
+ if (uri && uri[i])
+ printf("Uri: %s\n", uri[i]);
+ }
+ for (i = 0; i < mc; i++) {
+ if (mime && mime[i])
+ printf("Mime: %s\n", mime[i]);
+ }
+ for (i = 0; i < sc; i++) {
+ if (subapp && subapp[i])
+ printf("subapp: %s\n", subapp[i]);
+ }
+
+ printf("-------------------------------------------------------\n\n");
+ return 0;
+}
+
+
+static int __get_app_category_list(char *appid)
+{
+ int ret = -1;
+ pkgmgrinfo_appinfo_h handle;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_foreach_category() failed\n");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return -1;
+ }
+ pkgmgr_appinfo_destroy_appinfo(handle);
+ return 0;
+}
+
+static int __get_app_metadata_list(char *appid)
+{
+ int ret = -1;
+ pkgmgrinfo_appinfo_h handle;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return -1;
+ }
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return 0;
+}
+
+static int __get_app_control_list(char *appid)
+{
+ int ret = -1;
+ pkgmgrinfo_appinfo_h handle;
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return -1;
+ }
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return 0;
+}
+
+static int __set_app_enabled(char *appid, bool enabled)
+{
+ int ret = -1;
+ ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int __get_app_list(char *pkgid)
+{
+ pkgmgrinfo_pkginfo_h handle;
+ int ret = -1;
+ char *test_data = "test data";
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+ printf("List of Ui-Apps\n\n");
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_get_list() failed\n");
+ }
+ printf("List of Svc-Apps\n\n");
+ ret = pkgmgrinfo_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_get_list() failed\n");
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 0;
+}
+
+static int __get_pkg_info(char *pkgid)
+{
+ pkgmgrinfo_pkginfo_h handle;
+ int ret = -1;
+
+ printf("Get Pkg Info Called [%s]\n", pkgid);
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+
+ __get_pkgmgrinfo_pkginfo(handle, NULL);
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 0;
+}
+
+static int __get_app_info(char *appid)
+{
+ printf("Get App Info Called [%s]\n", appid);
+ char *exec = NULL;
+ char *app_id = NULL;
+ char *apptype = NULL;
+ char *icon = NULL;
+ char *label = NULL;
+ char *package = NULL;
+ pkgmgr_app_component component = 0;
+ bool nodisplay = 0;
+ bool multiple = 0;
+ bool taskmanage = 0;
+ pkgmgr_hwacceleration_type hwacceleration;
+ pkgmgrinfo_app_screenreader screenreader;
+ bool onboot = 0;
+ bool autorestart = 0;
+ bool enabled = 0;
+ bool preload = 0;
+ pkgmgrinfo_appinfo_h handle;
+ int ret = -1;
+
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret < 0) {
+ printf("Failed to get handle\n");
+ return -1;
+ }
+
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
+ if (ret < 0) {
+ printf("Failed to get package\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
+ if (ret < 0) {
+ printf("Failed to get exec\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_label(handle, &label);
+ if (ret < 0) {
+ printf("Failed to get label\n");
+ }
+ ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
+ if (ret < 0) {
+ printf("Failed to get icon\n");
+ }
+
+ ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+ if (ret < 0) {
+ printf("Failed to get exec\n");
+ }
+ ret = pkgmgrinfo_appinfo_get_component(handle, &component);
+ if (ret < 0) {
+ printf("Failed to get component\n");
+ }
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
+ if (ret < 0) {
+ printf("Failed to get apptype\n");
+ }
+ ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
+ if (ret < 0) {
+ printf("Failed to get nodisplay\n");
+ }
+ ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
+ if (ret < 0) {
+ printf("Failed to get multiple\n");
+ }
+ ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
+ if (ret < 0) {
+ printf("Failed to get taskmanage\n");
+ }
+ ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
+ if (ret < 0) {
+ printf("Failed to get hwacceleration\n");
+ }
+ ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
+ if (ret < 0) {
+ printf("Failed to get screenreader\n");
+ }
+ ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
+ if (ret < 0) {
+ printf("Failed to get onboot\n");
+ }
+ ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
+ if (ret < 0) {
+ printf("Failed to get autorestart\n");
+ }
+ ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
+ if (ret < 0) {
+ printf("Failed to get enabled\n");
+ }
+ ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
+ if (ret < 0) {
+ printf("Failed to get preload\n");
+ }
+
+ if (app_id)
+ printf("Appid: %s\n", app_id);
+
+ if (package)
+ printf("Package: %s\n", package);
+
+ if (exec)
+ printf("Exec: %s\n", exec);
+ if (apptype)
+ printf("Apptype: %s\n", apptype);
+
+ if (component == PM_UI_APP) {
+ printf("component: uiapp\n");
+
+ if (icon)
+ printf("Icon: %s\n", icon);
+ if (label)
+ printf("Label: %s\n", label);
+
+ printf("Nodisplay: %d\n", nodisplay);
+ printf("Multiple: %d\n", multiple);
+ printf("Taskmanage: %d\n", taskmanage);
+ printf("Hw-Acceleration: %d\n", hwacceleration);
+ printf("Screenreader: %d\n", screenreader);
+ } else if (component == PM_SVC_APP) {
+ printf("component: svcapp\n");
+
+ if (icon)
+ printf("Icon: %s\n", icon);
+ if (label)
+ printf("Label: %s\n", label);
+
+ printf("Autorestart: %d\n", autorestart);
+ printf("Onboot: %d\n", onboot);
+ } else {
+ printf("Invalid Component Type\n");
+ }
+
+ printf("Enabled: %d\n", enabled);
+ printf("Preload: %d\n", preload);
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ return 0;
+
+}
+
+static int __check_manifest_validation(char *manifest)
+{
+ int ret = 0;
+ if (manifest == NULL) {
+ printf("Manifest file is NULL\n");
+ return -1;
+ }
+ ret = pkgmgr_parser_check_manifest_validation(manifest);
+ if (ret < 0) {
+ printf("check manifest validation failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ char *locale = NULL;
+ long starttime;
+ long endtime;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ locale = vconf_get_str(VCONFKEY_LANGSET);
+ if (locale == NULL)
+ printf("locale is NULL\n");
+ else {
+ printf("Locale is %s\n", locale);
+ free(locale);
+ }
+
+ locale = NULL;
+ if (argc == 2) {
+ if (strcmp(argv[1], "--listpkg") == 0) {
+ ret = __get_pkg_list();
+ if (ret == -1) {
+ printf("get pkg list failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--app-flt") == 0) {
+ ret = __add_app_filter();
+ if (ret == -1) {
+ printf("Adding app filter failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--pkg-flt") == 0) {
+ ret = __add_pkg_filter();
+ if (ret == -1) {
+ printf("Adding pkg filter failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--metadata-flt") == 0) {
+ ret = __add_metadata_filter();
+ if (ret == -1) {
+ printf("Adding pkg filter failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--listapp") == 0) {
+ ret = __get_installed_app_list();
+ if (ret == -1) {
+ printf("get installed app list failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--listdisabled") == 0) {
+ ret = __get_disabled_pkg_list();
+ if (ret == -1) {
+ printf("get disabled pkg list failed\n");
+ goto end;
+ } else {
+ goto end;
+ }
+ } else {
+ __print_usage();
+ ret = -1;
+ goto end;
+ }
+ }else if (argc == 4) {
+ if (strcmp(argv[1], "--setappenabled") == 0) {
+ ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
+ if (ret == -1) {
+ printf("set app enabled failed\n");
+ goto end;
+ }
+ goto end;
+ } else if(strcmp(argv[1], "--setpkgenabled") == 0) {
+ ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
+ if (ret == -1) {
+ printf("set pkg enabled failed\n");
+ goto end;
+ }
+ goto end;
+ } else if (strcmp(argv[1], "--cmp-pkgcert") == 0) {
+ int len = 0;
+ char *r_pkgid = NULL;
+ char *l_pkgid = NULL;
+
+ len = (strlen(argv[2]) + 1);
+ r_pkgid = (char *)calloc(len, sizeof(char));
+ if(r_pkgid == NULL)
+ goto end;
+ strncpy(r_pkgid, argv[2], len - 1);
+
+ len = (strlen(argv[3]) + 1);
+ l_pkgid = (char *)calloc(len, sizeof(char));
+ if(l_pkgid == NULL) {
+ free(r_pkgid);
+ goto end;
+ }
+ strncpy(l_pkgid, argv[3], len - 1);
+
+ ret = __compare_pkg_certinfo_from_db(r_pkgid, l_pkgid);
+ if (ret == -1) {
+ printf("compare certinfo from db failed\n");
+ }
+ free(l_pkgid);
+ free(r_pkgid);
+ goto end;
+ } else if (strcmp(argv[1], "--cmp-appcert") == 0) {
+ ret = __compare_app_certinfo_from_db(argv[2], argv[3]);
+ if (ret == -1) {
+ printf("compare certinfo from db failed\n");
+ goto end;
+ }
+ goto end;
+ } else if (strcmp(argv[1], "--arg-flt") == 0) {
+ ret = __add_arg_filter(argv[2], argv[3]);
+ if (ret == -1) {
+ printf("compare certinfo from db failed\n");
+ goto end;
+ }
+ goto end;
+ } else {
+ __print_usage();
+ ret = -1;
+ goto end;
+ }
+ }
+
+ if (argc != 3) {
+ __print_usage();
+ ret = -1;
+ goto end;
+ }
+ if (!argv[1] || !argv[2]) {
+ __print_usage();
+ ret = -1;
+ goto end;
+ }
+
+ if (strcmp(argv[1], "--pkg") == 0) {
+ ret = __get_pkg_info(argv[2]);
+ if (ret == -1) {
+ printf("get pkg info failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--app") == 0) {
+ ret = __get_app_info(argv[2]);
+ if (ret == -1) {
+ printf("get app info failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--list") == 0) {
+ ret = __get_app_list(argv[2]);
+ if (ret == -1) {
+ printf("get app list failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--imd") == 0) {
+ ret = __insert_manifest_in_db(argv[2]);
+ if (ret == -1) {
+ printf("insert in db failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--fota") == 0) {
+ ret = __fota_insert_manifest_in_db(argv[2]);
+ if (ret == -1) {
+ printf("insert in db failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--rmd") == 0) {
+ ret = __remove_manifest_from_db(argv[2]);
+ if (ret == -1) {
+ printf("remove from db failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--setdb") == 0) {
+ ret = __set_pkginfo_in_db(argv[2]);
+ if (ret == -1) {
+ printf("set pkginfo in db failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--setcert") == 0) {
+ ret = __set_certinfo_in_db(argv[2]);
+ if (ret == -1) {
+ printf("set certinfo in db failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--getcert") == 0) {
+ ret = __get_certinfo_from_db(argv[2]);
+ if (ret == -1) {
+ printf("get certinfo from db failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--delcert") == 0) {
+ ret = __del_certinfo_from_db(argv[2]);
+ if (ret == -1) {
+ printf("del certinfo from db failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--check") == 0) {
+ ret = __check_manifest_validation(argv[2]);
+ if (ret == -1) {
+ printf("check manifest failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--category") == 0) {
+ ret = __get_app_category_list(argv[2]);
+ if (ret == -1) {
+ printf("get app category list failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--metadata") == 0) {
+ ret = __get_app_metadata_list(argv[2]);
+ if (ret == -1) {
+ printf("get app metadata list failed\n");
+ goto end;
+ }
+ } else if (strcmp(argv[1], "--appcontrol") == 0) {
+ ret = __get_app_control_list(argv[2]);
+ if (ret == -1) {
+ printf("get app control list failed\n");
+ goto end;
+ }
+ } else
+ __print_usage();
+
+end:
+
+ gettimeofday(&tv, NULL);
+ endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ printf("spend time for pkginfo is [%d]ms\n", (int)(endtime - starttime));
+
+ return ret;
+}
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include <pkgmgr_parser.h>
+#include <pkgmgr-info.h>
+
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define BUFSZE 1024
+#define OPT_MANIFEST_DIRECTORY "/opt/share/packages"
+#define USR_MANIFEST_DIRECTORY "/usr/share/packages"
+#define PACKAGE_INFO_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+
+#define PKG_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_parser.db-journal"
+#define PKG_CERT_DB_FILE "/opt/dbspace/.pkgmgr_cert.db"
+#define PKG_CERT_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_cert.db-journal"
+#define PKG_INFO_DB_LABEL "pkgmgr::db"
+
+#define TOKEN_TYPE_STR "type="
+#define TOKEN_PKGID_STR "package="
+
+#define SEPERATOR_START '"'
+#define SEPERATOR_END '"'
+
+#ifdef _E
+#undef _E
+#endif
+#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E] "fmt"\n", ##arg);
+
+#ifdef _D
+#undef _D
+#endif
+#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D] "fmt"\n", ##arg);
+
+static int initdb_count_package(void)
+{
+ int total = 0;
+
+ return total;
+}
+
+static int initdb_xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
+
+
+char* _manifest_to_package(const char* manifest)
+{
+ char *package;
+
+ if(manifest == NULL)
+ return NULL;
+
+ package = strdup(manifest);
+ if(package == NULL)
+ return NULL;
+
+
+ if (!strstr(package, ".xml")) {
+ _E("%s is not a manifest file", manifest);
+ free(package);
+ return NULL;
+ }
+
+ return package;
+}
+
+static void __str_trim(char *input)
+{
+ char *trim_str = input;
+
+ if (input == NULL)
+ return;
+
+ while (*input != 0) {
+ if (!isspace(*input)) {
+ *trim_str = *input;
+ trim_str++;
+ }
+ input++;
+ }
+
+ *trim_str = 0;
+ return;
+}
+
+static char * getvalue(const char* pBuf, const char* pKey)
+{
+ const char* p = NULL;
+ const char* pStart = NULL;
+ const char* pEnd = NULL;
+
+ p = strstr(pBuf, pKey);
+ if (p == NULL)
+ return NULL;
+
+ pStart = p + strlen(pKey) + 1;
+ pEnd = strchr(pStart, SEPERATOR_END);
+ if (pEnd == NULL)
+ return false;
+
+ size_t len = pEnd - pStart;
+ if (len <= 0)
+ return false;
+
+ char *pRes = (char*)malloc(len + 1);
+ strncpy(pRes, pStart, len);
+ pRes[len] = 0;
+
+ return pRes;
+}
+
+static int __find_rpm_manifest(const char* manifest)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *pkgtype = NULL;
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _D("Fail get : %s", manifest);
+ return -1;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgtype = getvalue(buf, TOKEN_TYPE_STR);
+ if (pkgtype != NULL) {
+ if ((strcmp(pkgtype,"tpk") == 0) || (strcmp(pkgtype,"wgt") == 0)) {
+ fclose(fp);
+ free(pkgtype);
+ return -1;
+ }
+ free(pkgtype);
+ }
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return 0;
+}
+
+static char *__find_rpm_pkgid(const char* manifest)
+{
+ FILE *fp = NULL;
+ char buf[BUFSZE] = {0};
+ char *pkgid = NULL;
+
+ fp = fopen(manifest, "r");
+ if (fp == NULL) {
+ _D("Fail get : %s", manifest);
+ return NULL;
+ }
+
+ while (fgets(buf, BUFSZE, fp) != NULL) {
+ __str_trim(buf);
+
+ pkgid = getvalue(buf, TOKEN_PKGID_STR);
+ if (pkgid != NULL) {
+ fclose(fp);
+ return pkgid;
+ }
+ memset(buf, 0x00, BUFSZE);
+ }
+
+ if (fp != NULL)
+ fclose(fp);
+
+ return NULL;
+}
+
+static int __check_time(long privous_time)
+{
+ long current_time;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ current_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ return (int)(current_time - privous_time);
+}
+
+int initdb_install_corexml(const char *directory)
+{
+ DIR *dir;
+ struct dirent entry, *result;
+ int ret;
+ char buf[BUFSZE];
+
+ int spend_time = 0;
+ int corexml_time = 0;
+ int smack_time = 0;
+ int prlivielge_time = 0;
+ int pkg_cnt = 0;
+
+ long check_time;
+ struct timeval tv;
+
+ dir = opendir(directory);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("Failed to access the [%s] because %s", directory, buf);
+ return -1;
+ }
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *manifest;
+ char *pkgid;
+
+ if (entry.d_name[0] == '.') continue;
+
+ manifest = _manifest_to_package(entry.d_name);
+ if (!manifest) {
+ _E("Failed to convert file to xml[%s]", entry.d_name);
+ continue;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s", directory, manifest);
+
+ ret = pkgmgr_parser_check_manifest_validation(buf);
+ if (ret < 0) {
+ _E("manifest validation failed : %s", buf);
+ free(manifest);
+ continue;
+ }
+
+ ret = __find_rpm_manifest(buf);
+ if (ret < 0) {
+ free(manifest);
+ continue;
+ }
+
+ pkg_cnt++;
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ const char *corexml_argv[] = { "/usr/bin/rpm-backend", "-k", "core-xml", "-s", buf, NULL };
+ initdb_xsystem(corexml_argv);
+
+ spend_time = __check_time(check_time);
+ _D("Install corexml : %s done[time:%d ms]", manifest, spend_time);
+ corexml_time += spend_time;
+
+ free(manifest);
+
+ pkgid = __find_rpm_pkgid(buf);
+ if(pkgid == NULL) {
+ _D("pkgid is NULL in %s", buf);
+ continue;
+ }
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ const char *rpmsmack_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-smack", "-s", pkgid, NULL };
+ initdb_xsystem(rpmsmack_argv);
+
+ spend_time = __check_time(check_time);
+ _D("Smack pkgid : %s done[time:%d ms]", pkgid, spend_time);
+ smack_time += spend_time;
+
+ gettimeofday(&tv, NULL);
+ check_time = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
+
+ const char *rpmperm_argv[] = { "/usr/bin/rpm-backend", "-k", "rpm-perm", "-s", pkgid, NULL };
+ initdb_xsystem(rpmperm_argv);
+
+ spend_time = __check_time(check_time);
+
+ _D("Privilege pkgid : %s done[time:%d ms]", pkgid, spend_time);
+ prlivielge_time += spend_time;
+
+ free(pkgid);
+ }
+
+ closedir(dir);
+
+ _D("================================================================");
+ _D("Package-Manager DB initialize for Core xml[%s]", directory);
+ _D("RPM package cnt : %d", pkg_cnt);
+ _D("Time for DB Init : %d sec", corexml_time / 1000);
+ _D("Time for SMACK : %d sec", smack_time / 1000);
+ _D("Time for Privilele : %d sec", prlivielge_time / 1000);
+ _D("Time for Toal process : %d sec", (corexml_time+smack_time+prlivielge_time) / 1000);
+ _D("================================================================");
+
+ return 0;
+}
+
+int initdb_load_directory(const char *directory)
+{
+ DIR *dir;
+ struct dirent entry, *result;
+ int ret;
+ char buf[BUFSZE];
+ int total_cnt = 0;
+ int ok_cnt = 0;
+
+ // desktop file
+ dir = opendir(directory);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("Failed to access the [%s] because %s", directory, buf);
+ return -1;
+ }
+
+ _D("Loading manifest files from %s", directory);
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *manifest;
+
+ if (entry.d_name[0] == '.') continue;
+ total_cnt++;
+
+ manifest = _manifest_to_package(entry.d_name);
+ if (!manifest) {
+ _E("Failed to convert file to xml[%s]", entry.d_name);
+ continue;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s", directory, manifest);
+
+ ret = pkgmgr_parser_check_manifest_validation(buf);
+ if (ret < 0) {
+ _E("manifest validation failed : %s", buf);
+ free(manifest);
+ continue;
+ }
+
+ /*temporarily fixed due to glib abort */
+ const char *pkginfo_argv[] = { "/usr/bin/pkginfo", "--imd", buf, NULL };
+ initdb_xsystem(pkginfo_argv);
+
+#if 0
+ ret = pkgmgr_parser_parse_manifest_for_installation(buf, NULL);
+ if (ret < 0) {
+ _E("Failed to add a xml[%s]", buf);
+ } else {
+ ok_cnt++;
+ }
+#endif
+ free(manifest);
+ }
+
+// _D("Package-XML process : Success [%d], fail[%d], total[%d] \n", ok_cnt, total_cnt-ok_cnt, total_cnt);
+ closedir(dir);
+
+ return 0;
+}
+
+
+
+static int initdb_change_perm(const char *db_file)
+{
+ char buf[BUFSZE];
+ char journal_file[BUFSZE];
+ char *files[3];
+ int ret, i;
+
+ files[0] = (char *)db_file;
+ files[1] = journal_file;
+ files[2] = NULL;
+
+ if(db_file == NULL)
+ return -1;
+
+ snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
+
+ for (i = 0; files[i]; i++) {
+ ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
+ return -1;
+ }
+
+ ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int initdb_update_preload_info()
+{
+ if (pkgmgr_parser_parse_manifest_for_preload() == -1) {
+ _E("pkgmgr_parser_parse_manifest_for_preload fail.");
+ return -1;
+ }
+ return 0;
+}
+static int __is_authorized()
+{
+ /* pkg_init db should be called by as root privilege. */
+
+ uid_t uid = getuid();
+ if ((uid_t) 0 == uid)
+ return 1;
+ else
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ int ret;
+ time_t start_time;
+ time_t end_time;
+
+ if (!__is_authorized()) {
+ _E("You are not an authorized user!\n");
+ return -1;
+ }
+
+ time(&start_time);
+
+ ret = initdb_count_package();
+ if (ret > 0) {
+ _D("Some Packages in the Package Info DB.");
+ return 0;
+ }
+
+ if (argv[1] == NULL) {
+ ret = initdb_install_corexml(USR_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load usr manifest directory.");
+ }
+ ret = initdb_install_corexml(OPT_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load opt manifest directory.");
+ }
+ } else if (strcmp(argv[1],"all") == 0) {
+ ret = initdb_load_directory(USR_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load usr manifest directory for all ");
+ }
+
+ ret = initdb_load_directory(OPT_MANIFEST_DIRECTORY);
+ if (ret == -1) {
+ _E("cannot load opt manifest directory for all ");
+ }
+ } else {
+ _E("Wrong pkg_initdb cmd args");
+ return 0;
+ }
+
+ ret = initdb_change_perm(PACKAGE_INFO_DB_FILE);
+ if (ret == -1) {
+ _E("cannot chown.");
+ }
+
+ ret = initdb_update_preload_info();
+ if (ret == -1) {
+ _E("cannot update preload info.");
+ }
+
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+ initdb_xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+ initdb_xsystem(argv_parserjn);
+ const char *argv_cert[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE, NULL };
+ initdb_xsystem(argv_cert);
+ const char *argv_certjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE_JOURNAL, NULL };
+ initdb_xsystem(argv_certjn);
+
+ time(&end_time);
+
+ _D("================================================================");
+ fprintf(stderr, "[PKG_INITDB][D] Package-Manager initializing start : %s", ctime(&start_time));
+ fprintf(stderr, "[PKG_INITDB][D] Package-Manager initializing end : %s", ctime(&end_time));
+ _D("================================================================");
+
+ return 0;
+}
+
+
--- /dev/null
+#!/bin/sh
+#
+
+_pkg_recovery_path="/opt/share/packages/.recovery/pkgmgr"
+_pkg_recovery_file="/opt/share/packages/.recovery/pkgmgr/*"
+
+FILE_LIST=`ls $_pkg_recovery_path`
+if [ -n "$FILE_LIST" ]; then
+ echo "There are packages to recovery"
+ /usr/bin/wrt-installer -b
+ /usr/bin/osp-installer -b
+ /usr/bin/efltpk-installer -b
+
+ echo "delete recovery files"
+ rm $_pkg_recovery_file
+else
+ echo "There is no packages to recovery."
+fi
+
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include "package-manager.h"
+
+#include <bundle.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <appcore-efl.h>
+#include <glib.h>
+
+
+#define KEY_MIME_TYPE "__AUL_MIME_TYPE__"
+#define KEY_MIME_CONTENT "__AUL_MIME_CONTENT__"
+
+#define KEY_MIME_TYPE_NEW "__APP_SVC_MIME_TYPE__"
+#define KEY_MIME_CONTENT_NEW "__APP_SVC_URI__"
+
+
+#if !defined(PACKAGE)
+#define PACKAGE "com.samsung.pkgmgr-install"
+#endif
+
+
+char *supported_mime_type_list[] = {
+ NULL /* sentinel */
+};
+
+struct appdata {
+ char *file_path;
+ char *extension;
+};
+
+
+static int __parse_argv(int argc, char **argv,
+ char **mime_type, char **file_path);
+static const char *__get_ext_from_file_path(const char *file_path);
+
+static int __parse_argv(int argc, char **argv,
+ char **mime_type, char **file_path)
+{
+ static bundle *b = NULL;
+ if (b)
+ bundle_free(b);
+
+ b = bundle_import_from_argv(argc, argv);
+ if (b == NULL) {
+ fprintf(stderr, "bundle for bundle_import_from_argv is NULL");
+ }
+
+ errno = 0;
+
+ if(bundle_get_val(b, KEY_MIME_CONTENT_NEW)) {
+ /* *mime_type = (char *)bundle_get_val(b, KEY_MIME_TYPE_NEW); */
+ *file_path = (char *)bundle_get_val(b, KEY_MIME_CONTENT_NEW);
+ } else {
+ *mime_type = (char *)bundle_get_val(b, KEY_MIME_TYPE);
+ *file_path = (char *)bundle_get_val(b, KEY_MIME_CONTENT);
+ }
+
+ if (errno)
+ return -1;
+
+ return 0;
+}
+
+static const char *__get_ext_from_file_path(const char *file_path)
+{
+ return strrchr(file_path, '.') + 1;
+}
+
+gboolean __term(void *data)
+{
+ ecore_main_loop_quit();
+
+ return FALSE;
+}
+
+int main(int argc, char **argv)
+{
+ struct appdata ad;
+ struct appcore_ops ops = {
+ .create = NULL,
+ .terminate = NULL,
+ .pause = NULL,
+ .resume = NULL,
+ .reset = NULL,
+ };
+
+ char *mime_type;
+ char *file_path;
+ const char *extension;
+ int request_id = 0;
+
+ if (__parse_argv(argc, argv, &mime_type, &file_path)) {
+ fprintf(stderr, "Failed to parse argv!\n");
+ return -1;
+ }
+
+ extension = __get_ext_from_file_path(file_path);
+
+ memset(&ad, 0x0, sizeof(struct appdata));
+ ops.data = &ad;
+ ad.file_path = file_path;
+ ad.extension = extension;
+
+
+ int pid = fork();
+ if (pid == 0) {
+ pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST);
+ request_id = pkgmgr_client_install(pc, extension, NULL, file_path, NULL,
+ PM_QUIET, NULL, NULL);
+ if (request_id < 0)
+ fprintf(stderr, "pkgmgr_client_install fail!\n");
+
+ request_id = pkgmgr_client_free(pc);
+ if (request_id < 0)
+ fprintf(stderr, "pkgmgr_client_free fail\n");
+
+ exit(0);
+ }
+
+ g_timeout_add(1000, __term, &ad);
+
+// sleep(2);
+ /* Wait until AULD(launchpad) retrives info of this process.
+ Its timeout is 1.2s. */
+
+ return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+}
+
--- /dev/null
+#/usr/bin/python
+import sys, subprocess
+
+num_try = 1
+frontends = {}
+
+if __name__ == "__main__":
+
+ # Run frontends
+ for i in range(num_try):
+ p = subprocess.Popen("pkgmgr_frontend_test -n 2>/dev/null 1>/dev/null".split())
+ frontends[i] = p
+ print("Run %d/%d frontend"%(i, num_try))
+
+
+ # wait frontends to be end
+ done = {}
+ seq = []
+ while True:
+ for i in frontends:
+ if not done.has_key(i):
+ p = frontends[i]
+ ret = p.poll()
+ if not None == ret:
+ print("Frontend #%d is terminated. Returns: %d"%(i, -ret))
+ done[i] = -ret
+ seq.append(i)
+ if num_try == len(done):
+ break
+
+ print("Test done.")
+ for i in frontends:
+ print("Return code of frontend #%d = %d"%(i, done[i]))
+ #print("Terminate seq:")
+ #print(seq)
+
--- /dev/null
+
+CONFIGURE_FILE(pkgmgr-types.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-types.pc @ONLY)
+
+INSTALL(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/package-manager-types.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/package-manager-plugin.h
+ DESTINATION include)
+
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-types.pc DESTINATION lib/pkgconfig)
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+
+
+
+
+#ifndef __PKG_MANAGER_PLUGIN_H__
+#define __PKG_MANAGER_PLUGIN_H__
+
+#include "package-manager-types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*_pkg_plugin_unload) (void);
+typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkgid);
+typedef int (*_pkg_plugin_get_installed_pkg_list) (const char *category,
+ const char *option,
+ package_manager_pkg_info_t
+ **list, int *count);
+typedef int (*_pkg_plugin_get_pkg_detail_info) (const char *pkgid,
+ package_manager_pkg_detail_info_t
+ *pkg_detail_info);
+typedef int (*_pkg_plugin_get_pkg_detail_info_from_package) (const char
+ *pkg_path,
+ package_manager_pkg_detail_info_t
+ *pkg_detail_info);
+
+typedef struct _pkg_plugin_set {
+char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+void *plugin_handle;
+_pkg_plugin_unload plugin_on_unload;
+_pkg_plugin_pkg_is_installed pkg_is_installed;
+_pkg_plugin_get_installed_pkg_list get_installed_pkg_list;
+_pkg_plugin_get_pkg_detail_info get_pkg_detail_info;
+_pkg_plugin_get_pkg_detail_info_from_package
+get_pkg_detail_info_from_package;
+} pkg_plugin_set;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PKG_MANAGER_PLUGIN_H__ */
--- /dev/null
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+
+
+
+
+/**
+ * @file package-manager-types.h
+ * @author Sewook Park <sewook7.park@samsung.com>
+ * @version 0.1
+ * @brief This file declares slp-pkgmgr-types
+ *
+ * @addtogroup APPLICATION_FRAMEWORK
+ * @{
+ *
+ * @defgroup pacakge_manager_type
+ * @section Header to use them:
+ * @code
+ * #include "package-manager-types.h"
+ * @endcode
+ *
+ * @addtogroup pacakge_manager_type
+ * @{
+ */
+
+#ifndef __PKG_MANAGER_TYPES_H__
+#define __PKG_MANAGER_TYPES_H__
+
+#include <errno.h>
+#include <stdbool.h>
+#include <time.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @mainpage
+ *
+ * This is package manager
+ *
+ * Packaeg manager is used to install/uninstall the packages.\n
+ * package includes dpkg, java, widget, etc. and it can be added\n
+ * Security is considered on current package manager\n
+ *
+ */
+
+/**
+ * @file package-manager.h
+ * @brief Package Manager header
+ *
+ * Generated by Sewook Park <sewook7.park@samsung.com>
+ */
+
+#define PKG_TYPE_STRING_LEN_MAX 128
+#define PKG_NAME_STRING_LEN_MAX 128
+#define PKG_VERSION_STRING_LEN_MAX 128
+#define PKG_VALUE_STRING_LEN_MAX 512
+#define PKG_URL_STRING_LEN_MAX 1024
+#define PKG_LABEL_STRING_LEN_MAX 128
+
+/**
+ *@brief application's structure retrieved by package-manager
+ */
+typedef struct _package_manager_pkg_info_t {
+ char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+ char pkg_name[PKG_NAME_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
+ char version[PKG_VERSION_STRING_LEN_MAX];
+ struct _package_manager_pkg_info_t *next;
+} package_manager_pkg_info_t;
+
+typedef struct _package_manager_pkg_detail_info_t {
+ char pkg_type[PKG_TYPE_STRING_LEN_MAX];
+ char pkg_name[PKG_NAME_STRING_LEN_MAX];
+ char pkgid[PKG_NAME_STRING_LEN_MAX];
+ char version[PKG_VERSION_STRING_LEN_MAX];
+ char pkg_description[PKG_VALUE_STRING_LEN_MAX];
+ char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
+ time_t installed_time; /* installed time it must be GMT+0 time */
+ int installed_size; /* installed total size */
+ int app_size; /* installed app size */
+ int data_size; /* data size which is made on run time */
+ char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */
+ void *pkg_optional_info;
+ char label[PKG_LABEL_STRING_LEN_MAX];
+ char author[PKG_VALUE_STRING_LEN_MAX];
+ char *icon_buf;
+ int icon_size;
+ GList *privilege_list;
+} package_manager_pkg_detail_info_t;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PKG_MANAGER_TYPES_H__ */
+/**
+ * @}
+ * @}
+ */
+
--- /dev/null
+#
+# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: package manager types
+Description: SLP package manager's types header
+Version: @VERSION@
+Requires:
+Libs:
+Cflags: -I${includedir}