new internal API for parser-plugin to get target_uid. 31/81631/4 accepted/tizen/common/20160803.193137 accepted/tizen/ivi/20160804.080746 accepted/tizen/mobile/20160804.080838 accepted/tizen/tv/20160804.080704 accepted/tizen/wearable/20160804.080511 submit/tizen/20160803.012753
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 27 Jul 2016 10:24:25 +0000 (19:24 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 27 Jul 2016 10:30:11 +0000 (19:30 +0900)
Change-Id: Id6ae8ce79be686659baab096ed7db70a5e4263d4
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
installer/CMakeLists.txt
installer/pkgmgr_installer.c
installer/pkgmgr_installer_info.h [new file with mode: 0644]
packaging/pkgmgr.spec

index aa2afa1..379aa14 100644 (file)
@@ -40,21 +40,11 @@ set_target_properties(pkgmgr_installer PROPERTIES VERSION ${VERSION})
 set_target_properties(pkgmgr_installer PROPERTIES COMPILE_FLAGS "${installer_pkgs_CFLAGS_str}")
 target_link_libraries(pkgmgr_installer ${installer_pkgs_LDFLAGS})
 
-
 ### Create pc file
 configure_file(pkgmgr-installer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc @ONLY)
 
-
 ## Install
-INSTALL(TARGETS
-                       pkgmgr_installer
-            DESTINATION ${LIB_INSTALL_DIR}
-               COMPONENT RuntimeLibraries)
-INSTALL(FILES
-                       pkgmgr_installer.h
-               DESTINATION include/pkgmgr)
-
-
-INSTALL(FILES
-               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc
-        DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS pkgmgr_installer DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES pkgmgr_installer.h DESTINATION include/pkgmgr)
+INSTALL(FILES pkgmgr_installer_info.h DESTINATION include/pkgmgr)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
index 2f014d7..12273d1 100644 (file)
@@ -32,6 +32,7 @@
 #include "pkgmgr_installer.h"
 #include "pkgmgr_installer_config.h"
 #include "pkgmgr_installer_debug.h"
+#include "pkgmgr_installer_info.h"
 
 #include "../client/include/comm_config.h"
 
@@ -65,6 +66,8 @@ struct pkgmgr_installer {
        GDBusConnection *conn;
 };
 
+static uid_t g_target_uid;
+
 static const char *__get_signal_name(pkgmgr_installer *pi, const char *key)
 {
        if (strcmp(key, PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR) == 0)
@@ -248,6 +251,7 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi,
        int mode = 0;
 
        pi->target_uid = getuid();
+       g_target_uid = pi->target_uid;
        while (1) {
                c = getopt_long(argc, argv, short_opts, long_opts, &opt_idx);
                /* printf("c=%d %c\n", c, c); //debug */
@@ -523,6 +527,7 @@ API int pkgmgr_installer_set_uid(pkgmgr_installer *pi, uid_t uid)
                return -1;
 
        pi->target_uid = uid;
+       g_target_uid = pi->target_uid;
 
        return 0;
 }
@@ -620,3 +625,10 @@ API int pkgmgr_installer_delete_certinfo(const char *pkgid)
        ret = pkgmgrinfo_delete_certinfo(pkgid);
        return ret;
 }
+
+API int pkgmgr_installer_info_get_target_uid(uid_t *uid)
+{
+       *uid = g_target_uid;
+
+       return 0;
+}
diff --git a/installer/pkgmgr_installer_info.h b/installer/pkgmgr_installer_info.h
new file mode 100644 (file)
index 0000000..0f29f6e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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_INFO_H__
+#define __PKGMGR_INSTALLER_INFO_H__
+
+/**
+ * @file       pkgmgr_installer_info.h
+ * @brief      This file declares API for getting information of pkgmgr_installer
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief      Get target_uid for pkg to be installed path
+ * @pre                None
+ * @post       None
+ * @param[out] uid     user id
+ * @return     0 if success, else retrun < 0
+ * @code
+       #include <pkgmgr_installer_info.h>
+       int main()
+       {
+               uid_t uid;
+               if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
+                       printf("failed to get target uid\n");
+               }
+               printf("uid = %d\n", uid);
+       }
+ * @endcode
+ */
+int pkgmgr_installer_info_get_target_uid(uid_t *uid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PKGMGR_INSTALLER_INFO_H__ */
+
index 6439c13..3dfcbb7 100644 (file)
@@ -165,7 +165,7 @@ HOME="$saveHOME"
 %manifest %{name}-installer-devel.manifest
 %defattr(-,root,root,-)
 %dir %{_includedir}/pkgmgr
-%{_includedir}/pkgmgr/pkgmgr_installer.h
+%{_includedir}/pkgmgr/*.h
 %{_libdir}/pkgconfig/pkgmgr-installer.pc
 %{_libdir}/libpkgmgr_installer.so