From: Sungjae Lim Date: Wed, 22 Aug 2012 05:28:28 +0000 (+0900) Subject: Update the latest source X-Git-Tag: 2.0_alpha^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=HEAD;p=platform%2Fcore%2Fapi%2Fnfc.git Update the latest source --- diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 index bbe9d02..ec68963 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +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 diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..5ddaa53 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +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 diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..72aad6c --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +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 + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config.default b/TC/config.default new file mode 100644 index 0000000..12ac1e2 --- /dev/null +++ b/TC/config.default @@ -0,0 +1,3 @@ +CAPI_PROJECT_ROOT=/home/abyss/capi +TET_INSTALL_HOST_PATH=/home/abyss/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..a4f6095 --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +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 + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100755 index 0000000..afde4ee --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,24 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-network-nfc + +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 + +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100755 index 0000000..0571a2c --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,4 @@ +/testcase/utc_network_nfc_ndef_record +/testcase/utc_network_nfc_ndef_message +/testcase/utc_network_nfc + diff --git a/TC/testcase/utc_network_nfc.c b/TC/testcase/utc_network_nfc.c new file mode 100755 index 0000000..4d2cb0d --- /dev/null +++ b/TC/testcase/utc_network_nfc.c @@ -0,0 +1,309 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +#define MY_ASSERT( fun , test , msg ) \ +{\ + if( !test ) \ + dts_fail(fun , msg ); \ +} + + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void nfc_manager_set_activation_changed_cb_p(void); +static void nfc_manager_set_activation_changed_cb_n(void); +static void nfc_manager_set_activation_p(void); +static void nfc_manager_set_activation_n(void); +static void nfc_manager_initialize_p(void); +static void nfc_manager_initialize_n(void); +static void nfc_manager_deinitialize_p(void); +static void nfc_manager_deinitialize_n(void); +static void nfc_manager_set_tag_discovered_cb_p(void); +static void nfc_manager_set_tag_discovered_cb_n(void); +static void nfc_manager_set_ndef_discovered_cb_p(void); +static void nfc_manager_set_ndef_discovered_cb_n(void); +static void nfc_manager_set_p2p_target_discovered_cb_p(void); +static void nfc_manager_set_p2p_target_discovered_cb_n(void); +static void nfc_manager_set_se_event_cb_p(void); +static void nfc_manager_set_se_event_cb_n(void); +static void nfc_manager_set_se_transaction_event_cb_p(void); +static void nfc_manager_set_se_transaction_event_cb_n(void); +static void nfc_manager_set_system_handler_enable_p(void); +static void nfc_manager_set_system_handler_enable_n(void); + + +void _activation_changed_cb(bool activated , void *user_data); +void _activation_completed_cb(int error, void *user_data); +void utc_test_cb(void * user_data); + + + + + +struct tet_testlist tet_testlist[] = { + { nfc_manager_set_activation_changed_cb_p , POSITIVE_TC_IDX }, + { nfc_manager_set_activation_changed_cb_n , NEGATIVE_TC_IDX }, + { nfc_manager_set_activation_p , POSITIVE_TC_IDX }, + { nfc_manager_set_activation_n , NEGATIVE_TC_IDX }, + { nfc_manager_initialize_p , POSITIVE_TC_IDX }, + { nfc_manager_initialize_n , NEGATIVE_TC_IDX }, + { nfc_manager_deinitialize_p , POSITIVE_TC_IDX }, + { nfc_manager_deinitialize_n , NEGATIVE_TC_IDX }, + { nfc_manager_set_tag_discovered_cb_p , POSITIVE_TC_IDX }, + { nfc_manager_set_tag_discovered_cb_n , NEGATIVE_TC_IDX }, + { nfc_manager_set_ndef_discovered_cb_p , POSITIVE_TC_IDX }, + { nfc_manager_set_ndef_discovered_cb_n , NEGATIVE_TC_IDX }, + { nfc_manager_set_p2p_target_discovered_cb_p , POSITIVE_TC_IDX }, + { nfc_manager_set_p2p_target_discovered_cb_n , NEGATIVE_TC_IDX }, + { nfc_manager_set_se_event_cb_p , POSITIVE_TC_IDX }, + { nfc_manager_set_se_event_cb_n , NEGATIVE_TC_IDX }, + { nfc_manager_set_se_transaction_event_cb_p , POSITIVE_TC_IDX }, + { nfc_manager_set_se_transaction_event_cb_n , NEGATIVE_TC_IDX }, + { nfc_manager_set_system_handler_enable_p , POSITIVE_TC_IDX }, + { nfc_manager_set_system_handler_enable_n , NEGATIVE_TC_IDX }, + + { NULL, 0 }, +}; + +//this method is called only once in start +static void startup(void) +{ + /* start of TC */ +} + +static void cleanup(void) +{ + /* end of TC */ +} + +void _activation_changed_cb(bool activated , void *user_data) +{ + if( activated == true) + { + } + else if( activated == false) + { + } +} + +void _activation_completed_cb(int error, void *user_data) +{ + error = 0; + return error; +} + +void utc_test_cb(void *user_data) +{ + return true; +} + + +static void nfc_manager_set_activation_changed_cb_p(void) +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_activation_changed_cb(_activation_changed_cb , NULL); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_activation_changed_cb_p is faild"); +} + +static void nfc_manager_set_activation_changed_cb_n(void) +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_activation_changed_cb(NULL , NULL); + + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_activation_changed_cb_n not allow null"); +} + +static void nfc_manager_set_activation_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_activation(1, _activation_completed_cb, NULL); + + dts_pass(__func__, "PASS"); +} + +static void nfc_manager_set_activation_n() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_activation(1, NULL, NULL); + + dts_pass(__func__, "PASS"); +} + +static void nfc_manager_initialize_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_initialize(NULL, NULL); + + nfc_manager_deinitialize(); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_initialize_p is faild"); +} + +static void nfc_manager_initialize_n() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_initialize(NULL, NULL); + + dts_pass(__func__, "PASS"); +} + +static void nfc_manager_deinitialize_p() +{ + int ret = NFC_ERROR_NONE; + + nfc_manager_initialize(NULL, NULL); + + ret = nfc_manager_deinitialize(); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_initialize_p is faild"); +} + +static void nfc_manager_deinitialize_n() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_deinitialize(); + + dts_pass(__func__, "PASS"); +} + +static void nfc_manager_set_tag_discovered_cb_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_tag_discovered_cb(utc_test_cb, NULL); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_tag_discovered_cb_p is faild"); +} + +static void nfc_manager_set_tag_discovered_cb_n() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_tag_discovered_cb(NULL, NULL); + + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_tag_discovered_cb_n not allow null"); +} + +static void nfc_manager_set_ndef_discovered_cb_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_ndef_discovered_cb(utc_test_cb , NULL); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_ndef_discovered_cb_p is faild"); +} + +static void nfc_manager_set_ndef_discovered_cb_n() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_ndef_discovered_cb(NULL, NULL); + + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_ndef_discovered_cb_n not allow null"); +} + +static void nfc_manager_set_p2p_target_discovered_cb_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_p2p_target_discovered_cb(utc_test_cb , NULL); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_p2p_target_discovered_cb_p is faild"); +} + +static void nfc_manager_set_p2p_target_discovered_cb_n() +{ + int ret; + + ret = nfc_manager_set_p2p_target_discovered_cb(NULL, NULL); + + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_p2p_target_discovered_cb_n not allow null"); +} + +static void nfc_manager_set_se_event_cb_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_se_event_cb(utc_test_cb , NULL); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_event_cb_p is faild"); +} + +static void nfc_manager_set_se_event_cb_n () +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_se_event_cb(NULL, NULL); + + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_event_cb_n not allow null"); +} + +static void nfc_manager_set_se_transaction_event_cb_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_se_transaction_event_cb(utc_test_cb , NULL); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_transaction_event_cb_p is faild"); +} + +static void nfc_manager_set_se_transaction_event_cb_n () +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_se_transaction_event_cb(NULL, NULL); + + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_transaction_event_cb_n not allow null"); +} + +static void nfc_manager_set_system_handler_enable_p() +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_system_handler_enable(true); + + dts_pass(__func__, "PASS"); + +} + +static void nfc_manager_set_system_handler_enable_n () +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_manager_set_system_handler_enable(NULL); + + dts_pass(__func__, "PASS"); +} diff --git a/TC/testcase/utc_network_nfc_ndef_message.c b/TC/testcase/utc_network_nfc_ndef_message.c new file mode 100755 index 0000000..45a36a6 --- /dev/null +++ b/TC/testcase/utc_network_nfc_ndef_message.c @@ -0,0 +1,282 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +#define MY_ASSERT( fun , test , msg ) \ +{\ + if( !test ) \ + dts_fail(fun , msg ); \ +} + + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_nfc_ndef_message_create_p(void); +static void utc_nfc_ndef_message_create_n(void); +static void utc_nfc_ndef_message_create_from_rawdata_p(void); +static void utc_nfc_ndef_message_create_from_rawdata_n(void); +static void utc_nfc_ndef_message_destroy_p(void); +static void utc_nfc_ndef_message_destroy_n(void); +static void utc_nfc_ndef_message_get_record_count_p(void); +static void utc_nfc_ndef_message_get_record_count_n(void); +static void utc_nfc_ndef_message_get_rawdata_p(void); +static void utc_nfc_ndef_message_get_rawdata_n(void); +static void utc_nfc_ndef_message_append_record_p(void); +static void utc_nfc_ndef_message_append_record_n(void); +static void utc_nfc_ndef_message_insert_record_p(void); +static void utc_nfc_ndef_message_insert_record_n(void); +static void utc_nfc_ndef_message_remove_record_p(void); +static void utc_nfc_ndef_message_remove_record_n(void); +static void utc_nfc_ndef_message_get_record_p(void); +static void utc_nfc_ndef_message_get_record_n(void); + + +struct tet_testlist tet_testlist[] = { + { utc_nfc_ndef_message_create_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_create_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_create_from_rawdata_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_create_from_rawdata_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_destroy_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_destroy_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_get_record_count_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_get_record_count_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_get_rawdata_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_get_rawdata_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_append_record_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_append_record_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_insert_record_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_insert_record_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_remove_record_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_remove_record_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_message_get_record_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_message_get_record_n , NEGATIVE_TC_IDX }, + + { NULL, 0 }, +}; + +//this method is called only once in start +static void startup(void) +{ + /* start of TC */ +} + +static void cleanup(void) +{ + /* end of TC */ +} + + +static void utc_nfc_ndef_message_create_p(void) +{ + int ret ; + nfc_ndef_message_h message; + ret = nfc_ndef_message_create(&message); + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_create_n(void) +{ + int ret ; + ret = nfc_ndef_message_create(NULL); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_create_from_rawdata_p(void) +{ + int ret ; + unsigned char *buffer; + int size; + nfc_ndef_message_h message; + nfc_ndef_message_h message2; + nfc_ndef_record_h record1; + ret = nfc_ndef_message_create(&message); + nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8); + nfc_ndef_message_append_record(message, record1); + nfc_ndef_message_get_rawdata(message, &buffer, &size); + ret = nfc_ndef_message_create_from_rawdata(&message2, buffer,size); + + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message2); + nfc_ndef_message_destroy(message); + free(buffer); + dts_pass(__func__, "PASS"); + +} +static void utc_nfc_ndef_message_create_from_rawdata_n(void) +{ + int ret ; + ret = nfc_ndef_message_create_from_rawdata(NULL, NULL, 0); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_destroy_p(void) +{ + int ret ; + nfc_ndef_message_h message; + ret = nfc_ndef_message_create(&message); + ret = nfc_ndef_message_destroy(message); + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); + +} +static void utc_nfc_ndef_message_destroy_n(void) +{ + int ret ; + ret = nfc_ndef_message_destroy(NULL); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_get_record_count_p(void) +{ + int ret ; + int count; + nfc_ndef_message_h message; + nfc_ndef_record_h record1; + ret = nfc_ndef_message_create(&message); + nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8); + nfc_ndef_message_append_record(message, record1); + ret = nfc_ndef_message_get_record_count(message, &count); + + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message); + dts_pass(__func__, "PASS"); + +} +static void utc_nfc_ndef_message_get_record_count_n(void) +{ + int ret ; + ret = nfc_ndef_message_get_record_count(NULL, NULL); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_get_rawdata_p(void) +{ + int ret ; + unsigned char *buffer; + int size; + nfc_ndef_message_h message; + nfc_ndef_record_h record1; + ret = nfc_ndef_message_create(&message); + nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8); + nfc_ndef_message_append_record(message, record1); + ret= nfc_ndef_message_get_rawdata(message, &buffer, &size); + + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message); + free(buffer); + dts_pass(__func__, "PASS"); + +} +static void utc_nfc_ndef_message_get_rawdata_n(void) +{ + int ret ; + ret = nfc_ndef_message_get_rawdata(NULL, NULL, NULL); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_append_record_p(void) +{ + int ret ; + nfc_ndef_message_h message; + nfc_ndef_record_h record1; + ret = nfc_ndef_message_create(&message); + nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8); + ret = nfc_ndef_message_append_record(message, record1); + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_append_record_n(void) +{ + int ret ; + ret = nfc_ndef_message_append_record(NULL, NULL); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_insert_record_p(void) +{ + int ret ; + nfc_ndef_message_h message; + nfc_ndef_record_h record1; + ret = nfc_ndef_message_create(&message); + nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8); + ret = nfc_ndef_message_insert_record(message,0, record1); + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_insert_record_n(void) +{ + int ret ; + ret = nfc_ndef_message_insert_record(NULL, 0 , NULL); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_remove_record_p(void) +{ + int ret ; + nfc_ndef_message_h message; + nfc_ndef_record_h record1; + ret = nfc_ndef_message_create(&message); + nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8); + ret = nfc_ndef_message_insert_record(message,0, record1); + ret = nfc_ndef_message_remove_record(message, 0); + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message); + dts_pass(__func__, "PASS"); + +} +static void utc_nfc_ndef_message_remove_record_n(void) +{ + int ret ; + ret = nfc_ndef_message_remove_record(NULL, 0); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} +static void utc_nfc_ndef_message_get_record_p(void) +{ + int ret ; + nfc_ndef_message_h message; + nfc_ndef_record_h record1, record2; + ret = nfc_ndef_message_create(&message); + nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8); + ret = nfc_ndef_message_insert_record(message,0, record1); + ret = nfc_ndef_message_get_record(message, 0, &record2); + MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL"); + nfc_ndef_message_destroy(message); + dts_pass(__func__, "PASS"); + +} +static void utc_nfc_ndef_message_get_record_n(void) +{ + int ret ; + ret = nfc_ndef_message_get_record(NULL, 0 , NULL); + MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL"); + dts_pass(__func__, "PASS"); +} + diff --git a/TC/testcase/utc_network_nfc_ndef_record.c b/TC/testcase/utc_network_nfc_ndef_record.c new file mode 100755 index 0000000..2162882 --- /dev/null +++ b/TC/testcase/utc_network_nfc_ndef_record.c @@ -0,0 +1,408 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_nfc_ndef_record_create_p(void); +static void utc_nfc_ndef_record_create_n(void); +static void utc_nfc_ndef_record_create_text_p(void); +static void utc_nfc_ndef_record_create_text_n(void); +static void utc_nfc_ndef_record_create_uri_p(void); +static void utc_nfc_ndef_record_create_uri_n(void); +static void utc_nfc_ndef_record_create_mime_p(void); +static void utc_nfc_ndef_record_create_mime_n_1(void); +static void utc_nfc_ndef_record_create_mime_n_2(void); +static void utc_nfc_ndef_record_create_mime_n_3(void); +static void utc_nfc_ndef_record_destroy_p(void); +static void utc_nfc_ndef_record_destroy_n(void); +static void utc_nfc_ndef_record_set_id_p(void); +static void utc_nfc_ndef_record_set_id_n(void); +static void utc_nfc_ndef_record_get_id_p(void); +static void utc_nfc_ndef_record_get_id_n(void); +static void utc_nfc_ndef_record_get_payload_p(void); +static void utc_nfc_ndef_record_get_payload_n(void); +static void utc_nfc_ndef_record_get_type_p(void); +static void utc_nfc_ndef_record_get_type_n(void); +static void utc_nfc_ndef_record_get_tnf_p(void); +static void utc_nfc_ndef_record_get_tnf_n(void); +static void utc_nfc_ndef_record_get_text_p(void); +static void utc_nfc_ndef_record_get_text_n(void); +static void utc_nfc_ndef_record_get_langcode_p(void); +static void utc_nfc_ndef_record_get_langcode_n(void); +static void utc_nfc_ndef_record_get_encode_type_p(void); +static void utc_nfc_ndef_record_get_encode_type_n(void); +static void utc_nfc_ndef_record_get_uri_p(void); +static void utc_nfc_ndef_record_get_uri_n(void); +static void utc_nfc_ndef_record_get_mime_type_p(void); +static void utc_nfc_ndef_record_get_mime_type_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_nfc_ndef_record_create_p , POSITIVE_TC_IDX }, + { utc_nfc_ndef_record_create_n , NEGATIVE_TC_IDX }, + { utc_nfc_ndef_record_create_text_p, POSITIVE_TC_IDX }, + { utc_nfc_ndef_record_create_text_n , NEGATIVE_TC_IDX}, + { utc_nfc_ndef_record_create_uri_p, 1}, + { utc_nfc_ndef_record_create_uri_n, 2 }, + { utc_nfc_ndef_record_create_mime_p, 1}, + { utc_nfc_ndef_record_create_mime_n_1, 2 }, + { utc_nfc_ndef_record_create_mime_n_2, 2 }, + { utc_nfc_ndef_record_create_mime_n_3, 2 }, + { utc_nfc_ndef_record_destroy_p, 1}, + { utc_nfc_ndef_record_destroy_n, 2}, + { utc_nfc_ndef_record_set_id_p, 1 }, + { utc_nfc_ndef_record_set_id_n, 2 }, + { utc_nfc_ndef_record_get_id_p, 1 }, + { utc_nfc_ndef_record_get_id_n, 2 }, + { utc_nfc_ndef_record_get_payload_p, 1}, + { utc_nfc_ndef_record_get_payload_n, 2}, + { utc_nfc_ndef_record_get_type_p, 1}, + { utc_nfc_ndef_record_get_type_n, 2}, + { utc_nfc_ndef_record_get_tnf_p, 1}, + { utc_nfc_ndef_record_get_tnf_n, 2}, + { utc_nfc_ndef_record_get_text_p, 1}, + { utc_nfc_ndef_record_get_text_n, 2}, + { utc_nfc_ndef_record_get_langcode_p, 1}, + { utc_nfc_ndef_record_get_langcode_n, 2}, + { utc_nfc_ndef_record_get_encode_type_p, 1}, + { utc_nfc_ndef_record_get_encode_type_n, 2}, + { utc_nfc_ndef_record_get_uri_p, 1}, + { utc_nfc_ndef_record_get_uri_n, 2}, + { utc_nfc_ndef_record_get_mime_type_p, 1}, + { utc_nfc_ndef_record_get_mime_type_n, 2}, + { NULL, 0 }, +}; + +//this method is called only once in start +static void startup(void) +{ + /* start of TC */ +} + +static void cleanup(void) +{ + /* end of TC */ +} +static void utc_nfc_ndef_record_create_p(void) +{ + int ret=0; + nfc_ndef_record_h record; + unsigned char testbuffer[] = "TEST"; + + ret = nfc_ndef_record_create(&record, NFC_RECORD_TNF_WELL_KNOWN, testbuffer,1, testbuffer, 4, testbuffer, 4); + if( ret == 0 ) + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_create is faild"); +} + +static void utc_nfc_ndef_record_create_n(void) +{ + int ret=0; + unsigned char testbuffer[] = "TEST"; + + ret = nfc_ndef_record_create(NULL, NFC_RECORD_TNF_WELL_KNOWN, testbuffer,1, testbuffer, 4, testbuffer, 4); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); +} +static void utc_nfc_ndef_record_create_text_p(void) +{ + int ret = 0; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + if( ret == 0 ) + nfc_ndef_record_destroy(record); + + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_create_text is faild"); +} +static void utc_nfc_ndef_record_create_text_n(void) +{ + int ret = 0; + ret = nfc_ndef_record_create_text(NULL, "test", "en-US", NFC_ENCODE_UTF_8 ); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} +static void utc_nfc_ndef_record_create_uri_p(void) +{ + int ret = 0; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_uri(&record , "http://test.com"); + if( ret == 0) + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_create_uri is faild"); +} +static void utc_nfc_ndef_record_create_uri_n(void) +{ + int ret = 0; + ret = nfc_ndef_record_create_uri(NULL , "http://test.com"); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} + +static void utc_nfc_ndef_record_create_mime_p(void) +{ + int ret = NFC_ERROR_NONE; + nfc_ndef_record_h record; + + ret = nfc_ndef_record_create_mime(&record, "text/plain", (unsigned char*)"the text record", sizeof("the text record")); + if( ret == NFC_ERROR_NONE) + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_create_mime is faild"); +} + +static void utc_nfc_ndef_record_create_mime_n_1(void) +{ + int ret = NFC_ERROR_NONE; + + ret = nfc_ndef_record_create_mime(NULL, "text/plain", (unsigned char*)"the text record", sizeof("the text record")); + dts_check_eq(__func__, ret, NFC_ERROR_INVALID_PARAMETER, "nfc_ndef_record_h null not allowed"); +} + +static void utc_nfc_ndef_record_create_mime_n_2(void) +{ + int ret = NFC_ERROR_NONE; + nfc_ndef_record_h record; + + ret = nfc_ndef_record_create_mime(&record, NULL, (unsigned char*)"the text record", sizeof("the text record")); + if( ret == NFC_ERROR_NONE) + nfc_ndef_record_destroy(record); + + dts_check_eq(__func__, ret, NFC_ERROR_INVALID_PARAMETER, "mime_type null not allowed"); +} + +static void utc_nfc_ndef_record_create_mime_n_3(void) +{ + int ret = NFC_ERROR_NONE; + nfc_ndef_record_h record; + + ret = nfc_ndef_record_create_mime(&record, "text/plain", NULL, sizeof("the text record")); + if( ret == NFC_ERROR_NONE) + nfc_ndef_record_destroy(record); + + dts_check_eq(__func__, ret, NFC_ERROR_INVALID_PARAMETER, "data null not allowed"); +} + +static void utc_nfc_ndef_record_destroy_p(void) +{ + int ret = 0; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + if( ret != 0){ + dts_fail(__func__, "can't create record\n"); + } + ret = nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_destroy is faild"); +} +static void utc_nfc_ndef_record_destroy_n(void) +{ + int ret = 0; + ret = nfc_ndef_record_destroy(NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); +} +static void utc_nfc_ndef_record_set_id_p(void) +{ + int ret = 0; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_set_id(record, (unsigned char *)"test", 4); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_set_id is faild"); +} +static void utc_nfc_ndef_record_set_id_n(void) +{ + int ret; + ret = nfc_ndef_record_set_id(NULL, (unsigned char *)"test", 4); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); +} +static void utc_nfc_ndef_record_get_id_p(void) +{ + int ret = 0; + int size; + nfc_ndef_record_h record; + unsigned char *id; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_set_id(record, (unsigned char *)"test", 4); + ret = nfc_ndef_record_get_id(record, &id, &size); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_id is faild"); + +} +static void utc_nfc_ndef_record_get_id_n(void) +{ + int ret; + ret = nfc_ndef_record_get_id(NULL,NULL, NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); +} +static void utc_nfc_ndef_record_get_payload_p(void) +{ + int ret = 0; + int size; + nfc_ndef_record_h record; + unsigned char *payload; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_get_payload(record, &payload, &size); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_payload is faild"); +} +static void utc_nfc_ndef_record_get_payload_n(void) +{ + int ret; + ret = nfc_ndef_record_set_id(NULL, (unsigned char *)"test", 4); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} +static void utc_nfc_ndef_record_get_type_p(void) +{ + int ret = 0; + int size; + nfc_ndef_record_h record; + unsigned char *data; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_get_type(record, &data, &size); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_type is faild"); +} +static void utc_nfc_ndef_record_get_type_n(void) +{ + int ret; + ret = nfc_ndef_record_get_type(NULL, NULL, NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} +static void utc_nfc_ndef_record_get_tnf_p(void) +{ + int ret = 0; + + nfc_ndef_record_h record; + nfc_record_tnf_e tnf; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_get_tnf(record, &tnf); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_tnf is faild"); +} +static void utc_nfc_ndef_record_get_tnf_n(void) +{ + int ret; + ret = nfc_ndef_record_get_tnf(NULL, NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} +static void utc_nfc_ndef_record_get_text_p(void) +{ + int ret = 0; + char *text; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_get_text(record, &text); + free(text); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_tnf is faild"); + +} +static void utc_nfc_ndef_record_get_text_n(void) +{ + int ret; + ret = nfc_ndef_record_get_text(NULL, NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} +static void utc_nfc_ndef_record_get_langcode_p(void) +{ + int ret = 0; + char *text; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_get_langcode(record, &text); + free(text); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_tnf is faild"); + +} +static void utc_nfc_ndef_record_get_langcode_n(void) +{ + int ret; + ret = nfc_ndef_record_get_langcode(NULL, NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} +static void utc_nfc_ndef_record_get_encode_type_p(void) +{ + int ret = 0; + nfc_encode_type_e type; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 ); + ret = nfc_ndef_record_get_encode_type(record, &type); + nfc_ndef_record_destroy(record); + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_encode_type is faild"); + +} +static void utc_nfc_ndef_record_get_encode_type_n(void) +{ + int ret; + ret = nfc_ndef_record_get_encode_type(NULL, NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} +static void utc_nfc_ndef_record_get_uri_p(void) +{ + int ret = 0; + char *uri; + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_uri(&record, "http://test.com"); + ret = nfc_ndef_record_get_uri(record, &uri); + if(ret == 0 ){ + free(uri); + nfc_ndef_record_destroy(record); + } + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_uri is faild"); +} +static void utc_nfc_ndef_record_get_uri_n(void) +{ + int ret; + ret = nfc_ndef_record_get_uri(NULL, NULL); + dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_h not allow null"); + +} + +static void utc_nfc_ndef_record_get_mime_type_p(void) +{ + int ret = NFC_ERROR_NONE; + char *mime_type; + + nfc_ndef_record_h record; + ret = nfc_ndef_record_create_mime(&record, "text/plain", (unsigned char*)"the text record", sizeof("the text record")); + ret = nfc_ndef_record_get_mime_type(record, &mime_type); + if(ret == NFC_ERROR_NONE ){ + free(mime_type); + nfc_ndef_record_destroy(record); + } + dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_record_get_mime_type is faild"); +} +static void utc_nfc_ndef_record_get_mime_type_n(void) +{ + int ret; + + ret = nfc_ndef_record_get_mime_type(NULL, NULL); + dts_check_eq(__func__, ret, NFC_ERROR_INVALID_PARAMETER, "nfc_ndef_record_h not allow null"); +} diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100644 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option for build operation checking +TET_BUILD_TOOL=make # build with using make command +TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build +TET_API_COMPLIANT=True # use TET API in Test Case ? +TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100644 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option +TET_CLEAN_TOOL= make clean # clean tool +TET_CLEAN_FILE= Makefile # file for clean +TET_API_COMPLIANT=True # TET API useage +TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100644 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capturing execution or not +TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional +TET_EXEC_FILE= # ex) exectool : execution file/ Optional +TET_API_COMPLIANT=True # Test case or Tool usesTET API? +TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/capi-network-nfc.pc.in b/capi-network-nfc.pc.in old mode 100755 new mode 100644 diff --git a/debian/README b/debian/README old mode 100755 new mode 100644 diff --git a/debian/capi-network-nfc-dev.install b/debian/capi-network-nfc-dev.install old mode 100755 new mode 100644 diff --git a/debian/capi-network-nfc-dev.postinst b/debian/capi-network-nfc-dev.postinst old mode 100755 new mode 100644 diff --git a/debian/capi-network-nfc.install b/debian/capi-network-nfc.install old mode 100755 new mode 100644 diff --git a/debian/capi-network-nfc.postinst b/debian/capi-network-nfc.postinst old mode 100755 new mode 100644 diff --git a/debian/changelog b/debian/changelog old mode 100755 new mode 100644 index 264981a..9220c26 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,67 @@ +capi-network-nfc (0.0.1-20) unstable; urgency=low + + * Modify the nfc set state function + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-20 + + -- Sungjae Lim Wed, 11 July 2012 12:20:08 +0900 + +capi-network-nfc (0.0.1-19) unstable; urgency=low + + * ADD NFC Err case for empty tag and not ndef format + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-19 + + -- Sechang Sohn Fri, 18 May 2012 14:20:08 +0900 + +capi-network-nfc (0.0.1-18) unstable; urgency=low + + * Patch for NFC Err case pssing issue + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-18 + + -- Sechang Sohn Fri, 11 May 2012 14:45:44 +0900 + +capi-network-nfc (0.0.1-17) unstable; urgency=low + + * prevent NFC set state CB reset + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-17 + + -- Sechang Sohn Wed, 18 Apr 2012 17:21:56 +0900 + +capi-network-nfc (0.0.1-16) unstable; urgency=low + + * make transfer NFC set state user data + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-16 + + -- Sechang Sohn Tue, 10 Apr 2012 15:05:24 +0900 + +capi-network-nfc (0.0.1-15) unstable; urgency=low + + * Adjust the calling sequence of callback + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-15 + + -- Wonkyu Kwon Mon, 09 Apr 2012 15:50:00 +0900 + +capi-network-nfc (0.0.1-14) unstable; urgency=low + + * add NFC nfc_manager_is_supported added + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-14 + + -- Sechang Sohn Mon, 09 Apr 2012 12:18:51 +0900 + +capi-network-nfc (0.0.1-13) unstable; urgency=low + + * add NFC init/deinit CB + * Git: slp/api/nfc + * Tag: capi-network-nfc_0.0.1-13 + + -- Sechang Sohn Thu, 05 Apr 2012 14:15:52 +0900 + capi-network-nfc (0.0.1-12) unstable; urgency=low * add NFC tag write exception diff --git a/debian/compat b/debian/compat old mode 100755 new mode 100644 diff --git a/include/nfc.h b/include/nfc.h index d546179..c5606d5 100755 --- a/include/nfc.h +++ b/include/nfc.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef __NFC_H__ @@ -47,11 +47,13 @@ typedef enum { NFC_ERROR_DEVICE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Previous opertion is not finished still busy */ NFC_ERROR_NO_DEVICE = NFC_ERROR_CLASS | 0x04, /**< no device */ NFC_ERROR_NOT_ACTIVATED = NFC_ERROR_CLASS | 0x05, /**< NFC is not activated */ - NFC_ERROR_NOT_SUPPORTED = NFC_ERROR_CLASS | 0x06, /**< Not supported NFC */ + NFC_ERROR_NOT_SUPPORTED = NFC_ERROR_CLASS | 0x06, /**< Not supported */ NFC_ERROR_ALREADY_ACTIVATED = NFC_ERROR_CLASS | 0x07, /**< Already activated */ NFC_ERROR_ALREADY_DEACTIVATED = NFC_ERROR_CLASS | 0x08, /**< Already deactivated */ NFC_ERROR_READ_ONLY_NDEF = NFC_ERROR_CLASS | 0x09, /**< Read only tag */ - NFC_ERROR_NO_SPACE_ON_NDEF = NFC_ERROR_CLASS | 0x0a /**< No enough space on tag */ + NFC_ERROR_NO_SPACE_ON_NDEF = NFC_ERROR_CLASS | 0x0a, /**< No enough space on tag */ + NFC_ERROR_NO_NDEF_MESSAGE = NFC_ERROR_CLASS | 0x0b, /**< No NDEF Message on Tag */ + NFC_ERROR_NOT_NDEF_FORMAT = NFC_ERROR_CLASS | 0x0c /**< Not NDEF format Tag */ } nfc_error_e; /** @@ -262,7 +264,18 @@ extern const unsigned char NFC_RECORD_HANDOVER_SELECT_TYPE[2]; * * @see nfc_manager_set_activation() */ -typedef void (* nfc_set_activation_completed_cb)(nfc_error_e error, void *user_data); +typedef void (* nfc_activation_completed_cb)(nfc_error_e error, void *user_data); + +/** + * @brief Called when nfc activation state is changed. + * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE + * + * @param [in] activated The activation state + * @param [in] user_data The user data passed from the callback registeration function + * + * @see nfc_manager_set_activation_changed_cb() + */ +typedef void (*nfc_activation_changed_cb)(bool activated , void *user_data); /** * @brief Called after nfc_manager_initialize() has completed. @@ -568,13 +581,21 @@ typedef void (*nfc_p2p_data_recived_cb)(nfc_p2p_target_h target, nfc_ndef_messag */ typedef void (*nfc_p2p_connection_handover_completed_cb)(nfc_error_e result, nfc_ac_type_e carrior, void * ac_data, int ac_data_size , void *user_data); - /** - * @brief Sets NFC Activation + * @brief Gets the value that indicates whether NFC is supported. * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE * * @remarks This function can executed Regardless of nfc_manager_initialize state. * + * @return true on NFC supported, otherwise false + * @see nfc_manager_set_activation() + */ +bool nfc_manager_is_supported(void); + +/** + * @brief Sets NFC Activation + * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE + * * @param [in] activation The NFC state for setting * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required * @param [in] user_data The user data to be passed to the callback function @@ -586,9 +607,35 @@ typedef void (*nfc_p2p_connection_handover_completed_cb)(nfc_error_e result, nfc * @retval #NFC_ERROR_ALREADY_ACTIVATED Already activated * @retval #NFC_ERROR_ALREADY_DEACTIVATED Already deactivated * @see nfc_manager_is_activated() - * @see nfc_set_activation_completed_cb() + * @see nfc_activation_completed_cb() */ -int nfc_manager_set_activation(bool activation, nfc_set_activation_completed_cb callback, void *user_data); +int nfc_manager_set_activation(bool activation, nfc_activation_completed_cb callback, void *user_data); + +/** + * @brief Set NFC Activation state changed callback + * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE + * + * @param [in] callback The callback function to invoke when activation state is changed. + * @param [in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see nfc_activation_changed_cb() + * @see nfc_manager_unset_activation_changed_cb() + */ +int nfc_manager_set_activation_changed_cb(nfc_activation_changed_cb callback , void *user_data); + +/** + * @brief Unregisters the callback function. + * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE + * + * @see nfc_manager_set_activation_changed_cb() + * @see nfc_activation_changed_cb() + */ +void nfc_manager_unset_activation_changed_cb(void); + /** * @brief Gets NFC Activation state @@ -615,7 +662,6 @@ bool nfc_manager_is_activated(void); * @return 0 on success, otherwise a negative error value. * @retval #NFC_ERROR_NONE Successful * @retval #NFC_ERROR_OPERATION_FAILED Operation fail - * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * @see nfc_manager_deinitialize() */ int nfc_manager_initialize(nfc_initialize_completed_cb callback, void *user_data); @@ -1420,6 +1466,7 @@ int nfc_tag_foreach_information(nfc_tag_h tag, nfc_tag_information_cb callback, * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag +* @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @post It invokes nfc_tag_transceive_completed_cb() when it has completed to t * @see nfc_tag_read_ndef() @@ -1442,6 +1489,8 @@ int nfc_tag_transceive(nfc_tag_h tag, unsigned char *buffer, int buffer_size, nf * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag * * @post It invokes nfc_tag_read_completed_cb() when it has completed to read NDEF formatted data. * @@ -1468,6 +1517,8 @@ int nfc_tag_read_ndef(nfc_tag_h tag, nfc_tag_read_completed_cb callback, void *u * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag * * @post It invokes nfc_tag_write_completed_cb() when it has completed to write NDEF data. * @see nfc_tag_is_support_ndef() @@ -1493,6 +1544,8 @@ int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg, nfc_tag_write_comp * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag * * @post It invokes nfc_tag_format_completed_cb() when it has completed to format the NFC tag. * @@ -1529,6 +1582,7 @@ int nfc_tag_format_ndef(nfc_tag_h tag, unsigned char *key, int key_size, nfc_tag * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @post It invokes nfc_mifare_authenticate_with_keyA_completed_cb() when it has completed to authenticate the given sector with key A. * @see nfc_mifare_authenticate_with_keyB() @@ -1571,6 +1625,7 @@ int nfc_mifare_authenticate_with_keyA(nfc_tag_h tag, int sector_index, unsigned * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @post It invokes nfc_mifare_authenticate_with_keyB_completed_cb() when it has completed to authenticate the given sector with key B. * @see nfc_mifare_authenticate_with_keyA() @@ -1601,6 +1656,7 @@ int nfc_mifare_authenticate_with_keyB(nfc_tag_h tag, int sector_index, unsigned * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @post It invokes nfc_mifare_read_block_completed_cb() when it has completed to read a block. * @see nfc_mifare_read_page() @@ -1624,10 +1680,10 @@ int nfc_mifare_read_block(nfc_tag_h tag, int block_index, nfc_mifare_read_block_ * @retval #NFC_ERROR_NONE Successful * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @post It invokes nfc_mifare_read_page_completed_cb() when it has completed to read a page. * @see nfc_mifare_read_block() @@ -1655,6 +1711,7 @@ int nfc_mifare_read_page(nfc_tag_h tag, int page_index, nfc_mifare_read_page_com * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @post It invokes nfc_mifare_write_block_completed_cb() when it hase completed to write a block. * @@ -1679,10 +1736,10 @@ int nfc_mifare_write_block(nfc_tag_h tag, int block_index, unsigned char *buffer * @retval #NFC_ERROR_NONE Successful * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @post It invokes nfc_mifare_write_page_completed_cb() when it has completed to write a page. * @@ -1710,6 +1767,7 @@ int nfc_mifare_write_page(nfc_tag_h tag, int page_index, unsigned char *buffer, * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @see nfc_mifare_decrement() * @see nfc_mifare_write_block() @@ -1734,6 +1792,7 @@ int nfc_mifare_increment(nfc_tag_h tag, int block_index, int value, nfc_mifare_i * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @see nfc_mifare_increment() * @see nfc_mifare_write_block() @@ -1757,6 +1816,7 @@ int nfc_mifare_decrement(nfc_tag_h tag, int block_index, int value, nfc_mifare_d * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @see nfc_mifare_restore() */ @@ -1779,6 +1839,7 @@ int nfc_mifare_transfer(nfc_tag_h tag, int block_index, nfc_mifare_transfer_comp * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @see nfc_mifare_transfer() */ @@ -1834,6 +1895,7 @@ int nfc_p2p_unset_data_received_cb(nfc_p2p_target_h target); * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @see nfc_p2p_send_completed_cb() * @see @see nfc_p2p_target_discovered_cb() @@ -1858,6 +1920,7 @@ int nfc_p2p_send(nfc_p2p_target_h target, nfc_ndef_message_h message, nfc_p2p_se * @retval #NFC_ERROR_OPERATION_FAILED Operation failed * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated * * @see nfc_p2p_connection_handover_completed_cb() * @see @see nfc_p2p_connection_handover_completed_cb() diff --git a/include/nfc_private.h b/include/nfc_private.h index 736f72e..5e3b58e 100755 --- a/include/nfc_private.h +++ b/include/nfc_private.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,33 +30,41 @@ typedef enum { typedef struct { nfc_tag_discovered_cb on_tag_discovered_cb; - void * on_tag_discovered_user_data; + void * on_tag_discovered_user_data; nfc_ndef_discovered_cb on_ndef_discovered_cb; - void * on_ndef_discovered_user_data; + void * on_ndef_discovered_user_data; net_nfc_target_info_s current_tag; //net_nfc_target_handle_s current_target; net_nfc_target_handle_h current_target; nfc_p2p_target_discovered_cb on_p2p_discovered_cb; - void * on_p2p_discovered_user_data; + void * on_p2p_discovered_user_data; - nfc_se_event_cb on_se_event_cb; - void * on_se_event_user_data; + nfc_se_event_cb on_se_event_cb; + void * on_se_event_user_data; - nfc_p2p_send_completed_cb on_p2p_send_completed_cb; - void * on_p2p_send_completed_user_data; + nfc_p2p_send_completed_cb on_p2p_send_completed_cb; + void * on_p2p_send_completed_user_data; nfc_p2p_data_recived_cb on_p2p_recv_cb; - void * on_p2p_recv_user_data; + void * on_p2p_recv_user_data; - nfc_p2p_connection_handover_completed_cb on_p2p_connection_handover_completed_cb; + nfc_p2p_connection_handover_completed_cb on_p2p_connection_handover_completed_cb; void * on_p2p_connection_handover_completed_user_data; nfc_initialize_completed_cb on_initialize_completed_cb; nfc_se_transaction_event_cb on_se_transaction_event_cb; - void * on_se_transaction_event_user_data; + void * on_se_transaction_event_user_data; + + nfc_activation_changed_cb on_activation_changed_cb; + void * on_activation_changed_user_data; + + nfc_activation_completed_cb on_activation_completed_cb; + void * on_activation_completed_user_data; + bool on_activation_doing; + } _nfc_context_s; typedef struct { diff --git a/packaging/capi-network-nfc.spec b/packaging/capi-network-nfc.spec index a51be91..30bbd7b 100755 --- a/packaging/capi-network-nfc.spec +++ b/packaging/capi-network-nfc.spec @@ -2,7 +2,7 @@ Name: capi-network-nfc Summary: A NFC library in SLP C API Version: 0.0.1 -Release: 1 +Release: 26 Group: TO_BE/FILLED_IN License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/nfc.c b/src/nfc.c index 7b1578c..0732a14 100755 --- a/src/nfc.c +++ b/src/nfc.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,7 +120,6 @@ static int _convert_error_code(const char *func, int native_error_code) case NET_NFC_TAG_WRITE_FAILED: case NET_NFC_OPERATION_FAIL: case NET_NFC_SECURITY_FAIL: - case NET_NFC_NO_NDEF_SUPPORT: case NET_NFC_INSUFFICIENT_STORAGE: case NET_NFC_NOT_CONNECTED: case NET_NFC_NOT_INITIALIZED: @@ -156,32 +155,58 @@ static int _convert_error_code(const char *func, int native_error_code) case NET_NFC_NDEF_TYPE_LENGTH_IS_NOT_OK: case NET_NFC_NDEF_ID_LENGTH_IS_NOT_OK: case NET_NFC_NDEF_BUF_END_WITHOUT_ME: - case NET_NFC_NO_NDEF_MESSAGE: error_code = NFC_ERROR_INVALID_NDEF_MESSAGE; errorstr = "INVALID_NDEF_MESSAGE"; break; + case NET_NFC_NO_NDEF_MESSAGE: + error_code = NFC_ERROR_NO_NDEF_MESSAGE; + errorstr = "NO_NDEF_MESSAGE"; + break; case NET_NFC_BUSY : error_code = NFC_ERROR_DEVICE_BUSY; errorstr = "DEVICE_BUSY"; break; + case NET_NFC_NO_NDEF_SUPPORT: + error_code = NFC_ERROR_NOT_NDEF_FORMAT; + errorstr = "NOT_SUPPORTED"; + break; default : error_code = NFC_ERROR_OPERATION_FAILED; errorstr = "OPERATION_FAILED"; } - LOGE( "[%s] %s(0x%08x)",func, errorstr, error_code); + LOGE( "NFC [%s] %s(0x%08x)",func, errorstr, error_code); return error_code; } _nfc_context_s g_nfc_context; -static nfc_set_activation_completed_cb g_nfc_set_activation_completed_cb = NULL; + + +static void nfc_manager_set_activation_completed_cb(nfc_activation_completed_cb callback , void *user_data) +{ + g_nfc_context.on_activation_completed_cb = callback; + g_nfc_context.on_activation_completed_user_data = user_data; + g_nfc_context.on_activation_doing = true; +} + +static void nfc_manager_unset_activation_completed_cb(void) +{ + g_nfc_context.on_activation_completed_cb = NULL; + g_nfc_context.on_activation_completed_user_data = NULL; + g_nfc_context.on_activation_doing = false; +} + +static bool nfc_manager_check_activation(void) +{ + return g_nfc_context.on_activation_doing; +} void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, void* data, void* user_param, void * trans_data) { - LOGI("[%s] message %d - start", __func__, message); + LOGI("NFC [%s] message %d - start result[%d] ", __func__, message, result); int capi_result = _convert_error_code("EVENT", result); @@ -332,7 +357,7 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo void * user_data = g_nfc_context.on_p2p_send_completed_user_data; g_nfc_context.on_p2p_send_completed_cb = NULL; g_nfc_context.on_p2p_send_completed_user_data = NULL; - cb(result , user_data ); + cb(capi_result , user_data ); } break; } @@ -393,7 +418,7 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo void * user_data = g_nfc_context.on_p2p_connection_handover_completed_user_data; g_nfc_context.on_p2p_connection_handover_completed_cb = NULL; g_nfc_context.on_p2p_connection_handover_completed_user_data = NULL; - cb(result , carrior_type, (void *)ac_data, ac_data_size, user_data ); + cb(capi_result , carrior_type, (void *)ac_data, ac_data_size, user_data ); net_nfc_exchanger_free_alternative_carrier_data((net_nfc_connection_handover_info_h)data); free(ac_data); @@ -416,10 +441,15 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo } else { + if (result == NET_NFC_NOT_CONNECTED) + { + capi_result = NFC_ERROR_NONE; + } + if( g_nfc_context.on_initialize_completed_cb ){ nfc_initialize_completed_cb cb = g_nfc_context.on_initialize_completed_cb; g_nfc_context.on_initialize_completed_cb = NULL; - cb( result,trans_data ); + cb( capi_result,trans_data ); } } break; @@ -431,52 +461,95 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo net_nfc_target_info_s *target_info = (net_nfc_target_info_s*)data; memset(&g_nfc_context.current_tag , 0 , sizeof( g_nfc_context.current_tag )); + g_nfc_context.current_tag = * target_info; + net_nfc_tag_info_s *list = g_nfc_context.current_tag.tag_info_list; + net_nfc_tag_info_s *newlist ; + newlist = (net_nfc_tag_info_s *)calloc(g_nfc_context.current_tag.number_of_keys, sizeof(net_nfc_tag_info_s)); - if(result == NET_NFC_OK) - { - g_nfc_context.current_tag = * target_info; - net_nfc_tag_info_s *list = g_nfc_context.current_tag.tag_info_list; - net_nfc_tag_info_s *newlist ; - newlist = (net_nfc_tag_info_s *)calloc(g_nfc_context.current_tag.number_of_keys, sizeof(net_nfc_tag_info_s)); - - //copy info list - for(i = 0; i < g_nfc_context.current_tag.number_of_keys ; i++){ - if( list[i].key ){ - newlist[i].key = strdup(list[i].key); - } - if ( list[i].value ){ - net_nfc_create_data(&newlist[i].value , ((data_s*)list[i].value)->buffer, ((data_s*)list[i].value)->length); - } + //copy info list + for(i = 0; i < g_nfc_context.current_tag.number_of_keys ; i++){ + if( list[i].key ){ + newlist[i].key = strdup(list[i].key); + } + if ( list[i].value ){ + net_nfc_create_data(&newlist[i].value , ((data_s*)list[i].value)->buffer, ((data_s*)list[i].value)->length); } - g_nfc_context.current_tag.tag_info_list = newlist; - } + g_nfc_context.current_tag.tag_info_list = newlist; nfc_initialize_completed_cb cb = g_nfc_context.on_initialize_completed_cb; g_nfc_context.on_initialize_completed_cb = NULL; if( cb ){ - cb( result, trans_data ); + cb( capi_result, trans_data ); } break; } case NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE : { - memset(&g_nfc_context.current_target , 0 , sizeof( g_nfc_context.current_target )); - g_nfc_context.on_p2p_recv_cb = NULL; - g_nfc_context.on_p2p_recv_user_data = NULL; - g_nfc_context.on_p2p_send_completed_cb = NULL; - g_nfc_context.on_p2p_send_completed_user_data = NULL; - - if(result == NET_NFC_OK) - { - g_nfc_context.current_target = (net_nfc_target_handle_h)data; - } + g_nfc_context.current_target = (net_nfc_target_handle_h)data; nfc_initialize_completed_cb cb = g_nfc_context.on_initialize_completed_cb; g_nfc_context.on_initialize_completed_cb = NULL; if( cb ){ - cb( result, trans_data ); + cb( capi_result, trans_data ); + } + + break; + } + + + case NET_NFC_MESSAGE_INIT : + { + bool activated = true; + + LOGE( "_nfc_response_handler NET_NFC_MESSAGE_INIT\n"); + + if (result == NET_NFC_OK){ + if( g_nfc_context.on_activation_changed_cb != NULL ){ + g_nfc_context.on_activation_changed_cb(activated , g_nfc_context.on_activation_changed_user_data); + LOGE( "_nfc_response_handler changed call back NET_NFC_MESSAGE_INIT NET_NFC_OK\n"); + } + + if( g_nfc_context.on_activation_completed_cb != NULL ){ + g_nfc_context.on_activation_completed_cb(result , g_nfc_context.on_activation_completed_user_data); + LOGE( "_nfc_response_handler completed call back NET_NFC_MESSAGE_INIT NET_NFC_OK\n"); + + nfc_manager_unset_activation_completed_cb(); + } + else + { + g_nfc_context.on_activation_doing = false; + LOGE( "g_nfc_context.on_activation_doing\n"); + } + + + } + + break; + } + + case NET_NFC_MESSAGE_DEINIT : + { + bool activated = false; + + if (result == NET_NFC_OK){ + if( g_nfc_context.on_activation_changed_cb != NULL ){ + g_nfc_context.on_activation_changed_cb(activated , g_nfc_context.on_activation_changed_user_data); + LOGE( "_nfc_response_handler NET_NFC_MESSAGE_DEINIT NET_NFC_OK\n"); + } + + if( g_nfc_context.on_activation_completed_cb != NULL ){ + g_nfc_context.on_activation_completed_cb(result , g_nfc_context.on_activation_completed_user_data); + LOGE( "_nfc_response_handler completed call back NET_NFC_MESSAGE_INIT NET_NFC_OK\n"); + + nfc_manager_unset_activation_completed_cb(); + } + else + { + g_nfc_context.on_activation_doing = false; + LOGE( "g_nfc_context.on_activation_doing\n"); + } } break; @@ -509,8 +582,8 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo case NET_NFC_MESSAGE_SE_TYPE_TRANSACTION: event = NFC_SE_EVENT_TRANSACTION; break; - default: - break; + default: + break; } if( g_nfc_context.on_se_event_cb ){ @@ -530,31 +603,39 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo } -static void __nfc_set_activation_completed(net_nfc_error_e error, void *user_data) + +bool nfc_manager_is_supported(void) { - int capi_result = _convert_error_code("nfc_set_activation_completed", error); - nfc_set_activation_completed_cb cb = g_nfc_set_activation_completed_cb; - g_nfc_set_activation_completed_cb = NULL; - if(cb) - { - cb(capi_result, user_data); - } - return ; + int nfc_supported = 0; + + net_nfc_is_supported(&nfc_supported); + + return nfc_supported; } -int nfc_manager_set_activation(bool activation, nfc_set_activation_completed_cb callback, void *user_data) + +int nfc_manager_set_activation(bool activation, nfc_activation_completed_cb callback, void *user_data) { int ret = 0; int nfc_supported = 0; + bool nfc_check_activation = 0; + + nfc_check_activation = nfc_manager_check_activation(); + + if(nfc_check_activation == true) + { + LOGE( "nfc_manager_check_activation BUSY!!!!!\n"); + return NFC_ERROR_DEVICE_BUSY; + } net_nfc_is_supported(&nfc_supported); if(!nfc_supported) { - ret = NFC_ERROR_NOT_SUPPORTED; + ret = NFC_ERROR_NOT_SUPPORTED; } else { @@ -563,24 +644,30 @@ int nfc_manager_set_activation(bool activation, nfc_set_activation_completed_cb { if(activation) { - ret = NFC_ERROR_ALREADY_ACTIVATED; + ret = NFC_ERROR_ALREADY_ACTIVATED; } else { - ret = NFC_ERROR_ALREADY_DEACTIVATED; + ret = NFC_ERROR_ALREADY_DEACTIVATED; } } else { - g_nfc_set_activation_completed_cb = callback; - ret = net_nfc_set_state(activation, __nfc_set_activation_completed); - if (ret) + + nfc_manager_set_activation_completed_cb(callback , user_data); + + ret = net_nfc_set_state(activation, NULL); + + if (ret == NET_NFC_OK) { - ret = NFC_ERROR_OPERATION_FAILED; + ret = NFC_ERROR_NONE; + LOGE( "nfc_manager_set_activation net_nfc_set_state success\n"); } else { - ret = NFC_ERROR_NONE; + nfc_manager_unset_activation_completed_cb(); + ret = NFC_ERROR_OPERATION_FAILED; + LOGE( "nfc_manager_set_activation net_nfc_set_state fail\n"); } } } @@ -588,6 +675,23 @@ int nfc_manager_set_activation(bool activation, nfc_set_activation_completed_cb } +int nfc_manager_set_activation_changed_cb(nfc_activation_changed_cb callback , void *user_data) +{ + if( callback == NULL) + return _return_invalid_param(__func__); + g_nfc_context.on_activation_changed_cb = callback; + g_nfc_context.on_activation_changed_user_data = user_data; + return 0; +} + +void nfc_manager_unset_activation_changed_cb(void) +{ + g_nfc_context.on_activation_changed_cb = NULL; + g_nfc_context.on_activation_changed_user_data = NULL; +} + + + bool nfc_manager_is_activated(void) { @@ -610,10 +714,7 @@ int nfc_manager_initialize (nfc_initialize_completed_cb callback, void *user_dat { int ret; - if(!nfc_manager_is_activated()) - { - return NFC_ERROR_NOT_ACTIVATED; - } + ret = net_nfc_initialize(); if( ret != NET_NFC_OK ) return _convert_error_code(__func__, ret); @@ -631,14 +732,15 @@ int nfc_manager_initialize (nfc_initialize_completed_cb callback, void *user_dat int nfc_manager_deinitialize (void) { int ret; + + net_nfc_state_deactivate(); + ret = net_nfc_deinitialize(); if( ret == 0) net_nfc_unset_response_callback(); - net_nfc_state_deactivate(); - return _convert_error_code(__func__, ret); } @@ -1089,34 +1191,23 @@ int nfc_tag_get_ndef_size(nfc_tag_h tag, unsigned int * actual_data_size) return _convert_error_code(__func__, ret); } -int nfc_tag_foreach_information(nfc_tag_h tag , nfc_tag_information_cb callback , void * user_data ){ - char **keys; - int number_of_keys; +int nfc_tag_foreach_information(nfc_tag_h tag , nfc_tag_information_cb callback , void * user_data ) +{ int i; - int ret ; + + net_nfc_tag_info_s *taglist = g_nfc_context.current_tag.tag_info_list; if( tag == NULL || callback == NULL ) return _return_invalid_param(__func__); - ret = net_nfc_get_tag_info_keys(tag, &keys , &number_of_keys); - if( ret != 0 ) - return _convert_error_code(__func__, ret); - - for( i = 0 ; i < number_of_keys ; i++){ - data_s *tmpdata; - ret = net_nfc_get_tag_info_value( tag, keys[i], (data_h*)&tmpdata); - if( ret == 0 ){ - bool cont; - cont = callback(keys[i], tmpdata->buffer, tmpdata->length, user_data); - if( !cont ) - break; - } + for(i=0; i NFC_AC_TYPE_UNKNOWN ) return _return_invalid_param(__func__); + if(!nfc_manager_is_activated()) + { + return NFC_ERROR_NOT_ACTIVATED; + } + switch( type ){ case NFC_AC_TYPE_BT: net_ac_type = NET_NFC_CONN_HANDOVER_CARRIER_BT; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/test/network_nfc_test.c b/test/network_nfc_test.c index a5fa3e5..d72f572 100755 --- a/test/network_nfc_test.c +++ b/test/network_nfc_test.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -451,6 +451,7 @@ void _target_discovered_cb2(nfc_discovered_type_e type, nfc_p2p_target_h target, } + void recv_ndef_from_peer(nfc_error_e error, void *user_data){ int ret ; success = 0; @@ -462,6 +463,26 @@ void recv_ndef_from_peer(nfc_error_e error, void *user_data){ } +void _activation_changed_cb(bool activated , void *user_data){ + if( activated == true){ + printf("NET_NFC_MESSAGE_INIT received\n"); + }else if( activated == false){ + printf("NET_NFC_MESSAGE_DEINIT received\n"); + } +} + + +void on_activation_changed_cb_test(nfc_error_e error, void *user_data){ + int ret ; + success = 0; + timeout_counter = 30; + ret = nfc_manager_set_activation_changed_cb(_activation_changed_cb , NULL); + printf("Now, wait NET_NFC_MESSAGE_INIT or NET_NFC_MESSAGE_DEINIT\n"); + ecore_timer_add(1, timeout_handler, NULL); + +} + + Eina_Bool check_terminate(void *data){ if( is_terminate ){ @@ -477,6 +498,7 @@ char *menu = "------------------\n" " 0. NFC OFF\n" " 1. NFC ON\n" + " 2. ON/OFF on_activation_changed_cb check\n" "------------------\n" " a. ndef record test\n" @@ -491,6 +513,7 @@ char *menu = " h. OFF nfc_manager_enable_system_handler\n" + "------------------\n" ">"; @@ -565,6 +588,11 @@ int main(int argc, char ** argv) elm_shutdown(); return 0; + case '2': + ret = nfc_manager_initialize(on_activation_changed_cb_test,NULL); + print_result("on_activation_changed_cb", ret); + break; + case 'a': ret = nfc_manager_initialize(ndef_record_create_test,NULL); print_result("nfc_manager_initialize", ret); @@ -604,6 +632,7 @@ int main(int argc, char ** argv) return 0; + default: printf("wrong selection!\n"); is_terminate = 1;