ADD_DEFINITIONS("-D_GNU_SOURCE")
ADD_SUBDIRECTORY(src/commonlib)
-ADD_SUBDIRECTORY(src/clientlib)
ADD_SUBDIRECTORY(src/manager)
-ADD_SUBDIRECTORY(src/plugin)
\ No newline at end of file
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
-
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
-
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
-
Name: nfc-manager
Summary: NFC framework manager
-Version: 0.1.146
+Version: 0.1.147
Release: 0
Group: Network & Connectivity/NFC
License: Flora-1.1
This package contains the development files for NFC Common library.
-%package -n nfc-client-lib
-Summary: NFC client library
-Group: Development/Libraries
-Requires: nfc-common-lib = %{version}-%{release}
-
-
-%description -n nfc-client-lib
-A library for Tizen NFC Client.
-
-
-%package -n nfc-client-lib-devel
-Summary: NFC client library (devel)
-Group: Network & Connectivity/Development
-Requires: nfc-client-lib = %{version}-%{release}
-
-
-%description -n nfc-client-lib-devel
-This package contains the development files for NFC Client library.
-
%build
export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
install -D -m 0644 LICENSE.Flora %{buildroot}/%{_datadir}/license/nfc-common-lib
install -D -m 0644 LICENSE.Flora %{buildroot}/%{_datadir}/license/%{name}
-install -D -m 0644 LICENSE.Flora %{buildroot}/%{_datadir}/license/nfc-client-lib
#install -D -m 0644 LICENSE.Flora %{buildroot}/%{_datadir}/license/nfc-client-test
systemctl restart %{name}.service
fi
-
-%post -n nfc-client-lib
-/sbin/ldconfig
-
-/usr/sbin/setcap cap_mac_override+ep /usr/bin/nfc-manager-daemon
-
-%postun -n nfc-client-lib -p /sbin/ldconfig
-
%postun
/sbin/ldconfig
%{_datadir}/license/%{name}
-%files -n nfc-client-lib
-%manifest nfc-client-lib.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libnfc.so
-%{_libdir}/libnfc.so.*
-%{_datadir}/license/nfc-client-lib
-
-
-%files -n nfc-client-lib-devel
-%manifest nfc-client-lib-devel.manifest
-%defattr(-,root,root,-)
-%{_libdir}/pkgconfig/nfc.pc
-%{_includedir}/nfc/*.h
-
-
%files -n nfc-common-lib
%manifest nfc-common-lib.manifest
%defattr(-,root,root,-)
%{_libdir}/libnfc-common-lib.so
%{_libdir}/libnfc-common-lib.so.*
-/usr/etc/package-manager/parserlib/metadata/libcardemulation_plugin.so
-/usr/etc/package-manager/parserlib/metadata/libuseese_plugin.so
%{_datadir}/license/nfc-common-lib
%{_datadir}/nfc-manager-daemon/sounds/Operation_sdk.wav
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(nfc-client-lib C)
-
-#SET(NFC_CLIENT_LIB "nfc-client-lib")
-SET(NFC_CLIENT_LIB "nfc")
-SET(VERSION_MAJOR 1)
-SET(VERSION ${VERSION_MAJOR}.0.0)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-include_directories(${CMAKE_SOURCE_DIR}/src/commonlib)
-include_directories(${CMAKE_SOURCE_DIR}/src/commonlib/include)
-include_directories(${CMAKE_SOURCE_DIR}/src/manager/include)
-
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} CLIENT_SRCS)
-
-IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
- SET(CMAKE_BUILD_TYPE "Release")
-ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(clientlib_pkges REQUIRED dlog vconf gthread-2.0)
-
-FOREACH(flag ${clientlib_pkges_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-MESSAGE("CHECK MODULE in MANAGER ${clientlib_pkges_LDFLAGS}")
-
-# this for NFC flag
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden")
-
-SET(ARM_CFLAGS "${ARM_CLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic")
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Wl,-z,nodelete")
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF("${ARCH}" MATCHES "^arm.*")
- ADD_DEFINITIONS("-DTARGET")
- MESSAGE("add -DTARGET")
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM_CFLAGS}")
-ENDIF()
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-ADD_LIBRARY(${NFC_CLIENT_LIB} SHARED ${CLIENT_SRCS})
-SET_TARGET_PROPERTIES(${NFC_CLIENT_LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${NFC_CLIENT_LIB} PROPERTIES VERSION ${VERSION})
-TARGET_LINK_LIBRARIES(${NFC_CLIENT_LIB} ${clientlib_pkges_LDFLAGS} nfc-common-lib)
-
-LINK_DIRECTORIES(${CMAKE_BUILD_DIR}/src/commonlib)
-
-
-SET(CLIENT_HEADER
- ${CMAKE_SOURCE_DIR}/src/commonlib/include/net_nfc_typedef.h
- include/net_nfc.h
- include/net_nfc_data.h
- include/net_nfc_target_info.h
- include/net_nfc_ndef_message.h
- include/net_nfc_ndef_record.h
- include/net_nfc_sign_record.h
- include/net_nfc_ndef_message_handover.h
- include/net_nfc_client_context.h
- include/net_nfc_client_manager.h
- include/net_nfc_client_system_handler.h
- include/net_nfc_client_transceive.h
- include/net_nfc_client_tag.h
- include/net_nfc_client_ndef.h
- include/net_nfc_client_llcp.h
- include/net_nfc_client_p2p.h
- include/net_nfc_client_snep.h
- include/net_nfc_client_handover.h
- include/net_nfc_client_se.h
- include/net_nfc_client_tag_felica.h
- include/net_nfc_client_tag_jewel.h
- include/net_nfc_tag_mifare.h
- include/net_nfc_client_test.h
- include/net_nfc_client_hce.h
-)
-
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/nfc.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/nfc.pc)
-
-IF (TIZEN_ARCH_64)
- INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${NFC_CLIENT_LIB}.pc DESTINATION /usr/lib64/pkgconfig)
-ELSE (TIZEN_ARCH_64)
- INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${NFC_CLIENT_LIB}.pc DESTINATION /usr/lib/pkgconfig)
-ENDIF(TIZEN_ARCH_64)
-
-IF (TIZEN_ARCH_64)
- INSTALL(TARGETS ${NFC_CLIENT_LIB} DESTINATION lib64)
-ELSE (TIZEN_ARCH_64)
- INSTALL(TARGETS ${NFC_CLIENT_LIB} DESTINATION lib)
-ENDIF(TIZEN_ARCH_64)
-
-FOREACH(hfile ${CLIENT_HEADER})
- INSTALL(FILES ${hfile} DESTINATION include/nfc)
-ENDFOREACH(hfile)
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_H__
-#define __NET_NFC_H__
-
-#include "net_nfc_typedef.h"
-#include "net_nfc_data.h"
-#include "net_nfc_target_info.h"
-#include "net_nfc_ndef_message.h"
-#include "net_nfc_ndef_record.h"
-#include "net_nfc_sign_record.h"
-#include "net_nfc_ndef_message_handover.h"
-
-#include "net_nfc_client_context.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_system_handler.h"
-#include "net_nfc_client_transceive.h"
-#include "net_nfc_client_tag.h"
-#include "net_nfc_client_ndef.h"
-#include "net_nfc_client_llcp.h"
-#include "net_nfc_client_p2p.h"
-#include "net_nfc_client_snep.h"
-#include "net_nfc_client_handover.h"
-#include "net_nfc_client_se.h"
-#include "net_nfc_client_tag_felica.h"
-#include "net_nfc_client_tag_jewel.h"
-#include "net_nfc_tag_mifare.h"
-#include "net_nfc_client_test.h"
-#include "net_nfc_client_hce.h"
-
-
-#endif //__NET_NFC_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_H__
-#define __NET_NFC_CLIENT_H__
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* TODO : change to internal header */
-void net_nfc_client_gdbus_init(void);
-
-void net_nfc_client_gdbus_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_CONTEXT_H__
-#define __NET_NFC_CLIENT_CONTEXT_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NET_NFC_SERVICE_EMPTY_TYPE \
- "http://tizen.org/appcontrol/operation/nfc/empty"
-#define NET_NFC_SERVICE_WELL_KNOWN_TYPE \
- "http://tizen.org/appcontrol/operation/nfc/wellknown"
-#define NET_NFC_SERVICE_EXTERNAL_TYPE \
- "http://tizen.org/appcontrol/operation/nfc/external"
-#define NET_NFC_SERVICE_MIME_TYPE \
- "http://tizen.org/appcontrol/operation/nfc/mime"
-#define NET_NFC_SERVICE_URI_TYPE \
- "http://tizen.org/appcontrol/operation/nfc/uri"
-
-
-net_nfc_error_e net_nfc_client_initialize();
-
-net_nfc_error_e net_nfc_client_deinitialize();
-
-net_nfc_error_e net_nfc_client_is_nfc_supported(int *state);
-
-net_nfc_error_e net_nfc_client_get_nfc_state(int *state);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_CONTEXT_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_HANDOVER_H__
-#define __NET_NFC_CLIENT_HANDOVER_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum
-{
- NET_NFC_HANDOVER_START,
- NET_NFC_HANDOVER_FINISH,
-}
-net_nfc_handover_event_e;
-
-typedef void (*net_nfc_p2p_connection_handover_completed_cb)(
- net_nfc_error_e result,
- net_nfc_conn_handover_carrier_type_e carrier,
- data_h ac_data,
- void *user_data);
-
-typedef void (*net_nfc_connection_handover_event_cb)(
- net_nfc_handover_event_e event,
- net_nfc_error_e result,
- net_nfc_conn_handover_carrier_type_e carrier,
- data_h ac_data,
- data_h ndef_message,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_handover_free_alternative_carrier_data(
- net_nfc_connection_handover_info_h info_handle);
-
-
-net_nfc_error_e net_nfc_client_handover_get_alternative_carrier_type(
- net_nfc_connection_handover_info_h info_handle,
- net_nfc_conn_handover_carrier_type_e *type);
-
-
-net_nfc_error_e net_nfc_client_handover_get_alternative_carrier_data(
- net_nfc_connection_handover_info_h info_handle,
- data_h *data);
-
-
-net_nfc_error_e net_nfc_client_p2p_connection_handover(
- net_nfc_target_handle_h handle,
- net_nfc_conn_handover_carrier_type_e arg_type,
- net_nfc_p2p_connection_handover_completed_cb callback,
- void *cb_data);
-
-
-net_nfc_error_e net_nfc_client_p2p_connection_handover_sync(
- net_nfc_target_handle_h handle,
- net_nfc_conn_handover_carrier_type_e arg_type,
- net_nfc_conn_handover_carrier_type_e *out_carrier,
- data_h *out_ac_data);
-
-
-void net_nfc_client_handover_set_handover_event_cb(
- net_nfc_connection_handover_event_cb callback,
- void *user_data);
-
-void net_nfc_client_handover_unset_handover_event_cb(void);
-
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_handover_init(void);
-
-void net_nfc_client_handover_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_HANDOVER_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_HCE_H__
-#define __NET_NFC_CLIENT_HCE_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*************Hce Callbacks*********/
-
-typedef void (*net_nfc_client_hce_event_cb)(
- net_nfc_target_handle_h handle,
- net_nfc_hce_event_t event,
- data_h apdu,
- void *user_data);
-
-/************* Hce API's*************/
-
-net_nfc_error_e net_nfc_client_hce_set_event_received_cb(
- net_nfc_client_hce_event_cb callback, void *user_data);
-net_nfc_error_e net_nfc_client_hce_unset_event_received_cb(void);
-
-net_nfc_error_e net_nfc_client_hce_response_apdu_sync(
- net_nfc_target_handle_h handle, data_h resp_apdu_data);
-
-
-/* internal */
-net_nfc_error_e net_nfc_client_hce_init(void);
-void net_nfc_client_hce_deinit(void);
-
-void net_nfc_client_hce_process_received_event(int event,
- net_nfc_target_handle_h handle, data_h data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_HCE_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_HCE_IPC_H__
-#define __NET_NFC_CLIENT_HCE_IPC_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* internal */
-net_nfc_error_e net_nfc_client_hce_ipc_init();
-void net_nfc_client_hce_ipc_deinit();
-bool net_nfc_client_hce_ipc_is_initialized();
-
-bool net_nfc_server_hce_ipc_send_to_server(int type,
- net_nfc_target_handle_s *handle, data_s *data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_HCE_IPC_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_LLCP_H__
-#define __NET_NFC_CLIENT_LLCP_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*net_nfc_client_llcp_config_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_listen_completed)(net_nfc_error_e result,
- net_nfc_llcp_socket_t client_socket,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_accept_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_reject_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_connect_completed)(net_nfc_error_e result,
- net_nfc_llcp_socket_t client_socket,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_connect_sap_completed)(
- net_nfc_error_e result,
- net_nfc_llcp_socket_t client_socket,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_send_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_send_to_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_receive_completed)(net_nfc_error_e result,
- data_h data,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_receive_from_completed)(
- net_nfc_error_e result,
- sap_t sap,
- data_h data,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_close_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_llcp_disconnect_completed)(
- net_nfc_error_e result,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_config(net_nfc_llcp_config_info_h config,
- net_nfc_client_llcp_config_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_config_sync
- (net_nfc_llcp_config_info_h config);
-
-net_nfc_error_e net_nfc_client_llcp_get_config
- (net_nfc_llcp_config_info_h *config);
-
-net_nfc_error_e net_nfc_client_llcp_listen(net_nfc_llcp_socket_t socket,
- const char *service_name,
- sap_t sap,
- net_nfc_client_llcp_listen_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_listen_sync(net_nfc_llcp_socket_t socket,
- const char *service_name,
- sap_t sap,
- net_nfc_llcp_socket_t *out_socket);
-
-net_nfc_error_e net_nfc_client_llcp_accept(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_accept_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_accept_sync(net_nfc_llcp_socket_t socket);
-
-net_nfc_error_e net_nfc_client_llcp_reject(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_reject_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_reject_sync(net_nfc_llcp_socket_t socket);
-
-net_nfc_error_e net_nfc_client_llcp_connect(net_nfc_llcp_socket_t socket,
- const char *service_name,
- net_nfc_client_llcp_connect_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_connect_sync(net_nfc_llcp_socket_t socket,
- const char *service_name,
- net_nfc_llcp_socket_t *out_socket);
-
-net_nfc_error_e net_nfc_client_llcp_send(net_nfc_llcp_socket_t socket,
- data_h data,
- net_nfc_client_llcp_send_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_send_sync(net_nfc_llcp_socket_t socket,
- data_h data);
-
-net_nfc_error_e net_nfc_client_llcp_send_to(net_nfc_llcp_socket_t socket,
- sap_t sap,
- data_h data,
- net_nfc_client_llcp_send_to_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_send_to_sync(net_nfc_llcp_socket_t socket,
- sap_t sap,
- data_h data);
-
-net_nfc_error_e net_nfc_client_llcp_receive(net_nfc_llcp_socket_t socket,
- size_t request_length,
- net_nfc_client_llcp_receive_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_receive_sync(net_nfc_llcp_socket_t socket,
- size_t request_length,
- data_h *out_data);
-
-net_nfc_error_e net_nfc_client_llcp_receive_from(net_nfc_llcp_socket_t socket,
- size_t request_length,
- net_nfc_client_llcp_receive_from_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_receive_from_sync(
- net_nfc_llcp_socket_t socket,
- size_t request_length,
- sap_t *out_sap,
- data_h *out_data);
-
-net_nfc_error_e net_nfc_client_llcp_close(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_close_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_close_sync(net_nfc_llcp_socket_t socket);
-
-net_nfc_error_e net_nfc_client_llcp_disconnect(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_disconnect_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_disconnect_sync(
- net_nfc_llcp_socket_t socket);
-
-void net_nfc_client_llcp_create_socket(net_nfc_llcp_socket_t *socket,
- net_nfc_llcp_socket_option_h option);
-
-net_nfc_error_e net_nfc_client_llcp_get_local_config(
- net_nfc_llcp_config_info_h *config);
-
-net_nfc_error_e net_nfc_client_llcp_get_local_socket_option(
- net_nfc_llcp_socket_t socket,
- net_nfc_llcp_socket_option_h *option);
-
-net_nfc_error_e net_nfc_client_llcp_create_socket_option(
- net_nfc_llcp_socket_option_h *option,
- uint16_t miu,
- uint8_t rw,
- net_nfc_socket_type_e type);
-
-net_nfc_error_e net_nfc_client_llcp_socket_option_default(
- net_nfc_llcp_socket_option_h *option);
-
-net_nfc_error_e net_nfc_client_llcp_get_socket_option_miu(
- net_nfc_llcp_socket_option_h option,
- uint16_t *miu);
-
-net_nfc_error_e net_nfc_client_llcp_set_socket_option_miu(
- net_nfc_llcp_socket_option_h option,
- uint16_t miu);
-
-net_nfc_error_e net_nfc_client_llcp_get_socket_option_rw(
- net_nfc_llcp_socket_option_h option,
- uint8_t *rt);
-
-net_nfc_error_e net_nfc_client_llcp_set_socket_option_rw(
- net_nfc_llcp_socket_option_h option,
- uint8_t rt);
-
-net_nfc_error_e net_nfc_client_llcp_get_socket_option_type(
- net_nfc_llcp_socket_option_h option,
- net_nfc_socket_type_e *type);
-
-net_nfc_error_e net_nfc_client_llcp_set_socket_option_type(
- net_nfc_llcp_socket_option_h option,
- net_nfc_socket_type_e type);
-
-net_nfc_error_e net_nfc_client_llcp_free_socket_option(
- net_nfc_llcp_socket_option_h option);
-
-net_nfc_error_e net_nfc_client_llcp_create_config(
- net_nfc_llcp_config_info_h *config,
- uint16_t miu,
- uint16_t wks,
- uint8_t lto,
- uint8_t option);
-
-net_nfc_error_e net_nfc_client_llcp_create_config_default(
- net_nfc_llcp_config_info_h *config);
-
-net_nfc_error_e net_nfc_client_llcp_get_config_miu(
- net_nfc_llcp_config_info_h config,
- uint16_t *miu);
-
-net_nfc_error_e net_nfc_client_llcp_get_config_wks(
- net_nfc_llcp_config_info_h config,
- uint16_t *wks);
-
-net_nfc_error_e net_nfc_client_llcp_get_config_lto(
- net_nfc_llcp_config_info_h config,
- uint8_t *lto);
-
-net_nfc_error_e net_nfc_client_llcp_get_config_option(
- net_nfc_llcp_config_info_h config,
- uint8_t *option);
-
-net_nfc_error_e net_nfc_client_llcp_set_config_miu(
- net_nfc_llcp_config_info_h config,
- uint16_t miu);
-
-net_nfc_error_e net_nfc_client_llcp_set_config_wks(
- net_nfc_llcp_config_info_h config,
- uint16_t wks);
-
-net_nfc_error_e net_nfc_client_llcp_set_config_lto(
- net_nfc_llcp_config_info_h config,
- uint8_t lto);
-
-net_nfc_error_e net_nfc_client_llcp_set_config_option(
- net_nfc_llcp_config_info_h config,
- uint8_t option);
-
-net_nfc_error_e net_nfc_client_llcp_free_config(
- net_nfc_llcp_config_info_h config);
-
-net_nfc_error_e net_nfc_client_llcp_create_socket_option_default(
- net_nfc_llcp_socket_option_h *option);
-
-net_nfc_error_e net_nfc_client_llcp_connect_sap(net_nfc_llcp_socket_t socket,
- sap_t sap,
- net_nfc_client_llcp_connect_sap_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_llcp_connect_sap_sync(
- net_nfc_llcp_socket_t socket,
- sap_t sap,
- net_nfc_llcp_socket_t *out_socket);
-
-
-net_nfc_error_e net_nfc_client_llcp_init(void);
-
-void net_nfc_client_llcp_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_LLCP_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_MANAGER_H__
-#define __NET_NFC_CLIENT_MANAGER_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*net_nfc_client_manager_set_active_completed)(
- net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_manager_get_server_state_completed)(
- net_nfc_error_e result,
- unsigned int state,
- void *user_data);
-
-typedef void (*net_nfc_client_manager_activated)(bool state,
- void *user_data);
-
-void net_nfc_client_manager_set_activated(
- net_nfc_client_manager_activated callback,
- void *user_data);
-
-void net_nfc_client_manager_unset_activated(void);
-
-net_nfc_error_e net_nfc_client_manager_set_active(int state,
- net_nfc_client_manager_set_active_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_manager_set_active_sync(int state);
-
-net_nfc_error_e net_nfc_client_manager_get_server_state(
- net_nfc_client_manager_get_server_state_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_manager_get_server_state_sync(
- unsigned int *state);
-
-bool net_nfc_client_manager_is_activated(void);
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_manager_init(void);
-
-void net_nfc_client_manager_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_NDEF_H__
-#define __NET_NFC_CLIENT_NDEF_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*net_nfc_client_ndef_read_completed)(net_nfc_error_e result,
- ndef_message_h message,
- void *user_data);
-
-typedef void (*net_nfc_client_ndef_write_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_ndef_make_read_only_completed)(
- net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_ndef_format_completed)(net_nfc_error_e result,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_ndef_read(net_nfc_target_handle_h handle,
- net_nfc_client_ndef_read_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_ndef_read_sync(net_nfc_target_handle_h handle,
- ndef_message_h *message);
-
-net_nfc_error_e net_nfc_client_ndef_write(net_nfc_target_handle_h handle,
- ndef_message_h message,
- net_nfc_client_ndef_write_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_ndef_write_sync(net_nfc_target_handle_h handle,
- ndef_message_h message);
-
-net_nfc_error_e net_nfc_client_ndef_make_read_only(
- net_nfc_target_handle_h handle,
- net_nfc_client_ndef_make_read_only_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_ndef_make_read_only_sync(
- net_nfc_target_handle_h handle);
-
-net_nfc_error_e net_nfc_client_ndef_format(net_nfc_target_handle_h handle,
- data_h key,
- net_nfc_client_ndef_format_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_ndef_format_sync(
- net_nfc_target_handle_h handle,
- data_h key);
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_ndef_init(void);
-
-void net_nfc_client_ndef_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_NDEF_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_P2P_H__
-#define __NET_NFC_CLIENT_P2P_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* p2p callbacks */
-
-typedef void (*net_nfc_client_p2p_send_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_p2p_device_discovered)(
- net_nfc_target_handle_h handle_info,
- void *user_data);
-
-typedef void (*net_nfc_client_p2p_device_detached)(void *user_data);
-
-typedef void (*net_nfc_client_p2p_data_received)(data_h p2p_data,
- void *user_data);
-
-/* P2P client API's*/
-net_nfc_error_e net_nfc_client_p2p_send(net_nfc_target_handle_h handle,
- data_h data,
- net_nfc_client_p2p_send_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_p2p_send_sync(net_nfc_target_handle_h handle,
- data_h data);
-
-
-/* P2P client API's - used for registering callbacks*/
-void net_nfc_client_p2p_set_data_received(
- net_nfc_client_p2p_data_received callback,
- void *user_data);
-
-void net_nfc_client_p2p_set_device_detached(
- net_nfc_client_p2p_device_detached callback,
- void *user_data);
-
-void net_nfc_client_p2p_set_device_discovered(
- net_nfc_client_p2p_device_discovered callback,
- void *user_data);
-
-/* P2P client API's - used for unregistering callbacks*/
-void net_nfc_client_p2p_unset_data_received(void);
-
-void net_nfc_client_p2p_unset_device_detached(void);
-
-void net_nfc_client_p2p_unset_device_discovered(void);
-
-/* TODO : move to internal header */
-/* Init/Deint function calls*/
-net_nfc_error_e net_nfc_client_p2p_init(void);
-
-void net_nfc_client_p2p_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_P2P_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_SE_H__
-#define __NET_NFC_CLIENT_SE_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*************Secure Element Callbacks*********/
-typedef void (*net_nfc_se_set_se_cb)(
- net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_se_get_se_cb)(
- net_nfc_error_e result,
- net_nfc_se_type_e se_type,
- void *user_data);
-
-typedef void (*net_nfc_se_set_card_emulation_cb)(
- net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_se_open_se_cb)(
- net_nfc_error_e result,
- net_nfc_target_handle_h handle,
- void *user_data);
-
-typedef void (*net_nfc_se_close_se_cb)(
- net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_se_get_atr_cb)(
- net_nfc_error_e result,
- data_h data,
- void *user_data);
-
-typedef void (*net_nfc_se_send_apdu_cb)(
- net_nfc_error_e result,
- data_h data,
- void *user_data);
-
-typedef void (*net_nfc_client_se_event)(
- net_nfc_message_e event,
- void *user_data);
-
-typedef void (*net_nfc_client_se_transaction_event)(
- net_nfc_se_type_e se_type,
- data_h aid,
- data_h param,
- void *user_data);
-
-typedef void (*net_nfc_client_se_ese_detected_event)(
- net_nfc_target_handle_h handle,
- int dev_type,
- data_h data,
- void *user_data);
-
-typedef bool (*net_nfc_client_se_registered_aid_cb)(net_nfc_se_type_e se_type,
- const char *aid, bool readonly, void *user_data);
-
-typedef bool (*net_nfc_client_se_registered_handler_cb)(const char *package,
- int count, void *user_data);
-
-/************* Secure Element API's*************/
-
-net_nfc_error_e net_nfc_client_se_set_secure_element_type(
- net_nfc_se_type_e se_type,
- net_nfc_se_set_se_cb callback,
- void *user_data);
-
-
-net_nfc_error_e net_nfc_client_se_set_secure_element_type_sync(
- net_nfc_se_type_e se_type);
-
-net_nfc_error_e net_nfc_client_se_get_secure_element_type_sync(
- net_nfc_se_type_e *se_type);
-
-net_nfc_error_e net_nfc_set_card_emulation_mode_sync(
- net_nfc_card_emulation_mode_t mode);
-
-net_nfc_error_e net_nfc_get_card_emulation_mode_sync(
- net_nfc_card_emulation_mode_t *se_type);
-
-net_nfc_error_e net_nfc_client_se_open_internal_secure_element(
- net_nfc_se_type_e se_type,
- net_nfc_se_open_se_cb callback,
- void *user_data);
-
-
-net_nfc_error_e net_nfc_client_se_open_internal_secure_element_sync(
- net_nfc_se_type_e se_type,
- net_nfc_target_handle_h *handle);
-
-
-net_nfc_error_e net_nfc_client_se_close_internal_secure_element(
- net_nfc_target_handle_h handle,
- net_nfc_se_close_se_cb callback,
- void *user_data);
-
-
-net_nfc_error_e net_nfc_client_se_close_internal_secure_element_sync(
- net_nfc_target_handle_h handle);
-
-
-net_nfc_error_e net_nfc_client_se_get_atr(
- net_nfc_target_handle_h handle,
- net_nfc_se_get_atr_cb callback,
- void *user_data);
-
-
-net_nfc_error_e net_nfc_client_se_get_atr_sync(
- net_nfc_target_handle_h handle,
- data_h *atr);
-
-
-net_nfc_error_e net_nfc_client_se_send_apdu(
- net_nfc_target_handle_h handle,
- data_h apdu_data,
- net_nfc_se_send_apdu_cb callback,
- void *user_data);
-
-
-net_nfc_error_e net_nfc_client_se_send_apdu_sync(
- net_nfc_target_handle_h handle,
- data_h apdu_data,
- data_h *response);
-
-
-/************* Secure Element CallBack Register/Deregister functions*************/
-
-void net_nfc_client_se_set_ese_detection_cb(
- net_nfc_client_se_ese_detected_event callback,
- void *user_data);
-
-void net_nfc_client_se_unset_ese_detection_cb(void);
-
-void net_nfc_client_se_set_transaction_event_cb(
- net_nfc_se_type_e se_type,
- net_nfc_client_se_transaction_event callback,
- void *user_data);
-
-void net_nfc_client_se_unset_transaction_event_cb(net_nfc_se_type_e type);
-
-void net_nfc_client_se_set_event_cb(net_nfc_client_se_event callback,
- void *user_data);
-
-void net_nfc_client_se_unset_event_cb(void);
-
-net_nfc_error_e net_nfc_client_se_set_transaction_fg_dispatch(int mode);
-
-
-/* new card emulation */
-net_nfc_error_e net_nfc_client_se_is_activated_aid_handler_sync(
- net_nfc_se_type_e se_type, const char *aid, bool *activated);
-
-net_nfc_error_e net_nfc_client_se_is_activated_category_handler_sync(
- net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, bool *activated);
-
-net_nfc_error_e net_nfc_client_se_get_registered_aids_count_sync(
- net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category,
- size_t *count);
-
-net_nfc_error_e net_nfc_client_se_foreach_registered_aids_sync(
- net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category,
- net_nfc_client_se_registered_aid_cb callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_se_register_aids_sync(net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, const char *aid, ...);
-net_nfc_error_e net_nfc_client_se_unregister_aid_sync(net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, const char *aid);
-net_nfc_error_e net_nfc_client_se_unregister_aids_sync(net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category);
-
-
-net_nfc_error_e net_nfc_client_se_set_default_route_sync(
- net_nfc_se_type_e switch_on, net_nfc_se_type_e switch_off,
- net_nfc_se_type_e battery_off);
-
-/* internal */
-net_nfc_error_e net_nfc_client_se_add_route_aid_sync(
- const char *package, net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, const char *aid,
- bool unlock_required, int power);
-
-net_nfc_error_e net_nfc_client_se_remove_route_aid_sync(
- const char *package, const char *aid);
-
-net_nfc_error_e net_nfc_client_se_remove_package_aids_sync(
- const char *package);
-
-net_nfc_error_e net_nfc_client_se_foreach_registered_handlers_sync(
- net_nfc_card_emulation_category_t category,
- net_nfc_client_se_registered_handler_cb callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_se_get_handler_storage_info_sync(
- net_nfc_card_emulation_category_t category, int *used, int *max);
-
-net_nfc_error_e net_nfc_client_se_get_conflict_handlers_sync(
- const char *package, net_nfc_card_emulation_category_t category,
- const char *aid, char ***handlers);
-
-net_nfc_error_e net_nfc_client_se_set_preferred_handler_sync(bool state);
-
-//net_nfc_error_e net_nfc_client_hce_get_route_table_sync(data_h arg_aid);
-
-
-/* TODO : move to internal header */
-/************* Secure Element Init/Deint*************/
-
-net_nfc_error_e net_nfc_client_se_init(void);
-
-void net_nfc_client_se_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_SE_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_SNEP_H__
-#define __NET_NFC_CLIENT_SNEP_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*net_nfc_client_snep_event_cb) (
- net_nfc_snep_handle_h target,
- net_nfc_snep_type_t event,
- net_nfc_error_e result,
- ndef_message_h msg,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_snep_start_server(
- net_nfc_target_handle_h target,
- const char *san,
- sap_t sap,
- net_nfc_client_snep_event_cb callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_snep_start_client(
- net_nfc_target_handle_h target,
- const char *san,
- sap_t sap,
- net_nfc_client_snep_event_cb callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_snep_send_client_request(
- net_nfc_snep_handle_h handle,
- net_nfc_snep_type_t snep_type,
- ndef_message_h msg,
- net_nfc_client_snep_event_cb callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_snep_send_client_request_sync(
- net_nfc_target_handle_h target,
- net_nfc_snep_type_t snep_type,
- ndef_message_h msg,
- net_nfc_snep_type_t *resp_type,
- ndef_message_h *response);
-
-net_nfc_error_e net_nfc_client_snep_stop_service(
- net_nfc_target_handle_h target,
- net_nfc_snep_handle_h service,
- net_nfc_client_snep_event_cb callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_snep_stop_service_sync(
- net_nfc_target_handle_h target,
- net_nfc_snep_handle_h service);
-
-net_nfc_error_e net_nfc_client_snep_register_server(const char *san,
- sap_t sap,
- net_nfc_client_snep_event_cb callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_snep_unregister_server(const char *san,
- sap_t sap);
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_snep_init(void);
-
-void net_nfc_client_snep_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_SNEP_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_SYSTEM_HANDLER_H__
-#define __NET_NFC_CLIENT_SYSTEM_HANDLER_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*net_nfc_client_popup_set_state_callback)(
- net_nfc_error_e result,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_sys_handler_set_state(int state,
- net_nfc_client_popup_set_state_callback callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_sys_handler_set_state_force(int state,
- net_nfc_client_popup_set_state_callback callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_sys_handler_set_state_sync(int state);
-
-net_nfc_error_e net_nfc_client_sys_handler_set_state_force_sync(int state);
-
-net_nfc_error_e net_nfc_client_sys_handler_set_launch_popup_state(int enable);
-
-net_nfc_error_e net_nfc_client_sys_handler_set_launch_popup_state_force(
- int enable);
-
-net_nfc_error_e net_nfc_client_sys_handler_get_launch_popup_state(int *state);
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_sys_handler_init(void);
-
-void net_nfc_client_sys_handler_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_SYSTEM_HANDLER_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_TAG_H__
-#define __NET_NFC_CLIENT_TAG_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if 0
-typedef void (*net_nfc_client_tag_is_tag_connected_completed)(
- net_nfc_error_e result,
- net_nfc_target_type_e dev_type,
- void *user_data);
-
-typedef void (*net_nfc_client_tag_get_current_tag_info_completed)(
- net_nfc_error_e result,
- net_nfc_target_info_h info,
- void *user_data);
-
-typedef void (*net_nfc_client_tag_get_current_target_handle_completed)(
- net_nfc_error_e result,
- net_nfc_target_handle_h handle,
- void *user_data);
-#endif
-typedef void (*net_nfc_client_tag_tag_discovered)(net_nfc_target_info_h info,
- void *user_data);
-
-typedef void (*net_nfc_client_tag_tag_detached)(void *user_data);
-
-#if 0
-net_nfc_error_e net_nfc_client_tag_is_tag_connected(
- net_nfc_client_tag_is_tag_connected_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_tag_get_current_tag_info(
- net_nfc_client_tag_get_current_tag_info_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_tag_get_current_target_handle(
- net_nfc_client_tag_get_current_target_handle_completed callback,
- void *user_data);
-#endif
-net_nfc_error_e net_nfc_client_tag_is_tag_connected_sync(
- net_nfc_target_type_e *dev_type);
-
-net_nfc_error_e net_nfc_client_tag_get_current_tag_info_sync(
- net_nfc_target_info_h *info);
-
-net_nfc_error_e net_nfc_client_barcode_get_barcode_sync(
- unsigned char **barcode, int* barcode_len);
-
-net_nfc_error_e net_nfc_client_tag_get_current_target_handle_sync(
- net_nfc_target_handle_h *handle);
-
-void net_nfc_client_tag_set_tag_discovered(
- net_nfc_client_tag_tag_discovered callback,
- void *user_data);
-
-void net_nfc_client_tag_unset_tag_discovered(void);
-
-void net_nfc_client_tag_set_tag_detached(
- net_nfc_client_tag_tag_detached callback,
- void *user_data);
-
-void net_nfc_client_tag_unset_tag_detached(void);
-
-
-/* internal function */
-void net_nfc_client_tag_set_filter(net_nfc_event_filter_e filter);
-
-net_nfc_event_filter_e net_nfc_client_tag_get_filter(void);
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_tag_init(void);
-
-void net_nfc_client_tag_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_TAG_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_TAG_FELICA_H__
-#define __NET_NFC_CLIENT_TAG_FELICA_H__
-
-#include "net_nfc_typedef.h"
-#include "net_nfc_client_transceive.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-
-@addtogroup NET_NFC_MANAGER_TAG
-@{
-
- send poll request to felica tag.
- Use this command to acquire and identify a card. Acqusition of IDm and PMm is possible with this command.
- By specifying a request code , you can acquire system code or communication performance of the system.
- By specifying a time slot, you can designate the maximum number of time slots possible to return response.
-
- NET_NFC_FELICA_POLL_NO_REQUEST = 0x00
- NET_NFC_FELICA_POLL_SYSTEM_CODE_REQUEST = 0x01
- NET_NFC_FELICA_POLL_COMM_SPEED_REQUEST= 0x02
-
- time slot
-
- Time slot Max number of slots
- 0x00, 1
- 0x01, 2
- 0x03, 4
- 0x07, 8
- 0x0f, 16
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] req_code request code with this command
- @param[in] time_slot time slot value
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (SYSTEM_CODE, etc) is not founded
-
-*/
-
-net_nfc_error_e net_nfc_client_felica_poll(net_nfc_target_handle_h handle,
- net_nfc_felica_poll_request_code_e req_code,
- uint8_t time_slote,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-/**
- Use this command to check for the existence of Area / Service specified by Area Code / Service Code
- If the specified Area / Service exists, the card returns version information of the key known as "Key Version" (2 Bytes)
- If the specified Area / Service does not exist, the card returns 0xffff as it s Key Version
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] number_of_area_service the number of specified Area / Service list
- @param[in] area_service_list specified Area / Service list
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (IDm, etc) is not founded
- @exception NET_NFC_OUT_OF_BOUND the length of IDm is not correct. number of services exceed max value
-
-*/
-
-net_nfc_error_e net_nfc_client_felica_request_service(
- net_nfc_target_handle_h handle,
- uint8_t number_of_area_service,
- uint16_t area_service_list[],
- uint8_t number_of_services,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-/**
- Use this command to check whether a card exist
- the Current mode of the card is returned.
-
- Mode
-
- 0x00 Mode0
- 0x01 Mode1
- 0x02 Mode2
- 0x03 Mode3
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (IDm, etc) is not founded
- @exception NET_NFC_OUT_OF_BOUND the length of IDm is not correct
-
-*/
-
-net_nfc_error_e net_nfc_client_felica_request_response(
- net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-/**
- Use this command to read block data from a Service that requires no authentification
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] number_of_service the number of service list to read
- @param[in] service_list specified Service list to read
- @param[in] number_of_blocks the number of blocks to read
- @param[in] block_list the blocks to read
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (IDm, etc) is not founded
- @exception NET_NFC_OUT_OF_BOUND the length of IDm is not correct
-
-*/
-
-net_nfc_error_e net_nfc_client_felica_read_without_encryption(
- net_nfc_target_handle_h handle,
- uint8_t number_of_services,
- uint16_t service_list[],
- uint8_t number_of_blocks,
- uint8_t block_list[],
- nfc_transceive_data_callback callback,
- void *user_data);
-
-/**
- Use this command to write block data to a Service that requires no authentification
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] number_of_service the number of service list to write
- @param[in] service_list specified Service list to write
- @param[in] number_of_blocks the number of blocks to write
- @param[in] block_list the blocks to write
- @param[in] data the data to write
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (IDm, etc) is not founded
- @exception NET_NFC_OUT_OF_BOUND the length of IDm is not correct. number of services exceed max value, the data length to write is exceed the limitation. It should be less than number_of_blocks * 16 bytes
-
-*/
-
-net_nfc_error_e net_nfc_client_felica_write_without_encryption(
- net_nfc_target_handle_h handle,
- uint8_t number_of_services,
- uint16_t service_list[],
- uint8_t number_of_blocks,
- uint8_t block_list[],
- data_h data,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-/**
- Use this command to acquire system code of the system located on a card
- If a card is divided into mutiple system, this command acquires system code of all the system existing in the card
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (IDm, etc) is not founded
- @exception NET_NFC_OUT_OF_BOUND the length of IDm is not correct.
-
-*/
-
-net_nfc_error_e net_nfc_client_felica_request_system_code(
- net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void* trans_param);
-
-/**
-@}
-*/
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //__NET_NFC_CLIENT_TAG_FELICA_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_TAG_INTERNAL_H__
-#define __NET_NFC_CLIENT_TAG_INTERNAL_H__
-
-#include <glib.h>
-
-#include "net_nfc_typedef_internal.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-gboolean net_nfc_client_tag_is_connected(void);
-
-net_nfc_target_info_s *net_nfc_client_tag_get_client_target_info(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_TAG_INTERNAL_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_TAG_JEWEL_H__
-#define __NET_NFC_CLIENT_TAG_JEWEL_H__
-
-#include "net_nfc_typedef.h"
-#include "net_nfc_client_transceive.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-
-@addtogroup NET_NFC_MANAGER_TAG
-@{
-
- read uid from jewel tag.
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (UID, etc) is not founded
-
-*/
-
-net_nfc_error_e net_nfc_client_jewel_read_id(net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-/**
- read one byte of specific address .
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] block block number. (block 0 ~ block E)
- @param[in] byte byte number. Each block has 8 bytes. (byte 0 ~ byte 7)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (UID, etc) is not founded
-
-*/
-
-net_nfc_error_e net_nfc_client_jewel_read_byte(net_nfc_target_handle_h handle,
- uint8_t block,
- uint8_t byte,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-/**
- read all byte from tag .
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied (damaged data is recieved) or error ack is recieved
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (UID, etc) is not founded
-
-*/
-
-
-net_nfc_error_e net_nfc_client_jewel_read_all(net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-
-/**
- operate erase and write cycle . If any of BLOCK-0 to BLOCK-D is locked then write with erase is barred form thoes blocks.
- Additionally 0, D, E blocks are automatically in the lock condition. so write with erase is always barred from thoes blocks.
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] block block number. (block 0 ~ block E)
- @param[in] data the data to write
- @param[in] byte byte number. Each block has 8 bytes. (byte 0 ~ byte 7)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is received from tag
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (UID, etc) is not founded
-
-*/
-
-net_nfc_error_e net_nfc_client_jewel_write_with_erase(
- net_nfc_target_handle_h handle,
- uint8_t block,
- uint8_t byte,
- uint8_t data,
- nfc_transceive_callback callback,
- void *user_data);
-
-
-/**
- operate no erase and write cycle .
-
- The WRITE-NE command is available for three main purposes
- - Lock . to set the ��lock bit�� for a block
- - OTP . to set One-Time-Programmable bits (bytes 2 . 7 of Block-E), where between one and eight OTP bits can be set with a singleWRITE-NE command
- - A fast-write in order to reduce overall time to write data to memory blocks for the first time given that the original condition of memory is zero
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] block block number. (block 0 ~ block E)
- @param[in] data the data to write
- @param[in] byte byte number. Each block has 8 bytes. (byte 0 ~ byte 7)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout is raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is received from tag
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (UID, etc) is not founded
-
-*/
-
-net_nfc_error_e net_nfc_client_jewel_write_with_no_erase(
- net_nfc_target_handle_h handle,
- uint8_t block,
- uint8_t byte,
- uint8_t data,
- nfc_transceive_callback callback,
- void *user_data);
-
-/**
-@}
- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //__NET_NFC_CLIENT_TAG_JEWEL_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_TEST_H__
-#define __NET_NFC_CLIENT_TEST_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*net_nfc_client_test_sim_test_completed)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_test_prbs_test_completed)(
- net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_test_get_firmware_version_completed)(
- net_nfc_error_e result,
- char *version,
- void *user_data);
-typedef void (*net_nfc_client_test_set_ee_data_completed)(
- net_nfc_error_e result,
- void *user_data);
-
-typedef void (*net_nfc_client_test_ese_test_completed)(net_nfc_error_e result,
- void *user_data);
-
-
-net_nfc_error_e net_nfc_client_test_sim_test(
- net_nfc_client_test_sim_test_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_test_sim_test_sync(void);
-
-net_nfc_error_e net_nfc_client_test_prbs_test(uint32_t tech,
- uint32_t rate,
- net_nfc_client_test_prbs_test_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_test_prbs_test_sync(uint32_t tech,
- uint32_t rate);
-
-net_nfc_error_e net_nfc_client_test_get_firmware_version(
- net_nfc_client_test_get_firmware_version_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_test_get_firmware_version_sync(char **version);
-
-net_nfc_error_e net_nfc_client_test_set_ee_data(int mode,
- int reg_id,
- data_h data,
- net_nfc_client_test_set_ee_data_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_test_set_ee_data_sync(int mode,
- int reg_id,
- data_h data);
-
-net_nfc_error_e net_nfc_client_test_ese_test(
- net_nfc_client_test_sim_test_completed callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_test_ese_test_sync(void);
-
-
-
-net_nfc_error_e net_nfc_client_test_set_se_tech_type_sync(net_nfc_se_type_e type, int tech);
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_test_init(void);
-
-void net_nfc_client_test_deinit(void);
-
-net_nfc_error_e net_nfc_client_test_set_listen_tech_mask_sync(uint32_t tech);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_TEST_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_TRANSCEIVE_H__
-#define __NET_NFC_CLIENT_TRANSCEIVE_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*nfc_transceive_callback)(net_nfc_error_e result,
- void *user_data);
-
-typedef void (*nfc_transceive_data_callback)(net_nfc_error_e result,
- data_h data,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_h handle,
- data_h rawdata,
- nfc_transceive_callback callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_h handle,
- data_h rawdata,
- nfc_transceive_data_callback callback,
- void *user_data);
-
-net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_h handle,
- data_h rawdata);
-
-net_nfc_error_e net_nfc_client_transceive_data_sync(
- net_nfc_target_handle_h handle,
- data_h rawdata,
- data_h *response);
-
-/* TODO : move to internal header */
-net_nfc_error_e net_nfc_client_transceive_init(void);
-
-void net_nfc_client_transceive_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_TRANSCEIVE_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_CLIENT_UTIL_INTERNAL_H__
-#define __NET_NFC_CLIENT_UTIL_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct _NetNfcCallback
-{
- void *callback;
- void *user_data;
-}
-NetNfcCallback;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_CLIENT_UTIL_INTERNAL_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_DATA_H__
-#define __NET_NFC_DATA_H__
-
-#include <net_nfc_typedef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
-
-@addtogroup NET_NFC_MANAGER_INFO
-@{
- This document is for the APIs reference document
-
- NFC Manager defines are defined in <nfc-manager-def.h>
-
- @li @c #net_nfc_initialize Initialize the nfc device.
-
-*/
-
-/**
- create data handler only.
-
- @param[out] data data handler
-
- @return return the result of this operation
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-*/
-
-net_nfc_error_e net_nfc_create_data_only(data_h *data);
-
-/**
- create data handler with initial values, bytes will be copied into the data handler.
-
- @param[out] data data handler
- @param[in] bytes binary data
- @param[in] length size of binary data;
-
- @return return the result of this operation
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-*/
-net_nfc_error_e net_nfc_create_data(data_h *data, const uint8_t *bytes, size_t length);
-
-/**
- get the byes and length from data handler. data handler assume bytes may have '0x0' value.
- that's why this function also provides the length.
-
- @param[in] data data handler
- @param[out] bytes binary pointer (it returns the direct pointer of handler's data) do not free this
- @param[out] length length of the binary data;
-
- @return return the result of this operation
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-net_nfc_error_e net_nfc_get_data(const data_h data, uint8_t **bytes, size_t *length);
-
-/**
- replace the data handler with given bytes. binary data (bytes) will be copied to data hander.
- application should free or use local variable for given byte pointer.
-
- @param[in] data data handler
- @param[in] bytes binary data
- @param[in] length size of binary data
-
- @return return the result of this operation
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-
-net_nfc_error_e net_nfc_set_data(data_h data, const uint8_t *bytes, size_t length);
-
-/**
- get length of data handler's bytes.
-
- @param[in] data data handler
-
- @return return the length of bytes
-
- @exception 0 is returned if data is NULL
-*/
-
-size_t net_nfc_get_data_length(const data_h data);
-
-/**
- get pointer of the handler's bytes (do not free this. it should be freed when the application call "net_nfc_free_data" function)
-
- @param[in] data data handler
-
- @return return the pointer of bytes.
-
- @exception NULL is returned if data is NULL
-*/
-
-uint8_t *net_nfc_get_data_buffer(const data_h data);
-
-/**
- free data handler. (it also free the copied bytes)
-
- @param[in] data data handler
-
- @return return the result of this operation
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-
-net_nfc_error_e net_nfc_free_data(data_h data);
-
-
-/**
-@}
-*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_DATA_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_NDEF_MESSAGE_H__
-#define __NET_NFC_NDEF_MESSAGE_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
-
-@addtogroup NET_NFC_MANAGER_NDEF
-@{
- This document is for the APIs reference document
-
- NFC Manager defines are defined in <nfc-manager-def.h>
-
- @li @c #net_nfc_initialize Initialize the nfc device.
-
-*/
-
-/**
- create ndef message handler. this function allocate the ndef message handler and initialize.
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[out] ndef_message instance of the ndef_message is retuened
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
- @code
-
- net_nfc_error_e result = NET_NFC_OK;
- ndef_message_h msg = NULL;
- ndef_record_h record = NULL;
-
- result = net_nfc_create_ndef_message (&msg);
- if (result != NET_NFC_OK) return result;
-
- result = net_nfc_create_uri_type_record (&record , "http://www.samsung.com" ,NET_NFC_SCHEMA_FULL_URI);
- if (result != NET_NFC_OK) return result;
-
- result = net_nfc_append_record_to_ndef_message (msg ,record);
- if (result != NET_NFC_OK) return result;
-
- net_nfc_write_ndef(id, msg, &user_context);
-
- net_nfc_free_ndef_message (msg);
-
- @endcode
-*/
-
-
-net_nfc_error_e net_nfc_create_ndef_message(ndef_message_h *ndef_message);
-
-/**
- this APIs is the getter of record counts
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message output structure to get the record
- @param[out] count number of record count
-
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
- @code
-
- static void net_nfc_cb(net_nfc_message_e message, net_nfc_error_e result, void* data , void* userContext)
- {
- switch (message)
- {
- case NET_NFC_MESSAGE_READ_NDEF:
- {
- if(data != NULL)
- {
- int count = 0;
- ndef_message_h ndef = (ndef_message_h)(data);
- net_nfc_get_ndef_message_record_count (ndef, &count);
- printf ("record count = %d\n", count);
- }
- }
- break;
- }
- }
- @endcode
-*/
-net_nfc_error_e net_nfc_get_ndef_message_record_count(ndef_message_h ndef_message, int *count);
-
-/**
- This function converts the NDEF Message structure to serial bytes of ndef message.
-
- it gets copy of the rawdata bytes from ndef_message. ndef_message has no effect after free rawdata
- Application should free rawdata.
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message output structure to get the record
- @param[out] rawdata this is the raw data that will be formed into the
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NDEF_BUF_END_WITHOUT_ME Wrong formatted NDEF message
-
- @code
-
- net_nfc_error_e result = NET_NFC_OK;
- data_h rawdata;
- ndef_message_h msg = NULL;
- ndef_record_h record = NULL;
- int idx;
- uint8_t * buffer = NULL;
-
- result = net_nfc_create_ndef_message (&msg);
- if (result != NET_NFC_OK) return result;
-
- result = net_nfc_create_uri_type_record (&record , "http://www.samsung.com" ,NET_NFC_SCHEMA_FULL_URI);
- if (result != NET_NFC_OK) return result;
-
- result = net_nfc_append_record_to_ndef_message (msg ,record);
- if (result != NET_NFC_OK) return result;
-
- net_nfc_create_rawdata_from_ndef_message (msg, &rawdata);
-
- buffer = net_nfc_get_data_buffer (rawdata) ;
-
- for (idx = 0; idx < net_nfc_get_data_length (rawdata) ; idx++)
- {
- printf (" %02X", buffer[idx]);
- if (idx % 16 == 0) printf ("\n");
- }
-
- net_nfc_free_ndef_message (msg);
-
- @endcode
-
-
-*/
-
-net_nfc_error_e net_nfc_create_rawdata_from_ndef_message(ndef_message_h ndef_message, data_h *rawdata);
-
-/**
- This function return the structure of ndef_message from serial format of ndef message.
- You may say create ndef handler from raw serial bytes
- it cunsumes the bytes array until get the (ME==1). it retunrs error if the bytes array does not have ME flag.
- if the array has two NDEF Message serially (not recursive case - like smart poster). the first NDEF message
- will be converted to ndef_message handler, and other messages will be ignored.
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[out] ndef_message ndef message handler that will be returned
- @param[in] rawdata ndef message that formed in bytes array
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NDEF_BUF_END_WITHOUT_ME Wrong formatted NDEF message
-
- @code
-
- static void net_nfc_cb(net_nfc_message_e message, net_nfc_error_e result, void* data , void* userContext)
- {
- switch (message)
- {
- case NET_NFC_MESSAGE_READ_NDEF:
- {
- if(data != NULL)
- {
- record_h record;
- ndef_message_h url;
- data_h ndef_type;
- data_h payload;
-
- ndef_message_h ndef = (ndef_message_h)(data);
- net_nfc_get_record_by_index (ndef, 0, &record);
- net_nfc_get_record_type (record, &ndef_type);
- if (strncmp (ndef_type.buffer, "Sp", ndef_type.length)){
- net_nfc_get_record_payload (record, &payload);
- net_nfc_create_ndef_message_from_rawdata (&url, payload);
- printf_ndef_massage (url);
- }
- }
- }
- break;
- }
- }
- @endcode
-
-*/
-
-
-net_nfc_error_e net_nfc_create_ndef_message_from_rawdata(ndef_message_h *ndef_message, data_h rawdata);
-
-/**
- it returns the total size of ndef message bytes. parse the structure data and count the bytes
- to know the length of bytes required to store the NDEF message.
-
- it calculates the length every time application calls this function. it does not cache inside.
- TODO: do we need to cache the value inside of ndef_message_h
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message this is the raw data that will be formed into the
- @param[out] length number of bytes required to create ndef message serial format
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_ndef_message_byte_length(ndef_message_h ndef_message, uint32_t *length);
-/**
- Append a record to ndef message structure.
- This API help to create NDEF message and it control Record flags to follow the NDEF forum specification
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message NDEF message structure
- @param[in] record a record will be added into the ndef message
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
- @code
-
- net_nfc_error_e result = NET_NFC_OK;
- data_h rawdata;
- ndef_message_h msg = NULL;
- ndef_record_h record = NULL;
- int idx;
- uint8_t * buffer = NULL;
-
- result = net_nfc_create_ndef_message (&msg);
- if (result != NET_NFC_OK) return result;
-
- result = net_nfc_create_uri_type_record (&record , "http://www.samsung.com" ,NET_NFC_SCHEMA_FULL_URI);
- if (result != NET_NFC_OK) return result;
-
- result = net_nfc_append_record_to_ndef_message (msg ,record);
- if (result != NET_NFC_OK) return result;
-
- net_nfc_create_rawdata_from_ndef_message (msg, &rawdata);
-
- buffer = net_nfc_get_data_buffer (rawdata) ;
-
- for (idx = 0; idx < net_nfc_get_data_length (rawdata) ; idx++)
- {
- printf (" %02X", buffer[idx]);
- if (idx % 16 == 0) printf ("\n");
- }
-
- net_nfc_free_ndef_message (msg);
-
- @endcode
-
-
-*/
-net_nfc_error_e net_nfc_append_record_to_ndef_message(ndef_message_h ndef_message, ndef_record_h record);
-
-/**
- remove the record that indicated by index number.
- and this deleted record will be freed.
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message the message wil be freed
- @param[in] index index of record
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_OUT_OF_BOUND index is out of bound
- @exception NET_NFC_INVALID_FORMAT Wrong formatted ndef message
-
-*/
-
-net_nfc_error_e net_nfc_remove_record_by_index(ndef_message_h ndef_message, int index);
-
-/**
- get record by index. this function just return the pointer of record.
- if you change the record value it directly affected to NDEF message
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message the message wil be freed
- @param[in] index index of record
- @param[in] record record pointer
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_OUT_OF_BOUND index is out of bound
-
-*/
-net_nfc_error_e net_nfc_get_record_by_index(ndef_message_h ndef_message, int index, ndef_record_h *record);
-
-/**
- Add a record by index. This API help to add record by index. MB or ME bits will automatically assained.
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message the message wil be freed
- @param[in] index index of record
- @param[in] record record pointer
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_OUT_OF_BOUND index is out of bound
- @exception NET_NFC_INVALID_FORMAT Wrong formatted ndef message
-*/
-
-net_nfc_error_e net_nfc_append_record_by_index(ndef_message_h ndef_message, int index, ndef_record_h record);
-
-
-/**
- search the specific type in the NDEF message. this function return the first record that holds the type.
- if the type has "urn:nfc:wkt:" or "urn:nfc:ext:", these prefix will be removed automatically.
-
- @param[in] ndef_message NDEF message handler
- @param[in] tnf TNF value
- @param[in] type Record type , include type length
- @param[out] record record handle
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_NO_DATA_FOUND search is failed
- @exception NET_NFC_INVALID_FORMAT Wrong formatted ndef message
-
- @code
-
- static void net_nfc_cb(net_nfc_message_e message, net_nfc_error_e result, void* data , void* userContext)
- {
- switch (message)
- {
- case NET_NFC_MESSAGE_READ_NDEF:
- {
- if(data != NULL)
- {
- date_h type;
- int count = 0;
- ndef_message_h ndef = (ndef_message_h)(data);
- ndef_record_h record;
- net_nfc_create_data (&type, "Sp", 2);
- net_nfc_search_record_by_type (ndef, NET_NFC_RECORD_WELL_KNOWN_TYPE, type, &record);
- }
- }
- break;
- }
- }
-
- @endcode
-
-*/
-net_nfc_error_e net_nfc_search_record_by_type(ndef_message_h ndef_message, net_nfc_record_tnf_e tnf, data_h type, ndef_record_h *record);
-
-
-/**
- this function helps to free the ndef_message_s type structure.
- it has multiple ndef_record_s with linked list form and each record has own pointer.
- this function free these memory in one shot!
- don't worry about the record handler. these handlers also freed.
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message the message wil be freed
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_free_ndef_message(ndef_message_h ndef_message);
-
-
-/**
- retreive ndef message which is read by nfc-manager .
- after reading message, it will be removed from nfc-manager storage
-
- \par Sync (or) Async: sync
- This is a Synchronous API
-
- @param[in] ndef_message the message wil be retrieved
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_NO_NDEF_MESSAGE No ndef message is found
- @exception NET_NFC_INVALID_FORMAT Wrong formatted ndef message
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
-*/
-
-net_nfc_error_e net_nfc_retrieve_current_ndef_message(ndef_message_h *ndef_message);
-
-
-/**
-@} */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_NDEF_MESSAGE_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_NDEF_MESSAGE_HANDOVER_H__
-#define __NET_NFC_NDEF_MESSAGE_HANDOVER_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- This function create carrier configure handler instance.
-
- @param[out] config instance handler
- @param[in] type Carrier types. It would be BT or WPS or etc.
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_OUT_OF_BOUND type value is not enum value
- @exception NET_NFC_ALLOC_FAIL allocation is failed
-*/
-net_nfc_error_e net_nfc_create_carrier_config(net_nfc_carrier_config_h *config, net_nfc_conn_handover_carrier_type_e type);
-
-/**
- Add property key and value for configuration.
- the data will be copied to config handle, you should free used data array.
-
- @param[in] config instance handler
- @param[in] attribute attribute key for value.
- @param[in] size size of value
- @param[in] data value array (binary type)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL allocation is failed
-*/
-net_nfc_error_e net_nfc_add_carrier_config_property(net_nfc_carrier_config_h config, uint16_t attribute, uint16_t size, uint8_t *data);
-
-/**
- Remove the key and value from configuration, you can also remove the group with CREDENTIAL key.
- The the attribute is exist then it will be removed and also freed automatically.
-
- @param[in] config instance handler
- @param[in] attribute attribute key for value.
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_NO_DATA_FOUND the given key is not found
- @exception NET_NFC_ALREADY_REGISTERED the given attribute is already registered
-*/
-net_nfc_error_e net_nfc_remove_carrier_config_property(net_nfc_carrier_config_h config, uint16_t attribute);
-
-/**
- Get the property value by attribute.
-
- @param[in] config instance handler
- @param[in] attribute attribute key for value.
- @param[out] size size of value
- @param[out] data value array (binary type)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_NO_DATA_FOUND The given key is not found
-*/
-net_nfc_error_e net_nfc_get_carrier_config_property(net_nfc_carrier_config_h config, uint16_t attribute, uint16_t *size, uint8_t **data);
-
-/**
- The group will be joined into the configure
-
- @param[in] config instance handler
- @param[in] group group handle
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALREADY_REGISTERED The given group is already registered
-*/
-net_nfc_error_e net_nfc_append_carrier_config_group(net_nfc_carrier_config_h config, net_nfc_property_group_h group);
-
-/**
- Remove the group from configure handle
-
- @param[in] config instance handler
- @param[in] group group handle
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_NO_DATA_FOUND given handle pointer is not exist in the configure handle
-*/
-net_nfc_error_e net_nfc_remove_carrier_config_group(net_nfc_carrier_config_h config, net_nfc_property_group_h group);
-
-/**
- Get the group from configure handle by index
-
- @param[in] config instance handler
- @param[in] attribute group attribute
- @param[out] group group handle
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_OUT_OF_BOUND the index number is not bound of the max count
- @exception NET_NFC_NO_DATA_FOUND this is should be happened if the configure handle is damaged
-*/
-net_nfc_error_e net_nfc_get_carrier_config_group(net_nfc_carrier_config_h config, uint16_t attribute, net_nfc_property_group_h *group);
-
-/**
- free the configure handle
-
- @param[in] config instance handler
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-net_nfc_error_e net_nfc_free_carrier_config(net_nfc_carrier_config_h config);
-
-/**
- create the group handle
-
- @param[out] group instance group handler
- @param[in] attribute attribute of the property
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL allocation is failed
-*/
-net_nfc_error_e net_nfc_create_carrier_config_group(net_nfc_property_group_h *group, uint16_t attribute);
-
-/**
- add property into the group
-
- @param[in] group instance group handler
- @param[in] attribute attribute of the property
- @param[in] size size of data (value)
- @param[in] data data of the property
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL allocation is failed
- @exception NET_NFC_ALREADY_REGISTERED the given key is already registered
-*/
-net_nfc_error_e net_nfc_add_carrier_config_group_property(net_nfc_property_group_h group, uint16_t attribute, uint16_t size, uint8_t *data);
-
-/**
- get property from group handle
-
- @param[in] group instance group handler
- @param[in] attribute attribute of the property
- @param[out] size size of data (value)
- @param[out] data data of the property
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_NO_DATA_FOUND the attribute does not exist in the group
-*/
-net_nfc_error_e net_nfc_get_carrier_config_group_property(net_nfc_property_group_h group, uint16_t attribute, uint16_t *size, uint8_t **data);
-
-/**
- remove the property from the group
-
- @param[in] group instance group handler
- @param[in] attribute attribute of the property
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_NO_DATA_FOUND the attribute does not exist in the group
-*/
-net_nfc_error_e net_nfc_remove_carrier_config_group_property(net_nfc_property_group_h group, uint16_t attribute);
-
-
-/**
- free the group
-
- @param[in] group instance group handler
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-net_nfc_error_e net_nfc_free_carrier_group(net_nfc_property_group_h group);
-
-/**
- Create record handler with config.
-
- @param[out] record record handler
- @param[in] config the carrier configure handle
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL allocation is failed
-*/
-net_nfc_error_e net_nfc_create_ndef_record_with_carrier_config(ndef_record_h *record, net_nfc_carrier_config_h config);
-
-
-/**
- create configure from the ndef record. the record must contained the configuration.
- config should be freed after using
-
- @param[out] config the configure handle
- @param[in] record record handler
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL allocation is failed
- @exception NET_NFC_INVALID_FORMAT if the record does not contained the valid format.
-*/
-net_nfc_error_e net_nfc_create_carrier_config_from_config_record(net_nfc_carrier_config_h *config, ndef_record_h record);
-
-net_nfc_error_e net_nfc_create_carrier_config_from_carrier(
- net_nfc_carrier_config_h *config, net_nfc_ch_carrier_h carrier);
-
-net_nfc_error_e net_nfc_create_handover_carrier(net_nfc_ch_carrier_h *carrier,
- net_nfc_conn_handover_carrier_state_e cps);
-
-net_nfc_error_e net_nfc_duplicate_handover_carrier(net_nfc_ch_carrier_h *dest,
- net_nfc_ch_carrier_h src);
-
-net_nfc_error_e net_nfc_free_handover_carrier(net_nfc_ch_carrier_h carrier);
-
-net_nfc_error_e net_nfc_set_handover_carrier_cps(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_state_e cps);
-
-net_nfc_error_e net_nfc_get_handover_carrier_cps(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_state_e *cps);
-
-net_nfc_error_e net_nfc_set_handover_carrier_type(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_type_e type);
-
-net_nfc_error_e net_nfc_get_handover_carrier_type(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_type_e *type);
-
-net_nfc_error_e net_nfc_append_handover_carrier_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h record);
-
-net_nfc_error_e net_nfc_get_handover_carrier_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h *record);
-
-net_nfc_error_e net_nfc_remove_handover_carrier_record(
- net_nfc_ch_carrier_h carrier);
-
-net_nfc_error_e net_nfc_append_handover_auxiliary_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h record);
-
-net_nfc_error_e net_nfc_get_handover_auxiliary_record_count(
- net_nfc_ch_carrier_h carrier, uint32_t *count);
-
-net_nfc_error_e net_nfc_get_handover_auxiliary_record(
- net_nfc_ch_carrier_h carrier, int index, ndef_record_h *record);
-
-net_nfc_error_e net_nfc_remove_handover_auxiliary_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h record);
-
-
-net_nfc_error_e net_nfc_create_handover_message(net_nfc_ch_message_h *message);
-
-net_nfc_error_e net_nfc_free_handover_message(net_nfc_ch_message_h message);
-
-net_nfc_error_e net_nfc_get_handover_random_number(net_nfc_ch_message_h message,
- uint16_t *random_number);
-
-net_nfc_error_e net_nfc_append_handover_carrier(net_nfc_ch_message_h message,
- net_nfc_ch_carrier_h carrier);
-
-net_nfc_error_e net_nfc_get_handover_carrier_count(net_nfc_ch_message_h message,
- uint32_t *count);
-
-net_nfc_error_e net_nfc_get_handover_carrier(net_nfc_ch_message_h message,
- int index, net_nfc_ch_carrier_h *carrier);
-
-net_nfc_error_e net_nfc_get_handover_carrier_by_type(
- net_nfc_ch_message_h message,
- net_nfc_conn_handover_carrier_type_e type,
- net_nfc_ch_carrier_h *carrier);
-
-net_nfc_error_e net_nfc_export_handover_to_ndef_message(
- net_nfc_ch_message_h message, ndef_message_h *result);
-
-net_nfc_error_e net_nfc_import_handover_from_ndef_message(
- ndef_message_h msg, net_nfc_ch_message_h *result);
-
-/**
- create the connection handover error record message
-
- @param[out] record connection handover carrier info handler
- @param[in] reason error codes (reason)
- @param[in] data extra data for each error codes
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL allocation is failed
-*/
-net_nfc_error_e net_nfc_create_handover_error_record(ndef_record_h * record, uint8_t reason, uint32_t data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //__NET_NFC_NDEF_MESSAGE_HANDOVER_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_NDEF_RECORD_H__
-#define __NET_NFC_NDEF_RECORD_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
-
-@addtogroup NET_NFC_MANAGER_RECORD
-@{
- This document is for the APIs reference document
-
- NFC Manager defines are defined in <nfc-typedef.h>
-
-*/
-
-
-/**
- This define gives you Message Begin from the flag byte
-
- @param[in] flag flag that comes from "net_nfc_get_record_flags" function
- @return the mb flag
-
- @exception NONE
-*/
-uint8_t net_nfc_get_record_mb(uint8_t flag);
-/**
- This define gives you Message end from the flag byte
-
- @param[in] flag flag that comes from "net_nfc_get_record_flags" function
- @return the me flag
-
- @exception NONE
-*/
-uint8_t net_nfc_get_record_me(uint8_t flag);
-/**
- This define gives you Chun Flag that indicate that either the first record chunk or a middle record chunk of a chunked payload
-
- @param[in] flag flag that comes from "net_nfc_get_record_flags" function
- @return the chunk flag
-
- @exception NONE
-*/
-uint8_t net_nfc_get_record_cf(uint8_t flag);
-/**
- This define gives you ID length present flag
-
- @param[in] flag flag that comes from "net_nfc_get_record_flags" function
- @return the il (id length flag) flag
-
- @exception NONE
-
-*/
-uint8_t net_nfc_get_record_il(uint8_t flag);
-/**
- This define gives you short record flag. This flag indicates that the payload length filed is a single octet
-
- @param[in] flag flag that comes from "net_nfc_get_record_flags" function
- @return the short record flag
-
- @exception NONE
-*/
-uint8_t net_nfc_get_record_sr(uint8_t flag);
-
-
-
-/**
- creat a record with given parameter value. this function automatically set the NDEF record flags
-
- @param[out] record Record handler
- @param[in] tnf record type (TNF value) empty, well known, mime type, URI, external, or unchanged
- @param[in] typeName specify type name ex) Sp, U, or Hr ...
- @param[in] id record id
- @param[in] payload payload of this record
-
- @return return the result of the calling the function
-
- @exception NET_NFC_OUT_OF_BOUND tnf value is out of range
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
- @code
- char uri[] = " yahoo.com";
- ndef_record_s uriRecord;
-
- data_h payload;
-
- net_nfc_create_data (&payload, uri, strlen (uri));
- uri[0] = 0x01;
-
- if((result = net_nfc_create_record( &uriRecord, NET_NFC_RECORD_WELL_KNOWN_TYPE, "U" , NULL, payload, )) != NET_NFC_OK)
- {
- printf("U record is failed [%d]\n", result);
- }
- @endcode
-*/
-net_nfc_error_e net_nfc_create_record(ndef_record_h *record, net_nfc_record_tnf_e tnf, data_h typeName, data_h id, data_h payload);
-
-
-/**
- this function helps to create text type payload
- please, refer the NDEF forum specification "Text Record Type Definition"
- it creates byte array payload can be used in text type record
-
- this function does not encode the text. The paramter "text" will be asuumed as that it is already encoded with encode type.
- this function just helps to create text records.
-
- @param[out] record Record handler
- @param[in] text encoded text (this should be text not binary)
- @param[in] language_code_str language_code_str ex) en-US
- @param[in] encode text concoding type such as "utf8"
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
-
- @code
- net_nfc_error_e result = NET_NFC_OK;
- ndef_message_h msg = NULL;
- ndef_record_h record = NULL;
-
- char* message = "Hello, NFC World";
-
- net_nfc_create_ndef_message (&msg);
- net_nfc_create_text_type_record (&record , message, "en-US", NET_NFC_ENCODE_UTF_8);
- net_nfc_append_record_to_ndef_message (msg ,record);
-
- @endcode
-
-*/
-net_nfc_error_e net_nfc_create_text_type_record(ndef_record_h *record, const char *text, const char *language_code_str, net_nfc_encode_type_e encode);
-
-/**
- this function helps to create URI type payload
- please refer the NFC forum specification "URI Record type Definition"
- it creates byte array payload.
-
- @param[out] record Record handler
- @param[in] uri string uri that will be stored in the payload
- @param[in] protocol_schema protocol schema that is specified in NFC Forum
-
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
- @code
- net_nfc_error_e result = NET_NFC_OK;
- ndef_message_h msg = NULL;
- ndef_record_h record = NULL;
-
- net_nfc_create_ndef_message (&msg);
- net_nfc_create_uri_type_record (&record ,"http://www.samsung.com" ,NET_NFC_SCHEMA_FULL_URI);
- net_nfc_append_record_to_ndef_message (msg ,record);
- @endcode
-*/
-
-net_nfc_error_e net_nfc_create_uri_type_record(ndef_record_h *record, const char *uri, net_nfc_schema_type_e protocol_schema);
-
-/**
- this function is getter of record payload.
- this function gives you the pointer of pyaload that is contained by record.
- Do not free the payload. it will be freed when the record is freed
-
- @param[in] record Record handler
- @param[out] payload data_h type payload pointer (it gives you the pointer of payload; not copied)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-net_nfc_error_e net_nfc_get_record_payload(ndef_record_h record, data_h *payload);
-
-/**
- this function is getter of record type.
- this function gives you the pointer of record type that is contained by record.
- Do not free the type. it will be freed when the record is freed
-
- @param[in] record Record handler
- @param[out] type dat_h type pointer (it gives you the pointer of type; not copied)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-net_nfc_error_e net_nfc_get_record_type(ndef_record_h record, data_h *type);
-
-/**
- this function is getter of record ID.
- this function gives you the pointer of ID that is contained by record.
- it may return NULL pointer if the ID is not exist
- Do not free the type. it will be freed when the record is freed.
-
- @param[in] record Record handler
- @param[out] id dat_h type ID pointer (it gives you the pointer of payload not copied)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-*/
-net_nfc_error_e net_nfc_get_record_id(ndef_record_h record, data_h *id);
-
-/**
- this function is getter of record TNF value.
-
- @param[in] record Record handler
- @param[out] tnf TNF value
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-
-*/
-net_nfc_error_e net_nfc_get_record_tnf(ndef_record_h record, net_nfc_record_tnf_e *tnf);
-
-/**
- this function is getter of record flags.
- you can get the each flag value by using defines "RECORD_GET_XX"
-
- @param[in] record Record handler
- @param[out] flag flag value (it gives you the pointer of payload not copied)
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
- @code
-
- ndef_record_h record;
- uint8_t flag;
-
- net_nfc_get_record_by_index (msg, 0, &record);
- if (record != NULL){
- net_nfc_get_record_flags (record, &flag);
- printf ("MB:%d, ME:%d, CF:%d, IL:%d, SR:%d\n",
- net_nfc_get_record_mb(flag),
- net_nfc_get_record_me(flag),
- net_nfc_get_record_cf(flag),
- net_nfc_get_record_il(flag),
- net_nfc_get_record_sr(flag));
- }
-
- @endcode
-
-*/
-net_nfc_error_e net_nfc_get_record_flags(ndef_record_h record, uint8_t *flag);
-
-
-/**
- you can set record ID with this function
-
- @param[in] record Record handler
- @param[in] id Record ID
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-net_nfc_error_e net_nfc_set_record_id(ndef_record_h record, data_h id);
-
-/**
- this function free the record handler. do not use this function after appending the ndef message
-
- @param[in] record Record handler
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-net_nfc_error_e net_nfc_free_record(ndef_record_h record);
-
-
-/**
- this function get text from text record. it allocate buffer char and store the text string. you should free this string.
-
- @param[in] record Record handler
- @param[out] buffer text string
-
- @return return the result of the calling the function
-
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE record is not text record
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_create_text_string_from_text_record(ndef_record_h record, char **buffer);
-
-/**
- this function get language code from text record. (ex: US-en)
-
- @param[in] record Record handler
- @param[out] lang_code_str lang code string value followed by IANA
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE record is not text record
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_languange_code_string_from_text_record(ndef_record_h record, char **lang_code_str);
-
-
-/**
- this function get encoding type from text record (ex: UTF-8)
-
- @param[in] record Record handler
- @param[out] encoding encoding type
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE record is not text record
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_encoding_type_from_text_record(ndef_record_h record, net_nfc_encode_type_e *encoding);
-
-
-/**
- this function get URI from uri record. you should free the uri string.
-
- @param[in] record Record handler
- @param[out] uri uri text string
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE record is not uri record
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_create_uri_string_from_uri_record(ndef_record_h record, char **uri);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //__NET_NFC_NDEF_RECORD_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_SIGN_RECORD_H__
-#define __NET_NFC_SIGN_RECORD_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-/**
-
-@addtogroup NET_NFC_MANAGER_RECORD
-@{
- This document is for the APIs reference document
-
- NFC Manager defines are defined in <nfc-typedef.h>
-
-*/
-
-/**
- this function make the signature of some continuous records
- please refer the NFC forum specification "Signature Record type Definition"
-
- @param[in/out] msg NDEF message handler. After executing this function, a signature record will be added.
- @param[in] begin_index the index of beginning record that will be signed.
- @param[in] end_index the last index of record that will be signed.
- @param[in] cert_file PKCS #12 type certificate file (.p12). And the file should be encoded in DER type. (NOT PEM type)
- @param[in] passowrd the password of cert_file
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
- @code
- ndef_message_h msg = NULL;
-
- // create a ndef message and add some records
- // ...
-
- net_nfc_sign_records(msg, 0, 1, "/tmp/cert.p12", "abcdef");
- @endcode
-*/
-net_nfc_error_e net_nfc_sign_records(ndef_message_h msg, int begin_index, int end_index, char *cert_file, char *password);
-
-/**
- this function make the signature of whole records in NDEF message
-
- @param[in/out] msg NDEF message handler. After executing this function, a signature record will be added.
- @param[in] cert_file PKCS #12 type certificate file (.p12). And the file should be encoded in DER type. (NOT PEM type)
- @param[in] passowrd the password of cert_file
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
- @code
- ndef_message_h msg = NULL;
-
- // create a ndef message and add some records
- // ...
-
- net_nfc_sign_ndef_message(msg, "/tmp/cert.p12", "abcdef");
- @endcode
-*/
-net_nfc_error_e net_nfc_sign_ndef_message(ndef_message_h msg, char *cert_file, char *password);
-
-/**
- This function does verify signature of records
- record MUST be continuous.
-
- @param[in] begin_record the handle of beginning record that will be verified
- @param[in] sign_record the handle of signature record
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
- @code
- net_nfc_error_e error = NET_NFC_OK;
- ndef_message_h msg = NULL;
- ndef_record_h begin_record = NULL;
- ndef_record_h sign_record = NULL;
-
- // import NDEF message including the signature record.
- // ...
-
- net_nfc_get_record_by_index(msg, 0, &begin_record);
- net_nfc_get_record_by_index(msg, 2, &sign_record);
-
- error = net_nfc_verify_signature_records(begin_record, sign_record);
-
- return (error == NET_NFC_OK);
- @endcode
-*/
-net_nfc_error_e net_nfc_verify_signature_records(ndef_record_h begin_record, ndef_record_h sign_record);
-
-/**
- This function does verify signature in NDEF message
- If message has 2 or more signature record, it should do verify every signatures and return result.
- (Despite of failing only one signature record, this function will return error.)
-
- @param[in] msg NDEF message that will be verified.
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
- @code
- net_nfc_error_e error = NET_NFC_OK;
- ndef_message_h msg = NULL;
-
- // import NDEF message including the signature record.
- // ...
-
- error = net_nfc_verify_signature_ndef_message(msg);
-
- return (error == NET_NFC_OK);
- @endcode
-*/
-net_nfc_error_e net_nfc_verify_signature_ndef_message(ndef_message_h msg);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //__NET_NFC_SIGN_RECORD_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_TAG_MIFARE_H__
-#define __NET_NFC_TAG_MIFARE_H__
-
-#include "net_nfc_typedef.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-
-@addtogroup NET_NFC_MANAGER_TAG
-@{
- Authenticate a sector with key A. I/O operation. e.g. read / write /
- increment / decrement will be available after successful authentication.
- This API is only available for MIFARE classic
-
- MIFARE CLASSIC MINI
- => 0 ~ 4 : 5 sector and 4 block with 16 bytes
-
- MIFARE CLASSIC 1K
- => 0 ~ 15 : 16 sector and 4 block with 16 bytes
-
- MIFARE CLASSIC 4K
- => 0 ~ 31 : 32 sector and 4 block with 16 bytes
- => 32 ~ 39 : 8 sector and 16 block with 16 bytes
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] sector sector to authenticate with key A
- @param[in] auth_key 6 byte key to authenticate the sector
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (UID, etc) is not
- founded
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyA(
- net_nfc_target_handle_h handle,
- uint8_t sector,
- data_h auth_key,
- void *callback,
- void *user_data);
-
-/**
- Authenticate a sector with key B. I/O operation. e.g. read / write /
- increment / decrement will be available after successful authentication.
- This API is only available for MIFARE classic
-
- MIFARE CLASSIC MINI
- => 0 ~ 4 : 5 sector and 4 block with 16 bytes
-
- MIFARE CLASSIC 1K
- => 0 ~ 15 : 16 sector and 4 block with 16 bytes
-
- MIFARE CLASSIC 4K
- => 0 ~ 31 : 32 sector and 4 block with 16 bytes
- => 32 ~ 39 : 8 sector and 16 block with 16 bytes
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] sector sector to authenticate with key B
- @param[in] auth_key 6 byte key to authenticate the sector
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_NO_DATA_FOUND mendantory tag info (UID, etc) is not
- founded
-
-*/
-
-
-net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyB(
- net_nfc_target_handle_h handle,
- uint8_t sector,
- data_h auth_key,
- void *callback,
- void *user_data);
-
-/**
- read block or read page. If detected card is MIFARE classic, then It will
- read a block (16 byte). If detected card is Ultra light, then It will read
- 4 page (16 block)
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] addr block or starting page number
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_READ_FAILED received chunked data is not valied
- (damaged data is recieved) or error ack
- is recieved
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_read(net_nfc_target_handle_h handle,
- uint8_t addr,
- void *callback,
- void *user_data);
-
-/**
- write block (16 byte) to addr. Only 4 bytes will be written when tag is
- ultra light
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] addr block or starting page number
- @param[in] data data to write
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is received
- from tag
-
-*/
-
-
-net_nfc_error_e net_nfc_client_mifare_write_block(
- net_nfc_target_handle_h handle,
- uint8_t addr,
- data_h data,
- void *callback,
- void *user_data);
-
-/**
- write page (4 byte) to addr. Only 4 bytes will be written when tag is
- MIFARE classic
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] addr block or starting page number
- @param[in] data data to write
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is
- received from tag
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_write_page(
- net_nfc_target_handle_h handle,
- uint8_t addr,
- data_h data,
- void *callback,
- void *user_data);
-
-
-/**
- Increase a value block, storing the result in the temporary block on the
- tag
- This API is only available for MIFARE classic
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] addr block
- @param[in] value index of block to increase, starting from 0
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is received
- from tag
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_increment(net_nfc_target_handle_h handle,
- uint8_t addr,
- int value,
- void *callback,
- void *user_data);
-
-/**
- Decrease a value block, storing the result in the temporary block on the
- tag
- This API is only available for MIFARE classic
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] addr block
- @param[in] value index of block to decrease, starting from 0
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is received
- from tag
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_decrement(net_nfc_target_handle_h handle,
- uint8_t addr,
- int value,
- void *callback,
- void *user_data);
-
-/**
- Copy from the temporary block to a value block.
- This API is only available for MIFARE classic
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] addr block
- @param[in] value index of block to decrease, starting from 0
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is received
- from tag
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_transfer(net_nfc_target_handle_h handle,
- uint8_t addr,
- void *callback,
- void *user_data);
-
-/**
- Copy from a value block to the temporary block.
- This API is only available for MIFARE classic
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] handle target handle of detected tag
- @param[in] addr block
- @param[in] value index of block to decrease, starting from 0
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter has illigal NULL pointer
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NOT_INITIALIZED Try to operate without initialization
- @exception NET_NFC_BUSY Device is too busy to handle your request
- @exception NET_NFC_OPERATION_FAIL Operation is failed because of the
- internal oal error
- @exception NET_NFC_RF_TIMEOUT Timeout raised while communicate with tag
- @exception NET_NFC_NOT_SUPPORTED you may recieve this error if you
- request not supported command
- @exception NET_NFC_INVALID_HANDLE target handle is not valid
- @exception NET_NFC_TAG_WRITE_FAILED read only tag, or error ack is received
- from tag
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_restore(net_nfc_target_handle_h handle,
- uint8_t addr,
- void *callback,
- void *user_data);
-
-/**
- create default factory key. The key is 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] key the handle to create key
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_create_default_key(data_h* key);
-
-/**
- create mifare application directory key. The key is 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] key the handle to create key
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_create_application_directory_key(
- data_h* key);
-
-/**
- create nfc forum key. The key is 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7
-
- \par Sync (or) Async: Sync
- This is a Asynchronous API
-
- @param[in] key the handle to create key
-
- @return return the result of the calling the function
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
-
-*/
-
-net_nfc_error_e net_nfc_client_mifare_create_net_nfc_forum_key(data_h* key);
-
-/**
-@} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__NET_NFC_TAG_MIFARE_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __NET_NFC_TARGET_INFO_H__
-#define __NET_NFC_TARGET_INFO_H__
-
-#include "net_nfc_typedef.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-
-@addtogroup NET_NFC_MANAGER_INFO
-@{
- This document is for the APIs reference document
-
- NFC Manager defines are defined in <nfc-typedef.h>
-
- These APIs help to get information of detected target. these target info handler holds
- - type of target
- - target ID
- - ndef message supporting
- - max data size (if this tag is ndef message tag)
- - actual data size (if this tag is ndef message tag)
-*/
-
-/**
- type getter from target info handler
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[out] type tag type these type is one of the enum "net_nfc_target_type_e" defined
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_tag_type(net_nfc_target_info_h target_info, net_nfc_target_type_e *type);
-
-/**
- type getter from target info handler
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[out] handle target handle that is generated by nfc-manager
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_tag_handle(net_nfc_target_info_h target_info, net_nfc_target_handle_h *handle);
-
-/**
- this API returns the NDEF support boolean value.
- The TRUE value will be returned if the detected target is support NDEF, or return FALSE
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[out] is_support boolean value of NDEF supporting
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_tag_ndef_support(net_nfc_target_info_h target_info, bool *is_support);
-
-/**
- Get current ndef tag state
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[out] state ndef tag state
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-
-net_nfc_error_e net_nfc_get_tag_ndef_state(net_nfc_target_info_h target_info, net_nfc_ndef_card_state_e *state);
-
-/**
- The max size getter from target info handler. This max size indicates the maximum size of NDEF message that can be stored in this detected tag.
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[out] max_size max size of NDEF message that can be stored in this detected tag.
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_tag_max_data_size(net_nfc_target_info_h target_info, uint32_t *max_size);
-
-/**
- this function return the actual NDEF message size that stored in the tag
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[out] actual_data the actual NDEF message size that stored in the tag
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-
-*/
-
-net_nfc_error_e net_nfc_get_tag_actual_data_size(net_nfc_target_info_h target_info, uint32_t *actual_data);
-
-
-/**
- this function return keys which will be used to get a tag information
-
- \par Sync (or) Async: Sync
- This is a Synchronous API. keys will be freed by user.
-
- @param[in] target_info target info handler
- @param[out] keys pointer of double array. it will be array of string.
- @param[out] number_of_keys length of array.
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_ALLOC_FAIL memory allocation is failed
- @exception NET_NFC_NO_DATA_FOUND No data is returned
-
- @code
- void user_cb(net_nfc_message_e message, net_nfc_error_e result, void* data, void* trans_param)
- {
-
- switch(message)
- {
- case NET_NFC_MESSAGE_TAG_DISCOVERED:
- {
- if(info != NULL)
- {
- net_nfc_target_info_h target_info = (net_nfc_target_info_h)data;
-
- char **keys;
- int keys_length;
-
- if(net_nfc_get_tag_info_keys(target_info, &keys, &keys_length) == true)
- {
- int index = 0;
- for(; index < keys_length; index++)
- {
- char* key = keys[index];
- }
- }
-
- free(keys);
- }
- }
- }
-
- }
- @endcode
-
- @return return the result of calling this functions
-
-*/
-
-net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_info, char ***keys, int *number_of_keys);
-
-/**
- this function return value which is matched key
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[in] key key to retrieve
- @param[out] value value which is matched with key
-
- @code
- void user_cb(net_nfc_message_e message, net_nfc_error_e result, void* data, void* trans_param)
- {
-
- switch(message)
- {
- case NET_NFC_MESSAGE_TAG_DISCOVERED:
- {
- if(info != NULL)
- {
- net_nfc_target_info_h target_info = (net_nfc_target_info_h)data;
-
- char** keys;
- int keys_length;
-
- if(net_nfc_get_tag_info_keys(target_info, &keys, &keys_length) == NET_NFC_OK)
- {
- int index = 0;
- for(; index < keys_length; index++)
- {
- char* key = keys[index];
- data_h value;
- net_nfc_get_tag_info_value(target_info, key, &value);
- net_nfc_free_data(value);
- }
- }
- }
- }
- }
-
- }
- @endcode
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
- @exception NET_NFC_NO_DATA_FOUND No data is returned
-*/
-
-net_nfc_error_e net_nfc_get_tag_info_value(net_nfc_target_info_h target_info, const char *key, data_h *value);
-
-/**
- Get ndef message of current tag
-
- @remark This data can be expired because it is snapshot when tag was attached. If you want to get updated data, call @net_nfc_client_ndef_read function.
- @remark @msg must be release by caller with @net_nfc_free_ndef_message
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handler
- @param[out] msg ndef message
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-
-net_nfc_error_e net_nfc_get_tag_ndef_message(net_nfc_target_info_h target_info, ndef_message_h *msg);
-
-/**
- Duplicate a handle of target information
-
- ** IMPORTANT : After using duplicated handle, you should release a handle returned from this function.
- ** You can release a handle by net_nfc_release_tag_info function.
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] origin The original handle you want to duplicate
- @param[out] result The result of this function.
-
- @code
- void user_cb(net_nfc_message_e message, net_nfc_error_e result, void *data, void *trans_param)
- {
- switch(message)
- {
- case NET_NFC_MESSAGE_TAG_DISCOVERED:
- {
- net_nfc_target_info_h target_info = (net_nfc_target_info_h)data;
- net_nfc_target_info_h handle = NULL;
-
- net_nfc_duplicate_target_info(target_info, &handle);
-
- // do something...
-
- net_nfc_release_tag_info(handle);
- }
- break;
- }
-
- }
- @endcode
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-
-net_nfc_error_e net_nfc_duplicate_target_info(net_nfc_target_info_h origin, net_nfc_target_info_h *result);
-
-/**
- After using net_nfc_target_info_h handle, you should release its resource by this function.
-
- ** IMPORTANT : Never use this function in user callback you registered by net_nfc_set_response_callback function
- ** This function is for the result of net_nfc_duplicate_target_info or net_nfc_get_current_tag_info_sync
-
- \par Sync (or) Async: Sync
- This is a Synchronous API
-
- @param[in] target_info target info handle
-
- @code
- net_nfc_target_info_h handle;
-
- net_nfc_get_current_tag_info_sync(&handle);
-
- // do something...
-
- net_nfc_release_tag_info(handle);
- @endcode
-
- @return return the result of calling this functions
-
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
-*/
-
-net_nfc_error_e net_nfc_release_tag_info(net_nfc_target_info_h target_info);
-
-
-/**
-@} */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //__NET_NFC_TARGET_INFO_H__
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <glib.h>
-#include <gio/gio.h>
-
-#include "net_nfc_typedef.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_client_se.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_tag.h"
-#include "net_nfc_client_ndef.h"
-#include "net_nfc_client_transceive.h"
-#include "net_nfc_client_llcp.h"
-#include "net_nfc_client_snep.h"
-#include "net_nfc_client_p2p.h"
-#include "net_nfc_client_test.h"
-#include "net_nfc_client_system_handler.h"
-#include "net_nfc_client_handover.h"
-#include "net_nfc_client_hce.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-void __attribute__ ((constructor)) lib_init()
-{
-}
-
-void __attribute__ ((destructor)) lib_fini()
-{
-}
-
-void net_nfc_client_gdbus_init(void)
-{
-#if 0 /* change gdbus init time */
- if (net_nfc_client_manager_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_tag_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_ndef_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_transceive_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_llcp_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_snep_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_p2p_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_sys_handler_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_se_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_test_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_handover_init() != NET_NFC_OK)
- return;
- if (net_nfc_client_hce_init() != NET_NFC_OK)
- return;
-#endif
-}
-
-void net_nfc_client_gdbus_deinit(void)
-{
- net_nfc_client_hce_deinit();
- net_nfc_client_handover_deinit();
- net_nfc_client_test_deinit();
- net_nfc_client_se_deinit();
- net_nfc_client_sys_handler_deinit();
- net_nfc_client_p2p_deinit();
- net_nfc_client_snep_deinit();
- net_nfc_client_llcp_deinit();
- net_nfc_client_transceive_deinit();
- net_nfc_client_ndef_deinit();
- net_nfc_client_tag_deinit();
- net_nfc_client_manager_deinit();
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "vconf.h"
-
-#include "net_nfc_typedef.h"
-#include "net_nfc_client.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_initialize()
-{
- net_nfc_error_e result = NET_NFC_OK;
-
- net_nfc_client_gdbus_init();
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_deinitialize()
-{
- net_nfc_error_e result = NET_NFC_OK;
-
- net_nfc_client_gdbus_deinit();
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_is_nfc_supported(int *state)
-{
- net_nfc_error_e ret;
-
- if (state != NULL)
- {
- if (vconf_get_bool(VCONFKEY_NFC_FEATURE, state) == 0)
- {
- ret = NET_NFC_OK;
- }
- else
- {
- ret = NET_NFC_INVALID_STATE;
- }
- }
- else
- {
- ret = NET_NFC_NULL_PARAMETER;
- }
-
- return ret;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_get_nfc_state(int *state)
-{
- net_nfc_error_e ret;
-
- if (state != NULL)
- {
- if (vconf_get_bool(VCONFKEY_NFC_STATE, state) == 0)
- {
- ret = NET_NFC_OK;
- }
- else
- {
- ret = NET_NFC_INVALID_STATE;
- }
- }
- else
- {
- ret = NET_NFC_NULL_PARAMETER;
- }
-
- return ret;
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <string.h>
-
-#include "net_nfc_data.h"
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_util_internal.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_create_data_only(data_h *data)
-{
- return net_nfc_create_data(data, NULL, 0);
-}
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_create_data(data_h *data,
- const uint8_t *bytes, size_t length)
-{
- data_s *tmp_data = NULL;
-
- if (data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *data = NULL;
-
- tmp_data = net_nfc_util_create_data(length);
- if (tmp_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- if (length > 0 && bytes != NULL)
- {
- memcpy(tmp_data->buffer, bytes, length);
- }
-
- *data = (data_h)tmp_data;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_data(const data_h data,
- uint8_t **bytes, size_t *length)
-{
- data_s *tmp_data = (data_s *)data;
-
- if (bytes == NULL || length == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- *bytes = NULL;
- *length = 0;
-
- if (data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *bytes = tmp_data->buffer;
- *length = tmp_data->length;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_data(data_h data,
- const uint8_t *bytes, size_t length)
-{
- data_s *tmp_data = (data_s *)data;
-
- if (data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (tmp_data->buffer == bytes && tmp_data->length == length)
- {
- return NET_NFC_OK;
- }
-
- net_nfc_util_clear_data(tmp_data);
-
- if (length > 0)
- {
- net_nfc_util_init_data(tmp_data, length);
-
- if (bytes != NULL)
- {
- memcpy(tmp_data->buffer, bytes, length);
- }
- }
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API size_t net_nfc_get_data_length(const data_h data)
-{
- data_s *tmp_data = (data_s *)data;
-
- if (data == NULL)
- {
- return 0;
- }
-
- return tmp_data->length;
-}
-
-NET_NFC_EXPORT_API uint8_t *net_nfc_get_data_buffer(const data_h data)
-{
- data_s *tmp_data = (data_s *)data;
-
- if (data == NULL)
- {
- return NULL;
- }
-
- return tmp_data->buffer;
-}
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_free_data(data_h data)
-{
- data_s *tmp_data = (data_s *)data;
-
- if (data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (tmp_data->buffer != NULL)
- {
- _net_nfc_util_free_mem(tmp_data->buffer);
- }
- _net_nfc_util_free_mem(tmp_data);
-
- return NET_NFC_OK;
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_data.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_handover.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-typedef struct _handover_handler_t
-{
- net_nfc_connection_handover_event_cb handover_event_cb;
- gpointer handover_event_data;
-}
-handover_handler_t;
-
-static NetNfcGDbusHandover *handover_proxy = NULL;
-static handover_handler_t handover_callbacks;
-
-static void p2p_connection_handover(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void __started(NetNfcGDbusHandover *object,
- GVariant *arg_message)
-{
- data_s message;
-
- INFO_MSG(">>> SIGNAL arrived");
-
- net_nfc_util_gdbus_variant_to_data_s(arg_message, &message);
-
- if (handover_callbacks.handover_event_cb != NULL) {
- handover_callbacks.handover_event_cb(NET_NFC_HANDOVER_START,
- NET_NFC_OK, NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN,
- NULL, &message,
- handover_callbacks.handover_event_data);
- }
-
- net_nfc_util_clear_data(&message);
-}
-
-static void __finished(NetNfcGDbusHandover *object,
- gint arg_result,
- gint arg_type,
- GVariant *arg_address,
- GVariant *arg_message)
-{
- data_s address, message;
-
- INFO_MSG(">>> SIGNAL arrived");
-
- net_nfc_util_gdbus_variant_to_data_s(arg_address, &address);
- net_nfc_util_gdbus_variant_to_data_s(arg_message, &message);
-
- if (handover_callbacks.handover_event_cb != NULL) {
- handover_callbacks.handover_event_cb(NET_NFC_HANDOVER_FINISH,
- arg_result, arg_type, &address, &message,
- handover_callbacks.handover_event_data);
- }
-
- net_nfc_util_clear_data(&message);
- net_nfc_util_clear_data(&address);
-}
-
-static void p2p_connection_handover(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e result;
- GVariant *data = NULL;
- net_nfc_conn_handover_carrier_type_e type =
- NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN;
- GError *error = NULL;
- data_s arg_data;
-
- g_assert(user_data != NULL);
-
- if (handover_proxy == NULL)
- {
- if (net_nfc_client_handover_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("handover_proxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- if (net_nfc_gdbus_handover_call_request_finish(handover_proxy,
- (gint *)&result,
- (gint *)&type,
- &data,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish"
- " connection handover: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_p2p_connection_handover_completed_cb callback =
- (net_nfc_p2p_connection_handover_completed_cb)func_data->callback;
-
- net_nfc_util_gdbus_variant_to_data_s(data, &arg_data);
-
- callback(result,
- type,
- &arg_data,
- func_data->user_data);
-
- net_nfc_util_clear_data(&arg_data);
- }
-
- g_free(func_data);
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_handover_free_alternative_carrier_data(
- net_nfc_connection_handover_info_h info_handle)
-{
- net_nfc_connection_handover_info_s *info =
- (net_nfc_connection_handover_info_s *)info_handle;
-
- if (info_handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (info->data.buffer != NULL)
- {
- _net_nfc_util_free_mem(info->data.buffer);
- }
-
- _net_nfc_util_free_mem(info);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_handover_get_alternative_carrier_type(
- net_nfc_connection_handover_info_h info_handle,
- net_nfc_conn_handover_carrier_type_e *type)
-{
- net_nfc_connection_handover_info_s *info =
- (net_nfc_connection_handover_info_s *)info_handle;
-
- if (info_handle == NULL || type == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- *type = info->type;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_handover_get_alternative_carrier_data(
- net_nfc_connection_handover_info_h info_handle,
- data_h *data)
-{
- net_nfc_connection_handover_info_s *info =
- (net_nfc_connection_handover_info_s *)info_handle;
-
- if (info_handle == NULL || data == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- return net_nfc_create_data(data, info->data.buffer, info->data.length);
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_p2p_connection_handover(
- net_nfc_target_handle_h handle,
- net_nfc_conn_handover_carrier_type_e arg_type,
- net_nfc_p2p_connection_handover_completed_cb callback,
- void *cb_data)
-{
-
- net_nfc_target_handle_s *tag_handle = (net_nfc_target_handle_s *)handle;
- NetNfcCallback *funcdata;
-
- if (handover_proxy == NULL)
- {
- if(net_nfc_client_handover_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("handover_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- funcdata = g_try_new0(NetNfcCallback, 1);
- if (funcdata == NULL) {
- return NET_NFC_ALLOC_FAIL;
- }
-
- funcdata->callback = (gpointer)callback;
- funcdata->user_data = cb_data;
-
- net_nfc_gdbus_handover_call_request(handover_proxy,
- GPOINTER_TO_UINT(tag_handle),
- arg_type,
- NULL,
- p2p_connection_handover,
- funcdata);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_p2p_connection_handover_sync(
- net_nfc_target_handle_h handle,
- net_nfc_conn_handover_carrier_type_e arg_type,
- net_nfc_conn_handover_carrier_type_e *out_carrier,
- data_h *out_ac_data)
-{
- net_nfc_target_handle_s *tag_handle = (net_nfc_target_handle_s *)handle;
- GVariant *out_data = NULL;
- net_nfc_error_e out_result = NET_NFC_OK;
- net_nfc_conn_handover_carrier_type_e out_type =
- NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN;
- GError *error = NULL;
-
- if (handover_proxy == NULL)
- {
- if(net_nfc_client_handover_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("handover_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_handover_call_request_sync(handover_proxy,
- GPOINTER_TO_UINT(tag_handle),
- arg_type,
- (gint32 *)&out_result,
- (gint32 *)&out_type,
- &out_data,
- NULL,
- &error) == TRUE) {
- if (out_carrier) {
- *out_carrier = out_type;
- }
-
- if (out_ac_data) {
- *out_ac_data = net_nfc_util_gdbus_variant_to_data(out_data);
- }
- } else {
- DEBUG_ERR_MSG("handover (sync call) failed: %s",error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_handover_set_handover_event_cb(
- net_nfc_connection_handover_event_cb callback,
- void *user_data)
-{
- if (callback == NULL)
- return;
-
- if (handover_proxy == NULL)
- {
- if (net_nfc_client_handover_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("handover_proxy fail");
- return;
- }
- }
-
- handover_callbacks.handover_event_cb = callback;
- handover_callbacks.handover_event_data = user_data;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_handover_unset_handover_event_cb(void)
-{
- handover_callbacks.handover_event_cb = NULL;
- handover_callbacks.handover_event_data = NULL;
-}
-
-
-net_nfc_error_e net_nfc_client_handover_init(void)
-{
- GError *error = NULL;
-
- if (handover_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- handover_proxy = net_nfc_gdbus_handover_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Handover",
- NULL,
- &error);
- if (handover_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- g_signal_connect(handover_proxy, "started",
- G_CALLBACK(__started), NULL);
-
- g_signal_connect(handover_proxy, "finished",
- G_CALLBACK(__finished), NULL);
-
- return NET_NFC_OK;
-}
-
-
-void net_nfc_client_handover_deinit(void)
-{
- if (handover_proxy)
- {
- g_object_unref(handover_proxy);
- handover_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "vconf.h"
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_hce_ipc.h"
-#include "net_nfc_client_hce.h"
-
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-typedef struct _HceHandler HceHandler;
-
-struct _HceHandler
-{
- net_nfc_client_hce_event_cb hce_event_cb;
- gpointer hce_data;
-};
-
-static NetNfcGDbusHce *hce_proxy = NULL;
-
-static HceHandler hce_handler;
-static char package_name[1024];
-
-static void __load_package_name()
-{
- if (net_nfc_util_get_pkgid_by_pid(getpid(),
- package_name, sizeof(package_name)) == false) {
- DEBUG_ERR_MSG("failed to get package name, pid [%d]", getpid());
- }
-}
-
-static void hce_event_received(GObject *source_object, guint arg_handle,
- guint arg_event, GVariant *arg_apdu, gchar *arg_package)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- if (hce_handler.hce_event_cb != NULL) {
-
- data_s apdu = { NULL, 0 };
-
- net_nfc_util_gdbus_variant_to_data_s(arg_apdu, &apdu);
-
- hce_handler.hce_event_cb((net_nfc_target_handle_h)arg_handle,
- (net_nfc_hce_event_t)arg_event, &apdu,
- hce_handler.hce_data);
-
- net_nfc_util_clear_data(&apdu);
- }
-}
-
-void net_nfc_client_hce_process_received_event(int event,
- net_nfc_target_handle_h handle, data_h data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- if (hce_handler.hce_event_cb != NULL) {
- hce_handler.hce_event_cb(handle,
- (net_nfc_hce_event_t)event, data,
- hce_handler.hce_data);
- }
-}
-
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_hce_set_event_received_cb(
- net_nfc_client_hce_event_cb callback, void *user_data)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (callback == NULL) {
- return net_nfc_client_hce_unset_event_received_cb();
- }
-
- if (hce_proxy == NULL)
- {
- result = net_nfc_client_hce_init();
- if (result != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("net_nfc_client_hce_init failed, [%d]", result);
-
- return result;
- }
- }
-
- if (net_nfc_gdbus_hce_call_start_hce_handler_sync(hce_proxy,
- &result, NULL, &error) == true) {
- hce_handler.hce_event_cb = callback;
- hce_handler.hce_data = user_data;
-
- if (net_nfc_client_hce_ipc_is_initialized() == false) {
- result = net_nfc_client_hce_ipc_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_hce_ipc_init failed");
-
- result = NET_NFC_IPC_FAIL;
- }
- }
- } else {
- DEBUG_ERR_MSG("net_nfc_gdbus_hce_call_start_hce_handler_sync failed: %s", error->message);
- g_error_free(error);
-
- result = NET_NFC_IPC_FAIL;
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_hce_unset_event_received_cb(void)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (hce_proxy == NULL) {
- DEBUG_ERR_MSG("not initialized!!!");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- if (net_nfc_gdbus_hce_call_stop_hce_handler_sync(hce_proxy,
- &result, NULL, &error) == true) {
- hce_handler.hce_event_cb = NULL;
- hce_handler.hce_data = NULL;
-
- net_nfc_client_hce_ipc_deinit();
- } else {
- DEBUG_ERR_MSG("net_nfc_gdbus_hce_call_stop_hce_handler_sync failed: %s", error->message);
- g_error_free(error);
-
- result = NET_NFC_IPC_FAIL;
- }
-
- return result;
-}
-#if 0
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_hce_response_apdu_sync(
- net_nfc_target_handle_h handle,
- data_h resp_apdu_data)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *arg_data = NULL;
-
- INFO_MSG(">>> net_nfc_client_hce_response_apdu_sync!!");
-
- if (hce_proxy == NULL)
- {
- result = net_nfc_client_hce_init();
- if (result != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("net_nfc_client_hce_init failed, [%d]", result);
-
- return result;
- }
- }
-
- arg_data = net_nfc_util_gdbus_data_to_variant((data_s *)resp_apdu_data);
- if (arg_data == NULL)
- {
-
- INFO_MSG(">>> resp_apdu_data is null !!");
- return NET_NFC_INVALID_PARAM;
- }
-
- if (net_nfc_gdbus_hce_call_response_apdu_sync(
- hce_proxy,
- GPOINTER_TO_UINT(handle),
- arg_data,
- &result,
- NULL,
- &error) == true) {
- } else {
- DEBUG_ERR_MSG("Response APDU failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-#else
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_hce_response_apdu_sync(
- net_nfc_target_handle_h handle,
- data_h resp_apdu_data)
-{
- net_nfc_error_e result;
-
- DEBUG_CLIENT_MSG(">>> net_nfc_client_hce_response_apdu_sync!!");
-
- if (hce_proxy == NULL) {
- result = net_nfc_client_hce_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_hce_init failed, [%d]", result);
-
- return result;
- }
- }
-
- if (net_nfc_client_hce_ipc_is_initialized() == false) {
- if (net_nfc_client_hce_ipc_init() == false) {
- DEBUG_ERR_MSG("net_nfc_client_hce_ipc_init failed");
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_server_hce_ipc_send_to_server(0, handle, resp_apdu_data) == true) {
- result = NET_NFC_OK;
- } else {
- DEBUG_ERR_MSG("net_nfc_server_hce_ipc_send_to_server failed");
-
- result = NET_NFC_IPC_FAIL;
- }
-
- return result;
-}
-#endif
-net_nfc_error_e net_nfc_client_hce_init(void)
-{
- GError *error = NULL;
-
- DEBUG_CLIENT_MSG("net_nfc_client_hce_init call");
-
- if (hce_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- hce_proxy = net_nfc_gdbus_hce_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Hce",
- NULL,
- &error);
-
- if (hce_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
-
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- g_signal_connect(hce_proxy, "event-received",
- G_CALLBACK(hce_event_received), NULL);
-
- /* get package name */
- __load_package_name();
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_hce_deinit(void)
-{
- if (hce_proxy != NULL)
- {
- net_nfc_client_hce_ipc_deinit();
-
- g_object_unref(hce_proxy);
- hce_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.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://floralicense.org/license/
- *
- * 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 <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/un.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/epoll.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <stdarg.h>
-#include <signal.h>
-#include <glib-object.h>
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_defines.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_hce.h"
-#include "net_nfc_client_hce.h"
-#include "net_nfc_client_hce_ipc.h"
-
-/* static variable */
-static pthread_mutex_t g_client_ipc_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t cb_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static int hce_client_socket = -1;
-static GIOChannel *hce_client_channel = NULL;
-static guint hce_client_src_id = 0;
-
-/* static function */
-
-/////////////////////
-static void __set_non_block_socket(int socket)
-{
- int flags;
-
- flags = fcntl(socket, F_GETFL);
- flags |= O_NONBLOCK;
-
- if (fcntl(socket, F_SETFL, flags) < 0) {
- DEBUG_ERR_MSG("fcntl, executing nonblock error");
- }
-}
-
-static bool __receive_data_from_server(int socket, data_s *data)
-{
- bool result;
- ssize_t ret;
- uint32_t len;
-
- /* first, receive length */
- ret = recv(socket, (void *)&len, sizeof(len), 0);
- if (ret != sizeof(len)) {
- DEBUG_ERR_MSG("recv failed, socket [%d], result [%d]", socket, ret);
-
- return false;
- }
-
- if (len > 1024) {
- DEBUG_ERR_MSG("too large message, socket [%d], len [%d]", socket, len);
-
- return false;
- }
-
- result = net_nfc_util_init_data(data, len);
- if (result == true) {
- ssize_t offset = 0;
-
- /* second, receive buffer */
- do {
- ret = recv(socket, data->buffer + offset, data->length - offset, 0);
- if (ret == -1) {
- break;
- }
-
- offset += ret;
- } while (offset < len);
-
- if (offset != len) {
- DEBUG_ERR_MSG("recv failed, socket [%d], offset [%d], len [%d]", socket, offset, len);
-
- net_nfc_util_clear_data(data);
-
- result = false;
- } else {
- DEBUG_CLIENT_MSG("recv success, length [%d]", offset);
- }
- } else {
- DEBUG_ERR_MSG("net_nfc_util_init_data failed");
- }
-
- return result;
-}
-
-static bool __process_server_message()
-{
- bool result;
- data_s data;
-
- if (__receive_data_from_server(hce_client_socket, &data) == true) {
- net_nfc_hce_data_t *header;
- data_s temp;
-
- header = (net_nfc_hce_data_t *)data.buffer;
-
- temp.buffer = header->data;
- temp.length = data.length - sizeof(net_nfc_hce_data_t);
-
- net_nfc_client_hce_process_received_event(header->type,
- (net_nfc_target_handle_h)header->handle, (data_h)&temp);
-
- result = true;
- } else {
- DEBUG_ERR_MSG("__receive_data_from_client failed");
-
- result = false;
- }
-
- return result;
-}
-
-static bool __send_data_to_server(int socket, data_s *data)
-{
- ssize_t ret;
-
- ret = send(socket, data->buffer, data->length, 0);
- if (ret == -1) {
- DEBUG_ERR_MSG("send failed, socket [%d]", socket);
-
- return false;
- }
-
- return true;
-}
-
-bool net_nfc_server_hce_ipc_send_to_server(int type,
- net_nfc_target_handle_s *handle, data_s *data)
-{
- bool ret;
- data_s temp;
- uint32_t len = sizeof(net_nfc_hce_data_t);
-
- if (data != NULL && data->length > 0) {
- len += data->length;
- }
-
- ret = net_nfc_util_init_data(&temp, len + sizeof(len));
- if (ret == true) {
- net_nfc_hce_data_t *header;
-
- *(uint32_t *)(temp.buffer) = len;
- header = (net_nfc_hce_data_t *)(temp.buffer + sizeof(len));
-
- header->type = type;
- header->handle = (int)handle;
-
- if (data != NULL && data->length > 0) {
- memcpy(header->data, data->buffer, data->length);
- }
-
- ret = __send_data_to_server(hce_client_socket, &temp);
-
- net_nfc_util_clear_data(&temp);
- } else {
- DEBUG_ERR_MSG("net_nfc_util_init_data failed");
- }
-
- return ret;
-}
-
-/******************************************************************************/
-
-inline void net_nfc_client_ipc_lock()
-{
- pthread_mutex_lock(&g_client_ipc_mutex);
-}
-
-inline void net_nfc_client_ipc_unlock()
-{
- pthread_mutex_unlock(&g_client_ipc_mutex);
-}
-
-bool net_nfc_client_hce_ipc_is_initialized()
-{
- return (hce_client_socket != -1 && hce_client_channel != NULL);
-}
-
-static net_nfc_error_e _finalize_client_socket()
-{
- net_nfc_error_e result = NET_NFC_OK;
-
- net_nfc_client_ipc_lock();
-
- if (hce_client_src_id > 0) {
- g_source_remove(hce_client_src_id);
- hce_client_src_id = 0;
- }
-
- if (hce_client_channel != NULL) {
- g_io_channel_unref(hce_client_channel);
- hce_client_channel = NULL;
- }
-
- if (hce_client_socket != -1) {
- shutdown(hce_client_socket, SHUT_WR);
- close(hce_client_socket);
- hce_client_socket = -1;
-
- INFO_MSG("client socket closed");
- }
-
- net_nfc_client_ipc_unlock();
-
- return result;
-}
-
-static gboolean __on_io_event_cb(GIOChannel *channel, GIOCondition condition,
- gpointer data)
-{
- if ((G_IO_ERR & condition) || (G_IO_HUP & condition)) {
- DEBUG_CLIENT_MSG("client socket is closed");
-
- /* clean up client context */
- net_nfc_client_hce_ipc_deinit();
-
- return FALSE;
- } else if (G_IO_NVAL & condition) {
- DEBUG_CLIENT_MSG("INVALID socket");
-
- return FALSE;
- } else if (G_IO_IN & condition) {
- if(channel != hce_client_channel) {
- DEBUG_CLIENT_MSG("unknown channel");
-
- return FALSE;
- }
-
- DEBUG_CLIENT_MSG("message from server to client socket");
-
- if (__process_server_message() == false) {
- DEBUG_ERR_MSG("__process_server_message failed");
-
- net_nfc_client_hce_ipc_deinit();
-
- return FALSE;
- }
- } else {
- DEBUG_CLIENT_MSG("IO ERROR. socket is closed ");
-
- /* clean up client context */
- net_nfc_client_hce_ipc_deinit();
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-net_nfc_error_e net_nfc_client_hce_ipc_init()
-{
- net_nfc_error_e result = NET_NFC_OK;
- struct sockaddr_un saddrun_rv;
- socklen_t len_saddr = 0;
- pthread_mutexattr_t attr;
-
- if (net_nfc_client_hce_ipc_is_initialized() == true)
- {
- DEBUG_CLIENT_MSG("client is already initialized");
-
- return NET_NFC_ALREADY_INITIALIZED;
- }
-
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
- pthread_mutex_init(&cb_lock, &attr);
-
- memset(&saddrun_rv, 0, sizeof(struct sockaddr_un));
-
- net_nfc_client_ipc_lock();
-
- hce_client_socket = socket(AF_UNIX, SOCK_STREAM, 0);
- if (hce_client_socket == -1)
- {
- DEBUG_ERR_MSG("get socket is failed");
-
- result = NET_NFC_IPC_FAIL;
- goto ERROR;
- }
-
- __set_non_block_socket(hce_client_socket);
-
- saddrun_rv.sun_family = AF_UNIX;
- strncpy(saddrun_rv.sun_path, NET_NFC_HCE_SERVER_DOMAIN, sizeof(saddrun_rv.sun_path) - 1);
-
- len_saddr = sizeof(saddrun_rv.sun_family) + strlen(NET_NFC_HCE_SERVER_DOMAIN);
-
- if (connect(hce_client_socket, (struct sockaddr *)&saddrun_rv, len_saddr) < 0) {
- DEBUG_ERR_MSG("error is occured");
- result = NET_NFC_IPC_FAIL;
-
- goto ERROR;
- }
-
- GIOCondition condition = (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_IN);
-
- hce_client_channel = g_io_channel_unix_new(hce_client_socket);
- if (hce_client_channel == NULL) {
- DEBUG_ERR_MSG(" g_io_channel_unix_new is failed ");
- result = NET_NFC_IPC_FAIL;
-
- goto ERROR;
- }
-
- hce_client_src_id = g_io_add_watch(hce_client_channel, condition,
- __on_io_event_cb, NULL);
- if (hce_client_src_id < 1) {
- DEBUG_ERR_MSG(" g_io_add_watch is failed ");
- result = NET_NFC_IPC_FAIL;
-
- goto ERROR;
- }
-
- DEBUG_CLIENT_MSG("client socket is ready");
-
- net_nfc_client_ipc_unlock();
-
- return NET_NFC_OK;
-
-ERROR :
- DEBUG_ERR_MSG("error while initializing client ipc");
-
- net_nfc_client_ipc_unlock();
-
- _finalize_client_socket();
-
- return result;
-}
-
-void net_nfc_client_hce_ipc_deinit()
-{
- if (net_nfc_client_hce_ipc_is_initialized() == true) {
- _finalize_client_socket();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_llcp.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-typedef struct _LlcpFuncData LlcpFuncData;
-
-struct _LlcpFuncData
-{
- gpointer callback;
- gpointer user_data;
-};
-
-static NetNfcGDbusLlcp *llcp_proxy = NULL;
-static net_nfc_llcp_config_info_s llcp_config = { 128, 0, 0, 1 };
-static net_nfc_target_handle_s *llcp_handle = NULL;
-static GList *socket_data_list = NULL;
-static guint socket_handle = 0;
-
-
-void llcp_socket_data_append(net_nfc_llcp_internal_socket_s *socket_data);
-
-void llcp_socket_data_remove(net_nfc_llcp_internal_socket_s *socket_data);
-
-net_nfc_llcp_internal_socket_s *llcp_socket_data_find
- (net_nfc_llcp_socket_t socket);
-
-/* aysnc callback */
-static void llcp_call_config(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_listen(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_connect(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_connect_sap(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_send(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_send_to(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_receive(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_receive_from(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_close(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void llcp_call_disconnect(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-/* signal callback */
-static void llcp_error(NetNfcGDbusLlcp *object,
- guint arg_handle,
- guint client_socket,
- gint error,
- gpointer user_data);
-
-static void llcp_incoming(NetNfcGDbusLlcp *object,
- guint arg_handle,
- guint client_socket,
- guint incoming_socket,
- gpointer user_data);
-
-void llcp_socket_data_append(net_nfc_llcp_internal_socket_s *socket_data)
-{
- if (socket_data_list == NULL)
- return;
-
- if (socket_data)
- {
- socket_data_list = g_list_append(socket_data_list,
- socket_data);
- }
-}
-
-void llcp_socket_data_remove(net_nfc_llcp_internal_socket_s *socket_data)
-{
- if (socket_data_list == NULL)
- return;
-
- if (socket_data)
- {
- socket_data_list = g_list_remove(socket_data_list,
- socket_data);
-
- g_free(socket_data->service_name);
- g_free(socket_data);
- }
-}
-
-net_nfc_llcp_internal_socket_s *llcp_socket_data_find
- (net_nfc_llcp_socket_t socket)
-{
- GList *pos;
-
- if (socket_data_list == NULL)
- return NULL;
-
-
- for (pos = g_list_first(socket_data_list); pos ; pos = pos->data)
- {
- net_nfc_llcp_internal_socket_s *data;
-
- data = pos->data;
- if (data == NULL)
- continue;
-
- if (data->client_socket == socket)
- break;
- }
-
- if (pos == NULL)
- return NULL;
-
- return pos->data;
-}
-
-static void llcp_call_config(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- GError *error = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_config_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish config: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_config_completed callback =
- (net_nfc_client_llcp_config_completed)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_listen(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- guint32 out_client_socket = -1;
- GError *error = NULL;
- guint32 out_oal_socket = -1;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_listen_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &out_client_socket,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish listen: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- socket_data = llcp_socket_data_find(out_client_socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return;
- }
-
- socket_data->oal_socket = out_oal_socket;
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_listen_completed callback =
- (net_nfc_client_llcp_listen_completed)func_data->callback;
-
- callback(result, out_client_socket, func_data->user_data);
- }
-
- /* TODO : release resource when socket is closed */
-// g_free(func_data);
-}
-
-static void llcp_call_accept(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- GError *error = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_accept_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish accept: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_accept_completed callback =
- (net_nfc_client_llcp_accept_completed)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_reject(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- GError *error = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_reject_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish reject: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_reject_completed callback =
- (net_nfc_client_llcp_reject_completed)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_connect(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- guint32 out_client_socket = -1;
- GError *error = NULL;
- guint32 out_oal_socket = -1;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_connect_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &out_client_socket,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish connect: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- socket_data = llcp_socket_data_find(out_client_socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return;
- }
-
- socket_data->oal_socket = out_oal_socket;
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_connect_completed callback =
- (net_nfc_client_llcp_connect_completed)func_data->callback;
-
- callback(result, out_client_socket, func_data->user_data);
- }
-
- /* TODO : release resource when socket is closed */
-// g_free(func_data);
-}
-
-static void llcp_call_connect_sap(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- guint32 out_client_socket = -1;
- GError *error = NULL;
- guint32 out_oal_socket = -1;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_connect_sap_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &out_client_socket,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish connect sap: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- socket_data = llcp_socket_data_find(out_client_socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return;
- }
-
- socket_data->oal_socket = out_oal_socket;
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_connect_sap_completed callback =
- (net_nfc_client_llcp_connect_sap_completed)func_data->callback;
-
- callback(result, out_client_socket, func_data->user_data);
- }
-
- /* TODO : release resource when socket is closed */
-// g_free(func_data);
-}
-
-static void llcp_call_send(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- guint32 out_client_socket = -1;
- GError *error = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_send_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &out_client_socket,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish send: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_send_completed callback =
- (net_nfc_client_llcp_send_completed)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_send_to(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- guint32 out_client_socket = -1;
- GError *error = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_send_to_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &out_client_socket,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish send to: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_send_to_completed callback =
- (net_nfc_client_llcp_send_to_completed)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_receive(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- GVariant *variant = NULL;
- GError *error = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_receive_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &variant,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish receive: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_receive_completed callback =
- (net_nfc_client_llcp_receive_completed)func_data->callback;
- data_s data = { NULL, 0 };
-
- net_nfc_util_gdbus_variant_to_data_s(variant, &data);
-
- callback(result, &data, func_data->user_data);
-
- net_nfc_util_clear_data(&data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_receive_from(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- sap_t sap = 0;
- GVariant *variant = NULL;
- GError *error = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_receive_from_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &sap,
- &variant,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish receive from: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_receive_from_completed callback =
- (net_nfc_client_llcp_receive_from_completed)func_data->callback;
- data_s data = { NULL, 0 };
-
- net_nfc_util_gdbus_variant_to_data_s(variant, &data);
-
- callback(result, sap, &data, func_data->user_data);
-
- net_nfc_util_clear_data(&data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_close(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- guint32 out_client_socket = -1;
- GError *error = NULL;
-
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_close_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &out_client_socket,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish close: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- socket_data = llcp_socket_data_find(out_client_socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return;
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_llcp_close_completed callback =
- (net_nfc_client_llcp_close_completed)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_call_disconnect(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LlcpFuncData *func_data = user_data;
- net_nfc_error_e result;
- guint32 out_client_socket = -1;
- GError *error = NULL;
-
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- g_assert(func_data != NULL);
-
- if (net_nfc_gdbus_llcp_call_disconnect_finish(
- NET_NFC_GDBUS_LLCP(source_object),
- &result,
- &out_client_socket,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish disconnect: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- socket_data = llcp_socket_data_find(out_client_socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return;
- }
-
- if (func_data->callback != NULL) {
- net_nfc_client_llcp_disconnect_completed callback =
- (net_nfc_client_llcp_disconnect_completed)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void llcp_error(NetNfcGDbusLlcp *object,
- guint arg_handle,
- guint client_socket,
- gint error,
- gpointer user_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-}
-
-static void llcp_incoming(NetNfcGDbusLlcp *object,
- guint arg_handle,
- guint client_socket,
- guint incoming_socket,
- gpointer user_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-}
-
-/* Public APIs */
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_config(net_nfc_llcp_config_info_h config,
- net_nfc_client_llcp_config_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- GVariant *variant;
-
- if (config == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- memcpy(&llcp_config, config, sizeof(net_nfc_llcp_config_info_s));
-
- variant = g_variant_new("(qqyy)",
- config->miu,
- config->wks,
- config->lto,
- config->option);
-
- net_nfc_gdbus_llcp_call_config(llcp_proxy,
- variant,
- NULL,
- llcp_call_config,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_config_sync
- (net_nfc_llcp_config_info_h config)
-{
- net_nfc_error_e result;
- GVariant *variant = NULL;
- GError *error = NULL;
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- memcpy(&llcp_config, config, sizeof(net_nfc_llcp_config_info_s));
-
- variant = g_variant_new("(qqyy)",
- config->miu,
- config->wks,
- config->lto,
- config->option);
-
- if (net_nfc_gdbus_llcp_call_config_sync(llcp_proxy,
- variant,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not config: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_config
- (net_nfc_llcp_config_info_h *config)
-{
- if (config == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- *config = (net_nfc_llcp_config_info_h)&llcp_config;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_listen(net_nfc_llcp_socket_t socket,
- const char *service_name,
- sap_t sap,
- net_nfc_client_llcp_listen_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* FIXME: temporary typecast to (uint8_t *) */
- socket_data->service_name = (uint8_t *)g_strdup(service_name);
- socket_data->sap = sap;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_listen(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- socket_data->miu,
- socket_data->rw,
- socket_data->type,
- socket_data->sap,
- service_name,
- NULL,
- llcp_call_listen,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_listen_sync(net_nfc_llcp_socket_t socket,
- const char *service_name,
- sap_t sap,
- net_nfc_llcp_socket_t *out_socket)
-{
- net_nfc_error_e result;
- GError *error = NULL;
- guint32 out_client_socket;
-
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
- net_nfc_llcp_internal_socket_s *out_socket_data = NULL;
-
- if (out_socket == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (service_name == NULL)
- {
- DEBUG_ERR_MSG("service_name is empty");
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* FIXME: temporary typecast to (uint8_t *) */
- socket_data->service_name = (uint8_t *)g_strdup(service_name);
- socket_data->sap = sap;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_listen_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- socket_data->miu,
- socket_data->rw,
- socket_data->type,
- socket_data->sap,
- service_name,
- &result,
- &out_client_socket,
- NULL,
- &error) == true) {
- out_socket_data = llcp_socket_data_find(out_client_socket);
- if (out_socket_data == NULL || out_socket_data != socket_data)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return NET_NFC_UNKNOWN_ERROR;
- }
-
-// out_socket_data->oal_socket = out_oal_socket;
-
- if (out_socket)
- *out_socket = out_client_socket;
- } else {
- DEBUG_ERR_MSG("can not listen: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_accept(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_accept_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_accept(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket,
- NULL,
- llcp_call_accept,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_accept_sync(net_nfc_llcp_socket_t socket)
-{
- net_nfc_error_e result;
- GError *error = NULL;
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_accept_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket,
- &result,
- NULL,
- &error) == false) {
- DEBUG_ERR_MSG("can not connect: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_reject(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_reject_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_reject(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket,
- NULL,
- llcp_call_reject,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_reject_sync(net_nfc_llcp_socket_t socket)
-{
- net_nfc_error_e result;
- GError *error = NULL;
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_reject_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket,
- &result,
- NULL,
- &error) == false) {
- DEBUG_ERR_MSG("can not connect: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_connect(net_nfc_llcp_socket_t socket,
- const char *service_name,
- net_nfc_client_llcp_connect_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (service_name == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_connect(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- socket_data->miu,
- socket_data->rw,
- socket_data->type,
- service_name,
- NULL,
- llcp_call_connect,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_connect_sync(net_nfc_llcp_socket_t socket,
- const char *service_name,
- net_nfc_llcp_socket_t *out_socket)
-{
- net_nfc_error_e result;
- GError *error = NULL;
- guint32 out_client_socket;
-
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
- net_nfc_llcp_internal_socket_s *out_socket_data = NULL;
-
- if (service_name == NULL || out_socket == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_connect_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- socket_data->miu,
- socket_data->rw,
- socket_data->type,
- service_name,
- &result,
- &out_client_socket,
- NULL,
- &error) == true) {
- out_socket_data = llcp_socket_data_find(out_client_socket);
- if (out_socket_data == NULL || out_socket_data != socket_data)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return NET_NFC_UNKNOWN_ERROR;
- }
-
-// out_socket_data->oal_socket = out_oal_socket;
-
- if (out_socket)
- *out_socket = out_client_socket;
- } else {
- DEBUG_ERR_MSG("can not connect: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_connect_sap(net_nfc_llcp_socket_t socket,
- sap_t sap,
- net_nfc_client_llcp_connect_sap_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (sap == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_connect_sap(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- socket_data->miu,
- socket_data->rw,
- socket_data->type,
- sap,
- NULL,
- llcp_call_connect_sap,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_connect_sap_sync(
- net_nfc_llcp_socket_t socket,
- sap_t sap,
- net_nfc_llcp_socket_t *out_socket)
-{
- net_nfc_error_e result;
- GError *error = NULL;
- guint32 out_client_socket;
-
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
- net_nfc_llcp_internal_socket_s *out_socket_data = NULL;
-
- if (out_socket == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (sap == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_connect_sap_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- socket_data->miu,
- socket_data->rw,
- socket_data->type,
- sap,
- &result,
- &out_client_socket,
- NULL,
- &error) == true) {
- out_socket_data = llcp_socket_data_find(out_client_socket);
- if (out_socket_data == NULL || out_socket_data != socket_data)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return NET_NFC_UNKNOWN_ERROR;
- }
-
-// out_socket_data->oal_socket = out_oal_socket;
-
- if (out_socket)
- *out_socket = out_client_socket;
- } else {
- DEBUG_ERR_MSG("can not connect: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_send(net_nfc_llcp_socket_t socket,
- data_h data,
- net_nfc_client_llcp_send_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- GVariant *variant;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (data == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (socket <= 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- variant = net_nfc_util_gdbus_data_to_variant(data);
-
- net_nfc_gdbus_llcp_call_send(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- variant,
- NULL,
- llcp_call_send,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_send_sync(net_nfc_llcp_socket_t socket,
- data_h data)
-{
- net_nfc_error_e result;
- GVariant *variant;
- GError *error = NULL;
- guint32 out_client_socket;
-
- net_nfc_llcp_internal_socket_s *socket_data;
- net_nfc_llcp_internal_socket_s *out_socket_data;
-
- if (data == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (socket <= 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- variant = net_nfc_util_gdbus_data_to_variant(data);
-
- if (net_nfc_gdbus_llcp_call_send_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- variant,
- &result,
- &out_client_socket,
- NULL,
- &error) == true) {
- out_socket_data = llcp_socket_data_find(out_client_socket);
- if (out_socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not find socket_data");
- return NET_NFC_UNKNOWN_ERROR;
- }
- } else {
- DEBUG_ERR_MSG("can not call send: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_send_to(net_nfc_llcp_socket_t socket,
- sap_t sap,
- data_h data,
- net_nfc_client_llcp_send_to_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- GVariant *variant;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (data == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (socket <= 0 || sap == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- variant = net_nfc_util_gdbus_data_to_variant(data);
-
- net_nfc_gdbus_llcp_call_send_to(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- sap,
- variant,
- NULL,
- llcp_call_send_to,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_send_to_sync(net_nfc_llcp_socket_t socket,
- sap_t sap,
- data_h data)
-{
- net_nfc_error_e result;
- GVariant *variant;
- GError *error = NULL;
- guint32 out_client_socket;
-
- net_nfc_llcp_internal_socket_s *socket_data;
- net_nfc_llcp_internal_socket_s *out_socket_data;
-
- if (data == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (socket <= 0 || sap == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- variant = net_nfc_util_gdbus_data_to_variant(data);
-
- if (net_nfc_gdbus_llcp_call_send_to_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- sap,
- variant,
- &result,
- &out_client_socket,
- NULL,
- &error) == true) {
- out_socket_data = llcp_socket_data_find(out_client_socket);
- if (out_socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not find socket_data");
- return NET_NFC_UNKNOWN_ERROR;
- }
- } else {
- DEBUG_ERR_MSG("can not call send to: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_receive(net_nfc_llcp_socket_t socket,
- size_t request_length,
- net_nfc_client_llcp_receive_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (socket <= 0 || request_length == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_receive(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- request_length,
- NULL,
- llcp_call_receive,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_receive_sync(net_nfc_llcp_socket_t socket,
- size_t request_length,
- data_h *out_data)
-{
- net_nfc_error_e result;
- GVariant *variant;
- GError *error = NULL;
- net_nfc_llcp_internal_socket_s *socket_data;
-
- if (out_data == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *out_data = NULL;
-
- if (socket <= 0 || request_length == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_receive_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- request_length,
- &result,
- &variant,
- NULL,
- &error) == true) {
- *out_data = net_nfc_util_gdbus_variant_to_data(variant);
- } else {
- DEBUG_ERR_MSG("can not call receive: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_receive_from(net_nfc_llcp_socket_t socket,
- size_t request_length,
- net_nfc_client_llcp_receive_from_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (socket <= 0 || request_length == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_receive_from(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- request_length,
- NULL,
- llcp_call_receive_from,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_receive_from_sync(
- net_nfc_llcp_socket_t socket,
- size_t request_length,
- sap_t *out_sap,
- data_h *out_data)
-{
- net_nfc_error_e result;
- GError *error = NULL;
- GVariant *variant;
- sap_t sap;
-
- net_nfc_llcp_internal_socket_s *socket_data;
-
- if (out_sap == NULL || out_data == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *out_data = NULL;
- *out_sap = 0;
-
- if (socket <= 0 || request_length == 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_receive_from_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- request_length,
- &result,
- &sap,
- &variant,
- NULL,
- &error) == true) {
- *out_sap = sap;
- *out_data = net_nfc_util_gdbus_variant_to_data(variant);
- } else {
- DEBUG_ERR_MSG("can not call receive from: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_close(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_close_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (socket <= 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_close(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- NULL,
- llcp_call_close,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_close_sync(net_nfc_llcp_socket_t socket)
-{
- net_nfc_error_e result;
- GError *error = NULL;
- guint32 out_client_socket;
-
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
- net_nfc_llcp_internal_socket_s *out_socket_data = NULL;
-
- if (socket <= 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_close_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- &result,
- &out_client_socket,
- NULL,
- &error) == true) {
- out_socket_data = llcp_socket_data_find(out_client_socket);
- if (out_socket_data == NULL || out_socket_data != socket_data)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return NET_NFC_UNKNOWN_ERROR;
- }
- } else {
- DEBUG_ERR_MSG("can not close: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_disconnect(net_nfc_llcp_socket_t socket,
- net_nfc_client_llcp_disconnect_completed callback,
- void *user_data)
-{
- LlcpFuncData *func_data;
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- if (socket <= 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_new0(LlcpFuncData, 1);
- if (func_data == NULL) {
- DEBUG_ERR_MSG("g_new0 failed");
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_llcp_call_disconnect(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- NULL,
- llcp_call_disconnect,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_disconnect_sync(
- net_nfc_llcp_socket_t socket)
-{
- net_nfc_error_e result;
- GError *error = NULL;
- guint32 out_client_socket;
-
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
- net_nfc_llcp_internal_socket_s *out_socket_data = NULL;
-
- if (socket <= 0) {
- return NET_NFC_INVALID_PARAM;
- }
-
- if (llcp_proxy == NULL)
- {
- if(net_nfc_client_llcp_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("llcp_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- {
- DEBUG_ERR_MSG("can not get socket_data");
- return NET_NFC_LLCP_INVALID_SOCKET;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_llcp_call_disconnect_sync(llcp_proxy,
- GPOINTER_TO_UINT(llcp_handle),
- socket_data->client_socket,
- &result,
- &out_client_socket,
- NULL,
- &error) == true) {
- out_socket_data = llcp_socket_data_find(out_client_socket);
- if (out_socket_data == NULL || out_socket_data != socket_data)
- {
- DEBUG_ERR_MSG("Wrong client socket is returned");
- return NET_NFC_UNKNOWN_ERROR;
- }
- } else {
- DEBUG_ERR_MSG("can not disconnect: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_llcp_create_socket(net_nfc_llcp_socket_t *socket,
- net_nfc_llcp_socket_option_h option)
-{
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- socket_data = g_new0(net_nfc_llcp_internal_socket_s, 1);
-
- socket_data->client_socket = socket_handle++;
-
- if (option)
- {
- socket_data->miu = option->miu;
- socket_data->rw = option->rw;
- socket_data->type = option->type;
- }
- else
- {
- socket_data->miu = 128;
- socket_data->rw = 1;
- socket_data->type =
- NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED;
- }
-
- socket_data->device_id = llcp_handle;
- socket_data->close_requested = false;
-
-
- if (socket)
- *socket = socket_data->client_socket;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_local_config(
- net_nfc_llcp_config_info_h *config)
-{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *config = (net_nfc_llcp_config_info_h)&llcp_config;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_local_socket_option(
- net_nfc_llcp_socket_t socket,
- net_nfc_llcp_socket_option_h *info)
-{
- net_nfc_llcp_internal_socket_s *socket_data = NULL;
-
- DEBUG_CLIENT_MSG("function %s is called", __func__);
-
- socket_data = llcp_socket_data_find(socket);
- if (socket_data == NULL)
- return NET_NFC_LLCP_INVALID_SOCKET;
-
- *info = (net_nfc_llcp_socket_option_h)socket_data;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_create_socket_option(
- net_nfc_llcp_socket_option_h *option,
- uint16_t miu,
- uint8_t rw,
- net_nfc_socket_type_e type)
-{
- net_nfc_llcp_socket_option_s *struct_option = NULL;
-
- if (option == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (miu < 128 || miu > 1152 ||
- rw < 1 || rw > 15 ||
- type < NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED ||
- type > NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONLESS)
- {
- return NET_NFC_OUT_OF_BOUND;
- }
-
- _net_nfc_util_alloc_mem(struct_option, sizeof(net_nfc_llcp_socket_option_s));
- if (struct_option != NULL)
- {
- struct_option->miu = miu;
- struct_option->rw = rw;
- struct_option->type = type;
-
- *option = (net_nfc_llcp_socket_option_h)struct_option;
-
- return NET_NFC_OK;
- }
- else
- {
- return NET_NFC_ALLOC_FAIL;
- }
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_create_socket_option_default(
- net_nfc_llcp_socket_option_h *option)
-{
- return net_nfc_client_llcp_create_socket_option(
- option,
- 128,
- 1,
- NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_socket_option_miu(
- net_nfc_llcp_socket_option_h option,
- uint16_t *miu)
-{
- net_nfc_llcp_socket_option_s *struct_option =
- (net_nfc_llcp_socket_option_s *)option;
-
- if (option == NULL || miu == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *miu = struct_option->miu;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_set_socket_option_miu(
- net_nfc_llcp_socket_option_h option,
- uint16_t miu)
-{
- net_nfc_llcp_socket_option_s *struct_option =
- (net_nfc_llcp_socket_option_s *)option;
-
- if (option == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- struct_option->miu = miu;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_socket_option_rw(
- net_nfc_llcp_socket_option_h option,
- uint8_t *rw)
-{
- if (option == NULL || rw == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
- net_nfc_llcp_socket_option_s *struct_option = (net_nfc_llcp_socket_option_s *)option;
-
- *rw = struct_option->rw;
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_set_socket_option_rw(
- net_nfc_llcp_socket_option_h option,
- uint8_t rw)
-{
- if (option == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
- net_nfc_llcp_socket_option_s *struct_option = (net_nfc_llcp_socket_option_s *)option;
-
- struct_option->rw = rw;
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_socket_option_type(
- net_nfc_llcp_socket_option_h option,
- net_nfc_socket_type_e * type)
-{
- if (option == NULL || type == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
- net_nfc_llcp_socket_option_s *struct_option = (net_nfc_llcp_socket_option_s *)option;
-
- *type = struct_option->type;
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_set_socket_option_type(
- net_nfc_llcp_socket_option_h option,
- net_nfc_socket_type_e type)
-{
- if (option == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
- net_nfc_llcp_socket_option_s *struct_option = (net_nfc_llcp_socket_option_s *)option;
-
- struct_option->type = type;
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_free_socket_option(
- net_nfc_llcp_socket_option_h option)
-{
- if (option == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- _net_nfc_util_free_mem(option);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_create_config(
- net_nfc_llcp_config_info_h *config,
- uint16_t miu,
- uint16_t wks,
- uint8_t lto,
- uint8_t option)
-{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s **tmp_config =
- (net_nfc_llcp_config_info_s **)config;
-
- _net_nfc_util_alloc_mem(*tmp_config,
- sizeof(net_nfc_llcp_config_info_s));
-
- if (*tmp_config == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- (*tmp_config)->miu = miu;
- (*tmp_config)->wks = wks;
- (*tmp_config)->lto = lto;
- (*tmp_config)->option = option;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_create_config_default(net_nfc_llcp_config_info_h *config)
-{
- return net_nfc_client_llcp_create_config(config, 128, 1, 10, 0);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_config_miu(
- net_nfc_llcp_config_info_h config,
- uint16_t *miu)
-{
- if (config == NULL || miu == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s *tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- *miu = tmp_config->miu;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_config_wks(
- net_nfc_llcp_config_info_h config,
- uint16_t *wks)
-{
- if (config == NULL || wks == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s *tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- *wks = tmp_config->wks;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_config_lto(
- net_nfc_llcp_config_info_h config,
- uint8_t *lto)
-{
- if (config == NULL || lto == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s *tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- *lto = tmp_config->lto;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_get_config_option(
- net_nfc_llcp_config_info_h config,
- uint8_t *option)
-{
- if (config == NULL || option == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s *tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- *option = tmp_config->option;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_set_config_miu(
- net_nfc_llcp_config_info_h config,
- uint16_t miu)
-{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (miu < 128 || miu > 1152)
- {
- return NET_NFC_OUT_OF_BOUND;
- }
-
- net_nfc_llcp_config_info_s * tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- tmp_config->miu = miu;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_set_config_wks(
- net_nfc_llcp_config_info_h config,
- uint16_t wks)
-{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s *tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- tmp_config->wks = wks;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_set_config_lto(
- net_nfc_llcp_config_info_h config,
- uint8_t lto)
-{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s *tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- tmp_config->lto = lto;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_set_config_option(
- net_nfc_llcp_config_info_h config,
- uint8_t option)
-{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- net_nfc_llcp_config_info_s * tmp_config =
- (net_nfc_llcp_config_info_s *)config;
-
- tmp_config->option = option;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_llcp_free_config(net_nfc_llcp_config_info_h config)
-{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- _net_nfc_util_free_mem(config);
- return NET_NFC_OK;
-}
-
-net_nfc_error_e net_nfc_client_llcp_init(void)
-{
- GError *error = NULL;
-
- if (llcp_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- llcp_proxy = net_nfc_gdbus_llcp_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Llcp",
- NULL,
- &error);
- if (llcp_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
-
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- g_signal_connect(llcp_proxy, "error",
- G_CALLBACK(llcp_error), NULL);
-
- g_signal_connect(llcp_proxy, "incoming",
- G_CALLBACK(llcp_incoming), NULL);
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_llcp_deinit(void)
-{
- if (llcp_proxy)
- {
- g_object_unref(llcp_proxy);
- llcp_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_debug_internal.h"
-
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_context.h"
-#include "net_nfc_client_manager.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-#define DEACTIVATE_DELAY 500 /* ms */
-#define ACTIVATE_DELAY 100 /* ms */
-
-typedef struct _ManagerFuncData ManagerFuncData;
-
-struct _ManagerFuncData
-{
- gpointer callback;
- gpointer user_data;
- net_nfc_error_e result;
-};
-
-static NetNfcGDbusManager *manager_proxy = NULL;
-static NetNfcGDbusManager *auto_start_proxy = NULL;
-static ManagerFuncData activated_func_data;
-static int is_activated = -1;
-static guint timeout_id[2];
-
-static void manager_call_set_active_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void manager_call_get_server_state_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-
-static void manager_activated(NetNfcGDbusManager *manager,
- gboolean activated,
- gpointer user_data);
-
-
-static gboolean _set_activate_time_elapsed_callback(gpointer user_data)
-{
- ManagerFuncData *func_data = (ManagerFuncData *)user_data;
- net_nfc_client_manager_set_active_completed callback;
-
- if (timeout_id[0] > 0) {
- g_assert(func_data != NULL);
-
- g_source_remove(timeout_id[0]);
- timeout_id[0] = 0;
-
- callback = (net_nfc_client_manager_set_active_completed)func_data->callback;
-
- callback(func_data->result, func_data->user_data);
-
- g_free(func_data);
- }
-
- return false;
-}
-
-static void manager_call_set_active_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- ManagerFuncData *func_data = (ManagerFuncData *)user_data;
- net_nfc_error_e result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_manager_call_set_active_finish(
- NET_NFC_GDBUS_MANAGER(source_object),
- &result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish call_set_active: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- func_data->result = result;
- net_nfc_client_get_nfc_state(&is_activated);
-
- if (is_activated == false) {
- /* FIXME : wait several times */
- timeout_id[0] = g_timeout_add(DEACTIVATE_DELAY,
- _set_activate_time_elapsed_callback,
- func_data);
- } else {
- timeout_id[0] = g_timeout_add(ACTIVATE_DELAY,
- _set_activate_time_elapsed_callback,
- func_data);
- }
-}
-
-static void manager_call_get_server_state_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e result;
- guint out_state = 0;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_manager_call_get_server_state_finish(
- NET_NFC_GDBUS_MANAGER(source_object),
- &result,
- &out_state,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish get_server_state: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_manager_get_server_state_completed callback =
- (net_nfc_client_manager_get_server_state_completed)func_data->callback;
-
- callback(result, out_state, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static gboolean _activated_time_elapsed_callback(gpointer user_data)
-{
- net_nfc_client_manager_activated callback =
- (net_nfc_client_manager_activated)activated_func_data.callback;
-
- if (timeout_id[1] > 0) {
- g_source_remove(timeout_id[1]);
- timeout_id[1] = 0;
-
- callback(is_activated, activated_func_data.user_data);
- }
-
- return false;
-}
-
-static void manager_activated(NetNfcGDbusManager *manager,
- gboolean activated,
- gpointer user_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
- DEBUG_CLIENT_MSG("activated %d", activated);
-
- /* update current state */
- is_activated = (int)activated;
-
- if (activated_func_data.callback != NULL)
- {
- if (is_activated == false) {
- /* FIXME : wait several times */
- timeout_id[1] = g_timeout_add(DEACTIVATE_DELAY,
- _activated_time_elapsed_callback,
- NULL);
- } else {
- timeout_id[1] = g_timeout_add(ACTIVATE_DELAY,
- _activated_time_elapsed_callback,
- NULL);
- }
- }
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_manager_set_activated(
- net_nfc_client_manager_activated callback,
- void *user_data)
-{
- if (callback == NULL)
- return;
-
- if (manager_proxy == NULL)
- {
- if (net_nfc_client_manager_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("manager_proxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- activated_func_data.callback = callback;
- activated_func_data.user_data = user_data;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_manager_unset_activated(void)
-{
- activated_func_data.callback = NULL;
- activated_func_data.user_data = NULL;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_manager_set_active(int state,
- net_nfc_client_manager_set_active_completed callback,
- void *user_data)
-{
- gboolean active = FALSE;
- ManagerFuncData *func_data;
-
- if (auto_start_proxy == NULL) {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_manager_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Manager",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- func_data = g_try_new0(ManagerFuncData, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- if (state == true)
- active = TRUE;
-
- net_nfc_gdbus_manager_call_set_active(auto_start_proxy,
- active,
- NULL,
- manager_call_set_active_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_manager_set_active_sync(int state)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
-
- if (auto_start_proxy == NULL) {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_manager_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Manager",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- if (net_nfc_gdbus_manager_call_set_active_sync(auto_start_proxy,
- (gboolean)state,
- &out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call SetActive: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_manager_get_server_state(
- net_nfc_client_manager_get_server_state_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (manager_proxy == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer) callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_manager_call_get_server_state(manager_proxy,
- NULL,
- manager_call_get_server_state_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_manager_get_server_state_sync(
- unsigned int *state)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- guint out_state = 0;
- GError *error = NULL;
-
- if (state == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- *state = 0;
-
- if (manager_proxy == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_manager_call_get_server_state_sync(manager_proxy,
- &out_result,
- &out_state,
- NULL,
- &error) == TRUE)
- {
- *state = out_state;
- }
- else
- {
- DEBUG_ERR_MSG("can not call GetServerState: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-
-}
-
-net_nfc_error_e net_nfc_client_manager_init(void)
-{
- GError *error = NULL;
-
- if (manager_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- manager_proxy = net_nfc_gdbus_manager_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Manager",
- NULL,
- &error);
- if (manager_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- g_signal_connect(manager_proxy, "activated",
- G_CALLBACK(manager_activated), NULL);
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_manager_deinit(void)
-{
- if (manager_proxy)
- {
- int i;
-
- for (i = 0; i < 2; i++) {
- if (timeout_id[i] > 0) {
- g_source_remove(timeout_id[i]);
- timeout_id[i] = 0;
- }
- }
-
- g_object_unref(manager_proxy);
- manager_proxy = NULL;
- }
-
- if (auto_start_proxy) {
- g_object_unref(auto_start_proxy);
- auto_start_proxy = NULL;
- }
-}
-
-/* internal function */
-bool net_nfc_client_manager_is_activated()
-{
- if (is_activated < 0) {
- net_nfc_client_get_nfc_state(&is_activated);
- }
-
- return is_activated;
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_data.h"
-#include "net_nfc_ndef_message.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_ndef.h"
-#include "net_nfc_client_tag_internal.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-static NetNfcGDbusNdef *ndef_proxy = NULL;
-
-static gboolean ndef_is_supported_tag(void);
-
-static void ndef_call_read(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void ndef_call_write(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void ndef_call_make_read_only(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void ndef_call_format(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static gboolean ndef_is_supported_tag(void)
-{
- net_nfc_target_info_s *target_info = NULL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- {
- DEBUG_ERR_MSG("target_info does not exist");
-
- return FALSE;
- }
-
- switch (target_info->devType)
- {
- case NET_NFC_ISO14443_A_PICC :
- case NET_NFC_MIFARE_MINI_PICC :
- case NET_NFC_MIFARE_1K_PICC :
- case NET_NFC_MIFARE_4K_PICC :
- case NET_NFC_MIFARE_ULTRA_PICC :
- case NET_NFC_JEWEL_PICC :
- return TRUE;
- break;
- default:
- DEBUG_CLIENT_MSG(
- "not supported tag for read only tag");
- return FALSE;
- }
-}
-
-static void ndef_call_read(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GVariant *out_data = NULL;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_ndef_call_read_finish(
- NET_NFC_GDBUS_NDEF(source_object),
- (gint *)&out_result,
- &out_data,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish read: %s", error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_ndef_read_completed callback =
- (net_nfc_client_ndef_read_completed)func_data->callback;
- ndef_message_h message;
-
- message = net_nfc_util_gdbus_variant_to_ndef_message(out_data);
-
- callback(out_result, message, func_data->user_data);
-
- net_nfc_util_free_ndef_message(message);
- }
-
- g_free(func_data);
-}
-
-static void ndef_call_write(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_ndef_call_write_finish(
- NET_NFC_GDBUS_NDEF(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish write: %s", error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_ndef_write_completed callback =
- (net_nfc_client_ndef_write_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void ndef_call_make_read_only(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_ndef_call_make_read_only_finish(
- NET_NFC_GDBUS_NDEF(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish make read only: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_ndef_make_read_only_completed callback =
- (net_nfc_client_ndef_make_read_only_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void ndef_call_format(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_ndef_call_format_finish(
- NET_NFC_GDBUS_NDEF(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish format: %s", error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_ndef_format_completed callback =
- (net_nfc_client_ndef_format_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_read(net_nfc_target_handle_h handle,
- net_nfc_client_ndef_read_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- DEBUG_CLIENT_MSG("send request :: read ndef = [%p]", handle);
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL) {
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_ndef_call_read(ndef_proxy,
- GPOINTER_TO_UINT(handle),
- NULL,
- ndef_call_read,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_read_sync(net_nfc_target_handle_h handle,
- ndef_message_h *message)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GVariant *out_data = NULL;
- GError *error = NULL;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- DEBUG_CLIENT_MSG("send request :: read ndef = [%p]", handle);
-
- if (net_nfc_gdbus_ndef_call_read_sync(ndef_proxy,
- GPOINTER_TO_UINT(handle),
- (gint *)&out_result,
- &out_data,
- NULL,
- &error) == TRUE) {
- *message = net_nfc_util_gdbus_variant_to_ndef_message(out_data);
- } else {
- DEBUG_ERR_MSG("can not call read: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_write(net_nfc_target_handle_h handle,
- ndef_message_h message,
- net_nfc_client_ndef_write_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
- GVariant *arg_data;
-
- if (handle == NULL || message == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL) {
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- arg_data = net_nfc_util_gdbus_ndef_message_to_variant(message);
-
- net_nfc_gdbus_ndef_call_write(ndef_proxy,
- GPOINTER_TO_UINT(handle),
- arg_data,
- NULL,
- ndef_call_write,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_write_sync(net_nfc_target_handle_h handle,
- ndef_message_h message)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *arg_data;
-
- if (handle == NULL || message == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- arg_data = net_nfc_util_gdbus_ndef_message_to_variant(message);
-
- if (net_nfc_gdbus_ndef_call_write_sync(ndef_proxy ,
- GPOINTER_TO_UINT(handle),
- arg_data,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call write: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_make_read_only(
- net_nfc_target_handle_h handle,
- net_nfc_client_ndef_make_read_only_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- if (ndef_is_supported_tag() == FALSE)
- return NET_NFC_NOT_SUPPORTED;
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL) {
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_ndef_call_make_read_only(ndef_proxy,
- GPOINTER_TO_UINT(handle),
- NULL,
- ndef_call_make_read_only,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_make_read_only_sync(
- net_nfc_target_handle_h handle)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- if (ndef_is_supported_tag() == FALSE)
- return NET_NFC_NOT_SUPPORTED;
-
- if (net_nfc_gdbus_ndef_call_make_read_only_sync(ndef_proxy,
- GPOINTER_TO_UINT(handle),
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not make read only: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_format(net_nfc_target_handle_h handle,
- data_h key,
- net_nfc_client_ndef_format_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
- GVariant *arg_data;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL) {
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- arg_data = net_nfc_util_gdbus_data_to_variant((data_s *)key);
-
- net_nfc_gdbus_ndef_call_format(ndef_proxy ,
- GPOINTER_TO_UINT(handle),
- arg_data,
- NULL,
- ndef_call_format,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_ndef_format_sync(
- net_nfc_target_handle_h handle,
- data_h key)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GVariant *arg_data;
- GError *error = NULL;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (ndef_proxy == NULL)
- {
- if(net_nfc_client_ndef_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- arg_data = net_nfc_util_gdbus_data_to_variant((data_s *)key);
-
- if (net_nfc_gdbus_ndef_call_format_sync(ndef_proxy ,
- GPOINTER_TO_UINT(handle),
- arg_data,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call format: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-net_nfc_error_e net_nfc_client_ndef_init(void)
-{
- GError *error = NULL;
-
- if (ndef_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- ndef_proxy = net_nfc_gdbus_ndef_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Ndef",
- NULL,
- &error);
- if (ndef_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_ndef_deinit(void)
-{
- if (ndef_proxy)
- {
- g_object_unref(ndef_proxy);
- ndef_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * 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 <linux/limits.h>
-
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_ndef_message.h"
-#include "net_nfc_data.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-
-#ifndef NET_NFC_MANAGER_DATA_PATH
-#define NET_NFC_MANAGER_DATA_PATH "/opt/usr/share/nfc-manager-daemon"
-#endif
-
-#ifndef NET_NFC_MANAGER_DATA_PATH_MESSAGE
-#define NET_NFC_MANAGER_DATA_PATH_MESSAGE "message"
-#endif
-
-#ifndef NET_NFC_MANAGER_NDEF_FILE_NAME
-#define NET_NFC_MANAGER_NDEF_FILE_NAME "ndef-message.txt"
-#endif
-
-
-/* public functions */
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_ndef_message(ndef_message_h *ndef_message)
-{
- return net_nfc_util_create_ndef_message(
- (ndef_message_s **)ndef_message);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_rawdata_from_ndef_message(
- ndef_message_h ndef_message, data_h *rawdata)
-{
- uint32_t count;
- net_nfc_error_e result;
- data_h data;
-
- if (ndef_message == NULL || rawdata == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *rawdata = NULL;
-
- result = net_nfc_get_ndef_message_byte_length(ndef_message, &count);
- if (result != NET_NFC_OK) {
- return result;
- }
-
- result = net_nfc_create_data(&data ,NULL, count);
- if (result != NET_NFC_OK) {
- return result;
- }
-
- result = net_nfc_util_convert_ndef_message_to_rawdata(
- (ndef_message_s *)ndef_message, (data_s *)data);
- if (result == NET_NFC_OK) {
- *rawdata = data;
- } else {
- net_nfc_free_data(data);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_ndef_message_from_rawdata(
- ndef_message_h *ndef_message, data_h rawdata)
-{
- net_nfc_error_e result;
- ndef_message_h msg;
-
- if (ndef_message == NULL || rawdata == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *ndef_message = NULL;
-
- result = net_nfc_create_ndef_message(&msg);
- if (result != NET_NFC_OK) {
- return result;
- }
-
- result = net_nfc_util_convert_rawdata_to_ndef_message(
- (data_s *)rawdata, (ndef_message_s *)msg);
- if (result == NET_NFC_OK) {
- *ndef_message = msg;
- } else {
- net_nfc_free_ndef_message(msg);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_ndef_message_byte_length(
- ndef_message_h ndef_message, uint32_t *length)
-{
- net_nfc_error_e result;
-
- if (ndef_message == NULL || length == NULL){
- return NET_NFC_NULL_PARAMETER;
- }
-
- *length = net_nfc_util_get_ndef_message_length(
- (ndef_message_s *)ndef_message);
- if (*length > 0) {
- result = NET_NFC_OK;
- } else {
- result = NET_NFC_INVALID_PARAM;
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_append_record_to_ndef_message(
- ndef_message_h ndef_message, ndef_record_h record)
-{
- if (ndef_message == NULL || record == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- return net_nfc_util_append_record((ndef_message_s *)ndef_message,
- (ndef_record_s *)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_free_ndef_message(ndef_message_h ndef_message)
-{
- if (ndef_message == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- return net_nfc_util_free_ndef_message((ndef_message_s *)ndef_message);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_ndef_message_record_count(
- ndef_message_h ndef_message, int *count)
-{
- ndef_message_s *msg = (ndef_message_s *)ndef_message;
-
- if (ndef_message == NULL || count == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *count = msg->recordCount;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API void net_nfc_ndef_print_message(ndef_message_h ndef_message)
-{
- net_nfc_util_print_ndef_message((ndef_message_s *)ndef_message);
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_search_record_by_type(ndef_message_h ndef_message,
- net_nfc_record_tnf_e tnf, data_h type, ndef_record_h *record)
-{
- return net_nfc_util_search_record_by_type(
- (ndef_message_s *)ndef_message, tnf,
- (data_s *)type, (ndef_record_s **)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_append_record_by_index(ndef_message_h ndef_message,
- int index, ndef_record_h record)
-{
- return net_nfc_util_append_record_by_index(
- (ndef_message_s *)ndef_message, index,
- (ndef_record_s *) record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_record_by_index(ndef_message_h ndef_message,
- int index, ndef_record_h *record)
-{
- return net_nfc_util_get_record_by_index(
- (ndef_message_s *)ndef_message, index,
- (ndef_record_s **)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_remove_record_by_index(ndef_message_h ndef_message,
- int index)
-{
- return net_nfc_util_remove_record_by_index(
- (ndef_message_s*)ndef_message, index);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_retrieve_current_ndef_message(
- ndef_message_h *ndef_message)
-{
- net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
- char file_path[PATH_MAX] = { 0, };
- FILE *fp = NULL;
-
- if (ndef_message == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- snprintf(file_path, sizeof(file_path), "%s/%s/%s",
- NET_NFC_MANAGER_DATA_PATH,
- NET_NFC_MANAGER_DATA_PATH_MESSAGE,
- NET_NFC_MANAGER_NDEF_FILE_NAME);
-
- if ((fp = fopen(file_path, "r")) != NULL)
- {
- long int size = 0;
-
- /* rewind to start of file */
- fseek(fp, 0, SEEK_END);
- size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
-
- DEBUG_CLIENT_MSG("message length = [%ld]", size);
-
- if (size > 0)
- {
- data_s data = { NULL, 0 };
-
- if (net_nfc_util_init_data(&data, size) == true)
- {
- int current;
- size_t offset = 0;
-
- /* read fully */
- do {
- current = fread(data.buffer + offset, 1,
- data.length - offset, fp);
- if (current > 0)
- offset += current;
- else
- break;
- } while (offset < data.length);
-
- if (offset == data.length) {
- result = net_nfc_create_ndef_message_from_rawdata(ndef_message, &data);
- } else {
- DEBUG_ERR_MSG("failed to read ndef message");
- }
-
- net_nfc_util_clear_data(&data);
- }
- else
- {
- result = NET_NFC_ALLOC_FAIL;
- }
- }
- else
- {
- result = NET_NFC_NO_NDEF_MESSAGE;
- }
-
- fclose(fp);
- }
- else
- {
- result = NET_NFC_NO_NDEF_MESSAGE;
- }
-
- return result;
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * 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 <glib.h>
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_handover.h"
-#include "net_nfc_ndef_message_handover.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_carrier_config(net_nfc_carrier_config_h *config,
- net_nfc_conn_handover_carrier_type_e type)
-{
- return net_nfc_util_create_carrier_config(
- (net_nfc_carrier_config_s **)config, type);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_add_carrier_config_property(
- net_nfc_carrier_config_h config, uint16_t attribute, uint16_t size,
- uint8_t * data)
-{
- return net_nfc_util_add_carrier_config_property(
- (net_nfc_carrier_config_s *)config, attribute, size, data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_remove_carrier_config_property(
- net_nfc_carrier_config_h config, uint16_t attribute)
-{
- return net_nfc_util_remove_carrier_config_property(
- (net_nfc_carrier_config_s *)config, attribute);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_carrier_config_property(
- net_nfc_carrier_config_h config, uint16_t attribute,
- uint16_t *size, uint8_t **data)
-{
- return net_nfc_util_get_carrier_config_property(
- (net_nfc_carrier_config_s *)config, attribute, size, data);
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_append_carrier_config_group(
- net_nfc_carrier_config_h config, net_nfc_property_group_h group)
-{
- return net_nfc_util_append_carrier_config_group(
- (net_nfc_carrier_config_s *)config,
- (net_nfc_carrier_property_s *)group);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_remove_carrier_config_group(
- net_nfc_carrier_config_h config, net_nfc_property_group_h group)
-{
- return net_nfc_util_remove_carrier_config_group(
- (net_nfc_carrier_config_s *)config,
- (net_nfc_carrier_property_s *)group);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_carrier_config_group(
- net_nfc_carrier_config_h config, uint16_t attribute,
- net_nfc_property_group_h *group)
-{
- return net_nfc_util_get_carrier_config_group(
- (net_nfc_carrier_config_s *)config, attribute,
- (net_nfc_carrier_property_s **)group);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_free_carrier_config(net_nfc_carrier_config_h config)
-{
- return net_nfc_util_free_carrier_config(
- (net_nfc_carrier_config_s *)config);
-}
-
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_carrier_config_group(
- net_nfc_property_group_h *group, uint16_t attribute)
-{
- return net_nfc_util_create_carrier_config_group(
- (net_nfc_carrier_property_s **)group, attribute);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_add_carrier_config_group_property(
- net_nfc_property_group_h group, uint16_t attribute, uint16_t size,
- uint8_t *data)
-{
- return net_nfc_util_add_carrier_config_group_property(
- (net_nfc_carrier_property_s *)group, attribute, size, data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_carrier_config_group_property(
- net_nfc_property_group_h group, uint16_t attribute, uint16_t *size,
- uint8_t **data)
-{
- return net_nfc_util_get_carrier_config_group_property(
- (net_nfc_carrier_property_s *)group, attribute, size, data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_remove_carrier_config_group_property(
- net_nfc_property_group_h group, uint16_t attribute)
-{
- return net_nfc_util_remove_carrier_config_group_property(
- (net_nfc_carrier_property_s *)group, attribute);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_free_carrier_group(net_nfc_property_group_h group)
-{
- return net_nfc_util_free_carrier_group(
- (net_nfc_carrier_property_s *)group);
-}
-
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_ndef_record_with_carrier_config(
- ndef_record_h *record, net_nfc_carrier_config_h config)
-{
- return net_nfc_util_create_ndef_record_with_carrier_config(
- (ndef_record_s**)record, (net_nfc_carrier_config_s *)config);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_carrier_config_from_config_record(
- net_nfc_carrier_config_h *config, ndef_record_h record)
-{
- return net_nfc_util_create_carrier_config_from_config_record(
- (net_nfc_carrier_config_s **)config, (ndef_record_s *)record);
-
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_carrier_config_from_carrier(
- net_nfc_carrier_config_h *config, net_nfc_ch_carrier_h carrier)
-{
- return net_nfc_util_create_carrier_config_from_carrier(
- (net_nfc_carrier_config_s **)config, (net_nfc_ch_carrier_s *)carrier);
-
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_handover_carrier(net_nfc_ch_carrier_h *carrier,
- net_nfc_conn_handover_carrier_state_e cps)
-{
- return net_nfc_util_create_handover_carrier(
- (net_nfc_ch_carrier_s **)carrier, cps);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_duplicate_handover_carrier(net_nfc_ch_carrier_h *dest,
- net_nfc_ch_carrier_h src)
-{
- return net_nfc_util_duplicate_handover_carrier(
- (net_nfc_ch_carrier_s **)dest,
- (net_nfc_ch_carrier_s *)src);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_free_handover_carrier(net_nfc_ch_carrier_h carrier)
-{
- return net_nfc_util_free_handover_carrier(
- (net_nfc_ch_carrier_s *)carrier);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_set_handover_carrier_cps(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_state_e cps)
-{
- return net_nfc_util_set_handover_carrier_cps(
- (net_nfc_ch_carrier_s *)carrier, cps);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_carrier_cps(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_state_e *cps)
-{
- return net_nfc_util_get_handover_carrier_cps(
- (net_nfc_ch_carrier_s *)carrier, cps);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_set_handover_carrier_type(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_type_e type)
-{
- return net_nfc_util_set_handover_carrier_type(
- (net_nfc_ch_carrier_s *)carrier, type);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_carrier_type(
- net_nfc_ch_carrier_h carrier,
- net_nfc_conn_handover_carrier_type_e *type)
-{
- return net_nfc_util_get_handover_carrier_type(
- (net_nfc_ch_carrier_s *)carrier, type);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_append_handover_carrier_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h record)
-{
- return net_nfc_util_append_handover_carrier_record(
- (net_nfc_ch_carrier_s *)carrier, (ndef_record_s *)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_carrier_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h *record)
-{
- return net_nfc_util_get_handover_carrier_record(
- (net_nfc_ch_carrier_s *)carrier, (ndef_record_s **)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_remove_handover_carrier_record(
- net_nfc_ch_carrier_h carrier)
-{
- return net_nfc_util_remove_handover_carrier_record(
- (net_nfc_ch_carrier_s *)carrier);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_append_handover_auxiliary_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h record)
-{
- return net_nfc_util_append_handover_auxiliary_record(
- (net_nfc_ch_carrier_s *)carrier, (ndef_record_s *)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_auxiliary_record_count(
- net_nfc_ch_carrier_h carrier, uint32_t *count)
-{
- return net_nfc_util_get_handover_auxiliary_record_count(
- (net_nfc_ch_carrier_s *)carrier, count);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_auxiliary_record(
- net_nfc_ch_carrier_h carrier, int index, ndef_record_h *record)
-{
- return net_nfc_util_get_handover_auxiliary_record(
- (net_nfc_ch_carrier_s *)carrier, index, (ndef_record_s **)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_remove_handover_auxiliary_record(
- net_nfc_ch_carrier_h carrier, ndef_record_h record)
-{
- return net_nfc_util_remove_handover_auxiliary_record(
- (net_nfc_ch_carrier_s *)carrier, (ndef_record_s *)record);
-}
-
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_handover_message(
- net_nfc_ch_message_h *message)
-{
- return net_nfc_util_create_handover_message(
- (net_nfc_ch_message_s **)message);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_free_handover_message(
- net_nfc_ch_message_h message)
-{
- return net_nfc_util_free_handover_message(
- (net_nfc_ch_message_s *)message);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_random_number(
- net_nfc_ch_message_h message, uint16_t *random_number)
-{
- return net_nfc_util_get_handover_random_number(
- (net_nfc_ch_message_s *)message, random_number);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_append_handover_carrier(
- net_nfc_ch_message_h message, net_nfc_ch_carrier_h carrier)
-{
- return net_nfc_util_append_handover_carrier(
- (net_nfc_ch_message_s *)message,
- (net_nfc_ch_carrier_s *)carrier);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_carrier_count(
- net_nfc_ch_message_h message, uint32_t *count)
-{
- return net_nfc_util_get_handover_carrier_count(
- (net_nfc_ch_message_s *)message, count);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_carrier(
- net_nfc_ch_message_h message, int index,
- net_nfc_ch_carrier_h *carrier)
-{
- return net_nfc_util_get_handover_carrier(
- (net_nfc_ch_message_s *)message, index,
- (net_nfc_ch_carrier_s **)carrier);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_handover_carrier_by_type(
- net_nfc_ch_message_h message,
- net_nfc_conn_handover_carrier_type_e type,
- net_nfc_ch_carrier_h *carrier)
-{
- return net_nfc_util_get_handover_carrier_by_type(
- (net_nfc_ch_message_s *)message, type,
- (net_nfc_ch_carrier_s **)carrier);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_export_handover_to_ndef_message(
- net_nfc_ch_message_h message, ndef_message_h *result)
-{
- return net_nfc_util_export_handover_to_ndef_message(
- (net_nfc_ch_message_s *)message, (ndef_message_s **)result);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_import_handover_from_ndef_message(
- ndef_message_h msg, net_nfc_ch_message_h *result)
-{
- return net_nfc_util_import_handover_from_ndef_message(
- (ndef_message_s *)msg, (net_nfc_ch_message_s **)result);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_handover_error_record(ndef_record_h *record, uint8_t reason, uint32_t data)
-{
- return net_nfc_util_create_handover_error_record((ndef_record_s **)record, reason, data);
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_ndef_record.h"
-#include "net_nfc_ndef_message.h"
-#include "net_nfc_data.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_record.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_record(ndef_record_h *record,
- net_nfc_record_tnf_e tnf, data_h typeName, data_h id, data_h payload)
-{
- return net_nfc_util_create_record(tnf, (data_s *)typeName,
- (data_s *)id, (data_s *)payload, (ndef_record_s **)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_text_type_record(ndef_record_h *record,
- const char *text, const char *language_code_str,
- net_nfc_encode_type_e encode)
-{
- return net_nfc_util_create_text_type_record(text, language_code_str,
- encode, (ndef_record_s **)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_uri_type_record(ndef_record_h *record,
- const char *uri, net_nfc_schema_type_e protocol_schema)
-{
- return net_nfc_util_create_uri_type_record(uri, protocol_schema,
- (ndef_record_s **)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_free_record(ndef_record_h record)
-{
- return net_nfc_util_free_record((ndef_record_s *)record);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_record_payload(ndef_record_h record,
- data_h *payload)
-{
- ndef_record_s *struct_record = (ndef_record_s *)record;
-
- if (record == NULL || payload == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *payload = (data_h)&(struct_record->payload_s);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_record_type(ndef_record_h record, data_h *type)
-{
- ndef_record_s *struct_record = (ndef_record_s *)record;
-
- if (record == NULL || type == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *type = (data_h)&(struct_record->type_s);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_record_id(ndef_record_h record, data_h *id)
-{
- ndef_record_s *struct_record = (ndef_record_s *)record;
-
- if (record == NULL || id == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *id = (data_h)&(struct_record->id_s);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_record_tnf(ndef_record_h record,
- net_nfc_record_tnf_e *TNF)
-{
- ndef_record_s *struct_record = (ndef_record_s *)record;
-
- if (record == NULL || TNF == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *TNF = (net_nfc_record_tnf_e)struct_record->TNF;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_set_record_id(ndef_record_h record, data_h id)
-{
- data_s *tmp_id = (data_s *)id;
-
- if (record == NULL || tmp_id == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- return net_nfc_util_set_record_id((ndef_record_s *)record,
- tmp_id->buffer, tmp_id->length);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_record_flags(ndef_record_h record, uint8_t *flag)
-{
- ndef_record_s *struct_record = (ndef_record_s *)record;
-
- if (record == NULL || flag == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *flag = struct_record->MB;
- *flag <<= 1;
- *flag += struct_record->ME;
- *flag <<= 1;
- *flag += struct_record->CF;
- *flag <<= 1;
- *flag += struct_record->SR;
- *flag <<= 1;
- *flag += struct_record->IL;
- *flag <<= 3;
- *flag += struct_record->TNF;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API uint8_t net_nfc_get_record_mb(uint8_t flag)
-{
- return ((flag >> 7) & 0x01);
-}
-
-NET_NFC_EXPORT_API uint8_t net_nfc_get_record_me(uint8_t flag)
-{
- return ((flag >> 6) & 0x01);
-}
-
-NET_NFC_EXPORT_API uint8_t net_nfc_get_record_cf(uint8_t flag)
-{
- return ((flag >> 5) & 0x01);
-}
-
-NET_NFC_EXPORT_API uint8_t net_nfc_get_record_sr(uint8_t flag)
-{
- return ((flag >> 4) & 0x01);
-}
-
-NET_NFC_EXPORT_API uint8_t net_nfc_get_record_il(uint8_t flag)
-{
- return ((flag >> 3) & 0x01);
-}
-
-static bool _is_text_record(ndef_record_h record)
-{
- bool result = false;
- data_h type;
-
- if ((net_nfc_get_record_type(record, &type) == NET_NFC_OK) &&
- (strncmp((char *)net_nfc_get_data_buffer(type),
- TEXT_RECORD_TYPE,
- net_nfc_get_data_length(type)) == 0))
- result = true;
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_text_string_from_text_record(
- ndef_record_h record, char **buffer)
-{
- net_nfc_error_e result;
- data_h payload;
-
- if (record == NULL || buffer == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *buffer = NULL;
-
- if (_is_text_record(record) == false)
- {
- DEBUG_ERR_MSG("record type is not matched");
-
- return NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE;
- }
-
- result = net_nfc_get_record_payload(record, &payload);
- if (result == NET_NFC_OK)
- {
- uint8_t *buffer_temp = net_nfc_get_data_buffer(payload);
- uint32_t buffer_length = net_nfc_get_data_length(payload);
-
- int controllbyte = buffer_temp[0];
- int lang_code_length = controllbyte & 0x3F;
- int index = lang_code_length + 1;
- int text_length = buffer_length - (lang_code_length + 1);
-
- char *temp = NULL;
-
- _net_nfc_util_alloc_mem(temp, text_length + 1);
- if (temp != NULL)
- {
- memcpy(temp, &(buffer_temp[index]), text_length);
-
- DEBUG_CLIENT_MSG("text = [%s]", temp);
-
- *buffer = temp;
- }
- else
- {
- result = NET_NFC_ALLOC_FAIL;
- }
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_languange_code_string_from_text_record(
- ndef_record_h record, char **lang_code_str)
-{
- net_nfc_error_e result;
- data_h payload;
-
- if (record == NULL || lang_code_str == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *lang_code_str = NULL;
-
- if (_is_text_record(record) == false)
- {
- DEBUG_ERR_MSG("record type is not matched");
-
- return NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE;
- }
-
- result = net_nfc_get_record_payload(record, &payload);
- if (result == NET_NFC_OK)
- {
- uint8_t *buffer_temp = net_nfc_get_data_buffer(payload);
- char *buffer = NULL;
-
- int controllbyte = buffer_temp[0];
- int lang_code_length = controllbyte & 0x3F;
- int index = 1;
-
- _net_nfc_util_alloc_mem(buffer, lang_code_length + 1);
- if (buffer != NULL)
- {
- memcpy(buffer, &(buffer_temp[index]), lang_code_length);
-
- DEBUG_CLIENT_MSG("language code = [%s]", buffer);
-
- *lang_code_str = buffer;
- }
- else
- {
- result = NET_NFC_ALLOC_FAIL;
- }
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_encoding_type_from_text_record(ndef_record_h record,
- net_nfc_encode_type_e *encoding)
-{
- net_nfc_error_e result;
- data_h payload;
-
- if (record == NULL || encoding == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *encoding = NET_NFC_ENCODE_UTF_8;
-
- if (_is_text_record(record) == false)
- {
- DEBUG_ERR_MSG("record type is not matched");
-
- return NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE;
- }
-
- result = net_nfc_get_record_payload(record, &payload);
- if (result == NET_NFC_OK)
- {
- uint8_t *buffer_temp = net_nfc_get_data_buffer(payload);
-
- int controllbyte = buffer_temp[0];
-
- if ((controllbyte & 0x80) == 0x80)
- {
- *encoding = NET_NFC_ENCODE_UTF_16;
- }
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_create_uri_string_from_uri_record(ndef_record_h record,
- char **uri)
-{
- return net_nfc_util_create_uri_string_from_uri_record(
- (ndef_record_s *)record, uri);
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_p2p.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-typedef struct _P2p_SignalHandler P2pSignalHandler;
-
-struct _P2p_SignalHandler
-{
- net_nfc_client_p2p_device_discovered p2p_device_discovered_cb;
- net_nfc_client_p2p_device_detached p2p_device_detached_cb;
- net_nfc_client_p2p_data_received p2p_data_received_cb;
-
- gpointer p2p_device_discovered_data;
- gpointer p2p_device_detached_data;
- gpointer p2p_data_received_data;
-};
-
-static NetNfcGDbusP2p *p2p_proxy = NULL;
-static P2pSignalHandler p2p_signal_handler;
-
-static void p2p_device_detached(GObject *source_object,
- gpointer user_data);
-
-static void p2p_device_discovered(GObject *source_object,
- guint arg_handle,
- gpointer user_data);
-
-static void p2p_device_data_received(GObject *source_object,
- GVariant *arg_data,
- gpointer user_data);
-
-static void p2p_call_send(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void p2p_device_detached(GObject *source_object,
- gpointer user_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- /*llcp client function to set/unset the current target id needs to be implemented*/
- /*net_nfc_client_llcp_current_target_id(NULL);*/
-
- if (p2p_signal_handler.p2p_device_detached_cb)
- {
- p2p_signal_handler.p2p_device_detached_cb(
- p2p_signal_handler.p2p_device_detached_data);
- }
-
- /*llcp client function to close all socket needs to be implemented*/
- /*net_nfc_client_llcp_close_all_socket();*/
-}
-
-static void p2p_device_discovered(GObject *source_object,
- guint arg_handle,
- gpointer user_data)
-{
- net_nfc_target_handle_s *handle_info = NULL;
-
- INFO_MSG(">>> SIGNAL arrived");
-
- handle_info = GUINT_TO_POINTER(arg_handle);
-
- if (p2p_signal_handler.p2p_device_discovered_cb)
- {
- p2p_signal_handler.p2p_device_discovered_cb(handle_info,
- p2p_signal_handler.p2p_device_discovered_data);
- }
-}
-
-static void p2p_device_data_received(GObject *source_object,
- GVariant *arg_data,
- gpointer user_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- if (p2p_signal_handler.p2p_data_received_cb)
- {
- data_s p2p_data = { NULL, };
-
- net_nfc_util_gdbus_variant_to_data_s(arg_data, &p2p_data);
-
- p2p_signal_handler.p2p_data_received_cb(&p2p_data,
- p2p_signal_handler.p2p_data_received_data);
-
- net_nfc_util_clear_data(&p2p_data);
- }
-}
-
-static void p2p_call_send(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_p2p_call_send_finish(
- NET_NFC_GDBUS_P2P(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish p2p send: %s", error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_p2p_send_completed callback =
- (net_nfc_client_p2p_send_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_p2p_send(net_nfc_target_handle_h handle,
- data_h data,
- net_nfc_client_p2p_send_completed callback,
- void *user_data)
-{
- GVariant *arg_data;
- NetNfcCallback *func_data;
-
- if (p2p_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get P2pProxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL) {
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- arg_data = net_nfc_util_gdbus_data_to_variant(data);
-
- net_nfc_gdbus_p2p_call_send(p2p_proxy,
- 0 /* FIXME */,
- arg_data,
- GPOINTER_TO_UINT(handle),
- NULL,
- p2p_call_send,
- func_data);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_p2p_send_sync(net_nfc_target_handle_h handle,
- data_h data)
-{
- GVariant *arg_data;
- GError *error = NULL;
-
- net_nfc_error_e out_result;
-
- if (p2p_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get P2pProxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- arg_data = net_nfc_util_gdbus_data_to_variant(data);
-
- if (net_nfc_gdbus_p2p_call_send_sync(p2p_proxy,
- 0 /* FIXME */,
- arg_data,
- GPOINTER_TO_UINT(handle),
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("p2p send (sync call) failed: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_p2p_set_device_discovered(
- net_nfc_client_p2p_device_discovered callback,
- void *user_data)
-{
- if (callback == NULL)
- return;
-
- if (p2p_proxy == NULL)
- {
- if (net_nfc_client_p2p_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("P2pProxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- p2p_signal_handler.p2p_device_discovered_cb = callback;
- p2p_signal_handler.p2p_device_discovered_data = user_data;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_p2p_set_device_detached(
- net_nfc_client_p2p_device_detached callback,
- void *user_data)
-{
- if (callback == NULL)
- return;
-
- if (p2p_proxy == NULL)
- {
- if (net_nfc_client_p2p_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("P2pProxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- p2p_signal_handler.p2p_device_detached_cb = callback;
- p2p_signal_handler.p2p_device_detached_data = user_data;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_p2p_set_data_received(
- net_nfc_client_p2p_data_received callback,
- void *user_data)
-{
- if (callback == NULL)
- return;
-
- if (p2p_proxy == NULL)
- {
- if (net_nfc_client_p2p_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("P2pProxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- p2p_signal_handler.p2p_data_received_cb = callback;
- p2p_signal_handler.p2p_data_received_data = user_data;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_p2p_unset_device_discovered(void)
-{
- p2p_signal_handler.p2p_device_discovered_cb = NULL;
- p2p_signal_handler.p2p_device_discovered_data = NULL;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_p2p_unset_device_detached(void)
-{
- p2p_signal_handler.p2p_device_detached_cb = NULL;
- p2p_signal_handler.p2p_device_detached_data = NULL;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_p2p_unset_data_received(void)
-{
- p2p_signal_handler.p2p_data_received_cb = NULL;
- p2p_signal_handler.p2p_data_received_data = NULL;
-}
-
-net_nfc_error_e net_nfc_client_p2p_init(void)
-{
- GError *error = NULL;
-
- if (p2p_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- p2p_proxy = net_nfc_gdbus_p2p_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/P2p",
- NULL,
- &error);
- if (p2p_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- /* FIXME : set timeout to infinite */
- g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(p2p_proxy), G_MAXINT32);
-
- g_signal_connect(p2p_proxy, "detached",
- G_CALLBACK(p2p_device_detached), NULL);
-
- g_signal_connect(p2p_proxy, "discovered",
- G_CALLBACK(p2p_device_discovered), NULL);
-
- g_signal_connect(p2p_proxy, "received",
- G_CALLBACK(p2p_device_data_received), NULL);
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_p2p_deinit(void)
-{
- if (p2p_proxy)
- {
- g_object_unref(p2p_proxy);
- p2p_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "vconf.h"
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_se.h"
-
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-typedef struct _SeFuncData SeFuncData;
-
-struct _SeFuncData
-{
- gpointer se_callback;
- gpointer se_data;
-};
-
-typedef struct _SeEventHandler SeEventHandler;
-
-struct _SeEventHandler
-{
- net_nfc_client_se_event se_event_cb;
- gpointer se_event_data;
-};
-
-typedef struct _SeTransEventHandler SeTransEventHandler;
-
-struct _SeTransEventHandler
-{
- net_nfc_client_se_transaction_event transaction_event_cb;
- gpointer transaction_event_data;
-};
-
-typedef struct _SeESEDetectedHandler SeESEDetectedHandler;
-
-struct _SeESEDetectedHandler
-{
- net_nfc_client_se_ese_detected_event se_ese_detected_cb;
- gpointer se_ese_detected_data;
-};
-
-
-static NetNfcGDbusSecureElement *se_proxy = NULL;
-static NetNfcGDbusSecureElement *auto_start_proxy = NULL;
-
-static SeEventHandler se_eventhandler;
-static SeTransEventHandler uicc_transactionEventHandler;
-static SeTransEventHandler ese_transactionEventHandler;
-static SeESEDetectedHandler se_esedetecthandler;
-
-static void se_ese_detected(GObject *source_object,
- guint arg_handle,
- gint arg_se_type,
- GVariant *arg_data);
-
-static void se_type_changed(GObject *source_object,
- gint arg_se_type);
-
-static void set_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void open_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void close_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void send_apdu_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void get_atr_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void se_rf_detected(GObject *source_object,
- gint arg_se_type,
- GVariant *arg_data);
-
-
-static void se_ese_detected(GObject *source_object,
- guint arg_handle,
- gint arg_se_type,
- GVariant *arg_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- if (se_esedetecthandler.se_ese_detected_cb != NULL) {
- data_s buffer_data = { NULL, 0 };
- net_nfc_client_se_ese_detected_event callback =
- (net_nfc_client_se_ese_detected_event)se_esedetecthandler.se_ese_detected_cb;
-
- net_nfc_util_gdbus_variant_to_data_s(arg_data, &buffer_data);
-
- callback((net_nfc_target_handle_h)arg_handle,
- arg_se_type, &buffer_data,
- se_esedetecthandler.se_ese_detected_data);
-
- net_nfc_util_clear_data(&buffer_data);
- }
-}
-
-static void se_rf_detected(GObject *source_object,
- gint arg_se_type,
- GVariant *arg_data)
-{
-
- INFO_MSG(">>> SIGNAL arrived");
-
- if (se_eventhandler.se_event_cb != NULL)
- {
- net_nfc_client_se_event callback =
- (net_nfc_client_se_event)se_eventhandler.se_event_cb;
-
- callback((net_nfc_message_e)NET_NFC_MESSAGE_SE_FIELD_ON,
- se_eventhandler.se_event_data);
- }
-}
-
-
-static void se_type_changed(GObject *source_object,
- gint arg_se_type)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- if (se_eventhandler.se_event_cb != NULL)
- {
- net_nfc_client_se_event callback =
- (net_nfc_client_se_event)se_eventhandler.se_event_cb;
-
- callback((net_nfc_message_e)NET_NFC_MESSAGE_SE_TYPE_CHANGED,
- se_eventhandler.se_event_data);
- }
-}
-
-
-static void se_transaction_event(GObject *source_object,
- gint arg_se_type,
- GVariant *arg_aid,
- GVariant *arg_param,
- gint fg_dispatch,
- gint focus_app_pid)
-{
- void *user_data = NULL;
- net_nfc_client_se_transaction_event callback = NULL;
- pid_t mypid = getpid();
-
- INFO_MSG(">>> SIGNAL arrived");
-
- if (fg_dispatch == true && focus_app_pid != getpgid(mypid)) {
- SECURE_MSG("skip transaction event, fg_dispatch [%d], focus_app_pid [%d]", fg_dispatch, focus_app_pid);
- return;
- }
-#ifdef CHECK_NFC_ACCESS_FOR_ESE
- if (net_nfc_gdbus_secure_element_call_check_transaction_permission_sync(
- NET_NFC_GDBUS_SECURE_ELEMENT(source_object),
- arg_aid,
- &result,
- NULL,
- &error) == false) {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_check_transaction_permission_sync failed : %s", error->message);
- g_error_free(error);
- return;
- }
-
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("not allowed process [%d]", result);
- return;
- }
-#endif
- switch (arg_se_type)
- {
- case NET_NFC_SE_TYPE_UICC :
- if (uicc_transactionEventHandler.transaction_event_cb != NULL)
- {
- callback = uicc_transactionEventHandler.transaction_event_cb;
- user_data = uicc_transactionEventHandler.transaction_event_data;
- }
- break;
-
- case NET_NFC_SE_TYPE_ESE :
- if (ese_transactionEventHandler.transaction_event_cb != NULL)
- {
- callback = ese_transactionEventHandler.transaction_event_cb;
- user_data = ese_transactionEventHandler.transaction_event_data;
- }
- break;
-
- default :
- DEBUG_ERR_MSG("Transaction event SE type wrong [%d]", arg_se_type);
- break;
- }
-
- if (callback != NULL) {
- data_s aid = { NULL, 0 };
- data_s param = { NULL, 0 };
-
- net_nfc_util_gdbus_variant_to_data_s(arg_aid, &aid);
- net_nfc_util_gdbus_variant_to_data_s(arg_param, ¶m);
-
- callback(arg_se_type, &aid, ¶m, user_data);
-
- net_nfc_util_clear_data(¶m);
- net_nfc_util_clear_data(&aid);
- }
-}
-
-static void se_card_emulation_mode_changed(GObject *source_object,
- gint arg_se_type)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- if (se_eventhandler.se_event_cb != NULL)
- {
- net_nfc_client_se_event callback =
- (net_nfc_client_se_event)se_eventhandler.se_event_cb;
-
- callback((net_nfc_message_e)NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED,
- se_eventhandler.se_event_data);
- }
-}
-
-static void set_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- SeFuncData *func_data = (SeFuncData *)user_data;
- net_nfc_error_e result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_secure_element_call_set_finish(se_proxy,
- &result,
- res,
- &error) == FALSE)
- {
-
- DEBUG_ERR_MSG("Could not set secure element: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->se_callback != NULL)
- {
- net_nfc_se_set_se_cb se_callback =
- (net_nfc_se_set_se_cb)func_data->se_callback;
-
- se_callback(result, func_data->se_data);
- }
-
- g_free(func_data);
-}
-
-static void open_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- SeFuncData *func_data = (SeFuncData *)user_data;
- net_nfc_error_e result;
- guint out_handle = 0;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_secure_element_call_open_secure_element_finish(
- auto_start_proxy,
- &result,
- &out_handle,
- res,
- &error) == FALSE)
- {
-
- DEBUG_ERR_MSG("Could not open secure element: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->se_callback != NULL)
- {
- net_nfc_se_open_se_cb se_callback =
- (net_nfc_se_open_se_cb)func_data->se_callback;
-
- se_callback(result,
- (net_nfc_target_handle_h)out_handle,
- func_data->se_data);
- }
-
- g_free(func_data);
-}
-
-
-static void close_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- SeFuncData *func_data = (SeFuncData *)user_data;
- net_nfc_error_e result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_secure_element_call_close_secure_element_finish(
- se_proxy,
- &result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Could not close secure element: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->se_callback != NULL)
- {
- net_nfc_se_close_se_cb se_callback =
- (net_nfc_se_close_se_cb)func_data->se_callback;
-
- se_callback(result, func_data->se_data);
- }
-
- g_free(func_data);
-}
-
-
-static void send_apdu_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- SeFuncData *func_data = (SeFuncData *)user_data;
- net_nfc_error_e result;
- GVariant *out_response = NULL;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_secure_element_call_send_apdu_finish(
- se_proxy,
- &result,
- &out_response,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Could not send apdu: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->se_callback != NULL)
- {
- net_nfc_se_send_apdu_cb se_callback =
- (net_nfc_se_send_apdu_cb)func_data->se_callback;
- data_s data = { NULL, };
-
- net_nfc_util_gdbus_variant_to_data_s(out_response, &data);
-
- se_callback(result, &data, func_data->se_data);
-
- net_nfc_util_clear_data(&data);
- }
-
- g_free(func_data);
-}
-
-
-static void get_atr_secure_element(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- SeFuncData *func_data = (SeFuncData *)user_data;
- net_nfc_error_e result;
- GVariant *out_atr = NULL;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_secure_element_call_get_atr_finish(
- se_proxy,
- &result,
- &out_atr,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Could not get atr: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->se_callback != NULL)
- {
- net_nfc_se_get_atr_cb se_callback =
- (net_nfc_se_get_atr_cb)func_data->se_callback;
- data_s data = { NULL, };
-
- net_nfc_util_gdbus_variant_to_data_s(out_atr, &data);
-
- se_callback(result, &data, func_data->se_data);
-
- net_nfc_util_clear_data(&data);
- }
-
- g_free(func_data);
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_set_secure_element_type(
- net_nfc_se_type_e se_type,
- net_nfc_se_set_se_cb callback,
- void *user_data)
-{
- SeFuncData *func_data;
-
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- /* FIXME : return result of this error */
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(SeFuncData, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->se_callback = (gpointer)callback;
- func_data->se_data = user_data;
-
- net_nfc_gdbus_secure_element_call_set(
- se_proxy,
- (gint)se_type,
- NULL,
- set_secure_element,
- func_data);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_set_secure_element_type_sync(
- net_nfc_se_type_e se_type)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_secure_element_call_set_sync(
- se_proxy,
- (gint)se_type,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Set secure element failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_get_secure_element_type_sync(
- net_nfc_se_type_e *se_type)
-{
- net_nfc_error_e result = NET_NFC_OK;
- gint type;
-#if 1
- GError *error = NULL;
-#endif
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-#if 0
- if (vconf_get_int(VCONFKEY_NFC_SE_TYPE, &type) == 0) {
- *se_type = type;
- } else {
- result = NET_NFC_OPERATION_FAIL;
- }
-#else
- if (net_nfc_gdbus_secure_element_call_get_sync(
- se_proxy,
- &result,
- &type,
- NULL,
- &error) == true) {
-
- SECURE_MSG("type [%d]", type);
- *se_type = type;
- } else {
- DEBUG_ERR_MSG("get secure element failed: %s", error->message);
-
- g_error_free(error);
-
- result = NET_NFC_IPC_FAIL;
- }
-#endif
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_set_card_emulation_mode_sync(
- net_nfc_card_emulation_mode_t mode)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_secure_element_call_set_card_emulation_sync(
- se_proxy,
- (gint)mode,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Set card emulation failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_card_emulation_mode_sync(
- net_nfc_card_emulation_mode_t *se_type)
-{
- net_nfc_error_e result = NET_NFC_OK;
- gint type;
- GError *error = NULL;
-
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_secure_element_call_get_card_emulation_sync(
- se_proxy,
- &result,
- &type,
- NULL,
- &error) == true) {
- *se_type = type;
- } else {
- DEBUG_ERR_MSG("get secure element failed: %s", error->message);
-
- g_error_free(error);
-
- result = NET_NFC_IPC_FAIL;
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_open_internal_secure_element(
- net_nfc_se_type_e se_type,
- net_nfc_se_open_se_cb callback,
- void *user_data)
-{
- SeFuncData *func_data;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- func_data = g_try_new0(SeFuncData, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->se_callback = (gpointer)callback;
- func_data->se_data = user_data;
-
- net_nfc_gdbus_secure_element_call_open_secure_element(
- auto_start_proxy,
- (gint)se_type,
- NULL,
- open_secure_element,
- func_data);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_open_internal_secure_element_sync(
- net_nfc_se_type_e se_type,
- net_nfc_target_handle_h *handle)
-{
- net_nfc_error_e result = NET_NFC_OK;
- guint out_handle = 0;
- GError *error = NULL;
-
- if (handle == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- if (net_nfc_gdbus_secure_element_call_open_secure_element_sync(
- auto_start_proxy,
- se_type,
- &result,
- &out_handle,
- NULL,
- &error) == true) {
- *handle = GUINT_TO_POINTER(out_handle);
- } else {
- DEBUG_ERR_MSG("Open internal secure element failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_close_internal_secure_element(
- net_nfc_target_handle_h handle,
- net_nfc_se_close_se_cb callback,
- void *user_data)
-{
- SeFuncData *func_data;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- func_data = g_try_new0(SeFuncData, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->se_callback = (gpointer)callback;
- func_data->se_data = user_data;
-
- net_nfc_gdbus_secure_element_call_close_secure_element(
- auto_start_proxy,
- GPOINTER_TO_UINT(handle),
- NULL,
- close_secure_element,
- func_data);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_close_internal_secure_element_sync(
- net_nfc_target_handle_h handle)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- if (net_nfc_gdbus_secure_element_call_close_secure_element_sync(
- auto_start_proxy,
- GPOINTER_TO_UINT(handle),
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("close internal secure element failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_get_atr(
- net_nfc_target_handle_h handle,
- net_nfc_se_get_atr_cb callback,
- void *user_data)
-{
- SeFuncData *func_data;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- func_data = g_try_new0(SeFuncData, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->se_callback = (gpointer)callback;
- func_data->se_data = user_data;
-
- net_nfc_gdbus_secure_element_call_get_atr(
- auto_start_proxy,
- GPOINTER_TO_UINT(handle),
- NULL,
- get_atr_secure_element,
- func_data);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_get_atr_sync(
- net_nfc_target_handle_h handle,
- data_h *atr)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GVariant *out_atr = NULL;
- GError *error = NULL;
-
- if (atr == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *atr = NULL;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- if (net_nfc_gdbus_secure_element_call_get_atr_sync(
- auto_start_proxy,
- GPOINTER_TO_UINT(handle),
- &result,
- &out_atr,
- NULL,
- &error) == true) {
- *atr = net_nfc_util_gdbus_variant_to_data(out_atr);
- } else {
- DEBUG_ERR_MSG("Get attributes failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_send_apdu(
- net_nfc_target_handle_h handle,
- data_h apdu_data,
- net_nfc_se_send_apdu_cb callback,
- void *user_data)
-{
- SeFuncData *func_data;
- GVariant *arg_data;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- arg_data = net_nfc_util_gdbus_data_to_variant((data_s *)apdu_data);
- if (arg_data == NULL)
- return NET_NFC_INVALID_PARAM;
-
- func_data = g_try_new0(SeFuncData, 1);
- if (func_data == NULL) {
- g_variant_unref(arg_data);
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->se_callback = (gpointer)callback;
- func_data->se_data = user_data;
-
- net_nfc_gdbus_secure_element_call_send_apdu(
- auto_start_proxy,
- GPOINTER_TO_UINT(handle),
- arg_data,
- NULL,
- send_apdu_secure_element,
- func_data);
-
- return NET_NFC_OK;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_send_apdu_sync(
- net_nfc_target_handle_h handle,
- data_h apdu_data,
- data_h *response)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GVariant *out_data = NULL;
- GError *error = NULL;
- GVariant *arg_data;
-
- if (response == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *response = NULL;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- /* allow this function even nfc is off */
-
- arg_data = net_nfc_util_gdbus_data_to_variant((data_s *)apdu_data);
- if (arg_data == NULL)
- return NET_NFC_INVALID_PARAM;
-
- if (net_nfc_gdbus_secure_element_call_send_apdu_sync(
- auto_start_proxy,
- GPOINTER_TO_UINT(handle),
- arg_data,
- &result,
- &out_data,
- NULL,
- &error) == true) {
- *response = net_nfc_util_gdbus_variant_to_data(out_data);
- } else {
- DEBUG_ERR_MSG("Send APDU failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_se_set_ese_detection_cb(
- net_nfc_client_se_ese_detected_event callback,
- void *user_data)
-{
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- se_esedetecthandler.se_ese_detected_cb = callback;
- se_esedetecthandler.se_ese_detected_data = user_data;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_se_unset_ese_detection_cb(void)
-{
- se_esedetecthandler.se_ese_detected_cb = NULL;
- se_esedetecthandler.se_ese_detected_data = NULL;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_se_set_transaction_event_cb(
- net_nfc_se_type_e se_type,
- net_nfc_client_se_transaction_event callback,
- void *user_data)
-{
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- if (se_type == NET_NFC_SE_TYPE_ESE)
- {
- ese_transactionEventHandler.transaction_event_cb = callback;
- ese_transactionEventHandler.transaction_event_data = user_data;
- }
- else if (se_type == NET_NFC_SE_TYPE_UICC)
- {
- uicc_transactionEventHandler.transaction_event_cb = callback;
- uicc_transactionEventHandler.transaction_event_data = user_data;
- }
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_se_unset_transaction_event_cb(net_nfc_se_type_e type)
-{
- if (type == NET_NFC_SE_TYPE_ESE)
- {
- ese_transactionEventHandler.transaction_event_cb = NULL;
- ese_transactionEventHandler.transaction_event_data = NULL;
- }
- else if (type == NET_NFC_SE_TYPE_UICC)
- {
- uicc_transactionEventHandler.transaction_event_cb = NULL;
- uicc_transactionEventHandler.transaction_event_data = NULL;
- }
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_se_set_event_cb(net_nfc_client_se_event callback,
- void *user_data)
-{
- if (se_proxy == NULL)
- {
- if (net_nfc_client_se_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("se_proxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- se_eventhandler.se_event_cb = callback;
- se_eventhandler.se_event_data = user_data;
-}
-
-
-NET_NFC_EXPORT_API
-void net_nfc_client_se_unset_event_cb(void)
-{
- se_eventhandler.se_event_cb = NULL;
- se_eventhandler.se_event_data = NULL;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_set_transaction_fg_dispatch(int mode)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_set_transaction_fg_dispatch_sync(
- auto_start_proxy,
- mode,
- &result,
- NULL,
- &error) != true) {
-
- DEBUG_ERR_MSG("set transaction fg dispatch failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_set_default_route_sync(
- net_nfc_se_type_e switch_on,
- net_nfc_se_type_e switch_off,
- net_nfc_se_type_e battery_off)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL)
- {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_set_default_route_sync(
- se_proxy,
- switch_on,
- switch_off,
- battery_off,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Set Route Aid failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- DEBUG_CLIENT_MSG("net_nfc_gdbus_secure_element_call_set_default_route_sync end");
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_is_activated_aid_handler_sync(
- net_nfc_se_type_e se_type, const char *aid, bool *activated)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- gboolean ret = false;
-
- if (activated == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_is_activated_aid_handler_sync(
- se_proxy,
- se_type,
- aid,
- &result,
- &ret,
- NULL,
- &error) == true) {
- *activated = ret;
- } else {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_is_activated_aid_handler_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_is_activated_category_handler_sync(
- net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, bool *activated)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- gboolean ret = false;
-
- if (activated == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_is_activated_category_handler_sync(
- se_proxy,
- se_type,
- category,
- &result,
- &ret,
- NULL,
- &error) == true) {
- *activated = ret;
- } else {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_is_activated_category_handler_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_get_registered_aids_count_sync(
- net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category,
- size_t *count)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *aids = NULL;
-
- if (count == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_get_registered_aids_sync(
- se_proxy,
- se_type,
- category,
- &result,
- &aids,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_get_registered_aids_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (result == NET_NFC_OK) {
- GVariantIter iter;
-
- g_variant_iter_init(&iter, aids);
-
- *count = g_variant_iter_n_children(&iter);
-
- g_variant_unref(aids);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_foreach_registered_aids_sync(
- net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category,
- net_nfc_client_se_registered_aid_cb callback,
- void *user_data)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *aids = NULL;
-
- if (callback == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_get_registered_aids_sync(
- se_proxy,
- se_type,
- category,
- &result,
- &aids,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_get_registered_aids_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (result == NET_NFC_OK) {
- GVariantIter iter;
- const gchar *aid;
- gboolean manifest;
-
- g_variant_iter_init(&iter, aids);
-
- while (g_variant_iter_loop(&iter, "(sb)", &aid, &manifest) == true) {
- callback(se_type, aid, (bool)manifest, user_data);
- }
- }
-
- return result;
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_register_aids_sync(net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, const char *aid, ...)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_register_aid_sync(
- se_proxy,
- se_type,
- category,
- aid,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_register_aid_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_unregister_aid_sync(net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, const char *aid)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_unregister_aid_sync(
- se_proxy,
- se_type,
- category,
- aid,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_unregister_aid_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_unregister_aids_sync(net_nfc_se_type_e se_type, net_nfc_card_emulation_category_t category)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_unregister_aids_sync(
- se_proxy,
- se_type,
- category,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_unregister_aids_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_foreach_registered_handlers_sync(
- net_nfc_card_emulation_category_t category,
- net_nfc_client_se_registered_handler_cb callback,
- void *user_data)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *handlers = NULL;
-
- if (callback == NULL) {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_get_registered_handlers_sync(
- se_proxy,
- category,
- &result,
- &handlers,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_get_registered_handlers_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (result == NET_NFC_OK) {
- GVariantIter iter;
- const gchar *handler;
- int count;
-
- g_variant_iter_init(&iter, handlers);
-
- while (g_variant_iter_loop(&iter, "(is)", &count, &handler) == true) {
- callback(handler, count, user_data);
- }
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_add_route_aid_sync(
- const char *package, net_nfc_se_type_e se_type,
- net_nfc_card_emulation_category_t category, const char *aid,
- bool unlock_required, int power)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_add_route_aid_sync(
- auto_start_proxy,
- package,
- aid,
- se_type,
- category,
- unlock_required,
- power,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Set Route Aid failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- DEBUG_CLIENT_MSG("net_nfc_gdbus_secure_element_call_add_route_aid_sync end");
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_remove_route_aid_sync(
- const char *package, const char *aid)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_remove_route_aid_sync(
- auto_start_proxy,
- package,
- aid,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Remove Route Aid failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- DEBUG_CLIENT_MSG("net_nfc_gdbus_hce_call_set_route_aid_sync end");
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_remove_package_aids_sync(
- const char *package)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (auto_start_proxy == NULL)
- {
- GError *error = NULL;
-
- auto_start_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (auto_start_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_remove_package_aids_sync(
- auto_start_proxy,
- package,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Remove Package Aid failed: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- DEBUG_CLIENT_MSG("net_nfc_client_se_remove_package_aids_sync end");
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_set_preferred_handler_sync(bool state)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_set_preferred_handler_sync(
- se_proxy,
- state,
- &result,
- NULL, &error) == FALSE) {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_set_preferred_handler_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_get_handler_storage_info_sync(
- net_nfc_card_emulation_category_t category, int *used, int *max)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_get_handler_storage_info_sync(
- se_proxy,
- category,
- &result,
- used,
- max,
- NULL, &error) == FALSE) {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_get_handler_storage_info_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_se_get_conflict_handlers_sync(
- const char *package, net_nfc_card_emulation_category_t category,
- const char *aid, char ***handlers)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *packages = NULL;
-
- if (se_proxy == NULL) {
- result = net_nfc_client_se_init();
- if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_client_se_init failed, [%d]", result);
-
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (net_nfc_gdbus_secure_element_call_get_conflict_handlers_sync(
- se_proxy,
- package,
- category,
- aid,
- &result,
- &packages,
- NULL, &error) == true) {
- if (result == NET_NFC_DATA_CONFLICTED) {
- GVariantIter iter;
- gchar **pkgs;
- size_t len;
-
- g_variant_iter_init(&iter, packages);
- len = g_variant_iter_n_children(&iter);
-
- SECURE_MSG("conflict count [%d]", len);
-
- if (len > 0) {
- size_t i;
- gchar *temp;
-
- pkgs = g_new0(gchar *, len + 1);
-
- for (i = 0; i < len; i++) {
- if (g_variant_iter_next(&iter, "(s)", &temp) == true) {
- SECURE_MSG("conflict package [%s]", temp);
- pkgs[i] = g_strdup(temp);
- } else {
- DEBUG_ERR_MSG("g_variant_iter_next failed");
- }
- }
-
- *handlers = pkgs;
- }
- }
- } else {
- DEBUG_ERR_MSG("net_nfc_gdbus_secure_element_call_get_conflict_handlers_sync failed : %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-net_nfc_error_e net_nfc_client_se_init(void)
-{
- GError *error = NULL;
-
- if (se_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- se_proxy = net_nfc_gdbus_secure_element_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/SecureElement",
- NULL,
- &error);
- if (se_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
-
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- g_signal_connect(se_proxy, "se-type-changed",
- G_CALLBACK(se_type_changed), NULL);
-
- g_signal_connect(se_proxy, "ese-detected",
- G_CALLBACK(se_ese_detected), NULL);
-
- g_signal_connect(se_proxy, "transaction-event",
- G_CALLBACK(se_transaction_event), NULL);
-
- g_signal_connect(se_proxy, "card-emulation-mode-changed",
- G_CALLBACK(se_card_emulation_mode_changed), NULL);
-
- g_signal_connect(se_proxy, "rf-detected",
- G_CALLBACK(se_rf_detected), NULL);
-
- return NET_NFC_OK;
-}
-
-
-void net_nfc_client_se_deinit(void)
-{
- if (se_proxy)
- {
- g_object_unref(se_proxy);
- se_proxy = NULL;
- }
-
- if (auto_start_proxy)
- {
- g_object_unref(auto_start_proxy);
- auto_start_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_util_sign_record.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_sign_records(ndef_message_h msg, int begin_index, int end_index, char *cert_file, char *password)
-{
- return net_nfc_util_sign_records((ndef_message_s *)msg, begin_index, end_index, cert_file, password);
-}
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_sign_ndef_message(ndef_message_h msg, char *cert_file, char *password)
-{
- return net_nfc_util_sign_ndef_message((ndef_message_s *)msg, cert_file, password);
-}
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_verify_signature_ndef_message(ndef_message_h msg)
-{
- return net_nfc_util_verify_signature_ndef_message((ndef_message_s *)msg);
-}
-
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_verify_signature_records(ndef_record_h begin_record, ndef_record_h sign_record)
-{
- return net_nfc_util_verify_signature_records((ndef_record_s *)begin_record, (ndef_record_s *)sign_record);
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_data.h"
-#include "net_nfc_ndef_message.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_snep.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-static NetNfcGDbusSnep *snep_proxy = NULL;
-
-/*******************************************************************/
-
-static void snep_send_client_request(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-/*********************************************************************/
-
-static void snep_send_client_request(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GVariant *parameter = (GVariant *)user_data;
- net_nfc_error_e out_result;
- net_nfc_snep_type_t out_type = NET_NFC_SNEP_GET;
- GVariant *out_data = NULL;
- GError *error = NULL;
- net_nfc_client_snep_event_cb callback;
- void *user_param;
- net_nfc_snep_handle_h handle;
-
- g_assert(parameter != NULL);
-
- if (net_nfc_gdbus_snep_call_client_request_finish(
- NET_NFC_GDBUS_SNEP(source_object),
- (gint *)&out_result,
- (guint *)&out_type,
- &out_data,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish send client request %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- g_variant_get(parameter, "(uuu)",
- (guint *)&callback,
- (guint *)&user_param,
- (guint *)&handle);
-
- if (callback != NULL) {
- ndef_message_h message;
-
- message = net_nfc_util_gdbus_variant_to_ndef_message(out_data);
-
- callback(handle, out_type, out_result,
- message, user_param);
-
- net_nfc_free_ndef_message(message);
- }
-
- g_variant_unref(parameter);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_snep_start_server(
- net_nfc_target_handle_h target,
- const char *san,
- sap_t sap,
- net_nfc_client_snep_event_cb callback,
- void *user_data)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *parameter;
-
- if (snep_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get Snep Proxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- parameter = g_variant_new("(uu)",
- GPOINTER_TO_UINT(callback),
- GPOINTER_TO_UINT(user_data));
-
- if (net_nfc_gdbus_snep_call_server_start_sync(snep_proxy,
- GPOINTER_TO_UINT(target),
- sap,
- san,
- GPOINTER_TO_UINT(parameter),
- (gint *)&result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("snep server(sync call) failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
-
- g_variant_unref(parameter);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_snep_start_client(
- net_nfc_target_handle_h target,
- const char *san,
- sap_t sap,
- net_nfc_client_snep_event_cb callback,
- void *user_data)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *parameter;
-
- if (snep_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get Snep Proxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- parameter = g_variant_new("(uu)",
- GPOINTER_TO_UINT(callback),
- GPOINTER_TO_UINT(user_data));
-
- if (net_nfc_gdbus_snep_call_client_start_sync(snep_proxy,
- GPOINTER_TO_UINT(target),
- sap,
- san,
- GPOINTER_TO_UINT(parameter),
- (gint *)&result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("snep client(sync call) failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
-
- g_variant_unref(parameter);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_snep_send_client_request(
- net_nfc_snep_handle_h target,
- net_nfc_snep_type_t snep_type,
- ndef_message_h msg,
- net_nfc_client_snep_event_cb callback,
- void *user_data)
-{
- GVariant *ndef_msg = NULL;
- GVariant *parameter;
-
- if (target == NULL || msg == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (snep_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get Snep Proxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- parameter = g_variant_new("(uuu)",
- GPOINTER_TO_UINT(callback),
- GPOINTER_TO_UINT(user_data),
- GPOINTER_TO_UINT(target));
-
- ndef_msg = net_nfc_util_gdbus_ndef_message_to_variant(msg);
-
- net_nfc_gdbus_snep_call_client_request(snep_proxy,
- GPOINTER_TO_UINT(target),
- snep_type,
- ndef_msg,
- NULL,
- snep_send_client_request,
- parameter);
-
- return NET_NFC_OK;
-}
-#if 0
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_snep_send_client_request_sync(
- net_nfc_target_handle_h target,
- net_nfc_snep_type_t snep_type,
- ndef_message_h msg,
- net_nfc_snep_type_t *resp_type,
- ndef_message_h *response)
-{
- GVariant *resp_msg = NULL;
- GVariant *arg_msg = NULL;
- GError *error = NULL;
- net_nfc_error_e result;
- guint type;
-
- if (target == NULL || msg == NULL ||
- resp_type == NULL || response == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *response = NULL;
-
- if (snep_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get Snep Proxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- arg_msg = net_nfc_util_gdbus_ndef_message_to_variant(msg);
-
- if (net_nfc_gdbus_snep_call_client_request_sync(snep_proxy,
- GPOINTER_TO_UINT(target),
- snep_type,
- arg_msg,
- &result,
- resp_type,
- &resp_msg,
- NULL,
- &error) == TRUE)
- {
- data_s ndef_data = { NULL, };
-
- net_nfc_util_gdbus_variant_to_data_s(resp_msg, &ndef_data);
-
- if (ndef_data.buffer != NULL && ndef_data.length > 0)
- {
- result = net_nfc_create_ndef_message_from_rawdata(
- response,
- &ndef_data);
-
- net_nfc_util_free_data(&ndef_data);
- }
- }
- else
- {
- DEBUG_ERR_MSG(" send client request (sync call) failed: %s",
- error->message);
- g_error_free(error);
-
- return NET_NFC_IPC_FAIL;
- }
-
-
- return result;
-}
-#endif
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_snep_stop_service_sync(
- net_nfc_target_handle_h target,
- net_nfc_snep_handle_h service)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (target == NULL || service == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (snep_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get Snep Proxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_snep_call_stop_snep_sync(
- snep_proxy,
- GPOINTER_TO_UINT(target),
- GPOINTER_TO_UINT(service),
- (gint *)&result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("snep stop service(sync call) failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-static void _snep_event_cb(NetNfcGDbusSnep *object,
- guint arg_handle,
- guint arg_event,
- gint arg_result,
- GVariant *arg_ndef_msg,
- guint arg_user_data)
-{
- GVariant *parameter = (GVariant *)GUINT_TO_POINTER(arg_user_data);
-
- INFO_MSG(">>> SIGNAL arrived");
-
- DEBUG_CLIENT_MSG("handle [%p], event [%d], result [%d], user_data [%p]",
- GUINT_TO_POINTER(arg_handle),
- arg_event,
- arg_result,
- parameter);
-
- if (parameter != NULL)
- {
- net_nfc_client_snep_event_cb callback;
- void *user_data;
-
- g_variant_get(parameter,
- "(uu)",
- &callback,
- &user_data);
-
- if (callback != NULL)
- {
- ndef_message_h message;
-
- message = net_nfc_util_gdbus_variant_to_ndef_message(
- arg_ndef_msg);
-
- callback(GUINT_TO_POINTER(arg_handle),
- arg_event,
- arg_result,
- message,
- user_data);
-
- net_nfc_free_ndef_message(message);
- }
-#if 0 /* remove temporary... */
- if (arg_event == NET_NFC_LLCP_UNREGISTERED) {
- g_variant_unref(parameter);
- }
-#endif
- }
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_snep_register_server(const char *san,
- sap_t sap,
- net_nfc_client_snep_event_cb callback,
- void *user_data)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *parameter;
-
- if (snep_proxy == NULL)
- {
- if(net_nfc_client_snep_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("Snep Proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- parameter = g_variant_new("(uu)",
- GPOINTER_TO_UINT(callback),
- GPOINTER_TO_UINT(user_data));
-
- if (net_nfc_gdbus_snep_call_server_register_sync(snep_proxy,
- sap,
- san,
- GPOINTER_TO_UINT(parameter),
- (gint *)&result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("snep register server(sync call) failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
-
- g_variant_unref(parameter);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_snep_unregister_server(const char *san,
- sap_t sap)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (snep_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not get Snep Proxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_snep_call_server_unregister_sync(snep_proxy,
- sap,
- san,
- (gint *)&result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("snep unregister server(sync call) failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-net_nfc_error_e net_nfc_client_snep_init(void)
-{
- GError *error = NULL;
-
- if (snep_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- snep_proxy = net_nfc_gdbus_snep_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Snep",
- NULL,
- &error);
- if (snep_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- g_signal_connect(snep_proxy, "snep-event",
- G_CALLBACK(_snep_event_cb), NULL);
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_snep_deinit(void)
-{
- if (snep_proxy)
- {
- g_object_unref(snep_proxy);
- snep_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_ndef_message.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_system_handler.h"
-
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-static NetNfcGDbusPopup *popup_proxy = NULL;
-static int popup_state = 0;
-
-static void popup_set_active_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void popup_set_active_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_popup_call_set_finish(
- NET_NFC_GDBUS_POPUP(source_object),
- &result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish popup_set_active: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_popup_set_state_callback callback =
- (net_nfc_client_popup_set_state_callback)func_data->callback;
-
- callback(result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_sys_handler_set_state(int state,
- net_nfc_client_popup_set_state_callback callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (popup_proxy == NULL)
- {
- if(net_nfc_client_sys_handler_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("popup_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL )
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_popup_call_set(popup_proxy,
- state,
- CHECK_FOREGROUND,
- NULL,
- popup_set_active_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_sys_handler_set_state_sync(int state)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- if (popup_proxy == NULL)
- {
- if(net_nfc_client_sys_handler_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("popup_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_popup_call_set_sync(popup_proxy,
- state,
- CHECK_FOREGROUND,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call SetActive: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_sys_handler_set_state_force(int state,
- net_nfc_client_popup_set_state_callback callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (popup_proxy == NULL)
- {
- if(net_nfc_client_sys_handler_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("popup_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_popup_call_set(popup_proxy,
- state,
- NO_CHECK_FOREGROUND,
- NULL,
- popup_set_active_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_sys_handler_set_state_force_sync(int state)
-{
- net_nfc_error_e result;
- GError *error = NULL;
-
- if (popup_proxy == NULL)
- {
- if(net_nfc_client_sys_handler_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("popup_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_popup_call_set_sync(popup_proxy,
- state,
- NO_CHECK_FOREGROUND,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call SetActive: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_sys_handler_set_launch_popup_state(
- int enable)
-{
- popup_state = enable;
-
- return net_nfc_client_sys_handler_set_state_sync(enable);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_sys_handler_set_launch_popup_state_force(
- int enable)
-{
- popup_state = enable;
-
- return net_nfc_client_sys_handler_set_state_force_sync(enable);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_sys_handler_get_launch_popup_state(
- int *state)
-{
- net_nfc_error_e result = NET_NFC_OK;
- gint out_state = NET_NFC_LAUNCH_APP_SELECT;
- GError *error = NULL;
-
- if (state == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- *state = NET_NFC_LAUNCH_APP_SELECT;
-
- if (popup_proxy == NULL) {
- if(net_nfc_client_sys_handler_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("popup_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_popup_call_get_sync(popup_proxy,
- &result,
- &out_state,
- NULL,
- &error) == true) {
- *state = out_state;
- } else {
-
- DEBUG_ERR_MSG("net_nfc_gdbus_popup_call_get_sync failed: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-net_nfc_error_e net_nfc_client_sys_handler_init(void)
-{
- GError *error = NULL;
-
- if (popup_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- popup_proxy = net_nfc_gdbus_popup_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Popup",
- NULL,
- &error);
- if (popup_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_OPERATION_FAIL;
- }
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_sys_handler_deinit(void)
-{
- if (popup_proxy)
- {
- g_object_unref(popup_proxy);
- popup_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_data.h"
-#include "net_nfc_target_info.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_tag.h"
-#include "net_nfc_client_tag_internal.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-static NetNfcGDbusTag *tag_proxy = NULL;
-
-static NetNfcCallback tag_discovered_func_data;
-static NetNfcCallback tag_detached_func_data;
-
-static net_nfc_target_info_s *client_target_info = NULL;
-static net_nfc_event_filter_e client_filter = NET_NFC_ALL_ENABLE;
-
-static gboolean tag_check_filter(net_nfc_target_type_e type);
-
-static void tag_get_info_list(guint8 *buffer,
- gint number_of_keys,
- net_nfc_tag_info_s **list);
-
-static void tag_get_target_info(guint handle,
- guint dev_type,
- gboolean is_ndef_supported,
- guchar ndef_card_state,
- guint max_data_size,
- guint actual_data_size,
- guint number_of_keys,
- GVariant *target_info_values,
- GVariant *raw_data,
- net_nfc_target_info_s **info);
-
-#if 0
-/* async callback */
-static void tag_is_tag_connected(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void tag_get_current_tag_info(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void tag_get_current_target_handle(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-#endif
-/* signal callback */
-static void tag_tag_discovered(NetNfcGDbusTag *object,
- guint arg_handle,
- gint arg_dev_type,
- gboolean arg_is_ndef_supported,
- guchar arg_ndef_card_state,
- guint arg_max_data_size,
- guint arg_actual_data_size,
- guint arg_number_of_keys,
- GVariant *arg_target_info_values,
- GVariant *arg_raw_data,
- gpointer user_data);
-
-static void tag_tag_detached(NetNfcGDbusTag *object,
- guint arg_handle,
- gint arg_dev_type,
- gpointer user_data);
-
-static gboolean tag_check_filter(net_nfc_target_type_e type)
-{
- net_nfc_event_filter_e converted = NET_NFC_ALL_ENABLE;
-
- DEBUG_CLIENT_MSG("client filter = %d", client_filter);
-
- if (type >= NET_NFC_ISO14443_A_PICC &&
- type <= NET_NFC_MIFARE_DESFIRE_PICC)
- {
- converted = NET_NFC_ISO14443A_ENABLE;
- }
- else if (type >= NET_NFC_ISO14443_B_PICC &&
- type <= NET_NFC_ISO14443_BPRIME_PICC)
- {
- converted = NET_NFC_ISO14443B_ENABLE;
- }
- else if (type == NET_NFC_FELICA_PICC)
- {
- converted = NET_NFC_FELICA_ENABLE;
- }
- else if (type == NET_NFC_JEWEL_PICC)
- {
- converted = NET_NFC_FELICA_ENABLE;
- }
- else if (type == NET_NFC_ISO15693_PICC)
- {
- converted = NET_NFC_ISO15693_ENABLE;
- }
-
- if ((converted & client_filter) == 0)
- return FALSE;
-
- return TRUE;
-}
-
-static void tag_get_info_list(guint8 *buffer,
- gint number_of_keys,
- net_nfc_tag_info_s **list)
-{
- net_nfc_tag_info_s *tmp_list = NULL;
- net_nfc_tag_info_s *current = NULL;
-
- gint i = 0;
- gint length;
-
- guint8 *pos = buffer;
-
- if (buffer == NULL)
- return;
-
- tmp_list = g_new0(net_nfc_tag_info_s, number_of_keys);
- current = tmp_list;
-
- while (i < number_of_keys)
- {
- gchar *str = NULL;
- data_h value = NULL;
-
- /* key */
- length = *pos; /* first values is length of key */
- pos++;
-
- str = g_new0(gchar, length + 1);
- memcpy(str, pos, length);
-
- SECURE_MSG("key = [%s]", str);
-
- pos += length;
-
- current->key = str;
-
- /* value */
- length = *pos; /* first value is length of value */
- pos++;
-
- value = NULL;
- if (length > 0)
- {
- net_nfc_create_data(&value, pos, length);
- pos += length;
- }
-
- current->value = value;
-
- current++;
- i++;
- }
-
- *list = tmp_list;
-}
-
-static void tag_get_target_info(guint handle,
- guint dev_type,
- gboolean is_ndef_supported,
- guchar ndef_card_state,
- guint max_data_size,
- guint actual_data_size,
- guint number_of_keys,
- GVariant *target_info_values,
- GVariant *raw_data,
- net_nfc_target_info_s **info)
-{
- guint8 *buffer = NULL;
- net_nfc_target_info_s *info_data = NULL;
- net_nfc_tag_info_s *list = NULL;
-
- if (info == NULL)
- return;
-
- net_nfc_util_gdbus_variant_to_buffer(target_info_values,
- &buffer, NULL);
-
- tag_get_info_list(buffer, number_of_keys, &list);
-
- info_data = g_new0(net_nfc_target_info_s, 1);
-
- info_data->ndefCardState = ndef_card_state;
- info_data->actualDataSize = actual_data_size;
- info_data->maxDataSize = max_data_size;
- info_data->devType = dev_type;
- info_data->handle = GUINT_TO_POINTER(handle);
- info_data->is_ndef_supported = (uint8_t)is_ndef_supported;
- info_data->number_of_keys = number_of_keys;
- info_data->tag_info_list = list;
-
- net_nfc_util_gdbus_variant_to_data_s(raw_data,
- &info_data->raw_data);
-
- *info = info_data;
-}
-#if 0
-static void tag_is_tag_connected(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- gboolean out_is_connected = false;
- net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_tag_call_is_tag_connected_finish(
- NET_NFC_GDBUS_TAG(source_object),
- &out_result,
- &out_is_connected,
- (gint32 *)&out_dev_type,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish is_tag_connected: %s",
- error->message);
- g_error_free(error);
-
- out_result = NET_NFC_IPC_FAIL;
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_tag_is_tag_connected_completed callback =
- (net_nfc_client_tag_is_tag_connected_completed)func_data->callback;
-
- if (out_is_connected == FALSE)
- out_result = NET_NFC_NOT_CONNECTED;
-
- callback(out_result, out_dev_type, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void tag_get_current_tag_info(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result = NET_NFC_OK;
-
- net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
- gboolean out_is_connected = FALSE;
- gboolean out_is_ndef_supported = FALSE;
- guchar out_ndef_card_state = 0;
- guint out_handle = 0;
- guint out_max_data_size = 0;
- guint out_actual_data_size = 0;
- guint out_number_of_keys = 0;
- GVariant *out_target_info_values = NULL;
- GVariant *out_raw_data = NULL;
-
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_tag_call_get_current_tag_info_finish (
- NET_NFC_GDBUS_TAG(source_object),
- &out_result,
- &out_is_connected,
- &out_handle,
- (gint *)&out_dev_type,
- &out_is_ndef_supported,
- &out_ndef_card_state,
- &out_max_data_size,
- &out_actual_data_size,
- &out_number_of_keys,
- &out_target_info_values,
- &out_raw_data,
- res,
- &error) == FALSE)
- {
- out_result = NET_NFC_IPC_FAIL;
-
- DEBUG_ERR_MSG("Can not finish get_current_tag_info: %s",
- error->message);
- g_error_free(error);
- }
-
- if (out_result == NET_NFC_OK && out_is_connected == true) {
- net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
- client_target_info = NULL;
-
- if (tag_check_filter(out_dev_type) == true) {
- tag_get_target_info(out_handle,
- out_dev_type,
- out_is_ndef_supported,
- out_ndef_card_state,
- out_max_data_size,
- out_actual_data_size,
- out_number_of_keys,
- out_target_info_values,
- out_raw_data,
- &client_target_info);
- } else {
- INFO_MSG("The detected target is filtered out, type [%d]", out_dev_type);
-
- out_is_connected = false;
- }
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_tag_get_current_tag_info_completed callback =
- (net_nfc_client_tag_get_current_tag_info_completed)func_data->callback;
-
- if (out_result == NET_NFC_OK && out_is_connected == false)
- out_result = NET_NFC_NOT_CONNECTED;
-
- callback(out_result, client_target_info, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void tag_get_current_target_handle(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result = NET_NFC_OK;
- net_nfc_target_handle_h out_handle = NULL;
- net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
- gboolean out_is_connected = false;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_tag_call_get_current_target_handle_finish(
- NET_NFC_GDBUS_TAG(source_object),
- &out_result,
- &out_is_connected,
- (guint *)&out_handle,
- (gint *)&out_dev_type,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish get_current_target_handle: %s",
- error->message);
- g_error_free(error);
-
- out_result = NET_NFC_IPC_FAIL;
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_tag_get_current_target_handle_completed callback =
- (net_nfc_client_tag_get_current_target_handle_completed)func_data->callback;
-
- if (out_result == NET_NFC_OK && out_is_connected == FALSE)
- out_result = NET_NFC_NOT_CONNECTED;
-
- callback(out_result,
- GUINT_TO_POINTER(out_handle),
- func_data->user_data);
- }
-
- g_free(func_data);
-}
-#endif
-static void tag_tag_discovered(NetNfcGDbusTag *object,
- guint arg_handle,
- gint arg_dev_type,
- gboolean arg_is_ndef_supported,
- guchar arg_ndef_card_state,
- guint arg_max_data_size,
- guint arg_actual_data_size,
- guint arg_number_of_keys,
- GVariant *arg_target_info_values,
- GVariant *arg_raw_data,
- gpointer user_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
- client_target_info = NULL;
-
- if (tag_check_filter(arg_dev_type) == FALSE) {
- DEBUG_CLIENT_MSG("The detected target is filtered out, type [%d]", arg_dev_type);
-
- return;
- }
-
- tag_get_target_info(arg_handle,
- arg_dev_type,
- arg_is_ndef_supported,
- arg_ndef_card_state,
- arg_max_data_size,
- arg_actual_data_size,
- arg_number_of_keys,
- arg_target_info_values,
- arg_raw_data,
- &client_target_info);
-
- if (tag_discovered_func_data.callback != NULL) {
- net_nfc_client_tag_tag_discovered callback =
- (net_nfc_client_tag_tag_discovered)tag_discovered_func_data.callback;
-
- callback(client_target_info,
- tag_discovered_func_data.user_data);
- }
-}
-
-static void tag_tag_detached(NetNfcGDbusTag *object,
- guint arg_handle,
- gint arg_dev_type,
- gpointer user_data)
-{
- INFO_MSG(">>> SIGNAL arrived");
-
- if (tag_check_filter(arg_dev_type) == TRUE) {
- if (tag_detached_func_data.callback != NULL) {
- net_nfc_client_tag_tag_detached callback =
- (net_nfc_client_tag_tag_detached)tag_detached_func_data.callback;
-
- callback(tag_detached_func_data.user_data);
- }
- } else {
- DEBUG_CLIENT_MSG("The detected target is filtered out, type [%d]", arg_dev_type);
- }
-
- net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
- client_target_info = NULL;
-}
-
-/* internal function */
-gboolean net_nfc_client_tag_is_connected(void)
-{
- if (client_target_info == NULL)
- return FALSE;
-
- if (client_target_info->handle == NULL)
- return FALSE;
-
- return TRUE;
-}
-
-net_nfc_target_info_s *net_nfc_client_tag_get_client_target_info(void)
-{
- return client_target_info;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_tag_is_tag_connected_sync(
- net_nfc_target_type_e *dev_type)
-{
- net_nfc_target_info_s *info;
- net_nfc_error_e result = NET_NFC_OK;
- net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
- gboolean out_is_connected = false;
- GError *error = NULL;
-
- if (tag_proxy == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- info = net_nfc_client_tag_get_client_target_info();
- if (info == NULL) {
- /* try to request target information from server */
- if (net_nfc_gdbus_tag_call_is_tag_connected_sync(tag_proxy,
- &result,
- &out_is_connected,
- (gint *)&out_dev_type,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not get is_tag_connected result: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
-
- return result;
- }
-
- if (out_is_connected == true) {
- if (dev_type)
- *dev_type = out_dev_type;
-
- result = NET_NFC_OK;
- } else {
- result = NET_NFC_NOT_CONNECTED;
- }
- } else {
- /* target was connected */
- if (dev_type != NULL) {
- *dev_type = info->devType;
- }
-
- result = NET_NFC_OK;
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_barcode_get_barcode_sync(
- unsigned char **barcode, int* barcode_len)
-{
- data_s *data;
- GError *error = NULL;
- GVariant *out_barcode = NULL;
- net_nfc_error_e result = NET_NFC_OK;
-
- if (tag_proxy == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_tag_call_get_barcode_sync(tag_proxy,
- &result,
- &out_barcode,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can no get barcode result: %s", error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
-
- return result;
- }
-
- if(result == NET_NFC_OK)
- {
- data = g_new0(data_s, 1);
- net_nfc_util_gdbus_variant_to_data_s(out_barcode, data);
-
- if(data == NULL || data->buffer == NULL || data->length == 0)
- return NET_NFC_OPERATION_FAIL;
-
- //alloc barcode
- *barcode_len = data->length;
- *barcode = (unsigned char *)calloc(*barcode_len, sizeof(unsigned char));
- memcpy(*barcode, data->buffer, *barcode_len);
-
- if (data != NULL) {
- net_nfc_util_free_data(data);
- }
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_tag_get_current_tag_info_sync(
- net_nfc_target_info_h *info)
-{
- net_nfc_error_e result = NET_NFC_OK;
- net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
- gboolean out_is_connected = false;
- gboolean out_is_ndef_supported = false;
- guchar out_ndef_card_state = 0;
- guint out_handle = 0;
- guint out_max_data_size = 0;
- guint out_actual_data_size = 0;
- guint out_number_of_keys = 0;
- GVariant *out_target_info_values = NULL;
- GVariant *out_raw_data = NULL;
- GError *error = NULL;
-
- if (tag_proxy == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_client_tag_get_client_target_info() == NULL) {
- /* try to request target information from server */
- if (net_nfc_gdbus_tag_call_get_current_tag_info_sync(tag_proxy,
- &result,
- &out_is_connected,
- &out_handle,
- (gint *)&out_dev_type,
- &out_is_ndef_supported,
- &out_ndef_card_state,
- &out_max_data_size,
- &out_actual_data_size,
- &out_number_of_keys,
- &out_target_info_values,
- &out_raw_data,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can no get current_tag_info result: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
-
- return result;
- }
-
- if (result == NET_NFC_OK) {
- if (out_is_connected == true) {
- if (tag_check_filter(out_dev_type) == true) {
- tag_get_target_info(out_handle,
- out_dev_type,
- out_is_ndef_supported,
- out_ndef_card_state,
- out_max_data_size,
- out_actual_data_size,
- out_number_of_keys,
- out_target_info_values,
- out_raw_data,
- &client_target_info);
-
- result = NET_NFC_OK;
- } else {
- DEBUG_CLIENT_MSG("The detected target is filtered out");
-
- result = NET_NFC_NOT_CONNECTED;
- }
- } else {
- result = NET_NFC_NOT_CONNECTED;
- }
- }
- } else {
- result = NET_NFC_OK;
- }
-
- if (result == NET_NFC_OK && info != NULL) {
- *info = client_target_info;
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_tag_get_current_target_handle_sync(
- net_nfc_target_handle_h *handle)
-{
- net_nfc_target_info_s *info;
- net_nfc_error_e result;
- net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
- gboolean out_is_connected = false;
- guint out_handle = 0;
- GError *error = NULL;
-
- if (tag_proxy == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- info = net_nfc_client_tag_get_client_target_info();
- if (info == NULL) {
- if (net_nfc_gdbus_tag_call_get_current_target_handle_sync(
- tag_proxy,
- &result,
- &out_is_connected,
- &out_handle,
- (gint *)&out_dev_type,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can no get current_target_handle result: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
-
- return result;
- }
-
- if (result == NET_NFC_OK) {
- if (out_is_connected == true) {
- if (handle)
- *handle = GUINT_TO_POINTER(out_handle);
-
- result = NET_NFC_OK;
- } else {
- result = NET_NFC_NOT_CONNECTED;
- }
- }
- } else if (info->devType == NET_NFC_NFCIP1_INITIATOR ||
- info->devType == NET_NFC_NFCIP1_TARGET) {
- if (handle)
- *handle = info->handle;
-
- result = NET_NFC_OK;
- } else {
- result = NET_NFC_NOT_CONNECTED;
- }
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_tag_set_tag_discovered(
- net_nfc_client_tag_tag_discovered callback,
- void *user_data)
-{
- if (callback == NULL)
- return;
-
- if (tag_proxy == NULL)
- {
- if (net_nfc_client_tag_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- tag_discovered_func_data.callback = (gpointer)callback;
- tag_discovered_func_data.user_data = user_data;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_tag_unset_tag_discovered(void)
-{
- tag_discovered_func_data.callback = NULL;
- tag_discovered_func_data.user_data = NULL;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_tag_set_tag_detached(
- net_nfc_client_tag_tag_detached callback,
- void *user_data)
-{
- if (callback == NULL)
- return;
-
- if (tag_proxy == NULL)
- {
- if (net_nfc_client_tag_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("tag_proxy fail");
- /* FIXME : return result of this error */
- return;
- }
- }
-
- tag_detached_func_data.callback = (gpointer)callback;
- tag_detached_func_data.user_data = user_data;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_tag_unset_tag_detached(void)
-{
- tag_detached_func_data.callback = NULL;
- tag_detached_func_data.user_data = NULL;
-}
-
-NET_NFC_EXPORT_API
-void net_nfc_client_tag_set_filter(net_nfc_event_filter_e filter)
-{
- client_filter = filter;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_event_filter_e net_nfc_client_tag_get_filter(void)
-{
- return client_filter;
-}
-
-net_nfc_error_e net_nfc_client_tag_init(void)
-{
- GError *error = NULL;
-
- if (tag_proxy)
- {
- DEBUG_CLIENT_MSG("Alrady initialized");
-
- return NET_NFC_OK;
- }
-
- if (client_target_info)
- {
- net_nfc_release_tag_info(
- (net_nfc_target_info_h)client_target_info);
- client_target_info = NULL;
- }
-
- client_filter = NET_NFC_ALL_ENABLE;
-
- tag_proxy = net_nfc_gdbus_tag_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Tag",
- NULL,
- &error);
- if (tag_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- g_signal_connect(tag_proxy, "tag-discovered",
- G_CALLBACK(tag_tag_discovered), NULL);
-
- g_signal_connect(tag_proxy, "tag-detached",
- G_CALLBACK(tag_tag_detached), NULL);
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_tag_deinit(void)
-{
- client_filter = NET_NFC_ALL_ENABLE;
-
- net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
- client_target_info = NULL;
-
- net_nfc_client_tag_unset_tag_discovered();
- net_nfc_client_tag_unset_tag_detached();
-
- if (tag_proxy)
- {
- g_object_unref(tag_proxy);
- tag_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * 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 <glib.h>
-#include <string.h>
-
-#include "net_nfc_client_tag_felica.h"
-#include "net_nfc_client_tag_internal.h"
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_target_info.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-#define FELICA_CMD_POLL 0x00
-#define FELICA_CMD_REQ_SERVICE 0x02
-#define FELICA_CMD_REQ_RESPONSE 0x04
-#define FELICA_CMD_READ_WITHOUT_ENC 0x06
-#define FELICA_CMD_WRITE_WITHOUT_ENC 0x08
-#define FELICA_CMD_REQ_SYSTEM_CODE 0x0C
-#define FELICA_TAG_KEY "IDm"
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_felica_poll(net_nfc_target_handle_h handle,
- net_nfc_felica_poll_request_code_e req_code,
- uint8_t time_slote,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t send_buffer[6] = { 0x00, };
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if (target_info->devType != NET_NFC_FELICA_PICC)
- {
- DEBUG_CLIENT_MSG("only felica tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- /* total size of requet command */
- send_buffer[0] = 0x06;
- send_buffer[1] = FELICA_CMD_POLL;
-
- /* use wild card for system code */
- send_buffer[2] = 0xff;
- send_buffer[3] = 0xff;
-
- send_buffer[4] = req_code;
- send_buffer[5] = time_slote;
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 6);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 6;
-
- return net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_felica_request_service(
- net_nfc_target_handle_h handle,
- uint8_t number_of_area_service,
- uint16_t area_service_list[],
- uint8_t number_of_services,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h IDm = NULL;
-
- uint32_t send_buffer_length;
- uint8_t* send_buffer = NULL;
- uint8_t* temp = NULL;
-
- int i;
-
- if (handle == NULL || area_service_list == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if (target_info->devType != NET_NFC_FELICA_PICC)
- {
- DEBUG_CLIENT_MSG("only felica tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if (net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- FELICA_TAG_KEY,
- &IDm) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if (((data_s*)IDm)->length != 8)
- return NET_NFC_OUT_OF_BOUND;
-
- if (number_of_area_service > 32)
- return NET_NFC_OUT_OF_BOUND;
-
- /* size + cmd + UID + number of service service count + service list */
- send_buffer_length = 1 + 1 + 8 + 1 + (2 * number_of_services);
-
- _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- /* set cmd length */
- *send_buffer = send_buffer_length;
- send_buffer++;
-
- /* set cmd */
- *send_buffer = FELICA_CMD_REQ_SERVICE;
- send_buffer++;
-
- /* set IDm */
- memcpy(send_buffer, ((data_s*)IDm)->buffer, ((data_s*)IDm)->length);
- send_buffer = send_buffer + ((data_s*)IDm)->length;
-
- /* set the number of service codes */
- *send_buffer = number_of_area_service;
- send_buffer++;
-
- for (i = 0; i < number_of_services; i++)
- {
- memcpy(send_buffer, &area_service_list[i], sizeof(uint16_t));
- send_buffer = send_buffer + 2;
- }
-
- DEBUG_MSG_PRINT_BUFFER(temp, send_buffer_length);
-
- rawdata.buffer = send_buffer;
- rawdata.length = send_buffer_length;
-
- net_nfc_error_e result = NET_NFC_OK;
- result = net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
- if (temp != NULL)
- _net_nfc_util_free_mem(temp);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_felica_request_response(
- net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h IDm = NULL;
-
- uint8_t send_buffer[10] = { 0x00, };
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if (target_info->devType != NET_NFC_FELICA_PICC)
- {
- DEBUG_CLIENT_MSG("only felica tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if (net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- FELICA_TAG_KEY,
- &IDm) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if (((data_s*)IDm)->length != 8)
- return NET_NFC_OUT_OF_BOUND;
-
- send_buffer[0] = 0xA;
- send_buffer[1] = FELICA_CMD_REQ_RESPONSE;
-
- memcpy(send_buffer + 2,
- ((data_s*)IDm)->buffer,
- ((data_s*)IDm)->length);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 10);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 10;
-
- return net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_felica_read_without_encryption(
- net_nfc_target_handle_h handle,
- uint8_t number_of_services,
- uint16_t service_list[],
- uint8_t number_of_blocks,
- uint8_t block_list[],
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h IDm = NULL;
-
- uint32_t send_buffer_length;
- uint8_t* send_buffer = NULL;
- uint8_t* temp = NULL;
-
- int i;
-
- if (handle == NULL || service_list == NULL || block_list == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if (target_info->devType != NET_NFC_FELICA_PICC)
- {
- DEBUG_CLIENT_MSG("only felica tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if (net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- FELICA_TAG_KEY,
- &IDm) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if (((data_s*)IDm)->length != 8)
- return NET_NFC_OUT_OF_BOUND;
-
- if (number_of_services > 16)
- return NET_NFC_OUT_OF_BOUND;
-
- send_buffer_length = 1 + 1 + 8 + 1 + (2 * number_of_services)
- + 1 + number_of_blocks;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *send_buffer = send_buffer_length;
- send_buffer++;
-
- *send_buffer = FELICA_CMD_READ_WITHOUT_ENC;
- send_buffer++;
-
- memcpy(send_buffer, ((data_s*)IDm)->buffer, ((data_s*)IDm)->length);
- send_buffer = send_buffer + ((data_s*)IDm)->length;
-
- *send_buffer = number_of_services;
- send_buffer++;
-
- for (i = 0; i < number_of_services; i++)
- {
- memcpy(send_buffer, &service_list[i], sizeof(uint16_t));
- send_buffer = send_buffer + 2;
- }
-
- *send_buffer = number_of_blocks;
- send_buffer++;
-
- for (i = 0; i < number_of_blocks; i++)
- {
- memcpy(send_buffer, &block_list[i], sizeof(uint8_t));
- send_buffer++;
- }
-
- DEBUG_MSG_PRINT_BUFFER(temp, send_buffer_length);
-
- rawdata.buffer = temp;
- rawdata.length = send_buffer_length;
-
- net_nfc_error_e result = NET_NFC_OK;
- result = net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
- if (temp != NULL)
- _net_nfc_util_free_mem(temp);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_felica_write_without_encryption(
- net_nfc_target_handle_h handle,
- uint8_t number_of_services,
- uint16_t service_list[],
- uint8_t number_of_blocks,
- uint8_t block_list[],
- data_h data,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h IDm = NULL;
-
- uint32_t send_buffer_length;
- uint8_t* send_buffer = NULL;
- uint8_t* temp = NULL;
-
- int i;
-
- if (handle == NULL || service_list == NULL ||
- block_list == NULL || data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if (target_info->devType != NET_NFC_FELICA_PICC)
- {
- DEBUG_CLIENT_MSG("only felica tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if (net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- FELICA_TAG_KEY,
- &IDm) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if (((data_s*)IDm)->length != 8)
- return NET_NFC_OUT_OF_BOUND;
-
- if (number_of_services > 16)
- return NET_NFC_OUT_OF_BOUND;
-
- if (((data_s*)data)->length > 16 * number_of_blocks)
- return NET_NFC_OUT_OF_BOUND;
-
- send_buffer_length = 1 + 1 + 8 + 1 + (2 * number_of_services)
- + 1 + number_of_blocks
- +((data_s*)data)->length;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *send_buffer = send_buffer_length;
- send_buffer++;
-
- *send_buffer = FELICA_CMD_WRITE_WITHOUT_ENC;
- send_buffer++;
-
- memcpy(send_buffer, ((data_s*)IDm)->buffer, ((data_s*)IDm)->length);
- send_buffer = send_buffer + ((data_s*)IDm)->length;
-
- *send_buffer = number_of_services;
- send_buffer++;
-
- for (i = 0; i < number_of_services; i++)
- {
- memcpy(send_buffer, &service_list[i], sizeof(uint16_t));
- send_buffer = send_buffer + 2;
- }
-
- *send_buffer = number_of_blocks;
- send_buffer++;
-
- for (i = 0; i < number_of_blocks; i++)
- {
- memcpy(send_buffer, &block_list[i], sizeof(uint8_t));
- send_buffer++;
- }
-
- memcpy(send_buffer, ((data_s*)data)->buffer, ((data_s*)data)->length);
-
- DEBUG_MSG_PRINT_BUFFER(temp, send_buffer_length);
-
- rawdata.buffer = temp;
- rawdata.length = send_buffer_length;
-
- net_nfc_error_e result = NET_NFC_OK;
-
- result = net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
- if (temp != NULL)
- _net_nfc_util_free_mem(temp);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_felica_request_system_code(
- net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h IDm = NULL;
-
- uint8_t send_buffer[10] = { 0x00, };
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if (target_info->devType != NET_NFC_FELICA_PICC)
- {
- DEBUG_CLIENT_MSG("only felica tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if (net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- FELICA_TAG_KEY,
- &IDm) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if (((data_s*)IDm)->length != 8)
- return NET_NFC_OUT_OF_BOUND;
-
-
- send_buffer[0] = 0xA;
- send_buffer[1] = FELICA_CMD_REQ_SYSTEM_CODE;
-
- memcpy(send_buffer + 2,
- ((data_s *)IDm)->buffer,
- ((data_s *)IDm)->length);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 10);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 10;
-
- return net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <glib.h>
-#include <string.h>
-
-#include "net_nfc_client_tag_jewel.h"
-#include "net_nfc_client_tag_internal.h"
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_target_info.h"
-
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-
-#define JEWEL_CMD_REQA 0x26
-#define JEWEL_CMD_WUPA 0x52
-#define JEWEL_CMD_RID 0x78
-#define JEWEL_CMD_RALL 0x00
-#define JEWEL_CMD_READ 0x01
-#define JEWEL_CMD_WRITE_E 0x53
-#define JEWEL_CMD_WRITE_NE 0x1A
-#define JEWEL_TAG_KEY "UID"
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_jewel_read_id(net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t send_buffer[9] = {0x00, };
-
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if(target_info->devType != NET_NFC_JEWEL_PICC)
- {
- DEBUG_CLIENT_MSG("only Jewel tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- send_buffer[0] = JEWEL_CMD_RID;
-
- net_nfc_util_compute_CRC(CRC_B, send_buffer, 9);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 9);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 9;
-
- return net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_jewel_read_byte(net_nfc_target_handle_h handle,
- uint8_t block,
- uint8_t byte,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h UID = NULL;
-
- uint8_t send_buffer[9] = {0x00, };
-
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(block > 0xE || byte > 0x7 )
- return NET_NFC_OUT_OF_BOUND;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if(target_info->devType != NET_NFC_JEWEL_PICC)
- {
- DEBUG_CLIENT_MSG("only Jewel tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if(net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- JEWEL_TAG_KEY,
- &UID) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
-
- if(((data_s*)UID)->length != 4)
- return NET_NFC_OUT_OF_BOUND;
-
- /* command */
- send_buffer[0] = JEWEL_CMD_READ;
-
- /* addr */
- send_buffer[1] = (((block << 3) & 0x78) | (byte & 0x7));
-
- /* data */
- send_buffer[2] = 0x00;
-
- /* UID0 ~ 3 */
- memcpy(&(send_buffer[3]),
- ((data_s*)UID)->buffer,
- ((data_s*)UID)->length);
-
- net_nfc_util_compute_CRC(CRC_B, send_buffer, 9);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 9);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 9;
-
- return net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_jewel_read_all(net_nfc_target_handle_h handle,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h UID = NULL;
-
- uint8_t send_buffer[9] = {0x00, };
-
- if(handle == NULL )
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if(target_info->devType != NET_NFC_JEWEL_PICC)
- {
- DEBUG_CLIENT_MSG("only Jewel tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if(net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- JEWEL_TAG_KEY,
- &UID) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if(((data_s*)UID)->length != 4)
- return NET_NFC_OUT_OF_BOUND;
-
- /* command */
- send_buffer[0] = JEWEL_CMD_RALL;
-
- /* addr */
- send_buffer[1] = 0x00;
-
- /* data */
- send_buffer[2] = 0x00;
-
- /* UID0 ~ 3 */
- memcpy(&(send_buffer[3]),
- ((data_s*)UID)->buffer,
- ((data_s*)UID)->length);
-
- net_nfc_util_compute_CRC(CRC_B, send_buffer, 9);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 9);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 9;
-
- return net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_jewel_write_with_erase(
- net_nfc_target_handle_h handle,
- uint8_t block,
- uint8_t byte,
- uint8_t data,
- nfc_transceive_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h UID = NULL;
-
- uint8_t send_buffer[9] = {0x00, };
-
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(block > 0xE || byte > 0x7 )
- return NET_NFC_OUT_OF_BOUND;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if(net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- JEWEL_TAG_KEY,
- &UID) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if(((data_s*)UID)->length != 4)
- return NET_NFC_OUT_OF_BOUND;
-
- /* command */
- send_buffer[0] = JEWEL_CMD_WRITE_E;
-
- /* addr */
- send_buffer[1] = (((block << 3) & 0x78) | (byte & 0x7));
-
- /* data */
- send_buffer[2] = data;
-
- /* UID0 ~ 3 */
- memcpy(&(send_buffer[3]),
- ((data_s*)UID)->buffer,
- ((data_s*)UID)->length);
-
- net_nfc_util_compute_CRC(CRC_B, send_buffer, 9);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 9);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 9;
-
- return net_nfc_client_transceive(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_jewel_write_with_no_erase(
- net_nfc_target_handle_h handle,
- uint8_t block,
- uint8_t byte,
- uint8_t data,
- nfc_transceive_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- data_h UID = NULL;
-
- uint8_t send_buffer[9] = {0x00, };
-
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(block > 0xE || byte > 0x7 )
- return NET_NFC_OUT_OF_BOUND;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
- return NET_NFC_NO_DATA_FOUND;
-
- if(target_info->devType != NET_NFC_JEWEL_PICC)
- {
- DEBUG_CLIENT_MSG("only Jewel tag is available");
- return NET_NFC_NOT_ALLOWED_OPERATION;
- }
-
- if(net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- JEWEL_TAG_KEY,
- &UID) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if(((data_s*)UID)->length != 4)
- return NET_NFC_OUT_OF_BOUND;
-
- /* command */
- send_buffer[0] = JEWEL_CMD_WRITE_NE;
-
- /* addr */
- send_buffer[1] = (((block << 3) & 0x78) | (byte & 0x7));
-
- /* data */
- send_buffer[2] = data;
-
- /* UID0 ~ 3 */
- memcpy(&(send_buffer[3]),
- ((data_s*)UID)->buffer,
- ((data_s*)UID)->length);
-
- net_nfc_util_compute_CRC(CRC_B, send_buffer, 9);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 9);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 9;
-
- return net_nfc_client_transceive(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
-
- * http://floralicense.org/license/
- *
- * 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 <glib.h>
-#include <string.h>
-
-#include "net_nfc_client_transceive.h"
-#include "net_nfc_client_tag_internal.h"
-
-#include "net_nfc_tag_mifare.h"
-
-#include "net_nfc_data.h"
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_target_info.h"
-#include "net_nfc_util_internal.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-#define MIFARE_CMD_RAW 0x00U
-#define MIFARE_CMD_AUTH_A 0x60U /**< authenticate with key A */
-#define MIFARE_CMD_AUTH_B 0x61U /**< authenticate with key B */
-#define MIFARE_CMD_READ 0x30U /**< read 16 bytes */
-#define MIFARE_CMD_WRITE_BLOCK 0xA0U /**< write 16 bytes */
-#define MIFARE_CMD_WRITE_PAGE 0xA2U /**< write 4 bytes */
-#define MIFARE_CMD_INCREMENT 0xC1U /**< Increment. */
-#define MIFARE_CMD_DECREMENT 0xC0U /**< Decrement. */
-#define MIFARE_CMD_TRANSFER 0xB0U /**< Tranfer. */
-#define MIFARE_CMD_RESTORE 0xC2U /**< Restore. */
-#define MIFARE_TAG_KEY "UID"
-
-#define MIFARE_CMD_READ_SECTOR 0x38U /* read sector */
-#define MIFARE_CMD_WRITE_SECTOR 0xA8U /* write sector */
-
-static uint8_t default_key[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-static uint8_t mad_key[6] = { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5 };
-static uint8_t net_nfc_forum_key[6] = { 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7 };
-
-#define MIFARE_BLOCK_4 4
-#define MIFARE_BLOCK_16 16
-
-#define MIFARE_MINI_SECTORS 5
-#define MIFARE_1K_SECTORS 16
-#define MIFARE_4K_SECTORS 40
-
-#define MIFARE_BLOCK_SIZE 16 /* 1 block is 16 byte */
-#define MIFARE_PAGE_SIZE 4 /* 1 page is 4 byte */
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyA(
- net_nfc_target_handle_h handle,
- uint8_t sector,
- data_h auth_key,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s *key;
- data_s rawdata;
-
- data_h UID = NULL;
-
- uint8_t* send_buffer = NULL;
- uint8_t* temp = NULL;
-
- int send_buffer_length = 0;
-
- uint8_t sector_to_block = 0;
-
-
- if (handle == NULL || auth_key == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- key = (data_s *)auth_key;
-
- if (key->length != 6)
- return NET_NFC_OUT_OF_BOUND;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info)
- {
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_4K_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE Classic TAG");
- return NET_NFC_NOT_SUPPORTED;
- }
- }
-
- if (net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- MIFARE_TAG_KEY,
- &UID) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- switch (target_info->devType)
- {
- case NET_NFC_MIFARE_MINI_PICC :
- {
- /* 0 ~ 4 : 5 sector and 4 block with 16 bytes */
- if (sector > MIFARE_MINI_SECTORS - 1)
- return NET_NFC_OUT_OF_BOUND;
-
- sector_to_block = sector * MIFARE_BLOCK_4 + 3;
- }
- break;
- case NET_NFC_MIFARE_1K_PICC :
- {
- /* 0 ~ 15 : 16 sector and 4 block with 16 bytes */
- if (sector > MIFARE_1K_SECTORS)
- return NET_NFC_OUT_OF_BOUND;
-
- sector_to_block = sector * MIFARE_BLOCK_4 + 3;
- }
- break;
- case NET_NFC_MIFARE_4K_PICC :
- {
- /* 0 ~ 31 : 32 sector and 4 block with 16 bytes
- * 32 ~ 39 : 8 sector and 16 block with 16 bytes
- */
- if (sector > MIFARE_4K_SECTORS)
- return NET_NFC_OUT_OF_BOUND;
-
- if (sector < 32)
- sector_to_block = sector * MIFARE_BLOCK_4 + 3;
- else
- {
- sector_to_block = (31 * MIFARE_BLOCK_4 + 3)
- + (sector - 32)
- * MIFARE_BLOCK_16 + 15;
- }
- }
- break;
- default :
- break;
- }
-
-
- /* cmd + addr + UID + AUTH_KEY + CRC_A */
- send_buffer_length = 1 + 1 + ((data_s*)UID)->length
- + key->length + 2;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- {
- net_nfc_free_data(UID);
- return NET_NFC_ALLOC_FAIL;
- }
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_AUTH_A;
- temp++;
-
- *temp = sector_to_block;
- temp++;
-
- memcpy(temp, ((data_s*)UID)->buffer, ((data_s*)UID)->length);
- temp = temp + ((data_s*)UID)->length;
-
- memcpy(temp, key->buffer, key->length);
-
- net_nfc_util_compute_CRC(CRC_A, send_buffer, send_buffer_length);
-
-
- rawdata.buffer = send_buffer;
- rawdata.length = send_buffer_length;
-
- net_nfc_error_e result = net_nfc_client_transceive(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
- if (send_buffer != NULL)
- _net_nfc_util_free_mem(send_buffer);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyB(
- net_nfc_target_handle_h handle,
- uint8_t sector,
- data_h auth_key,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s *key;
- data_s rawdata;
-
- data_h UID = NULL;
-
- uint8_t* send_buffer = NULL;
- uint8_t* temp = NULL;
-
- int send_buffer_length = 0;
-
- uint8_t sector_to_block = 0;
-
-
- if (handle == NULL || auth_key == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- key = (data_s *)auth_key;
-
- if (key->length != 6)
- return NET_NFC_OUT_OF_BOUND;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info != NULL)
- {
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_4K_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE Classic TAG");
- return NET_NFC_NOT_SUPPORTED;
- }
- }
-
- if (net_nfc_get_tag_info_value((net_nfc_target_info_h)target_info,
- MIFARE_TAG_KEY,
- &UID) != NET_NFC_OK)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- switch (target_info->devType)
- {
- case NET_NFC_MIFARE_MINI_PICC :
- {
- /* 0 ~ 4 : 5 sector and 4 block with 16 bytes */
- if (sector > MIFARE_MINI_SECTORS)
- return NET_NFC_OUT_OF_BOUND;
-
- sector_to_block = sector * MIFARE_BLOCK_4 + 3;
- }
- break;
- case NET_NFC_MIFARE_1K_PICC :
- {
- /* 0 ~ 15 : 16 sector and 4 block with 16 bytes */
- if (sector > MIFARE_1K_SECTORS)
- return NET_NFC_OUT_OF_BOUND;
-
- sector_to_block = sector * MIFARE_BLOCK_4 + 3;
- }
- break;
- case NET_NFC_MIFARE_4K_PICC :
- {
- /* 0 ~ 31 : 32 sector and 4 block with 16 bytes
- * 32 ~ 39 : 8 sector and 16 block with 16 bytes
- */
- if (sector > MIFARE_4K_SECTORS)
- return NET_NFC_OUT_OF_BOUND;
-
- if (sector < 32)
- sector_to_block = sector * MIFARE_BLOCK_4 + 3;
- else
- {
- sector_to_block = (31 * MIFARE_BLOCK_4 + 3)
- + (sector - 32)
- * MIFARE_BLOCK_16 + 15;
- }
- }
- break;
- default :
- break;
- }
-
- send_buffer_length = 1 + 1 + ((data_s*)UID)->length
- + key->length + 2; /* cmd + addr + UID + AUTH_KEY + CRC_A */
-
- _net_nfc_util_alloc_mem(send_buffer, send_buffer_length
- * sizeof(uint8_t));
- if (send_buffer == NULL)
- {
- net_nfc_free_data(UID);
- return NET_NFC_ALLOC_FAIL;
- }
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_AUTH_B;
- temp++;
-
- *temp = sector_to_block;
- temp++;
-
- memcpy(temp, ((data_s*)UID)->buffer, ((data_s*)UID)->length);
- temp = temp + ((data_s*)UID)->length;
-
- memcpy(temp, key->buffer, key->length);
-
- net_nfc_util_compute_CRC(CRC_A, send_buffer, send_buffer_length);
-
- rawdata.buffer = send_buffer;
- rawdata.length = send_buffer_length;
-
- net_nfc_error_e result = net_nfc_client_transceive(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
- if (send_buffer != NULL)
- _net_nfc_util_free_mem(send_buffer);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_read(net_nfc_target_handle_h handle,
- uint8_t addr,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t send_buffer[2] = { 0 };
-
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info != NULL)
- {
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_ULTRA_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE TAG = [%d]",
- target_info->devType);
- return NET_NFC_NOT_SUPPORTED;
- }
-
- if (target_info->devType == NET_NFC_MIFARE_ULTRA_PICC)
- {
- if (addr > 7)
- return NET_NFC_OUT_OF_BOUND;
- }
- }
-
-
- send_buffer[0] = MIFARE_CMD_READ;
- send_buffer[1] = addr;
-
-
- rawdata.buffer = send_buffer;
- rawdata.length = 2;
-
- return net_nfc_client_transceive_data(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_write_block(
- net_nfc_target_handle_h handle,
- uint8_t addr,
- data_h data,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t* send_buffer = NULL;
-
- uint32_t send_buffer_length = 0;
-
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_ULTRA_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE TAG = [%d] ",
- target_info->devType);
- return NET_NFC_NOT_SUPPORTED;
- }
-
- if (target_info->devType == NET_NFC_MIFARE_ULTRA_PICC)
- {
- if (addr > 7)
- return NET_NFC_OUT_OF_BOUND;
- }
-
- if (target_info->devType == NET_NFC_MIFARE_ULTRA_PICC)
- {
- if (((data_s *)data)->length > MIFARE_PAGE_SIZE)
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page */
- send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_PAGE;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- MIFARE_PAGE_SIZE);
-
- }
- else
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page */
- send_buffer_length = 1 + 1 +
- ((data_s*)data)->length;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_PAGE;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- ((data_s*)data)->length);
- }
-
- }
- else
- {
-
- if (((data_s*)data)->length > MIFARE_BLOCK_SIZE)
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page*/
- send_buffer_length = 1 + 1 + MIFARE_BLOCK_SIZE;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_BLOCK;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- MIFARE_BLOCK_SIZE);
- }
- else
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page */
- send_buffer_length = 1 + 1 + ((data_s*)data)->length;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_BLOCK;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- ((data_s*)data)->length);
- }
- }
-
-
- rawdata.buffer = send_buffer;
- rawdata.length = send_buffer_length;
-
- net_nfc_error_e result = net_nfc_client_transceive(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
- if (send_buffer != NULL)
- _net_nfc_util_free_mem(send_buffer);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_write_page(
- net_nfc_target_handle_h handle,
- uint8_t addr,
- data_h data,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- uint8_t* send_buffer = NULL;
-
- uint32_t send_buffer_length = 0;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info == NULL)
- return NET_NFC_NOT_INITIALIZED;
-
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_ULTRA_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE TAG = [%d] ",
- target_info->devType);
- return NET_NFC_NOT_SUPPORTED;
- }
-
- if (target_info->devType == NET_NFC_MIFARE_ULTRA_PICC)
- {
- if (addr > 7)
- return NET_NFC_OUT_OF_BOUND;
- }
-
- if (target_info->devType == NET_NFC_MIFARE_ULTRA_PICC)
- {
- if (((data_s*)data)->length > MIFARE_PAGE_SIZE)
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page */
- send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_PAGE;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- MIFARE_PAGE_SIZE);
- }
- else
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page */
- send_buffer_length = 1 + 1 + ((data_s*)data)->length;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_PAGE;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- ((data_s*)data)->length);
- }
-
- }
- else
- {
- if (((data_s*)data)->length > MIFARE_PAGE_SIZE)
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page */
- send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_BLOCK;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- MIFARE_PAGE_SIZE);
-
- }
- else
- {
- uint8_t* temp = NULL;
-
- /* cmd + addr + page */
- send_buffer_length = 1 + 1 + ((data_s*)data)->length;
-
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- temp = send_buffer;
-
- *temp = MIFARE_CMD_WRITE_BLOCK;
- temp++;
-
- *temp = addr;
- temp++;
-
- memcpy(temp,
- ((data_s*)data)->buffer,
- ((data_s*)data)->length);
- }
-
- }
-
-
- data_s rawdata;
-
- rawdata.buffer = send_buffer;
- rawdata.length = send_buffer_length;
-
- net_nfc_error_e result = net_nfc_client_transceive(handle,
- (data_h)&rawdata,
- callback,
- user_data);
-
- if (send_buffer != NULL)
- _net_nfc_util_free_mem(send_buffer);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_increment(net_nfc_target_handle_h handle,
- uint8_t addr,
- int value,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t send_buffer[8] = { 0 };
-
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info)
- {
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_4K_PICC)
- {
- DEBUG_CLIENT_MSG(
- "not a MIFARE Classic TAG = [%d]",
- target_info->devType);
- return NET_NFC_NOT_SUPPORTED;
- }
- }
-
-
- send_buffer[0] = MIFARE_CMD_INCREMENT;
- send_buffer[1] = addr;
-
- /* little endian.
- little value of byte array will be saved first in memory */
- send_buffer[5] = (value & 0xFF000000) >> 24;
- send_buffer[4] = (value & 0x00FF0000) >> 16;
- send_buffer[3] = (value & 0x0000FF00) >> 8;
- send_buffer[2] = (value & 0x000000FF);
-
- net_nfc_util_compute_CRC(CRC_A, send_buffer, 8);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 8;
-
- return net_nfc_client_transceive(handle, (data_h)&rawdata, callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_decrement(net_nfc_target_handle_h handle,
- uint8_t addr,
- int value,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t send_buffer[8] = { 0 };
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info)
- {
-
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_4K_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE Classic TAG = [%d] ",
- target_info->devType);
- return NET_NFC_NOT_SUPPORTED;
- }
- }
-
- send_buffer[0] = MIFARE_CMD_DECREMENT;
- send_buffer[1] = addr;
-
- /* little endian.
- little value of byte array will be saved first in memory */
- send_buffer[5] = (value & 0xFF000000) >> 24;
- send_buffer[4] = (value & 0x00FF0000) >> 16;
- send_buffer[3] = (value & 0x0000FF00) >> 8;
- send_buffer[2] = (value & 0x000000FF);
-
- net_nfc_util_compute_CRC(CRC_A, send_buffer, 8);
-
- DEBUG_MSG_PRINT_BUFFER(send_buffer, 8);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 8;
-
- return net_nfc_client_transceive(handle, (data_h)&rawdata, callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_transfer(net_nfc_target_handle_h handle,
- uint8_t addr,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t send_buffer[4] = { 0 };
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info)
- {
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_4K_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE Classic TAG = [%d]",
- target_info->devType);
- return NET_NFC_NOT_SUPPORTED;
- }
- }
-
- send_buffer[0] = MIFARE_CMD_TRANSFER;
- send_buffer[1] = addr;
-
- net_nfc_util_compute_CRC(CRC_A, send_buffer, 4);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 4;
-
- return net_nfc_client_transceive(handle, (data_h)&rawdata, callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_restore(net_nfc_target_handle_h handle,
- uint8_t addr,
- void *callback,
- void *user_data)
-{
- net_nfc_target_info_s* target_info = NULL;
-
- data_s rawdata;
-
- uint8_t send_buffer[4] = { 0 };
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info)
- {
- if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
- target_info->devType > NET_NFC_MIFARE_4K_PICC)
- {
- DEBUG_CLIENT_MSG("not a MIFARE Classic TAG = [%d]",
- target_info->devType);
- return NET_NFC_NOT_SUPPORTED;
- }
- }
-
- send_buffer[0] = MIFARE_CMD_RESTORE;
- send_buffer[1] = addr;
-
- net_nfc_util_compute_CRC(CRC_A, send_buffer, 4);
-
- rawdata.buffer = send_buffer;
- rawdata.length = 4;
-
- return net_nfc_client_transceive(handle, (data_h)&rawdata, callback,
- user_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_create_default_key(data_h* key)
-{
- if (key == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- return net_nfc_create_data(key, default_key, 6);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_create_application_directory_key(
- data_h* key)
-{
- if (key == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- return net_nfc_create_data(key, mad_key, 6);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_mifare_create_net_nfc_forum_key(data_h* key)
-{
- if (key == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- return net_nfc_create_data(key, net_nfc_forum_key, 6);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdbool.h>
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_data.h"
-#include "net_nfc_target_info.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_ndef_message.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_type(net_nfc_target_info_h target_info,
- net_nfc_target_type_e *type)
-{
- net_nfc_target_info_s *target_info_private =
- (net_nfc_target_info_s *)target_info;
-
- if (type == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *type = NET_NFC_UNKNOWN_TARGET;
-
- if (target_info == NULL)
- {
- return NET_NFC_INVALID_HANDLE;
- }
-
- *type = target_info_private->devType;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_handle(net_nfc_target_info_h target_info,
- net_nfc_target_handle_h *handle)
-{
- net_nfc_target_info_s *target_info_private =
- (net_nfc_target_info_s *)target_info;
-
- if (handle == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *handle = NULL;
-
- if (target_info == NULL)
- {
- return NET_NFC_INVALID_HANDLE;
- }
-
- *handle = (net_nfc_target_handle_h)target_info_private->handle;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_ndef_support(net_nfc_target_info_h target_info,
- bool *is_support)
-{
- net_nfc_target_info_s *target_info_private =
- (net_nfc_target_info_s *)target_info;
-
- if (target_info == NULL || is_support == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *is_support = (bool)target_info_private->is_ndef_supported;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_ndef_state(net_nfc_target_info_h target_info,
- net_nfc_ndef_card_state_e *state)
-{
- net_nfc_target_info_s *target_info_private =
- (net_nfc_target_info_s *)target_info;
-
- if (target_info == NULL || state == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *state = (net_nfc_ndef_card_state_e)target_info_private->ndefCardState;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_max_data_size(net_nfc_target_info_h target_info,
- uint32_t *max_size)
-{
- net_nfc_target_info_s *target_info_private =
- (net_nfc_target_info_s *)target_info;
-
- if (target_info == NULL || max_size == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *max_size = target_info_private->maxDataSize;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_actual_data_size(
- net_nfc_target_info_h target_info, uint32_t * actual_data)
-{
- net_nfc_target_info_s *target_info_private =
- (net_nfc_target_info_s *)target_info;
-
- if (target_info == NULL || actual_data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- *actual_data = target_info_private->actualDataSize;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_info,
- char ***keys, int * number_of_keys)
-{
- net_nfc_target_info_s *handle = (net_nfc_target_info_s *)target_info;
- int i = 0;
-
- if (keys == NULL || number_of_keys == NULL || target_info == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (handle->tag_info_list == NULL)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- if (handle->number_of_keys <= 0)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- DEBUG_CLIENT_MSG("number of keys = [%d]", handle->number_of_keys);
-
- if (handle->keylist != NULL)
- {
- *number_of_keys = handle->number_of_keys;
- *keys = handle->keylist;
-
- return NET_NFC_OK;
- }
-
- i = handle->number_of_keys * sizeof(char *);
-
- _net_nfc_util_alloc_mem(*keys, i);
- if (*keys == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- net_nfc_tag_info_s *tag_info = handle->tag_info_list;
-
- for (; i < handle->number_of_keys; i++, tag_info++)
- {
- (*keys)[i] = tag_info->key;
- }
-
- *number_of_keys = handle->number_of_keys;
-
- /* store local context */
- handle->keylist = *keys;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_info_value(net_nfc_target_info_h target_info,
- const char *key, data_h *value)
-{
- net_nfc_target_info_s *handle = (net_nfc_target_info_s *)target_info;
- net_nfc_tag_info_s *tag_info;
-
- if (target_info == NULL || key == NULL || value == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (handle->tag_info_list == NULL)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
-
- int i = 0;
-
- tag_info = handle->tag_info_list;
-
- for (; i < handle->number_of_keys; i++, tag_info++)
- {
- if (strcmp(key, tag_info->key) == 0)
- {
- if (tag_info->value == NULL)
- {
- return NET_NFC_NO_DATA_FOUND;
- }
- else
- {
- *value = tag_info->value;
- break;
- }
- }
- }
-
- if (i == handle->number_of_keys)
- return NET_NFC_NO_DATA_FOUND;
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_get_tag_ndef_message(net_nfc_target_info_h target_info,
- ndef_message_h *msg)
-{
- net_nfc_target_info_s *target_info_private =
- (net_nfc_target_info_s *)target_info;
- net_nfc_error_e result;
-
- if (target_info == NULL || msg == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- result = net_nfc_create_ndef_message_from_rawdata(msg,
- (data_h)&target_info_private->raw_data);
-
- return result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_duplicate_target_info(net_nfc_target_info_h origin,
- net_nfc_target_info_h *result)
-{
- net_nfc_target_info_s *handle = (net_nfc_target_info_s *)origin;
- net_nfc_target_info_s *temp = NULL;
-
- if (handle == NULL || result == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- _net_nfc_util_alloc_mem(temp, sizeof(net_nfc_target_info_s));
- if (temp == NULL)
- {
- return NET_NFC_ALLOC_FAIL;
- }
-
- temp->ndefCardState = handle->ndefCardState;
- temp->actualDataSize = handle->actualDataSize;
- temp->maxDataSize = handle->maxDataSize;
- temp->devType = handle->devType;
- temp->handle = handle->handle;
- temp->is_ndef_supported = handle->is_ndef_supported;
- temp->number_of_keys = handle->number_of_keys;
-
- if (temp->number_of_keys > 0)
- {
- int i;
-
- _net_nfc_util_alloc_mem(temp->tag_info_list, temp->number_of_keys * sizeof(net_nfc_tag_info_s));
- if (temp->tag_info_list == NULL)
- {
- _net_nfc_util_free_mem(temp);
- return NET_NFC_ALLOC_FAIL;
- }
-
- for (i = 0; i < handle->number_of_keys; i++)
- {
- if (handle->tag_info_list[i].key != NULL)
- _net_nfc_util_strdup(temp->tag_info_list[i].key, handle->tag_info_list[i].key);
-
- if (handle->tag_info_list[i].value != NULL)
- {
- data_s *data = (data_s *)handle->tag_info_list[i].value;
-
- net_nfc_create_data(&temp->tag_info_list[i].value, data->buffer, data->length);
- }
- }
- }
-
- if (handle->raw_data.length > 0)
- {
- net_nfc_util_init_data(&temp->raw_data, handle->raw_data.length);
- memcpy(temp->raw_data.buffer, handle->raw_data.buffer, temp->raw_data.length);
- }
-
- *result = (net_nfc_target_info_h)temp;
-
- return NET_NFC_OK;
-}
-
-static net_nfc_error_e _release_tag_info(net_nfc_target_info_s *info)
-{
- net_nfc_tag_info_s *list = NULL;
-
- if (info == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- list = info->tag_info_list;
- if (list != NULL)
- {
- int i;
-
- for (i = 0; i < info->number_of_keys; i++, list++)
- {
- if (list->key != NULL)
- _net_nfc_util_free_mem(list->key);
-
- if (list->value != NULL)
- net_nfc_free_data(list->value);
- }
-
- _net_nfc_util_free_mem(info->tag_info_list);
- }
-
- if (info->keylist != NULL)
- {
- _net_nfc_util_free_mem(info->keylist);
- }
-
- net_nfc_util_clear_data(&info->raw_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_release_tag_info(net_nfc_target_info_h target_info)
-{
- net_nfc_target_info_s *info = (net_nfc_target_info_s *)target_info;
- net_nfc_error_e result;
-
- if (info == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- result = _release_tag_info(info);
-
- _net_nfc_util_free_mem(info);
-
- return result;
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "net_nfc_debug_internal.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_test.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-static void test_call_sim_test_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void test_call_prbs_test_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void test_call_get_firmware_version_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void test_call_set_ee_data_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void test_call_ese_test_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static NetNfcGDbusTest *test_proxy = NULL;
-
-
-static void test_call_sim_test_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_test_call_sim_test_finish(
- NET_NFC_GDBUS_TEST(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish sim_test: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_test_sim_test_completed callback =
- (net_nfc_client_test_sim_test_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void test_call_prbs_test_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_test_call_prbs_test_finish(
- NET_NFC_GDBUS_TEST(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish prbs test: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_test_prbs_test_completed callback =
- (net_nfc_client_test_prbs_test_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void test_call_get_firmware_version_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- gchar *out_version = NULL;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_test_call_get_firmware_version_finish(
- NET_NFC_GDBUS_TEST(source_object),
- (gint *)&out_result,
- &out_version,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish get_firmware_version: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_test_get_firmware_version_completed callback =
- (net_nfc_client_test_get_firmware_version_completed)func_data->callback;
-
- callback(out_result, out_version, func_data->user_data);
- }
-
- g_free(out_version);
- g_free(func_data);
-}
-
-static void test_call_set_ee_data_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_test_call_set_ee_data_finish(
- NET_NFC_GDBUS_TEST(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish set_ee_data: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_test_set_ee_data_completed callback =
- (net_nfc_client_test_set_ee_data_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-static void test_call_ese_test_callback(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_test_call_ese_test_finish(
- NET_NFC_GDBUS_TEST(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish sim_test: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- net_nfc_client_test_ese_test_completed callback =
- (net_nfc_client_test_ese_test_completed)func_data->callback;
-
- callback(out_result, func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_sim_test(
- net_nfc_client_test_sim_test_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_test_call_sim_test(test_proxy,
- NULL,
- test_call_sim_test_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_sim_test_sync(void)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_test_call_sim_test_sync(test_proxy,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call SimTest: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_prbs_test(uint32_t tech,
- uint32_t rate,
- net_nfc_client_test_prbs_test_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_test_call_prbs_test(test_proxy,
- tech,
- rate,
- NULL,
- test_call_prbs_test_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_prbs_test_sync(uint32_t tech,
- uint32_t rate)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_test_call_prbs_test_sync(test_proxy,
- tech,
- rate,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call PrbsTest: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_get_firmware_version(
- net_nfc_client_test_get_firmware_version_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_test_call_get_firmware_version(test_proxy,
- NULL,
- test_call_get_firmware_version_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_get_firmware_version_sync(char **version)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- gchar *out_version = NULL;
- GError *error = NULL;
-
- if (version == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- *version = NULL;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_test_call_get_firmware_version_sync(test_proxy,
- (gint *)&out_result,
- &out_version,
- NULL,
- &error) == TRUE)
- {
- *version = out_version;
- }
- else
- {
- DEBUG_ERR_MSG("can not call Get Firmware version: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_set_ee_data(int mode,
- int reg_id,
- data_h data,
- net_nfc_client_test_set_ee_data_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
- GVariant *variant;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL) {
- return NET_NFC_ALLOC_FAIL;
- }
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- variant = net_nfc_util_gdbus_data_to_variant((data_s *)data);
-
- net_nfc_gdbus_test_call_set_ee_data(test_proxy,
- mode,
- reg_id,
- variant,
- NULL,
- test_call_set_ee_data_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_set_ee_data_sync(int mode,
- int reg_id,
- data_h data)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GVariant *variant = NULL;
- GError *error = NULL;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- variant = net_nfc_util_gdbus_data_to_variant((data_s *)data);
-
- if (net_nfc_gdbus_test_call_set_ee_data_sync(test_proxy,
- mode,
- reg_id,
- variant,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call SetEeTest: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_ese_test(
- net_nfc_client_test_ese_test_completed callback,
- void *user_data)
-{
- NetNfcCallback *func_data;
-
- DEBUG_CLIENT_MSG("NFC ESE Test!!!!");
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- func_data = g_try_new0(NetNfcCallback, 1);
- if (func_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- func_data->callback = (gpointer)callback;
- func_data->user_data = user_data;
-
- net_nfc_gdbus_test_call_ese_test(test_proxy,
- NULL,
- test_call_ese_test_callback,
- func_data);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_ese_test_sync(void)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
-
- DEBUG_CLIENT_MSG("NFC ESE Test SYNC!!!!");
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_test_call_ese_test_sync(test_proxy,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call ESE Test: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_set_se_tech_type_sync(
- net_nfc_se_type_e type, int tech)
-{
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_test_call_set_se_tech_type_sync(test_proxy,
- (guint32)type,
- (guint32)tech,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call SetSeTechType: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_test_set_listen_tech_mask_sync(uint32_t tech)
-{
- net_nfc_error_e result = NET_NFC_OK;
- GError *error = NULL;
-
- DEBUG_CLIENT_MSG("net_nfc_client_test_set_listen_tech_mask_sync start");
-
- if (test_proxy == NULL)
- {
- if(net_nfc_client_test_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("test_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- if (net_nfc_gdbus_test_call_set_listen_tech_mask_sync(test_proxy,
- tech,
- &result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("can not call listen tech mask: %s",
- error->message);
- result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return result;
-}
-
-
-net_nfc_error_e net_nfc_client_test_init(void)
-{
- GError *error = NULL;
-
- if (test_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- test_proxy = net_nfc_gdbus_test_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Test",
- NULL,
- &error);
- if (test_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_test_deinit(void)
-{
- if (test_proxy)
- {
- g_object_unref(test_proxy);
- test_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <string.h>
-
-#include "net_nfc_typedef_internal.h"
-#include "net_nfc_debug_internal.h"
-#include "net_nfc_util_internal.h"
-#include "net_nfc_util_gdbus_internal.h"
-#include "net_nfc_gdbus.h"
-#include "net_nfc_client.h"
-#include "net_nfc_client_util_internal.h"
-#include "net_nfc_client_manager.h"
-#include "net_nfc_client_tag_internal.h"
-#include "net_nfc_client_transceive.h"
-
-#ifndef NET_NFC_EXPORT_API
-#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
-#endif
-
-static NetNfcGDbusTransceive *transceive_proxy = NULL;
-
-static GVariant *transceive_data_to_transceive_variant(
- net_nfc_target_type_e dev_type,
- data_s *data);
-
-static void transceive_call(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static void transceive_data_call(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-static GVariant *transceive_data_to_transceive_variant(
- net_nfc_target_type_e devType,
- data_s *data)
-{
- data_s transceive_info = { NULL, };
- GVariant *variant;
-
- if (data == NULL)
- {
- DEBUG_ERR_MSG("data is empty");
-
- return NULL;
- }
-
- switch (devType)
- {
- case NET_NFC_MIFARE_MINI_PICC :
- case NET_NFC_MIFARE_1K_PICC :
- case NET_NFC_MIFARE_4K_PICC :
- case NET_NFC_MIFARE_ULTRA_PICC :
- if (net_nfc_util_init_data(&transceive_info,
- data->length + 2) == true)
- {
- memcpy(transceive_info.buffer,
- data->buffer,
- data->length);
-
- net_nfc_util_compute_CRC(CRC_A,
- transceive_info.buffer,
- transceive_info.length);
- }
- break;
-
- case NET_NFC_JEWEL_PICC :
- if (data->length > 9)
- {
- DEBUG_ERR_MSG("data length is larger than 9");
-
- return NULL;
- }
-
- if (net_nfc_util_init_data(&transceive_info, 9) == true)
- {
- memcpy(transceive_info.buffer,
- data->buffer,
- data->length);
-
- net_nfc_util_compute_CRC(CRC_B,
- transceive_info.buffer,
- transceive_info.length);
- }
- break;
-
- default :
- if(net_nfc_util_init_data(&transceive_info,
- data->length) == true)
- {
- memcpy(transceive_info.buffer,
- data->buffer,
- data->length);
- }
- break;
- }
-
- variant = net_nfc_util_gdbus_data_to_variant(&transceive_info);
-
- net_nfc_util_clear_data(&transceive_info);
-
- return variant;
-}
-
-static void transceive_data_call(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GVariant *out_data = NULL;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_transceive_call_transceive_data_finish(
- NET_NFC_GDBUS_TRANSCEIVE(source_object),
- (gint *)&out_result,
- &out_data,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish transceive: %s", error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- data_s resp = { NULL, };
-
- net_nfc_util_gdbus_variant_to_data_s(out_data, &resp);
-
- ((nfc_transceive_data_callback)func_data->callback)(
- out_result,
- &resp,
- func_data->user_data);
-
- net_nfc_util_clear_data(&resp);
- }
-
- g_free(func_data);
-}
-
-static void transceive_call(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
- GError *error = NULL;
-
- g_assert(user_data != NULL);
-
- if (net_nfc_gdbus_transceive_call_transceive_finish(
- NET_NFC_GDBUS_TRANSCEIVE(source_object),
- (gint *)&out_result,
- res,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not finish transceive: %s", error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (func_data->callback != NULL)
- {
- ((nfc_transceive_callback)func_data->callback)(
- out_result,
- func_data->user_data);
- }
-
- g_free(func_data);
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_h handle,
- data_h rawdata,
- nfc_transceive_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s *target_info;
- NetNfcCallback *funcdata;
- GVariant *arg_data;
-
- if (transceive_proxy == NULL)
- {
- if(net_nfc_client_transceive_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("transceive_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
- return NET_NFC_NOT_CONNECTED;
-
- DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
-
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL) {
- return NET_NFC_INVALID_PARAM;
- }
-
- funcdata = g_try_new0(NetNfcCallback, 1);
- if (funcdata == NULL) {
- g_variant_unref(arg_data);
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- funcdata->callback = (gpointer)callback;
- funcdata->user_data = user_data;
-
- net_nfc_gdbus_transceive_call_transceive(transceive_proxy,
- GPOINTER_TO_UINT(handle),
- target_info->devType,
- arg_data,
- NULL,
- transceive_call,
- funcdata);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_h handle,
- data_h rawdata,
- nfc_transceive_data_callback callback,
- void *user_data)
-{
- net_nfc_target_info_s *target_info;
- NetNfcCallback *funcdata;
- GVariant *arg_data;
-
- if (transceive_proxy == NULL)
- {
- if(net_nfc_client_transceive_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("transceive_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
- return NET_NFC_NOT_CONNECTED;
-
- DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
-
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL) {
- return NET_NFC_INVALID_PARAM;
- }
-
- funcdata = g_try_new0(NetNfcCallback, 1);
- if (funcdata == NULL) {
- g_variant_unref(arg_data);
-
- return NET_NFC_ALLOC_FAIL;
- }
-
- funcdata->callback = (gpointer)callback;
- funcdata->user_data = user_data;
-
- net_nfc_gdbus_transceive_call_transceive_data(transceive_proxy,
- GPOINTER_TO_UINT(handle),
- target_info->devType,
- arg_data,
- NULL,
- transceive_data_call,
- funcdata);
-
- return NET_NFC_OK;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_h handle,
- data_h rawdata)
-{
- net_nfc_target_info_s *target_info;
- net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
- GVariant *arg_data;
-
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (transceive_proxy == NULL)
- {
- if(net_nfc_client_transceive_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("transceive_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
- return NET_NFC_NOT_CONNECTED;
-
- DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
-
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- if (net_nfc_gdbus_transceive_call_transceive_sync(transceive_proxy,
- GPOINTER_TO_UINT(handle),
- target_info->devType,
- arg_data,
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Transceive (sync call) failed: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- return out_result;
-}
-
-NET_NFC_EXPORT_API
-net_nfc_error_e net_nfc_client_transceive_data_sync(
- net_nfc_target_handle_h handle,
- data_h rawdata,
- data_h *response)
-{
- net_nfc_target_info_s *target_info;
- net_nfc_error_e out_result = NET_NFC_OK;
- GVariant *out_data = NULL;
- GError *error = NULL;
- GVariant *arg_data;
-
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (transceive_proxy == NULL)
- {
- if(net_nfc_client_transceive_init() != NET_NFC_OK)
- {
- DEBUG_ERR_MSG("transceive_proxy fail");
- return NET_NFC_NOT_INITIALIZED;
- }
- }
-
- /* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_NOT_ACTIVATED;
- }
-
- target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
- return NET_NFC_NOT_CONNECTED;
-
- DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
-
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL)
- return NET_NFC_ALLOC_FAIL;
-
- if (net_nfc_gdbus_transceive_call_transceive_data_sync(
- transceive_proxy,
- GPOINTER_TO_UINT(handle),
- target_info->devType,
- arg_data,
- (gint *)&out_result,
- &out_data,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Transceive (sync call) failed: %s",
- error->message);
- out_result = NET_NFC_IPC_FAIL;
-
- g_error_free(error);
- }
-
- if (response && out_data != NULL)
- {
- *response = net_nfc_util_gdbus_variant_to_data(out_data);
- }
-
- return out_result;
-}
-
-
-net_nfc_error_e net_nfc_client_transceive_init(void)
-{
- GError *error = NULL;
-
- if (transceive_proxy)
- {
- DEBUG_CLIENT_MSG("Already initialized");
-
- return NET_NFC_OK;
- }
-
- transceive_proxy = net_nfc_gdbus_transceive_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.tizen.NetNfcService",
- "/org/tizen/NetNfcService/Transceive",
- NULL,
- &error);
- if (transceive_proxy == NULL)
- {
- DEBUG_ERR_MSG("Can not create proxy : %s", error->message);
- g_error_free(error);
-
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- return NET_NFC_OK;
-}
-
-void net_nfc_client_transceive_deinit(void)
-{
- if (transceive_proxy)
- {
- g_object_unref(transceive_proxy);
- transceive_proxy = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <stdlib.h>
-#include <string.h>
-
-#include "net_nfc_client_util_internal.h"
-
+++ /dev/null
-prefix=/usr
-exec_prefix=${prefix}/bin
-libdir=@LIB_INSTALL_DIR@
-includedir=${prefix}/include
-
-Name: nfc
-Description: NFC
-Version: $version
-Requires:
-Libs: -lnfc
-Cflags: -I/usr/include/nfc
\ No newline at end of file
include/net_nfc_util_handover.h
include/net_nfc_util_ndef_record.h
include/net_nfc_util_sign_record.h
+ include/net_nfc_debug_internal.h
+ include/net_nfc_util_gdbus_internal.h
+ net_nfc_gdbus.h
+ include/net_nfc_util_defines.h
+ include/net_nfc_util_hce.h
)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${NFC_COMMON_LIB}.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/${NFC_COMMON_LIB}.pc)
ADD_EXECUTABLE(${NFC_MANAGER_DAEMON} ${MANAGER_SRCS})
-TARGET_LINK_LIBRARIES(${NFC_MANAGER_DAEMON} ${manager_pkges_LDFLAGS} pthread dl rt nfc-common-lib nfc)
+TARGET_LINK_LIBRARIES(${NFC_MANAGER_DAEMON} ${manager_pkges_LDFLAGS} pthread dl rt nfc-common-lib)
LINK_DIRECTORIES(${CMAKE_BUILD_DIR}/src/commonlib ${CMAKE_BUILD_DIR}/src/clientlib)
INSTALL(TARGETS ${NFC_MANAGER_DAEMON} DESTINATION bin)
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
-SET (this_target cardemulation_plugin)
-SET (this_target_2 useese_plugin)
-
-SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
-include_directories(${CMAKE_SOURCE_DIR}/src/commonlib/include)
-include_directories(${CMAKE_SOURCE_DIR}/src/clientlib/include)
-#include_directories(${CMAKE_SOURCE_DIR}/src/clientlib)
-
-#INCLUDE(FindPkgConfig)
-#pkg_check_modules(pkg REQUIRED glib-2.0 dlog libxml-2.0)
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs_plugin REQUIRED
- glib-2.0
- pkgmgr-info
- libxml-2.0
- dlog
- syspopup-caller
-)
-
-FOREACH(flag ${pkgs_plugin_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET (${this_target}_SOURCE_FILES
- pkgmgr_plugin_cardemulation.c
-)
-SET (${this_target_2}_SOURCE_FILES
- pkgmgr_plugin_useese.c
-)
-
-ADD_DEFINITIONS("-DDLOG_ERROR_ENABLED")
-ADD_DEFINITIONS("-DLOG_TAG=\"CARDEMULATION_PLUGIN\"")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" )
-
-SET(CMAKE_C_FLAGS_PROFILING " -g -pg")
-SET(CMAKE_CXX_FLAGS_PROFILING " -std=c++0x -g -pg")
-SET(CMAKE_C_FLAGS_DEBUG " -g")
-SET(CMAKE_CXX_FLAGS_DEBUG " -std=c++0x -g")
-SET(CMAKE_C_FLAGS_RELEASE " -g")
-SET(CMAKE_CXX_FLAGS_RELEASE " -std=c++0x -g")
-SET(CMAKE_C_FLAGS_CCOV " -g --coverage")
-SET(CMAKE_CXX_FLAGS_CCOV " -std=c++0x -g --coverage")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -std=gnu99")
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -Wl,-zdefs")
-
-SET(ARM_CFLAGS "${ARM_CLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic")
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-
-
-## Create Library
-ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES} )
-ADD_LIBRARY (${this_target_2} SHARED ${${this_target_2}_SOURCE_FILES} )
-## SET LINKER FLAGS
-#SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
-
-TARGET_LINK_LIBRARIES(${this_target} ${pkgs_plugin_LDFLAGS} nfc)
-TARGET_LINK_LIBRARIES(${this_target_2} ${pkgs_plugin_LDFLAGS} nfc)
-
-INSTALL(TARGETS ${this_target} DESTINATION "/usr/etc/package-manager/parserlib/metadata")
-INSTALL(TARGETS ${this_target_2} DESTINATION "/usr/etc/package-manager/parserlib/metadata")
-
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <pkgmgr-info.h>
-#include <glib.h>
-#include <string.h>
-#include <libxml/parser.h>
-#include <dlog.h>
-#include <syspopup_caller.h>
-#include <bundle_internal.h>
-
-#include "net_nfc.h"
-
-#define DBG(fmt, args ...) \
- do { \
- LOGD(fmt, ## args); \
- } while (0)
-
-#ifndef PKGMGR_MODULE_API
-#define PKGMGR_MODULE_API __attribute__ ((visibility("default")))
-#endif
-
-typedef struct metadata {
- const char *key;
- const char *value;
-} metadata;
-
-int _nfc_register_aid(char *xml_path, const char *pkgid)
-{
- xmlChar *key = NULL;
- int ret = 0;
- char *aid = NULL;
- net_nfc_se_type_e se_type;
- bool unlock_required;
- int power;
- net_nfc_card_emulation_category_t category;
- xmlNodePtr pRoot, pCurrentElement;
- char **conflict_handlers = NULL;
-
- DBG(">>>>");
- fprintf(stderr, "[NFC CARD EMUL] _nfc_register_aid >>>>>>>>\n");
-
- xmlDocPtr pDocument = xmlParseFile(xml_path);
- if (pDocument == NULL) {
- DBG("xmlDocPtr conversion failed.");
- return NET_NFC_OPERATION_FAIL;
- }
-
- pRoot = xmlDocGetRootElement(pDocument);
- if (pRoot == NULL) {
- DBG(" Empty document");
- xmlFreeDoc(pDocument);
- return NET_NFC_OPERATION_FAIL;
- }
-
- for (pCurrentElement = pRoot->children; pCurrentElement; pCurrentElement = pCurrentElement->next) {
- if (pCurrentElement->type == XML_ELEMENT_NODE) {
- if (!(xmlStrcmp(pCurrentElement->name, (const xmlChar *) "wallet"))) {
- xmlNodePtr pSubElement;
-
- DBG("wallet element found...");
-
- for (pSubElement = pCurrentElement->children; pSubElement; pSubElement = pSubElement->next) {
- if (pSubElement->type == XML_ELEMENT_NODE) {
- if (!(xmlStrcmp(pSubElement->name, (const xmlChar *) "aid-group"))) {
-
- DBG("aid-group element found...");
-
- key = xmlGetProp(pSubElement, (const xmlChar*)"category");
- if (key != NULL) {
- xmlNodePtr pAidElement;
-
- DBG( "category : %s, ", (char *)key);
-
- if (strcasecmp((char*)key, "payment") == 0) {
- category = NET_NFC_CARD_EMULATION_CATEGORY_PAYMENT;
- }
- else if (strcasecmp((char*)key, "other") == 0) {
- category = NET_NFC_CARD_EMULATION_CATEGORY_OTHER;
- }
- else {
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
- xmlFree(key);
- key = NULL;
-
- //parsing property
- for (pAidElement = pSubElement->children; pAidElement; pAidElement = pAidElement->next) {
- if (pAidElement->type == XML_ELEMENT_NODE) {
- if (!(xmlStrcmp(pAidElement->name, (const xmlChar *) "aid"))) {
- key = xmlGetProp(pAidElement, (const xmlChar*)"aid");
- if (key != NULL) {
- DBG("aid : %s, ", (char *)key);
- aid = strdup((char*)key);
- xmlFree(key);
- key = NULL;
- }
- else {
- DBG("aid is null");
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
-
- key = xmlGetProp(pAidElement, (const xmlChar*)"se_type");
- if (key != NULL) {
- DBG("se_type : %s, ", (char *)key);
- if (strcasecmp((char*)key, "ese") == 0) {
- se_type = NET_NFC_SE_TYPE_ESE;
- }
- else if (strcasecmp((char*)key, "uicc") == 0) {
- se_type = NET_NFC_SE_TYPE_UICC;
- }
- else if (strcasecmp((char*)key, "hce") == 0) {
- se_type = NET_NFC_SE_TYPE_HCE;
- }
- else {
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
- xmlFree(key);
- key = NULL;
- }
- else {
- DBG("se_type is null");
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
-
- key = xmlGetProp(pAidElement, (const xmlChar*)"unlock");
- if (key != NULL) {
- DBG("unlock : %s, ", (char *)key);
- if (strcasecmp((char*)key, "true") == 0) {
- unlock_required = true;
- }
- else if (strcasecmp((char*)key, "false") == 0) {
- unlock_required = false;
- }
- else {
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
- xmlFree(key);
- key = NULL;
- }
- else {
- DBG( "unlock is null");
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
-
- key = xmlGetProp(pAidElement, (const xmlChar*)"power");
- if (key != NULL) {
- DBG("power : %s, ", (char *)key);
- if (strcasecmp((char*)key, "on") == 0) {
- power = unlock_required ? 0x29 : 0x39;
- }
- else if (strcasecmp((char*)key, "off") == 0) {
- power = unlock_required ? 0x2B : 0x3B;
- }
- else if (strcasecmp((char*)key, "sleep") == 0) {
- power = unlock_required ? 0x29 : 0x39;
- }
- else {
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
- xmlFree(key);
- key = NULL;
- }
- else {
- DBG("power is null");
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
-
- ret = net_nfc_client_se_add_route_aid_sync(pkgid, se_type, category, aid, unlock_required, power);
- if (ret == NET_NFC_DATA_CONFLICTED) {
- if (conflict_handlers == NULL) {
- ret = net_nfc_client_se_get_conflict_handlers_sync(pkgid, category, aid, &conflict_handlers);
- if (ret == NET_NFC_DATA_CONFLICTED) {
- DBG("conflicted aid [%s], [%s]", aid, conflict_handlers[0]);
- } else {
- DBG("net_nfc_client_se_get_conflict_handlers_sync failed, [%d]", ret);
- }
- } else {
- DBG("skip more conflict");
- }
- } else if (ret == NET_NFC_OK) {
- DBG("net_nfc_client_se_add_route_aid_sync() result : [%d]", ret);
- }
-
- free(aid);
- aid = NULL;
- }
- }
- }
- }
- else {
- DBG("category is null");
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
- }
- else {
- DBG("cannot find aid-group element : %s", (char*)pSubElement->name);
- ret = NET_NFC_NO_DATA_FOUND;
- goto ERROR;
- }
- }
- }
- }
- else {
- DBG("cannot find wallet element : %s", (char*)pCurrentElement->name);
- ret = NET_NFC_NO_DATA_FOUND;
- }
- }
- }
-
- xmlUnlinkNode(pRoot);
- xmlFreeNode(pRoot);
- xmlFreeDoc(pDocument);
-
- if (conflict_handlers != NULL) {
- bundle *b;
-
- DBG("launch popup");
-
- b = bundle_create();
-
- bundle_add(b, "package", pkgid);
- bundle_add_str_array(b, "conflict",
- (const char **)conflict_handlers,
- g_strv_length(conflict_handlers));
-
- ret = syspopup_launch("nfc-syspopup", b);
- DBG("syspopup_launch result [%d]", ret);
-
- bundle_free(b);
-
- g_strfreev(conflict_handlers);
-
- ret = NET_NFC_OK;
- }
-
- DBG("<<<<");
-
- return ret;
-
-ERROR:
- net_nfc_client_se_remove_package_aids_sync(pkgid);
-
- if (conflict_handlers != NULL) {
- g_strfreev(conflict_handlers);
- }
-
- if (aid != NULL) {
- free(aid);
- }
-
- if (key != NULL) {
- xmlFree(key);
- }
-
- xmlUnlinkNode(pRoot);
- xmlFreeNode(pRoot);
- xmlFreeDoc(pDocument);
-
- return ret;
-}
-
-static void __build_full_path(const char *prefix, const char *tail,
- char *output, size_t out_len)
-{
- size_t len;
-
- /* add tail slash */
- len = strlen(prefix);
- if (len > 0) {
- len = snprintf(output, out_len, "%s", prefix);
- if (len > 0 && len < out_len - 1 && output[len - 1] != '/') {
- output[len] = '/';
- output[len + 1] = '\0';
- len++;
- }
- }
-
- if (strlen(tail) > 0) {
- if (len > 0) {
- const char *buf2;
-
- if (tail[0] == '/') {
- buf2 = tail + 1;
- } else {
- buf2 = tail;
- }
-
- strncat(output + len, buf2, out_len - len - 1);
- output[out_len - 1] = '\0';
- } else {
- snprintf(output, out_len, "%s", tail);
- }
- }
-}
-
-static int __install(const char *pkgid, const char *appid, GList *md_list)
-{
- GList *list;
- pkgmgrinfo_pkginfo_h handle = NULL;
- int ret;
- char *path = NULL;
- char buf[1024] = { 0, };
- metadata *detail;
-
- fprintf(stderr, "[NFC CARD EMUL] __install >>>>>>>>\n");
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
- if (ret != 0) {
- DBG("pkgmgrinfo_pkginfo_get_pkginfo() [%d]", ret);
- fprintf(stderr, "[NFC CARD EMUL] pkgmgrinfo_pkginfo_get_pkginfo failed [%d]\n", ret);
- goto END;
- }
-
-
- ret = pkgmgrinfo_pkginfo_get_root_path(handle, &path);
- if (ret != 0) {
- DBG("pkgmgrinfo_pkginfo_get_root_path() [%d]", ret);
- fprintf(stderr, "[NFC CARD EMUL] pkgmgrinfo_pkginfo_get_root_path failed [%d]\n", ret);
- goto END;
- }
-
- DBG("pkgid [%s]", pkgid);
- DBG("root path [%s]", path);
-
- //get xml path from metadata
- list = g_list_first(md_list);
- detail = (metadata*)list->data;
- DBG("key = %s, value = %s", detail->key, detail->value);
-
- /* add tail slash */
- __build_full_path(path, detail->value, buf, sizeof(buf));
- DBG("full path = %s", buf);
-
- ret = _nfc_register_aid(buf, pkgid);
- DBG("_nfc_register_aid() [%d]", ret);
-
-END :
- if (!handle) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- }
-
- return ret;
-}
-
-static int __uninstall(const char *pkgid, const char *appid, GList *md_list)
-{
- int ret;
-
- fprintf(stderr, "[NFC CARD EMUL] __uninstall >>>>>>>>\n");
-
- ret = net_nfc_client_se_remove_package_aids_sync(pkgid);
- DBG("net_nfc_client_se_remove_route_aid_sync() [%d]", ret);
-
- return ret;
-}
-
-PKGMGR_MODULE_API
-int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *md_list)
-{
- int ret;
-
- DBG("PKGMGR_MDPARSER_PLUGIN_INSTALL called");
-
- fprintf(stderr, "[NFC CARD EMUL] INSTALL >>>>>>>>\n");
-
- ret = net_nfc_client_initialize();
- if (ret != 0) {
- DBG("net_nfc_client_initialize() [%d]", ret);
-
- fprintf(stderr, "[NFC CARD EMUL] net_nfc_client_initialize failed [%d]\n", ret);
- return ret;
- }
-
- ret = __install(pkgid, appid, md_list);
-
- net_nfc_client_deinitialize();
-
- return ret;
-}
-
-
-PKGMGR_MODULE_API
-int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList *md_list)
-{
- int ret;
-
- DBG("PKGMGR_MDPARSER_PLUGIN_UNINSTALL called");
-
- fprintf(stderr, "[NFC CARD EMUL] UNINSTALL >>>>>>>>\n");
-
- ret = net_nfc_client_initialize();
- if (ret != 0) {
- DBG("net_nfc_client_initialize() [%d]", ret);
- fprintf(stderr, "[NFC CARD EMUL] net_nfc_client_initialize failed [%d]\n", ret);
- return ret;
- }
-
- ret = __uninstall(pkgid, appid, md_list);
-
- net_nfc_client_deinitialize();
-
- return ret;
-}
-
-PKGMGR_MODULE_API
-int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgid, const char *appid, GList *list)
-{
- int ret;
-
- DBG("PKGMGR_MDPARSER_PLUGIN_UPGRADE called");
-
- fprintf(stderr, "[NFC CARD EMUL] UPGRADE >>>>>>>>");
-
- ret = net_nfc_client_initialize();
- if (ret != 0) {
- DBG("net_nfc_client_initialize() [%d]", ret);
- fprintf(stderr, "[NFC CARD EMUL] net_nfc_client_initialize failed [%d]\n", ret);
- return ret;
- }
-
- ret = __uninstall(pkgid, appid, list);
- if (ret != 0) {
- DBG("__uninstall() [%d]", ret);
- } else {
- DBG("__uninstall() success");
- }
-
- ret = __install(pkgid, appid, list);
- if (ret != 0) {
- DBG("__install() [%d]", ret);
- } else {
- DBG("__install() success");
- }
-
- net_nfc_client_deinitialize();
-
- return ret;
-}
+++ /dev/null
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 <pkgmgr-info.h>
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <dlog.h>
-#include <sys/stat.h>
-#include <unistd.h>
-//#include <sys/types.h>
-//#include <syspopup_caller.h>
-
-//#include "net_nfc.h"
-
-#define CSA_USEESE_PATH "/csa/useese"
-#define CSA_USEESE_FILE_PATH "/csa/useese/aid.dat"
-#define DBG(fmt, args ...) \
- do { \
- LOGD(fmt, ## args); \
- } while (0)
-
-#ifndef PKGMGR_MODULE_API
-#define PKGMGR_MODULE_API __attribute__ ((visibility("default")))
-#endif
-
-typedef struct metadata {
- const char *key;
- const char *value;
-} metadata;
-
-static GList *list;
-static GList *list_metadata;
-
-static int __add_aid_to_csa(const char *aid_string)
-{
- int res = 0;
- const int filePerm = 0777;
- int fd = -1;
- int writeLen = 0;
- char buf[1024 + 1];
- int count = 0;
- struct stat stat_buf;
- const char tk = ';';
- const char newline = '\n';
- char *token = NULL;
- char *token_metadata = NULL;
- int token_counter = 0;
- int metadata_token_counter = 0;
- int i = 0;
-
- memset(&stat_buf, 0, sizeof(struct stat));
-
- if (stat(CSA_USEESE_PATH, &stat_buf) < 0) {
- if (mkdir(CSA_USEESE_PATH, filePerm) == 0) {
- DBG("mkdir sucess!!!!!");
- res = chmod("/csa/useese", 0777);
- if(res < 0) {
- DBG("fail chmod /csa/useese");
- return -1;
- }
- }
- else {
- DBG("mkdir error");
- return -1;
- }
- }
-
- //get aid list from csa
- fd = open(CSA_USEESE_FILE_PATH, 00000002 | 00000100, filePerm);
- if (fd >= 0) {
- count = read(fd, buf, 1024);
- ///////////
- if (count > 0 && count <= 1024) {
- while (count > 0 && buf[count - 1] == '\n')
- count--;
- buf[count] = '\0';
- } else {
- buf[0] = '\0';
- }
- close(fd);
- }
- ///////////
- DBG("count : %d", count);
- if (count > 0) {
- token = strtok(buf, ";");
- while(token) {
- DBG("Token[%d] : %s", token_counter, token);
- list = g_list_append(list, strdup(token));
- token_counter++;
- token = strtok(NULL, ";");
- }
- }
-
- //get aid list from metadata
- char *aids = strdup(aid_string);
- token_metadata = strtok(aids, ";");
- while(token_metadata) {
- DBG("Metadata Token[%d] : %s", metadata_token_counter, token);
- list_metadata = g_list_append(list_metadata, strdup(token_metadata));
- metadata_token_counter++;
- token_metadata = strtok(NULL, ";");
- }
- //csa vs metadata value
- for (i = 0; i < g_list_length(list_metadata); i++) {
- GList* node;
- node = g_list_nth(list_metadata, i);
- DBG("[%d]th metadata value is %s", i, (char*)node->data);
-
- if (g_list_find_custom(list, (char*)node->data, (GCompareFunc)strcmp)) {
- DBG("AID [%s] is already exist!", (char*)node->data);
- }
- else {
- DBG("AID [%s] will be added to csa", (char*)node->data);
- list = g_list_append(list, strdup((char*)node->data));
- }
- }
-
- //re-write the final aid list
- fd = open(CSA_USEESE_FILE_PATH, 00000002 | 00000100, filePerm);
- if (fd >= 0) {
- for (i = 0; i < g_list_length(list); i++) {
- GList* node;
- node = g_list_nth(list, i);
- DBG("[%d]th list value is %s", i, (char*)node->data);
-
- writeLen = write(fd, (char*)node->data, strlen((char*)node->data));
- DBG("write to csa file : %d", writeLen);
- writeLen = write(fd, &tk, 1); //temp
- DBG("write to csa file : %d", writeLen);
- }
- writeLen = write(fd, &newline, 1); //temp
- DBG("write to csa file : %d", writeLen);
-
- close(fd);
- }
-
- free(aids);
-
- return res;
-}
-
-static int __install(const char *pkgid, const char *appid, GList *md_list)
-{
- GList *list;
- pkgmgrinfo_pkginfo_h handle = NULL;
- int ret;
- char *path = NULL;
- metadata *detail;
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
- if (ret != 0) {
- DBG("pkgmgrinfo_pkginfo_get_pkginfo() [%d]", ret);
- goto END;
- }
-
- ret = pkgmgrinfo_pkginfo_get_root_path(handle, &path);
- if (ret != 0) {
- DBG("pkgmgrinfo_pkginfo_get_root_path() [%d]", ret);
- goto END;
- }
-
- DBG("pkgid [%s]", pkgid);
- DBG("root path [%s]", path);
-
- //get xml path from metadata
- list = g_list_first(md_list);
- detail = (metadata*)list->data;
- DBG("key = %s, value = %s", detail->key, detail->value);
-
- /* add tail slash */
- ret = __add_aid_to_csa(detail->value);
- DBG("__add_aid_to_csa() result : %d", ret);
-
-// ret = _nfc_register_aid(buf, pkgid);
-// DBG("_nfc_register_aid() [%d]", ret);
-
-END :
- if (!handle) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- }
-
- return ret;
-}
-
-static int __uninstall(const char *pkgid, const char *appid, GList *md_list)
-{
- int ret = 0;
-
-// ret = net_nfc_client_se_remove_package_aids_sync(pkgid);
-// DBG("net_nfc_client_se_remove_route_aid_sync() [%d]", ret);
-
- return ret;
-}
-
-PKGMGR_MODULE_API
-int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *md_list)
-{
- int ret;
-
- DBG("PKGMGR_MDPARSER_PLUGIN_INSTALL called");
-
-// ret = net_nfc_client_initialize();
-// if (ret != 0) {
-// DBG("net_nfc_client_initialize() [%d]", ret);
-// return ret;
-// }
-
- ret = __install(pkgid, appid, md_list);
-
-// net_nfc_client_deinitialize();
-
- return ret;
-}
-
-
-PKGMGR_MODULE_API
-int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList *md_list)
-{
- int ret;
-
- DBG("PKGMGR_MDPARSER_PLUGIN_UNINSTALL called");
-
-// ret = net_nfc_client_initialize();
-// if (ret != 0) {
-// DBG("net_nfc_client_initialize() [%d]", ret);
-// return ret;
-// }
-
- ret = __uninstall(pkgid, appid, md_list);
-
-// net_nfc_client_deinitialize();
-
- return ret;
-}
-
-PKGMGR_MODULE_API
-int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgid, const char *appid, GList *list)
-{
- int ret;
-
- DBG("PKGMGR_MDPARSER_PLUGIN_UPGRADE called");
-
-// ret = net_nfc_client_initialize();
-// if (ret != 0) {
-// DBG("net_nfc_client_initialize() [%d]", ret);
-// return ret;
-// }
-
- ret = __uninstall(pkgid, appid, list);
- if (ret != 0) {
- DBG("__uninstall() [%d]", ret);
- } else {
- DBG("__uninstall() success");
- }
-
- ret = __install(pkgid, appid, list);
- if (ret != 0) {
- DBG("__install() [%d]", ret);
- } else {
- DBG("__install() success");
- }
-
-// net_nfc_client_deinitialize();
-
- return ret;
-}