From 49c1ccf01dfcf16c498289b54626c1afeb56eaa9 Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Wed, 13 Mar 2013 01:51:25 +0900 Subject: [PATCH] Tizen 2.1 base --- AUTHORS | 2 + CMakeLists.txt | 55 + LICENSE | 204 +++ TC/build.sh | 41 + TC/execute.sh | 41 + TC/tet_code | 12 + TC/tet_scen | 7 + TC/tetbuild.cfg | 3 + TC/tetclean.cfg | 2 + TC/tetexec.cfg | 1 + TC/unit/Makefile | 30 + TC/unit/drmcontentsdef.h | 153 +++ TC/unit/tc_gen.sh | 28 + TC/unit/tslist | 9 + TC/unit/utc_MODULE_API_func.c.in | 67 + .../utc_drmclient_drm_get_constraint_info_func.c | 1051 +++++++++++++++ TC/unit/utc_drmclient_drm_get_content_info_func.c | 281 ++++ TC/unit/utc_drmclient_drm_get_data_func.c | 445 ++++++ TC/unit/utc_drmclient_drm_get_file_info_func.c | 354 +++++ TC/unit/utc_drmclient_drm_get_file_type_func.c | 534 ++++++++ .../utc_drmclient_drm_get_license_status_func.c | 333 +++++ TC/unit/utc_drmclient_drm_is_action_allowed_func.c | 358 +++++ TC/unit/utc_drmclient_drm_is_drm_file_func.c | 561 ++++++++ TC/unit/utc_drmclient_drm_process_request_func.c | 1287 ++++++++++++++++++ drm-client.pc.in | 6 + include/drm_client.h | 319 +++++ include/drm_client_ipc.h | 264 ++++ include/drm_client_log.h | 100 ++ include/drm_client_types.h | 1097 +++++++++++++++ packaging/drm-client.spec | 55 + service/drm_client.cpp | 1426 ++++++++++++++++++++ service/drm_client_ipc.cpp | 552 ++++++++ test/Makefile | 14 + test/test_drm_client.cpp | 995 ++++++++++++++ 34 files changed, 10687 insertions(+) create mode 100755 AUTHORS create mode 100755 CMakeLists.txt create mode 100755 LICENSE create mode 100755 TC/build.sh create mode 100755 TC/execute.sh create mode 100755 TC/tet_code create mode 100755 TC/tet_scen create mode 100755 TC/tetbuild.cfg create mode 100755 TC/tetclean.cfg create mode 100755 TC/tetexec.cfg create mode 100755 TC/unit/Makefile create mode 100755 TC/unit/drmcontentsdef.h create mode 100755 TC/unit/tc_gen.sh create mode 100755 TC/unit/tslist create mode 100755 TC/unit/utc_MODULE_API_func.c.in create mode 100755 TC/unit/utc_drmclient_drm_get_constraint_info_func.c create mode 100755 TC/unit/utc_drmclient_drm_get_content_info_func.c create mode 100755 TC/unit/utc_drmclient_drm_get_data_func.c create mode 100755 TC/unit/utc_drmclient_drm_get_file_info_func.c create mode 100755 TC/unit/utc_drmclient_drm_get_file_type_func.c create mode 100755 TC/unit/utc_drmclient_drm_get_license_status_func.c create mode 100755 TC/unit/utc_drmclient_drm_is_action_allowed_func.c create mode 100755 TC/unit/utc_drmclient_drm_is_drm_file_func.c create mode 100755 TC/unit/utc_drmclient_drm_process_request_func.c create mode 100755 drm-client.pc.in create mode 100755 include/drm_client.h create mode 100755 include/drm_client_ipc.h create mode 100755 include/drm_client_log.h create mode 100755 include/drm_client_types.h create mode 100755 packaging/drm-client.spec create mode 100755 service/drm_client.cpp create mode 100755 service/drm_client_ipc.cpp create mode 100755 test/Makefile create mode 100755 test/test_drm_client.cpp diff --git a/AUTHORS b/AUTHORS new file mode 100755 index 0000000..e1c9411 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Mahendra Kumar Prajapat +Harsha Shekar \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..591fefe --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,55 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(drm-client CXX) + +#Verbose +#SET(CMAKE_VERBOSE_MAKEFILE ON) + +# Message +#MESSAGE("FLAGS: ${CMAKE_C_FLAGS}") +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(LIBDIR ${PREFIX}/lib) +SET(INCLUDEDIR ${PREFIX}/include) +SET(VERSION 0.0.1) + +SET(SRCS + service/drm_client.cpp + service/drm_client_ipc.cpp +) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +SET(extapi "-fvisibility=hidden") +SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${extapi}") + +#SET(DEBUG "-Wall -Werror -ggdb3 -fno-omit-frame-pointer -rdynamic -fno-optimize-sibling-calls -fstack-protector-all") +#SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${DEBUG}") + +INCLUDE(FindPkgConfig) +pkg_check_modules(exppkgs REQUIRED dlog capi-base-common glib-2.0) + +FOREACH(flag ${exppkgs_CFLAGS}) + SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-ldl" ) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${exppkgs_LDFLAGS}) +SET_TARGET_PROPERTIES( + drm-client + PROPERTIES + SOVERSION 0 + VERSION 0.0.1 +) + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc) +INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION lib/pkgconfig) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib) +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION /usr/include/drm-client/) diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..a06208b --- /dev/null +++ b/LICENSE @@ -0,0 +1,204 @@ +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. + diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..c2e3d7a --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +#Modify path to local TETware folder +export TET_INSTALL_PATH=/path/to/TETware +if [ ! -d "$TET_INSTALL_PATH" ]; then + echo "TET_INSTALL_PATH = $TET_INSTALL_PATH doesn't exist" + echo "Modify this script build.sh with tetware directory" + exit +fi + +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 + +DATE=$(date +'%Y.%m.%d_%H.%M') +HTML_RESULT=$RESULT_DIR/drm_tc_build_result_$DATE.html +JOURNAL_RESULT=$RESULT_DIR/drm_tc_build_result_$DATE.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ + +# Log Levels +# LOG_LEVEL=3 prints only tet_infoline +# LOG_LEVEL=7 prints only tet_infoline & tet_printf +LOG_LEVEL=7 +grw -c $LOG_LEVEL -f chtml -o $HTML_RESULT $JOURNAL_RESULT + +# Copy the results outside drm-client +echo "Copy the results outside drm-client & in folder drm_tc_results_client" +mkdir -p ../../drm_tc_results_client +cp $RESULT_DIR/drm_tc_build_result_$DATE.html ../../drm_tc_results_client/ diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..916b893 --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +#Modify path to TETware folder on target +export TET_INSTALL_PATH=/path/to/TETware +if [ ! -d "$TET_INSTALL_PATH" ]; then + echo "TET_INSTALL_PATH = $TET_INSTALL_PATH doesn't exist" + echo "Modify this script execute.sh with tetware directory" + exit +fi + +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 + +DATE=$(date +'%Y.%m.%d_%H.%M') +HTML_RESULT=$RESULT_DIR/drm_tc_execute_result_$DATE.html +JOURNAL_RESULT=$RESULT_DIR/drm_tc_execute_result_$DATE.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ + +# Log Levels +# LOG_LEVEL=3 prints only tet_infoline +# LOG_LEVEL=7 prints only tet_infoline & tet_printf +LOG_LEVEL=7 +grw -c $LOG_LEVEL -f chtml -o $HTML_RESULT $JOURNAL_RESULT + +# Copy the results outside drm-client +echo "Copy the results outside drm-client & in folder drm_tc_results_client" +mkdir -p ../../drm_tc_results_client +cp $RESULT_DIR/drm_tc_execute_result_$DATE.html ../../drm_tc_results_client/ diff --git a/TC/tet_code b/TC/tet_code new file mode 100755 index 0000000..a2cf6c1 --- /dev/null +++ b/TC/tet_code @@ -0,0 +1,12 @@ +# 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" diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..43cbc9b --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/unit/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100755 index 0000000..6192c78 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,3 @@ +TET_OUTPUT_CAPTURE=False +TET_BUILD_TOOL=make +TET_PASS_TC_NAME=True diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100755 index 0000000..c66eda4 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,2 @@ +TET_OUTPUT_CAPTURE=False +TET_CLEAN_TOOL=make clean diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100755 index 0000000..0d9d39a --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1 @@ +TET_OUTPUT_CAPTURE=False diff --git a/TC/unit/Makefile b/TC/unit/Makefile new file mode 100755 index 0000000..39bd791 --- /dev/null +++ b/TC/unit/Makefile @@ -0,0 +1,30 @@ +CC ?= gcc + +TARGETS = utc_drmclient_drm_is_drm_file_func \ + utc_drmclient_drm_process_request_func \ + utc_drmclient_drm_get_file_type_func \ + utc_drmclient_drm_get_license_status_func \ + utc_drmclient_drm_get_content_info_func \ + utc_drmclient_drm_get_file_info_func \ + utc_drmclient_drm_get_constraint_info_func \ + utc_drmclient_drm_is_action_allowed_func \ + utc_drmclient_drm_get_data_func + +PKGS = drm-client + +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 + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +all: $(TARGETS) + +$(TARGETS): %: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -rf $(TARGETS) ../results ../tet_tmp_dir diff --git a/TC/unit/drmcontentsdef.h b/TC/unit/drmcontentsdef.h new file mode 100755 index 0000000..c28f405 --- /dev/null +++ b/TC/unit/drmcontentsdef.h @@ -0,0 +1,153 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * 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 drmcontentsdef.h + * @brief DRM TC Content MACROs. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @author Harsha Shekar (h.shekar@samsung.com) + * @version 0.1 + * @history 0.1: DRM TC Content MACROs + */ + +#ifndef __DRM_CONTENTS_DEF_H__ +#define __DRM_CONTENTS_DEF_H__ + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus */ + +#include "drm_client.h" + +#define FILE_PATH_MAX_SIZE (256) +/* Modify path to local tc_data on target */ +#define DRM_CONTENT_PATH "/path/to/tc_data" + +/* + * Valid File paths + */ +#define FILE_PATH_VALID_FILE_OMA_1 DRM_CONTENT_PATH"/flourish_count5.dcf" +#define FILE_PATH_VALID_FILE_OMA_2 DRM_CONTENT_PATH"/download.jpg.dm-849344490.odf" +#define FILE_PATH_VALID_FILE_OMA_3 DRM_CONTENT_PATH"/4931_D2_AacpMetaDummy.o4a" +#define FILE_PATH_VALID_FILE_OMA_4 DRM_CONTENT_PATH"/4941_D2_VideoH264AACDummy.o4v" +#define FILE_PATH_VALID_FILE_OMA_5 DRM_CONTENT_PATH"/barimage_interval.dcf" +#define FILE_PATH_VALID_FILE_OMA_6 DRM_CONTENT_PATH"/MonkeyMadness_startend_time.dcf" +#define FILE_PATH_VALID_FILE_OMA_7 DRM_CONTENT_PATH"/pbarimage_timedcount.dcf" +#define FILE_PATH_VALID_FILE_OMA_8 DRM_CONTENT_PATH"/cupcake_play.dcf" + +/* + * This file will be generated as a part of DM to DCF conversion test-case + */ +#define FILE_PATH_VALID_FILE_OMA_9 DRM_CONTENT_PATH"/image_cd.dcf" + +#define FILE_PATH_VALID_FILE_OMA_10 DRM_CONTENT_PATH"/3001_D1_Aac.dcf" + +#define FILE_PATH_VALID_FILE_OMA_11 DRM_CONTENT_PATH"/temp/flourish_count5.dcf" + +/* + * This file will be generated as a part of DM to DCF conversion test-case + */ +#define FILE_PATH_VALID_FILE_OMA_12 DRM_CONTENT_PATH"/1202_F1_Jpg.dcf" + + +#define FILE_PATH_VALID_FILE_PR_1 DRM_CONTENT_PATH"/Jazz_Audio_OPLs0.pya" +#define FILE_PATH_VALID_FILE_PR_2 DRM_CONTENT_PATH"/MD_h264_V4AES.pyv" +#define FILE_PATH_VALID_FILE_PR_3 DRM_CONTENT_PATH"/ExpirationAudio1.pya" + +#define FILE_PATH_VALID_FILE_PR_ENV_1 DRM_CONTENT_PATH"/krishna.eny" +#define FILE_PATH_VALID_FILE_PR_ENV_2 DRM_CONTENT_PATH"/jazz_audio_opls0.pye" + + +#define FILE_PATH_VALID_FILE_DIVX_1 DRM_CONTENT_PATH"/V19_HD720p10_ICT_00.avi" + +/* + * Invalid File paths + */ +#define INVALID_POINTER_OBJECT NULL +#define FILE_PATH_INVALID_FILE_NULL NULL +#define FILE_PATH_INVALID_FILE_EMPTY "" + +#define FILE_PATH_INVALID_FILE_OMA_1 DRM_CONTENT_PATH"/flourish_count5.dr" +#define FILE_PATH_INVALID_FILE_OMA_2 DRM_CONTENT_PATH"/Flower1.jpg" +#define FILE_PATH_INVALID_FILE_OMA_3 DRM_CONTENT_PATH"/image_cd.dm" + +#define FILE_PATH_INVALID_FILE_PR_1 DRM_CONTENT_PATH"/clr_jazz_AAC.asf" +#define FILE_PATH_INVALID_FILE_PR_2 DRM_CONTENT_PATH"/jazz.wma" + +#define FILE_PATH_INVALID_FILE_PR_ENV_1 DRM_CONTENT_PATH"/krishna.jpg" + +#define FILE_PATH_INVALID_FILE_DIVX_1 DRM_CONTENT_PATH"/sine_wave.avi" + +/** Valid RO file paths + * + */ +#define FILE_PATH_VALID_RO_FILE_OMA_1 DRM_CONTENT_PATH"/flourish_count5.dr" +#define FILE_PATH_VALID_RO_FILE_OMA_2 DRM_CONTENT_PATH"/3001_D1_Aac_3Counts.drc" + +/** Invalid RO file paths + * + */ +#define FILE_PATH_INVALID_RO_FILE_OMA_1 DRM_CONTENT_PATH"/flourish_count5.dcf" + +/* + * Valid License Initiators + */ +/* Jazz_Audio_OPLs0.pya */ +#define LICENSE_INITIATOR_VALID_PR_FILE "http://playready.directtaps.net/pr/initiator.aspx?p=0&contentid=ZVXWl75xFUOdCY/tO8bLCA==&type=license&content=http://131.107.149.211/pr/media/1044/Jazz_Audio_OPLs0.pya" + +/* DomainTestVideo1.pyv */ +#define LICENSE_INITIATOR_VALID_PR_FILE_1 "http://playready.directtaps.net/pr/initiator.aspx?p=0&contentid=ybubwBx/XUidiUX3zdMRTg==&type=license&content=http://131.107.149.211/pr/media/1044/DomainTestVideo1.pyv" + +/* DomainTestVideo1.pyv */ +#define JOIN_DOMAIN_INITIATOR_VALID_PR_FILE_1 "http://playready.directtaps.net/pr/initiator.aspx?p=0&type=JOIN" + +/* DomainTestVideo1.pyv */ +#define LEAVE_DOMAIN_INITIATOR_VALID_PR_FILE_1 "http://playready.directtaps.net/pr/initiator.aspx?p=0&type=LEAVE" + +/* DomainTestVideo1.pyv */ +#define METERING_INITIATOR_VALID_PR_FILE_1 "http://playready.directtaps.net/pr/initiator.aspx?p=0&contentid=ybubwBx/XUidiUX3zdMRTg==&type=metering&content=http://131.107.149.211/pr/media/1044/DomainTestVideo1.pyv" + +/* ExpirationAudio1.pya */ +#define LICENSE_INITIATOR_VALID_PR_FILE_2 "http://playready.directtaps.net/pr/initiator.aspx?p=0&contentid=qTNJyCKLmUCdGpx1ZHQ0Aw==&type=license&content=http://131.107.149.211/pr/media/1044/ExpirationAudio1.pya" + +/* MD_h264_V4AES.pyv */ +#define LICENSE_INITIATOR_VALID_PR_FILE_3 "http://playready.directtaps.net/pr/initiator.aspx?p=0&contentid=ewIUg21KrEecS3qu8m9EMQ==&type=license&content=http://131.107.149.211/pr/media/1044/MD_h264_V4AES.pyv" + +/* jazz_wma_Domain_No_Copy.pya */ +#define LICENSE_INITIATOR_VALID_PR_FILE_4 "http://playready.directtaps.net/pr/initiator.aspx?p=1&contentid=fXZukDZR4kKMOIbSE+MuPg==&type=license&content=http://131.107.149.211/pr/media/1207/jazz_wma_Domain_No_Copy.pya" + +/* + * Invalid License Initiators + */ +#define INVALID_LICENSE_INITIATOR_PR_FILE_1 "http://playready.directtaps.net/prxx/initiatorxxxx.aspx?p=0&contentid=ZVXWl75xFUOdCY/tO8bLCA==&type=license&content=http://131.107.149.211/pr/media/1044/Jazz_Audio_OPLs0.pya" +#define INVALID_JOIN_DOMAIN_INITIATOR_1 "http://playready.directtaps.net/prxx/initiatorxxxx.aspx?p=0&type=JOIN" +#define INVALID_LEAVE_DOMAIN_INITIATOR_1 "http://playready.directtaps.net/prxx/initiatorxxxx.aspx?p=0&type=LEAVE" +#define INVALID_METERING_INITIATOR_1 "http://playready.directtaps.net/prxx/initiatorxxxx.aspx?p=0&contentid=ybubwBx/XUidiUX3zdMRTg==&type=metering&content=http://131.107.149.211/pr/media/1044/DomainTestVideo1.pyv" +#define INVALID_LICENSE_INITIATOR_PR_FILE_2 "http://playready.directtaps.net/pr/initiator.aspx?p=0&contentid=ZVXWl75xFUOdCY/tO8bLCA==&type=license&content=http://131.107.149.211/prxx/media/1044/Jazz_Audio_OPLs0xxxx.pya" + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __DRM_CONTENTS_DEF_H__ */ diff --git a/TC/unit/tc_gen.sh b/TC/unit/tc_gen.sh new file mode 100755 index 0000000..54f482d --- /dev/null +++ b/TC/unit/tc_gen.sh @@ -0,0 +1,28 @@ +#!/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" diff --git a/TC/unit/tslist b/TC/unit/tslist new file mode 100755 index 0000000..e88f788 --- /dev/null +++ b/TC/unit/tslist @@ -0,0 +1,9 @@ +/unit/utc_drmclient_drm_is_drm_file_func +/unit/utc_drmclient_drm_process_request_func +/unit/utc_drmclient_drm_get_file_type_func +/unit/utc_drmclient_drm_get_license_status_func +/unit/utc_drmclient_drm_get_content_info_func +/unit/utc_drmclient_drm_get_file_info_func +/unit/utc_drmclient_drm_get_constraint_info_func +/unit/utc_drmclient_drm_is_action_allowed_func +/unit/utc_drmclient_drm_get_data_func diff --git a/TC/unit/utc_MODULE_API_func.c.in b/TC/unit/utc_MODULE_API_func.c.in new file mode 100755 index 0000000..5edf1b7 --- /dev/null +++ b/TC/unit/utc_MODULE_API_func.c.in @@ -0,0 +1,67 @@ +#include +#include "pkgname.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 int pid; + +static void startup(void) +{ +} + +static void cleanup(void) +{ +} + +/** + * @brief Positive test case of @API@() + */ +static void utc_@MODULE@_@API@_func_01(void) +{ + int r = 0; + char buf[MAX_LOCAL_BUFSZ]; + + r = @API@(...); + + if (r<0) { + 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; + char buf[MAX_LOCAL_BUFSZ]; + + r = @API@(...); + + if (r>=0) { + tet_infoline("@API@() failed in negative test case"); + tet_result(TET_FAIL); + return; + } + tet_result(TET_PASS); +} diff --git a/TC/unit/utc_drmclient_drm_get_constraint_info_func.c b/TC/unit/utc_drmclient_drm_get_constraint_info_func.c new file mode 100755 index 0000000..de08d33 --- /dev/null +++ b/TC/unit/utc_drmclient_drm_get_constraint_info_func.c @@ -0,0 +1,1051 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_get_constraint_info_func.c + * @brief TETware unit testing functions for drm_get_constraint_info. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_get_constraint_info_func_01(void); +static void utc_drmclient_drm_get_constraint_info_func_02(void); +static void utc_drmclient_drm_get_constraint_info_func_03(void); +static void utc_drmclient_drm_get_constraint_info_func_04(void); +/* Disabled below test-cases due to network & other dependencies */ +#if 0 +static void utc_drmclient_drm_get_constraint_info_func_05(void); +static void utc_drmclient_drm_get_constraint_info_func_06(void); +static void utc_drmclient_drm_get_constraint_info_func_07(void); +static void utc_drmclient_drm_get_constraint_info_func_08(void); +#endif +static void utc_drmclient_drm_get_constraint_info_func_09(void); +static void utc_drmclient_drm_get_constraint_info_func_10(void); +static void utc_drmclient_drm_get_constraint_info_func_11(void); +static void utc_drmclient_drm_get_constraint_info_func_12(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_get_constraint_info_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_03, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_04, POSITIVE_TC_IDX }, + /* Disabled below test-cases due to network & other dependencies */ +#if 0 + { utc_drmclient_drm_get_constraint_info_func_05, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_06, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_07, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_08, POSITIVE_TC_IDX }, +#endif + { utc_drmclient_drm_get_constraint_info_func_09, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_10, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_11, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_constraint_info_func_12, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_get_constraint_info:Test started"); + tet_infoline("OMA DRM Content should be registered"); + tet_infoline("RO must be installed to get valid constraint information"); +} + +static void cleanup(void) +{ + tet_infoline("drm_get_constraint_info:Test completed"); +} + +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_02(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_DISPLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_5); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_5); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_5); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_EXECUTE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_6); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_6); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_6); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_8); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_8); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_8); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/* Disabled below test-cases due to network & other dependencies */ +#if 0 +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_1); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_2); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_07(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_3); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_3); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_3); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_08(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_DIVX_1); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x",ret); + if(constraint_info.const_type.is_unlimited){ + tet_printf("Unlimited:for permission=%d",perm_type); + } + + if(constraint_info.const_type.is_accumulated){ + tet_printf("Accumulated Constraint is present"); + tet_printf("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + tet_printf("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + tet_printf("Count Constraint is present"); + tet_printf("original_count=%d", + constraint_info.original_count); + tet_printf("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + tet_printf("DATETIME Constraint is present"); + tet_printf("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + tet_printf("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + tet_printf("INDIVIDUAL Constraint is present"); + tet_printf("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + tet_printf("INTERVAL Constraint is present"); + tet_printf("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + tet_printf("SYSTEM Constraint is present"); + tet_printf("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + } + + if(constraint_info.const_type.is_timedcount){ + tet_printf("TIMED-COUNT Constraint is present"); + tet_printf("timed_original_count=%d", + constraint_info.timed_original_count); + + tet_printf("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + tet_printf("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} +#endif +/** + * @brief Negative test case of drm_get_constraint_info() + */ + +static void utc_drmclient_drm_get_constraint_info_func_09(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + + ret = drm_get_constraint_info(FILE_PATH_INVALID_FILE_NULL,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_constraint_info() + */ + +static void utc_drmclient_drm_get_constraint_info_func_10(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_constraint_info() + */ + +static void utc_drmclient_drm_get_constraint_info_func_11(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_get_constraint_info(file_path,perm_type,INVALID_POINTER_OBJECT); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_constraint_info() + */ +static void utc_drmclient_drm_get_constraint_info_func_12(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_DISPLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_7); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS != ret ){ + /* pbarimage_timedcount.dr RO is in wrong format */ + /* Thus it will fail */ + tet_infoline("drm_get_constraint_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_7); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_constraint_info"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_7); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} diff --git a/TC/unit/utc_drmclient_drm_get_content_info_func.c b/TC/unit/utc_drmclient_drm_get_content_info_func.c new file mode 100755 index 0000000..0f01cd7 --- /dev/null +++ b/TC/unit/utc_drmclient_drm_get_content_info_func.c @@ -0,0 +1,281 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_get_content_info_func.c + * @brief TETware unit testing functions for drm_get_content_info. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_get_content_info_func_01(void); +static void utc_drmclient_drm_get_content_info_func_02(void); +static void utc_drmclient_drm_get_content_info_func_03(void); +static void utc_drmclient_drm_get_content_info_func_04(void); +static void utc_drmclient_drm_get_content_info_func_05(void); +static void utc_drmclient_drm_get_content_info_func_06(void); +static void utc_drmclient_drm_get_content_info_func_07(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_get_content_info_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_content_info_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_content_info_func_03, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_content_info_func_04, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_content_info_func_05, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_content_info_func_06, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_content_info_func_07, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_get_content_info:Test started"); +} + +static void cleanup(void) +{ + tet_infoline("drm_get_content_info:Test completed"); +} + +/** + * @brief Positive test case of drm_get_content_info() + */ +static void utc_drmclient_drm_get_content_info_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_content_info_s content_info; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_get_content_info(file_path,&content_info); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_content_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + if('\0' != content_info.author[0]) tet_printf("author=%s",content_info.author); + if('\0' != content_info.copyright[0]) tet_printf("copyright=%s",content_info.copyright); + if('\0' != content_info.description[0]) tet_printf("description=%s",content_info.description); + if('\0' != content_info.icon_uri[0]) tet_printf("icon_uri=%s",content_info.icon_uri); + if('\0' != content_info.info_url[0]) tet_printf("info_url=%s",content_info.info_url); + if('\0' != content_info.content_url[0]) tet_printf("content_url=%s",content_info.content_url); + if('\0' != content_info.rights_url[0]) tet_printf("rights_url=%s",content_info.rights_url); + if('\0' != content_info.title[0]) tet_printf("title=%s",content_info.title); + if('\0' != content_info.mime_type[0]) tet_printf("mime_type=%s",content_info.mime_type); + if('\0' != content_info.content_id[0]) tet_printf("content_id=%s",content_info.content_id); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_content_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_content_info() + */ +static void utc_drmclient_drm_get_content_info_func_02(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_content_info_s content_info; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_2); + + ret = drm_get_content_info(file_path,&content_info); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_content_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x",ret); + if('\0' != content_info.author[0]) tet_printf("author=%s",content_info.author); + if('\0' != content_info.copyright[0]) tet_printf("copyright=%s",content_info.copyright); + if('\0' != content_info.description[0]) tet_printf("description=%s",content_info.description); + if('\0' != content_info.icon_uri[0]) tet_printf("icon_uri=%s",content_info.icon_uri); + if('\0' != content_info.info_url[0]) tet_printf("info_url=%s",content_info.info_url); + if('\0' != content_info.content_url[0]) tet_printf("content_url=%s",content_info.content_url); + if('\0' != content_info.rights_url[0]) tet_printf("rights_url=%s",content_info.rights_url); + if('\0' != content_info.title[0]) tet_printf("title=%s",content_info.title); + if('\0' != content_info.mime_type[0]) tet_printf("mime_type=%s",content_info.mime_type); + if('\0' != content_info.content_id[0]) tet_printf("content_id=%s",content_info.content_id); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_content_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_content_info() + */ +static void utc_drmclient_drm_get_content_info_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_content_info_s content_info; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_get_content_info(file_path,&content_info); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_content_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x",ret); + if('\0' != content_info.author[0]) tet_printf("author=%s",content_info.author); + if('\0' != content_info.copyright[0]) tet_printf("copyright=%s",content_info.copyright); + if('\0' != content_info.description[0]) tet_printf("description=%s",content_info.description); + if('\0' != content_info.icon_uri[0]) tet_printf("icon_uri=%s",content_info.icon_uri); + if('\0' != content_info.info_url[0]) tet_printf("info_url=%s",content_info.info_url); + if('\0' != content_info.content_url[0]) tet_printf("content_url=%s",content_info.content_url); + if('\0' != content_info.rights_url[0]) tet_printf("rights_url=%s",content_info.rights_url); + if('\0' != content_info.title[0]) tet_printf("title=%s",content_info.title); + if('\0' != content_info.mime_type[0]) tet_printf("mime_type=%s",content_info.mime_type); + if('\0' != content_info.content_id[0]) tet_printf("content_id=%s",content_info.content_id); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_content_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_content_info() + */ +static void utc_drmclient_drm_get_content_info_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_content_info_s content_info; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_4); + + ret = drm_get_content_info(file_path,&content_info); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_content_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x",ret); + if('\0' != content_info.author[0]) tet_printf("author=%s",content_info.author); + if('\0' != content_info.copyright[0]) tet_printf("copyright=%s",content_info.copyright); + if('\0' != content_info.description[0]) tet_printf("description=%s",content_info.description); + if('\0' != content_info.icon_uri[0]) tet_printf("icon_uri=%s",content_info.icon_uri); + if('\0' != content_info.info_url[0]) tet_printf("info_url=%s",content_info.info_url); + if('\0' != content_info.content_url[0]) tet_printf("content_url=%s",content_info.content_url); + if('\0' != content_info.rights_url[0]) tet_printf("rights_url=%s",content_info.rights_url); + if('\0' != content_info.title[0]) tet_printf("title=%s",content_info.title); + if('\0' != content_info.mime_type[0]) tet_printf("mime_type=%s",content_info.mime_type); + if('\0' != content_info.content_id[0]) tet_printf("content_id=%s",content_info.content_id); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_content_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_content_info() + */ + +static void utc_drmclient_drm_get_content_info_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_content_info_s content_info; + + ret = drm_get_content_info(FILE_PATH_INVALID_FILE_NULL,&content_info); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_content_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_content_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_content_info() + */ + +static void utc_drmclient_drm_get_content_info_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_content_info_s content_info; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + ret = drm_get_content_info(file_path,&content_info); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_content_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_content_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_content_info() + */ + +static void utc_drmclient_drm_get_content_info_func_07(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_DIVX_1); + + ret = drm_get_content_info(file_path,INVALID_POINTER_OBJECT); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_content_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_content_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret =%d",ret); + tet_result(TET_FAIL); + } +} diff --git a/TC/unit/utc_drmclient_drm_get_data_func.c b/TC/unit/utc_drmclient_drm_get_data_func.c new file mode 100755 index 0000000..687e35a --- /dev/null +++ b/TC/unit/utc_drmclient_drm_get_data_func.c @@ -0,0 +1,445 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_get_data_func.c + * @brief TETware unit testing functions for drm_get_data. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_get_data_func_01(void); +static void utc_drmclient_drm_get_data_func_02(void); +static void utc_drmclient_drm_get_data_func_03(void); +static void utc_drmclient_drm_get_data_func_04(void); +static void utc_drmclient_drm_get_data_func_05(void); +static void utc_drmclient_drm_get_data_func_06(void); +static void utc_drmclient_drm_get_data_func_07(void); +static void utc_drmclient_drm_get_data_func_08(void); +static void utc_drmclient_drm_get_data_func_09(void); +static void utc_drmclient_drm_get_data_func_10(void); +static void utc_drmclient_drm_get_data_func_11(void); +static void utc_drmclient_drm_get_data_func_12(void); +static void utc_drmclient_drm_get_data_func_13(void); +static void utc_drmclient_drm_get_data_func_14(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_get_data_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_02, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_03, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_04, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_05, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_06, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_07, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_08, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_09, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_10, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_11, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_12, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_13, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_data_func_14, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_get_data:Test started"); +} + +static void cleanup(void) +{ + tet_infoline("drm_get_data:Test completed"); +} + +/** + * @brief Positive test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_01(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_SECURE_CLOCK; + drm_secure_clock_data_s secure_clock_info={0}; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf ("Testing:DRM_DATA_TYPE_SECURE_CLOCK"); + ret = drm_get_data(data_type,NULL,(void*)&secure_clock_info); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret + && 1 == secure_clock_info.is_secure_clock_set){ + tet_printf("Secure Clock is SET:ret=0x%x",ret); + tet_printf("Secure Time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + secure_clock_info.secure_clock.tm_year, + secure_clock_info.secure_clock.tm_mon, + secure_clock_info.secure_clock.tm_mday, + secure_clock_info.secure_clock.tm_hour, + secure_clock_info.secure_clock.tm_min, + secure_clock_info.secure_clock.tm_sec); + tet_result(TET_PASS); + }else if(DRM_RETURN_SUCCESS == ret + && 0 == secure_clock_info.is_secure_clock_set){ + tet_printf("Secure Clock is NOT SET:ret=0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_printf("Secure Clock Retrieval FAILED:ret=0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_02(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_NONE; + drm_secure_clock_data_s secure_clock_info={0}; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf ("Testing:DRM_DATA_TYPE_SECURE_CLOCK"); + ret = drm_get_data(data_type,NULL,(void*)&secure_clock_info); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret + && 1 == secure_clock_info.is_secure_clock_set){ + tet_printf("Secure Clock is SET:ret=0x%x",ret); + tet_printf("Secure Time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + secure_clock_info.secure_clock.tm_year, + secure_clock_info.secure_clock.tm_mon, + secure_clock_info.secure_clock.tm_mday, + secure_clock_info.secure_clock.tm_hour, + secure_clock_info.secure_clock.tm_min, + secure_clock_info.secure_clock.tm_sec); + tet_result(TET_FAIL); + }else if(DRM_RETURN_SUCCESS == ret + && 0 == secure_clock_info.is_secure_clock_set){ + tet_printf("Secure Clock is NOT SET:ret=0x%x",ret); + tet_result(TET_FAIL); + }else{ + tet_printf("Passing Invalid data_type=%d",data_type); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_03(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_SECURE_CLOCK; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf ("Testing:DRM_DATA_TYPE_SECURE_CLOCK"); + ret = drm_get_data(data_type,NULL,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Returned Success:ret=0x%x",ret); + tet_result(TET_FAIL); + }else{ + tet_printf("Passing Invalid output parameter"); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_04(void) +{ + drm_data_type_e data_type=DRM_DATA_TYPE_NONE; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf ("Testing:DRM_DATA_TYPE_SECURE_CLOCK"); + ret = drm_get_data(data_type,NULL,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Returned Success:ret=0x%x data_type=%d",ret,data_type); + tet_result(TET_FAIL); + }else{ + tet_printf("Passing Invalid data_type=%d",data_type); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_05(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG; + int ret = DRM_RETURN_INTERNAL_ERROR; + int transtrk_flag = 0; + + tet_printf ("Testing:DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG"); + ret = drm_get_data(data_type, NULL, (void*)&transtrk_flag); + tet_printf("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("transtrk_flag = %d", transtrk_flag); + tet_result(TET_PASS); + } else { + tet_printf("Get Transaction Tracking Flag failed!!, " + "ret = 0x%x", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_06(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf ("Testing:DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG"); + ret = drm_get_data(data_type, NULL,NULL); + tet_printf("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Returned Success"); + tet_result(TET_FAIL); + } else { + tet_printf("Invalid output:ret = 0x%x", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_07(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_ID; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_TRANSACTION_TRACKING_ID"); + drm_transaction_id_info_s transaction_id_info; + memset(&transaction_id_info,0x0,sizeof(drm_transaction_id_info_s)); + + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_get_data(data_type,(void*)file_path,(void*)&transaction_id_info); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Transaction ID Length =%d file_path=%s", + transaction_id_info.tr_id_len,file_path); + if(0 != transaction_id_info.tr_id_len){ + tet_printf("Transaction ID =%s", + transaction_id_info.tr_id); + } + tet_result(TET_PASS); + }else{ + tet_printf("Transaction ID Retrieval FAILED:ret=0x%x file_path=%s", + ret,file_path); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_08(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_ID; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_TRANSACTION_TRACKING_ID"); + drm_transaction_id_info_s transaction_id_info; + memset(&transaction_id_info,0x0,sizeof(drm_transaction_id_info_s)); + + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_EMPTY); + + ret = drm_get_data(data_type,(void*)file_path,(void*)&transaction_id_info); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Transaction ID Length =%d file_path=%s", + transaction_id_info.tr_id_len,file_path); + if(0 != transaction_id_info.tr_id_len){ + tet_printf("Transaction ID =%s", + transaction_id_info.tr_id); + } + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid Input:ret=0x%x file_path=%s", + ret,file_path); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_09(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_ID; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_TRANSACTION_TRACKING_ID"); + + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_get_data(data_type,(void*)file_path,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Returned Success:ret=0x%x",ret); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid Output:ret=0x%x file_path=%s", + ret,file_path); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_10(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_ID; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_TRANSACTION_TRACKING_ID"); + drm_transaction_id_info_s transaction_id_info; + memset(&transaction_id_info,0x0,sizeof(drm_transaction_id_info_s)); + + ret = drm_get_data(data_type,NULL,(void*)&transaction_id_info); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Returned Success:ret=0x%x",ret); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid Input:ret=0x%x",ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_11(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_DIVX_REGISTRATION_CODE; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_DIVX_REGISTRATION_CODE"); + + drm_code_info_s reg_code_info; + memset(®_code_info,0x0,sizeof(drm_code_info_s)); + + ret = drm_get_data(data_type, NULL, (void*) ®_code_info); + tet_printf("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Code Length = %d", reg_code_info.code_len); + if (0 != reg_code_info.code_len) { + tet_printf("Code = %s", reg_code_info.code); + } + tet_result(TET_PASS); + } else { + tet_printf("Divx Registration Code Retrieval failed!!"); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_12(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_DIVX_REGISTRATION_CODE; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_DIVX_REGISTRATION_CODE"); + + ret = drm_get_data(data_type, NULL,NULL); + tet_printf("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Success:ret=0x%x", ret); + tet_result(TET_FAIL); + } else { + tet_printf("Invalid output:ret=0x%x", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_13(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE"); + + drm_code_info_s dereg_code_info; + memset(&dereg_code_info,0x0,sizeof(drm_code_info_s)); + ret = drm_get_data(data_type, NULL, (void*) &dereg_code_info); + tet_printf("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Code Length = %d", dereg_code_info.code_len); + if (0 != dereg_code_info.code_len) { + tet_printf("Code = %s", dereg_code_info.code); + } + tet_result(TET_PASS); + } else { + tet_printf("Divx Deregistration Code Retrieval failed!!"); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_data() + */ +static void utc_drmclient_drm_get_data_func_14(void) +{ + drm_data_type_e data_type = DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE; + int ret = DRM_RETURN_INTERNAL_ERROR; + + tet_printf("Testing:DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE"); + + ret = drm_get_data(data_type, NULL,NULL); + tet_printf("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Success:ret=0x%x", ret); + tet_result(TET_FAIL); + } else { + tet_printf("Invalid output:ret=0x%x", ret); + tet_result(TET_PASS); + } +} diff --git a/TC/unit/utc_drmclient_drm_get_file_info_func.c b/TC/unit/utc_drmclient_drm_get_file_info_func.c new file mode 100755 index 0000000..1b00e81 --- /dev/null +++ b/TC/unit/utc_drmclient_drm_get_file_info_func.c @@ -0,0 +1,354 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_get_file_info_func.c + * @brief TETware unit testing functions for drm_get_file_info. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_get_file_info_func_01(void); +static void utc_drmclient_drm_get_file_info_func_02(void); +static void utc_drmclient_drm_get_file_info_func_03(void); +static void utc_drmclient_drm_get_file_info_func_04(void); +static void utc_drmclient_drm_get_file_info_func_05(void); +static void utc_drmclient_drm_get_file_info_func_06(void); +static void utc_drmclient_drm_get_file_info_func_07(void); +static void utc_drmclient_drm_get_file_info_func_08(void); +static void utc_drmclient_drm_get_file_info_func_09(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_get_file_info_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_03, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_04, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_05, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_06, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_07, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_08, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_info_func_09, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_get_file_info:Test started"); +} + +static void cleanup(void) +{ + tet_infoline("drm_get_file_info:Test completed"); +} + +/** + * @brief Positive test case of drm_get_file_info() + */ +static void utc_drmclient_drm_get_file_info_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + if(DRM_METHOD_TYPE_UNDEFINED != fileInfo.oma_info.method){ + tet_printf("method=%d",fileInfo.oma_info.method); + tet_printf("version=%d",fileInfo.oma_info.version); + }else if(0 != fileInfo.pr_env_info.org_file_size){ + tet_printf("PlayReady Envelope File"); + tet_printf("org_file_name=%s",fileInfo.pr_env_info.org_file_name); + tet_printf("org_file_size=%d",fileInfo.pr_env_info.org_file_size); + }else{ + tet_printf("Other DRM File=%s",file_path); + } + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path=%s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_info() + */ +static void utc_drmclient_drm_get_file_info_func_02(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_2); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + if(DRM_METHOD_TYPE_UNDEFINED != fileInfo.oma_info.method){ + tet_printf("method=%d",fileInfo.oma_info.method); + tet_printf("version=%d",fileInfo.oma_info.version); + }else if(0 != fileInfo.pr_env_info.org_file_size){ + tet_printf("PlayReady Envelope File"); + tet_printf("org_file_name=%s",fileInfo.pr_env_info.org_file_name); + tet_printf("org_file_size=%d",fileInfo.pr_env_info.org_file_size); + }else{ + tet_printf("Other DRM File=%s",file_path); + } + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path=%s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_info() + */ +static void utc_drmclient_drm_get_file_info_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + if(DRM_METHOD_TYPE_UNDEFINED != fileInfo.oma_info.method){ + tet_printf("method=%d",fileInfo.oma_info.method); + tet_printf("version=%d",fileInfo.oma_info.version); + }else if(0 != fileInfo.pr_env_info.org_file_size){ + tet_printf("PlayReady Envelope File"); + tet_printf("org_file_name=%s",fileInfo.pr_env_info.org_file_name); + tet_printf("org_file_size=%d",fileInfo.pr_env_info.org_file_size); + }else{ + tet_printf("Other DRM File=%s",file_path); + } + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path=%s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_info() + */ +static void utc_drmclient_drm_get_file_info_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_4); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + if(DRM_METHOD_TYPE_UNDEFINED != fileInfo.oma_info.method){ + tet_printf("method=%d",fileInfo.oma_info.method); + tet_printf("version=%d",fileInfo.oma_info.version); + }else if(0 != fileInfo.pr_env_info.org_file_size){ + tet_printf("PlayReady Envelope File"); + tet_printf("org_file_name=%s",fileInfo.pr_env_info.org_file_name); + tet_printf("org_file_size=%d",fileInfo.pr_env_info.org_file_size); + }else{ + tet_printf("Other DRM File=%s",file_path); + } + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path=%s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_info() + */ +static void utc_drmclient_drm_get_file_info_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_ENV_1); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_1); + if(DRM_METHOD_TYPE_UNDEFINED != fileInfo.oma_info.method){ + tet_printf("method=%d",fileInfo.oma_info.method); + tet_printf("version=%d",fileInfo.oma_info.version); + }else if(0 != fileInfo.pr_env_info.org_file_size){ + tet_printf("PlayReady Envelope File"); + tet_printf("org_file_name=%s",fileInfo.pr_env_info.org_file_name); + tet_printf("org_file_size=%d",fileInfo.pr_env_info.org_file_size); + }else{ + tet_printf("Other DRM File=%s",file_path); + } + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path=%s",FILE_PATH_VALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_info() + */ +static void utc_drmclient_drm_get_file_info_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_ENV_2); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_2); + if(DRM_METHOD_TYPE_UNDEFINED != fileInfo.oma_info.method){ + tet_printf("method=%d",fileInfo.oma_info.method); + tet_printf("version=%d",fileInfo.oma_info.version); + }else if(0 != fileInfo.pr_env_info.org_file_size){ + tet_printf("PlayReady Envelope File"); + tet_printf("org_file_name=%s",fileInfo.pr_env_info.org_file_name); + tet_printf("org_file_size=%d",fileInfo.pr_env_info.org_file_size); + }else{ + tet_printf("Other DRM File=%s",file_path); + } + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path=%s",FILE_PATH_VALID_FILE_PR_ENV_2); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_info() + */ + +static void utc_drmclient_drm_get_file_info_func_07(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + + ret = drm_get_file_info(FILE_PATH_INVALID_FILE_NULL,&fileInfo); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_info() + */ + +static void utc_drmclient_drm_get_file_info_func_08(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_info_s fileInfo; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_EMPTY); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_info() + */ + +static void utc_drmclient_drm_get_file_info_func_09(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_ENV_1); + + ret = drm_get_file_info(file_path,INVALID_POINTER_OBJECT); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_file_info PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_info FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} diff --git a/TC/unit/utc_drmclient_drm_get_file_type_func.c b/TC/unit/utc_drmclient_drm_get_file_type_func.c new file mode 100755 index 0000000..0af3a9d --- /dev/null +++ b/TC/unit/utc_drmclient_drm_get_file_type_func.c @@ -0,0 +1,534 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_get_file_type_func.c + * @brief TETware unit testing functions for drm_get_file_type. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_get_file_type_func_01(void); +static void utc_drmclient_drm_get_file_type_func_02(void); +static void utc_drmclient_drm_get_file_type_func_03(void); +static void utc_drmclient_drm_get_file_type_func_04(void); +static void utc_drmclient_drm_get_file_type_func_05(void); +static void utc_drmclient_drm_get_file_type_func_06(void); +static void utc_drmclient_drm_get_file_type_func_07(void); +static void utc_drmclient_drm_get_file_type_func_08(void); +static void utc_drmclient_drm_get_file_type_func_09(void); +static void utc_drmclient_drm_get_file_type_func_10(void); +static void utc_drmclient_drm_get_file_type_func_11(void); +static void utc_drmclient_drm_get_file_type_func_12(void); +static void utc_drmclient_drm_get_file_type_func_13(void); +static void utc_drmclient_drm_get_file_type_func_14(void); +static void utc_drmclient_drm_get_file_type_func_15(void); +static void utc_drmclient_drm_get_file_type_func_16(void); +static void utc_drmclient_drm_get_file_type_func_17(void); +static void utc_drmclient_drm_get_file_type_func_18(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_get_file_type_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_03, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_04, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_05, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_06, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_07, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_08, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_09, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_10, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_11, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_12, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_13, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_14, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_15, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_16, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_17, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_file_type_func_18, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_get_file_type:Test started"); +} + +static void cleanup(void) +{ + tet_infoline("drm_get_file_type:Test completed"); +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_OMA_V1 == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_02(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_2); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_OMA_V2 == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_OMA_V2 == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_4); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_OMA_V2 == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_1); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_PLAYREADY == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_2); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_PLAYREADY == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_07(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_ENV_1); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_PLAYREADY_ENVELOPE == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_08(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_ENV_2); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_PLAYREADY_ENVELOPE == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_file_type() + */ +static void utc_drmclient_drm_get_file_type_func_09(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_DIVX_1); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_DIVX == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_10(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + + ret = drm_get_file_type(FILE_PATH_INVALID_FILE_NULL,&file_type); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_11(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_12(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_OMA_1); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_UNDEFINED == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_13(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_OMA_2); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_UNDEFINED == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_14(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_OMA_3); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_UNDEFINED == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_3); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_3); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_15(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_PR_1); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_UNDEFINED == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_16(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_PR_2); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_UNDEFINED == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_2); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_17(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_PR_ENV_1); + + ret = drm_get_file_type(file_path,&file_type); + if(DRM_RETURN_SUCCESS == ret && DRM_TYPE_UNDEFINED == file_type){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_file_type() + */ + +static void utc_drmclient_drm_get_file_type_func_18(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_PR_ENV_1); + + ret = drm_get_file_type(file_path,INVALID_POINTER_OBJECT); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_file_type PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_file_type FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x file_type=%d",ret,file_type); + tet_result(TET_FAIL); + } +} diff --git a/TC/unit/utc_drmclient_drm_get_license_status_func.c b/TC/unit/utc_drmclient_drm_get_license_status_func.c new file mode 100755 index 0000000..045ef7f --- /dev/null +++ b/TC/unit/utc_drmclient_drm_get_license_status_func.c @@ -0,0 +1,333 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_get_license_status_func.c + * @brief TETware unit testing functions for drm_get_license_status. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_get_license_status_func_01(void); +static void utc_drmclient_drm_get_license_status_func_02(void); +static void utc_drmclient_drm_get_license_status_func_03(void); +static void utc_drmclient_drm_get_license_status_func_04(void); +static void utc_drmclient_drm_get_license_status_func_05(void); +static void utc_drmclient_drm_get_license_status_func_06(void); +static void utc_drmclient_drm_get_license_status_func_07(void); +static void utc_drmclient_drm_get_license_status_func_08(void); +static void utc_drmclient_drm_get_license_status_func_09(void); +static void utc_drmclient_drm_get_license_status_func_10(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_get_license_status_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_03, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_04, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_05, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_06, POSITIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_07, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_08, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_09, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_get_license_status_func_10, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_get_license_status:Test started"); + tet_infoline("OMA DRM Content should be registered"); + tet_infoline("RO must be installed to get valid License status"); +} + +static void cleanup(void) +{ + tet_infoline("drm_get_license_status:Test completed"); +} + +/** + * @brief Positive test case of drm_get_license_status() + */ +static void utc_drmclient_drm_get_license_status_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_license_status() + */ +static void utc_drmclient_drm_get_license_status_func_02(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_DISPLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_2); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_license_status() + */ +static void utc_drmclient_drm_get_license_status_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_license_status() + */ +static void utc_drmclient_drm_get_license_status_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_4); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_license_status() + */ +static void utc_drmclient_drm_get_license_status_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_1); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_get_license_status() + */ +static void utc_drmclient_drm_get_license_status_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_PLAY; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_2); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS == ret ){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_license_status() + */ + +static void utc_drmclient_drm_get_license_status_func_07(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_NONE; + + ret = drm_get_license_status(FILE_PATH_INVALID_FILE_NULL,perm_type,&license_status); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_license_status() + */ + +static void utc_drmclient_drm_get_license_status_func_08(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_NONE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_license_status() + */ + +static void utc_drmclient_drm_get_license_status_func_09(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_NONE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_DIVX_1); + + ret = drm_get_license_status(file_path,perm_type,INVALID_POINTER_OBJECT); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_get_license_status() + */ + +static void utc_drmclient_drm_get_license_status_func_10(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + drm_permission_type_e perm_type = DRM_PERMISSION_TYPE_NONE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_OMA_2); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_get_license_status PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_2); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_get_license_status FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_2); + tet_printf ("ret = 0x%x license_status=%d",ret,license_status); + tet_result(TET_FAIL); + } +} diff --git a/TC/unit/utc_drmclient_drm_is_action_allowed_func.c b/TC/unit/utc_drmclient_drm_is_action_allowed_func.c new file mode 100755 index 0000000..e5d26c5 --- /dev/null +++ b/TC/unit/utc_drmclient_drm_is_action_allowed_func.c @@ -0,0 +1,358 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_is_action_allowed_func.c + * @brief TETware unit testing functions for drm_is_action_allowed. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_is_action_allowed_func_01(void); +static void utc_drmclient_drm_is_action_allowed_func_02(void); +static void utc_drmclient_drm_is_action_allowed_func_03(void); +static void utc_drmclient_drm_is_action_allowed_func_04(void); +static void utc_drmclient_drm_is_action_allowed_func_05(void); +static void utc_drmclient_drm_is_action_allowed_func_06(void); +static void utc_drmclient_drm_is_action_allowed_func_07(void); +static void utc_drmclient_drm_is_action_allowed_func_08(void); +static void utc_drmclient_drm_is_action_allowed_func_09(void); +static void utc_drmclient_drm_is_action_allowed_func_10(void); +static void utc_drmclient_drm_is_action_allowed_func_11(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_is_action_allowed_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_03, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_04, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_05, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_06, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_07, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_08, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_09, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_10, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_action_allowed_func_11, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_is_action_allowed:Test started"); +} + +static void cleanup(void) +{ + tet_infoline("drm_is_action_allowed:Test completed"); +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_9); + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_allowed){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_9); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_9); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_02(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_2); + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_4); + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_HAS_VALID_SETAS_STATUS; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + action_data.data = (int)DRM_SETAS_RINGTONE; + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_allowed){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_07(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_HAS_VALID_SETAS_STATUS; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_8); + action_data.data= (int)DRM_SETAS_RINGTONE; + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_8); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_8); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_08(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_DEVICE_ACTIVATED; + + ret = drm_is_action_allowed(action,NULL,&is_allowed); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_09(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_VALID_SECURE_CLOCK; + + ret = drm_is_action_allowed(action,NULL,&is_allowed); + if(DRM_RETURN_SUCCESS == ret){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_action_allowed() + */ +static void utc_drmclient_drm_is_action_allowed_func_10(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED; + + ret = drm_is_action_allowed(action,NULL,&is_allowed); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("ret = 0x%x is_allowed=%d",ret,is_allowed); + tet_result(TET_FAIL); + } +} + + +/** + * @brief Negative test case of drm_is_action_allowed() + */ + +static void utc_drmclient_drm_is_action_allowed_func_11(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED; + drm_action_allowed_data_s action_data; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + snprintf(action_data.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_is_action_allowed(action,&action_data,INVALID_POINTER_OBJECT); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_is_action_allowed PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_action_allowed FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x",ret); + tet_result(TET_FAIL); + } +} diff --git a/TC/unit/utc_drmclient_drm_is_drm_file_func.c b/TC/unit/utc_drmclient_drm_is_drm_file_func.c new file mode 100755 index 0000000..78b7c91 --- /dev/null +++ b/TC/unit/utc_drmclient_drm_is_drm_file_func.c @@ -0,0 +1,561 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_is_drm_file_func.c + * @brief TETware unit testing functions for drm_is_drm_file. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_is_drm_file_func_01(void); +static void utc_drmclient_drm_is_drm_file_func_02(void); +static void utc_drmclient_drm_is_drm_file_func_03(void); +static void utc_drmclient_drm_is_drm_file_func_04(void); +static void utc_drmclient_drm_is_drm_file_func_05(void); +static void utc_drmclient_drm_is_drm_file_func_06(void); +static void utc_drmclient_drm_is_drm_file_func_07(void); +static void utc_drmclient_drm_is_drm_file_func_08(void); +static void utc_drmclient_drm_is_drm_file_func_09(void); +static void utc_drmclient_drm_is_drm_file_func_10(void); +static void utc_drmclient_drm_is_drm_file_func_11(void); +static void utc_drmclient_drm_is_drm_file_func_12(void); +static void utc_drmclient_drm_is_drm_file_func_13(void); +static void utc_drmclient_drm_is_drm_file_func_14(void); +static void utc_drmclient_drm_is_drm_file_func_15(void); +static void utc_drmclient_drm_is_drm_file_func_16(void); +static void utc_drmclient_drm_is_drm_file_func_17(void); +static void utc_drmclient_drm_is_drm_file_func_18(void); +static void utc_drmclient_drm_is_drm_file_func_19(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_is_drm_file_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_03, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_04, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_05, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_06, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_07, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_08, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_09, POSITIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_10, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_11, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_12, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_13, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_14, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_15, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_16, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_17, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_18, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_is_drm_file_func_19, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_is_drm_file:Test started"); +} + +static void cleanup(void) +{ + tet_infoline("drm_is_drm_file:Test completed"); +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_02(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_2); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_3); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_3); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_4); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_OMA_4); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_2); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_07(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_ENV_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_08(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_PR_ENV_2); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_PR_ENV_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_is_drm_file() + */ +static void utc_drmclient_drm_is_drm_file_func_09(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_DIVX_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_VALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_10(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + + ret = drm_is_drm_file(FILE_PATH_INVALID_FILE_NULL,&is_drm_file); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_NULL); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_11(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_EMPTY); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_12(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_OMA_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_13(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_OMA_2); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_14(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_OMA_3); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_3); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_OMA_3); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_15(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_PR_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_16(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_PR_2); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_2); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_17(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_PR_ENV_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_PR_ENV_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_18(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_DIVX_1); + + ret = drm_is_drm_file(file_path,&is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_FALSE == is_drm_file){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_is_drm_file() + */ + +static void utc_drmclient_drm_is_drm_file_func_19(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR ; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_DIVX_1); + + ret = drm_is_drm_file(file_path,INVALID_POINTER_OBJECT); + if(DRM_RETURN_SUCCESS != ret){ + tet_infoline("drm_is_drm_file PASS!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_PASS); + }else{ + tet_infoline("drm_is_drm_file FAIL!!!"); + tet_printf ("file_path checked is %s",FILE_PATH_INVALID_FILE_DIVX_1); + tet_printf ("ret = 0x%x is_drm_file=%d",ret,is_drm_file); + tet_result(TET_FAIL); + } +} diff --git a/TC/unit/utc_drmclient_drm_process_request_func.c b/TC/unit/utc_drmclient_drm_process_request_func.c new file mode 100755 index 0000000..6c9afe5 --- /dev/null +++ b/TC/unit/utc_drmclient_drm_process_request_func.c @@ -0,0 +1,1287 @@ +/* + * drm-client TCs + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 utc_drmclient_drm_process_request_func.c + * @brief TETware unit testing functions for drm_process_request. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @version 0.1 + * @history 0.1: Initial draft + */ + +#include +#include + +#include + +#include "drmcontentsdef.h" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_drmclient_drm_process_request_func_01(void); +static void utc_drmclient_drm_process_request_func_02(void); +static void utc_drmclient_drm_process_request_func_03(void); +static void utc_drmclient_drm_process_request_func_04(void); +static void utc_drmclient_drm_process_request_func_05(void); +static void utc_drmclient_drm_process_request_func_06(void); +static void utc_drmclient_drm_process_request_func_07(void); +static void utc_drmclient_drm_process_request_func_08(void); +static void utc_drmclient_drm_process_request_func_09(void); +static void utc_drmclient_drm_process_request_func_10(void); +static void utc_drmclient_drm_process_request_func_11(void); +static void utc_drmclient_drm_process_request_func_12(void); +static void utc_drmclient_drm_process_request_func_13(void); +static void utc_drmclient_drm_process_request_func_14(void); +static void utc_drmclient_drm_process_request_func_15(void); +static void utc_drmclient_drm_process_request_func_16(void); +static void utc_drmclient_drm_process_request_func_17(void); +static void utc_drmclient_drm_process_request_func_18(void); +static void utc_drmclient_drm_process_request_func_19(void); +static void utc_drmclient_drm_process_request_func_20(void); +static void utc_drmclient_drm_process_request_func_21(void); +static void utc_drmclient_drm_process_request_func_22(void); +static void utc_drmclient_drm_process_request_func_23(void); +static void utc_drmclient_drm_process_request_func_24(void); +static void utc_drmclient_drm_process_request_func_25(void); +static void utc_drmclient_drm_process_request_func_26(void); +static void utc_drmclient_drm_process_request_func_27(void); +static void utc_drmclient_drm_process_request_func_28(void); +static void utc_drmclient_drm_process_request_func_29(void); +static void utc_drmclient_drm_process_request_func_30(void); +static void utc_drmclient_drm_process_request_func_31(void); +static void utc_drmclient_drm_process_request_func_32(void); +static void utc_drmclient_drm_process_request_func_33(void); +static void utc_drmclient_drm_process_request_func_34(void); +static void utc_drmclient_drm_process_request_func_35(void); +static void utc_drmclient_drm_process_request_func_36(void); +static void utc_drmclient_drm_process_request_func_37(void); +static void utc_drmclient_drm_process_request_func_38(void); +static void utc_drmclient_drm_process_request_func_39(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_drmclient_drm_process_request_func_01, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_02, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_03, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_04, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_05, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_06, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_07, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_08, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_09, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_10, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_11, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_12, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_13, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_14, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_15, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_16, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_17, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_18, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_19, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_20, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_21, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_22, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_23, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_24, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_25, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_26, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_27, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_28, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_29, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_30, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_31, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_32, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_33, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_34, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_35, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_36, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_37, NEGATIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_38, POSITIVE_TC_IDX }, + { utc_drmclient_drm_process_request_func_39, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + tet_infoline("drm_process_request:Test started"); +} + +static void cleanup(void) +{ + tet_infoline("drm_process_request:Test completed"); +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_01(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_FILE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("Testing:DRM_REQUEST_TYPE_REGISTER_FILE"); + + ret = drm_process_request(request_type,(void*)file_path,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register success:file_path=%s", + file_path); + tet_result(TET_PASS); + }else{ + tet_printf("Register FAILED:ret=0x%x file_path=%s", + ret,file_path); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_02(void) +{ + /** This is duplication of + * test-case utc_drmclient_drm_process_request_func_01 + * This test-case is added to ensure proper behavior if same content is + * registered 2 times. + */ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_FILE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("Testing:DRM_REQUEST_TYPE_REGISTER_FILE"); + + ret = drm_process_request(request_type,(void*)file_path,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register success:file_path=%s", + file_path); + tet_result(TET_PASS); + }else{ + tet_printf("Register FAILED:ret=0x%x file_path=%s", + ret,file_path); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_03(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_NONE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf("Testing:DRM_REQUEST_TYPE_NONE"); + + ret = drm_process_request(request_type,(void*)file_path,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register success:file_path=%s", + file_path); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid request_type=%d ret=0x%x file_path=%s", + request_type,ret,file_path); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_04(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_FILE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_FILE"); + + ret = drm_process_request(request_type,(void*)file_path,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register success:file_path=%s", + file_path); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid file_path: ret=0x%x file_path=%s", + ret,file_path); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_05(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_FILE; + char *file_path = NULL; + + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_FILE"); + + ret = drm_process_request(request_type,(void*)file_path,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register success:file_path=%p", + file_path); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid file_path: ret=0x%x file_path=%p", + ret,file_path); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_06(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_FILE; + drm_unregister_info_s unregister_info; + memset(&unregister_info,0x0,sizeof(drm_unregister_info_s)); + + tet_printf("Testing:DRM_REQUEST_TYPE_UNREGISTER_FILE"); + snprintf(unregister_info.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + unregister_info.remove_license = 1; + + ret = drm_process_request(request_type,(void*)&unregister_info,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Un-register success:file_path=%s", + unregister_info.file_path); + tet_result(TET_PASS); + }else{ + tet_printf("Un-register FAILED:ret=0x%x " + "file_path=%s",ret,unregister_info.file_path); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_07(void) +{ + /** This is duplication of + * test-case utc_drmclient_drm_process_request_func_06 + * This test-case is added to ensure proper behavior if same content is + * unregistered 2 times. + */ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_FILE; + drm_unregister_info_s unregister_info; + memset(&unregister_info,0x0,sizeof(drm_unregister_info_s)); + + tet_printf("Testing:DRM_REQUEST_TYPE_UNREGISTER_FILE"); + snprintf(unregister_info.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + unregister_info.remove_license = 0; + + ret = drm_process_request(request_type,(void*)&unregister_info,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Un-register success:file_path=%s", + unregister_info.file_path); + tet_result(TET_PASS); + }else{ + tet_printf("Un-register FAILED:ret=0x%x " + "file_path=%s",ret,unregister_info.file_path); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_08(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_FILE; + drm_unregister_info_s unregister_info; + memset(&unregister_info,0x0,sizeof(drm_unregister_info_s)); + + tet_printf("Testing:DRM_REQUEST_TYPE_UNREGISTER_FILE"); + snprintf(unregister_info.file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_INVALID_FILE_EMPTY); + unregister_info.remove_license = 0; + + ret = drm_process_request(request_type,(void*)&unregister_info,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Un-register success:file_path=%s", + unregister_info.file_path); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid file path:ret=0x%x " + "file_path=%s",ret,unregister_info.file_path); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_09(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_FILE; + + tet_printf("Testing:DRM_REQUEST_TYPE_UNREGISTER_FILE"); + + ret = drm_process_request(request_type,NULL,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Un-register success"); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid input:ret=0x%x",ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_10(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_LICENSE"); + + drm_register_lic_info_s lic_req_info; + drm_register_lic_resp_s lic_resp_info; + + memset(&lic_req_info,0x0,sizeof(drm_register_lic_info_s)); + memset(&lic_resp_info,0x0,sizeof(drm_register_lic_resp_s)); + + struct stat stat_buf = { 0 }; + FILE *fp = NULL; + unsigned int read_len=0; + char *tempPath = NULL; + + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_RO_FILE_OMA_1); + + if (0 == stat(file_path, &stat_buf)) { + lic_req_info.lic_data_len = stat_buf.st_size; + tet_printf("file_path=%s file_size=%u",file_path, + lic_req_info.lic_data_len); + } else { + tet_printf("stat failed:error=%s file_path=%s", + strerror(errno),file_path); + tet_result(TET_FAIL); + return; + } + + fp = fopen(file_path,"r"); + if(NULL == fp){ + tet_printf("fopen failed:error=%s file_path=%s", + strerror(errno),file_path); + tet_result(TET_FAIL); + return; + } + + memset(lic_req_info.lic_data,0x0,sizeof(lic_req_info.lic_data)); + read_len = fread(lic_req_info.lic_data,1,lic_req_info.lic_data_len,fp); + tet_printf("read_len=%u lic_req_info.lic_data_len=%u", + read_len,lic_req_info.lic_data_len); + + fclose(fp); + + tempPath = strrchr((char *)file_path, '.'); + if(strncmp(tempPath, ".dr", 2) == 0 + || strncmp(tempPath, ".drc", 3) == 0){ + tet_printf("DRM v1 License file"); + + lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS; + lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_UNKNOWN; + lic_req_info.operation_callback.callback = NULL; + + ret = drm_process_request(request_type,(void*)&lic_req_info, + (void*)&lic_resp_info); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register License success"); + tet_printf("CID=%s",lic_resp_info.cid); + tet_result(TET_PASS); + }else{ + tet_printf("Register License FAILED:" + "ret=0x%x",ret); + tet_result(TET_FAIL); + } + }else{ + tet_printf("Not a License file:ret=0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_11(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_LICENSE"); + + drm_register_lic_info_s lic_req_info; + drm_register_lic_resp_s lic_resp_info; + + memset(&lic_req_info,0x0,sizeof(drm_register_lic_info_s)); + memset(&lic_resp_info,0x0,sizeof(drm_register_lic_resp_s)); + + struct stat stat_buf = { 0 }; + FILE *fp = NULL; + unsigned int read_len=0; + char *tempPath = NULL; + + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_RO_FILE_OMA_2); + + if (0 == stat(file_path, &stat_buf)) { + lic_req_info.lic_data_len = stat_buf.st_size; + tet_printf("file_path=%s file_size=%u",file_path, + lic_req_info.lic_data_len); + } else { + tet_printf("stat failed:error=%s file_path=%s", + strerror(errno),file_path); + tet_result(TET_FAIL); + return; + } + + fp = fopen(file_path,"r"); + if(NULL == fp){ + tet_printf("fopen failed:error=%s file_path=%s", + strerror(errno),file_path); + tet_result(TET_FAIL); + return; + } + + memset(lic_req_info.lic_data,0x0,sizeof(lic_req_info.lic_data)); + read_len = fread(lic_req_info.lic_data,1,lic_req_info.lic_data_len,fp); + tet_printf("read_len=%u lic_req_info.lic_data_len=%u", + read_len,lic_req_info.lic_data_len); + + fclose(fp); + + tempPath = strrchr((char *)file_path, '.'); + if(strncmp(tempPath, ".dr", 2) == 0 + || strncmp(tempPath, ".drc", 3) == 0){ + tet_printf("DRM v1 License file"); + + lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS; + lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_UNKNOWN; + lic_req_info.operation_callback.callback = NULL; + + ret = drm_process_request(request_type,(void*)&lic_req_info, + (void*)&lic_resp_info); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register License success"); + tet_printf("CID=%s",lic_resp_info.cid); + tet_result(TET_PASS); + }else{ + tet_printf("Register License FAILED:" + "ret=0x%x",ret); + tet_result(TET_FAIL); + } + }else{ + tet_printf("Not a License file:ret=0x%x",ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_12(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_LICENSE"); + + ret = drm_process_request(request_type,NULL,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register License success"); + tet_result(TET_FAIL); + }else{ + tet_printf("Invalid input and output ret=0x%x",ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + * @remark Content is un-registered as a part of + * utc_drmclient_drm_process_request_func_06 + * and utc_drmclient_drm_process_request_func_07. + * Thus re-registering the content. + */ +static void utc_drmclient_drm_process_request_func_13(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_FILE; + char file_path[FILE_PATH_MAX_SIZE] = {0,}; + + snprintf(file_path,FILE_PATH_MAX_SIZE, "%s",FILE_PATH_VALID_FILE_OMA_1); + tet_printf ("Testing:DRM_REQUEST_TYPE_REGISTER_FILE"); + + ret = drm_process_request(request_type,(void*)file_path,NULL); + tet_printf("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + tet_printf("Register success:file_path=%s", + file_path); + tet_result(TET_PASS); + }else{ + tet_printf("Register FAILED:ret=0x%x file_path=%s", + ret,file_path); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_14(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL; + tet_printf ("Testing:DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL"); + + drm_initiator_info_s initiator_info; + drm_web_server_resp_data_s ws_resp_data; + + memset(&initiator_info,0x0,sizeof(drm_initiator_info_s)); + memset(&ws_resp_data,0x0,sizeof(drm_web_server_resp_data_s)); + + snprintf(initiator_info.initiator_url,DRM_MAX_LEN_INITIATOR_URL, "%s", + LICENSE_INITIATOR_VALID_PR_FILE); + + tet_printf ("Source Initiator URL=%s",LICENSE_INITIATOR_VALID_PR_FILE); + tet_printf ("Destination Initiator URL=%s",initiator_info.initiator_url); + + initiator_info.initiator_url_len = strlen(initiator_info.initiator_url); + initiator_info.operation_callback.callback = NULL; + + tet_printf ("Source Initiator URL Length=%u",strlen(LICENSE_INITIATOR_VALID_PR_FILE)); + tet_printf ("Destination Initiator URL Length=%u",strlen(initiator_info.initiator_url)); + + ret = drm_process_request(request_type, (void*)&initiator_info, + (void*)&ws_resp_data); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Server Error Code = %d", + ws_resp_data.result_code); + tet_printf("Content URL = %s", + ws_resp_data.content_url); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_15(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL; + tet_printf ("Testing:DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL"); + + drm_initiator_info_s initiator_info; + drm_web_server_resp_data_s ws_resp_data; + + memset(&initiator_info,0x0,sizeof(drm_initiator_info_s)); + memset(&ws_resp_data,0x0,sizeof(drm_web_server_resp_data_s)); + + snprintf(initiator_info.initiator_url,DRM_MAX_LEN_INITIATOR_URL, "%s", + LICENSE_INITIATOR_VALID_PR_FILE_1); + + tet_printf ("Source Initiator URL=%s",LICENSE_INITIATOR_VALID_PR_FILE_1); + tet_printf ("Destination Initiator URL=%s",initiator_info.initiator_url); + + initiator_info.initiator_url_len = strlen(initiator_info.initiator_url); + initiator_info.operation_callback.callback = NULL; + + tet_printf ("Source Initiator URL Length=%u",strlen(LICENSE_INITIATOR_VALID_PR_FILE_1)); + tet_printf ("Destination Initiator URL Length=%u",strlen(initiator_info.initiator_url)); + + ret = drm_process_request(request_type, (void*)&initiator_info, + (void*)&ws_resp_data); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Server Error Code = %d", + ws_resp_data.result_code); + tet_printf("Content URL = %s", + ws_resp_data.content_url); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_16(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL; + tet_printf ("Testing:DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL"); + + drm_initiator_info_s initiator_info; + drm_web_server_resp_data_s ws_resp_data; + + memset(&initiator_info,0x0,sizeof(drm_initiator_info_s)); + memset(&ws_resp_data,0x0,sizeof(drm_web_server_resp_data_s)); + + snprintf(initiator_info.initiator_url,DRM_MAX_LEN_INITIATOR_URL, "%s", + JOIN_DOMAIN_INITIATOR_VALID_PR_FILE_1); + + tet_printf ("Source Initiator URL=%s",JOIN_DOMAIN_INITIATOR_VALID_PR_FILE_1); + tet_printf ("Destination Initiator URL=%s",initiator_info.initiator_url); + + initiator_info.initiator_url_len = strlen(initiator_info.initiator_url); + initiator_info.operation_callback.callback = NULL; + + tet_printf ("Source Initiator URL Length=%u",strlen(JOIN_DOMAIN_INITIATOR_VALID_PR_FILE_1)); + tet_printf ("Destination Initiator URL Length=%u",strlen(initiator_info.initiator_url)); + + ret = drm_process_request(request_type, (void*)&initiator_info, + (void*)&ws_resp_data); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Server Error Code = %d", + ws_resp_data.result_code); + tet_printf("Content URL = %s", + ws_resp_data.content_url); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_17(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL; + tet_printf ("Testing:DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL"); + + drm_initiator_info_s initiator_info; + drm_web_server_resp_data_s ws_resp_data; + + memset(&initiator_info,0x0,sizeof(drm_initiator_info_s)); + memset(&ws_resp_data,0x0,sizeof(drm_web_server_resp_data_s)); + + snprintf(initiator_info.initiator_url,DRM_MAX_LEN_INITIATOR_URL, "%s", + LEAVE_DOMAIN_INITIATOR_VALID_PR_FILE_1); + + tet_printf ("Source Initiator URL=%s",LEAVE_DOMAIN_INITIATOR_VALID_PR_FILE_1); + tet_printf ("Destination Initiator URL=%s",initiator_info.initiator_url); + + initiator_info.initiator_url_len = strlen(initiator_info.initiator_url); + initiator_info.operation_callback.callback = NULL; + + tet_printf ("Source Initiator URL Length=%u",strlen(LEAVE_DOMAIN_INITIATOR_VALID_PR_FILE_1)); + tet_printf ("Destination Initiator URL Length=%u",strlen(initiator_info.initiator_url)); + + ret = drm_process_request(request_type, (void*)&initiator_info, + (void*)&ws_resp_data); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Server Error Code = %d", + ws_resp_data.result_code); + tet_printf("Content URL = %s", + ws_resp_data.content_url); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_18(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL; + tet_printf ("Testing:DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL"); + + drm_initiator_info_s initiator_info; + drm_web_server_resp_data_s ws_resp_data; + + memset(&initiator_info,0x0,sizeof(drm_initiator_info_s)); + memset(&ws_resp_data,0x0,sizeof(drm_web_server_resp_data_s)); + + snprintf(initiator_info.initiator_url,DRM_MAX_LEN_INITIATOR_URL, "%s", + METERING_INITIATOR_VALID_PR_FILE_1); + + tet_printf ("Source Initiator URL=%s",METERING_INITIATOR_VALID_PR_FILE_1); + tet_printf ("Destination Initiator URL=%s",initiator_info.initiator_url); + + initiator_info.initiator_url_len = strlen(initiator_info.initiator_url); + initiator_info.operation_callback.callback = NULL; + + tet_printf ("Source Initiator URL Length=%u",strlen(METERING_INITIATOR_VALID_PR_FILE_1)); + tet_printf ("Destination Initiator URL Length=%u",strlen(initiator_info.initiator_url)); + + ret = drm_process_request(request_type, (void*)&initiator_info, + (void*)&ws_resp_data); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Server Error Code = %d", + ws_resp_data.result_code); + tet_printf("Content URL = %s", + ws_resp_data.content_url); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_19(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL; + tet_printf ("Testing:DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL"); + + drm_initiator_info_s initiator_info; + drm_web_server_resp_data_s ws_resp_data; + + memset(&initiator_info,0x0,sizeof(drm_initiator_info_s)); + memset(&ws_resp_data,0x0,sizeof(drm_web_server_resp_data_s)); + + snprintf(initiator_info.initiator_url,DRM_MAX_LEN_INITIATOR_URL, "%s", + INVALID_LICENSE_INITIATOR_PR_FILE_1); + + tet_printf ("Source Initiator URL=%s",INVALID_LICENSE_INITIATOR_PR_FILE_1); + tet_printf ("Destination Initiator URL=%s",initiator_info.initiator_url); + + initiator_info.initiator_url_len = strlen(initiator_info.initiator_url); + initiator_info.operation_callback.callback = NULL; + + tet_printf ("Source Initiator URL Length=%u",strlen(INVALID_LICENSE_INITIATOR_PR_FILE_1)); + tet_printf ("Destination Initiator URL Length=%u",strlen(initiator_info.initiator_url)); + + ret = drm_process_request(request_type, (void*)&initiator_info, + (void*)&ws_resp_data); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Server Error Code = %d", + ws_resp_data.result_code); + tet_printf("Content URL = %s", + ws_resp_data.content_url); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_20(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL; + tet_printf ("Testing:DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("Success:ret = 0x%x", ret); + tet_result(TET_FAIL); + } else { + tet_printf("Invalid input-output:ret = 0x%x", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_21(void) +{ + int ret = DRM_RETURN_SUCCESS; + tet_printf("Testing:DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES"); + + /* + * Disabled this test-case because all contents will be unregistered + * Thus it will interfer with other TCs + */ +#if 0 + drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES; + ret = drm_process_request(request_type, NULL,NULL); +#endif + + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_22(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_INSERT_EXT_MEMORY; + tet_printf("Testing:DRM_REQUEST_TYPE_INSERT_EXT_MEMORY"); + + ret = drm_process_request(request_type, NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_23(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY; + tet_printf("Testing:DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY"); + + ret = drm_process_request(request_type, NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_24(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE; + tet_printf("Testing:DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE"); + + drm_submit_roap_message_info_s message_info; + memset(&message_info,0x0,sizeof(drm_submit_roap_message_info_s)); + + ret = drm_process_request(request_type,(void *)&message_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_25(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE; + tet_printf("Testing:DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_26(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT; + tet_printf("Testing:DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT"); + + drm_submit_roap_user_consent_info_s user_consent_info; + memset(&user_consent_info,0x0,sizeof(drm_submit_roap_user_consent_info_s)); + + ret = drm_process_request(request_type,(void *)&user_consent_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_27(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT; + tet_printf("Testing:DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_28(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_HTTP_USER_CANCEL; + tet_printf("Testing:DRM_REQUEST_TYPE_HTTP_USER_CANCEL"); + + drm_http_user_cancel_info_s user_cancel_info; + memset(&user_cancel_info,0x0,sizeof(drm_http_user_cancel_info_s)); + + ret = drm_process_request(request_type,(void *)&user_cancel_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + /** + * As this TC depends on network connectivity, + * Thus making it TET_PASS + */ + tet_result(TET_PASS); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_29(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_HTTP_USER_CANCEL; + tet_printf("Testing:DRM_REQUEST_TYPE_HTTP_USER_CANCEL"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_30(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_COPY_FILE; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_COPY_FILE"); + + drm_register_copy_file_info_s copy_file_info; + memset(©_file_info,0x0,sizeof(drm_register_copy_file_info_s)); + + snprintf(copy_file_info.src_file_path,256, "%s",FILE_PATH_VALID_FILE_OMA_1); + snprintf(copy_file_info.dest_file_path,256, "%s",FILE_PATH_VALID_FILE_OMA_11); + tet_printf("Src file=%s",copy_file_info.src_file_path); + tet_printf("Dst file=%s",copy_file_info.dest_file_path); + + ret = drm_process_request(request_type,(void *)©_file_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_31(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_COPY_FILE; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_COPY_FILE"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_32(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_MOVE_FILE; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_MOVE_FILE"); + + drm_register_copy_file_info_s copy_file_info; + memset(©_file_info,0x0,sizeof(drm_register_copy_file_info_s)); + + snprintf(copy_file_info.src_file_path,256, "%s",FILE_PATH_VALID_FILE_OMA_1); + snprintf(copy_file_info.dest_file_path,256, "%s",FILE_PATH_VALID_FILE_OMA_11); + tet_printf("Src file=%s",copy_file_info.src_file_path); + tet_printf("Dst file=%s",copy_file_info.dest_file_path); + + ret = drm_process_request(request_type,(void *)©_file_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_33(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_MOVE_FILE; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_MOVE_FILE"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_34(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_INSERT_EXT_MEMORY; + tet_printf("Testing:DRM_REQUEST_TYPE_INSERT_EXT_MEMORY"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_35(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY; + tet_printf("Testing:DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_36(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_SETAS; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_SETAS"); + + drm_register_setas_info_s setas_info; + memset(&setas_info,0x0,sizeof(drm_register_setas_info_s)); + + drm_register_setas_resp_data_s resp_info; + memset(&resp_info, 0x0, sizeof(drm_register_setas_resp_data_s)); + + snprintf(setas_info.file_path,256, "%s",FILE_PATH_VALID_FILE_OMA_12); + tet_printf("file_path=%s",setas_info.file_path); + + setas_info.setas_cat = DRM_SETAS_WALLPAPER; + + ret = drm_process_request(request_type, (void *) &setas_info, (void *) &resp_info); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_37(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_SETAS; + tet_printf("Testing:DRM_REQUEST_TYPE_REGISTER_SETAS"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_PASS); + } +} + +/** + * @brief Positive test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_38(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_SETAS; + tet_printf("Testing:DRM_REQUEST_TYPE_UNREGISTER_SETAS"); + + drm_unregister_setas_info_s setas_info; + memset(&setas_info,0x0,sizeof(drm_unregister_setas_info_s)); + + snprintf(setas_info.file_path,256, "%s",FILE_PATH_VALID_FILE_OMA_12); + tet_printf("file_path=%s",setas_info.file_path); + + setas_info.setas_cat = DRM_SETAS_WALLPAPER; + + ret = drm_process_request(request_type,(void *)&setas_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_PASS); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_FAIL); + } +} + +/** + * @brief Negative test case of drm_process_request() + */ +static void utc_drmclient_drm_process_request_func_39(void) +{ + int ret = DRM_RETURN_INTERNAL_ERROR; + drm_request_type_e request_type = DRM_REQUEST_TYPE_UNREGISTER_SETAS; + tet_printf("Testing:DRM_REQUEST_TYPE_UNREGISTER_SETAS"); + + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + tet_printf("ret = 0x%x SUCCESS", ret); + tet_result(TET_FAIL); + } else { + tet_printf("ret = 0x%x FAILED", ret); + tet_result(TET_PASS); + } +} diff --git a/drm-client.pc.in b/drm-client.pc.in new file mode 100755 index 0000000..d0143dd --- /dev/null +++ b/drm-client.pc.in @@ -0,0 +1,6 @@ +Name: drm-client +Description: DRM client Package +Version: @VERSION@ +Requires: dlog capi-base-common glib-2.0 +Libs: -L@LIBDIR@ -ldrm-client +Cflags: -I@INCLUDEDIR@/drm-client diff --git a/include/drm_client.h b/include/drm_client.h new file mode 100755 index 0000000..d2d4003 --- /dev/null +++ b/include/drm_client.h @@ -0,0 +1,319 @@ +/* + * drm-client + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * 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 drm_client.h + * @brief DRM Client API declaration header file. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @author Harsha Shekar (h.shekar@samsung.com) + * @version 0.1 + * @history 0.1: DRM Client API Declarations + */ + +#ifndef __DRM_CLIENT_H__ +#define __DRM_CLIENT_H__ + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus */ + +#include "drm_client_types.h" + +/** + * @defgroup DRMCLIENT drm-client + * @{ + */ + +/** + * @} + */ + +/** + * @addtogroup DRMCLIENT + * @{ + */ + +/** + * An application can check that a file is DRM file + * (OMA DRM, PlayReady, DivX etc.) + * + * @param[in] file_path Specifies the pointer points a DRM file path. + * @param[out] is_drm_file DRM_TRUE if the input file is a DRM file + * else DRM_FALSE. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * + * @remarks + * @see + * @since 0.1 + */ +int drm_is_drm_file(const char *file_path, drm_bool_type_e *is_drm_file); + +/** + * An application can get DRM file type of the file that is + * specified in file_path + * + * @param[in] file_path Specifies the pointer points a DRM file path. + * @param[out] file_type DRM file type. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @remarks + * @see + * @since 0.1 + */ +int drm_get_file_type(const char *file_path, drm_file_type_e *file_type); + +/** + * An application can check that a DRM file has valid license or not. + * + * @param[in] file_path DRM file path. + * @param[in] perm_type Enumeration type of permission. + * @param[out] license_status license status. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +int drm_get_license_status(const char *file_path, + drm_permission_type_e perm_type, + drm_license_status_e *license_status); + +/** + * An application can get DRM Content information for the file + * specified in file_path. + * + * @param[in] file_path DRM file path. + * @param[out] content_info Content information. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +int drm_get_content_info(const char *file_path, + drm_content_info_s *content_info); + +/** + * An application can get file information of a DRM file. + * + * @param[in] file_path DRM file path. + * @param[out] fileInfo DRM file info. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +int drm_get_file_info(const char *file_path, drm_file_info_s *file_info); + +/** + * An application can get constraints associated with + * given permission & given file + * + * @param[in] file_path DRM file path. + * @param[in] perm_type Enumeration type of permission. + * @param[out] constraint_info Constraint info. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +int drm_get_constraint_info(const char *file_path, + drm_permission_type_e perm_type, + drm_constraint_info_s *constraint_info); + +/** + * An application can check the feasibility of actions to be + * performed based on the type of DRM file. + * + * @param[in] action Action to be taken. + * @param[in] action_data Data needed to check action + * allowed operation + * @param[out] is_allowed DRM_TRUE if action is allowed + * else DRM_FALSE + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +int drm_is_action_allowed(drm_action_type_e action, + drm_action_allowed_data_s *action_data, + drm_bool_type_e *is_allowed); + + +/** + * An application can get the requested data from DRM. + * + * @param[in] data_type Data types as per enum drm_data_type_e. + * @param[in] input Pointer to appropriate structure as per data_type. + * @param[out] output Output data. Pointer to appropriate structure as + * per data_type. + * + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks Please typecast to appropriate data structures + * as per data types. + * + * if data_type = DRM_DATA_TYPE_SECURE_CLOCK + * then input type: input = NULL + * and output type: output = pointer to struct + * drm_secure_clock_data_s + * + * if data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG + * then input type: input = NULL + * and output type: output = pointer to int + * + * if data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_ID + * then input type: input = pointer to file path (const char) + * and output type: output = pointer to struct + * drm_transaction_id_info_s + * + * if data_type = DRM_DATA_TYPE_DIVX_REGISTRATION_CODE + * then input type: input = NULL + * and output type: output = pointer to struct drm_code_info_s + * + * if data_type = DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE + * then input type: input = NULL + * and output type: output = pointer to struct drm_code_info_s + * + * @see + * @since 0.1 + */ +int drm_get_data(drm_data_type_e data_type, void *input, void *output); + +/** + * An application can do particular request to DRM. + * + * @param[in] request_type Request types as per enum drm_request_type_e. + * @param[in] input Pointer to appropriate structure as per + * request_type. + * @param[out] output Output data. Pointer to appropriate structure as + * per request_type. + * + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks Please typecast to appropriate data structures + * as per data types. + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_FILE + * then input type: input = pointer to const char (file_path) + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_UNREGISTER_FILE + * then input type: input = pointer to struct drm_unregister_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES + * then input type: input = NULL + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE + * then input type: input = pointer to + * struct drm_register_lic_info_s. + * and output type: output = pointer to + * struct drm_register_lic_resp_s. + * + * if request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL + * then input type: input = pointer to struct drm_initiator_info_s + * and output type: output = pointer to struct drm_web_server_resp_data_s + * + * if request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE + * then input type: input = pointer to struct drm_submit_roap_message_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT + * then input type: input = pointer to struct drm_submit_roap_user_consent_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_HTTP_USER_CANCEL + * then input type: input = pointer to struct drm_http_user_cancel_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_COPY_FILE + * then input type: input = pointer to struct drm_register_copy_file_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_MOVE_FILE + * then input type: input = pointer to struct drm_register_copy_file_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_INSERT_EXT_MEMORY + * then input type: input = NULL + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY + * then input type: input = NULL + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_SETAS + * then input type: input = pointer to struct drm_register_setas_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_UNREGISTER_SETAS + * then input type: input = pointer to struct drm_unregister_setas_info_s + * and output type: output = NULL + * + * @see + * @since 0.1 + */ +int drm_process_request(drm_request_type_e request_type, + void *input, void *output); + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /*__DRM_CLIENT_H__ */ diff --git a/include/drm_client_ipc.h b/include/drm_client_ipc.h new file mode 100755 index 0000000..46cc60d --- /dev/null +++ b/include/drm_client_ipc.h @@ -0,0 +1,264 @@ +/* + * drm-client + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 drm_client_ipc.h + * @brief DRM Client Inter process communication declarations. + * @author Harsha Shekar (h.shekar@samsung.com) + * @version 0.1 + * @history 0.1: DRM Client Inter process communication declarations. + */ + +#ifndef __DRM_CLIENT_IPC_H__ +#define __DRM_CLIENT_IPC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus */ + +#include "drm_client_types.h" + +/* + * DRM Socket Path + */ +#define DRM_SOCK_PATH "/tmp/DrmSocket" + +/* + * Maximum Size of Cookie + */ +#define DRM_MAX_LEN_COOKIE (20) + +/** +* Maximum Request Data length +*/ +#define DRM_MAX_REQUEST_DATA_LENGTH (4096) + +/** +* Maximum Response Data length +*/ +#define DRM_MAX_RESPONSE_DATA_LENGTH (4096) + +/** +* Maximum number of Data Items +*/ +#define DRM_MAX_DATA_ITEMS_NUM (5) + +/** +* Maximum Read/Write Chunk Size +*/ +#define DRM_MAX_CHUNK_SIZE (10 * 1024) + +/** +* Maximum concurrent clients supported +*/ +#define DRM_MAX_CLIENT_SUPPORTED 10 + +/** +* Maximum callback data size +*/ +#define DRM_MAX_CB_DATA_SIZE 256 + + + +/** + * @enum drm_request_api_e + * @brief DRM API names. + */ +typedef enum { + DRM_API_NONE, /**< For initialization purpose */ + DRM_IS_DRM_FILE, /**< Is DRM file */ + DRM_GET_FILE_TYPE, /**< Get DRM file type */ + DRM_GET_LICENSE_STATUS, /**< Get License Status */ + DRM_GET_CONTENT_INFO, /**< Get Content Information */ + DRM_GET_FILE_INFO, /**< Get DRM file Information */ + DRM_GET_CONSTRAINT_INFO, /**< Get Constraint Information */ + DRM_IS_ACTION_ALLOWED, /**< Is Action allowed */ + DRM_GET_DATA, /**< Get Data */ + DRM_PROCESS_REQUEST, /**< Process Request */ + DRM_API_MAX /**< Max enum value */ +} drm_request_api_e; + +/** + * @struct drm_client_cb_data_s + * @brief DRM operation callback information structure + * with additional information. + */ +typedef struct +{ + /** Client Id */ + int client_id; + + /** Callback operation info */ + drm_user_operation_info_s callback_operation_info; + + /** Callback user data */ + char call_bk_data[DRM_MAX_CB_DATA_SIZE]; +} drm_client_cb_data_s; + +/** + * @struct drm_client_cb_info_s + * @brief Client Callback info. + * @remark Stores details about Registered client callbacks + */ +typedef struct { + + /** Client Id */ + int client_id; + + /** Callback */ + drm_operation_cb_s operation_callback; +} drm_client_cb_info_s; + +/** + * @struct drm_client_info_s + * @brief Client Information structure. + * @remark It can be used to track drm clients. + */ +typedef struct { + + /** Client Id */ + int client_id; + + /** Process Id */ + int p_id; + + /** Thread Id */ + int thread_id; + + /** Sync Socket */ + int sync_sock_fd; + + /** Async Socket */ + int async_sock_fd; +} drm_client_info_s; + +/** + * @struct drm_req_fixed_data_s + * @brief DRM input parameter(request) fixed data structure. + */ +typedef struct { + + /* Client Request Type */ + drm_request_api_e api_name; + + /* Permission type */ + drm_permission_type_e permission_type; + + /* Action type */ + drm_action_type_e action; + + /* Request Data Type */ + drm_data_type_e data_type; + + /* Process Request Type */ + drm_request_type_e request_type; + + /* Client specific Information */ + drm_client_info_s client_info; + + /** No of data items(Pointers) */ + unsigned int num_data_items; + + /** Length of each data item */ + unsigned int data_length[DRM_MAX_DATA_ITEMS_NUM]; + + /* Request Data */ + char request_data[DRM_MAX_REQUEST_DATA_LENGTH]; + +}drm_req_fixed_data_s; + +/** + * @struct drm_request_data_s + * @brief DRM input parameter(request) structure. + */ +typedef struct { + + /** Fixed Data */ + drm_req_fixed_data_s fixed_data; + + /** Array of individual data items */ + char *data_items[DRM_MAX_DATA_ITEMS_NUM]; + +} drm_request_data_s; + +/** + * @struct drm_resp_fixed_data_s + * @brief DRM output parameter(response) fixed data structure. + */ +typedef struct { + + /* Response Result */ + drm_result_e resp_result; + + /* Bool value */ + drm_bool_type_e bool_val; + + /* file type */ + drm_file_type_e file_type; + + /* License Status */ + drm_license_status_e lic_status; + + /** No of data items(Pointers) */ + unsigned int num_data_items; + + /** Length of each data item */ + unsigned int data_length[DRM_MAX_DATA_ITEMS_NUM]; + + /* Response Data */ + char response_data[DRM_MAX_RESPONSE_DATA_LENGTH]; + +} drm_resp_fixed_data_s; + +/** + * @struct drm_response_data_s + * @brief DRM output parameter(response) structure. + */ +typedef struct { + + /** Fixed Data */ + drm_resp_fixed_data_s fixed_data; + + /** Array of individual data items */ + char *data_items[DRM_MAX_DATA_ITEMS_NUM]; + +} drm_response_data_s; + +/** + * This API is used to send a request to the Server to call corresponding API + * + * @param[in] client_in Carries the input parameters of Client API to Server + * @param[out] server_out Carries the output parameters of Client API from Server + * @return 0 on success & other values on failure + * @remarks + * @see + * @since 0.1 + */ +int drm_client_comm(drm_request_data_s *client_in, drm_response_data_s *server_out); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /*__DRM_CLIENT_IPC_H__ */ diff --git a/include/drm_client_log.h b/include/drm_client_log.h new file mode 100755 index 0000000..63f0a81 --- /dev/null +++ b/include/drm_client_log.h @@ -0,0 +1,100 @@ +/* + * drm-client + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 drm_client_log.h + * @brief DRM Client log specific file. + * @author Harsha Shekar (h.shekar@samsung.com) + * @version 0.1 + * @history 0.1: DRM LOG definitions. + */ + +#ifndef __DRM_CLIENT_LOG_H__ +#define __DRM_CLIENT_LOG_H__ + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus */ + +#include +#include +#include +#include +#include +#include + +#define drmclientgettid() (long int)syscall(__NR_gettid) +#define DRM_CLIENT_FILENAME(X) (strrchr((char *)(X), '/') ? (char *)(strrchr((char*)(X), '/') + 1) : ((char *)(X))) + +/* + * Enable this flag to use internal logging mechanism + */ +//#define __DRM_CLIENT_USE_INTERNAL_LOGGING__ + +#ifdef __DRM_CLIENT_USE_INTERNAL_LOGGING__ + +/* Use internal logging mechanism */ +extern const char *__progname; + +#define DRM_CLIENT_LOG(FMT, ARG...) do{ \ + fprintf(stderr, "\n [EXE name=%s]:[PID=%ld]:[TID=%ld]:[%s:%s:%d]:", __progname, (long int)getpid(), drmclientgettid(), DRM_CLIENT_FILENAME(__FILE__), __func__, __LINE__); \ + fprintf(stderr, FMT, ##ARG); \ + fprintf(stderr,"\n"); \ + }while(0); + +#define DRM_CLIENT_EXCEPTION(FMT, ARG...) do{ \ + fprintf(stderr, "\n [EXE name=%s]:[PID=%ld]:[TID=%ld]:[%s:%s:%d]:[DRM-ERROR-CLIENT]:", __progname, (long int)getpid(), drmclientgettid(), DRM_CLIENT_FILENAME(__FILE__), __func__, __LINE__); \ + fprintf(stderr, FMT, ##ARG); \ + fprintf(stderr,"\n"); \ + }while(0); + +#define DRM_CLIENT_FRQ_LOG DRM_CLIENT_LOG + +#else /*__DRM_CLIENT_USE_INTERNAL_LOGGING__ */ + +/* Use DLOG logging mechanism */ +#include "dlog.h" + +/* DRM Client layer debug messages*/ +#define TAG_DRM_CLIENT "DRM_CLIENT" + +/* DLOG Level +DEBUG Debug message. - always compiled into application, but not logged at run time by default on release mode. on debug mode, this message will be logged at run time. +INFO Information message - Normal operational messages. above of this priority will always be logged. +WARN Warning messages - not an error, but indication that an error will occur if action is not taken +ERROR Error message - indicate error. +*/ + +/* Client layer related logs */ +#define DRM_CLIENT_LOG(FMT, ARG...) SLOG(LOG_INFO, TAG_DRM_CLIENT, "[PID=%ld]:[TID=%ld]:[%s:%s:%d]:"FMT, (long int)getpid(), drmclientgettid(), DRM_CLIENT_FILENAME(__FILE__), __func__, __LINE__, ##ARG); +#define DRM_CLIENT_FRQ_LOG(FMT, ARG...) SLOG(LOG_DEBUG, TAG_DRM_CLIENT, "[PID=%ld]:[TID=%ld]:[%s:%s:%d]:"FMT, (long int)getpid(), drmclientgettid(), DRM_CLIENT_FILENAME(__FILE__), __func__, __LINE__, ##ARG); +#define DRM_CLIENT_EXCEPTION(FMT, ARG...) SLOG(LOG_ERROR, TAG_DRM_CLIENT, "[PID=%ld]:[TID=%ld]:[%s:%s:%d]:[DRM-ERROR-CLIENT]"FMT"\n", (long int)getpid(), drmclientgettid(), DRM_CLIENT_FILENAME(__FILE__), __func__, __LINE__, ##ARG); + +#endif /* __DRM_CLIENT_USE_INTERNAL_LOGGING__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __DRM_CLIENT_LOG_H__*/ diff --git a/include/drm_client_types.h b/include/drm_client_types.h new file mode 100755 index 0000000..40664b4 --- /dev/null +++ b/include/drm_client_types.h @@ -0,0 +1,1097 @@ +/* + * drm-client + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 drm_client_types.h + * @brief DRM Client API macros, structures & enum declaration file. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @author Harsha Shekar (h.shekar@samsung.com) + * @version 0.1 + * @history 0.1: First version of DRM Client API macros, + * structures & enum declarations. + */ + +#ifndef __DRM_CLIENT_TYPES_H__ +#define __DRM_CLIENT_TYPES_H__ + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus */ + +#include "tizen_error.h" +#include +#include + + +/******************************************************************/ + +/* + * Maximum Length of Author field + */ +#define DRM_MAX_LEN_AUTHOR (64) + +/* + * Maximum Length of Copyright field + */ +#define DRM_MAX_LEN_COPYRIGHT (64) + +/* + * Maximum Length of Description field + */ +#define DRM_MAX_LEN_DESCRIPTION (256) + +/* + * Maximum Length of Icon URI field + */ +#define DRM_MAX_LEN_ICON_URI (256) + +/* + * Maximum Length of Info URL field + */ +#define DRM_MAX_LEN_INFO_URL (256) + +/* + * Maximum Length of Content URL field + */ +#define DRM_MAX_LEN_CONTENT_URL (512) + +/* + * Maximum Length of Rights URL field + */ +#define DRM_MAX_LEN_RIGHTS_URL (256) + +/* + * Maximum Length of Title field + */ +#define DRM_MAX_LEN_TITLE (256) + +/* + * Maximum Length of MIME (Content Type) field + */ +#define DRM_MAX_LEN_MIME (64) + +/* + * Maximum Length of Content ID field + */ +#define DRM_MAX_LEN_CID (256) + +/* + * Maximum Length of Individual Identity field + */ +#define DRM_MAX_LEN_INDIVIDUAL_IDENTITY (64) + +/* + * Maximum Length of System Identity field + */ +#define DRM_MAX_LEN_SYSTEM_IDENTITY (64) + +/* + * Maximum Length of original filename for PlayReady envelope + */ +#define DRM_MAX_LEN_FILEPATH (256) + +/** +* Maximum length of Transaction ID of the DCF +*/ +#define DRM_MAX_SIZE_TRANSACTION_ID (17) + +/** +* Maximum length of DivX code (Registration / De-registration code ) +*/ +#define DRM_MAX_SIZE_DIVX_CODE (16) + +/** +* Maximum length of License Data +*/ +#define DRM_MAX_LEN_LICENSE_DATA (3000) + +/** +* Maximum length of Initiator URL +*/ +#define DRM_MAX_LEN_INITIATOR_URL (512) + +/** +* Maximum length of IP Address +*/ +#define DRM_MAX_LEN_IP_ADDR (64) + +/* + * Max length of APP ID + */ +#define DRM_MAX_LEN_APP_ID (15) + +/* + * Max length of User ID + */ +#define DRM_MAX_LEN_USER_GUID (15) + +/* + * Max length of Device ID + */ +#define DRM_MAX_LEN_DEVICE_ID (15) + +/* + * Max length of Order ID + */ +#define DRM_MAX_LEN_ORDER_ID (23) + +/* + * Max length of Service ID + */ +#define DRM_MAX_LEN_SERVICE_ID (31) + +/* + * Max length of Account ID + */ +#define DRM_MAX_LEN_ACCOUNT_ID (31) + +/****************************************************************/ + +/** + * @enum drm_result_e + * @brief DRM Return values. + */ +typedef enum { + /**< Success */ + DRM_RETURN_SUCCESS = 0, + /**< Invalid Argument */ + DRM_RETURN_INVALID_ARG = TIZEN_ERROR_INVALID_PARAMETER, + /**< Insufficient Memory */ + DRM_RETURN_INSUFFICIENT_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, + /**< Parsing Error */ + DRM_RETURN_PARSING_ERROR = TIZEN_ERROR_DRM_CLASS | 0x01, + /**< DB Error */ + DRM_RETURN_DB_ERROR = TIZEN_ERROR_DRM_CLASS | 0x02, + /**< File Error */ + DRM_RETURN_FILE_ERROR = TIZEN_ERROR_DRM_CLASS | 0x03, + /**< Communication Error */ + DRM_RETURN_COMMUNICATION_ERROR = TIZEN_ERROR_DRM_CLASS | 0x04, + /**< OPL Error */ + DRM_RETURN_OPL_ERROR = TIZEN_ERROR_DRM_CLASS | 0x05, + /**< Internal Error */ + DRM_RETURN_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN +} drm_result_e; + +/** + * @enum drm_bool_type_e + * @brief DRM Bool values. + */ +typedef enum { + DRM_FALSE = 0, /**< false */ + DRM_TRUE = 1, /**< true */ + DRM_UNKNOWN = 0xFFFFFFFF /**< error */ +} drm_bool_type_e; + +/** + * @enum drm_file_type_e + * @brief DRM file types. + */ +typedef enum { + DRM_TYPE_UNDEFINED, /**< For initialization purpose */ + DRM_TYPE_OMA_V1, /**< OMA DRM v1 file */ + DRM_TYPE_OMA_V2, /**< OMA DRM v2 file */ + DRM_TYPE_PLAYREADY, /**< PlayReady file */ + DRM_TYPE_PLAYREADY_ENVELOPE, /**< PlayReady Envelope file */ + DRM_TYPE_DIVX, /**< DivX file */ + DRM_TYPE_OMA_PD, /**< Progressive Download file */ + DRM_TYPE_PIFF, /**< PIFF file */ + DRM_TYPE_SAPPS /**< Samsung Apps */ +} drm_file_type_e; + +/** + * @enum drm_permission_type_e + * @brief DRM Permission types. + */ +typedef enum { + DRM_PERMISSION_TYPE_NONE, /**< For initialization purpose */ + DRM_PERMISSION_TYPE_ANY, /**< Any permission */ + DRM_PERMISSION_TYPE_PLAY, /**< Play Permission */ + DRM_PERMISSION_TYPE_COLLABORATIVE_PLAY, /**< Collaborative Play + (e.g gaming application) */ + + DRM_PERMISSION_TYPE_DISPLAY, /**< Display Permission */ + DRM_PERMISSION_TYPE_EXECUTE, /**< Execute Permission */ + DRM_PERMISSION_TYPE_PRINT, /**< Print Permission */ + DRM_PERMISSION_TYPE_EXPORT_COPY, /**< Export-copy permission */ + DRM_PERMISSION_TYPE_EXPORT_MOVE /**< Export-move permission */ +} drm_permission_type_e; + +/** + * @enum drm_license_status_e + * @brief DRM License status. + */ +typedef enum { + DRM_LICENSE_STATUS_UNDEFINED, /**< For initialization purpose */ + DRM_LICENSE_STATUS_VALID, /**< Valid License */ + DRM_LICENSE_STATUS_FUTURE_USE, /**< License for future use */ + DRM_LICENSE_STATUS_EXPIRED, /**< Expired License */ + DRM_LICENSE_STATUS_NO_LICENSE, /**< No License */ +} drm_license_status_e; + +/** + * @enum drm_action_type_e + * @brief DRM Action types. + */ +typedef enum { + DRM_ACTION_UNDEFINED, /**< for initialization purpose */ + DRM_IS_FORWARDING_ALLOWED, /**< if a file can be forwarded */ + DRM_HAS_VALID_SETAS_STATUS, /**< if a file can be SETAS */ + DRM_IS_DEVICE_ACTIVATED, /**< if a device is DIVX activated */ + DRM_IS_VALID_SECURE_CLOCK /**< if Secure Clock is set */ +} drm_action_type_e; + +/** + * @enum drm_method_type_e + * @brief DRM method types. + */ +typedef enum { + DRM_METHOD_TYPE_UNDEFINED, /**< For initialization purpose */ + DRM_METHOD_TYPE_FORWARD_LOCK, /**< OMA DRM forward lock */ + DRM_METHOD_TYPE_COMBINED_DELIVERY, /**< OMA DRM Combined Delivery */ + DRM_METHOD_TYPE_SEPARATE_DELIVERY /**< OMA DRM Separate Delivery + & OMA DRM v2 */ +}drm_method_type_e; + +/** + * @enum drm_rights_version_e + * @brief DRM Rights Version. + */ +typedef enum { + DRM_OMA_DRMV1_RIGHTS, /**< OMA DRM v1 */ + DRM_OMA_DRMV2_RIGHTS, /**< OMA DRM v2 */ + DRM_UNDEFINED_RIGHTS = 3 /**< dummy */ +} drm_rights_version_e; + +/** + * @enum drm_constraint_identity_type_e + * @brief DRM Constraint Identity type. + */ +typedef enum { + DRM_CONSTRAINT_IDENTITY_TYPE_NONE, /**< For initialization */ + DRM_CONSTRAINT_IDENTITY_TYPE_IMEI, /**< IMEI */ + DRM_CONSTRAINT_IDENTITY_TYPE_IMSI, /**< IMSI */ + DRM_CONSTRAINT_IDENTITY_TYPE_MSISDN, /**< MS-ISDN */ + DRM_CONSTRAINT_IDENTITY_TYPE_WIM /**< WIM + (Wireless/WAP Identity Module ) */ +} drm_constraint_identity_type_e; + +/** + * @enum drm_setas_category_e + * @brief DRM SETAS type. + */ +typedef enum { + DRM_SETAS_NONE = -1, /**< No set as operation */ + DRM_SETAS_WALLPAPER = 0, /**< Set As Wallpaper */ + DRM_SETAS_RINGTONE = 2, /**< Set As Ringtone */ +} drm_setas_category_e; + +/** + * @enum drm_data_type_e + * @brief DRM Requested Data types. + */ +typedef enum { + /* For initialization purpose */ + DRM_DATA_TYPE_NONE = -1, + + /* Secure Clock Information */ + DRM_DATA_TYPE_SECURE_CLOCK = 0, + + /* Transaction Tracking flag status information */ + DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG, + + /* Transaction Tracking ID information */ + DRM_DATA_TYPE_TRANSACTION_TRACKING_ID, + + /* DivX Registration Code information */ + DRM_DATA_TYPE_DIVX_REGISTRATION_CODE, + + /* DivX De-registration Code information */ + DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE, +} drm_data_type_e; + +/** + * @enum drm_request_type_e + * @brief DRM Request types. + */ +typedef enum { + /* For initialization purpose */ + DRM_REQUEST_TYPE_NONE = -1, + + /* Request to Register DRM file in DB */ + DRM_REQUEST_TYPE_REGISTER_FILE = 0, + + /* Request to Un-register DRM file from DB */ + DRM_REQUEST_TYPE_UNREGISTER_FILE, + + /* Request to Un-register All DRM files from DB */ + DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES, + + /* Request to Register / install License into DB */ + DRM_REQUEST_TYPE_REGISTER_LICENSE, + + /* Request to start Initiator processing for PlayReady */ + DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL, + + /* Submit Roap Message */ + DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE, + + /* Submit Roap User Consent */ + DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT, + + /* HTTP User Cancel */ + DRM_REQUEST_TYPE_HTTP_USER_CANCEL, + + /* Register Copy File */ + DRM_REQUEST_TYPE_REGISTER_COPY_FILE, + + /* Register Move File */ + DRM_REQUEST_TYPE_REGISTER_MOVE_FILE, + + /* Insert External Memory */ + DRM_REQUEST_TYPE_INSERT_EXT_MEMORY, + + /* Extract External Memory */ + DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY, + + /* Register SetAs */ + DRM_REQUEST_TYPE_REGISTER_SETAS, + + /* Unregister SetAs */ + DRM_REQUEST_TYPE_UNREGISTER_SETAS + +} drm_request_type_e; + +/** + * @enum drm_roap_init_src_e + * @brief DRM ROAP initialization source. + */ +typedef enum{ + /**< dummy */ + DRM_ROAP_INIT_FROM_UNKNOWN, + + /**< roap is initialized from browser*/ + DRM_ROAP_INIT_FROM_BROWSER, + + /**< roap is initialized from DRM content */ + DRM_ROAP_INIT_FROM_CONTENT, + + /**< roap is initialized from WAPPUSH */ + DRM_ROAP_INIT_FROM_WAPPUSH +} drm_roap_init_src_e; + +/** + * @enum drm_operation_type_e + * @brief DRM operation type. + */ +typedef enum { + /* License Acquisition Operation */ + DRM_OPERATION_TYPE_LICENSE_ACQ, + + /* Join Domain Operation */ + DRM_OPERATION_TYPE_JOIN_DOMAIN, + + /* Leave Domain Operation */ + DRM_OPERATION_TYPE_LEAVE_DOMAIN, + + /* Metering Operation */ + DRM_OPERATION_TYPE_METERING_INFO, + + /* Unknown Operation type */ + DRM_OPERATION_TYPE_UNKNOWN +} drm_operation_type_e; + +/** + * @enum drm_operation_status_e + * @brief DRM operation status. + */ +typedef enum { + /** DRM operation is started */ + DRM_OPERATION_STATUS_STARTED, + + /** DRM operation is in Progress */ + DRM_OPERATION_STATUS_INPROGRESS, + + /** DRM operation is Completed */ + DRM_OPERATION_STATUS_COMPLETED, + + /** During DRM operation, additional operation is to be performed */ + DRM_OPERATION_STATUS_ADDITIONAL_INFO, + /*Operation is canceled*/ + DRM_OPERATION_STATUS_CANCELED, + /** An error occurred with respect to DRM operation */ + DRM_OPERATION_STATUS_ERROR +} drm_operation_status_e; + +/** + * @enum drm_web_server_result_code_e + * @brief DRM Return values. + */ +typedef enum { + /** No server Error */ + DRM_RESULT_CODE_NONE, + + /** Device Certificate is revoked. + * User shall be informed that their device needs to be updated. + */ + DRM_RESULT_CODE_DEVCERT_REVOKED, + + /** Indicates a server problem.Device shall silently retry 3 times. + * If failure persists, user shall be informed about a server failure + * and to try again later + */ + DRM_RESULT_CODE_INTERNAL_ERROR, + + /** Means an invalid protocol message. + * This shall never happen unless there's been a "man in the middle" + * attack. Device shall perform a retry. + */ + DRM_RESULT_CODE_INVALID_MESSAGE, + + /** Means that the device limit has been reached for this domain and + * therefore the device cannot join this Domain. + * The application on the device shall provide the appropriate + * response to the end user. + */ + DRM_RESULT_CODE_DEVICE_LIMIT_REACHED, + + /** Indicates that the device shall join a Domain and then + * retry license acquisition. + */ + DRM_RESULT_CODE_DOMAIN_REQUIRED, + + /** Indicates that the device shall renew the Domain Certificate + * for this Domain. The device shall join Domain and then retry + * license acquisition. + */ + DRM_RESULT_CODE_RENEW_DOMAIN, + + /** Device shall leave Domain */ + DRM_RESULT_CODE_NOT_A_MEMBER, + + /** Means that device is not using correct protocol, most likely + * because server has been updated since device was manufactured. + * The device shall notify user to check for updates or fail gracefully. + */ + DRM_RESULT_CODE_PROTOCOL_VERSION_MISMATCH, + + /** User shall always be authenticated before making license acquisitions. + * If this error happens, device shall notify user to contact + * customer service. + */ + DRM_RESULT_CODE_UNKNOWN_ACCOUNTID, + + /** Device shall follow redirect. */ + DRM_RESULT_CODE_PROTOCOL_REDIRECT, + + /** Service specific Server errors */ + DRM_RESULT_CODE_SERVICE_SPECIFIC, +} drm_web_server_result_code_e; + +/** + * @enum drm_initiator_type + * @brief DRM Initiator type + */ +typedef enum { + DRM_INITIATOR_TYPE_NONE = -1, + DRM_INITIATOR_TYPE_INITIATOR_URL, + DRM_INITIATOR_TYPE_LICENSE_ACQ, + DRM_INITIATOR_TYPE_JOIN_DOMAIN, + DRM_INITIATOR_TYPE_LEAVE_DOMAIN, + DRM_INITIATOR_TYPE_METERING_INFO +} drm_initiator_type; + +/** + * @enum drm_const_type_e + * @brief DRM constraint types + */ +typedef enum { + DRM_CONSTRAINT_TYPE_RENTAL = 0, + DRM_CONSTRAINT_TYPE_RENTAL_UNLIMITED, + DRM_CONSTRAINT_TYPE_PURCHASE, + DRM_CONSTRAINT_TYPE_BASE, + DRM_CONSTRAINT_TYPE_EXPIRED, + DRM_CONSTRAINT_TYPE_NOT_AUTHORIZED, + DRM_CONSTRAINT_TYPE_INVALID_DRM_VERSION, + DRM_CONSTRAINT_TYPE_UNKNOWN_TYPE, + DRM_CONSTRAINT_TYPE_GENERAL_ERROR +} drm_const_type_e; + +/** + * @struct drm_content_info_s + * @brief DRM content info structure. + */ +typedef struct { + /**< Author of original content */ + char author[DRM_MAX_LEN_AUTHOR]; + + /**< Copyright information */ + char copyright[DRM_MAX_LEN_COPYRIGHT]; + + /**< Content information */ + char description[DRM_MAX_LEN_DESCRIPTION]; + + char icon_uri[DRM_MAX_LEN_ICON_URI]; /**< Icon URI */ + char info_url[DRM_MAX_LEN_INFO_URL]; /**< Information URL */ + char content_url[DRM_MAX_LEN_CONTENT_URL]; /**< Content URL */ + char rights_url[DRM_MAX_LEN_RIGHTS_URL]; /**< Rights URL */ + char title[DRM_MAX_LEN_TITLE]; /**< Content Title */ + + /**< Original MIME type */ + char mime_type[DRM_MAX_LEN_MIME]; + char content_id[DRM_MAX_LEN_CID]; /**< Content ID */ + +} drm_content_info_s; + +/** + * @struct drm_file_oma_info_s + * @brief DRM (OMA)file info structure. + */ +typedef struct { + drm_rights_version_e version; /**< OMA DRM Rights Version */ + drm_method_type_e method; /**< OMA DRM Method type */ +}drm_file_oma_info_s; + +/** + * @struct drm_file_pr_env_info_s + * @brief DRM (PlayReady Envelope)file info structure. + */ +typedef struct { + /**< Original content file name inside Playready - Envelope Contents */ + char org_file_name[DRM_MAX_LEN_FILEPATH]; + + /**< Original content file size inside Playready - Envelope Contents */ + unsigned int org_file_size; +}drm_file_pr_env_info_s; + +/** + * @struct drm_file_sapps_info_s + * @brief DRM (SAPPS)file info structure. + */ +typedef struct { + char content_id[DRM_MAX_LEN_CID]; /**< Content ID */ + char rights_url[DRM_MAX_LEN_RIGHTS_URL]; /**< Rights URL */ +} drm_file_sapps_info_s; + +/** + * @struct drm_file_info_s + * @brief DRM file info structure. + */ +typedef struct { + drm_file_oma_info_s oma_info; /**< OMA DRM file info */ + drm_file_pr_env_info_s pr_env_info; /**< PlayReady + Envelope file info */ + drm_file_sapps_info_s sapps_info; /**< SAPPS file info */ +} drm_file_info_s; + +/** + * @struct drm_constraint_type_s + * @brief DRM Constraint type structure. + */ +typedef struct { + int is_unlimited; /**< Unlimited constraints */ + int is_count; /**< Count constraint present/not present */ + int is_datetime; /**< Datetime constraint present/not present */ + int is_interval; /**< Interval constraint present/not present */ + int is_timedcount; /**< TimedCount constraint present/not present */ + int is_accumulated; /**< Accumulated constraint present/not present */ + int is_individual; /**< Individual constraint present/not present */ + int is_system; /**< System constraint present/not present */ + drm_const_type_e constraint_type; /**< Divx constraint types */ +} drm_constraint_type_s; + +/** + * @struct drm_constraint_info_s + * @brief DRM Constraint info structure. + */ +typedef struct { + + /**< Constraint type*/ + drm_constraint_type_s const_type; + + /**< Original Count */ + int original_count; + + /**< Remaining Count */ + int remaining_count; + + /**< Start Time */ + /* + * As per definition of struct tm:- + * int tm_sec seconds [0,61] + * int tm_min minutes [0,59] + * int tm_hour hour [0,23] + * int tm_mday day of month [1,31] + * int tm_mon month of year [0,11] + * int tm_year years since 1900 + * int tm_wday day of week [0,6] (Sunday = 0) + * int tm_yday day of year [0,365] + * int tm_isdst daylight savings flag + * + */ + + /* if tm_year = 109 then it means actual year = 109 + 1900 = 2009 + * if tm_mon = 0 then it means actual month = 0 + 1 = 1 = January + * if tm_mon = 1 then it means actual month = 1 + 1 = 2 = Feb + * Other parameters doesn't need any manipulation + * if tm_mday = 5 then it means day of the month = 5 + */ + struct tm start_time; + + /**< End time */ + /* + * As per definition of struct tm:- + * int tm_sec seconds [0,61] + * int tm_min minutes [0,59] + * int tm_hour hour [0,23] + * int tm_mday day of month [1,31] + * int tm_mon month of year [0,11] + * int tm_year years since 1900 + * int tm_wday day of week [0,6] (Sunday = 0) + * int tm_yday day of year [0,365] + * int tm_isdst daylight savings flag + * + */ + + /* if tm_year = 109 then it means actual year = 109 + 1900 = 2009 + * if tm_mon = 0 then it means actual month = 0 + 1 = 1 = January + * if tm_mon = 1 then it means actual month = 1 + 1 = 2 = Feb + * Other parameters doesn't need any manipulation + * if tm_mday = 5 then it means day of the month = 5 + */ + struct tm end_time; + + /**< Interval Time */ + /* + * In interval time calculation, no need to manipulate it. + * e.g if tm_year = 109 then it means actual year = 109. + * It means license constraint says that content can be consumed in 109 years. + * + * e.g:- + * tm_year = 1 + * tm_mon = 0 + * tm_mday = 0 + * tm_hour = 1 + * tm_min = 10 + * tm_sec = 40 + * + * It means content has validity for 1 year, 1 hour, 1 minute & 40 seconds. + */ + struct tm interval_time; + + /**< Timed original count */ + int timed_original_count; + + /**< Timed Remaining count */ + int timed_remaining_count; + + /**< Timer attribute of Timed-count constraint */ + int timed_count_timer; + + /**< Accumulated original time in seconds */ + int accumulated_original_seconds; + + /**< Accumulated remaining time in seconds */ + int accumulated_remaining_seconds; + + /**< individual identity type */ + drm_constraint_identity_type_e individual_identity_type; + + /**< individual identity */ + char individual_id[DRM_MAX_LEN_INDIVIDUAL_IDENTITY]; + + /**< system identity type */ + drm_constraint_identity_type_e system_identity_type; + + /**< system identity */ + char system_id[DRM_MAX_LEN_SYSTEM_IDENTITY]; +} drm_constraint_info_s; + +/** +* @struct drm_action_allowed_data_s +* @brief DRM Action Allowed structure. +*/ +typedef struct { + /**< File Path */ + char file_path[DRM_MAX_LEN_FILEPATH]; + /**< Additional input data */ + int data; +}drm_action_allowed_data_s; + +/** +* @struct drm_secure_clock_data_s +* @brief DRM secure clock data structure. +*/ +typedef struct { + /** Flag to inform whether secure clock is SET or NOT SET + * is_secure_clock_set = 0 => Secure clock NOT SET. + * is_secure_clock_set = 1 => Secure clock is SET. + */ + int is_secure_clock_set; + + /** Secure clock data */ + struct tm secure_clock; +}drm_secure_clock_data_s; + +/** + * @struct drm_transaction_id_info_s + * @brief DRM Transaction tracking ID structure. + */ +typedef struct { + /* transaction ID value*/ + char tr_id[DRM_MAX_SIZE_TRANSACTION_ID]; + + /* + * length of Transaction ID string. + * The value zero(0) indicates that transaction id is not available + */ + unsigned int tr_id_len; +}drm_transaction_id_info_s; + +/** + * @struct drm_code_info_s + * @brief DRM DivX (Registration / De-registration)Code information structure. + */ +typedef struct { + /** Code */ + char code[DRM_MAX_SIZE_DIVX_CODE]; + + /** + * length of Code. + * The value zero(0) indicates that Code is not available. + */ + unsigned int code_len; +}drm_code_info_s; + +/** + * @struct drm_unregister_info_s + * @brief DRM Unregister Information structure. + */ +typedef struct { + /** file path to be unregistered */ + char file_path[DRM_MAX_LEN_FILEPATH]; + + /* + * Flag to inform whether license also need to be removed + * remove_license = 0 => Do not remove License. + * remove_license = 1 => Remove License. + */ + int remove_license; +}drm_unregister_info_s; + +/** + * @struct drm_user_operation_info_s + * @brief DRM operation information structure. + */ +typedef struct { + /** Type of OPERATION */ + drm_operation_type_e operation_type; + + /** Status of OPERATION */ + drm_operation_status_e operation_status; +} drm_user_operation_info_s; + +/** + * Function pointer to handle DRM operation notifications + * + * @param[out] operation_info operation information . + * @param[out] output_data Output data specific to operation. + * @return None + * @see + * @since 0.1 + */ +typedef void (*drm_operation_cb)(drm_user_operation_info_s *operation_info, + void *output_data); + +/** + * @struct drm_operation_cb_s + * @brief DRM Operation callback structure. + * @remark Currently one member but new callback can be added depending on + * requirements. + */ +typedef struct { + /** Callback */ + drm_operation_cb callback; +}drm_operation_cb_s; + +/** + * @struct drm_register_lic_info_s + * @brief DRM License register Information structure. + */ +typedef struct { + /** Pointer to license buffer data */ + unsigned char lic_data[DRM_MAX_LEN_LICENSE_DATA]; + + /** license buffer data length */ + unsigned int lic_data_len; + + /** license version (OMA DRM v1 or OMA DRM v2) */ + drm_rights_version_e lic_version; + + /** Source of ROAP Initialization */ + drm_roap_init_src_e roap_init_src; + + /** Callback for status update */ + drm_operation_cb_s operation_callback; +}drm_register_lic_info_s; + +/** + * @struct drm_register_lic_resp_s + * @brief DRM License register Output parameter. + */ +typedef struct { + + /** Content ID */ + char cid[DRM_MAX_LEN_CID]; + +}drm_register_lic_resp_s; + +/** + * @struct drm_custom_data_info_s + * @brief DRM Custom Data Information. + */ +typedef struct { + char app_id[DRM_MAX_LEN_APP_ID + 1]; /** App ID */ + char user_guid[DRM_MAX_LEN_USER_GUID +1]; /** User GID */ + char device_id[DRM_MAX_LEN_DEVICE_ID + 1]; /** Device ID */ + char order_id[DRM_MAX_LEN_ORDER_ID + 1]; /** Order ID */ + char service_id[DRM_MAX_LEN_SERVICE_ID + 1]; /** Service ID */ + char account_id[DRM_MAX_LEN_ACCOUNT_ID + 1]; /** Account ID */ +} drm_custom_data_info_s; + +/** + * @struct drm_initiator_info_s + * @brief DRM License Initiator Information structure. + */ +typedef struct { + /** Pointer to Initiator URL */ + char initiator_url[DRM_MAX_LEN_INITIATOR_URL]; + + /** Initiator URL length */ + unsigned int initiator_url_len; + + /** Callback for status update */ + drm_operation_cb_s operation_callback; + + /** Initiator Type */ + drm_initiator_type init_type; + + /** Custom Data */ + drm_custom_data_info_s custom_data; +}drm_initiator_info_s; + +/** + * @struct drm_web_server_resp_data_s + * @brief DRM Web Server Response Data After submitting Initiator URL Information. + */ +typedef struct { + /** Content URL. Application can download content using this URL if available*/ + char content_url[DRM_MAX_LEN_CONTENT_URL]; + + /** Server Result Code */ + drm_web_server_result_code_e result_code; +} drm_web_server_resp_data_s; + +/** + * Function pointer to handle DRM Roap Notifications + * + * @param[out] cbParam Parameter + * @param[out] appSessionData Application Session Data + * @param[out] agentSessionData DRM Agent Session Data + * @return None + * @see + * @since 0.1 + */ +typedef void (*drm_roap_service_cb) (void *cbParam, /** + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 drm_client.cpp + * @brief DRM Client API defintions. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @author Harsha Shekar (h.shekar@samsung.com) + * @version 0.1 + * @history 0.1: First version of DRM Client API Definitions. + */ + +#include +#include +#include + +#include "drm_client.h" +#include "drm_client_ipc.h" +#include "drm_client_log.h" +//#include "security-server.h" + +#include + +#ifndef EXPORT_API +#define EXPORT_API __attribute__((visibility("default"))) +#endif + + + +/** + * Private function + * + * + * @param[in] file_path Specifies the pointer points a DRM file path. + * @return This function returns DRM file type. + * @remarks + * @see + * @since 0.1 + */ +static drm_file_type_e _drm_client_get_file_type(const char* file_path); + +/** + * An application can check that a file is DRM file + * (OMA DRM, PlayReady, DivX etc.) + * + * @param[in] file_path Specifies the pointer points a DRM file path. + * @param[out] is_drm_file DRM_TRUE if the input file is a DRM file + * else DRM_FALSE. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * + * @remarks + * @see + * @since 0.1 + */ +EXPORT_API int drm_is_drm_file(const char *file_path, + drm_bool_type_e *is_drm_file) +{ + DRM_CLIENT_LOG("Enter: file_path = %s", (!file_path) ? NULL:file_path); + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + int ret_cpy = 0; + + /* Check input parameters */ + if (!file_path || '\0' == file_path[0] || !is_drm_file) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!, file_path = %p, is_drm_file = %p", + file_path, is_drm_file); + return DRM_RETURN_INVALID_ARG; + } + + file_type = _drm_client_get_file_type(file_path); + + switch (file_type) { + case DRM_TYPE_OMA_V1: + case DRM_TYPE_OMA_V2: + case DRM_TYPE_PLAYREADY: + case DRM_TYPE_PLAYREADY_ENVELOPE: + /* All the above 4 cases correspond to a file being DRM file! */ + DRM_CLIENT_LOG("file_type = %d", file_type); + *is_drm_file = DRM_TRUE; + break; + + case DRM_TYPE_DIVX: { + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + /* In this case, further analysis of headers required to identify DRM file */ + /* Contact the server to perform operations */ + + /* Store the input parameters to the Request Data structure to be sent to server */ + if ((ret_cpy = g_strlcpy(req_data.fixed_data.request_data, file_path, + DRM_MAX_LEN_FILEPATH)) >= DRM_MAX_LEN_FILEPATH) { + DRM_CLIENT_EXCEPTION("file_path = %s, filepath_len = %d, ret_cpy = %d", + file_path, strlen(file_path), ret_cpy); + return DRM_RETURN_INVALID_ARG; + } + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_IS_DRM_FILE; + + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + return DRM_RETURN_COMMUNICATION_ERROR; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + *is_drm_file = DRM_FALSE; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + *is_drm_file = resp_data.fixed_data.bool_val; + } + + } + break; + + case DRM_TYPE_UNDEFINED: + DRM_CLIENT_LOG("file_type = %d", file_type); + *is_drm_file = DRM_FALSE; + break; + + default: + DRM_CLIENT_EXCEPTION("Undefined file type!!"); + *is_drm_file = DRM_FALSE; + goto ErrorExit; + } + + DRM_CLIENT_LOG("Exit:Success!!, is_drm_file = %d", + *is_drm_file); + return DRM_RETURN_SUCCESS; + +ErrorExit: + DRM_CLIENT_EXCEPTION("Exit:failed!!, is_drm_file = %d", + *is_drm_file); + return DRM_RETURN_INTERNAL_ERROR; + +} + +/** + * An application can get DRM file type of the file that is + * specified in file_path + * + * @param[in] file_path Specifies the pointer points a DRM file path. + * @param[out] file_type DRM file type. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @remarks + * @see + * @since 0.1 + */ +EXPORT_API int drm_get_file_type(const char *file_path, drm_file_type_e *file_type) +{ + DRM_CLIENT_LOG("Enter: file_path = %s", (!file_path) ? NULL:file_path); + + /* Check input parameters */ + if (!file_path || '\0' == file_path[0] || !file_type) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!, file_path = %p, file_type = %p", + file_path, file_type); + return DRM_RETURN_INVALID_ARG; + } + + *file_type = _drm_client_get_file_type(file_path); + DRM_CLIENT_LOG("Exit:Success!! file_type = %d", *file_type); + return DRM_RETURN_SUCCESS; +} + +/** + * An application can check that a DRM file has valid license or not. + * + * @param[in] file_path DRM file path. + * @param[in] perm_type Enumeration type of permission. + * @param[out] license_status license status. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +EXPORT_API int drm_get_license_status(const char *file_path, + drm_permission_type_e perm_type, + drm_license_status_e *license_status) +{ + DRM_CLIENT_LOG("Enter: file_path = %s, perm_type = %d", + (!file_path) ? NULL:file_path, perm_type); + + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + drm_result_e result = DRM_RETURN_SUCCESS; + int ret_cpy = 0; + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + /* Check input parameters */ + if (!file_path || '\0' == file_path[0] || !license_status) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!, file_path = %p, license_status = %p", + file_path, license_status); + return DRM_RETURN_INVALID_ARG; + } + + /* Store the input parameters to the Request Data structure to be sent to server */ + if ((ret_cpy = g_strlcpy(req_data.fixed_data.request_data, file_path, + DRM_MAX_LEN_FILEPATH)) >= DRM_MAX_LEN_FILEPATH) { + DRM_CLIENT_EXCEPTION("file_path = %s, filepath_len = %d, ret_cpy = %d", + file_path, strlen(file_path), ret_cpy); + return DRM_RETURN_INVALID_ARG; + } + + req_data.fixed_data.permission_type = perm_type; + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_GET_LICENSE_STATUS; + + /* Send Data to DRM server */ + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + *license_status = DRM_LICENSE_STATUS_UNDEFINED; + result = resp_data.fixed_data.resp_result; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + *license_status = resp_data.fixed_data.lic_status; + } + + DRM_CLIENT_LOG("*license_status = %d", *license_status); + +ErrorExit: + if (result != DRM_RETURN_SUCCESS) { + DRM_CLIENT_EXCEPTION("Exit:failed!!, result = 0x%x", result); + } else { + DRM_CLIENT_LOG("Exit:Success!!, result = 0x%x", result); + } + + return result; +} + +/** + * An application can get DRM Content information for the file + * specified in file_path. + * + * @param[in] file_path DRM file path. + * @param[out] content_info Content information. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +EXPORT_API int drm_get_content_info(const char *file_path, + drm_content_info_s *content_info) +{ + DRM_CLIENT_LOG("Enter: file_path = %s", (!file_path) ? NULL:file_path); + + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + drm_result_e result = DRM_RETURN_SUCCESS; + int ret_cpy = 0; + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + /* Check input parameters */ + if (!file_path || '\0' == file_path[0] || !content_info) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!, file_path = %p, content_info = %p", + file_path, content_info); + return DRM_RETURN_INVALID_ARG; + } + + /* memset the output structure */ + memset(content_info, 0x00, sizeof(drm_content_info_s)); + + /* Store the input parameters to the Request Data structure to be sent to server */ + if ((ret_cpy = g_strlcpy(req_data.fixed_data.request_data, file_path, + DRM_MAX_LEN_FILEPATH)) >= DRM_MAX_LEN_FILEPATH) { + DRM_CLIENT_EXCEPTION("file_path = %s, filepath_len = %d, ret_cpy = %d", + file_path, strlen(file_path), ret_cpy); + return DRM_RETURN_INVALID_ARG; + } + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_GET_CONTENT_INFO; + + /* Send Data to DRM server */ + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + memset(content_info, 0x00, sizeof(drm_content_info_s)); + result = resp_data.fixed_data.resp_result; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + memcpy(content_info, &resp_data.fixed_data.response_data, sizeof(drm_content_info_s)); + } + + DRM_CLIENT_LOG("content_info->author = %s", content_info->author); + DRM_CLIENT_LOG("content_info->content_id = %s", content_info->content_id); + DRM_CLIENT_LOG("content_info->content_url = %s", content_info->content_url); + DRM_CLIENT_LOG("content_info->copyright = %s", content_info->copyright); + DRM_CLIENT_LOG("content_info->description = %s", content_info->description); + DRM_CLIENT_LOG("content_info->icon_uri = %s", content_info->icon_uri); + DRM_CLIENT_LOG("content_info->info_url = %s", content_info->info_url); + DRM_CLIENT_LOG("content_info->mime_type = %s", content_info->mime_type); + DRM_CLIENT_LOG("content_info->rights_url = %s", content_info->rights_url); + DRM_CLIENT_LOG("content_info->title = %s", content_info->title); + +ErrorExit: +if (result != DRM_RETURN_SUCCESS) { + DRM_CLIENT_EXCEPTION("Exit:failed!!, result = 0x%x", result); + } else { + DRM_CLIENT_LOG("Exit:Success!!, result = 0x%x", result); + } + + return result; +} + +/** + * An application can get file information of a DRM file. + * + * @param[in] file_path DRM file path. + * @param[out] fileInfo DRM file info. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +EXPORT_API int drm_get_file_info(const char *file_path, + drm_file_info_s *fileInfo) +{ + DRM_CLIENT_LOG("Enter: file_path = %s", (!file_path) ? NULL:file_path); + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + drm_result_e result = DRM_RETURN_SUCCESS; + int ret_cpy = 0; + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + /* Check input parameters */ + if (!file_path || '\0' == file_path[0] || !fileInfo) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!, file_path = %p, fileInfo = %p", + file_path, fileInfo); + return DRM_RETURN_INVALID_ARG; + } + + DRM_CLIENT_LOG("file_path = %s", file_path); + + /* memset the output structure */ + memset(fileInfo, 0x00, sizeof(drm_file_info_s)); + + /* Store the input parameters to the Request Data structure to be sent to server */ + if ((ret_cpy = g_strlcpy(req_data.fixed_data.request_data, file_path, + DRM_MAX_LEN_FILEPATH)) >= DRM_MAX_LEN_FILEPATH) { + DRM_CLIENT_EXCEPTION("file_path = %s, filepath_len = %d, ret_cpy = %d", + file_path, strlen(file_path), ret_cpy); + return DRM_RETURN_INVALID_ARG; + } + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_GET_FILE_INFO; + + /* Send Data to DRM server */ + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + memset(fileInfo, 0x00, sizeof(drm_file_info_s)); + result = resp_data.fixed_data.resp_result; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + memcpy(fileInfo, &resp_data.fixed_data.response_data, sizeof(drm_file_info_s)); + } + + DRM_CLIENT_LOG("fileInfo->oma_info.method = %d", fileInfo->oma_info.method); + DRM_CLIENT_LOG("fileInfo->oma_info.version = %d", fileInfo->oma_info.version); + +ErrorExit: + if (result != DRM_RETURN_SUCCESS) { + DRM_CLIENT_EXCEPTION("Exit:failed!!, result = 0x%x", result); + } else { + DRM_CLIENT_LOG("Exit:Success!!, result = 0x%x", result); + } + return result; +} + +/** + * An application can get constraints associated with + * given permission & given file + * + * @param[in] file_path DRM file path. + * @param[in] perm_type Enumeration type of permission. + * @param[out] constraint_info Constraint info. + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +EXPORT_API int drm_get_constraint_info(const char *file_path, + drm_permission_type_e perm_type, + drm_constraint_info_s *constraint_info) +{ + DRM_CLIENT_LOG("Enter: file_path = %s, perm_type = %d", + (!file_path) ? NULL:file_path, perm_type); + + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + drm_result_e result = DRM_RETURN_SUCCESS; + int ret_cpy = 0; + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + /* Check input parameters */ + if (!file_path || '\0' == file_path[0] || !constraint_info) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!, file_path = %p, constraint_info = %p", + file_path, constraint_info); + return DRM_RETURN_INVALID_ARG; + } + + DRM_CLIENT_LOG("file_path = %s, perm_type = %d", file_path, perm_type); + + /* memset the output structure */ + memset(constraint_info, 0x00, sizeof(drm_constraint_info_s)); + + /* Store the input parameters to the Request Data structure to be sent to server */ + if ((ret_cpy = g_strlcpy(req_data.fixed_data.request_data, file_path, + DRM_MAX_LEN_FILEPATH)) >= DRM_MAX_LEN_FILEPATH) { + DRM_CLIENT_EXCEPTION("file_path = %s, filepath_len = %d, ret_cpy = %d", + file_path, strlen(file_path), ret_cpy); + return DRM_RETURN_INVALID_ARG; + } + req_data.fixed_data.permission_type = perm_type; + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_GET_CONSTRAINT_INFO; + + /* Send Data to DRM server */ + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + memset(constraint_info, 0x00, sizeof(drm_constraint_info_s)); + result = resp_data.fixed_data.resp_result; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + memcpy(constraint_info, &resp_data.fixed_data.response_data, sizeof(drm_constraint_info_s)); + } + +ErrorExit: + if (result != DRM_RETURN_SUCCESS) { + DRM_CLIENT_EXCEPTION("Exit:failed!!, result = 0x%x", result); + } else { + DRM_CLIENT_LOG("Exit:Success!!, result = 0x%x", result); + } + return result; +} + +/** + * An application can check the feasibility of actions to be + * performed based on the type of DRM file. + * + * @param[in] action Action to be taken. + * @param[in] action_data Data needed to check action + * allowed operation + * @param[out] is_allowed DRM_TRUE if action is allowed + * else DRM_FALSE + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks + * @see + * @since 0.1 + */ +EXPORT_API int drm_is_action_allowed(drm_action_type_e action, + drm_action_allowed_data_s *action_data, + drm_bool_type_e *is_allowed) +{ + DRM_CLIENT_LOG("Enter: action = %d, action_data = %p", action, action_data); + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + drm_result_e result = DRM_RETURN_SUCCESS; + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + /* Check input parameters based on action type */ + switch(action){ + case DRM_IS_FORWARDING_ALLOWED: + case DRM_HAS_VALID_SETAS_STATUS: + { + /* Check input parameters */ + if ((strlen(action_data->file_path)<=0) || !is_allowed) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!, action_data->file_path = %p," + " is_allowed = %p", action_data->file_path, is_allowed); + return DRM_RETURN_INVALID_ARG; + } + DRM_CLIENT_LOG("action_data->file_path = %s, action = %d, data = %d", + action_data->file_path, action, action_data->data); + + /* Copy the input parameters to the Request structure */ + req_data.fixed_data.action = action; + memcpy(req_data.fixed_data.request_data, action_data, + sizeof(drm_action_allowed_data_s)); + break; + } + + case DRM_IS_DEVICE_ACTIVATED: + case DRM_IS_VALID_SECURE_CLOCK: + { + /* Check input parameters */ + if (!is_allowed) { + DRM_CLIENT_EXCEPTION("Invalid Arg!!,is_allowed = %p",is_allowed); + return DRM_RETURN_INVALID_ARG; + } + + /* Copy the input parameters to the Request structure */ + req_data.fixed_data.action = action; + break; + } + + default: + DRM_CLIENT_EXCEPTION("Invalid action type=%d",action); + return DRM_RETURN_INVALID_ARG; + } + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_IS_ACTION_ALLOWED; + + /* Send Data to DRM server */ + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + *is_allowed = DRM_FALSE; + result = resp_data.fixed_data.resp_result; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + *is_allowed = resp_data.fixed_data.bool_val; + } + +ErrorExit: + if (result != DRM_RETURN_SUCCESS) { + DRM_CLIENT_EXCEPTION("Exit:failed!!, result = 0x%x", result); + } else { + DRM_CLIENT_LOG("Exit:Success!!, result = 0x%x", result); + } + return result; +} + +/** + * An application can get the requested data from DRM. + * + * @param[in] data_type Data types as per enum drm_data_type_e. + * @param[in] input Pointer to appropriate structure as per data_type. + * @param[out] output Output data. Pointer to appropriate structure as + * per data_type. + * + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks Please typecast to appropriate data structures + * as per data types. + * + * if data_type = DRM_DATA_TYPE_SECURE_CLOCK + * then input type: input = NULL + * and output type: output = pointer to struct + * drm_secure_clock_data_s + * + * if data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG + * then input type: input = NULL + * and output type: output = pointer to int + * + * if data_type = DRM_DATA_TYPE_TRANSACTION_TRACKING_ID + * then input type: input = pointer to file path (const char) + * and output type: output = pointer to struct + * drm_transaction_id_info_s + * + * if data_type = DRM_DATA_TYPE_DIVX_REGISTRATION_CODE + * then input type: input = NULL + * and output type: output = pointer to struct drm_code_info_s + * + * if data_type = DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE + * then input type: input = NULL + * and output type: output = pointer to struct drm_code_info_s + * + * @see + * @since 0.1 + */ +EXPORT_API int drm_get_data(drm_data_type_e data_type, void *input, void *output) +{ + DRM_CLIENT_LOG("Enter: data_type = %d, input = %p, output = %p", + data_type, input, output); + /* Local Variables */ + drm_result_e result = DRM_RETURN_SUCCESS; + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + int ret_cpy = 0; + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + /* Check Input & Output Parameters and fill the Request data */ + switch (data_type) { + case DRM_DATA_TYPE_SECURE_CLOCK: + case DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG: + case DRM_DATA_TYPE_DIVX_REGISTRATION_CODE: + case DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE: + if (!output) { + DRM_CLIENT_EXCEPTION("Invalid arguments!!, output = %p", output); + return DRM_RETURN_INVALID_ARG; + } + break; + case DRM_DATA_TYPE_TRANSACTION_TRACKING_ID: { + if (!input || ((char*)input)[0] == '\0' || !output) { + DRM_CLIENT_EXCEPTION("Invalid arguments!!, input = %p, output = %p", + input, output); + return DRM_RETURN_INVALID_ARG; + } + + /* Copy the input parameter to be sent as Request Data */ + if ((ret_cpy = g_strlcpy(req_data.fixed_data.request_data, + (const gchar*) input, DRM_MAX_LEN_FILEPATH)) + >= DRM_MAX_LEN_FILEPATH) { + DRM_CLIENT_EXCEPTION("file_path = %s, filepath_len = %d, ret_cpy = %d", + (const char*)input, strlen(((const char*)input)), ret_cpy); + return DRM_RETURN_INVALID_ARG; + } + } + break; + default: + DRM_CLIENT_EXCEPTION("Invalid argument, data_type = %d", data_type); + return DRM_RETURN_INVALID_ARG; + } + + DRM_CLIENT_LOG("data_type=%d input=%p output=%p", data_type, input, output); + + /* Fill other parameters to be sent */ + req_data.fixed_data.data_type = data_type; + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_GET_DATA; + + /* Send Data to DRM server */ + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + + result = resp_data.fixed_data.resp_result; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + + /* Store the response result to the output based on the request data type */ + switch (data_type) { + + case DRM_DATA_TYPE_SECURE_CLOCK: { + drm_secure_clock_data_s sec_clk_data = { 0, }; + + /* Copy from response data into local structure */ + memcpy(&sec_clk_data, resp_data.fixed_data.response_data, + sizeof(drm_secure_clock_data_s)); + DRM_CLIENT_LOG("sec_clk_data.is_secure_clock_set = %d", + sec_clk_data.is_secure_clock_set); + DRM_CLIENT_LOG("Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + sec_clk_data.secure_clock.tm_year, + sec_clk_data.secure_clock.tm_mon, + sec_clk_data.secure_clock.tm_mday, + sec_clk_data.secure_clock.tm_hour, + sec_clk_data.secure_clock.tm_min, + sec_clk_data.secure_clock.tm_sec); + + /* Now copy into output parameter */ + memcpy(output, &sec_clk_data, sizeof(drm_secure_clock_data_s)); + + } + break; + + case DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG: { + + int transtrack_flag = 0; + + /* Copy from response data into local structure */ + memcpy(&transtrack_flag, resp_data.fixed_data.response_data, sizeof(int)); + DRM_CLIENT_LOG("transtrack_flag = %d", transtrack_flag); + + /* Now copy into output parameter */ + memcpy(output, &transtrack_flag, sizeof(int)); + + } + break; + + case DRM_DATA_TYPE_TRANSACTION_TRACKING_ID: { + drm_transaction_id_info_s transid_info; + memset(&transid_info,0,sizeof(transid_info)); + + /* Copy from response data into local structure */ + memcpy(&transid_info, resp_data.fixed_data.response_data, + sizeof(drm_transaction_id_info_s)); + DRM_CLIENT_LOG("transid_info.tr_id = %s", transid_info.tr_id); + DRM_CLIENT_LOG("transid_info.tr_id_len = %d", + transid_info.tr_id_len) + + /* Now copy into output parameter */ + memcpy(output, &transid_info, sizeof(drm_transaction_id_info_s)); + + } + break; + + case DRM_DATA_TYPE_DIVX_REGISTRATION_CODE: { + + drm_code_info_s registration_info; + memset(®istration_info,0,sizeof(registration_info)); + + /* Copy from response data into local structure */ + memcpy(®istration_info, resp_data.fixed_data.response_data, + sizeof(drm_code_info_s)); + DRM_CLIENT_LOG("registration_info.code = %s", + registration_info.code); + DRM_CLIENT_LOG("registration_info.code_len = %d", + registration_info.code_len); + + /* Now copy into output parameter */ + memcpy(output, ®istration_info, sizeof(drm_code_info_s)); + + } + break; + + case DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE: { + + drm_code_info_s deregis_info; + memset(&deregis_info,0,sizeof(deregis_info)); + + /* Copy from response data into local structure */ + memcpy(&deregis_info, resp_data.fixed_data.response_data, + sizeof(drm_code_info_s)); + DRM_CLIENT_LOG("deregis_info.code = %s", + deregis_info.code); + DRM_CLIENT_LOG("deregis_info.code_len = %d", + deregis_info.code_len); + + /* Now copy into output parameter */ + memcpy(output, &deregis_info, sizeof(drm_code_info_s)); + + } + break; + + } + + } + + /* Success */ + DRM_CLIENT_LOG("Exit:Success:result=0x%x",result); + return result; + +ErrorExit: + /* Failure */ + DRM_CLIENT_EXCEPTION("Exit:failed:result=0x%x",result); + return result; +} + +/** + * An application can do particular request to DRM. + * + * @param[in] request_type Request types as per enum drm_request_type_e. + * @param[in] input Pointer to appropriate structure as per + * request_type. + * @param[out] output Output data. Pointer to appropriate structure as + * per request_type. + * + * @return 0 on success, else a negative error value + * @retval DRM_RETURN_SUCCESS on success + * @retval DRM_RETURN_INVALID_ARG if arguments are invalid + * @retval DRM_RETURN_COMMUNICATION_ERROR if socket error + * @retval DRM_RETURN_INTERNAL_ERROR if operation error + * @remarks Please typecast to appropriate data structures + * as per data types. + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_FILE + * then input type: input = pointer to const char (file_path) + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_UNREGISTER_FILE + * then input type: input = pointer to struct drm_unregister_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES + * then input type: input = NULL + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE + * then input type: input = pointer to + * struct drm_register_lic_info_s. + * and output type: output = pointer to + * struct drm_register_lic_resp_s. + * + * if request_type = DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL + * then input type: input = pointer to struct drm_initiator_info_s + * and output type: output = pointer to struct drm_web_server_resp_data_s + * + * if request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE + * then input type: input = pointer to struct drm_submit_roap_message_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT + * then input type: input = pointer to struct drm_submit_roap_user_consent_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_HTTP_USER_CANCEL + * then input type: input = pointer to struct drm_http_user_cancel_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_COPY_FILE + * then input type: input = pointer to struct drm_register_copy_file_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_MOVE_FILE + * then input type: input = pointer to struct drm_register_copy_file_info_s + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_INSERT_EXT_MEMORY + * then input type: input = NULL + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY + * then input type: input = NULL + * and output type: output = NULL + * + * if request_type = DRM_REQUEST_TYPE_REGISTER_SETAS + * then input type: input = pointer to struct drm_register_setas_info_s + * and output type: output = pointer to the struct drm_register_setas_resp_data_s + * + * if request_type = DRM_REQUEST_TYPE_UNREGISTER_SETAS + * then input type: input = pointer to struct drm_unregister_setas_info_s + * and output type: output = NULL + * + * @see + * @since 0.1 + */ +EXPORT_API int drm_process_request(drm_request_type_e request_type, + void *input, void *output) +{ + DRM_CLIENT_LOG("Enter: request_type = %d, input = %p, output = %p", + request_type, input, output); + /* Local Variables */ + drm_result_e result = DRM_RETURN_SUCCESS; + drm_request_data_s req_data; + drm_response_data_s resp_data; + int ret_comm = 0; + int ret_cpy = 0; + + /* memset the structures */ + memset(&req_data, 0x0, sizeof(drm_request_data_s)); + memset(&resp_data, 0x0, sizeof(drm_response_data_s)); + + DRM_CLIENT_LOG("request_type = %d", request_type); + + /* Check Input & Output Parameters */ + switch (request_type) { + case DRM_REQUEST_TYPE_REGISTER_FILE: { + if (!input || ((char*)input)[0] == '\0') { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + /* Copy the input to Request Structure */ + if ((ret_cpy = g_strlcpy(req_data.fixed_data.request_data, + (const gchar*) input, DRM_MAX_LEN_FILEPATH)) + >= DRM_MAX_LEN_FILEPATH) { + DRM_CLIENT_EXCEPTION("file_path = %s, filepath_len = %d, ret_cpy = %d", + (const char*)input, strlen(((const char*)input)), ret_cpy); + return DRM_RETURN_INVALID_ARG; + } + } + } + break; + + case DRM_REQUEST_TYPE_UNREGISTER_FILE: { + if (!input || ((char*)input)[0] == '\0') { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, sizeof(drm_unregister_info_s)); + } + } + break; + + case DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES: { + DRM_CLIENT_LOG("No parameters required!"); + } + break; + + case DRM_REQUEST_TYPE_REGISTER_LICENSE: { + if (!input || ((char*)input)[0] == '\0' || !output) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p, output = %p", + input, output); + return DRM_RETURN_INVALID_ARG; + } else { + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_register_lic_info_s)); + + } + } + break; + + case DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL: { + if (!input || ((char*)input)[0] == '\0' || !output) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p, output = %p", + input, output); + return DRM_RETURN_INVALID_ARG; + } else { + + DRM_CLIENT_LOG("initiator_url[%s]", ((drm_initiator_info_s*)input)->initiator_url); + DRM_CLIENT_LOG("initiator_url_len[%u]", ((drm_initiator_info_s*)input)->initiator_url_len); + DRM_CLIENT_LOG("operation_callback.callback[%p]", ((drm_initiator_info_s*)input)->operation_callback.callback); + DRM_CLIENT_LOG("init_type[%d]", ((drm_initiator_info_s*)input)->init_type); + DRM_CLIENT_LOG("custom_data.app_id[%s]", ((drm_initiator_info_s*)input)->custom_data.app_id); + DRM_CLIENT_LOG("custom_data.user_guid[%s]", ((drm_initiator_info_s*)input)->custom_data.user_guid); + DRM_CLIENT_LOG("custom_data.device_id[%s]", ((drm_initiator_info_s*)input)->custom_data.device_id); + DRM_CLIENT_LOG("custom_data.order_id[%s]", ((drm_initiator_info_s*)input)->custom_data.order_id); + DRM_CLIENT_LOG("custom_data.service_id[%s]", ((drm_initiator_info_s*)input)->custom_data.service_id); + DRM_CLIENT_LOG("custom_data.account_id[%s]", ((drm_initiator_info_s*)input)->custom_data.account_id); + + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_initiator_info_s)); + } + } + break; + + case DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE: { + + if (!input + || (!((drm_submit_roap_message_info_s*) input)->buffer) + || (((drm_submit_roap_message_info_s*) input)->buffer[0] == '\0') + || (((drm_submit_roap_message_info_s*) input)->buff_size == 0)) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_submit_roap_message_info_s)); + + /* Number of additional data items to be sent */ + if ((((drm_submit_roap_message_info_s*) input)->app_session_data.pData) + && (((drm_submit_roap_message_info_s*) input)->app_session_data.size_pData != 0)) { + req_data.fixed_data.num_data_items = 2; + } else { + req_data.fixed_data.num_data_items = 1; + } + + /* Fill details pertaining to additional pointers to be sent */ + req_data.fixed_data.data_length[0] = + ((drm_submit_roap_message_info_s*) input)->buff_size; + + /* Allocate memory for data items */ + req_data.data_items[0] = (char*) malloc( + req_data.fixed_data.data_length[0]); + if (!req_data.data_items[0]) { + DRM_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p", + req_data.data_items[0]); + result = DRM_RETURN_INSUFFICIENT_MEMORY; + goto ErrorExit; + } + + /* Copy the buffer into data items */ + memcpy(req_data.data_items[0], + ((drm_submit_roap_message_info_s*) input)->buffer, + ((drm_submit_roap_message_info_s*) input)->buff_size); + + if (2 == req_data.fixed_data.num_data_items) { + req_data.fixed_data.data_length[1] = + ((drm_submit_roap_message_info_s*) input)->app_session_data.size_pData; + + req_data.data_items[1] = (char*) malloc( + req_data.fixed_data.data_length[1]); + if (!req_data.data_items[1]) { + DRM_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p", + req_data.data_items[1]); + result = DRM_RETURN_INSUFFICIENT_MEMORY; + goto ErrorExit; + } + + /* Copy the Additional data */ + memcpy( req_data.data_items[1], + ((drm_submit_roap_message_info_s*) input)->app_session_data.pData, + ((drm_submit_roap_message_info_s*) input)->app_session_data.size_pData); + } + } + + } + break; + + case DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT: { + + if (!input + || (!((drm_submit_roap_user_consent_info_s*) input)->agentdata) + || (((drm_submit_roap_user_consent_info_s*) input)->size_agentdata == 0)) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_submit_roap_user_consent_info_s)); + + /* Number of additional data items to be sent */ + req_data.fixed_data.num_data_items = 1; + + /* Fill details pertaining to additional pointers to be sent */ + req_data.fixed_data.data_length[0] = + ((drm_submit_roap_user_consent_info_s*) input)->size_agentdata; + + /* Allocate memory for data items */ + req_data.data_items[0] = (char*) malloc( + req_data.fixed_data.data_length[0]); + if (!req_data.data_items[0]) { + DRM_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p", + req_data.data_items[0]); + result = DRM_RETURN_INSUFFICIENT_MEMORY; + goto ErrorExit; + } + + /* Copy the buffer into data items */ + memcpy(req_data.data_items[0], + ((drm_submit_roap_user_consent_info_s*) input)->agentdata, + ((drm_submit_roap_user_consent_info_s*) input)->size_agentdata); + } + + } + break; + + case DRM_REQUEST_TYPE_HTTP_USER_CANCEL: { + + if (!input + || (!((drm_http_user_cancel_info_s*) input)->app_session_data) + || (((drm_http_user_cancel_info_s*) input)->size_app_session_data == 0)) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_http_user_cancel_info_s)); + + /* Number of additional data items to be sent */ + req_data.fixed_data.num_data_items = 1; + + /* Fill details pertaining to additional pointers to be sent */ + req_data.fixed_data.data_length[0] = + ((drm_http_user_cancel_info_s*) input)->size_app_session_data; + + /* Allocate memory for data items */ + req_data.data_items[0] = (char*) malloc( + req_data.fixed_data.data_length[0]); + if (!req_data.data_items[0]) { + DRM_CLIENT_EXCEPTION("Memory Allocation Error!, Buf = %p", + req_data.data_items[0]); + result = DRM_RETURN_INSUFFICIENT_MEMORY; + goto ErrorExit; + } + + /* Copy the buffer into data items */ + memcpy(req_data.data_items[0], + ((drm_http_user_cancel_info_s*) input)->app_session_data, + ((drm_http_user_cancel_info_s*) input)->size_app_session_data); + + } + + } + break; + + case DRM_REQUEST_TYPE_REGISTER_COPY_FILE: { + + if (!input + || (((drm_register_copy_file_info_s*) input)->src_file_path[0] == '\0') + || (((drm_register_copy_file_info_s*) input)->dest_file_path[0] == '\0')) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_register_copy_file_info_s)); + } + } + break; + + case DRM_REQUEST_TYPE_REGISTER_MOVE_FILE: { + + if (!input + || (((drm_register_move_file_info_s*) input)->src_file_path[0] == '\0') + || (((drm_register_move_file_info_s*) input)->dest_file_path[0] == '\0')) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_register_move_file_info_s)); + } + } + break; + + case DRM_REQUEST_TYPE_INSERT_EXT_MEMORY: + case DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY: + DRM_CLIENT_LOG("No parameters to check!!"); + break; + + case DRM_REQUEST_TYPE_REGISTER_SETAS: { + + if (!input + || (((drm_register_setas_info_s*) input)->file_path[0] == '\0')) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_register_setas_info_s)); + } + + } + break; + + case DRM_REQUEST_TYPE_UNREGISTER_SETAS: { + + if (!input + || (((drm_unregister_setas_info_s*) input)->file_path[0] == '\0')) { + DRM_CLIENT_EXCEPTION("Invalid argument!!, input = %p", input); + return DRM_RETURN_INVALID_ARG; + } else { + /* Copy the input to Request Structure */ + memcpy(req_data.fixed_data.request_data, input, + sizeof(drm_unregister_setas_info_s)); + } + } + break; + + default: + DRM_CLIENT_EXCEPTION("Invalid Argument! request_type = %d", + request_type); + return DRM_RETURN_INVALID_ARG; + } + + DRM_CLIENT_LOG("input=%p output=%p", input, output); + + /* Fill other parameters to be sent */ + req_data.fixed_data.request_type = request_type; + + /* Tell the server which API to be used */ + req_data.fixed_data.api_name = DRM_PROCESS_REQUEST; + + /* Send Data to DRM server */ + /* Call the Client Communication API */ + if ((ret_comm = drm_client_comm(&req_data, &resp_data)) != 0) { + DRM_CLIENT_EXCEPTION("drm_client_comm error!!, ret_comm = %d", ret_comm); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + + /* Copy the response obtained from the server into the output parameter */ + if (resp_data.fixed_data.resp_result != 0) { + DRM_CLIENT_EXCEPTION("Error returned from server!!, resp_data.fixed_data.resp_result = 0x%x", + resp_data.fixed_data.resp_result); + + result = resp_data.fixed_data.resp_result; + goto ErrorExit; + } else { + DRM_CLIENT_LOG("resp_data.fixed_data.resp_result = 0x%x", resp_data.fixed_data.resp_result); + + /* Store the response result to the output based on the Request type */ + switch (request_type) { + case DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL: { + + drm_web_server_resp_data_s ws_resp_data; + memset(&ws_resp_data,0,sizeof(ws_resp_data)); + /* Copy from response data into local structure */ + memcpy(&ws_resp_data, resp_data.fixed_data.response_data, + sizeof(drm_web_server_resp_data_s)); + DRM_CLIENT_LOG("ws_resp_data.fixed_data.content_url = %s", + ws_resp_data.content_url); + DRM_CLIENT_LOG("ws_resp_data.result_code = 0x%x", + ws_resp_data.result_code); + + /* Now copy into output parameter */ + memcpy(output, &ws_resp_data, sizeof(drm_web_server_resp_data_s)); + + } + break; + + case DRM_REQUEST_TYPE_REGISTER_LICENSE: { + + drm_register_lic_resp_s lic_resp; + memset(&lic_resp,0,sizeof(lic_resp)); + + /* Copy from response data into local structure */ + memcpy(&lic_resp, resp_data.fixed_data.response_data, + sizeof(drm_register_lic_resp_s)); + DRM_CLIENT_LOG("lic_resp.cid = %s", lic_resp.cid); + + /* Now copy into output parameter */ + memcpy(output, &lic_resp, sizeof(drm_register_lic_resp_s)); + + } + break; + + case DRM_REQUEST_TYPE_REGISTER_SETAS: { + + DRM_CLIENT_LOG("Register Setas Successful"); + drm_register_setas_resp_data_s setas_resp = { 0, }; + + /* Copy from response data into local structure */ + memcpy(&setas_resp, resp_data.fixed_data.response_data, + sizeof(drm_register_setas_resp_data_s)); + + /* Now copy into output parameter */ + memcpy(output, &setas_resp, sizeof(drm_register_setas_resp_data_s)); + } + break; + case DRM_REQUEST_TYPE_REGISTER_FILE: + case DRM_REQUEST_TYPE_UNREGISTER_FILE: + case DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES: + case DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE: + case DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT: + case DRM_REQUEST_TYPE_HTTP_USER_CANCEL: + case DRM_REQUEST_TYPE_REGISTER_COPY_FILE: + case DRM_REQUEST_TYPE_REGISTER_MOVE_FILE: + case DRM_REQUEST_TYPE_INSERT_EXT_MEMORY: + case DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY: + case DRM_REQUEST_TYPE_UNREGISTER_SETAS: + DRM_CLIENT_LOG("No output parameters to be handled!!"); + break; + + } + } + + +ErrorExit: + + /* Free Request Data memory */ + for (unsigned int i = 0; i < req_data.fixed_data.num_data_items; i++) { + if (req_data.data_items[i]) + free(req_data.data_items[i]); + } + + /* Free Response Data memory */ + for (unsigned int i = 0; i < resp_data.fixed_data.num_data_items; i++) { + if (resp_data.data_items[i]) + free(resp_data.data_items[i]); + } + + DRM_CLIENT_LOG("Result[0x%x]", result); + + return result; +} + +/** + * Private function + * + * + * @param[in] file_path Specifies the pointer points a DRM file path. + * @return This function returns DRM file type. + * @remarks + * @see + * @since 0.1 + */ +static drm_file_type_e _drm_client_get_file_type(const char* file_path) +{ + char *p = NULL; + p = (char *) strrchr(file_path, '.'); + if (!p) { + DRM_CLIENT_EXCEPTION("Invalid file_path!, file_path = %s", file_path); + return DRM_TYPE_UNDEFINED; + } + + DRM_CLIENT_LOG("file_path=[%s], p=[0x%x]", file_path, p); + + if (p && ((strncasecmp(p, ".dcf", 4) == 0))) { + + DRM_CLIENT_LOG("OMA DRM V1 File: file_path=%s p=%s", file_path, p); + return DRM_TYPE_OMA_V1; + + } else if (p && ((strncasecmp(p, ".odf", 4) == 0) + || (strncasecmp(p, ".o4a", 4) == 0) + || (strncasecmp(p, ".o4v", 4) == 0))) { + + DRM_CLIENT_LOG("OMA DRM V2 File: file_path=%s p=%s", file_path, p); + return DRM_TYPE_OMA_V2; + + } else if ((p && ((strncasecmp(p, ".pya", 4) == 0) + || (strncasecmp(p, ".pyv", 4) == 0)))) { + + DRM_CLIENT_LOG("PlayReady File: file_path=%s p=%s", file_path, p); + return DRM_TYPE_PLAYREADY; + + } else if (p && ((strncasecmp(p, ".eny", 4) == 0) + || (strncasecmp(p, ".pye", 4) == 0) + || (strncasecmp(p, ".jue", 4) == 0))) { + + DRM_CLIENT_LOG("PlayReady Envelope File: file_path=%s p=%s", file_path, p); + return DRM_TYPE_PLAYREADY_ENVELOPE; + + } else if (p && ((strncasecmp(p, ".avi", 4) == 0) + || (strncasecmp(p, ".divx", 5) == 0))) { + + DRM_CLIENT_LOG("DivX DRM File: file_path=%s p=%s", file_path, p); + return DRM_TYPE_DIVX; + + } else { + DRM_CLIENT_LOG("NON DRM file=%s", file_path); + return DRM_TYPE_UNDEFINED; + } +} diff --git a/service/drm_client_ipc.cpp b/service/drm_client_ipc.cpp new file mode 100755 index 0000000..1967e45 --- /dev/null +++ b/service/drm_client_ipc.cpp @@ -0,0 +1,552 @@ +/* + * drm-client + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 drm_client_ipc.cpp + * @brief DRM Client Inter process communication definitions. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @author Harsha Shekar (h.shekar@samsung.com) + * @author Ravi S (ravi.cs@samsung.com) + * @version 0.1 + * @history 0.1: DRM Client Inter process communication definitions. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "drm_client_ipc.h" +#include "drm_client_log.h" + + +/** + * @brief Sync socket fd on a thread basis + */ +static __thread int sockfd = -1; + +/** + * @brief Client info on a thread basis + */ +static __thread drm_client_info_s client_info; + +/** + * @brief Async socket fd on a process basis + */ +static int async_sockfd = -1; + +/** + * @brief Storing the registered callbacks + */ +static drm_client_cb_info_s client_cb_info[DRM_MAX_CLIENT_SUPPORTED]; + +/** + * @brief Mutex to serialise async socket per process + */ +pthread_mutex_t async_mutex = PTHREAD_MUTEX_INITIALIZER; + +/** + * Library load time constructor + */ +void __drm_client_lib_load_constructor (void) __attribute__((constructor)); + +/** + * Library load time constructor + */ +void __drm_client_lib_unload_destructor (void) __attribute__((destructor)); + + +/** + * Constructor for library load time + * + * + * @param void + * @return void + * @remarks + * @see + * @since 0.1 + */ +void __drm_client_lib_load_constructor(void) +{ + DRM_CLIENT_LOG("libdrm-client.so.0 loaded!!!"); +} + +/** + * Destructor for library unload time + * + * + * @param void + * @return void + * @remarks + * @see + * @since 0.1 + */ +void __drm_client_lib_unload_destructor(void) +{ + DRM_CLIENT_LOG("libdrm-client.so.0 unloaded!!!"); + + /* Close the sockets */ + DRM_CLIENT_LOG("Closing sockets!!"); + if (sockfd >= 0) { + close(sockfd); + sockfd = -1; + } + if (async_sockfd >= 0) { + close(async_sockfd); + async_sockfd = -1; + } + DRM_CLIENT_LOG("Closed sockets!!"); +} + +/** + * Private function + * + * + * @param[in] callinfo Callback information + * @return void + * @remarks + * @see + * @since 0.1 + */ +void __search_client_info_cb(drm_client_cb_data_s* callinfo) +{ + int i = 0; + for (i = 0; i < DRM_MAX_CLIENT_SUPPORTED; i++) { + + DRM_CLIENT_LOG("client_cb_info[i].client_id = %d", client_cb_info[i].client_id); + DRM_CLIENT_LOG("callinfo->client_id = %d", callinfo->client_id); + + if (client_cb_info[i].client_id == callinfo->client_id) { + if (client_cb_info[i].operation_callback.callback) { + + client_cb_info[i].operation_callback.callback( + &callinfo->callback_operation_info, + &callinfo->call_bk_data); + } else { + DRM_CLIENT_EXCEPTION("Callback function is NULL here!!!!"); + } + /* Callback found, return from here */ + return; + } + } + + if (DRM_MAX_CLIENT_SUPPORTED == i) { + /* Client information for the process not yet stored */ + DRM_CLIENT_EXCEPTION("Callback information not stored!!, i = %d", i); + return; + } +} + +/** + * Private function + * Thread handler + * + * @param[in] thread_arg Thread argument + * @return void + * @remarks + * @see + * @since 0.1 + */ +void *client_async_cb_handler(void *thread_arg) { + drm_client_cb_data_s callinfo; + int retval = 0, result = 0; + + /* This Async thread will be running for the entire process alive time + * to handle all the async related operations sent from the server + */ + while (1) { + memset(&callinfo, 0x00, sizeof(drm_client_cb_data_s)); + retval = read(async_sockfd, &callinfo, sizeof(drm_client_cb_data_s)); + if (0 == retval) { + DRM_CLIENT_LOG("Read returns 0!, retval = %d", retval); + DRM_CLIENT_LOG("Server end closed!!!!"); + /* Since server end closes + * async socket creation needs to be done again + */ + goto ErrorExit; + } else if (retval < 0 || retval < sizeof(drm_client_cb_data_s)) { + DRM_CLIENT_EXCEPTION( + " Async call_back read error!!, retval = %d, error = %s", + retval, strerror(errno)); + } + + DRM_CLIENT_LOG( + "Calling application call back function from client, retval = %d", + retval); + /* Search the client cb info from the received client_id and call corresponding handler */ + __search_client_info_cb(&callinfo); + } + +ErrorExit: + pthread_mutex_lock(&async_mutex); + if (async_sockfd >= 0) { + close(async_sockfd); + async_sockfd = -1; + } + pthread_mutex_unlock(&async_mutex); + return NULL; +} + + + +/** + * Private function + * Create Async socket + * + * @param[in] client_in Client request data + * @return void + * @remarks + * @see + * @since 0.1 + */ +static int __create_async_socket(drm_request_data_s *client_in) +{ + struct sockaddr_un clientaddr; + int temp_len_sock = 0; + int retval = 0; + drm_result_e result = DRM_RETURN_SUCCESS; + pthread_t async_thread = 0; + int rv = 0; + /* Create a Async socket */ + if ((async_sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) + { + DRM_CLIENT_EXCEPTION("socket error!!, async_sockfd = %d, error = %s",async_sockfd, strerror(errno)); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG(" async_sockfd created successful , async_sockfd = %d",async_sockfd); + + temp_len_sock = strlen(DRM_SOCK_PATH); + memset(&clientaddr, 0x00, sizeof(clientaddr)); + clientaddr.sun_family = AF_UNIX; + memcpy(clientaddr.sun_path, DRM_SOCK_PATH, temp_len_sock); + clientaddr.sun_path[temp_len_sock] = '\0'; + + /* connect to the server, on same server SOCK_PATH */ + if ((retval = connect(async_sockfd, (struct sockaddr*) &clientaddr,sizeof(clientaddr))) < 0) + { + DRM_CLIENT_EXCEPTION("Async socket connect error!!, retval = %d, error = %s",retval, strerror(errno)); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("async_sockfd Connection success retval=%d ", retval); + + /* Store the necessary information into the client info and send to server */ + client_info.p_id = getpid(); + client_info.thread_id = pthread_self(); + client_info.client_id = client_info.p_id + client_info.thread_id; + DRM_CLIENT_LOG("Client_id = %d", client_info.client_id); + client_info.sync_sock_fd = -1; + client_info.async_sock_fd = async_sockfd; + + /* Send the server */ + if ((retval = write(async_sockfd, (char*) &client_info,sizeof(client_info))) < 0|| retval < sizeof(client_info)) + { + DRM_CLIENT_EXCEPTION("Async write error!!, retval = %d, error = %s",retval, strerror(errno)); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("async_sockfd Sent info to server"); + + /* Separate thread is created to handle async callback handling */ + rv = pthread_create(&async_thread, NULL, client_async_cb_handler, NULL); + if (rv != 0) { + DRM_CLIENT_EXCEPTION("pthread_create creation failed for Async socket"); + goto ErrorExit; + } + DRM_CLIENT_LOG("pthread_create success = [%d]", async_thread); + DRM_CLIENT_LOG("Async socket create success"); + return 1; + +ErrorExit: + /* Prevent: 35135 [h.shekar]*/ + if(async_sockfd >= 0) { + close(async_sockfd); + async_sockfd = -1; + } + return 0; +} + +/** + * Private function + * Create Sync socket + * + * @param[in] client_in Client request data + * @return void + * @remarks + * @see + * @since 0.1 + */ +static int __get_socket(drm_request_data_s *client_in) +{ + int fd; + int temp_len_sock = 0; + int retval = 0; + struct sockaddr_un clientaddr; + static int num_clients = 0; + + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { + DRM_CLIENT_EXCEPTION("sockfd socket create error!!, sockfd = %d, error = %s",fd, strerror(errno)); + goto ErrorExit; + } + DRM_CLIENT_LOG(" sockfd created successful , sockfd = %d",fd); + + /* Set parameters to be used in connect */ + temp_len_sock = strlen(DRM_SOCK_PATH); + memset(&clientaddr, 0x00, sizeof(clientaddr)); + clientaddr.sun_family = AF_UNIX; + memcpy(clientaddr.sun_path, DRM_SOCK_PATH, temp_len_sock); + clientaddr.sun_path[temp_len_sock] = '\0'; + + if ((retval = connect(fd, (struct sockaddr*)&clientaddr,sizeof(clientaddr))) < 0) + { + DRM_CLIENT_EXCEPTION("connect error!!, retval = %d, error = %s",retval, strerror(errno)); + goto ErrorExit; + } + DRM_CLIENT_LOG("sync socket is created sockfd = %d retval = %d",fd,retval); + + client_info.p_id = getpid(); + client_info.thread_id = pthread_self(); + client_info.client_id = client_info.p_id + client_info.thread_id; + DRM_CLIENT_LOG("Client_id = %d", client_info.client_id); + client_info.sync_sock_fd = fd; + client_info.async_sock_fd = async_sockfd; + + DRM_CLIENT_LOG("Writing socket sockfd = %d size=%d",fd,sizeof(client_info)); + + DRM_CLIENT_LOG("client_info.client_id before send = %d", client_info.client_id); + if ((retval = write(fd, (char*) &client_info,sizeof(client_info))) < 0 || retval < sizeof(client_info)) + { + DRM_CLIENT_EXCEPTION("write error!!, retval = %d, error = %s",retval, strerror(errno)); + goto ErrorExit; + } + DRM_CLIENT_LOG("Written socket sockfd = %d retval=%d",fd,retval); + return fd; + +ErrorExit: + + /* Prevent: 35135 [h.shekar]*/ + if (fd >= 0) + close(fd); + + return -1; +} + +/** + * This API is used to send a request to the Server to call corresponding API + * + * @param[in] client_in Carries the input parameters of Client API to Server + * @param[out] server_out Carries the output parameters of Client API from Server + * @return 0 on success & other values on failure + * @remarks + * @see + * @since 0.1 + */ +int drm_client_comm(drm_request_data_s *client_in, drm_response_data_s *server_out) +{ + int retval = 0; + drm_request_data_s send_data; + drm_response_data_s recv_data; + drm_result_e result = DRM_RETURN_SUCCESS; + unsigned int offset = 0; + unsigned int bytes_write = DRM_MAX_CHUNK_SIZE; + unsigned int bytes_read = DRM_MAX_CHUNK_SIZE; + + /* memset the structures */ + memset(&send_data, 0x0, sizeof(drm_request_data_s)); + memset(&recv_data, 0x0, sizeof(drm_response_data_s)); + + DRM_CLIENT_LOG("drm_client_comm in"); + + /* Create Async socket if not created already for this process */ + pthread_mutex_lock(&async_mutex); + if (-1 == async_sockfd) { + DRM_CLIENT_LOG("Creating async socket for current process!!"); + if(!__create_async_socket(client_in)) + { + DRM_CLIENT_EXCEPTION("__create_async_socket returned error"); + pthread_mutex_unlock(&async_mutex); + goto ErrorExit; + } + } + pthread_mutex_unlock(&async_mutex); + + /* Create Sync Socket on a per thread basis */ + if (-1 == sockfd) { + DRM_CLIENT_LOG("initial sockfd = %d", sockfd); + sockfd = __get_socket(client_in); + DRM_CLIENT_LOG("after get_socket sockfd = %d", sockfd); + if (sockfd < 0) { + DRM_CLIENT_EXCEPTION("get_socket failed sockfd = %d", sockfd); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + } + + /* Store the callback on a thread basis to be handled for each client */ + DRM_CLIENT_LOG("Callback = %p", ((drm_initiator_info_s*) (client_in->fixed_data.request_data))->operation_callback.callback); + DRM_CLIENT_LOG("Client id = %d", client_info.client_id); + + if (((drm_initiator_info_s*) (client_in->fixed_data.request_data))->operation_callback.callback) { + /* Callback present, store if not yet stored + * Loop through the list checking for client id if stored */ + int loop = 0; + for (; loop < DRM_MAX_CLIENT_SUPPORTED; loop++) { + if (client_cb_info[loop].client_id == client_info.client_id) { + DRM_CLIENT_LOG("Callback info already stored!!, client_id[%d] = %d", + loop, client_cb_info[loop].client_id); + break; + } else if (client_cb_info[loop].client_id == 0) { + DRM_CLIENT_LOG("No entry for cb yet, loop = %d", loop); + DRM_CLIENT_LOG("Empty structure, storing client callback here, id = %d", client_info.client_id); + client_cb_info[loop].client_id = client_info.client_id; + memcpy(&client_cb_info[loop].operation_callback, + &(((drm_initiator_info_s*) (client_in->fixed_data.request_data))->operation_callback), + sizeof(drm_operation_cb_s)); + break; + } + } + if (DRM_MAX_CLIENT_SUPPORTED == loop) { + DRM_CLIENT_LOG("loop = %d, Maximum clients reached!!!", loop); + } + } + + /* Copy the data received from the client into local */ + memcpy(&send_data, client_in, sizeof(drm_request_data_s)); + /* First write the static structures */ + DRM_CLIENT_LOG("Writing socket sockfd = %d size=%d",sockfd,sizeof(drm_req_fixed_data_s)); + if ((retval = write(sockfd, (char*) &send_data.fixed_data,sizeof(drm_req_fixed_data_s))) < 0|| retval < sizeof(drm_req_fixed_data_s)) + { + DRM_CLIENT_EXCEPTION("write error!!, retval = %d, error = %s",retval, strerror(errno)); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("Written socket sockfd = %d retval=%d",sockfd,retval); + + /* Now send the additional data items if any */ + if (send_data.fixed_data.num_data_items > 0) { + for (unsigned int i = 0; i < send_data.fixed_data.num_data_items; i++) + { + if (send_data.fixed_data.data_length[i] > DRM_MAX_CHUNK_SIZE) + { + while (bytes_write > 0) + { + DRM_CLIENT_LOG("Writing socket sockfd = %d size=%d",sockfd,bytes_write); + if ((retval = write(sockfd,(void*)(send_data.data_items[i] + offset), bytes_write)) < 0 || retval < bytes_write) + { + DRM_CLIENT_EXCEPTION("write error!!, retval = %d, error = %s",retval, strerror(errno)); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("Written socket sockfd = %d retval=%d",sockfd,retval); + offset += DRM_MAX_CHUNK_SIZE; + bytes_write = (int)(send_data.fixed_data.data_length[i] - offset) > (int)DRM_MAX_CHUNK_SIZE ? DRM_MAX_CHUNK_SIZE :(int)(send_data.fixed_data.data_length[i] - offset); + DRM_CLIENT_LOG("offset = %d, bytes_write = %d", offset, bytes_write); + } + bytes_write = DRM_MAX_CHUNK_SIZE; + } + else + { + DRM_CLIENT_LOG("Writing socket sockfd = %d size=%d",sockfd,send_data.fixed_data.data_length[i]); + if ((retval = write(sockfd, send_data.data_items[i], send_data.fixed_data.data_length[i])) < 0 || retval < send_data.fixed_data.data_length[i]) + { + DRM_CLIENT_EXCEPTION("write error!!, retval = %d, error = %s",retval, strerror(errno)); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("Written socket sockfd = %d retval=%d",sockfd,retval); + } + } + } + /* Set offset to be used again */ + offset = 0; + /* Read the fixed data into the receive structure */ + DRM_CLIENT_LOG("Reading socket sockfd = %d size=%d",sockfd,sizeof(drm_resp_fixed_data_s)); + if ((retval = read(sockfd, (char*) &recv_data.fixed_data,sizeof(drm_resp_fixed_data_s))) < 0 || retval < sizeof(drm_resp_fixed_data_s)) + { + DRM_CLIENT_EXCEPTION("read error!!, retval = %d, error = %s",retval, strerror(errno)); + result = DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("Read socket sockfd = %d retval=%d",sockfd,retval); + if (recv_data.fixed_data.num_data_items > 0) { + for (unsigned int loop = 0; loop < recv_data.fixed_data.num_data_items; loop++) + { + /* Allocate memory for the data items */ + recv_data.data_items[loop] = (char*) malloc(recv_data.fixed_data.data_length[loop]); + if (!recv_data.data_items[loop]) { + DRM_CLIENT_EXCEPTION("Memory Allocation Error!, buf = %p",recv_data.data_items[loop]); + recv_data.fixed_data.resp_result=DRM_RETURN_INSUFFICIENT_MEMORY; + goto ErrorExit; + } + if (recv_data.fixed_data.data_length[loop] > DRM_MAX_CHUNK_SIZE) + { + while (bytes_read > 0) + { + DRM_CLIENT_LOG("Reading socket sockfd = %d size=%d",sockfd,bytes_read); + if ((retval = read(sockfd,(void*)(recv_data.data_items[loop] + offset),bytes_read)) < 0 || retval < bytes_read) + { + DRM_CLIENT_EXCEPTION("Read error!!, retval = %d, error = %s", retval,strerror(errno)); + recv_data.fixed_data.resp_result=DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("Read socket sockfd = %d retval=%d",sockfd,retval); + offset += DRM_MAX_CHUNK_SIZE; + bytes_read = (int)(recv_data.fixed_data.data_length[loop] - offset) > (int) DRM_MAX_CHUNK_SIZE ? DRM_MAX_CHUNK_SIZE :(int)(recv_data.fixed_data.data_length[loop] - offset); + DRM_CLIENT_LOG("offset = %d, bytes_read = %d", offset, bytes_read); + } + bytes_read = DRM_MAX_CHUNK_SIZE; + } + else + { + DRM_CLIENT_LOG("Reading socket sockfd = %d size=%d",sockfd,recv_data.fixed_data.data_length[loop]); + if ((retval = read(sockfd,recv_data.data_items[loop],recv_data.fixed_data.data_length[loop])) < 0 || retval < recv_data.fixed_data.data_length[loop]) + { + DRM_CLIENT_EXCEPTION("Read error!!, retval = %d, error = %s",retval, strerror(errno)); + recv_data.fixed_data.resp_result=DRM_RETURN_COMMUNICATION_ERROR; + goto ErrorExit; + } + DRM_CLIENT_LOG("Read socket sockfd = %d retval=%d",sockfd,retval); + } + } + } + /* Copy the data from the server back to the client into the output parameter */ + memcpy(server_out, &recv_data, sizeof(drm_response_data_s)); + DRM_CLIENT_LOG("drm_client_comm success!!!, result = %d", result); + return result; + + ErrorExit: + if (sockfd >= 0) { + close(sockfd); + sockfd = -1; + } + return result; +} diff --git a/test/Makefile b/test/Makefile new file mode 100755 index 0000000..b26948c --- /dev/null +++ b/test/Makefile @@ -0,0 +1,14 @@ +CXX ?= g++ +TARGETS = test_drm_client +PKGS = drm-client +LDFLAGS = `pkg-config --libs $(PKGS)` +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -Wall -Wunused-function -Wunreachable-code -ggdb3 -fno-omit-frame-pointer -rdynamic -fno-optimize-sibling-calls -fstack-protector-all + +all: $(TARGETS) + +$(TARGETS): %: %.cpp + $(CXX) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TARGETS) \ No newline at end of file diff --git a/test/test_drm_client.cpp b/test/test_drm_client.cpp new file mode 100755 index 0000000..9a39af0 --- /dev/null +++ b/test/test_drm_client.cpp @@ -0,0 +1,995 @@ +/* + * drm-client test utility + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * Mahendra Kumar Prajapat + * Harsha Shekar + * + * + * 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 test_drm_client.cpp + * @brief Test case implementation specific to DRM Client APIs. + * @author Mahendra Kumar Prajapat (mahendra.p@samsung.com) + * @author Harsha Shekar (h.shekar@samsung.com) + * @version 0.1 + * @history 0.1: First version of DRM Client test utility. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "drm_client.h" + +#define drm_client_tid() (long int)syscall(__NR_gettid) +#define DRM_CLIENT_TEST_FILENAME(X) (strrchr((char*)(X), '/') ? (char*)(strrchr((char*)(X), '/') + 1) : ((char*)(X)) ) + +#define DRM_CLIENT_TEST_LOG(FMT, ARG...) do{\ + fprintf(stderr,"[PID=%ld]:[TID=%ld]:[%s:%s:%d]:",(long int)getpid(),drm_client_tid(),DRM_CLIENT_TEST_FILENAME(__FILE__),__func__,__LINE__); \ + fprintf(stderr,FMT,##ARG); \ + fprintf(stderr,"\n"); \ + } while(0); + +#define DRM_CLIENT_TEST_EXCEPTION(FMT, ARG...) do{\ + fprintf(stderr,"[PID=%ld]:[TID=%ld]:[%s:%s:%d]:",(long int)getpid(),drm_client_tid(),DRM_CLIENT_TEST_FILENAME(__FILE__),__func__,__LINE__); \ + fprintf(stderr,"[ERROR]"FMT,##ARG); \ + fprintf(stderr,"\n"); \ + } while(0); + +enum { + DRM_CLIENT_TEST_NONE, + DRM_CLIENT_TEST_is_drm_file, + DRM_CLIENT_TEST_get_file_type, + DRM_CLIENT_TEST_get_license_status, + DRM_CLIENT_TEST_get_content_info, + DRM_CLIENT_TEST_get_file_info, + DRM_CLIENT_TEST_get_constraint_info, + DRM_CLIENT_TEST_is_action_allowed, + DRM_CLIENT_TEST_get_data, + DRM_CLIENT_TEST_process_request, + DRM_CLIENT_TEST_print_return_code_values, + DRM_CLIENT_TEST_MAX +}; + +void test_operation_cb(drm_user_operation_info_s *operation_info, + void *output_data) +{ + DRM_CLIENT_TEST_LOG("Callback HIT"); +} + +int test_case(int option) +{ + DRM_CLIENT_TEST_LOG("option=[%d]", option); + + switch (option) { + case DRM_CLIENT_TEST_NONE: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_NONE start"); + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_NONE completed"); + break; + } + + case DRM_CLIENT_TEST_is_drm_file: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_is_drm_file start"); + + char file_path[512] = {0,}; + drm_bool_type_e is_drm_file = DRM_UNKNOWN; + int ret = -1; + + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + DRM_CLIENT_TEST_LOG("file_path = %s",file_path); + + ret = drm_is_drm_file(file_path,&is_drm_file); + DRM_CLIENT_TEST_LOG("file_path = %s ret=%d is_drm_file=%d",file_path,ret,is_drm_file); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file){ + DRM_CLIENT_TEST_LOG("file_path = %s DRM FILE",file_path); + }else{ + DRM_CLIENT_TEST_LOG("file_path = %s NOT a DRM FILE",file_path); + } + + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_is_drm_file completed"); + break; + } + + case DRM_CLIENT_TEST_get_file_type: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_file_type start"); + char file_path[512] = {0,}; + drm_file_type_e file_type = DRM_TYPE_UNDEFINED; + int ret = -1; + + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + DRM_CLIENT_TEST_LOG("file_path = %s",file_path); + + ret = drm_get_file_type(file_path,&file_type); + DRM_CLIENT_TEST_LOG("file_path = %s ret=%d file_type=%d",file_path,ret,file_type); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("file_path = %s DRM FILE type = %d",file_path,file_type); + switch(file_type){ + case DRM_TYPE_OMA_V1: /**< OMA DRM v1 file */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM FILE type = DRM_TYPE_OMA_V1 ",file_path); + break; + + case DRM_TYPE_OMA_V2: /**< OMA DRM v2 file */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM FILE type = DRM_TYPE_OMA_V2 ",file_path); + break; + + case DRM_TYPE_PLAYREADY: /**< PlayReady file */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM FILE type = DRM_TYPE_PLAYREADY ",file_path); + break; + + case DRM_TYPE_PLAYREADY_ENVELOPE: /**< PlayReady Envelope file */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM FILE type = DRM_TYPE_PLAYREADY_ENVELOPE ",file_path); + break; + + case DRM_TYPE_DIVX: /**< DivX file */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM FILE type = DRM_TYPE_DIVX ",file_path); + break; + + default: + DRM_CLIENT_TEST_LOG("file_path = %s Unkown DRM FILE type = %d",file_path,file_type); + } + + }else{ + DRM_CLIENT_TEST_LOG("file_path = %s Unknown DRM type",file_path); + } + + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_file_type completed"); + break; + } + + case DRM_CLIENT_TEST_get_license_status: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_license_status start"); + + char file_path[512] = {0,}; + drm_permission_type_e perm_type; + drm_license_status_e license_status = DRM_LICENSE_STATUS_UNDEFINED; + int ret = -1; + + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + + DRM_CLIENT_TEST_LOG("Enter permission type"); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_NONE",DRM_PERMISSION_TYPE_NONE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_ANY",DRM_PERMISSION_TYPE_ANY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_PLAY",DRM_PERMISSION_TYPE_PLAY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_COLLABORATIVE_PLAY",DRM_PERMISSION_TYPE_COLLABORATIVE_PLAY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_DISPLAY",DRM_PERMISSION_TYPE_DISPLAY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_EXECUTE",DRM_PERMISSION_TYPE_EXECUTE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_PRINT",DRM_PERMISSION_TYPE_PRINT); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_EXPORT_COPY",DRM_PERMISSION_TYPE_EXPORT_COPY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_EXPORT_MOVE",DRM_PERMISSION_TYPE_EXPORT_MOVE); + scanf("%d", (int*)&perm_type); + DRM_CLIENT_TEST_LOG("perm_type = %d file_path=%s",perm_type,file_path); + + ret = drm_get_license_status(file_path,perm_type,&license_status); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("drm_get_license_status success:license_status=%d",license_status); + switch(license_status){ + case DRM_LICENSE_STATUS_VALID: /**< Valid License */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM_LICENSE_STATUS_VALID",file_path); + break; + + case DRM_LICENSE_STATUS_FUTURE_USE: /**< License for future use */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM_LICENSE_STATUS_FUTURE_USE",file_path); + break; + case DRM_LICENSE_STATUS_EXPIRED: /**< Expired License */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM_LICENSE_STATUS_EXPIRED",file_path); + break; + + case DRM_LICENSE_STATUS_NO_LICENSE: /**< No License */ + DRM_CLIENT_TEST_LOG("file_path = %s DRM_LICENSE_STATUS_NO_LICENSE",file_path); + break; + + default: + DRM_CLIENT_TEST_EXCEPTION("file_path = %s Unknown License Status=%d",file_path,license_status); + } + }else{ + DRM_CLIENT_TEST_EXCEPTION("drm_get_license_status failed"); + } + + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_license_status completed"); + break; + } + + case DRM_CLIENT_TEST_get_content_info: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_content_info start"); + char file_path[512] = {0,}; + drm_content_info_s content_info; + memset(&content_info,0x0,sizeof(drm_content_info_s)); + int ret = -1; + + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",file_path); + + ret = drm_get_content_info(file_path,&content_info); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("drm_get_content_info success"); + if('\0' != content_info.author[0]) DRM_CLIENT_TEST_LOG("author=%s",content_info.author); + if('\0' != content_info.copyright[0]) DRM_CLIENT_TEST_LOG("copyright=%s",content_info.copyright); + if('\0' != content_info.description[0]) DRM_CLIENT_TEST_LOG("description=%s",content_info.description); + if('\0' != content_info.icon_uri[0]) DRM_CLIENT_TEST_LOG("icon_uri=%s",content_info.icon_uri); + if('\0' != content_info.info_url[0]) DRM_CLIENT_TEST_LOG("info_url=%s",content_info.info_url); + if('\0' != content_info.content_url[0]) DRM_CLIENT_TEST_LOG("content_url=%s",content_info.content_url); + if('\0' != content_info.rights_url[0]) DRM_CLIENT_TEST_LOG("rights_url=%s",content_info.rights_url); + if('\0' != content_info.title[0]) DRM_CLIENT_TEST_LOG("title=%s",content_info.title); + if('\0' != content_info.mime_type[0]) DRM_CLIENT_TEST_LOG("mime_type=%s",content_info.mime_type); + if('\0' != content_info.content_id[0]) DRM_CLIENT_TEST_LOG("content_id=%s",content_info.content_id); + }else{ + DRM_CLIENT_TEST_EXCEPTION("drm_get_content_info failed"); + } + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_content_info completed"); + break; + } + + case DRM_CLIENT_TEST_get_file_info: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_file_info start"); + char file_path[512] = {0,}; + drm_file_info_s fileInfo; + memset(&fileInfo,0x0,sizeof(drm_file_info_s)); + int ret = -1; + + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",file_path); + + ret = drm_get_file_info(file_path,&fileInfo); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("drm_get_file_info success"); + + if(DRM_METHOD_TYPE_UNDEFINED != fileInfo.oma_info.method){ + DRM_CLIENT_TEST_LOG("OMA DRM File"); + DRM_CLIENT_TEST_LOG("method=%d",fileInfo.oma_info.method); + DRM_CLIENT_TEST_LOG("version=%d",fileInfo.oma_info.version); + }else if(0 != fileInfo.pr_env_info.org_file_size){ + DRM_CLIENT_TEST_LOG("PlayReady Envelope File"); + DRM_CLIENT_TEST_LOG("org_file_name=%s",fileInfo.pr_env_info.org_file_name); + DRM_CLIENT_TEST_LOG("org_file_size=%d",fileInfo.pr_env_info.org_file_size); + }else{ + DRM_CLIENT_TEST_LOG("Other DRM File=%s",file_path); + } + }else{ + DRM_CLIENT_TEST_EXCEPTION("drm_get_file_info failed"); + } + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_file_info completed"); + break; + } + + case DRM_CLIENT_TEST_get_constraint_info: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_constraint_info start"); + char file_path[512] = {0,}; + drm_constraint_info_s constraint_info; + drm_permission_type_e perm_type; + memset(&constraint_info,0x0,sizeof(drm_constraint_info_s)); + int ret = -1; + + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + + DRM_CLIENT_TEST_LOG("Enter permission type"); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_NONE",DRM_PERMISSION_TYPE_NONE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_ANY",DRM_PERMISSION_TYPE_ANY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_PLAY",DRM_PERMISSION_TYPE_PLAY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_COLLABORATIVE_PLAY",DRM_PERMISSION_TYPE_COLLABORATIVE_PLAY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_DISPLAY",DRM_PERMISSION_TYPE_DISPLAY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_EXECUTE",DRM_PERMISSION_TYPE_EXECUTE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_PRINT",DRM_PERMISSION_TYPE_PRINT); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_EXPORT_COPY",DRM_PERMISSION_TYPE_EXPORT_COPY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_PERMISSION_TYPE_EXPORT_MOVE",DRM_PERMISSION_TYPE_EXPORT_MOVE); + scanf("%d", (int*)&perm_type); + DRM_CLIENT_TEST_LOG("perm_type = %d file_path=%s",perm_type,file_path); + + ret = drm_get_constraint_info(file_path,perm_type,&constraint_info); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("drm_get_constraint_info success"); + + if(constraint_info.const_type.is_unlimited){ + DRM_CLIENT_TEST_LOG("Unlimited:for permission=%d",perm_type); + break; + } + + if(constraint_info.const_type.is_accumulated){ + DRM_CLIENT_TEST_LOG("Accumulated Constraint is present"); + DRM_CLIENT_TEST_LOG("accumulated_original_seconds=%d", + constraint_info.accumulated_original_seconds); + DRM_CLIENT_TEST_LOG("accumulated_remaining_seconds=%d", + constraint_info.accumulated_remaining_seconds); + } + + if(constraint_info.const_type.is_count){ + DRM_CLIENT_TEST_LOG("Count Constraint is present"); + DRM_CLIENT_TEST_LOG("original_count=%d", + constraint_info.original_count); + DRM_CLIENT_TEST_LOG("remaining_count=%d", + constraint_info.remaining_count); + } + + if(constraint_info.const_type.is_datetime){ + DRM_CLIENT_TEST_LOG("DATETIME Constraint is present"); + DRM_CLIENT_TEST_LOG("start_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.start_time.tm_year, + constraint_info.start_time.tm_mon, + constraint_info.start_time.tm_mday, + constraint_info.start_time.tm_hour, + constraint_info.start_time.tm_min, + constraint_info.start_time.tm_sec); + + DRM_CLIENT_TEST_LOG("end_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.end_time.tm_year, + constraint_info.end_time.tm_mon, + constraint_info.end_time.tm_mday, + constraint_info.end_time.tm_hour, + constraint_info.end_time.tm_min, + constraint_info.end_time.tm_sec); + } + + if(constraint_info.const_type.is_individual){ + DRM_CLIENT_TEST_LOG("INDIVIDUAL Constraint is present"); + DRM_CLIENT_TEST_LOG("individual_identity_type=%d " + "individual_id=%s", + constraint_info.individual_identity_type, + constraint_info.individual_id); + + } + + if(constraint_info.const_type.is_interval){ + DRM_CLIENT_TEST_LOG("INTERVAL Constraint is present"); + DRM_CLIENT_TEST_LOG("interval_time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + constraint_info.interval_time.tm_year, + constraint_info.interval_time.tm_mon, + constraint_info.interval_time.tm_mday, + constraint_info.interval_time.tm_hour, + constraint_info.interval_time.tm_min, + constraint_info.interval_time.tm_sec); + } + + if(constraint_info.const_type.is_system){ + DRM_CLIENT_TEST_LOG("SYSTEM Constraint is present"); + DRM_CLIENT_TEST_LOG("system_identity_type=%d " + "system_id=%s", + constraint_info.system_identity_type, + constraint_info.system_id); + + } + + if(constraint_info.const_type.is_timedcount){ + DRM_CLIENT_TEST_LOG("TIMED-COUNT Constraint is present"); + DRM_CLIENT_TEST_LOG("timed_original_count=%d", + constraint_info.timed_original_count); + + DRM_CLIENT_TEST_LOG("timed_remaining_count=%d", + constraint_info.timed_remaining_count); + + DRM_CLIENT_TEST_LOG("timed_count_timer=%d", + constraint_info.timed_count_timer); + } + }else{ + DRM_CLIENT_TEST_EXCEPTION("drm_get_constraint_info failed"); + } + + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_constraint_info completed"); + break; + } + + case DRM_CLIENT_TEST_is_action_allowed: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_is_action_allowed start"); + + drm_bool_type_e is_allowed = DRM_UNKNOWN; + drm_action_type_e action = DRM_ACTION_UNDEFINED; + drm_action_allowed_data_s action_data; + int ret = -1; + memset(&action_data,0x0,sizeof(drm_action_allowed_data_s)); + + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", action_data.file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",action_data.file_path); + + DRM_CLIENT_TEST_LOG("Enter the action to be performed!"); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_ACTION_UNDEFINED", + DRM_ACTION_UNDEFINED); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_IS_FORWARDING_ALLOWED", + DRM_IS_FORWARDING_ALLOWED); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_HAS_VALID_SETAS_STATUS", + DRM_HAS_VALID_SETAS_STATUS); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_IS_DEVICE_ACTIVATED", + DRM_IS_DEVICE_ACTIVATED); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_IS_VALID_SECURE_CLOCK", + DRM_IS_VALID_SECURE_CLOCK); + + scanf("%d", (int*)&action); + + DRM_CLIENT_TEST_LOG("Action entered = %d", action); + + ret = drm_is_action_allowed(action,&action_data,&is_allowed); + if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){ + DRM_CLIENT_TEST_LOG("Action=%d is allowed",action); + }else{ + DRM_CLIENT_TEST_EXCEPTION("drm_is_action_allowed failed"); + } + + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_is_action_allowed completed"); + break; + } + + case DRM_CLIENT_TEST_get_data: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_data start"); + char file_path[512] = {0,}; + int ret = -1; + drm_data_type_e data_type = DRM_DATA_TYPE_NONE; + + DRM_CLIENT_TEST_LOG("Enter the data type to be received"); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_DATA_TYPE_SECURE_CLOCK", + DRM_DATA_TYPE_SECURE_CLOCK); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG", + DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_DATA_TYPE_TRANSACTION_TRACKING_ID", + DRM_DATA_TYPE_TRANSACTION_TRACKING_ID); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_DATA_TYPE_DIVX_REGISTRATION_CODE", + DRM_DATA_TYPE_DIVX_REGISTRATION_CODE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE", + DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE); + + scanf("%d", (int*)&data_type); + DRM_CLIENT_TEST_LOG("Data type received=%d",data_type); + + if(DRM_DATA_TYPE_TRANSACTION_TRACKING_ID == data_type){ + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",file_path); + } + + switch(data_type){ + case DRM_DATA_TYPE_SECURE_CLOCK: + { + DRM_CLIENT_TEST_LOG("Get DRM_DATA_TYPE_SECURE_CLOCK"); + drm_secure_clock_data_s secure_clock_info={0}; + ret = drm_get_data(data_type,NULL,(void*)&secure_clock_info); + DRM_CLIENT_TEST_LOG("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret + && 1 == secure_clock_info.is_secure_clock_set){ + DRM_CLIENT_TEST_LOG("Secure Clock is SET:ret=0x%x",ret); + DRM_CLIENT_TEST_LOG("Secure Time:" + "Year=%d,Month=%d,Day=%d,Hour=%d, minute=%d, Second=%d", + secure_clock_info.secure_clock.tm_year, + secure_clock_info.secure_clock.tm_mon, + secure_clock_info.secure_clock.tm_mday, + secure_clock_info.secure_clock.tm_hour, + secure_clock_info.secure_clock.tm_min, + secure_clock_info.secure_clock.tm_sec); + }else if(DRM_RETURN_SUCCESS == ret + && 0 == secure_clock_info.is_secure_clock_set){ + DRM_CLIENT_TEST_LOG("Secure Clock is NOT SET:ret=0x%x",ret); + }else{ + DRM_CLIENT_TEST_LOG("Secure Clock Retrieval FAILED:ret=0x%x",ret); + } + break; + } + + case DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG: + { + DRM_CLIENT_TEST_LOG("Get DRM_DATA_TYPE_TRANSACTION_TRACKING_FLAG"); + + int transtrk_flag = 0; + ret = drm_get_data(data_type, NULL, (void*)&transtrk_flag); + DRM_CLIENT_TEST_LOG("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("transtrk_flag = %d", transtrk_flag); + } else { + DRM_CLIENT_TEST_LOG("Get Transaction Tracking Flag failed!!, " + "ret = 0x%x", ret); + } + + break; + } + + case DRM_DATA_TYPE_TRANSACTION_TRACKING_ID: + { + DRM_CLIENT_TEST_LOG("Get DRM_DATA_TYPE_TRANSACTION_TRACKING_ID"); + drm_transaction_id_info_s transaction_id_info={"",0}; + ret = drm_get_data(data_type,(void*)file_path,(void*)&transaction_id_info); + DRM_CLIENT_TEST_LOG("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("Transaction ID Length =%d", + transaction_id_info.tr_id_len); + if(0 != transaction_id_info.tr_id_len){ + DRM_CLIENT_TEST_LOG("Transaction ID =%s", + transaction_id_info.tr_id); + } + }else{ + DRM_CLIENT_TEST_EXCEPTION("Transaction ID Retrieval FAILED:ret=0x%x",ret); + } + break; + } + + case DRM_DATA_TYPE_DIVX_REGISTRATION_CODE: + { + DRM_CLIENT_TEST_LOG("Get DRM_DATA_TYPE_DIVX_REGISTRATION_CODE"); + + drm_code_info_s reg_code_info = {"",0}; + ret = drm_get_data(data_type, NULL, (void*) ®_code_info); + DRM_CLIENT_TEST_LOG("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("Code Length = %d", reg_code_info.code_len); + if (0 != reg_code_info.code_len) { + DRM_CLIENT_TEST_LOG("Code = %s", reg_code_info.code); + } + } else { + DRM_CLIENT_TEST_EXCEPTION("Divx Registration Code failed!!"); + } + break; + } + + case DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE: + { + DRM_CLIENT_TEST_LOG("Get DRM_DATA_TYPE_DIVX_DEREGISTRATION_CODE"); + + drm_code_info_s dereg_code_info = {"",0}; + ret = drm_get_data(data_type, NULL, (void*) &dereg_code_info); + DRM_CLIENT_TEST_LOG("ret=0x%x", ret); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("Code Length = %d", dereg_code_info.code_len); + if (0 != dereg_code_info.code_len) { + DRM_CLIENT_TEST_LOG("Code = %s", dereg_code_info.code); + } + } else { + DRM_CLIENT_TEST_EXCEPTION("Divx Registration Code failed!!"); + } + + break; + } + + default: + DRM_CLIENT_TEST_EXCEPTION("Unsupported data type=%d",data_type); + } + + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_get_data completed"); + break; + } + + case DRM_CLIENT_TEST_process_request: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_process_request start"); + char file_path[512] = {0,}; + int ret = DRM_RETURN_SUCCESS; + drm_request_type_e request_type = DRM_REQUEST_TYPE_NONE; + + DRM_CLIENT_TEST_LOG("Enter the request type to be processed"); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_REGISTER_FILE",DRM_REQUEST_TYPE_REGISTER_FILE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_UNREGISTER_FILE",DRM_REQUEST_TYPE_UNREGISTER_FILE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES",DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_REGISTER_LICENSE",DRM_REQUEST_TYPE_REGISTER_LICENSE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL",DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE",DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT",DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_HTTP_USER_CANCEL",DRM_REQUEST_TYPE_HTTP_USER_CANCEL); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_REGISTER_COPY_FILE",DRM_REQUEST_TYPE_REGISTER_COPY_FILE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_REGISTER_MOVE_FILE",DRM_REQUEST_TYPE_REGISTER_MOVE_FILE); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_INSERT_EXT_MEMORY",DRM_REQUEST_TYPE_INSERT_EXT_MEMORY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY",DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_REGISTER_SETAS",DRM_REQUEST_TYPE_REGISTER_SETAS); + DRM_CLIENT_TEST_LOG(" %d ==> DRM_REQUEST_TYPE_UNREGISTER_SETAS",DRM_REQUEST_TYPE_UNREGISTER_SETAS); + + scanf("%d", (int*)&request_type); + DRM_CLIENT_TEST_LOG("request_type received=%d",request_type); + + switch(request_type){ + case DRM_REQUEST_TYPE_REGISTER_FILE: + { + DRM_CLIENT_TEST_LOG("Request for Register file"); + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%511s", file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",file_path); + + ret = drm_process_request(request_type,(void*)file_path,NULL); + DRM_CLIENT_TEST_LOG("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("Register success:file_path=%s", + file_path); + }else{ + DRM_CLIENT_TEST_EXCEPTION("Register FAILED:ret=0x%x file_path=%s", + ret,file_path); + } + break; + } + + case DRM_REQUEST_TYPE_UNREGISTER_FILE: + { + DRM_CLIENT_TEST_LOG("Request for Un-register file"); + drm_unregister_info_s unregister_info={"",0}; + DRM_CLIENT_TEST_LOG("Enter complete file name with path"); + scanf("%255s", unregister_info.file_path); + + DRM_CLIENT_TEST_LOG("Enter 1 if you want to remove License also"); + DRM_CLIENT_TEST_LOG("Enter 0 if you don't want to remove License"); + scanf("%d", &unregister_info.remove_license); + DRM_CLIENT_TEST_LOG("file_path=%s remove_license=%d", + unregister_info.file_path,unregister_info.remove_license); + + ret = drm_process_request(request_type,(void*)&unregister_info,NULL); + DRM_CLIENT_TEST_LOG("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("Un-register success:file_path=%s", + unregister_info.file_path); + }else{ + DRM_CLIENT_TEST_EXCEPTION("Un-register FAILED:ret=0x%x " + "file_path=%s",ret,unregister_info.file_path); + } + break; + } + + case DRM_REQUEST_TYPE_UNREGISTER_ALL_FILES: + { + DRM_CLIENT_TEST_LOG("Request for Un-register all files"); + ret = drm_process_request(request_type,NULL,NULL); + DRM_CLIENT_TEST_LOG("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("Un-register All files success"); + }else{ + DRM_CLIENT_TEST_EXCEPTION("Un-register All files FAILED:" + "ret=0x%x",ret); + } + break; + } + + case DRM_REQUEST_TYPE_REGISTER_LICENSE: + { + DRM_CLIENT_TEST_LOG("Request for Register License"); + drm_register_lic_info_s lic_req_info={"",0,}; + drm_register_lic_resp_s lic_resp_info={""}; + struct stat stat_buf = { 0 }; + FILE *fp = NULL; + unsigned int read_len=0; + char *tempPath = NULL; + + DRM_CLIENT_TEST_LOG("Enter LICENSE file (*.dr/*.drc) with path"); + scanf("%511s", file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",file_path); + + if (0 == stat(file_path, &stat_buf)) { + lic_req_info.lic_data_len = stat_buf.st_size; + DRM_CLIENT_TEST_LOG("file_path=%s file_size=%u",file_path, + lic_req_info.lic_data_len); + } else { + DRM_CLIENT_TEST_EXCEPTION("stat failed:error=%s file_path=%s", + strerror(errno),file_path); + break; + } + + fp = fopen(file_path,"r"); + if(NULL == fp){ + DRM_CLIENT_TEST_EXCEPTION("fopen failed:error=%s file_path=%s", + strerror(errno),file_path); + break; + } + + memset(lic_req_info.lic_data,0x0,sizeof(lic_req_info.lic_data)); + read_len = fread(lic_req_info.lic_data,1,lic_req_info.lic_data_len,fp); + DRM_CLIENT_TEST_LOG("read_len=%u lic_req_info.lic_data_len=%u", + read_len,lic_req_info.lic_data_len); + + fclose(fp); + + tempPath = strrchr((char *)file_path, '.'); + if(strncmp(tempPath, ".dr", 2) == 0 + || strncmp(tempPath, ".drc", 3) == 0){ + DRM_CLIENT_TEST_LOG("DRM v1 License file"); + + lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS; + lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_UNKNOWN; + lic_req_info.operation_callback.callback = test_operation_cb; + + ret = drm_process_request(request_type,(void*)&lic_req_info, + (void*)&lic_resp_info); + DRM_CLIENT_TEST_LOG("ret=0x%x",ret); + if(DRM_RETURN_SUCCESS == ret){ + DRM_CLIENT_TEST_LOG("Register License success"); + DRM_CLIENT_TEST_LOG("CID=%s",lic_resp_info.cid); + }else{ + DRM_CLIENT_TEST_EXCEPTION("Register License FAILED:" + "ret=0x%x",ret); + } + } + + break; + } + + case DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL: + { + DRM_CLIENT_TEST_LOG("Request for Initiator URL processing"); + + drm_initiator_info_s initiator_info = {"",0,}; + drm_web_server_resp_data_s ws_resp_data = {"",}; + + /* Get the input parameters */ + DRM_CLIENT_TEST_LOG("Enter the initiator URL"); + scanf("%512s", initiator_info.initiator_url); + initiator_info.initiator_url_len = strlen(initiator_info.initiator_url); + initiator_info.operation_callback.callback = test_operation_cb; + + ret = drm_process_request(request_type, (void*) &initiator_info, + (void*) &ws_resp_data); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("Server Error Code = %d", + ws_resp_data.result_code); + DRM_CLIENT_TEST_LOG("Content URL = %s", + ws_resp_data.content_url); + } else { + DRM_CLIENT_TEST_EXCEPTION("Submit Initiator URL Failed!!, ret = 0x%x", ret); + } + + break; + } + + case DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_SUBMIT_ROAP_MESSAGE"); + drm_submit_roap_message_info_s message_info; + memset(&message_info,0x0,sizeof(drm_submit_roap_message_info_s)); + ret = drm_process_request(request_type,(void *)&message_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("SUBMIT_ROAP_MESSAGE success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("SUBMIT_ROAP_MESSAGE Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_SUBMIT_ROAP_USER_CONSENT"); + drm_submit_roap_user_consent_info_s user_consent_info; + memset(&user_consent_info,0x0,sizeof(drm_submit_roap_user_consent_info_s)); + ret = drm_process_request(request_type,(void *)&user_consent_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("SUBMIT_ROAP_USER_CONSENT success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("SUBMIT_ROAP_USER_CONSENT Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_HTTP_USER_CANCEL: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_HTTP_USER_CANCEL"); + drm_http_user_cancel_info_s user_cancel_info; + memset(&user_cancel_info,0x0,sizeof(drm_http_user_cancel_info_s)); + ret = drm_process_request(request_type,(void *)&user_cancel_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("HTTP_USER_CANCEL success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("HTTP_USER_CANCEL Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_REGISTER_COPY_FILE: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_REGISTER_COPY_FILE"); + drm_register_copy_file_info_s copy_file_info; + memset(©_file_info,0x0,sizeof(drm_register_copy_file_info_s)); + + DRM_CLIENT_TEST_LOG("Enter Source file with path"); + scanf("%255s", copy_file_info.src_file_path); + DRM_CLIENT_TEST_LOG("src_file_path=%s",copy_file_info.src_file_path); + + DRM_CLIENT_TEST_LOG("Enter Destination file with path"); + scanf("%255s", copy_file_info.dest_file_path); + DRM_CLIENT_TEST_LOG("dest_file_path=%s",copy_file_info.dest_file_path); + + ret = drm_process_request(request_type,(void *)©_file_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("REGISTER_COPY_FILE success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("REGISTER_COPY_FILE Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_REGISTER_MOVE_FILE: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_REGISTER_MOVE_FILE"); + drm_register_copy_file_info_s copy_file_info; + memset(©_file_info,0x0,sizeof(drm_register_copy_file_info_s)); + + DRM_CLIENT_TEST_LOG("Enter Source file with path"); + scanf("%255s", copy_file_info.src_file_path); + DRM_CLIENT_TEST_LOG("src_file_path=%s",copy_file_info.src_file_path); + + DRM_CLIENT_TEST_LOG("Enter Destination file with path"); + scanf("%255s", copy_file_info.dest_file_path); + DRM_CLIENT_TEST_LOG("dest_file_path=%s",copy_file_info.dest_file_path); + + ret = drm_process_request(request_type,(void *)©_file_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("REGISTER_MOVE_FILE success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("REGISTER_MOVE_FILE Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_INSERT_EXT_MEMORY: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_INSERT_EXT_MEMORY"); + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("INSERT_EXT_MEMORY success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("INSERT_EXT_MEMORY Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_EXTRACT_EXT_MEMORY"); + ret = drm_process_request(request_type,NULL,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("INSERT_EXT_MEMORY success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("INSERT_EXT_MEMORY Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_REGISTER_SETAS: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_REGISTER_SETAS"); + drm_register_setas_info_s setas_info; + memset(&setas_info,0x0,sizeof(drm_register_setas_info_s)); + + DRM_CLIENT_TEST_LOG("Enter file name with path to be set"); + scanf("%255s", setas_info.file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",setas_info.file_path); + + DRM_CLIENT_TEST_LOG("Enter SETAS Category"); + DRM_CLIENT_TEST_LOG("Enter=%d -> DRM_SETAS_WALLPAPER",DRM_SETAS_WALLPAPER); + DRM_CLIENT_TEST_LOG("Enter=%d -> DRM_SETAS_RINGTONE",DRM_SETAS_RINGTONE); + scanf("%d", (int*)&setas_info.setas_cat); + DRM_CLIENT_TEST_LOG("setas_cat=%d",setas_info.setas_cat); + + ret = drm_process_request(request_type,(void *)&setas_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("REGISTER_SETAS success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("REGISTER_SETAS Failed!!, ret = 0x%x", ret); + } + break; + } + + case DRM_REQUEST_TYPE_UNREGISTER_SETAS: + { + DRM_CLIENT_TEST_LOG("DRM_REQUEST_TYPE_UNREGISTER_SETAS"); + drm_unregister_setas_info_s setas_info; + memset(&setas_info,0x0,sizeof(drm_unregister_setas_info_s)); + + DRM_CLIENT_TEST_LOG("Enter file name with path to be set"); + scanf("%255s", setas_info.file_path); + DRM_CLIENT_TEST_LOG("file_path=%s",setas_info.file_path); + + DRM_CLIENT_TEST_LOG("Enter SETAS Category"); + DRM_CLIENT_TEST_LOG("Enter=%d -> DRM_SETAS_WALLPAPER",DRM_SETAS_WALLPAPER); + DRM_CLIENT_TEST_LOG("Enter=%d -> DRM_SETAS_RINGTONE",DRM_SETAS_RINGTONE); + scanf("%d", (int*)&setas_info.setas_cat); + DRM_CLIENT_TEST_LOG("setas_cat=%d",setas_info.setas_cat); + + ret = drm_process_request(request_type,(void *)&setas_info,NULL); + if (DRM_RETURN_SUCCESS == ret) { + DRM_CLIENT_TEST_LOG("UNREGISTER_SETAS success"); + } else { + DRM_CLIENT_TEST_EXCEPTION("UNREGISTER_SETAS Failed!!, ret = 0x%x", ret); + } + break; + } + + default: + DRM_CLIENT_TEST_EXCEPTION("Unsupported request_type=%d",request_type); + } + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_process_request completed"); + break; + } + + case DRM_CLIENT_TEST_print_return_code_values: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_print_return_code_values Start"); + DRM_CLIENT_TEST_LOG("DRM_RETURN_SUCCESS=%d=0x%x",DRM_RETURN_SUCCESS,DRM_RETURN_SUCCESS); + DRM_CLIENT_TEST_LOG("DRM_RETURN_INVALID_ARG=%d=0x%x",DRM_RETURN_INVALID_ARG,DRM_RETURN_INVALID_ARG); + DRM_CLIENT_TEST_LOG("DRM_RETURN_INSUFFICIENT_MEMORY=%d=0x%x",DRM_RETURN_INSUFFICIENT_MEMORY,DRM_RETURN_INSUFFICIENT_MEMORY); + DRM_CLIENT_TEST_LOG("DRM_RETURN_PARSING_ERROR=%d=0x%x",DRM_RETURN_PARSING_ERROR,DRM_RETURN_PARSING_ERROR); + DRM_CLIENT_TEST_LOG("DRM_RETURN_DB_ERROR=%d=0x%x",DRM_RETURN_DB_ERROR,DRM_RETURN_DB_ERROR); + DRM_CLIENT_TEST_LOG("DRM_RETURN_FILE_ERROR=%d=0x%x",DRM_RETURN_FILE_ERROR,DRM_RETURN_FILE_ERROR); + DRM_CLIENT_TEST_LOG("DRM_RETURN_COMMUNICATION_ERROR=%d=0x%x",DRM_RETURN_COMMUNICATION_ERROR,DRM_RETURN_COMMUNICATION_ERROR); + DRM_CLIENT_TEST_LOG("DRM_RETURN_INTERNAL_ERROR=%d=0x%x",DRM_RETURN_INTERNAL_ERROR,DRM_RETURN_INTERNAL_ERROR); + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_print_return_code_values Completed"); + break; + } + + case DRM_CLIENT_TEST_MAX: + { + DRM_CLIENT_TEST_LOG("DRM_CLIENT_TEST_MAX"); + DRM_CLIENT_TEST_LOG("SUCCESS"); + return 0; + } + + default: + DRM_CLIENT_TEST_EXCEPTION("Wrong choice=%d",option); + goto ERR; + } + + DRM_CLIENT_TEST_LOG("SUCCESS"); + return 1; + +ERR: + DRM_CLIENT_TEST_EXCEPTION("test_case:Error:Exit from DRM CLIENT Test utility"); + return 0; +} + +int main(int argc, char* argv[]) +{ + int pid = getpid(); + int choice = DRM_CLIENT_TEST_NONE; + DRM_CLIENT_TEST_LOG("main:pid=[%d]", pid); + + do { + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_NONE",DRM_CLIENT_TEST_NONE); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_is_drm_file",DRM_CLIENT_TEST_is_drm_file); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_get_file_type",DRM_CLIENT_TEST_get_file_type); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_get_license_status",DRM_CLIENT_TEST_get_license_status); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_get_content_info",DRM_CLIENT_TEST_get_content_info); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_get_file_info",DRM_CLIENT_TEST_get_file_info); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_get_constraint_info",DRM_CLIENT_TEST_get_constraint_info); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_is_action_allowed",DRM_CLIENT_TEST_is_action_allowed); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_get_data",DRM_CLIENT_TEST_get_data); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_process_request",DRM_CLIENT_TEST_process_request); + DRM_CLIENT_TEST_LOG("choice=%d -> DRM_CLIENT_TEST_print_return_code_values",DRM_CLIENT_TEST_print_return_code_values); + DRM_CLIENT_TEST_LOG("choice=%d -> Exit from TEST Script",DRM_CLIENT_TEST_MAX); + DRM_CLIENT_TEST_LOG("Enter Your choice:1 to %d:Use choice no-%d to exit the test-program",DRM_CLIENT_TEST_MAX, DRM_CLIENT_TEST_MAX); + scanf("%3d", &choice); + } while (1 == test_case(choice)); + + DRM_CLIENT_TEST_LOG("Exiting process=[%d] from main", pid); + return 0; +} -- 2.7.4