Remove Profile Build Dependency: Do it at runtime
[platform/core/appfw/pkgmgr-server.git] / src / pkgmgr-server.c
index cf55a28..638e89a 100644 (file)
 #include <pkgmgr/pkgmgr_parser_db.h>
 #include <tzplatform_config.h>
 #include <drm-tizen-apps.h>
-#ifdef TIZEN_FEATURE_CSR
 #include <csr-content-screening.h>
-#endif
 
 #include "pkgmgr_installer.h"
 #include "pkgmgr-server.h"
 #include "queue.h"
 #include "package-manager.h"
 
+#include <system_info.h>
+
 #define OWNER_ROOT 0
 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
 #define APPFW_UID 301
@@ -102,6 +102,50 @@ static void sighandler(int signo);
 
 gboolean exit_server(void *data);
 
+typedef enum {
+       TIZEN_PROFILE_UNKNOWN = 0,
+       TIZEN_PROFILE_MOBILE = 0x1,
+       TIZEN_PROFILE_WEARABLE = 0x2,
+       TIZEN_PROFILE_TV = 0x4,
+       TIZEN_PROFILE_IVI = 0x8,
+       TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+
+static tizen_profile_t _get_tizen_profile()
+{
+       static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+       char *profileName;
+
+       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName) {
+       case 'm':
+       case 'M':
+               profile = TIZEN_PROFILE_MOBILE;
+               break;
+       case 'w':
+       case 'W':
+               profile = TIZEN_PROFILE_WEARABLE;
+               break;
+       case 't':
+       case 'T':
+               profile = TIZEN_PROFILE_TV;
+               break;
+       case 'i':
+       case 'I':
+               profile = TIZEN_PROFILE_IVI;
+               break;
+       default: // common or unknown ==> ALL ARE COMMON.
+               profile = TIZEN_PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
+#define TIZEN_FEATURE_CSR (_get_tizen_profile() != TIZEN_PROFILE_TV)
+
 /* To check whether a particular backend is free/busy */
 static int __is_backend_busy(int position)
 {
@@ -322,7 +366,6 @@ gboolean exit_server(void *data)
        return TRUE;
 }
 
-#ifdef TIZEN_FEATURE_CSR
 static int __check_csr(const char *path)
 {
        csr_cs_context_h context = NULL;
@@ -348,7 +391,6 @@ static int __check_csr(const char *path)
 
        return 0;
 }
-#endif
 
 static int __kill_app(char *appid, uid_t uid)
 {
@@ -1536,19 +1578,19 @@ gboolean queue_job(void *data)
        /* set current backend job */
        DBG("handle request type [%d]", job->req_type);
 
-#ifdef TIZEN_FEATURE_CSR
-       if (job->req_type == REQUEST_TYPE_INSTALL ||
-                       job->req_type == REQUEST_TYPE_MOUNT_INSTALL ||
-                       job->req_type == REQUEST_TYPE_REINSTALL) {
-               ret = __check_csr(job->pkgid);
-               if (ret != 0) {
-                       ret = -1;
-                       _send_fail_signal(job);
-                       _free_backend_job(job);
-                       return TRUE;
+       if (TIZEN_FEATURE_CSR) {
+               if (job->req_type == REQUEST_TYPE_INSTALL ||
+                               job->req_type == REQUEST_TYPE_MOUNT_INSTALL ||
+                               job->req_type == REQUEST_TYPE_REINSTALL) {
+                       ret = __check_csr(job->pkgid);
+                       if (ret != 0) {
+                               ret = -1;
+                               _send_fail_signal(job);
+                               _free_backend_job(job);
+                               return TRUE;
+                       }
                }
        }
-#endif
 
        switch (job->req_type) {
        case REQUEST_TYPE_INSTALL: