From: Kévin THIERRY Date: Wed, 12 Feb 2014 16:40:40 +0000 (+0100) Subject: Add multi-user support X-Git-Tag: accepted/tizen/ivi/20160218.022911^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c9c7e1784b77fa8dfce0aacda3919a216ca3515;p=apps%2Fcore%2Fpreloaded%2Fprint-service.git Add multi-user support Bug-Tizen: PTREL-253 Change-Id: I09b3c1196f6248849fdd39110ae1ffc439eb4d60 Signed-off-by: Kévin THIERRY --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a03aad8..6be1c28 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) INCLUDE(FindPkgConfig) #pkg_check_modules(utils_pkgs REQUIRED ecore eina avahi cups dlog vconf capi-appfw-application) -pkg_check_modules(utils_pkgs REQUIRED ecore eina dlog vconf capi-appfw-application) +pkg_check_modules(utils_pkgs REQUIRED ecore eina dlog vconf capi-appfw-application libtzplatform-config) FOREACH(flag ${utils_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -fdata-sections -ffunction-sections -Wl,--gc-sections") diff --git a/TC/CMakeLists.txt b/TC/CMakeLists.txt index 72ec464..5942319 100644 --- a/TC/CMakeLists.txt +++ b/TC/CMakeLists.txt @@ -7,6 +7,7 @@ SET(PREFIX /usr) SET(BINDIR "${PREFIX}/bin") SET(LIBDIR ${LIB_INSTALL_DIR}) SET(SRCS ppd_compare.c) +SET(ETC ${CMAKE_ETC}) SET(DB_LIB_NAME ptdb) SET(GETPPD getppd) @@ -38,13 +39,13 @@ IF(ENABLE_OM_TESTS) SET(HP_PRDLIST hp_product.list) SET(EPSON_LIST epson.list) SET(SAMSUNG_LIST samsung.list) - SET(PRINTLIST_DIR /opt/etc/cups/ppd/) + SET(PRINTLIST_DIR ${ETC}/cups/ppd/) ADD_LIBRARY(${OPMAP_LIB_NAME} SHARED ${SRCS_OM_LIB}) SET_TARGET_PROPERTIES(${OPMAP_LIB_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES(${OPMAP_LIB_NAME} PROPERTIES VERSION ${VERSION}) - pkg_check_modules(test_pkgs REQUIRED ecore eina dlog) + pkg_check_modules(test_pkgs REQUIRED ecore eina dlog libtzplatform-config) FOREACH(flag ${test_pkgs_LDFLAGS}) SET(OPMAP_TEST_LDFLAGS "${flag} ${OPMAP_TEST_LDFLAGS}") diff --git a/TC/ppd_test.sh b/TC/ppd_test.sh index 6218e80..a73aa25 100755 --- a/TC/ppd_test.sh +++ b/TC/ppd_test.sh @@ -1,18 +1,20 @@ #!/bin/sh +eval $(tzplatform-get TZ_SYS_ETC) + #used in extraction test hp_drvgz_path="/usr/share/cups/ppd/hp/hp.drv.gz" samsung_drvgz_path="/usr/share/cups/ppd/samsung/samsung.drv.gz" epson_drvgz_path="/usr/share/cups/ppd/epson/epson.drv.gz" -hp_drv_path="/opt/etc/cups/ppd/hp/hp.drv" -samsung_drv_path="/opt/etc/cups/ppd/samsung/samsung.drv" -epson_drv_path="/opt/etc/cups/ppd/epson/epson.drv" +hp_drv_path=$TZ_SYS_ETC"/cups/ppd/hp/hp.drv" +samsung_drv_path=$TZ_SYS_ETC"/cups/ppd/samsung/samsung.drv" +epson_drv_path=$TZ_SYS_ETC"/cups/ppd/epson/epson.drv" -hp_list_path="/opt/etc/cups/ppd/hp.list" -hp_product_path="/opt/etc/cups/ppd/hp_product.list" -samsung_list_path="/opt/etc/cups/ppd/samsung.list" -epson_list_path="/opt/etc/cups/ppd/epson.list" +hp_list_path=$TZ_SYS_ETC"/cups/ppd/hp.list" +hp_product_path=$TZ_SYS_ETC"/cups/ppd/hp_product.list" +samsung_list_path=$TZ_SYS_ETC"/cups/ppd/samsung.list" +epson_list_path=$TZ_SYS_ETC"/cups/ppd/epson.list" epson_extraction_complete=0 samsung_extraction_complete=0 @@ -470,7 +472,7 @@ echo " Validation TEST - Epson " echo "====================================================================" EXTRACTION_COMPLETE=$epson_extraction_complete -ORIGINAL_PPD_PATH="/opt/etc/cups/ppd/org_ppd/epson" +ORIGINAL_PPD_PATH=$TZ_SYS_ETC"/cups/ppd/org_ppd/epson" VALID_PATH=$EPSON_VALID VALID_RESULT_PATH=$EPSON_VALID/result TEMP_PATH=$EPSON_TEMP @@ -506,7 +508,7 @@ echo " Validation TEST - Samsung " echo "====================================================================" EXTRACTION_COMPLETE=$samsung_extraction_complete -ORIGINAL_PPD_PATH="/opt/etc/cups/ppd/org_ppd/samsung" +ORIGINAL_PPD_PATH=$TZ_SYS_ETC"/cups/ppd/org_ppd/samsung" VALID_PATH=$SAMSUNG_VALID VALID_RESULT_PATH=$SAMSUNG_VALID/result TEMP_PATH=$SAMSUNG_TEMP @@ -542,7 +544,7 @@ echo " Validation TEST - HP " echo "====================================================================" EXTRACTION_COMPLETE=$hp_extraction_complete -ORIGINAL_PPD_PATH="/opt/etc/cups/ppd/org_ppd/hp" +ORIGINAL_PPD_PATH=$TZ_SYS_ETC"/cups/ppd/org_ppd/hp" VALID_PATH=$HP_VALID VALID_RESULT_PATH=$HP_VALID/result TEMP_PATH=$HP_TEMP diff --git a/TC/print-test-opmap.sh b/TC/print-test-opmap.sh index 974cd9d..a98112d 100755 --- a/TC/print-test-opmap.sh +++ b/TC/print-test-opmap.sh @@ -1,6 +1,8 @@ #!/bin/bash -PLIST_PATH="/opt/etc/cups/ppd/" +eval $(tzplatform-get TZ_SYS_ETC) + +PLIST_PATH=$TZ_SYS_ETC"/cups/ppd/" HP_LIST="hp.list" EPSON_LIST="epson.list" SAMSUNG_LIST="samsung.list" diff --git a/include/pt_optionmapping.h b/include/pt_optionmapping.h index ff13b19..bd2f8ef 100644 --- a/include/pt_optionmapping.h +++ b/include/pt_optionmapping.h @@ -17,6 +17,9 @@ * */ +/* For multi-user support */ +#include + #ifndef PT_OPTIONMAPPING_H #define PT_OPTIONMAPPING_H @@ -51,7 +54,7 @@ typedef struct { } pt_resolution_keyword; #undef PT_OPTIONCUBE_TEST_PRINT -#define PT_USER_OPTION_CONFIG_FILE "/opt/etc/cups/ppd/settings.cfg" +#define PT_USER_OPTION_CONFIG_FILE tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/settings.cfg") ppd_choice_t *pt_selected_choice(int op, pt_orientation_e p); void pt_parse_options(ppd_file_t *ppd); diff --git a/include/pt_ppd.h b/include/pt_ppd.h index 6bf76e0..8d77027 100644 --- a/include/pt_ppd.h +++ b/include/pt_ppd.h @@ -17,13 +17,16 @@ * */ +/* For multi-user support */ +#include + #ifndef __PT_PPD_H__ #define __PT_PPD_H__ #define MAX_PATH_SIZE 512 #define MAX_COMMAND_SIZE 128*128 #define MANUFACTURER_NUM 3 -#define PPD_DIR "/opt/etc/cups/ppd" +#define PPD_DIR tzplatform_mkpath3(TZ_SYS_ETC, "cups", "ppd") /** * This function let the app get ppd file for the specified printer diff --git a/packaging/print-service.spec b/packaging/print-service.spec index 280c1f0..72916aa 100755 --- a/packaging/print-service.spec +++ b/packaging/print-service.spec @@ -1,52 +1,52 @@ -%global DATADIR /opt - Name: print-service -Summary: print service library +Summary: Print service library Version: 1.2.9 -Release: 1 +Release: 0 Group: System/Libraries -License: Flora Software License +License: Flora Source0: %{name}-%{version}.tar.gz Source1001: print-service.manifest Source1002: print-driver-data.manifest Source1003: print-service-tests.manifest -BuildRequires: cmake -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(eina) -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(vconf) -BuildRequires: glib2-devel -BuildRequires: binutils-devel -BuildRequires: cups-devel -BuildRequires: libxml2-devel -BuildRequires: capi-appfw-application-devel -Requires: glib2 -Requires: cups -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(eina) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: glib2-devel +BuildRequires: binutils-devel +BuildRequires: cups-devel +BuildRequires: libxml2-devel +BuildRequires: capi-appfw-application-devel +Requires: tizen-platform-config-tools +Requires: cups +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + BuildRoot: %{_tmppath}/%{name}-%{version}-build %description -print-service library +Print-service library %package devel -Summary: print library - development file +Summary: Print library - development file Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description devel -print library - development file +Print library - development file %package -n print-driver-data -Summary: printer data - ppd, cts, data files +Summary: Printer data - ppd, cts, data files Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description -n print-driver-data -printer data - ppd, cts, data files +Printer data - ppd, cts, data files %package tests -Summary: testing utilities +Summary: Testing utilities Group: Development/Libraries Requires: %{name} = %{version}-%{release} @@ -60,7 +60,7 @@ Set of utilities for testing different parts of library cp %{SOURCE1001} . cp %{SOURCE1002} . cp %{SOURCE1003} . -%cmake . -DENABLE_OM_TESTS=On +%cmake . -DENABLE_OM_TESTS=On -DCMAKE_ETC=%{TZ_SYS_ETC} %install rm -rf %{buildroot} @@ -75,19 +75,19 @@ rm -rf %{buildroot} %post /sbin/ldconfig -if ! [ -d /opt/etc/cups/ppd/hp ] +if ! [ -d %{TZ_SYS_ETC}/cups/ppd/hp ] then - mkdir -p /opt/etc/cups/ppd/hp + mkdir -p %{TZ_SYS_ETC}/cups/ppd/hp fi -if ! [ -d /opt/etc/cups/ppd/epson ] +if ! [ -d %{TZ_SYS_ETC}/cups/ppd/epson ] then - mkdir -p /opt/etc/cups/ppd/epson + mkdir -p %{TZ_SYS_ETC}/cups/ppd/epson fi -if ! [ -d /opt/etc/cups/ppd/samsung ] +if ! [ -d %{TZ_SYS_ETC}/cups/ppd/samsung ] then - mkdir -p /opt/etc/cups/ppd/samsung + mkdir -p %{TZ_SYS_ETC}/cups/ppd/samsung fi -chown -R 5000:5000 /opt/etc/cups/ppd +chown -R :%{TZ_SYS_USER_GROUP} %{TZ_SYS_ETC}/cups/ppd %post -n print-driver-data mkdir -p /usr/share/cups/model/samsung @@ -98,17 +98,17 @@ if [ -e /usr/share/cups/model/samsung/cms ] then rm /usr/share/cups/model/samsung/cms fi -if [ -f /opt/etc/cups/ppd/hp/hp.drv ] +if [ -f %{TZ_SYS_ETC}/cups/ppd/hp/hp.drv ] then - rm /opt/etc/cups/ppd/hp/hp.drv + rm %{TZ_SYS_ETC}/cups/ppd/hp/hp.drv fi -if [ -f /opt/etc/cups/ppd/samsung/samsung.drv ] +if [ -f %{TZ_SYS_ETC}/cups/ppd/samsung/samsung.drv ] then - rm /opt/etc/cups/ppd/samsung/samsung.drv + rm %{TZ_SYS_ETC}/cups/ppd/samsung/samsung.drv fi -if [ -f /opt/etc/cups/ppd/epson/epson.drv ] +if [ -f %{TZ_SYS_ETC}/cups/ppd/epson/epson.drv ] then - rm /opt/etc/cups/ppd/epson/epson.drv + rm %{TZ_SYS_ETC}/cups/ppd/epson/epson.drv fi %postun @@ -134,10 +134,10 @@ fi /usr/share/license/print-driver-data %dir /usr/share/cups/ppd/ /usr/share/cups/ppd/* -%exclude %{DATADIR}/etc/cups/ppd/hp_product.list -%exclude %{DATADIR}/etc/cups/ppd/hp.list -%exclude %{DATADIR}/etc/cups/ppd/epson.list -%exclude %{DATADIR}/etc/cups/ppd/samsung.list +%exclude %{TZ_SYS_ETC}/cups/ppd/hp_product.list +%exclude %{TZ_SYS_ETC}/cups/ppd/hp.list +%exclude %{TZ_SYS_ETC}/cups/ppd/epson.list +%exclude %{TZ_SYS_ETC}/cups/ppd/samsung.list %files -n print-service-tests %manifest print-service-tests.manifest @@ -147,10 +147,10 @@ fi %attr(0755,root,root) %{_bindir}/test-opmap %attr(0755,root,root) %{_bindir}/print-test-opmap.sh %{_libdir}/libopmap.so* -%attr(-,app,app) %{DATADIR}/etc/cups/ppd/hp.list -%attr(-,app,app) %{DATADIR}/etc/cups/ppd/hp_product.list -%attr(-,app,app) %{DATADIR}/etc/cups/ppd/epson.list -%attr(-,app,app) %{DATADIR}/etc/cups/ppd/samsung.list +%attr(-,-,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_ETC}/cups/ppd/hp.list +%attr(-,-,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_ETC}/cups/ppd/hp_product.list +%attr(-,-,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_ETC}/cups/ppd/epson.list +%attr(-,-,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_ETC}/cups/ppd/samsung.list %changelog diff --git a/scripts/print-test-getppd.sh b/scripts/print-test-getppd.sh index af93689..9b67120 100755 --- a/scripts/print-test-getppd.sh +++ b/scripts/print-test-getppd.sh @@ -1,6 +1,8 @@ #!/bin/bash -PLIST_PATH="/opt/etc/cups/ppd/" +eval $(tzplatform-get TZ_SYS_ETC) + +PLIST_PATH=$TZ_SYS_ETC"/cups/ppd/" HP_LIST="hp.list" EPSON_LIST="epson.list" SAMSUNG_LIST="samsung.list" diff --git a/src/pt_ppd.c b/src/pt_ppd.c index d83421a..54fe3de 100644 --- a/src/pt_ppd.c +++ b/src/pt_ppd.c @@ -26,25 +26,28 @@ #include #include +/* For multi-user support */ +#include + #include #include "pt_debug.h" #include "pt_common.h" #include "pt_ppd.h" #define GETPPD "/usr/bin/getppd" -#define CUPS_PPDDIR "/opt/etc/cups/ppd/" -#define SAMSUNG_DRV "/opt/etc/cups/ppd/samsung/samsung.drv" -#define SAMSUNG_DRV_GZ "/opt/etc/cups/ppd/samsung/samsung.drv.gz" +#define CUPS_PPDDIR tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/") +#define SAMSUNG_DRV tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/samsung/samsung.drv") +#define SAMSUNG_DRV_GZ tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/samsung/samsung.drv.gz") #define SAMSUNG_DRV_GZ_ORG "/usr/share/cups/ppd/samsung/samsung.drv.gz" -#define HP_DRV "/opt/etc/cups/ppd/hp/hp.drv" -#define HP_DRV_GZ "/opt/etc/cups/ppd/hp/hp.drv.gz" +#define HP_DRV tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/hp/hp.drv") +#define HP_DRV_GZ tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/hp/hp.drv.gz") #define HP_DRV_GZ_ORG "/usr/share/cups/ppd/hp/hp.drv.gz" -#define EPSON_DRV "/opt/etc/cups/ppd/epson/epson.drv" -#define EPSON_DRV_GZ "/opt/etc/cups/ppd/epson/epson.drv.gz" +#define EPSON_DRV tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/epson/epson.drv") +#define EPSON_DRV_GZ tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/epson/epson.drv.gz") #define EPSON_DRV_GZ_ORG "/usr/share/cups/ppd/epson/epson.drv.gz" -#define SAMSUNG_PPD_DIR "/opt/etc/cups/ppd/samsung" -#define EPSON_PPD_DIR "/opt/etc/cups/ppd/epson" -#define HP_PPD_DIR "/opt/etc/cups/ppd/hp" +#define SAMSUNG_PPD_DIR tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/samsung") +#define EPSON_PPD_DIR tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/epson") +#define HP_PPD_DIR tzplatform_mkpath(TZ_SYS_ETC, "cups/ppd/hp") #define PPDC_PREFIX "ppdc: Writing ./"