Add a build feature to support non-multiuser version appfw API 83/70983/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 23 May 2016 12:39:55 +0000 (21:39 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 23 May 2016 12:39:55 +0000 (21:39 +0900)
By setting LEGACY_APPFW as 1, it can be built on Tizen 2.3 or Tizen 2.4, which has no multiuser support.

Change-Id: I6f3c74e9c038f859d1a2402a533e2ce84e37cefb
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
CMakeLists.txt
packaging/context.spec
src/context_trigger.cpp

index 139e2ae..dfdcf02 100644 (file)
@@ -10,7 +10,7 @@ FILE(GLOB_RECURSE SRCS src/*.cpp)
 MESSAGE("Sources: ${SRCS}")
 
 # Dependencies
-SET(DEPS "libcontext-shared aul bundle capi-appfw-app-control pkgmgr-info")
+SET(DEPS "gio-2.0 libcontext-shared aul bundle capi-appfw-app-control pkgmgr-info")
 
 # Common Options
 INCLUDE(FindPkgConfig)
@@ -20,6 +20,10 @@ INCLUDE_DIRECTORIES(
 ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden)
 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section")
 
+IF(${LEGACY_APPFW})
+       ADD_DEFINITIONS(-DLEGACY_APPFW)
+ENDIF(${LEGACY_APPFW})
+
 # Building Library
 pkg_check_modules(api_pkg REQUIRED ${DEPS})
 
index 041dd36..9a84f71 100644 (file)
@@ -8,11 +8,14 @@ Source0:    %{name}-%{version}.tar.gz
 
 %define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}}
 
+%define LEGACY_APPFW   0
+
 %if "%{?BUILD_PROFILE}" == "tv"
 ExcludeArch: %{arm} aarch64 %ix86 x86_64
 %endif
 
 BuildRequires: cmake
+BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(libcontext-shared)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(bundle)
@@ -39,7 +42,7 @@ export CXXFLAGS+=" -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict
 
 export   CFLAGS+=" -fno-common"
 export CXXFLAGS+=" -Wnon-virtual-dtor"
-export CXXFLAGS+=" -std=c++11 -Wno-c++11-compat"
+export CXXFLAGS+=" -std=c++0x"
 
 #export   CFLAGS+=" -Wcast-qual"
 #export CXXFLAGS+=" -Wcast-qual"
@@ -53,7 +56,9 @@ export   CFLAGS+=" -D_ALLOW_SERVICE_APP_TRIGGER_"
 export CXXFLAGS+=" -D_ALLOW_SERVICE_APP_TRIGGER_"
 %endif
 
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{?BUILD_PROFILE}
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
+                                                          -DPROFILE=%{?BUILD_PROFILE} \
+                                                          -DLEGACY_APPFW=%{LEGACY_APPFW}
 make %{?jobs:-j%jobs}
 
 %install
index 2cc7262..0e503f0 100644 (file)
 #include <Json.h>
 #include <app_control_internal.h>
 #include <bundle.h>
+
+#ifndef LEGACY_APPFW
 #include <bundle_internal.h>
+#endif
+
 #include <context_trigger.h>
 #include <context_trigger_internal.h>
 #include <context_trigger_types_internal.h>
@@ -374,7 +378,11 @@ SO_EXPORT int context_trigger_rule_set_action_app_control(context_trigger_rule_h
        IF_FAIL_RETURN_TAG(error == ERR_NONE, error, _E, "Failed to get app id");
 
        pkgmgrinfo_appinfo_h app_info;
+#ifdef LEGACY_APPFW
+       error = pkgmgrinfo_appinfo_get_appinfo(app_id, &app_info);
+#else
        error = pkgmgrinfo_appinfo_get_usr_appinfo(app_id, getuid(), &app_info);
+#endif
        g_free(app_id);
        IF_FAIL_RETURN_TAG(error == PMINFO_R_OK, CONTEXT_TRIGGER_ERROR_INVALID_RULE, _E, "No such app");
 
@@ -432,7 +440,11 @@ SO_EXPORT int context_trigger_rule_set_action_notification(context_trigger_rule_
                IF_FAIL_RETURN_TAG(error == ERR_NONE, error, _E, "Failed to get app id");
 
                pkgmgrinfo_appinfo_h app_info;
+#ifdef LEGACY_APPFW
+               error = pkgmgrinfo_appinfo_get_appinfo(app_id, &app_info);
+#else
                error = pkgmgrinfo_appinfo_get_usr_appinfo(app_id, getuid(), &app_info);
+#endif
                g_free(app_id);
                IF_FAIL_RETURN_TAG(error == PMINFO_R_OK, CONTEXT_TRIGGER_ERROR_INVALID_RULE, _E, "No such app");
        }
@@ -540,7 +552,11 @@ SO_EXPORT int context_trigger_rule_custom_event_create(const char* event_item, c
 
        // Err: Invalid provider
        pkgmgrinfo_pkginfo_h pkg_info;
+#ifdef LEGACY_APPFW
+       int error = pkgmgrinfo_pkginfo_get_pkginfo(provider, &pkg_info);
+#else
        int error = pkgmgrinfo_pkginfo_get_usr_pkginfo(provider, getuid(), &pkg_info);
+#endif
        pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_info);
        IF_FAIL_RETURN_TAG(error == PMINFO_R_OK, CONTEXT_TRIGGER_ERROR_INVALID_DATA, _E, "No such package");
 
@@ -617,7 +633,11 @@ SO_EXPORT int context_trigger_rule_custom_condition_create(const char* condition
 
        // Err: Invalid provider
        pkgmgrinfo_pkginfo_h pkg_info;
+#ifdef LEGACY_APPFW
+       int error = pkgmgrinfo_pkginfo_get_pkginfo(provider, &pkg_info);
+#else
        int error = pkgmgrinfo_pkginfo_get_usr_pkginfo(provider, getuid(), &pkg_info);
+#endif
        pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_info);
        IF_FAIL_RETURN_TAG(error == PMINFO_R_OK, CONTEXT_TRIGGER_ERROR_INVALID_DATA, _E, "No such package");